| Index: third_party/WebKit/Source/platform/scroll/Scrollbar.cpp
|
| diff --git a/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp b/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp
|
| index 19538b25345adfea775bd2084f30f5c464d38b67..e549491bede882e566d442ce698a1b9a5975291b 100644
|
| --- a/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp
|
| +++ b/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp
|
| @@ -34,6 +34,12 @@
|
| #include "platform/scroll/ScrollableArea.h"
|
| #include "platform/scroll/ScrollbarTheme.h"
|
|
|
| +#if ((OS(POSIX) && !OS(MACOSX)) || OS(WIN))
|
| +// The position of the scrollbar thumb affects the appearance of the steppers, so
|
| +// when the thumb moves, we have to invalidate them for painting.
|
| +#define THUMB_POSITION_AFFECTS_BUTTONS
|
| +#endif
|
| +
|
| namespace blink {
|
|
|
| PassRefPtrWillBeRawPtr<Scrollbar> Scrollbar::create(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, ScrollbarControlSize size)
|
| @@ -59,6 +65,7 @@
|
| , m_enabled(true)
|
| , m_scrollTimer(this, &Scrollbar::autoscrollTimerFired)
|
| , m_overlapsResizer(false)
|
| + , m_suppressInvalidation(false)
|
| , m_isAlphaLocked(false)
|
| , m_elasticOverscroll(0)
|
| {
|
| @@ -92,8 +99,9 @@
|
| if (frameRect == this->frameRect())
|
| return;
|
|
|
| + invalidate();
|
| Widget::setFrameRect(frameRect);
|
| - setNeedsPaintInvalidation();
|
| + invalidate();
|
| }
|
|
|
| ScrollbarOverlayStyle Scrollbar::scrollbarOverlayStyle() const
|
| @@ -152,7 +160,11 @@
|
|
|
| void Scrollbar::updateThumb()
|
| {
|
| - setNeedsPaintInvalidation();
|
| +#ifdef THUMB_POSITION_AFFECTS_BUTTONS
|
| + invalidate();
|
| +#else
|
| + theme()->invalidateParts(this, ForwardTrackPart | BackTrackPart | ThumbPart);
|
| +#endif
|
| }
|
|
|
| void Scrollbar::updateThumbPosition()
|
| @@ -194,7 +206,7 @@
|
|
|
| // Handle the track.
|
| if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && thumbUnderMouse(this)) {
|
| - setNeedsPaintInvalidation();
|
| + theme()->invalidatePart(this, m_pressedPart);
|
| setHoveredPart(ThumbPart);
|
| return;
|
| }
|
| @@ -213,7 +225,7 @@
|
| // Handle the track. We halt track scrolling once the thumb is level
|
| // with us.
|
| if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && thumbUnderMouse(this)) {
|
| - setNeedsPaintInvalidation();
|
| + theme()->invalidatePart(this, m_pressedPart);
|
| setHoveredPart(ThumbPart);
|
| return;
|
| }
|
| @@ -307,21 +319,24 @@
|
| if (part == m_hoveredPart)
|
| return;
|
|
|
| - if (((m_hoveredPart == NoPart || part == NoPart) && theme()->invalidateOnMouseEnterExit())
|
| - // When there's a pressed part, we don't draw a hovered state, so there's no reason to invalidate.
|
| - || m_pressedPart == NoPart)
|
| - setNeedsPaintInvalidation();
|
| -
|
| + if ((m_hoveredPart == NoPart || part == NoPart) && theme()->invalidateOnMouseEnterExit())
|
| + invalidate(); // Just invalidate the whole scrollbar, since the buttons at either end change anyway.
|
| + else if (m_pressedPart == NoPart) { // When there's a pressed part, we don't draw a hovered state, so there's no reason to invalidate.
|
| + theme()->invalidatePart(this, part);
|
| + theme()->invalidatePart(this, m_hoveredPart);
|
| + }
|
| m_hoveredPart = part;
|
| }
|
|
|
| void Scrollbar::setPressedPart(ScrollbarPart part)
|
| {
|
| - if (m_pressedPart != NoPart
|
| - // When we no longer have a pressed part, we can start drawing a hovered state on the hovered part.
|
| - || m_hoveredPart != NoPart)
|
| - setNeedsPaintInvalidation();
|
| + if (m_pressedPart != NoPart)
|
| + theme()->invalidatePart(this, m_pressedPart);
|
| m_pressedPart = part;
|
| + if (m_pressedPart != NoPart)
|
| + theme()->invalidatePart(this, m_pressedPart);
|
| + else if (m_hoveredPart != NoPart) // When we no longer have a pressed part, we can start drawing a hovered state on the hovered part.
|
| + theme()->invalidatePart(this, m_hoveredPart);
|
| }
|
|
|
| bool Scrollbar::gestureEvent(const PlatformGestureEvent& evt)
|
| @@ -391,12 +406,12 @@
|
| // The mouse is moving back over the pressed part. We
|
| // need to start up the timer action again.
|
| startTimerIfNeeded(theme()->autoscrollTimerDelay());
|
| - setNeedsPaintInvalidation();
|
| + theme()->invalidatePart(this, m_pressedPart);
|
| } else if (m_hoveredPart == m_pressedPart) {
|
| // The mouse is leaving the pressed part. Kill our timer
|
| // if needed.
|
| stopTimerIfNeeded();
|
| - setNeedsPaintInvalidation();
|
| + theme()->invalidatePart(this, m_pressedPart);
|
| }
|
| }
|
|
|
| @@ -475,7 +490,7 @@
|
| return;
|
| m_enabled = e;
|
| theme()->updateEnabledState(this);
|
| - setNeedsPaintInvalidation();
|
| + invalidate();
|
| }
|
|
|
| bool Scrollbar::isOverlayScrollbar() const
|
| @@ -496,6 +511,15 @@
|
| return m_scrollableArea && m_scrollableArea->isActive();
|
| }
|
|
|
| +void Scrollbar::invalidateRect(const IntRect& rect)
|
| +{
|
| + if (suppressInvalidation())
|
| + return;
|
| +
|
| + if (m_scrollableArea)
|
| + m_scrollableArea->invalidateScrollbar(this, rect);
|
| +}
|
| +
|
| IntRect Scrollbar::convertToContainingView(const IntRect& localRect) const
|
| {
|
| if (m_scrollableArea)
|
| @@ -539,10 +563,4 @@
|
| return m_scrollableArea->scrollPosition().y() - m_scrollableArea->minimumScrollPosition().y();
|
| }
|
|
|
| -void Scrollbar::setNeedsPaintInvalidation()
|
| -{
|
| - if (m_scrollableArea)
|
| - m_scrollableArea->setScrollbarNeedsPaintInvalidation(this);
|
| -}
|
| -
|
| } // namespace blink
|
|
|