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 FormControlElement
;
31 class TextControlInnerElement
;
32 class TextControlInnerTextElement
;
34 class RenderTextControl
: public RenderBlock
{
36 virtual ~RenderTextControl();
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; }
48 virtual bool isEdited() const { return m_edited
; }
49 virtual void setEdited(bool isEdited
) { m_edited
= isEdited
; }
51 bool isUserEdited() const { return m_userEdited
; }
52 void setUserEdited(bool isUserEdited
);
56 void setSelectionStart(int);
57 void setSelectionEnd(int);
59 void setSelectionRange(int start
, int end
);
60 Selection
selection(int start
, int end
) const;
62 virtual void subtreeHasChanged();
64 String
textWithHardLineBreaks();
65 void selectionChanged(bool userTriggered
);
67 virtual void addFocusRingRects(GraphicsContext
*, int tx
, int ty
);
69 virtual bool canBeProgramaticallyScrolled(bool) const { return true; }
70 virtual void autoscroll();
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
);
81 bool canScroll() const;
83 // Returns the line height of the inner renderer.
84 virtual int innerLineHeight() const;
86 VisiblePosition
visiblePositionForIndex(int index
);
87 int indexForVisiblePosition(const VisiblePosition
&);
90 RenderTextControl(Node
*);
92 int scrollbarThickness() const;
93 void adjustInnerTextStyle(const RenderStyle
* startStyle
, RenderStyle
* textBlockStyle
) const;
94 void setInnerTextValue(const String
&);
96 virtual void styleDidChange(StyleDifference
, const RenderStyle
* oldStyle
);
98 void createSubtreeIfNeeded(TextControlInnerElement
* innerBlock
);
99 void hitInnerTextElement(HitTestResult
&, int x
, int y
, int tx
, int ty
);
100 void forwardEvent(Event
*);
102 int textBlockWidth() const;
103 int textBlockHeight() const;
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;
110 friend class TextIterator
;
111 HTMLElement
* innerTextElement() const;
113 FormControlElement
* formControlElement() const;
116 String
finishText(Vector
<UChar
>&) const;
120 RefPtr
<TextControlInnerTextElement
> m_innerText
;
123 } // namespace WebCore
125 #endif // RenderTextControl_h