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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 #include "platform/TraceEvent.h" | 45 #include "platform/TraceEvent.h" |
46 | 46 |
47 static const int kPixelsPerLineStep = 40; | 47 static const int kPixelsPerLineStep = 40; |
48 static const float kMinFractionToStepWhenPaging = 0.875f; | 48 static const float kMinFractionToStepWhenPaging = 0.875f; |
49 | 49 |
50 namespace blink { | 50 namespace blink { |
51 | 51 |
52 struct SameSizeAsScrollableArea { | 52 struct SameSizeAsScrollableArea { |
53 virtual ~SameSizeAsScrollableArea(); | 53 virtual ~SameSizeAsScrollableArea(); |
54 IntRect scrollbarDamage[2]; | |
55 #if ENABLE(ASSERT) && ENABLE(OILPAN) | 54 #if ENABLE(ASSERT) && ENABLE(OILPAN) |
56 VerifyEagerFinalization verifyEager; | 55 VerifyEagerFinalization verifyEager; |
57 #endif | 56 #endif |
58 void* pointer; | 57 void* pointer; |
59 unsigned bitfields : 16; | 58 unsigned bitfields : 16; |
60 IntPoint origin; | 59 IntPoint origin; |
61 }; | 60 }; |
62 | 61 |
63 static_assert(sizeof(ScrollableArea) == sizeof(SameSizeAsScrollableArea), "Scrol
lableArea should stay small"); | 62 static_assert(sizeof(ScrollableArea) == sizeof(SameSizeAsScrollableArea), "Scrol
lableArea should stay small"); |
64 | 63 |
(...skipping 10 matching lines...) Expand all Loading... |
75 int ScrollableArea::maxOverlapBetweenPages() | 74 int ScrollableArea::maxOverlapBetweenPages() |
76 { | 75 { |
77 static int maxOverlapBetweenPages = ScrollbarTheme::theme()->maxOverlapBetwe
enPages(); | 76 static int maxOverlapBetweenPages = ScrollbarTheme::theme()->maxOverlapBetwe
enPages(); |
78 return maxOverlapBetweenPages; | 77 return maxOverlapBetweenPages; |
79 } | 78 } |
80 | 79 |
81 ScrollableArea::ScrollableArea() | 80 ScrollableArea::ScrollableArea() |
82 : m_inLiveResize(false) | 81 : m_inLiveResize(false) |
83 , m_scrollbarOverlayStyle(ScrollbarOverlayStyleDefault) | 82 , m_scrollbarOverlayStyle(ScrollbarOverlayStyleDefault) |
84 , m_scrollOriginChanged(false) | 83 , m_scrollOriginChanged(false) |
| 84 , m_horizontalScrollbarNeedsPaintInvalidation(false) |
| 85 , m_verticalScrollbarNeedsPaintInvalidation(false) |
| 86 , m_scrollCornerNeedsPaintInvalidation(false) |
85 { | 87 { |
86 } | 88 } |
87 | 89 |
88 ScrollableArea::~ScrollableArea() | 90 ScrollableArea::~ScrollableArea() |
89 { | 91 { |
90 } | 92 } |
91 | 93 |
92 void ScrollableArea::clearScrollAnimators() | 94 void ScrollableArea::clearScrollAnimators() |
93 { | 95 { |
94 m_animators.clear(); | 96 m_animators.clear(); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 DoublePoint truncatedPosition = shouldUseIntegerScrollOffset() ? flooredIntP
oint(position) : position; | 241 DoublePoint truncatedPosition = shouldUseIntegerScrollOffset() ? flooredIntP
oint(position) : position; |
240 | 242 |
241 // Tell the derived class to scroll its contents. | 243 // Tell the derived class to scroll its contents. |
242 setScrollOffset(truncatedPosition, scrollType); | 244 setScrollOffset(truncatedPosition, scrollType); |
243 | 245 |
244 Scrollbar* verticalScrollbar = this->verticalScrollbar(); | 246 Scrollbar* verticalScrollbar = this->verticalScrollbar(); |
245 | 247 |
246 // Tell the scrollbars to update their thumb postions. | 248 // Tell the scrollbars to update their thumb postions. |
247 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { | 249 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { |
248 horizontalScrollbar->offsetDidChange(); | 250 horizontalScrollbar->offsetDidChange(); |
249 if (horizontalScrollbar->isOverlayScrollbar() && !hasLayerForHorizontalS
crollbar()) { | 251 if (horizontalScrollbar->isOverlayScrollbar() && !hasLayerForHorizontalS
crollbar()) |
250 if (!verticalScrollbar) | 252 setScrollbarNeedsPaintInvalidation(horizontalScrollbar); |
251 horizontalScrollbar->invalidate(); | |
252 else { | |
253 // If there is both a horizontalScrollbar and a verticalScrollba
r, | |
254 // then we must also invalidate the corner between them. | |
255 IntRect boundsAndCorner = horizontalScrollbar->boundsRect(); | |
256 boundsAndCorner.setWidth(boundsAndCorner.width() + verticalScrol
lbar->width()); | |
257 horizontalScrollbar->invalidateRect(boundsAndCorner); | |
258 } | |
259 } | |
260 } | 253 } |
261 if (verticalScrollbar) { | 254 if (verticalScrollbar) { |
262 verticalScrollbar->offsetDidChange(); | 255 verticalScrollbar->offsetDidChange(); |
263 if (verticalScrollbar->isOverlayScrollbar() && !hasLayerForVerticalScrol
lbar()) | 256 if (verticalScrollbar->isOverlayScrollbar() && !hasLayerForVerticalScrol
lbar()) |
264 verticalScrollbar->invalidate(); | 257 setScrollbarNeedsPaintInvalidation(verticalScrollbar); |
265 } | 258 } |
266 | 259 |
267 if (scrollPositionDouble() != oldPosition) { | 260 if (scrollPositionDouble() != oldPosition) { |
268 // FIXME: Pass in DoubleSize. crbug.com/414283. | 261 // FIXME: Pass in DoubleSize. crbug.com/414283. |
269 scrollAnimator()->notifyContentAreaScrolled(toFloatSize(scrollPositionDo
uble() - oldPosition)); | 262 scrollAnimator()->notifyContentAreaScrolled(toFloatSize(scrollPositionDo
uble() - oldPosition)); |
270 } | 263 } |
271 | 264 |
272 scrollAnimator()->setCurrentPosition(toFloatPoint(position)); | 265 scrollAnimator()->setCurrentPosition(toFloatPoint(position)); |
273 } | 266 } |
274 | 267 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 Scrollbar* hScrollbar = horizontalScrollbar(); | 388 Scrollbar* hScrollbar = horizontalScrollbar(); |
396 return hScrollbar && hScrollbar->isOverlayScrollbar(); | 389 return hScrollbar && hScrollbar->isOverlayScrollbar(); |
397 } | 390 } |
398 | 391 |
399 void ScrollableArea::setScrollbarOverlayStyle(ScrollbarOverlayStyle overlayStyle
) | 392 void ScrollableArea::setScrollbarOverlayStyle(ScrollbarOverlayStyle overlayStyle
) |
400 { | 393 { |
401 m_scrollbarOverlayStyle = overlayStyle; | 394 m_scrollbarOverlayStyle = overlayStyle; |
402 | 395 |
403 if (Scrollbar* scrollbar = horizontalScrollbar()) { | 396 if (Scrollbar* scrollbar = horizontalScrollbar()) { |
404 ScrollbarTheme::theme()->updateScrollbarOverlayStyle(scrollbar); | 397 ScrollbarTheme::theme()->updateScrollbarOverlayStyle(scrollbar); |
405 scrollbar->invalidate(); | 398 setScrollbarNeedsPaintInvalidation(scrollbar); |
406 } | 399 } |
407 | 400 |
408 if (Scrollbar* scrollbar = verticalScrollbar()) { | 401 if (Scrollbar* scrollbar = verticalScrollbar()) { |
409 ScrollbarTheme::theme()->updateScrollbarOverlayStyle(scrollbar); | 402 ScrollbarTheme::theme()->updateScrollbarOverlayStyle(scrollbar); |
410 scrollbar->invalidate(); | 403 setScrollbarNeedsPaintInvalidation(scrollbar); |
411 } | 404 } |
412 } | 405 } |
413 | 406 |
414 void ScrollableArea::invalidateScrollbar(Scrollbar* scrollbar, const IntRect& re
ct) | 407 void ScrollableArea::setScrollbarNeedsPaintInvalidation(Scrollbar* scrollbar) |
415 { | 408 { |
416 if (scrollbar == horizontalScrollbar()) { | 409 if (scrollbar == horizontalScrollbar()) { |
417 if (GraphicsLayer* graphicsLayer = layerForHorizontalScrollbar()) { | 410 if (GraphicsLayer* graphicsLayer = layerForHorizontalScrollbar()) { |
418 graphicsLayer->setNeedsDisplay(); | 411 graphicsLayer->setNeedsDisplay(); |
419 graphicsLayer->setContentsNeedsDisplay(); | 412 graphicsLayer->setContentsNeedsDisplay(); |
420 return; | 413 return; |
421 } | 414 } |
422 invalidateScrollbarRect(scrollbar, rect); | 415 m_horizontalScrollbarNeedsPaintInvalidation = true; |
| 416 scrollControlWasSetNeedsPaintInvalidation(); |
423 return; | 417 return; |
424 } | 418 } |
425 if (scrollbar == verticalScrollbar()) { | 419 if (scrollbar == verticalScrollbar()) { |
426 if (GraphicsLayer* graphicsLayer = layerForVerticalScrollbar()) { | 420 if (GraphicsLayer* graphicsLayer = layerForVerticalScrollbar()) { |
427 graphicsLayer->setNeedsDisplay(); | 421 graphicsLayer->setNeedsDisplay(); |
428 graphicsLayer->setContentsNeedsDisplay(); | 422 graphicsLayer->setContentsNeedsDisplay(); |
429 return; | 423 return; |
430 } | 424 } |
431 invalidateScrollbarRect(scrollbar, rect); | 425 m_verticalScrollbarNeedsPaintInvalidation = true; |
| 426 scrollControlWasSetNeedsPaintInvalidation(); |
432 return; | 427 return; |
433 } | 428 } |
434 // Otherwise the scrollbar is just created and has not been set as either | 429 // Otherwise the scrollbar is just created and has not been set as either |
435 // horizontalScrollbar() or verticalScrollbar(). | 430 // horizontalScrollbar() or verticalScrollbar(). |
436 } | 431 } |
437 | 432 |
438 void ScrollableArea::invalidateScrollCorner(const IntRect& rect) | 433 void ScrollableArea::setScrollCornerNeedsPaintInvalidation() |
439 { | 434 { |
440 if (GraphicsLayer* graphicsLayer = layerForScrollCorner()) { | 435 if (GraphicsLayer* graphicsLayer = layerForScrollCorner()) { |
441 graphicsLayer->setNeedsDisplay(); | 436 graphicsLayer->setNeedsDisplay(); |
442 return; | 437 return; |
443 } | 438 } |
444 invalidateScrollCornerRect(rect); | 439 m_scrollCornerNeedsPaintInvalidation = true; |
| 440 scrollControlWasSetNeedsPaintInvalidation(); |
445 } | 441 } |
446 | 442 |
447 bool ScrollableArea::hasLayerForHorizontalScrollbar() const | 443 bool ScrollableArea::hasLayerForHorizontalScrollbar() const |
448 { | 444 { |
449 return layerForHorizontalScrollbar(); | 445 return layerForHorizontalScrollbar(); |
450 } | 446 } |
451 | 447 |
452 bool ScrollableArea::hasLayerForVerticalScrollbar() const | 448 bool ScrollableArea::hasLayerForVerticalScrollbar() const |
453 { | 449 { |
454 return layerForVerticalScrollbar(); | 450 return layerForVerticalScrollbar(); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBa
r->width() : 0; | 578 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBa
r->width() : 0; |
583 if (Scrollbar* horizontalBar = horizontalScrollbar()) | 579 if (Scrollbar* horizontalBar = horizontalScrollbar()) |
584 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horiz
ontalBar->height() : 0; | 580 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horiz
ontalBar->height() : 0; |
585 | 581 |
586 return IntSize(std::max(0, size.width() - verticalScrollbarWidth), | 582 return IntSize(std::max(0, size.width() - verticalScrollbarWidth), |
587 std::max(0, size.height() - horizontalScrollbarHeight)); | 583 std::max(0, size.height() - horizontalScrollbarHeight)); |
588 | 584 |
589 } | 585 } |
590 | 586 |
591 } // namespace blink | 587 } // namespace blink |
OLD | NEW |