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