| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010, Google Inc. All rights reserved. | 2 * Copyright (c) 2010, Google Inc. All rights reserved. |
| 3 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. | 3 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 return kPixelsPerLineStep; | 66 return kPixelsPerLineStep; |
| 67 } | 67 } |
| 68 | 68 |
| 69 float ScrollableArea::minFractionToStepWhenPaging() | 69 float ScrollableArea::minFractionToStepWhenPaging() |
| 70 { | 70 { |
| 71 return kMinFractionToStepWhenPaging; | 71 return kMinFractionToStepWhenPaging; |
| 72 } | 72 } |
| 73 | 73 |
| 74 int ScrollableArea::maxOverlapBetweenPages() | 74 int ScrollableArea::maxOverlapBetweenPages() |
| 75 { | 75 { |
| 76 static int maxOverlapBetweenPages = ScrollbarTheme::theme()->maxOverlapBetwe
enPages(); | 76 static int maxOverlapBetweenPages = ScrollbarTheme::theme().maxOverlapBetwee
nPages(); |
| 77 return maxOverlapBetweenPages; | 77 return maxOverlapBetweenPages; |
| 78 } | 78 } |
| 79 | 79 |
| 80 ScrollableArea::ScrollableArea() | 80 ScrollableArea::ScrollableArea() |
| 81 : m_inLiveResize(false) | 81 : m_inLiveResize(false) |
| 82 , m_scrollbarOverlayStyle(ScrollbarOverlayStyleDefault) | 82 , m_scrollbarOverlayStyle(ScrollbarOverlayStyleDefault) |
| 83 , m_scrollOriginChanged(false) | 83 , m_scrollOriginChanged(false) |
| 84 , m_horizontalScrollbarNeedsPaintInvalidation(false) | 84 , m_horizontalScrollbarNeedsPaintInvalidation(false) |
| 85 , m_verticalScrollbarNeedsPaintInvalidation(false) | 85 , m_verticalScrollbarNeedsPaintInvalidation(false) |
| 86 , m_scrollCornerNeedsPaintInvalidation(false) | 86 , m_scrollCornerNeedsPaintInvalidation(false) |
| 87 { | 87 { |
| 88 } | 88 } |
| 89 | 89 |
| 90 ScrollableArea::~ScrollableArea() | 90 ScrollableArea::~ScrollableArea() |
| 91 { | 91 { |
| 92 } | 92 } |
| 93 | 93 |
| 94 void ScrollableArea::clearScrollAnimators() | 94 void ScrollableArea::clearScrollAnimators() |
| 95 { | 95 { |
| 96 #if OS(MACOSX) && ENABLE(OILPAN) | 96 #if OS(MACOSX) && ENABLE(OILPAN) |
| 97 if (m_scrollAnimator) | 97 if (m_scrollAnimator) |
| 98 m_scrollAnimator->dispose(); | 98 m_scrollAnimator->dispose(); |
| 99 #endif | 99 #endif |
| 100 m_scrollAnimator.clear(); | 100 m_scrollAnimator.clear(); |
| 101 m_programmaticScrollAnimator.clear(); | 101 m_programmaticScrollAnimator.clear(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 ScrollAnimatorBase* ScrollableArea::scrollAnimator() const | 104 ScrollAnimatorBase& ScrollableArea::scrollAnimator() const |
| 105 { | 105 { |
| 106 if (!m_scrollAnimator) | 106 if (!m_scrollAnimator) |
| 107 m_scrollAnimator = ScrollAnimatorBase::create(const_cast<ScrollableArea*
>(this)); | 107 m_scrollAnimator = ScrollAnimatorBase::create(const_cast<ScrollableArea*
>(this)); |
| 108 | 108 |
| 109 return m_scrollAnimator.get(); | 109 return *m_scrollAnimator; |
| 110 } | 110 } |
| 111 | 111 |
| 112 ProgrammaticScrollAnimator* ScrollableArea::programmaticScrollAnimator() const | 112 ProgrammaticScrollAnimator& ScrollableArea::programmaticScrollAnimator() const |
| 113 { | 113 { |
| 114 if (!m_programmaticScrollAnimator) | 114 if (!m_programmaticScrollAnimator) |
| 115 m_programmaticScrollAnimator = ProgrammaticScrollAnimator::create(const_
cast<ScrollableArea*>(this)); | 115 m_programmaticScrollAnimator = ProgrammaticScrollAnimator::create(const_
cast<ScrollableArea*>(this)); |
| 116 | 116 |
| 117 return m_programmaticScrollAnimator.get(); | 117 return *m_programmaticScrollAnimator; |
| 118 } | 118 } |
| 119 | 119 |
| 120 void ScrollableArea::setScrollOrigin(const IntPoint& origin) | 120 void ScrollableArea::setScrollOrigin(const IntPoint& origin) |
| 121 { | 121 { |
| 122 if (m_scrollOrigin != origin) { | 122 if (m_scrollOrigin != origin) { |
| 123 m_scrollOrigin = origin; | 123 m_scrollOrigin = origin; |
| 124 m_scrollOriginChanged = true; | 124 m_scrollOriginChanged = true; |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 156 break; | 156 break; |
| 157 case ScrollByPixel: | 157 case ScrollByPixel: |
| 158 case ScrollByPrecisePixel: | 158 case ScrollByPrecisePixel: |
| 159 step = pixelStep(orientation); | 159 step = pixelStep(orientation); |
| 160 break; | 160 break; |
| 161 } | 161 } |
| 162 | 162 |
| 163 if (direction == ScrollUp || direction == ScrollLeft) | 163 if (direction == ScrollUp || direction == ScrollLeft) |
| 164 delta = -delta; | 164 delta = -delta; |
| 165 | 165 |
| 166 return scrollAnimator()->userScroll(orientation, granularity, step, delta); | 166 return scrollAnimator().userScroll(orientation, granularity, step, delta); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void ScrollableArea::setScrollPosition(const DoublePoint& position, ScrollType s
crollType, ScrollBehavior behavior) | 169 void ScrollableArea::setScrollPosition(const DoublePoint& position, ScrollType s
crollType, ScrollBehavior behavior) |
| 170 { | 170 { |
| 171 if (behavior == ScrollBehaviorAuto) | 171 if (behavior == ScrollBehaviorAuto) |
| 172 behavior = scrollBehaviorStyle(); | 172 behavior = scrollBehaviorStyle(); |
| 173 | 173 |
| 174 if (scrollType == CompositorScroll) | 174 if (scrollType == CompositorScroll) |
| 175 scrollPositionChanged(clampScrollPosition(position), CompositorScroll); | 175 scrollPositionChanged(clampScrollPosition(position), CompositorScroll); |
| 176 else if (scrollType == ProgrammaticScroll) | 176 else if (scrollType == ProgrammaticScroll) |
| 177 programmaticScrollHelper(position, behavior); | 177 programmaticScrollHelper(position, behavior); |
| 178 else if (scrollType == UserScroll) | 178 else if (scrollType == UserScroll) |
| 179 userScrollHelper(position, behavior); | 179 userScrollHelper(position, behavior); |
| 180 else | 180 else |
| 181 ASSERT_NOT_REACHED(); | 181 ASSERT_NOT_REACHED(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void ScrollableArea::scrollBy(const DoubleSize& delta, ScrollType type, ScrollBe
havior behavior) | 184 void ScrollableArea::scrollBy(const DoubleSize& delta, ScrollType type, ScrollBe
havior behavior) |
| 185 { | 185 { |
| 186 setScrollPosition(scrollPositionDouble() + delta, type, behavior); | 186 setScrollPosition(scrollPositionDouble() + delta, type, behavior); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void ScrollableArea::setScrollPositionSingleAxis(ScrollbarOrientation orientatio
n, double position, ScrollType scrollType, ScrollBehavior behavior) | 189 void ScrollableArea::setScrollPositionSingleAxis(ScrollbarOrientation orientatio
n, double position, ScrollType scrollType, ScrollBehavior behavior) |
| 190 { | 190 { |
| 191 DoublePoint newPosition; | 191 DoublePoint newPosition; |
| 192 if (orientation == HorizontalScrollbar) | 192 if (orientation == HorizontalScrollbar) |
| 193 newPosition = DoublePoint(position, scrollAnimator()->currentPosition().
y()); | 193 newPosition = DoublePoint(position, scrollAnimator().currentPosition().y
()); |
| 194 else | 194 else |
| 195 newPosition = DoublePoint(scrollAnimator()->currentPosition().x(), posit
ion); | 195 newPosition = DoublePoint(scrollAnimator().currentPosition().x(), positi
on); |
| 196 | 196 |
| 197 // TODO(bokan): Note, this doesn't use the derived class versions since this
method is currently used | 197 // TODO(bokan): Note, this doesn't use the derived class versions since this
method is currently used |
| 198 // exclusively by code that adjusts the position by the scroll origin and th
e derived class versions | 198 // exclusively by code that adjusts the position by the scroll origin and th
e derived class versions |
| 199 // differ on whether they take that into account or not. | 199 // differ on whether they take that into account or not. |
| 200 ScrollableArea::setScrollPosition(newPosition, scrollType, behavior); | 200 ScrollableArea::setScrollPosition(newPosition, scrollType, behavior); |
| 201 } | 201 } |
| 202 | 202 |
| 203 void ScrollableArea::programmaticScrollHelper(const DoublePoint& position, Scrol
lBehavior scrollBehavior) | 203 void ScrollableArea::programmaticScrollHelper(const DoublePoint& position, Scrol
lBehavior scrollBehavior) |
| 204 { | 204 { |
| 205 cancelScrollAnimation(); | 205 cancelScrollAnimation(); |
| 206 | 206 |
| 207 if (scrollBehavior == ScrollBehaviorSmooth) | 207 if (scrollBehavior == ScrollBehaviorSmooth) |
| 208 programmaticScrollAnimator()->animateToOffset(toFloatPoint(position)); | 208 programmaticScrollAnimator().animateToOffset(toFloatPoint(position)); |
| 209 else | 209 else |
| 210 programmaticScrollAnimator()->scrollToOffsetWithoutAnimation(toFloatPoin
t(position)); | 210 programmaticScrollAnimator().scrollToOffsetWithoutAnimation(toFloatPoint
(position)); |
| 211 } | 211 } |
| 212 | 212 |
| 213 void ScrollableArea::userScrollHelper(const DoublePoint& position, ScrollBehavio
r scrollBehavior) | 213 void ScrollableArea::userScrollHelper(const DoublePoint& position, ScrollBehavio
r scrollBehavior) |
| 214 { | 214 { |
| 215 cancelProgrammaticScrollAnimation(); | 215 cancelProgrammaticScrollAnimation(); |
| 216 | 216 |
| 217 double x = userInputScrollable(HorizontalScrollbar) ? position.x() : scrollA
nimator()->currentPosition().x(); | 217 double x = userInputScrollable(HorizontalScrollbar) ? position.x() : scrollA
nimator().currentPosition().x(); |
| 218 double y = userInputScrollable(VerticalScrollbar) ? position.y() : scrollAni
mator()->currentPosition().y(); | 218 double y = userInputScrollable(VerticalScrollbar) ? position.y() : scrollAni
mator().currentPosition().y(); |
| 219 | 219 |
| 220 // Smooth user scrolls (keyboard, wheel clicks) are handled via the userScro
ll method. | 220 // Smooth user scrolls (keyboard, wheel clicks) are handled via the userScro
ll method. |
| 221 // TODO(bokan): The userScroll method should probably be modified to call th
is method | 221 // TODO(bokan): The userScroll method should probably be modified to call th
is method |
| 222 // and ScrollAnimatorBase to have a simpler animateToOffset met
hod like the | 222 // and ScrollAnimatorBase to have a simpler animateToOffset met
hod like the |
| 223 // ProgrammaticScrollAnimator. | 223 // ProgrammaticScrollAnimator. |
| 224 ASSERT(scrollBehavior == ScrollBehaviorInstant); | 224 ASSERT(scrollBehavior == ScrollBehaviorInstant); |
| 225 scrollAnimator()->scrollToOffsetWithoutAnimation(FloatPoint(x, y)); | 225 scrollAnimator().scrollToOffsetWithoutAnimation(FloatPoint(x, y)); |
| 226 } | 226 } |
| 227 | 227 |
| 228 LayoutRect ScrollableArea::scrollIntoView(const LayoutRect& rectInContent, const
ScrollAlignment& alignX, const ScrollAlignment& alignY, ScrollType) | 228 LayoutRect ScrollableArea::scrollIntoView(const LayoutRect& rectInContent, const
ScrollAlignment& alignX, const ScrollAlignment& alignY, ScrollType) |
| 229 { | 229 { |
| 230 // TODO(bokan): This should really be implemented here but ScrollAlignment i
s in Core which is a dependency violation. | 230 // TODO(bokan): This should really be implemented here but ScrollAlignment i
s in Core which is a dependency violation. |
| 231 ASSERT_NOT_REACHED(); | 231 ASSERT_NOT_REACHED(); |
| 232 return LayoutRect(); | 232 return LayoutRect(); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void ScrollableArea::scrollPositionChanged(const DoublePoint& position, ScrollTy
pe scrollType) | 235 void ScrollableArea::scrollPositionChanged(const DoublePoint& position, ScrollTy
pe scrollType) |
| 236 { | 236 { |
| 237 TRACE_EVENT0("blink", "ScrollableArea::scrollPositionChanged"); | 237 TRACE_EVENT0("blink", "ScrollableArea::scrollPositionChanged"); |
| 238 | 238 |
| 239 DoublePoint oldPosition = scrollPositionDouble(); | 239 DoublePoint oldPosition = scrollPositionDouble(); |
| 240 DoublePoint truncatedPosition = shouldUseIntegerScrollOffset() ? flooredIntP
oint(position) : position; | 240 DoublePoint truncatedPosition = shouldUseIntegerScrollOffset() ? flooredIntP
oint(position) : position; |
| 241 | 241 |
| 242 // Tell the derived class to scroll its contents. | 242 // Tell the derived class to scroll its contents. |
| 243 setScrollOffset(truncatedPosition, scrollType); | 243 setScrollOffset(truncatedPosition, scrollType); |
| 244 | 244 |
| 245 Scrollbar* verticalScrollbar = this->verticalScrollbar(); | 245 Scrollbar* verticalScrollbar = this->verticalScrollbar(); |
| 246 | 246 |
| 247 // Tell the scrollbars to update their thumb postions. | 247 // Tell the scrollbars to update their thumb postions. |
| 248 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { | 248 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { |
| 249 horizontalScrollbar->offsetDidChange(); | 249 horizontalScrollbar->offsetDidChange(); |
| 250 if (horizontalScrollbar->isOverlayScrollbar() && !hasLayerForHorizontalS
crollbar()) | 250 if (horizontalScrollbar->isOverlayScrollbar() && !hasLayerForHorizontalS
crollbar()) |
| 251 setScrollbarNeedsPaintInvalidation(horizontalScrollbar); | 251 setScrollbarNeedsPaintInvalidation(HorizontalScrollbar); |
| 252 } | 252 } |
| 253 if (verticalScrollbar) { | 253 if (verticalScrollbar) { |
| 254 verticalScrollbar->offsetDidChange(); | 254 verticalScrollbar->offsetDidChange(); |
| 255 if (verticalScrollbar->isOverlayScrollbar() && !hasLayerForVerticalScrol
lbar()) | 255 if (verticalScrollbar->isOverlayScrollbar() && !hasLayerForVerticalScrol
lbar()) |
| 256 setScrollbarNeedsPaintInvalidation(verticalScrollbar); | 256 setScrollbarNeedsPaintInvalidation(VerticalScrollbar); |
| 257 } | 257 } |
| 258 | 258 |
| 259 if (scrollPositionDouble() != oldPosition) { | 259 if (scrollPositionDouble() != oldPosition) { |
| 260 // FIXME: Pass in DoubleSize. crbug.com/414283. | 260 // FIXME: Pass in DoubleSize. crbug.com/414283. |
| 261 scrollAnimator()->notifyContentAreaScrolled(toFloatSize(scrollPositionDo
uble() - oldPosition)); | 261 scrollAnimator().notifyContentAreaScrolled(toFloatSize(scrollPositionDou
ble() - oldPosition)); |
| 262 } | 262 } |
| 263 | 263 |
| 264 scrollAnimator()->setCurrentPosition(toFloatPoint(position)); | 264 scrollAnimator().setCurrentPosition(toFloatPoint(position)); |
| 265 } | 265 } |
| 266 | 266 |
| 267 bool ScrollableArea::scrollBehaviorFromString(const String& behaviorString, Scro
llBehavior& behavior) | 267 bool ScrollableArea::scrollBehaviorFromString(const String& behaviorString, Scro
llBehavior& behavior) |
| 268 { | 268 { |
| 269 if (behaviorString == "auto") | 269 if (behaviorString == "auto") |
| 270 behavior = ScrollBehaviorAuto; | 270 behavior = ScrollBehaviorAuto; |
| 271 else if (behaviorString == "instant") | 271 else if (behaviorString == "instant") |
| 272 behavior = ScrollBehaviorInstant; | 272 behavior = ScrollBehaviorInstant; |
| 273 else if (behaviorString == "smooth") | 273 else if (behaviorString == "smooth") |
| 274 behavior = ScrollBehaviorSmooth; | 274 behavior = ScrollBehaviorSmooth; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) | 319 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) |
| 320 scrollAnimator->mouseEnteredContentArea(); | 320 scrollAnimator->mouseEnteredContentArea(); |
| 321 } | 321 } |
| 322 | 322 |
| 323 void ScrollableArea::mouseMovedInContentArea() const | 323 void ScrollableArea::mouseMovedInContentArea() const |
| 324 { | 324 { |
| 325 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) | 325 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) |
| 326 scrollAnimator->mouseMovedInContentArea(); | 326 scrollAnimator->mouseMovedInContentArea(); |
| 327 } | 327 } |
| 328 | 328 |
| 329 void ScrollableArea::mouseEnteredScrollbar(Scrollbar* scrollbar) const | 329 void ScrollableArea::mouseEnteredScrollbar(Scrollbar& scrollbar) const |
| 330 { | 330 { |
| 331 scrollAnimator()->mouseEnteredScrollbar(scrollbar); | 331 scrollAnimator().mouseEnteredScrollbar(scrollbar); |
| 332 } | 332 } |
| 333 | 333 |
| 334 void ScrollableArea::mouseExitedScrollbar(Scrollbar* scrollbar) const | 334 void ScrollableArea::mouseExitedScrollbar(Scrollbar& scrollbar) const |
| 335 { | 335 { |
| 336 scrollAnimator()->mouseExitedScrollbar(scrollbar); | 336 scrollAnimator().mouseExitedScrollbar(scrollbar); |
| 337 } | 337 } |
| 338 | 338 |
| 339 void ScrollableArea::contentAreaDidShow() const | 339 void ScrollableArea::contentAreaDidShow() const |
| 340 { | 340 { |
| 341 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) | 341 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) |
| 342 scrollAnimator->contentAreaDidShow(); | 342 scrollAnimator->contentAreaDidShow(); |
| 343 } | 343 } |
| 344 | 344 |
| 345 void ScrollableArea::contentAreaDidHide() const | 345 void ScrollableArea::contentAreaDidHide() const |
| 346 { | 346 { |
| 347 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) | 347 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) |
| 348 scrollAnimator->contentAreaDidHide(); | 348 scrollAnimator->contentAreaDidHide(); |
| 349 } | 349 } |
| 350 | 350 |
| 351 void ScrollableArea::finishCurrentScrollAnimations() const | 351 void ScrollableArea::finishCurrentScrollAnimations() const |
| 352 { | 352 { |
| 353 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) | 353 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) |
| 354 scrollAnimator->finishCurrentScrollAnimations(); | 354 scrollAnimator->finishCurrentScrollAnimations(); |
| 355 } | 355 } |
| 356 | 356 |
| 357 void ScrollableArea::didAddScrollbar(Scrollbar* scrollbar, ScrollbarOrientation
orientation) | 357 void ScrollableArea::didAddScrollbar(Scrollbar& scrollbar, ScrollbarOrientation
orientation) |
| 358 { | 358 { |
| 359 if (orientation == VerticalScrollbar) | 359 if (orientation == VerticalScrollbar) |
| 360 scrollAnimator()->didAddVerticalScrollbar(scrollbar); | 360 scrollAnimator().didAddVerticalScrollbar(scrollbar); |
| 361 else | 361 else |
| 362 scrollAnimator()->didAddHorizontalScrollbar(scrollbar); | 362 scrollAnimator().didAddHorizontalScrollbar(scrollbar); |
| 363 | 363 |
| 364 // <rdar://problem/9797253> AppKit resets the scrollbar's style when you att
ach a scrollbar | 364 // <rdar://problem/9797253> AppKit resets the scrollbar's style when you att
ach a scrollbar |
| 365 setScrollbarOverlayStyle(scrollbarOverlayStyle()); | 365 setScrollbarOverlayStyle(scrollbarOverlayStyle()); |
| 366 } | 366 } |
| 367 | 367 |
| 368 void ScrollableArea::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientat
ion orientation) | 368 void ScrollableArea::willRemoveScrollbar(Scrollbar& scrollbar, ScrollbarOrientat
ion orientation) |
| 369 { | 369 { |
| 370 if (orientation == VerticalScrollbar) | 370 if (orientation == VerticalScrollbar) |
| 371 scrollAnimator()->willRemoveVerticalScrollbar(scrollbar); | 371 scrollAnimator().willRemoveVerticalScrollbar(scrollbar); |
| 372 else | 372 else |
| 373 scrollAnimator()->willRemoveHorizontalScrollbar(scrollbar); | 373 scrollAnimator().willRemoveHorizontalScrollbar(scrollbar); |
| 374 } | 374 } |
| 375 | 375 |
| 376 void ScrollableArea::contentsResized() | 376 void ScrollableArea::contentsResized() |
| 377 { | 377 { |
| 378 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) | 378 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) |
| 379 scrollAnimator->contentsResized(); | 379 scrollAnimator->contentsResized(); |
| 380 } | 380 } |
| 381 | 381 |
| 382 bool ScrollableArea::hasOverlayScrollbars() const | 382 bool ScrollableArea::hasOverlayScrollbars() const |
| 383 { | 383 { |
| 384 Scrollbar* vScrollbar = verticalScrollbar(); | 384 Scrollbar* vScrollbar = verticalScrollbar(); |
| 385 if (vScrollbar && vScrollbar->isOverlayScrollbar()) | 385 if (vScrollbar && vScrollbar->isOverlayScrollbar()) |
| 386 return true; | 386 return true; |
| 387 Scrollbar* hScrollbar = horizontalScrollbar(); | 387 Scrollbar* hScrollbar = horizontalScrollbar(); |
| 388 return hScrollbar && hScrollbar->isOverlayScrollbar(); | 388 return hScrollbar && hScrollbar->isOverlayScrollbar(); |
| 389 } | 389 } |
| 390 | 390 |
| 391 void ScrollableArea::setScrollbarOverlayStyle(ScrollbarOverlayStyle overlayStyle
) | 391 void ScrollableArea::setScrollbarOverlayStyle(ScrollbarOverlayStyle overlayStyle
) |
| 392 { | 392 { |
| 393 m_scrollbarOverlayStyle = overlayStyle; | 393 m_scrollbarOverlayStyle = overlayStyle; |
| 394 | 394 |
| 395 if (Scrollbar* scrollbar = horizontalScrollbar()) { | 395 if (Scrollbar* scrollbar = horizontalScrollbar()) { |
| 396 ScrollbarTheme::theme()->updateScrollbarOverlayStyle(scrollbar); | 396 ScrollbarTheme::theme().updateScrollbarOverlayStyle(*scrollbar); |
| 397 setScrollbarNeedsPaintInvalidation(scrollbar); | 397 setScrollbarNeedsPaintInvalidation(HorizontalScrollbar); |
| 398 } | 398 } |
| 399 | 399 |
| 400 if (Scrollbar* scrollbar = verticalScrollbar()) { | 400 if (Scrollbar* scrollbar = verticalScrollbar()) { |
| 401 ScrollbarTheme::theme()->updateScrollbarOverlayStyle(scrollbar); | 401 ScrollbarTheme::theme().updateScrollbarOverlayStyle(*scrollbar); |
| 402 setScrollbarNeedsPaintInvalidation(scrollbar); | 402 setScrollbarNeedsPaintInvalidation(VerticalScrollbar); |
| 403 } | 403 } |
| 404 } | 404 } |
| 405 | 405 |
| 406 void ScrollableArea::setScrollbarNeedsPaintInvalidation(Scrollbar* scrollbar) | 406 void ScrollableArea::setScrollbarNeedsPaintInvalidation(ScrollbarOrientation ori
entation) |
| 407 { | 407 { |
| 408 if (scrollbar == horizontalScrollbar()) { | 408 if (orientation == HorizontalScrollbar) |
| 409 m_horizontalScrollbarNeedsPaintInvalidation = true; | 409 m_horizontalScrollbarNeedsPaintInvalidation = true; |
| 410 scrollControlWasSetNeedsPaintInvalidation(); | 410 else |
| 411 return; | |
| 412 } | |
| 413 if (scrollbar == verticalScrollbar()) { | |
| 414 m_verticalScrollbarNeedsPaintInvalidation = true; | 411 m_verticalScrollbarNeedsPaintInvalidation = true; |
| 415 scrollControlWasSetNeedsPaintInvalidation(); | 412 |
| 416 return; | 413 scrollControlWasSetNeedsPaintInvalidation(); |
| 417 } | |
| 418 // Otherwise the scrollbar is just created and has not been set as either | |
| 419 // horizontalScrollbar() or verticalScrollbar(). | |
| 420 } | 414 } |
| 421 | 415 |
| 422 void ScrollableArea::setScrollCornerNeedsPaintInvalidation() | 416 void ScrollableArea::setScrollCornerNeedsPaintInvalidation() |
| 423 { | 417 { |
| 424 if (GraphicsLayer* graphicsLayer = layerForScrollCorner()) { | 418 if (GraphicsLayer* graphicsLayer = layerForScrollCorner()) { |
| 425 graphicsLayer->setNeedsDisplay(); | 419 graphicsLayer->setNeedsDisplay(); |
| 426 return; | 420 return; |
| 427 } | 421 } |
| 428 m_scrollCornerNeedsPaintInvalidation = true; | 422 m_scrollCornerNeedsPaintInvalidation = true; |
| 429 scrollControlWasSetNeedsPaintInvalidation(); | 423 scrollControlWasSetNeedsPaintInvalidation(); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 | 567 |
| 574 } | 568 } |
| 575 | 569 |
| 576 DEFINE_TRACE(ScrollableArea) | 570 DEFINE_TRACE(ScrollableArea) |
| 577 { | 571 { |
| 578 visitor->trace(m_scrollAnimator); | 572 visitor->trace(m_scrollAnimator); |
| 579 visitor->trace(m_programmaticScrollAnimator); | 573 visitor->trace(m_programmaticScrollAnimator); |
| 580 } | 574 } |
| 581 | 575 |
| 582 } // namespace blink | 576 } // namespace blink |
| OLD | NEW |