2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3 * (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
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.
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.
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.
22 #ifndef RenderTextControl_h
23 #define RenderTextControl_h
25 #include "RenderBlock.h"
29 class HTMLTextFormControlElement;
31 class RenderTextControl : public RenderBlock {
33 virtual ~RenderTextControl();
35 HTMLTextFormControlElement* textFormControlElement() const;
36 virtual PassRefPtr<RenderStyle> createInnerTextStyle(const RenderStyle* startStyle) const = 0;
38 VisiblePosition visiblePositionForIndex(int index) const;
41 RenderTextControl(Node*);
43 // This convenience function should not be made public because innerTextElement may outlive the render tree.
44 HTMLElement* innerTextElement() const;
46 int scrollbarThickness() const;
47 void adjustInnerTextStyle(const RenderStyle* startStyle, RenderStyle* textBlockStyle) const;
49 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
51 void hitInnerTextElement(HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset);
53 int textBlockWidth() const;
54 int textBlockHeight() const;
56 float scaleEmToUnits(int x) const;
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;
64 virtual void updateFromElement();
65 virtual void computeLogicalHeight();
66 virtual RenderObject* layoutSpecialExcludedChild(bool relayoutChildren);
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; }
76 virtual void addFocusRingRects(Vector<IntRect>&, const LayoutPoint&);
78 virtual bool canBeProgramaticallyScrolled() const { return true; }
80 virtual bool requiresForcedStyleRecalcPropagation() const { return true; }
82 static bool isSelectableElement(HTMLElement*, Node*);
85 inline RenderTextControl* toRenderTextControl(RenderObject* object)
87 ASSERT(!object || object->isTextControl());
88 return static_cast<RenderTextControl*>(object);
91 inline const RenderTextControl* toRenderTextControl(const RenderObject* object)
93 ASSERT(!object || object->isTextControl());
94 return static_cast<const RenderTextControl*>(object);
97 // This will catch anyone doing an unnecessary cast.
98 void toRenderTextControl(const RenderTextControl*);
100 } // namespace WebCore
102 #endif // RenderTextControl_h