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 "core/rendering/RenderBlockFlow.h" | 34 #include "core/rendering/RenderBlockFlow.h" |
35 #include "platform/scroll/ScrollableArea.h" | |
36 | 35 |
37 namespace WebCore { | 36 namespace WebCore { |
38 | 37 |
39 class HTMLSelectElement; | 38 class HTMLSelectElement; |
40 | 39 |
41 class RenderListBox FINAL : public RenderBlockFlow, private ScrollableArea { | 40 class RenderListBox FINAL : public RenderBlockFlow { |
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&) const; | |
51 LayoutRect itemBoundingBoxRect(const LayoutPoint&, int index) const; | |
52 | |
53 bool scrollToRevealElementAtListIndex(int index); | |
54 | |
55 int scrollToward(const IntPoint&); // Returns the new index or -1 if no scro
ll occurred | |
56 | |
57 int size() const; | 45 int size() const; |
58 | 46 |
59 void repaintScrollbarIfNeeded(); | 47 void repaintScrollbarIfNeeded(); |
60 | 48 |
61 private: | 49 private: |
62 HTMLSelectElement* selectElement() const; | 50 HTMLSelectElement* selectElement() const; |
63 | 51 |
64 virtual const char* renderName() const OVERRIDE { return "RenderListBox"; } | 52 virtual const char* renderName() const OVERRIDE { return "RenderListBox"; } |
65 | 53 |
66 virtual bool isListBox() const OVERRIDE { return true; } | 54 virtual bool isListBox() const OVERRIDE { return true; } |
67 virtual bool isChildAllowed(RenderObject*, RenderStyle*) const OVERRIDE; | |
68 | 55 |
69 virtual void updateFromElement() OVERRIDE; | |
70 virtual bool hasControlClip() const OVERRIDE { return true; } | |
71 virtual void paintObject(PaintInfo&, const LayoutPoint&) OVERRIDE; | |
72 virtual LayoutRect controlClipRect(const LayoutPoint&) const OVERRIDE; | |
73 | |
74 virtual bool isPointInOverflowControl(HitTestResult&, const LayoutPoint& loc
ationInContainer, const LayoutPoint& accumulatedOffset) OVERRIDE; | |
75 | |
76 virtual bool scroll(ScrollDirection, ScrollGranularity, float) OVERRIDE; | |
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 OVERRIDE; | |
81 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic
alTop, LogicalExtentComputedValues&) const OVERRIDE; | 56 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic
alTop, LogicalExtentComputedValues&) const OVERRIDE; |
82 | 57 |
83 virtual void layout() OVERRIDE; | |
84 | |
85 virtual void invalidateTreeIfNeeded(const PaintInvalidationState&) OVERRIDE
FINAL; | |
86 | |
87 virtual void addFocusRingRects(Vector<IntRect>&, const LayoutPoint& addition
alOffset, const RenderLayerModelObject* paintContainer = 0) OVERRIDE; | |
88 | |
89 virtual bool canBeProgramaticallyScrolled() const OVERRIDE { return true; } | |
90 virtual void autoscroll(const IntPoint&) OVERRIDE; | |
91 virtual void stopAutoscroll() OVERRIDE; | 58 virtual void stopAutoscroll() OVERRIDE; |
92 | 59 |
93 virtual void panScroll(const IntPoint&) OVERRIDE; | |
94 | |
95 virtual int verticalScrollbarWidth() const OVERRIDE; | |
96 virtual LayoutUnit scrollLeft() const OVERRIDE; | |
97 virtual LayoutUnit scrollTop() const OVERRIDE; | |
98 virtual LayoutUnit scrollWidth() const OVERRIDE; | |
99 virtual LayoutUnit scrollHeight() const OVERRIDE; | |
100 virtual void setScrollLeft(LayoutUnit) OVERRIDE; | |
101 virtual void setScrollTop(LayoutUnit) OVERRIDE; | |
102 | |
103 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTes
tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAct
ion) OVERRIDE; | |
104 | |
105 // ScrollableArea interface. | |
106 virtual int scrollSize(ScrollbarOrientation) const OVERRIDE; | |
107 virtual IntPoint scrollPosition() const OVERRIDE; | |
108 virtual void setScrollOffset(const IntPoint&) OVERRIDE; | |
109 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) OVERRIDE; | |
110 virtual bool isActive() const OVERRIDE; | |
111 virtual bool isScrollCornerVisible() const OVERRIDE { return false; } // We
don't support resize on list boxes yet. If we did these would have to change. | |
112 virtual IntRect scrollCornerRect() const OVERRIDE { return IntRect(); } | |
113 virtual void invalidateScrollCornerRect(const IntRect&) OVERRIDE { } | |
114 virtual IntRect convertFromScrollbarToContainingView(const Scrollbar*, const
IntRect&) const OVERRIDE; | |
115 virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar*, const
IntRect&) const OVERRIDE; | |
116 virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar*, cons
t IntPoint&) const OVERRIDE; | |
117 virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar*, cons
t IntPoint&) const OVERRIDE; | |
118 virtual Scrollbar* verticalScrollbar() const OVERRIDE { return m_vBar.get();
} | |
119 virtual IntSize contentsSize() const OVERRIDE; | |
120 virtual int visibleHeight() const OVERRIDE; | |
121 virtual int visibleWidth() const OVERRIDE; | |
122 virtual IntPoint lastKnownMousePosition() const OVERRIDE; | |
123 virtual bool shouldSuspendScrollAnimations() const OVERRIDE; | |
124 virtual bool scrollbarsCanBeActive() const OVERRIDE; | |
125 virtual IntPoint minimumScrollPosition() const OVERRIDE; | |
126 virtual IntPoint maximumScrollPosition() const OVERRIDE; | |
127 virtual bool userInputScrollable(ScrollbarOrientation) const OVERRIDE; | |
128 virtual bool shouldPlaceVerticalScrollbarOnLeft() const OVERRIDE; | |
129 virtual int lineStep(ScrollbarOrientation) const OVERRIDE; | |
130 virtual int pageStep(ScrollbarOrientation) const OVERRIDE; | |
131 virtual float pixelStep(ScrollbarOrientation) const OVERRIDE; | |
132 virtual IntRect scrollableAreaBoundingBox() const OVERRIDE; | |
133 | |
134 LayoutRect itemBoundingBoxRectInternal(const LayoutPoint&, int index) const; | |
135 bool scrollToRevealElementAtListIndexInternal(int index); | |
136 | |
137 // NOTE: This should only be called by the overriden setScrollOffset from Sc
rollableArea. | |
138 void scrollTo(int newOffset); | |
139 | |
140 void setHasVerticalScrollbar(bool hasScrollbar); | 60 void setHasVerticalScrollbar(bool hasScrollbar); |
141 PassRefPtr<Scrollbar> createScrollbar(); | 61 PassRefPtr<Scrollbar> createScrollbar(); |
142 void destroyScrollbar(); | 62 void destroyScrollbar(); |
143 | 63 |
| 64 LayoutUnit defaultItemHeight() const; |
144 LayoutUnit itemHeight() const; | 65 LayoutUnit itemHeight() const; |
145 int numVisibleItems() const; | |
146 bool listIndexIsVisible(int index) const; | |
147 int numItems() const; | |
148 LayoutUnit listHeight() const; | |
149 int scrollbarLeft() const; | |
150 void paintScrollbar(PaintInfo&, const LayoutPoint&); | |
151 void paintItemForeground(PaintInfo&, const LayoutPoint&, int listIndex); | |
152 void paintItemBackground(PaintInfo&, const LayoutPoint&, int listIndex); | |
153 void scrollToRevealSelection(); | |
154 | |
155 int renderListBoxIndexToListIndex(int index) const; | |
156 int listIndexToRenderListBoxIndex(int index) const; | |
157 | |
158 bool m_optionsChanged; | |
159 bool m_scrollToRevealSelectionAfterLayout; | |
160 bool m_inAutoscroll; | |
161 int m_optionsWidth; | |
162 int m_indexOffset; | |
163 int m_listItemCount; | |
164 | |
165 RefPtr<Scrollbar> m_vBar; | |
166 }; | 66 }; |
167 | 67 |
168 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderListBox, isListBox()); | 68 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderListBox, isListBox()); |
169 | 69 |
170 } // namepace WebCore | 70 } // namepace WebCore |
171 | 71 |
172 #endif // RenderListBox_h | 72 #endif // RenderListBox_h |
OLD | NEW |