Fix the issue that Web Audio test case fails on PR3.
[framework/web/webkit-efl.git] / Source / WebCore / rendering / RenderTextControl.h
1 /*
2  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3  *           (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) 
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB.  If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  *
20  */
21
22 #ifndef RenderTextControl_h
23 #define RenderTextControl_h
24
25 #include "RenderBlock.h"
26
27 namespace WebCore {
28
29 class HTMLTextFormControlElement;
30
31 class RenderTextControl : public RenderBlock {
32 public:
33     virtual ~RenderTextControl();
34
35     HTMLTextFormControlElement* textFormControlElement() const;
36     virtual PassRefPtr<RenderStyle> createInnerTextStyle(const RenderStyle* startStyle) const = 0;
37
38     VisiblePosition visiblePositionForIndex(int index) const;
39
40 protected:
41     RenderTextControl(Node*);
42
43     // This convenience function should not be made public because innerTextElement may outlive the render tree.
44     HTMLElement* innerTextElement() const;
45
46     int scrollbarThickness() const;
47     void adjustInnerTextStyle(const RenderStyle* startStyle, RenderStyle* textBlockStyle) const;
48
49     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
50
51     void hitInnerTextElement(HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset);
52
53     int textBlockWidth() const;
54     int textBlockHeight() const;
55
56     float scaleEmToUnits(int x) const;
57
58     static bool hasValidAvgCharWidth(AtomicString family);
59     virtual float getAvgCharWidth(AtomicString family);
60     virtual LayoutUnit preferredContentWidth(float charWidth) const = 0;
61     virtual LayoutUnit computeControlHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const = 0;
62     virtual RenderStyle* textBaseStyle() const = 0;
63
64     virtual void updateFromElement();
65     virtual void computeLogicalHeight();
66     virtual RenderObject* layoutSpecialExcludedChild(bool relayoutChildren);
67
68 private:
69     virtual const char* renderName() const { return "RenderTextControl"; }
70     virtual bool isTextControl() const { return true; }
71     virtual void computePreferredLogicalWidths();
72     virtual void removeLeftoverAnonymousBlock(RenderBlock*) { }
73     virtual bool avoidsFloats() const { return true; }
74     virtual bool canHaveGeneratedChildren() const OVERRIDE { return false; }
75     
76     virtual void addFocusRingRects(Vector<IntRect>&, const LayoutPoint&);
77
78     virtual bool canBeProgramaticallyScrolled() const { return true; }
79
80     virtual bool requiresForcedStyleRecalcPropagation() const { return true; }
81
82     static bool isSelectableElement(HTMLElement*, Node*);
83 };
84
85 inline RenderTextControl* toRenderTextControl(RenderObject* object)
86
87     ASSERT(!object || object->isTextControl());
88     return static_cast<RenderTextControl*>(object);
89 }
90
91 inline const RenderTextControl* toRenderTextControl(const RenderObject* object)
92
93     ASSERT(!object || object->isTextControl());
94     return static_cast<const RenderTextControl*>(object);
95 }
96
97 // This will catch anyone doing an unnecessary cast.
98 void toRenderTextControl(const RenderTextControl*);
99
100 } // namespace WebCore
101
102 #endif // RenderTextControl_h