]> git.saurik.com Git - iphone-api.git/blob - WebCore/RenderTextControl.h
Add support for new WinterBoard Settings features.
[iphone-api.git] / WebCore / 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 FormControlElement;
30 class Selection;
31 class TextControlInnerElement;
32 class TextControlInnerTextElement;
33
34 class RenderTextControl : public RenderBlock {
35 public:
36 virtual ~RenderTextControl();
37
38 virtual const char* renderName() const { return "RenderTextControl"; }
39 virtual bool hasControlClip() const { return false; }
40 virtual IntRect controlClipRect(int tx, int ty) const;
41 virtual void calcHeight();
42 virtual void calcPrefWidths();
43 virtual void removeLeftoverAnonymousBlock(RenderBlock*) { }
44 virtual void updateFromElement();
45 virtual bool canHaveChildren() const { return false; }
46 virtual bool avoidsFloats() const { return true; }
47
48 virtual bool isEdited() const { return m_edited; }
49 virtual void setEdited(bool isEdited) { m_edited = isEdited; }
50
51 bool isUserEdited() const { return m_userEdited; }
52 void setUserEdited(bool isUserEdited);
53
54 int selectionStart();
55 int selectionEnd();
56 void setSelectionStart(int);
57 void setSelectionEnd(int);
58 void select();
59 void setSelectionRange(int start, int end);
60 Selection selection(int start, int end) const;
61
62 virtual void subtreeHasChanged();
63 String text();
64 String textWithHardLineBreaks();
65 void selectionChanged(bool userTriggered);
66
67 virtual void addFocusRingRects(GraphicsContext*, int tx, int ty);
68
69 virtual bool canBeProgramaticallyScrolled(bool) const { return true; }
70 virtual void autoscroll();
71
72 // Subclassed to forward to our inner div.
73 virtual int scrollLeft() const;
74 virtual int scrollTop() const;
75 virtual int scrollWidth() const;
76 virtual int scrollHeight() const;
77 virtual void setScrollLeft(int);
78 virtual void setScrollTop(int);
79 virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f);
80
81 bool canScroll() const;
82
83 // Returns the line height of the inner renderer.
84 virtual int innerLineHeight() const;
85
86 VisiblePosition visiblePositionForIndex(int index);
87 int indexForVisiblePosition(const VisiblePosition&);
88
89 protected:
90 RenderTextControl(Node*);
91
92 int scrollbarThickness() const;
93 void adjustInnerTextStyle(const RenderStyle* startStyle, RenderStyle* textBlockStyle) const;
94 void setInnerTextValue(const String&);
95
96 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
97
98 void createSubtreeIfNeeded(TextControlInnerElement* innerBlock);
99 void hitInnerTextElement(HitTestResult&, int x, int y, int tx, int ty);
100 void forwardEvent(Event*);
101
102 int textBlockWidth() const;
103 int textBlockHeight() const;
104
105 virtual int preferredContentWidth(float charWidth) const = 0;
106 virtual void adjustControlHeightBasedOnLineHeight(int lineHeight) = 0;
107 virtual void cacheSelection(int start, int end) = 0;
108 virtual PassRefPtr<RenderStyle> createInnerTextStyle(const RenderStyle* startStyle) const = 0;
109
110 friend class TextIterator;
111 HTMLElement* innerTextElement() const;
112
113 FormControlElement* formControlElement() const;
114
115 private:
116 String finishText(Vector<UChar>&) const;
117
118 bool m_edited;
119 bool m_userEdited;
120 RefPtr<TextControlInnerTextElement> m_innerText;
121 };
122
123 } // namespace WebCore
124
125 #endif // RenderTextControl_h