OLD | NEW |
1 /* | 1 /* |
2 * This file is part of the select element renderer in WebCore. | 2 * This file is part of the select element renderer in WebCore. |
3 * | 3 * |
4 * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved. | 4 * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 14 matching lines...) Expand all Loading... |
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef RenderListBox_h | 31 #ifndef RenderListBox_h |
32 #define RenderListBox_h | 32 #define RenderListBox_h |
33 | 33 |
34 #include "RenderBlock.h" | 34 #include "RenderBlock.h" |
35 #include "ScrollableArea.h" | |
36 | 35 |
37 namespace WebCore { | 36 namespace WebCore { |
38 | 37 |
39 class HTMLSelectElement; | 38 class HTMLSelectElement; |
40 | 39 |
41 class RenderListBox : public RenderBlock, private ScrollableArea { | 40 class RenderListBox : public RenderBlock { |
42 public: | 41 public: |
43 explicit RenderListBox(Element*); | 42 explicit RenderListBox(Element*); |
44 virtual ~RenderListBox(); | 43 virtual ~RenderListBox(); |
45 | 44 |
46 void selectionChanged(); | |
47 | |
48 void setOptionsChanged(bool changed) { m_optionsChanged = changed; } | |
49 | |
50 int listIndexAtOffset(const LayoutSize&); | |
51 LayoutRect itemBoundingBoxRect(const LayoutPoint&, int index); | |
52 | |
53 bool scrollToRevealElementAtListIndex(int index); | |
54 bool listIndexIsVisible(int index); | |
55 | |
56 int scrollToward(const IntPoint&); // Returns the new index or -1 if no scro
ll occurred | |
57 | |
58 int size() const; | 45 int size() const; |
59 | 46 |
60 private: | 47 private: |
61 HTMLSelectElement* selectElement() const; | 48 HTMLSelectElement* selectElement() const; |
62 | 49 |
63 virtual const char* renderName() const { return "RenderListBox"; } | 50 virtual const char* renderName() const { return "RenderListBox"; } |
64 | 51 |
65 virtual bool isListBox() const { return true; } | 52 virtual bool isListBox() const { return true; } |
66 | |
67 virtual void updateFromElement(); | |
68 virtual bool canBeReplacedWithInlineRunIn() const OVERRIDE; | |
69 virtual bool hasControlClip() const { return true; } | |
70 virtual void paintObject(PaintInfo&, const LayoutPoint&); | |
71 virtual LayoutRect controlClipRect(const LayoutPoint&) const; | |
72 | |
73 virtual bool isPointInOverflowControl(HitTestResult&, const LayoutPoint& loc
ationInContainer, const LayoutPoint& accumulatedOffset); | |
74 | |
75 virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1
, Node** stopNode = 0); | |
76 virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float
multiplier = 1, Node** stopNode = 0); | |
77 | |
78 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo
utUnit& maxLogicalWidth) const OVERRIDE; | |
79 virtual void computePreferredLogicalWidths() OVERRIDE; | |
80 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode
, LinePositionMode = PositionOnContainingLine) const; | |
81 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic
alTop, LogicalExtentComputedValues&) const OVERRIDE; | 53 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic
alTop, LogicalExtentComputedValues&) const OVERRIDE; |
82 | |
83 virtual void layout(); | |
84 | |
85 virtual void addFocusRingRects(Vector<IntRect>&, const LayoutPoint& addition
alOffset, const RenderLayerModelObject* paintContainer = 0) OVERRIDE; | |
86 | |
87 virtual bool canBeProgramaticallyScrolled() const { return true; } | |
88 virtual void autoscroll(const IntPoint&); | |
89 virtual void stopAutoscroll(); | |
90 | |
91 virtual bool shouldPanScroll() const { return true; } | |
92 virtual void panScroll(const IntPoint&); | |
93 | |
94 virtual int verticalScrollbarWidth() const; | |
95 virtual int scrollLeft() const; | |
96 virtual int scrollTop() const; | |
97 virtual int scrollWidth() const; | |
98 virtual int scrollHeight() const; | |
99 virtual void setScrollLeft(int); | |
100 virtual void setScrollTop(int); | |
101 | |
102 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTes
tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAct
ion) OVERRIDE; | |
103 | |
104 // ScrollableArea interface. | |
105 virtual int scrollSize(ScrollbarOrientation) const OVERRIDE; | |
106 virtual int scrollPosition(Scrollbar*) const OVERRIDE; | |
107 virtual void setScrollOffset(const IntPoint&) OVERRIDE; | |
108 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) OVERRIDE; | |
109 virtual bool isActive() const OVERRIDE; | |
110 virtual bool isScrollCornerVisible() const OVERRIDE { return false; } // We
don't support resize on list boxes yet. If we did these would have to change. | |
111 virtual IntRect scrollCornerRect() const OVERRIDE { return IntRect(); } | |
112 virtual void invalidateScrollCornerRect(const IntRect&) OVERRIDE { } | |
113 virtual IntRect convertFromScrollbarToContainingView(const Scrollbar*, const
IntRect&) const OVERRIDE; | |
114 virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar*, const
IntRect&) const OVERRIDE; | |
115 virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar*, cons
t IntPoint&) const OVERRIDE; | |
116 virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar*, cons
t IntPoint&) const OVERRIDE; | |
117 virtual Scrollbar* verticalScrollbar() const OVERRIDE { return m_vBar.get();
} | |
118 virtual IntSize contentsSize() const OVERRIDE; | |
119 virtual int visibleHeight() const OVERRIDE; | |
120 virtual int visibleWidth() const OVERRIDE; | |
121 virtual IntPoint lastKnownMousePosition() const OVERRIDE; | |
122 virtual bool shouldSuspendScrollAnimations() const OVERRIDE; | |
123 virtual bool scrollbarsCanBeActive() const OVERRIDE; | |
124 | |
125 virtual ScrollableArea* enclosingScrollableArea() const OVERRIDE; | |
126 virtual IntRect scrollableAreaBoundingBox() const OVERRIDE; | |
127 | |
128 // NOTE: This should only be called by the overriden setScrollOffset from Sc
rollableArea. | |
129 void scrollTo(int newOffset); | |
130 | |
131 void setHasVerticalScrollbar(bool hasScrollbar); | |
132 PassRefPtr<Scrollbar> createScrollbar(); | |
133 void destroyScrollbar(); | |
134 | |
135 LayoutUnit itemHeight() const; | 54 LayoutUnit itemHeight() const; |
136 void valueChanged(unsigned listIndex); | 55 virtual bool canBeProgramaticallyScrolled() const OVERRIDE { return true; } |
137 int numVisibleItems() const; | |
138 int numItems() const; | |
139 LayoutUnit listHeight() const; | |
140 void paintScrollbar(PaintInfo&, const LayoutPoint&); | |
141 void paintItemForeground(PaintInfo&, const LayoutPoint&, int listIndex); | |
142 void paintItemBackground(PaintInfo&, const LayoutPoint&, int listIndex); | |
143 void scrollToRevealSelection(); | |
144 | |
145 bool m_optionsChanged; | |
146 bool m_scrollToRevealSelectionAfterLayout; | |
147 bool m_inAutoscroll; | |
148 int m_optionsWidth; | |
149 int m_indexOffset; | |
150 | |
151 RefPtr<Scrollbar> m_vBar; | |
152 }; | 56 }; |
153 | 57 |
154 inline RenderListBox* toRenderListBox(RenderObject* object) | 58 inline RenderListBox* toRenderListBox(RenderObject* object) |
155 { | 59 { |
156 ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isListBox()); | 60 ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isListBox()); |
157 return static_cast<RenderListBox*>(object); | 61 return static_cast<RenderListBox*>(object); |
158 } | 62 } |
159 | 63 |
160 // This will catch anyone doing an unnecessary cast. | 64 // This will catch anyone doing an unnecessary cast. |
161 void toRenderListBox(const RenderListBox*); | 65 void toRenderListBox(const RenderListBox*); |
162 | 66 |
163 } // namepace WebCore | 67 } // namepace WebCore |
164 | 68 |
165 #endif // RenderListBox_h | 69 #endif // RenderListBox_h |
OLD | NEW |