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 explicit RenderTextControlSingleLine(HTMLInputElement&);
36 virtual ~RenderTextControlSingleLine();
37 // FIXME: Move create*Style() to their classes.
38 virtual PassRef<RenderStyle> createInnerTextStyle(const RenderStyle* startStyle) const OVERRIDE;
39 PassRef<RenderStyle> createInnerBlockStyle(const RenderStyle* startStyle) const;
41 void capsLockStateMayHaveChanged();
44 virtual void centerContainerIfNeeded(RenderBox*) const { }
45 virtual LayoutUnit computeLogicalHeightLimit() const;
46 HTMLElement* containerElement() const;
47 HTMLElement* innerBlockElement() const;
48 HTMLInputElement& inputElement() const;
51 void textFormControlElement() const WTF_DELETED_FUNCTION;
53 virtual bool hasControlClip() const OVERRIDE;
54 virtual LayoutRect controlClipRect(const LayoutPoint&) const OVERRIDE;
55 virtual bool isTextField() const OVERRIDE FINAL { return true; }
57 virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE;
58 virtual void layout() OVERRIDE;
60 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
62 virtual void autoscroll(const IntPoint&) OVERRIDE;
64 // Subclassed to forward to our inner div.
65 virtual int scrollLeft() const OVERRIDE;
66 virtual int scrollTop() const OVERRIDE;
67 virtual int scrollWidth() const OVERRIDE;
68 virtual int scrollHeight() const OVERRIDE;
69 virtual void setScrollLeft(int) OVERRIDE;
70 virtual void setScrollTop(int) OVERRIDE;
71 virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = 0) OVERRIDE FINAL;
72 virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = 0) OVERRIDE FINAL;
74 int textBlockWidth() const;
75 virtual float getAvgCharWidth(AtomicString family) OVERRIDE;
76 virtual LayoutUnit preferredContentLogicalWidth(float charWidth) const OVERRIDE;
77 virtual LayoutUnit computeControlLogicalHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const OVERRIDE;
79 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE;
81 virtual RenderStyle* textBaseStyle() const OVERRIDE;
83 bool textShouldBeTruncated() const;
85 HTMLElement* innerSpinButtonElement() const;
87 bool m_shouldDrawCapsLockIndicator;
88 LayoutUnit m_desiredInnerTextLogicalHeight;
91 inline HTMLElement* RenderTextControlSingleLine::containerElement() const
93 return inputElement().containerElement();
96 inline HTMLElement* RenderTextControlSingleLine::innerBlockElement() const
98 return inputElement().innerBlockElement();
101 RENDER_OBJECT_TYPE_CASTS(RenderTextControlSingleLine, isTextField())
103 // ----------------------------
105 class RenderTextControlInnerBlock FINAL : public RenderBlockFlow {
107 RenderTextControlInnerBlock(Element& element)
108 : RenderBlockFlow(element)
113 virtual bool hasLineIfEmpty() const OVERRIDE { return true; }
114 virtual bool isTextControlInnerBlock() const OVERRIDE { return true; }
117 RENDER_OBJECT_TYPE_CASTS(RenderTextControlInnerBlock, isTextControlInnerBlock())