Fix the issue that Web Audio test case fails on PR3.
[framework/web/webkit-efl.git] / Source / WebCore / rendering / RenderTextControlSingleLine.h
1 /*
2  * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
3  * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
4  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB.  If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  */
22
23 #ifndef RenderTextControlSingleLine_h
24 #define RenderTextControlSingleLine_h
25
26 #include "HTMLInputElement.h"
27 #include "RenderTextControl.h"
28
29 namespace WebCore {
30
31 class HTMLInputElement;
32
33 class RenderTextControlSingleLine : public RenderTextControl {
34 public:
35     RenderTextControlSingleLine(Node*);
36     virtual ~RenderTextControlSingleLine();
37     // FIXME: Move create*Style() to their classes.
38     virtual PassRefPtr<RenderStyle> createInnerTextStyle(const RenderStyle* startStyle) const;
39     PassRefPtr<RenderStyle> createInnerBlockStyle(const RenderStyle* startStyle) const;
40
41     void capsLockStateMayHaveChanged();
42
43 protected:
44     virtual void centerContainerIfNeeded(RenderBox*) const { }
45     virtual LayoutUnit computeHeightLimit() const;
46     HTMLElement* containerElement() const;
47     HTMLElement* innerBlockElement() const;
48     HTMLInputElement* inputElement() const;
49     virtual void updateFromElement() OVERRIDE;
50
51 private:
52     virtual bool hasControlClip() const;
53     virtual LayoutRect controlClipRect(const LayoutPoint&) const;
54     virtual bool isTextField() const { return true; }
55
56     virtual void paint(PaintInfo&, const LayoutPoint&);
57     virtual void layout();
58
59     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
60
61     virtual void autoscroll();
62
63     // Subclassed to forward to our inner div.
64     virtual int scrollLeft() const;
65     virtual int scrollTop() const;
66     virtual int scrollWidth() const;
67     virtual int scrollHeight() const;
68     virtual void setScrollLeft(int);
69     virtual void setScrollTop(int);
70     virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
71     virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
72
73     int textBlockWidth() const;
74     virtual float getAvgCharWidth(AtomicString family);
75     virtual LayoutUnit preferredContentWidth(float charWidth) const;
76     virtual LayoutUnit computeControlHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const OVERRIDE;
77     
78     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
79
80     virtual RenderStyle* textBaseStyle() const;
81
82     bool textShouldBeTruncated() const;
83
84     HTMLElement* innerSpinButtonElement() const;
85
86     bool m_shouldDrawCapsLockIndicator;
87     LayoutUnit m_desiredInnerTextHeight;
88 };
89
90 inline HTMLElement* RenderTextControlSingleLine::containerElement() const
91 {
92     return inputElement()->containerElement();
93 }
94
95 inline HTMLElement* RenderTextControlSingleLine::innerBlockElement() const
96 {
97     return inputElement()->innerBlockElement();
98 }
99
100 inline RenderTextControlSingleLine* toRenderTextControlSingleLine(RenderObject* object)
101 {
102     ASSERT(!object || object->isTextField());
103     return static_cast<RenderTextControlSingleLine*>(object);
104 }
105
106 // This will catch anyone doing an unnecessary cast.
107 void toRenderTextControlSingleLine(const RenderTextControlSingleLine*);
108
109 // ----------------------------
110
111 class RenderTextControlInnerBlock : public RenderBlock {
112 public:
113     RenderTextControlInnerBlock(Node* node, bool isMultiLine) : RenderBlock(node), m_multiLine(isMultiLine) { }
114
115 private:
116     virtual bool hasLineIfEmpty() const { return true; }
117     virtual VisiblePosition positionForPoint(const LayoutPoint&);
118
119     bool m_multiLine;
120 };
121
122 }
123
124 #endif