Index: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp |
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp |
index 282ec669367b4182c74c08c441d105b5eceb4465..b7ea489f47a8bfc36198b4f6a6227cd1f5bbd721 100644 |
--- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp |
+++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp |
@@ -199,9 +199,61 @@ |
return layer()->hasCompositedLayerMapping() ? layer()->compositedLayerMapping()->layerForScrollCorner() : 0; |
} |
-void PaintLayerScrollableArea::scrollControlWasSetNeedsPaintInvalidation() |
-{ |
- box().setMayNeedPaintInvalidation(); |
+void PaintLayerScrollableArea::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect) |
+{ |
+ // See crbug.com/343132. |
+ DisableCompositingQueryAsserts disabler; |
+ |
+ ASSERT(scrollbar == horizontalScrollbar() || scrollbar == verticalScrollbar()); |
+ ASSERT(scrollbar == horizontalScrollbar() ? !layerForHorizontalScrollbar() : !layerForVerticalScrollbar()); |
+ |
+ IntRect scrollRect = rect; |
+ // If we are not yet inserted into the tree, there is no need to issue paint invaldiations. |
+ if (!box().isLayoutView() && !box().parent()) |
+ return; |
+ |
+ if (scrollbar == verticalScrollbar()) |
+ scrollRect.move(verticalScrollbarStart(0, box().size().width()), box().borderTop()); |
+ else |
+ scrollRect.move(horizontalScrollbarStart(0), box().size().height() - box().borderBottom() - scrollbar->height()); |
+ |
+ if (scrollRect.isEmpty()) |
+ return; |
+ |
+ LayoutRect paintInvalidationRect = LayoutRect(scrollRect); |
+ box().flipForWritingMode(paintInvalidationRect); |
+ |
+ IntRect intRect = pixelSnappedIntRect(paintInvalidationRect); |
+ |
+ if (box().frameView()->isInPerformLayout()) { |
+ addScrollbarDamage(scrollbar, intRect); |
+ } else { |
+ // FIXME: We should not allow paint invalidation out of paint invalidation state. crbug.com/457415 |
+ DisablePaintInvalidationStateAsserts disabler; |
+ // We have invalidated the displayItemClient of the scrollbar, but for now we still need to |
+ // invalidate the rectangles to trigger repaints. |
+ box().invalidatePaintRectangleNotInvalidatingDisplayItemClients(LayoutRect(intRect)); |
+ box().invalidateDisplayItemClient(*scrollbar); |
+ } |
+} |
+ |
+void PaintLayerScrollableArea::invalidateScrollCornerRect(const IntRect& rect) |
+{ |
+ ASSERT(!layerForScrollCorner()); |
+ |
+ if (m_scrollCorner) { |
+ // FIXME: We should not allow paint invalidation out of paint invalidation state. crbug.com/457415 |
+ DisablePaintInvalidationStateAsserts disabler; |
+ DisableCompositingQueryAsserts compositingDisabler; |
+ m_scrollCorner->invalidatePaintRectangle(LayoutRect(rect)); |
+ box().invalidateDisplayItemClientForNonCompositingDescendantsOf(*m_scrollCorner); |
+ } else { |
+ box().invalidateDisplayItemClient(box()); |
+ } |
+ if (m_resizer) { |
+ m_resizer->invalidatePaintRectangle(LayoutRect(rect)); |
+ box().invalidateDisplayItemClientForNonCompositingDescendantsOf(*m_resizer); |
+ } |
} |
bool PaintLayerScrollableArea::shouldUseIntegerScrollOffset() const |
@@ -984,8 +1036,8 @@ |
if (hasScrollbar == hasHorizontalScrollbar()) |
return; |
- setScrollbarNeedsPaintInvalidation(horizontalScrollbar()); |
- |
+ if (!hasScrollbar && !layerForHorizontalScrollbar()) |
+ horizontalScrollbar()->invalidate(); |
m_scrollbarManager.setHasHorizontalScrollbar(hasScrollbar); |
@@ -995,7 +1047,10 @@ |
if (hasVerticalScrollbar()) |
verticalScrollbar()->styleChanged(); |
- setScrollCornerNeedsPaintInvalidation(); |
+ // These are valid because we want to invalidate display item clients on the current backing. |
+ DisablePaintInvalidationStateAsserts paintInvalidationAssertDisabler; |
+ DisableCompositingQueryAsserts compositingAssertDisabler; |
+ invalidateScrollCorner(scrollCornerRect()); |
// Force an update since we know the scrollbars have changed things. |
if (box().document().hasAnnotatedRegions()) |
@@ -1007,7 +1062,8 @@ |
if (hasScrollbar == hasVerticalScrollbar()) |
return; |
- setScrollbarNeedsPaintInvalidation(verticalScrollbar()); |
+ if (!hasScrollbar && !layerForVerticalScrollbar()) |
+ verticalScrollbar()->invalidate(); |
m_scrollbarManager.setHasVerticalScrollbar(hasScrollbar); |
@@ -1017,7 +1073,10 @@ |
if (hasVerticalScrollbar()) |
verticalScrollbar()->styleChanged(); |
- setScrollCornerNeedsPaintInvalidation(); |
+ // These are valid because we want to invalidate display item clients on the current backing. |
+ DisablePaintInvalidationStateAsserts paintInvalidationAssertDisabler; |
+ DisableCompositingQueryAsserts compositingAssertDisabler; |
+ invalidateScrollCorner(scrollCornerRect()); |
// Force an update since we know the scrollbars have changed things. |
if (box().document().hasAnnotatedRegions()) |
@@ -1439,9 +1498,9 @@ |
m_canDetachScrollbars = detach ? 1 : 0; |
if (!detach) { |
if (m_hBar && !m_hBarIsAttached) |
- destroyScrollbar(HorizontalScrollbar); |
+ destroyScrollbar(HorizontalScrollbar, true); |
if (m_vBar && !m_vBarIsAttached) |
- destroyScrollbar(VerticalScrollbar); |
+ destroyScrollbar(VerticalScrollbar, true); |
} |
} |
@@ -1497,15 +1556,17 @@ |
return widget.release(); |
} |
-void PaintLayerScrollableArea::ScrollbarManager::destroyScrollbar(ScrollbarOrientation orientation) |
+void PaintLayerScrollableArea::ScrollbarManager::destroyScrollbar(ScrollbarOrientation orientation, bool invalidate) |
{ |
RefPtrWillBeMember<Scrollbar>& scrollbar = orientation == HorizontalScrollbar ? m_hBar : m_vBar; |
ASSERT(orientation == HorizontalScrollbar ? !m_hBarIsAttached: !m_vBarIsAttached); |
if (!scrollbar) |
return; |
- m_scrollableArea->setScrollbarNeedsPaintInvalidation(scrollbar.get()); |
- |
+ if (invalidate) { |
+ m_scrollableArea->box().invalidateDisplayItemClient(*scrollbar); |
+ scrollbar->invalidate(); |
+ } |
if (!scrollbar->isCustomScrollbar()) |
m_scrollableArea->willRemoveScrollbar(scrollbar.get(), orientation); |