OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008, 2009 Apple Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "core/rendering/RenderScrollbar.h" | 27 #include "core/layout/LayoutScrollbar.h" |
28 | 28 |
29 #include "core/css/PseudoStyleRequest.h" | 29 #include "core/css/PseudoStyleRequest.h" |
30 #include "core/frame/FrameView.h" | 30 #include "core/frame/FrameView.h" |
31 #include "core/frame/LocalFrame.h" | 31 #include "core/frame/LocalFrame.h" |
32 #include "core/layout/LayoutPart.h" | 32 #include "core/layout/LayoutPart.h" |
33 #include "core/rendering/RenderScrollbarPart.h" | 33 #include "core/layout/LayoutScrollbarPart.h" |
34 #include "core/rendering/RenderScrollbarTheme.h" | 34 #include "core/layout/LayoutScrollbarTheme.h" |
35 #include "platform/graphics/GraphicsContext.h" | 35 #include "platform/graphics/GraphicsContext.h" |
36 | 36 |
37 namespace blink { | 37 namespace blink { |
38 | 38 |
39 PassRefPtrWillBeRawPtr<Scrollbar> RenderScrollbar::createCustomScrollbar(Scrolla
bleArea* scrollableArea, ScrollbarOrientation orientation, Node* ownerNode, Loca
lFrame* owningFrame) | 39 PassRefPtrWillBeRawPtr<Scrollbar> LayoutScrollbar::createCustomScrollbar(Scrolla
bleArea* scrollableArea, ScrollbarOrientation orientation, Node* ownerNode, Loca
lFrame* owningFrame) |
40 { | 40 { |
41 return adoptRefWillBeNoop(new RenderScrollbar(scrollableArea, orientation, o
wnerNode, owningFrame)); | 41 return adoptRefWillBeNoop(new LayoutScrollbar(scrollableArea, orientation, o
wnerNode, owningFrame)); |
42 } | 42 } |
43 | 43 |
44 RenderScrollbar::RenderScrollbar(ScrollableArea* scrollableArea, ScrollbarOrient
ation orientation, Node* ownerNode, LocalFrame* owningFrame) | 44 LayoutScrollbar::LayoutScrollbar(ScrollableArea* scrollableArea, ScrollbarOrient
ation orientation, Node* ownerNode, LocalFrame* owningFrame) |
45 : Scrollbar(scrollableArea, orientation, RegularScrollbar, RenderScrollbarTh
eme::renderScrollbarTheme()) | 45 : Scrollbar(scrollableArea, orientation, RegularScrollbar, LayoutScrollbarTh
eme::renderScrollbarTheme()) |
46 , m_owner(ownerNode) | 46 , m_owner(ownerNode) |
47 , m_owningFrame(owningFrame) | 47 , m_owningFrame(owningFrame) |
48 { | 48 { |
49 ASSERT(ownerNode || owningFrame); | 49 ASSERT(ownerNode || owningFrame); |
50 | 50 |
51 // FIXME: We need to do this because RenderScrollbar::styleChanged is called
as soon as the scrollbar is created. | 51 // FIXME: We need to do this because LayoutScrollbar::styleChanged is called
as soon as the scrollbar is created. |
52 | 52 |
53 // Update the scrollbar size. | 53 // Update the scrollbar size. |
54 IntRect rect(0, 0, 0, 0); | 54 IntRect rect(0, 0, 0, 0); |
55 updateScrollbarPart(ScrollbarBGPart); | 55 updateScrollbarPart(ScrollbarBGPart); |
56 if (RenderScrollbarPart* part = m_parts.get(ScrollbarBGPart)) { | 56 if (LayoutScrollbarPart* part = m_parts.get(ScrollbarBGPart)) { |
57 part->layout(); | 57 part->layout(); |
58 rect.setSize(flooredIntSize(part->size())); | 58 rect.setSize(flooredIntSize(part->size())); |
59 } else if (this->orientation() == HorizontalScrollbar) { | 59 } else if (this->orientation() == HorizontalScrollbar) { |
60 rect.setWidth(this->width()); | 60 rect.setWidth(this->width()); |
61 } else { | 61 } else { |
62 rect.setHeight(this->height()); | 62 rect.setHeight(this->height()); |
63 } | 63 } |
64 | 64 |
65 setFrameRect(rect); | 65 setFrameRect(rect); |
66 | 66 |
67 } | 67 } |
68 | 68 |
69 RenderScrollbar::~RenderScrollbar() | 69 LayoutScrollbar::~LayoutScrollbar() |
70 { | 70 { |
71 if (m_parts.isEmpty()) | 71 if (m_parts.isEmpty()) |
72 return; | 72 return; |
73 | 73 |
74 // When a scrollbar is detached from its parent (causing all parts removal)
and | 74 // When a scrollbar is detached from its parent (causing all parts removal)
and |
75 // ready to be destroyed, its destruction can be delayed because of RefPtr | 75 // ready to be destroyed, its destruction can be delayed because of RefPtr |
76 // maintained in other classes such as EventHandler (m_lastScrollbarUnderMou
se). | 76 // maintained in other classes such as EventHandler (m_lastScrollbarUnderMou
se). |
77 // Meanwhile, we can have a call to updateScrollbarPart which recreates the | 77 // Meanwhile, we can have a call to updateScrollbarPart which recreates the |
78 // scrollbar part. So, we need to destroy these parts since we don't want th
em | 78 // scrollbar part. So, we need to destroy these parts since we don't want th
em |
79 // to call on a destroyed scrollbar. See webkit bug 68009. | 79 // to call on a destroyed scrollbar. See webkit bug 68009. |
80 updateScrollbarParts(true); | 80 updateScrollbarParts(true); |
81 } | 81 } |
82 | 82 |
83 void RenderScrollbar::trace(Visitor* visitor) | 83 void LayoutScrollbar::trace(Visitor* visitor) |
84 { | 84 { |
85 #if ENABLE(OILPAN) | 85 #if ENABLE(OILPAN) |
86 visitor->trace(m_owner); | 86 visitor->trace(m_owner); |
87 visitor->trace(m_owningFrame); | 87 visitor->trace(m_owningFrame); |
88 #endif | 88 #endif |
89 Scrollbar::trace(visitor); | 89 Scrollbar::trace(visitor); |
90 } | 90 } |
91 | 91 |
92 RenderBox* RenderScrollbar::owningRenderer() const | 92 RenderBox* LayoutScrollbar::owningRenderer() const |
93 { | 93 { |
94 if (m_owningFrame) { | 94 if (m_owningFrame) { |
95 RenderBox* currentRenderer = m_owningFrame->ownerRenderer(); | 95 RenderBox* currentRenderer = m_owningFrame->ownerRenderer(); |
96 return currentRenderer; | 96 return currentRenderer; |
97 } | 97 } |
98 return m_owner && m_owner->renderer() ? m_owner->renderer()->enclosingBox()
: 0; | 98 return m_owner && m_owner->renderer() ? m_owner->renderer()->enclosingBox()
: 0; |
99 } | 99 } |
100 | 100 |
101 void RenderScrollbar::setParent(Widget* parent) | 101 void LayoutScrollbar::setParent(Widget* parent) |
102 { | 102 { |
103 Scrollbar::setParent(parent); | 103 Scrollbar::setParent(parent); |
104 if (!parent) { | 104 if (!parent) { |
105 // Destroy all of the scrollbar's RenderBoxes. | 105 // Destroy all of the scrollbar's RenderBoxes. |
106 updateScrollbarParts(true); | 106 updateScrollbarParts(true); |
107 } | 107 } |
108 } | 108 } |
109 | 109 |
110 void RenderScrollbar::setEnabled(bool e) | 110 void LayoutScrollbar::setEnabled(bool e) |
111 { | 111 { |
112 bool wasEnabled = enabled(); | 112 bool wasEnabled = enabled(); |
113 Scrollbar::setEnabled(e); | 113 Scrollbar::setEnabled(e); |
114 if (wasEnabled != e) | 114 if (wasEnabled != e) |
115 updateScrollbarParts(); | 115 updateScrollbarParts(); |
116 } | 116 } |
117 | 117 |
118 void RenderScrollbar::styleChanged() | 118 void LayoutScrollbar::styleChanged() |
119 { | 119 { |
120 updateScrollbarParts(); | 120 updateScrollbarParts(); |
121 } | 121 } |
122 | 122 |
123 void RenderScrollbar::setHoveredPart(ScrollbarPart part) | 123 void LayoutScrollbar::setHoveredPart(ScrollbarPart part) |
124 { | 124 { |
125 if (part == m_hoveredPart) | 125 if (part == m_hoveredPart) |
126 return; | 126 return; |
127 | 127 |
128 ScrollbarPart oldPart = m_hoveredPart; | 128 ScrollbarPart oldPart = m_hoveredPart; |
129 m_hoveredPart = part; | 129 m_hoveredPart = part; |
130 | 130 |
131 updateScrollbarPart(oldPart); | 131 updateScrollbarPart(oldPart); |
132 updateScrollbarPart(m_hoveredPart); | 132 updateScrollbarPart(m_hoveredPart); |
133 | 133 |
134 updateScrollbarPart(ScrollbarBGPart); | 134 updateScrollbarPart(ScrollbarBGPart); |
135 updateScrollbarPart(TrackBGPart); | 135 updateScrollbarPart(TrackBGPart); |
136 } | 136 } |
137 | 137 |
138 void RenderScrollbar::setPressedPart(ScrollbarPart part) | 138 void LayoutScrollbar::setPressedPart(ScrollbarPart part) |
139 { | 139 { |
140 ScrollbarPart oldPart = m_pressedPart; | 140 ScrollbarPart oldPart = m_pressedPart; |
141 Scrollbar::setPressedPart(part); | 141 Scrollbar::setPressedPart(part); |
142 | 142 |
143 updateScrollbarPart(oldPart); | 143 updateScrollbarPart(oldPart); |
144 updateScrollbarPart(part); | 144 updateScrollbarPart(part); |
145 | 145 |
146 updateScrollbarPart(ScrollbarBGPart); | 146 updateScrollbarPart(ScrollbarBGPart); |
147 updateScrollbarPart(TrackBGPart); | 147 updateScrollbarPart(TrackBGPart); |
148 } | 148 } |
149 | 149 |
150 PassRefPtr<LayoutStyle> RenderScrollbar::getScrollbarPseudoStyle(ScrollbarPart p
artType, PseudoId pseudoId) | 150 PassRefPtr<LayoutStyle> LayoutScrollbar::getScrollbarPseudoStyle(ScrollbarPart p
artType, PseudoId pseudoId) |
151 { | 151 { |
152 if (!owningRenderer()) | 152 if (!owningRenderer()) |
153 return nullptr; | 153 return nullptr; |
154 | 154 |
155 RefPtr<LayoutStyle> result = owningRenderer()->getUncachedPseudoStyle(Pseudo
StyleRequest(pseudoId, this, partType), owningRenderer()->style()); | 155 RefPtr<LayoutStyle> result = owningRenderer()->getUncachedPseudoStyle(Pseudo
StyleRequest(pseudoId, this, partType), owningRenderer()->style()); |
156 // Scrollbars for root frames should always have background color | 156 // Scrollbars for root frames should always have background color |
157 // unless explicitly specified as transparent. So we force it. | 157 // unless explicitly specified as transparent. So we force it. |
158 // This is because WebKit assumes scrollbar to be always painted and missing
background | 158 // This is because WebKit assumes scrollbar to be always painted and missing
background |
159 // causes visual artifact like non-paint invalidated dirty region. | 159 // causes visual artifact like non-paint invalidated dirty region. |
160 if (result && m_owningFrame && m_owningFrame->view() && !m_owningFrame->view
()->isTransparent() && !result->hasBackground()) | 160 if (result && m_owningFrame && m_owningFrame->view() && !m_owningFrame->view
()->isTransparent() && !result->hasBackground()) |
161 result->setBackgroundColor(StyleColor(Color::white)); | 161 result->setBackgroundColor(StyleColor(Color::white)); |
162 | 162 |
163 return result; | 163 return result; |
164 } | 164 } |
165 | 165 |
166 void RenderScrollbar::updateScrollbarParts(bool destroy) | 166 void LayoutScrollbar::updateScrollbarParts(bool destroy) |
167 { | 167 { |
168 updateScrollbarPart(ScrollbarBGPart, destroy); | 168 updateScrollbarPart(ScrollbarBGPart, destroy); |
169 updateScrollbarPart(BackButtonStartPart, destroy); | 169 updateScrollbarPart(BackButtonStartPart, destroy); |
170 updateScrollbarPart(ForwardButtonStartPart, destroy); | 170 updateScrollbarPart(ForwardButtonStartPart, destroy); |
171 updateScrollbarPart(BackTrackPart, destroy); | 171 updateScrollbarPart(BackTrackPart, destroy); |
172 updateScrollbarPart(ThumbPart, destroy); | 172 updateScrollbarPart(ThumbPart, destroy); |
173 updateScrollbarPart(ForwardTrackPart, destroy); | 173 updateScrollbarPart(ForwardTrackPart, destroy); |
174 updateScrollbarPart(BackButtonEndPart, destroy); | 174 updateScrollbarPart(BackButtonEndPart, destroy); |
175 updateScrollbarPart(ForwardButtonEndPart, destroy); | 175 updateScrollbarPart(ForwardButtonEndPart, destroy); |
176 updateScrollbarPart(TrackBGPart, destroy); | 176 updateScrollbarPart(TrackBGPart, destroy); |
177 | 177 |
178 if (destroy) | 178 if (destroy) |
179 return; | 179 return; |
180 | 180 |
181 // See if the scrollbar's thickness changed. If so, we need to mark our own
ing object as needing a layout. | 181 // See if the scrollbar's thickness changed. If so, we need to mark our own
ing object as needing a layout. |
182 bool isHorizontal = orientation() == HorizontalScrollbar; | 182 bool isHorizontal = orientation() == HorizontalScrollbar; |
183 int oldThickness = isHorizontal ? height() : width(); | 183 int oldThickness = isHorizontal ? height() : width(); |
184 int newThickness = 0; | 184 int newThickness = 0; |
185 RenderScrollbarPart* part = m_parts.get(ScrollbarBGPart); | 185 LayoutScrollbarPart* part = m_parts.get(ScrollbarBGPart); |
186 if (part) { | 186 if (part) { |
187 part->layout(); | 187 part->layout(); |
188 newThickness = isHorizontal ? part->size().height() : part->size().width
(); | 188 newThickness = isHorizontal ? part->size().height() : part->size().width
(); |
189 } | 189 } |
190 | 190 |
191 if (newThickness != oldThickness) { | 191 if (newThickness != oldThickness) { |
192 setFrameRect(IntRect(location(), IntSize(isHorizontal ? width() : newThi
ckness, isHorizontal ? newThickness : height()))); | 192 setFrameRect(IntRect(location(), IntSize(isHorizontal ? width() : newThi
ckness, isHorizontal ? newThickness : height()))); |
193 if (RenderBox* box = owningRenderer()) { | 193 if (RenderBox* box = owningRenderer()) { |
194 if (box->isRenderBlock()) | 194 if (box->isRenderBlock()) |
195 toRenderBlock(box)->notifyScrollbarThicknessChanged(); | 195 toRenderBlock(box)->notifyScrollbarThicknessChanged(); |
196 box->setChildNeedsLayout(); | 196 box->setChildNeedsLayout(); |
197 } | 197 } |
198 } | 198 } |
199 } | 199 } |
200 | 200 |
201 static PseudoId pseudoForScrollbarPart(ScrollbarPart part) | 201 static PseudoId pseudoForScrollbarPart(ScrollbarPart part) |
202 { | 202 { |
203 switch (part) { | 203 switch (part) { |
204 case BackButtonStartPart: | 204 case BackButtonStartPart: |
205 case ForwardButtonStartPart: | 205 case ForwardButtonStartPart: |
206 case BackButtonEndPart: | 206 case BackButtonEndPart: |
207 case ForwardButtonEndPart: | 207 case ForwardButtonEndPart: |
208 return SCROLLBAR_BUTTON; | 208 return SCROLLBAR_BUTTON; |
209 case BackTrackPart: | 209 case BackTrackPart: |
210 case ForwardTrackPart: | 210 case ForwardTrackPart: |
211 return SCROLLBAR_TRACK_PIECE; | 211 return SCROLLBAR_TRACK_PIECE; |
212 case ThumbPart: | 212 case ThumbPart: |
213 return SCROLLBAR_THUMB; | 213 return SCROLLBAR_THUMB; |
214 case TrackBGPart: | 214 case TrackBGPart: |
215 return SCROLLBAR_TRACK; | 215 return SCROLLBAR_TRACK; |
216 case ScrollbarBGPart: | 216 case ScrollbarBGPart: |
217 return SCROLLBAR; | 217 return SCROLLBAR; |
218 case NoPart: | 218 case NoPart: |
219 case AllParts: | 219 case AllParts: |
220 break; | 220 break; |
221 } | 221 } |
222 ASSERT_NOT_REACHED(); | 222 ASSERT_NOT_REACHED(); |
223 return SCROLLBAR; | 223 return SCROLLBAR; |
224 } | 224 } |
225 | 225 |
226 void RenderScrollbar::updateScrollbarPart(ScrollbarPart partType, bool destroy) | 226 void LayoutScrollbar::updateScrollbarPart(ScrollbarPart partType, bool destroy) |
227 { | 227 { |
228 if (partType == NoPart) | 228 if (partType == NoPart) |
229 return; | 229 return; |
230 | 230 |
231 RefPtr<LayoutStyle> partStyle = !destroy ? getScrollbarPseudoStyle(partType,
pseudoForScrollbarPart(partType)) : PassRefPtr<LayoutStyle>(nullptr); | 231 RefPtr<LayoutStyle> partStyle = !destroy ? getScrollbarPseudoStyle(partType,
pseudoForScrollbarPart(partType)) : PassRefPtr<LayoutStyle>(nullptr); |
232 | 232 |
233 bool needRenderer = !destroy && partStyle && partStyle->display() != NONE; | 233 bool needRenderer = !destroy && partStyle && partStyle->display() != NONE; |
234 | 234 |
235 if (needRenderer && partStyle->display() != BLOCK) { | 235 if (needRenderer && partStyle->display() != BLOCK) { |
236 // See if we are a button that should not be visible according to OS set
tings. | 236 // See if we are a button that should not be visible according to OS set
tings. |
237 ScrollbarButtonsPlacement buttonsPlacement = theme()->buttonsPlacement()
; | 237 ScrollbarButtonsPlacement buttonsPlacement = theme()->buttonsPlacement()
; |
238 switch (partType) { | 238 switch (partType) { |
239 case BackButtonStartPart: | 239 case BackButtonStartPart: |
240 needRenderer = (buttonsPlacement == ScrollbarButtonsSingle || bu
ttonsPlacement == ScrollbarButtonsDoubleStart || | 240 needRenderer = (buttonsPlacement == ScrollbarButtonsSingle || button
sPlacement == ScrollbarButtonsDoubleStart |
241 buttonsPlacement == ScrollbarButtonsDoubleBoth); | 241 || buttonsPlacement == ScrollbarButtonsDoubleBoth); |
242 break; | 242 break; |
243 case ForwardButtonStartPart: | 243 case ForwardButtonStartPart: |
244 needRenderer = (buttonsPlacement == ScrollbarButtonsDoubleStart
|| buttonsPlacement == ScrollbarButtonsDoubleBoth); | 244 needRenderer = (buttonsPlacement == ScrollbarButtonsDoubleStart || b
uttonsPlacement == ScrollbarButtonsDoubleBoth); |
245 break; | 245 break; |
246 case BackButtonEndPart: | 246 case BackButtonEndPart: |
247 needRenderer = (buttonsPlacement == ScrollbarButtonsDoubleEnd ||
buttonsPlacement == ScrollbarButtonsDoubleBoth); | 247 needRenderer = (buttonsPlacement == ScrollbarButtonsDoubleEnd || but
tonsPlacement == ScrollbarButtonsDoubleBoth); |
248 break; | 248 break; |
249 case ForwardButtonEndPart: | 249 case ForwardButtonEndPart: |
250 needRenderer = (buttonsPlacement == ScrollbarButtonsSingle || bu
ttonsPlacement == ScrollbarButtonsDoubleEnd || | 250 needRenderer = (buttonsPlacement == ScrollbarButtonsSingle || button
sPlacement == ScrollbarButtonsDoubleEnd |
251 buttonsPlacement == ScrollbarButtonsDoubleBoth); | 251 || buttonsPlacement == ScrollbarButtonsDoubleBoth); |
252 break; | 252 break; |
253 default: | 253 default: |
254 break; | 254 break; |
255 } | 255 } |
256 } | 256 } |
257 | 257 |
258 RenderScrollbarPart* partRenderer = m_parts.get(partType); | 258 LayoutScrollbarPart* partRenderer = m_parts.get(partType); |
259 if (!partRenderer && needRenderer) { | 259 if (!partRenderer && needRenderer) { |
260 partRenderer = RenderScrollbarPart::createAnonymous(&owningRenderer()->d
ocument(), this, partType); | 260 partRenderer = LayoutScrollbarPart::createAnonymous(&owningRenderer()->d
ocument(), this, partType); |
261 m_parts.set(partType, partRenderer); | 261 m_parts.set(partType, partRenderer); |
262 } else if (partRenderer && !needRenderer) { | 262 } else if (partRenderer && !needRenderer) { |
263 m_parts.remove(partType); | 263 m_parts.remove(partType); |
264 partRenderer->destroy(); | 264 partRenderer->destroy(); |
265 partRenderer = 0; | 265 partRenderer = 0; |
266 } | 266 } |
267 | 267 |
268 if (partRenderer) | 268 if (partRenderer) |
269 partRenderer->setStyle(partStyle.release()); | 269 partRenderer->setStyle(partStyle.release()); |
270 } | 270 } |
271 | 271 |
272 IntRect RenderScrollbar::buttonRect(ScrollbarPart partType) | 272 IntRect LayoutScrollbar::buttonRect(ScrollbarPart partType) |
273 { | 273 { |
274 RenderScrollbarPart* partRenderer = m_parts.get(partType); | 274 LayoutScrollbarPart* partRenderer = m_parts.get(partType); |
275 if (!partRenderer) | 275 if (!partRenderer) |
276 return IntRect(); | 276 return IntRect(); |
277 | 277 |
278 partRenderer->layout(); | 278 partRenderer->layout(); |
279 | 279 |
280 bool isHorizontal = orientation() == HorizontalScrollbar; | 280 bool isHorizontal = orientation() == HorizontalScrollbar; |
281 if (partType == BackButtonStartPart) | 281 if (partType == BackButtonStartPart) |
282 return IntRect(location(), IntSize(isHorizontal ? partRenderer->pixelSna
ppedWidth() : width(), isHorizontal ? height() : partRenderer->pixelSnappedHeigh
t())); | 282 return IntRect(location(), IntSize(isHorizontal ? partRenderer->pixelSna
ppedWidth() : width(), isHorizontal ? height() : partRenderer->pixelSnappedHeigh
t())); |
283 if (partType == ForwardButtonEndPart) | 283 if (partType == ForwardButtonEndPart) { |
284 return IntRect(isHorizontal ? x() + width() - partRenderer->pixelSnapped
Width() : x(), | 284 return IntRect(isHorizontal ? x() + width() - partRenderer->pixelSnapped
Width() : x(), |
285 isHorizontal ? y() : y() + height() - partRenderer->pixel
SnappedHeight(), | 285 isHorizontal ? y() : y() + height() - partRenderer->pixelSnappedHeig
ht(), |
286 isHorizontal ? partRenderer->pixelSnappedWidth() : width(
), | 286 isHorizontal ? partRenderer->pixelSnappedWidth() : width(), |
287 isHorizontal ? height() : partRenderer->pixelSnappedHeigh
t()); | 287 isHorizontal ? height() : partRenderer->pixelSnappedHeight()); |
| 288 } |
288 | 289 |
289 if (partType == ForwardButtonStartPart) { | 290 if (partType == ForwardButtonStartPart) { |
290 IntRect previousButton = buttonRect(BackButtonStartPart); | 291 IntRect previousButton = buttonRect(BackButtonStartPart); |
291 return IntRect(isHorizontal ? x() + previousButton.width() : x(), | 292 return IntRect(isHorizontal ? x() + previousButton.width() : x(), |
292 isHorizontal ? y() : y() + previousButton.height(), | 293 isHorizontal ? y() : y() + previousButton.height(), |
293 isHorizontal ? partRenderer->pixelSnappedWidth() : width(
), | 294 isHorizontal ? partRenderer->pixelSnappedWidth() : width(), |
294 isHorizontal ? height() : partRenderer->pixelSnappedHeigh
t()); | 295 isHorizontal ? height() : partRenderer->pixelSnappedHeight()); |
295 } | 296 } |
296 | 297 |
297 IntRect followingButton = buttonRect(ForwardButtonEndPart); | 298 IntRect followingButton = buttonRect(ForwardButtonEndPart); |
298 return IntRect(isHorizontal ? x() + width() - followingButton.width() - part
Renderer->pixelSnappedWidth() : x(), | 299 return IntRect(isHorizontal ? x() + width() - followingButton.width() - part
Renderer->pixelSnappedWidth() : x(), |
299 isHorizontal ? y() : y() + height() - followingButton.height(
) - partRenderer->pixelSnappedHeight(), | 300 isHorizontal ? y() : y() + height() - followingButton.height() - partRen
derer->pixelSnappedHeight(), |
300 isHorizontal ? partRenderer->pixelSnappedWidth() : width(), | 301 isHorizontal ? partRenderer->pixelSnappedWidth() : width(), |
301 isHorizontal ? height() : partRenderer->pixelSnappedHeight())
; | 302 isHorizontal ? height() : partRenderer->pixelSnappedHeight()); |
302 } | 303 } |
303 | 304 |
304 IntRect RenderScrollbar::trackRect(int startLength, int endLength) | 305 IntRect LayoutScrollbar::trackRect(int startLength, int endLength) |
305 { | 306 { |
306 RenderScrollbarPart* part = m_parts.get(TrackBGPart); | 307 LayoutScrollbarPart* part = m_parts.get(TrackBGPart); |
307 if (part) | 308 if (part) |
308 part->layout(); | 309 part->layout(); |
309 | 310 |
310 if (orientation() == HorizontalScrollbar) { | 311 if (orientation() == HorizontalScrollbar) { |
311 int marginLeft = part ? static_cast<int>(part->marginLeft()) : 0; | 312 int marginLeft = part ? static_cast<int>(part->marginLeft()) : 0; |
312 int marginRight = part ? static_cast<int>(part->marginRight()) : 0; | 313 int marginRight = part ? static_cast<int>(part->marginRight()) : 0; |
313 startLength += marginLeft; | 314 startLength += marginLeft; |
314 endLength += marginRight; | 315 endLength += marginRight; |
315 int totalLength = startLength + endLength; | 316 int totalLength = startLength + endLength; |
316 return IntRect(x() + startLength, y(), width() - totalLength, height()); | 317 return IntRect(x() + startLength, y(), width() - totalLength, height()); |
317 } | 318 } |
318 | 319 |
319 int marginTop = part ? static_cast<int>(part->marginTop()) : 0; | 320 int marginTop = part ? static_cast<int>(part->marginTop()) : 0; |
320 int marginBottom = part ? static_cast<int>(part->marginBottom()) : 0; | 321 int marginBottom = part ? static_cast<int>(part->marginBottom()) : 0; |
321 startLength += marginTop; | 322 startLength += marginTop; |
322 endLength += marginBottom; | 323 endLength += marginBottom; |
323 int totalLength = startLength + endLength; | 324 int totalLength = startLength + endLength; |
324 | 325 |
325 return IntRect(x(), y() + startLength, width(), height() - totalLength); | 326 return IntRect(x(), y() + startLength, width(), height() - totalLength); |
326 } | 327 } |
327 | 328 |
328 IntRect RenderScrollbar::trackPieceRectWithMargins(ScrollbarPart partType, const
IntRect& oldRect) | 329 IntRect LayoutScrollbar::trackPieceRectWithMargins(ScrollbarPart partType, const
IntRect& oldRect) |
329 { | 330 { |
330 RenderScrollbarPart* partRenderer = m_parts.get(partType); | 331 LayoutScrollbarPart* partRenderer = m_parts.get(partType); |
331 if (!partRenderer) | 332 if (!partRenderer) |
332 return oldRect; | 333 return oldRect; |
333 | 334 |
334 partRenderer->layout(); | 335 partRenderer->layout(); |
335 | 336 |
336 IntRect rect = oldRect; | 337 IntRect rect = oldRect; |
337 if (orientation() == HorizontalScrollbar) { | 338 if (orientation() == HorizontalScrollbar) { |
338 rect.setX(rect.x() + partRenderer->marginLeft()); | 339 rect.setX(rect.x() + partRenderer->marginLeft()); |
339 rect.setWidth(rect.width() - partRenderer->marginWidth()); | 340 rect.setWidth(rect.width() - partRenderer->marginWidth()); |
340 } else { | 341 } else { |
341 rect.setY(rect.y() + partRenderer->marginTop()); | 342 rect.setY(rect.y() + partRenderer->marginTop()); |
342 rect.setHeight(rect.height() - partRenderer->marginHeight()); | 343 rect.setHeight(rect.height() - partRenderer->marginHeight()); |
343 } | 344 } |
344 return rect; | 345 return rect; |
345 } | 346 } |
346 | 347 |
347 int RenderScrollbar::minimumThumbLength() | 348 int LayoutScrollbar::minimumThumbLength() |
348 { | 349 { |
349 RenderScrollbarPart* partRenderer = m_parts.get(ThumbPart); | 350 LayoutScrollbarPart* partRenderer = m_parts.get(ThumbPart); |
350 if (!partRenderer) | 351 if (!partRenderer) |
351 return 0; | 352 return 0; |
352 partRenderer->layout(); | 353 partRenderer->layout(); |
353 return orientation() == HorizontalScrollbar ? partRenderer->size().width() :
partRenderer->size().height(); | 354 return orientation() == HorizontalScrollbar ? partRenderer->size().width() :
partRenderer->size().height(); |
354 } | 355 } |
355 | 356 |
356 } | 357 } |
OLD | NEW |