Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1777)

Unified Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 1406133005: Calculate paint invalidation rect for scrollbars (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/frame/FrameView.cpp
diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp
index 29096603d9b63a9755fa09492108724c80373533..7849aee0df70855e915150cfee84e185c9bedb93 100644
--- a/third_party/WebKit/Source/core/frame/FrameView.cpp
+++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
@@ -382,9 +382,6 @@ bool FrameView::didFirstLayout() const
void FrameView::invalidateRect(const IntRect& rect)
{
- // For querying PaintLayer::compositingState() when invalidating scrollbars.
- // FIXME: do all scrollbar invalidations after layout of all frames is complete. It's currently not recursively true.
- DisableCompositingQueryAsserts disabler;
if (!parent()) {
if (HostWindow* window = hostWindow())
window->invalidateRect(rect);
@@ -400,7 +397,7 @@ void FrameView::invalidateRect(const IntRect& rect)
layoutObject->borderTop() + layoutObject->paddingTop());
// FIXME: We should not allow paint invalidation out of paint invalidation state. crbug.com/457415
DisablePaintInvalidationStateAsserts paintInvalidationAssertDisabler;
- layoutObject->invalidatePaintRectangle(LayoutRect(paintInvalidationRect));
+ layoutObject->invalidatePaintRectangleNotInvalidatingDisplayItemClients(LayoutRect(paintInvalidationRect));
}
void FrameView::setFrameRect(const IntRect& newRect)
@@ -983,7 +980,7 @@ void FrameView::layout()
setHorizontalScrollbarMode(ScrollbarAlwaysOff); // This causes a horizontal scrollbar to disappear.
setScrollbarModes(hMode, vMode);
- setScrollbarsSuppressed(false, true);
+ setScrollbarsSuppressed(false);
} else if (hMode != currentHMode || vMode != currentVMode) {
setScrollbarModes(hMode, vMode);
}
@@ -1057,10 +1054,6 @@ void FrameView::layout()
frame().document()->layoutUpdated();
}
-// The plan is to move to compositor-queried paint invalidation, in which case this
-// method would setNeedsRedraw on the GraphicsLayers with invalidations and
-// let the compositor pick which to actually draw.
-// See http://crbug.com/306706
void FrameView::invalidateTreeIfNeeded(PaintInvalidationState& paintInvalidationState)
{
if (shouldThrottleRendering())
@@ -1076,12 +1069,12 @@ void FrameView::invalidateTreeIfNeeded(PaintInvalidationState& paintInvalidation
rootForPaintInvalidation.invalidateTreeIfNeeded(paintInvalidationState);
- // Invalidate the paint of the frameviews scrollbars if needed
- if (hasVerticalBarDamage())
- invalidateRect(verticalBarDamage());
- if (hasHorizontalBarDamage())
- invalidateRect(horizontalBarDamage());
- resetScrollbarDamage();
+
+ if (!m_frame->settings() || !m_frame->settings()->rootLayerScrolls()) {
+ paintInvalidationState.setViewClippingAndScrollOffsetDisabled(true);
+ invalidatePaintOfScrollControlsIfNeeded(rootForPaintInvalidation, paintInvalidationState, paintInvalidationState.paintInvalidationContainer(), m_scrollCorner, nullptr);
+ paintInvalidationState.setViewClippingAndScrollOffsetDisabled(false);
+ }
#if ENABLE(ASSERT)
layoutView()->assertSubtreeClearedPaintInvalidationState();
@@ -1509,8 +1502,7 @@ void FrameView::didUpdateElasticOverscroll()
if (delta != 0) {
m_horizontalScrollbar->setElasticOverscroll(elasticOverscroll.width());
scrollAnimator()->notifyContentAreaScrolled(FloatSize(delta, 0));
- if (!m_scrollbarsSuppressed)
chrishtr 2015/11/17 01:34:20 So now we always invalidate, even with m_scrollbar
Xianzhu 2015/11/17 18:31:36 Previously we invalidated or added scrollbar damag
chrishtr 2015/11/17 18:52:54 Is there any benefit to the scrollbarsSuppressed()
Xianzhu 2015/11/17 19:04:24 The comment for setScrollbarsSuppressed() seems in
- m_horizontalScrollbar->invalidate();
+ setScrollbarNeedsPaintInvalidation(m_horizontalScrollbar.get());
}
}
if (m_verticalScrollbar) {
@@ -1518,8 +1510,7 @@ void FrameView::didUpdateElasticOverscroll()
if (delta != 0) {
m_verticalScrollbar->setElasticOverscroll(elasticOverscroll.height());
scrollAnimator()->notifyContentAreaScrolled(FloatSize(0, delta));
- if (!m_scrollbarsSuppressed)
- m_verticalScrollbar->invalidate();
+ setScrollbarNeedsPaintInvalidation(m_verticalScrollbar.get());
}
}
}
@@ -2083,24 +2074,10 @@ void FrameView::scrollTo(const DoublePoint& newPosition)
frame().loader().client()->didChangeScrollOffset();
}
-void FrameView::invalidatePaintForTickmarks() const
+void FrameView::invalidatePaintForTickmarks()
{
if (Scrollbar* scrollbar = verticalScrollbar())
- scrollbar->invalidate();
-}
-
-void FrameView::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect)
-{
- // Add in our offset within the FrameView.
- IntRect dirtyRect = rect;
- dirtyRect.moveBy(scrollbar->location());
-
- layoutView()->invalidateDisplayItemClient(*scrollbar);
-
- if (isInPerformLayout())
- addScrollbarDamage(scrollbar, rect);
- else
- invalidateRect(dirtyRect);
+ setScrollbarNeedsPaintInvalidation(scrollbar);
}
void FrameView::getTickmarks(Vector<IntRect>& tickmarks) const
@@ -2300,7 +2277,7 @@ void FrameView::updateScrollCorner()
if (!m_scrollCorner)
m_scrollCorner = LayoutScrollbarPart::createAnonymous(doc);
m_scrollCorner->setStyle(cornerStyle.release());
- invalidateScrollCorner(cornerRect);
+ setScrollCornerNeedsPaintInvalidation();
} else if (m_scrollCorner) {
m_scrollCorner->destroy();
m_scrollCorner = nullptr;
@@ -3011,7 +2988,7 @@ void FrameView::setHasHorizontalScrollbar(bool hasBar)
didAddScrollbar(m_horizontalScrollbar.get(), HorizontalScrollbar);
m_horizontalScrollbar->styleChanged();
} else {
- willRemoveScrollbar(m_horizontalScrollbar.get(), HorizontalScrollbar);
+ willRemoveScrollbar(*layoutView(), m_horizontalScrollbar.get(), HorizontalScrollbar);
if (AXObjectCache* cache = axObjectCache())
cache->remove(m_horizontalScrollbar.get());
// If the scrollbar has been marked as overlapping the window resizer,
@@ -3025,7 +3002,7 @@ void FrameView::setHasHorizontalScrollbar(bool hasBar)
cache->handleScrollbarUpdate(this);
}
- invalidateScrollCorner(scrollCornerRect());
+ setScrollCornerNeedsPaintInvalidation();
}
void FrameView::setHasVerticalScrollbar(bool hasBar)
@@ -3039,7 +3016,7 @@ void FrameView::setHasVerticalScrollbar(bool hasBar)
didAddScrollbar(m_verticalScrollbar.get(), VerticalScrollbar);
m_verticalScrollbar->styleChanged();
} else {
- willRemoveScrollbar(m_verticalScrollbar.get(), VerticalScrollbar);
+ willRemoveScrollbar(*layoutView(), m_verticalScrollbar.get(), VerticalScrollbar);
if (AXObjectCache* cache = axObjectCache())
cache->remove(m_verticalScrollbar.get());
// If the scrollbar has been marked as overlapping the window resizer,
@@ -3053,7 +3030,7 @@ void FrameView::setHasVerticalScrollbar(bool hasBar)
cache->handleScrollbarUpdate(this);
}
- invalidateScrollCorner(scrollCornerRect());
+ setScrollCornerNeedsPaintInvalidation();
}
void FrameView::setScrollbarModes(ScrollbarMode horizontalMode, ScrollbarMode verticalMode,
@@ -3220,16 +3197,12 @@ void FrameView::updateScrollbarGeometry()
width() - (m_verticalScrollbar ? m_verticalScrollbar->width() : 0),
m_horizontalScrollbar->height());
m_horizontalScrollbar->setFrameRect(adjustScrollbarRectForResizer(hBarRect, m_horizontalScrollbar.get()));
- if (!m_scrollbarsSuppressed && oldRect != m_horizontalScrollbar->frameRect())
- m_horizontalScrollbar->invalidate();
+ if (oldRect != m_horizontalScrollbar->frameRect())
+ setScrollbarNeedsPaintInvalidation(m_horizontalScrollbar.get());
- if (m_scrollbarsSuppressed)
- m_horizontalScrollbar->setSuppressInvalidation(true);
m_horizontalScrollbar->setEnabled(contentsWidth() > clientWidth);
m_horizontalScrollbar->setProportion(clientWidth, contentsWidth());
m_horizontalScrollbar->offsetDidChange();
- if (m_scrollbarsSuppressed)
- m_horizontalScrollbar->setSuppressInvalidation(false);
}
if (m_verticalScrollbar) {
@@ -3240,16 +3213,12 @@ void FrameView::updateScrollbarGeometry()
m_verticalScrollbar->width(),
height() - (m_horizontalScrollbar ? m_horizontalScrollbar->height() : 0));
m_verticalScrollbar->setFrameRect(adjustScrollbarRectForResizer(vBarRect, m_verticalScrollbar.get()));
- if (!m_scrollbarsSuppressed && oldRect != m_verticalScrollbar->frameRect())
- m_verticalScrollbar->invalidate();
+ if (oldRect != m_verticalScrollbar->frameRect())
+ setScrollbarNeedsPaintInvalidation(m_verticalScrollbar.get());
- if (m_scrollbarsSuppressed)
- m_verticalScrollbar->setSuppressInvalidation(true);
m_verticalScrollbar->setEnabled(contentsHeight() > clientHeight);
m_verticalScrollbar->setProportion(clientHeight, contentsHeight());
m_verticalScrollbar->offsetDidChange();
- if (m_scrollbarsSuppressed)
- m_verticalScrollbar->setSuppressInvalidation(false);
}
}
@@ -3352,8 +3321,6 @@ void FrameView::updateScrollbars(const DoubleSize& desiredOffset)
return;
InUpdateScrollbarsScope inUpdateScrollbarsScope(this);
- IntSize oldVisibleSize = visibleContentSize();
-
bool scrollbarExistenceChanged = false;
if (needsScrollbarReconstruction()) {
@@ -3378,17 +3345,6 @@ void FrameView::updateScrollbars(const DoubleSize& desiredOffset)
updateScrollCorner();
}
- // FIXME: We don't need to do this if we are composited.
- IntSize newVisibleSize = visibleContentSize();
- if (newVisibleSize.width() > oldVisibleSize.width()) {
- if (shouldPlaceVerticalScrollbarOnLeft())
- invalidateRect(IntRect(0, 0, newVisibleSize.width() - oldVisibleSize.width(), newVisibleSize.height()));
- else
- invalidateRect(IntRect(oldVisibleSize.width(), 0, newVisibleSize.width() - oldVisibleSize.width(), newVisibleSize.height()));
- }
- if (newVisibleSize.height() > oldVisibleSize.height())
- invalidateRect(IntRect(0, oldVisibleSize.height(), newVisibleSize.width(), newVisibleSize.height() - oldVisibleSize.height()));
-
setScrollOffsetFromUpdateScrollbars(desiredOffset);
}
@@ -3569,24 +3525,6 @@ void FrameView::adjustScrollbarsAvoidingResizerCount(int overlapDelta)
}
}
-void FrameView::setScrollbarsSuppressed(bool suppressed, bool repaintOnUnsuppress)
-{
- if (suppressed == m_scrollbarsSuppressed)
- return;
-
- m_scrollbarsSuppressed = suppressed;
-
- if (repaintOnUnsuppress && !suppressed) {
- if (m_horizontalScrollbar)
- m_horizontalScrollbar->invalidate();
- if (m_verticalScrollbar)
- m_verticalScrollbar->invalidate();
-
- // Invalidate the scroll corner too on unsuppress.
- invalidateScrollCorner(scrollCornerRect());
- }
-}
-
Scrollbar* FrameView::scrollbarAtRootFramePoint(const IntPoint& pointInRootFrame)
{
IntPoint pointInFrame = convertFromContainingWindow(pointInRootFrame);
@@ -3706,13 +3644,6 @@ bool FrameView::isScrollCornerVisible() const
return !scrollCornerRect().isEmpty();
}
-void FrameView::invalidateScrollCornerRect(const IntRect& rect)
-{
- invalidateRect(rect);
- if (m_scrollCorner)
- layoutView()->invalidateDisplayItemClientForNonCompositingDescendantsOf(*m_scrollCorner);
-}
-
ScrollBehavior FrameView::scrollBehaviorStyle() const
{
Element* scrollElement = m_frame->document()->scrollingElement();

Powered by Google App Engine
This is Rietveld 408576698