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).
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.
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.
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.
23 #ifndef RenderTextControlSingleLine_h
24 #define RenderTextControlSingleLine_h
26 #include "HTMLInputElement.h"
27 #include "RenderTextControl.h"
31 class HTMLInputElement;
33 class RenderTextControlSingleLine : public RenderTextControl {
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;
41 void capsLockStateMayHaveChanged();
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;
52 virtual bool hasControlClip() const;
53 virtual LayoutRect controlClipRect(const LayoutPoint&) const;
54 virtual bool isTextField() const { return true; }
56 virtual void paint(PaintInfo&, const LayoutPoint&);
57 virtual void layout();
59 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
61 virtual void autoscroll();
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);
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;
78 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
80 virtual RenderStyle* textBaseStyle() const;
82 bool textShouldBeTruncated() const;
84 HTMLElement* innerSpinButtonElement() const;
86 bool m_shouldDrawCapsLockIndicator;
87 LayoutUnit m_desiredInnerTextHeight;
90 inline HTMLElement* RenderTextControlSingleLine::containerElement() const
92 return inputElement()->containerElement();
95 inline HTMLElement* RenderTextControlSingleLine::innerBlockElement() const
97 return inputElement()->innerBlockElement();
100 inline RenderTextControlSingleLine* toRenderTextControlSingleLine(RenderObject* object)
102 ASSERT(!object || object->isTextField());
103 return static_cast<RenderTextControlSingleLine*>(object);
106 // This will catch anyone doing an unnecessary cast.
107 void toRenderTextControlSingleLine(const RenderTextControlSingleLine*);
109 // ----------------------------
111 class RenderTextControlInnerBlock : public RenderBlock {
113 RenderTextControlInnerBlock(Node* node, bool isMultiLine) : RenderBlock(node), m_multiLine(isMultiLine) { }
116 virtual bool hasLineIfEmpty() const { return true; }
117 virtual VisiblePosition positionForPoint(const LayoutPoint&);