Commit 027a0205 authored by skobes's avatar skobes Committed by Commit bot

Root layer scrolling: set correct size for document's main GraphicsLayer.

The main GraphicsLayer of a composited scroller should be the size of the
scroller's frame.  Report this size in PaintLayer::boundingBoxForCompositing
and update ViewPainter to use the same rect when painting the background fill.

This fixes placement of scrollbar layers in RTL documents, which were confused
by a bogus m_offsetFromLayoutObject because the rect returned by
LayoutView::documentRect is relative to the scroll origin.

This patch makes compositing/rtl/rtl-overflow-invalidation.html pass (discovered
through flag-specific expectations!)

Sadly we regress several repaint-tracking tests due to the new invalidation in
FrameView::viewportSizeChanged.  These will need flag-specific baselines (not
yet implemented) at least until http://crbug.com/568847 is addressed.

BUG=542432

Review URL: https://codereview.chromium.org/1472083006

Cr-Commit-Position: refs/heads/master@{#367034}
parent cd32776f
...@@ -92,7 +92,6 @@ compositing/rtl/rtl-iframe-fixed-overflow-scrolled.html [ Failure ] ...@@ -92,7 +92,6 @@ compositing/rtl/rtl-iframe-fixed-overflow-scrolled.html [ Failure ]
compositing/rtl/rtl-iframe-fixed-overflow.html [ Failure ] compositing/rtl/rtl-iframe-fixed-overflow.html [ Failure ]
compositing/rtl/rtl-iframe-fixed.html [ Failure ] compositing/rtl/rtl-iframe-fixed.html [ Failure ]
compositing/rtl/rtl-iframe-relative.html [ Failure ] compositing/rtl/rtl-iframe-relative.html [ Failure ]
compositing/rtl/rtl-overflow-invalidation.html [ Failure ]
compositing/scrollbars/custom-composited-different-track-parts.html [ Failure ] compositing/scrollbars/custom-composited-different-track-parts.html [ Failure ]
compositing/squashing/iframe-inside-squashed-layer.html [ Failure ] compositing/squashing/iframe-inside-squashed-layer.html [ Failure ]
compositing/squashing/remove-squashed-layer-plus-move.html [ Failure ] compositing/squashing/remove-squashed-layer-plus-move.html [ Failure ]
...@@ -398,6 +397,12 @@ fast/repaint/window-resize-background-image-non-fixed.html [ Failure ] ...@@ -398,6 +397,12 @@ fast/repaint/window-resize-background-image-non-fixed.html [ Failure ]
fast/repaint/window-resize-media-query.html [ Failure ] fast/repaint/window-resize-media-query.html [ Failure ]
fast/repaint/window-resize-no-layout-change1.html [ Failure ] fast/repaint/window-resize-no-layout-change1.html [ Failure ]
fast/repaint/window-resize-no-layout-change2.html [ Failure ] fast/repaint/window-resize-no-layout-change2.html [ Failure ]
fast/repaint/window-resize-percent-html.html [ Failure ]
fast/repaint/window-resize-percent-width-height.html [ Failure ]
fast/repaint/window-resize-positioned-bottom.html [ Failure ]
fast/repaint/window-resize-positioned-percent-top.html [ Failure ]
fast/repaint/window-resize-vertical-writing-mode.html [ Failure ]
fast/repaint/window-resize-viewport-percent.html [ Failure ]
fast/replaced/border-radius-clip.html [ Failure ] fast/replaced/border-radius-clip.html [ Failure ]
fast/scroll-behavior/main-frame-element-scroll.html [ Failure ] fast/scroll-behavior/main-frame-element-scroll.html [ Failure ]
fast/scroll-behavior/main-frame-element-scrollBy.html [ Failure ] fast/scroll-behavior/main-frame-element-scrollBy.html [ Failure ]
...@@ -483,12 +488,14 @@ scrollbars/custom-scrollbar-changing-style.html [ Failure ] ...@@ -483,12 +488,14 @@ scrollbars/custom-scrollbar-changing-style.html [ Failure ]
scrollingcoordinator/non-fast-scrollable-visibility-change.html [ Failure ] scrollingcoordinator/non-fast-scrollable-visibility-change.html [ Failure ]
svg/as-object/deep-nested-embedded-svg-size-changes-no-layout-triggers-1.html [ Failure ] svg/as-object/deep-nested-embedded-svg-size-changes-no-layout-triggers-1.html [ Failure ]
svg/as-object/deep-nested-embedded-svg-size-changes-no-layout-triggers-2.html [ Failure ] svg/as-object/deep-nested-embedded-svg-size-changes-no-layout-triggers-2.html [ Failure ]
svg/as-object/embedded-svg-size-changes-no-layout-triggers.html [ Failure ]
svg/as-object/nested-embedded-svg-size-changes-no-layout-triggers-1.html [ Failure ] svg/as-object/nested-embedded-svg-size-changes-no-layout-triggers-1.html [ Failure ]
svg/as-object/nested-embedded-svg-size-changes-no-layout-triggers-2.html [ Failure ] svg/as-object/nested-embedded-svg-size-changes-no-layout-triggers-2.html [ Failure ]
svg/custom/getscreenctm-in-scrollable-svg-area.xhtml [ Failure ] svg/custom/getscreenctm-in-scrollable-svg-area.xhtml [ Failure ]
svg/custom/junk-data.svg [ Failure ] svg/custom/junk-data.svg [ Failure ]
svg/custom/load-non-wellformed.svg [ Failure ] svg/custom/load-non-wellformed.svg [ Failure ]
svg/custom/missing-xlink.svg [ Failure ] svg/custom/missing-xlink.svg [ Failure ]
svg/custom/object-sizing-no-width-height-change-content-box-size.xhtml [ Failure ]
svg/custom/path-bad-data.svg [ Failure ] svg/custom/path-bad-data.svg [ Failure ]
svg/custom/scrolling-embedded-svg-file-image-repaint-problem.html [ Failure ] svg/custom/scrolling-embedded-svg-file-image-repaint-problem.html [ Failure ]
svg/custom/text-xy-updates-SVGList.xhtml [ Failure ] svg/custom/text-xy-updates-SVGList.xhtml [ Failure ]
......
...@@ -1253,6 +1253,17 @@ void FrameView::removeViewportConstrainedObject(LayoutObject* object) ...@@ -1253,6 +1253,17 @@ void FrameView::removeViewportConstrainedObject(LayoutObject* object)
void FrameView::viewportSizeChanged(bool widthChanged, bool heightChanged) void FrameView::viewportSizeChanged(bool widthChanged, bool heightChanged)
{ {
if (m_frame->settings() && m_frame->settings()->rootLayerScrolls()) {
// The background must be repainted when the FrameView is resized, even if the initial
// containing block does not change (so we can't rely on layout to issue the invalidation).
// This is because the background fills the main GraphicsLayer, which takes the size of the
// layout viewport.
// TODO(skobes): Paint non-fixed backgrounds into the scrolling contents layer and avoid
// this invalidation (http://crbug.com/568847).
if (LayoutView* lv = layoutView())
lv->setShouldDoFullPaintInvalidation();
}
if (!hasViewportConstrainedObjects()) if (!hasViewportConstrainedObjects())
return; return;
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include "core/frame/DeprecatedScheduleStyleRecalcDuringLayout.h" #include "core/frame/DeprecatedScheduleStyleRecalcDuringLayout.h"
#include "core/frame/FrameView.h" #include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h" #include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
#include "core/html/HTMLFrameElement.h" #include "core/html/HTMLFrameElement.h"
#include "core/layout/HitTestRequest.h" #include "core/layout/HitTestRequest.h"
#include "core/layout/HitTestResult.h" #include "core/layout/HitTestResult.h"
...@@ -2212,8 +2213,8 @@ LayoutRect PaintLayer::boundingBoxForCompositing(const PaintLayer* ancestorLayer ...@@ -2212,8 +2213,8 @@ LayoutRect PaintLayer::boundingBoxForCompositing(const PaintLayer* ancestorLayer
if (this != ancestorLayer && !hasVisibleContent() && !hasVisibleDescendant()) if (this != ancestorLayer && !hasVisibleContent() && !hasVisibleDescendant())
return LayoutRect(); return LayoutRect();
// The root layer is always just the size of the document. // Without composited scrolling, the root layer is the size of the document.
if (isRootLayer()) if (isRootLayer() && !needsCompositedScrolling())
return LayoutRect(m_layoutObject->view()->documentRect()); return LayoutRect(m_layoutObject->view()->documentRect());
// The layer created for the LayoutFlowThread is just a helper for painting and hit-testing, // The layer created for the LayoutFlowThread is just a helper for painting and hit-testing,
......
...@@ -55,7 +55,8 @@ void ViewPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo) ...@@ -55,7 +55,8 @@ void ViewPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo)
if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, m_layoutView, DisplayItem::BoxDecorationBackground, LayoutPoint())) if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, m_layoutView, DisplayItem::BoxDecorationBackground, LayoutPoint()))
return; return;
IntRect documentRect = m_layoutView.documentRect(); // The background fill rect is the size of the LayoutView's main GraphicsLayer.
IntRect backgroundRect = pixelSnappedIntRect(m_layoutView.layer()->boundingBoxForCompositing());
const Document& document = m_layoutView.document(); const Document& document = m_layoutView.document();
const FrameView& frameView = *m_layoutView.frameView(); const FrameView& frameView = *m_layoutView.frameView();
bool isMainFrame = !document.ownerElement(); bool isMainFrame = !document.ownerElement();
...@@ -65,14 +66,14 @@ void ViewPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo) ...@@ -65,14 +66,14 @@ void ViewPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo)
Color rootBackgroundColor = m_layoutView.style()->visitedDependentColor(CSSPropertyBackgroundColor); Color rootBackgroundColor = m_layoutView.style()->visitedDependentColor(CSSPropertyBackgroundColor);
const LayoutObject* rootObject = document.documentElement() ? document.documentElement()->layoutObject() : nullptr; const LayoutObject* rootObject = document.documentElement() ? document.documentElement()->layoutObject() : nullptr;
LayoutObjectDrawingRecorder recorder(context, m_layoutView, DisplayItem::BoxDecorationBackground, documentRect, LayoutPoint()); LayoutObjectDrawingRecorder recorder(context, m_layoutView, DisplayItem::BoxDecorationBackground, backgroundRect, LayoutPoint());
// Special handling for print economy mode. // Special handling for print economy mode.
bool forceBackgroundToWhite = BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(m_layoutView.styleRef(), document); bool forceBackgroundToWhite = BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(m_layoutView.styleRef(), document);
if (forceBackgroundToWhite) { if (forceBackgroundToWhite) {
// If for any reason the view background is not transparent, paint white instead, otherwise keep transparent as is. // If for any reason the view background is not transparent, paint white instead, otherwise keep transparent as is.
if (paintsBaseBackground || rootBackgroundColor.alpha() || m_layoutView.style()->backgroundLayers().image()) if (paintsBaseBackground || rootBackgroundColor.alpha() || m_layoutView.style()->backgroundLayers().image())
context.fillRect(documentRect, Color::white, SkXfermode::kSrc_Mode); context.fillRect(backgroundRect, Color::white, SkXfermode::kSrc_Mode);
return; return;
} }
...@@ -84,7 +85,7 @@ void ViewPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo) ...@@ -84,7 +85,7 @@ void ViewPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo)
// we need to apply inverse transform on the document rect to get to the root element space. // we need to apply inverse transform on the document rect to get to the root element space.
bool backgroundRenderable = true; bool backgroundRenderable = true;
TransformationMatrix transform; TransformationMatrix transform;
IntRect paintRect = documentRect; IntRect paintRect = backgroundRect;
if (!rootObject || !rootObject->isBox()) { if (!rootObject || !rootObject->isBox()) {
backgroundRenderable = false; backgroundRenderable = false;
} else if (rootObject->hasLayer()) { } else if (rootObject->hasLayer()) {
...@@ -98,16 +99,16 @@ void ViewPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo) ...@@ -98,16 +99,16 @@ void ViewPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo)
backgroundRenderable = false; backgroundRenderable = false;
} else { } else {
bool isClamped; bool isClamped;
paintRect = transform.inverse().projectQuad(FloatQuad(documentRect), &isClamped).enclosingBoundingBox(); paintRect = transform.inverse().projectQuad(FloatQuad(backgroundRect), &isClamped).enclosingBoundingBox();
backgroundRenderable = !isClamped; backgroundRenderable = !isClamped;
} }
} }
if (!backgroundRenderable) { if (!backgroundRenderable) {
if (baseBackgroundColor.alpha()) if (baseBackgroundColor.alpha())
context.fillRect(documentRect, baseBackgroundColor, shouldClearCanvas ? SkXfermode::kSrc_Mode : SkXfermode::kSrcOver_Mode); context.fillRect(backgroundRect, baseBackgroundColor, shouldClearCanvas ? SkXfermode::kSrc_Mode : SkXfermode::kSrcOver_Mode);
else if (shouldClearCanvas) else if (shouldClearCanvas)
context.fillRect(documentRect, Color(), SkXfermode::kClear_Mode); context.fillRect(backgroundRect, Color(), SkXfermode::kClear_Mode);
return; return;
} }
...@@ -126,15 +127,15 @@ void ViewPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo) ...@@ -126,15 +127,15 @@ void ViewPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo)
if (shouldDrawBackgroundInSeparateBuffer) { if (shouldDrawBackgroundInSeparateBuffer) {
if (baseBackgroundColor.alpha()) if (baseBackgroundColor.alpha())
context.fillRect(documentRect, baseBackgroundColor, shouldClearCanvas ? SkXfermode::kSrc_Mode : SkXfermode::kSrcOver_Mode); context.fillRect(backgroundRect, baseBackgroundColor, shouldClearCanvas ? SkXfermode::kSrc_Mode : SkXfermode::kSrcOver_Mode);
context.beginLayer(); context.beginLayer();
} }
Color combinedBackgroundColor = shouldDrawBackgroundInSeparateBuffer ? rootBackgroundColor : baseBackgroundColor.blend(rootBackgroundColor); Color combinedBackgroundColor = shouldDrawBackgroundInSeparateBuffer ? rootBackgroundColor : baseBackgroundColor.blend(rootBackgroundColor);
if (combinedBackgroundColor.alpha()) if (combinedBackgroundColor.alpha())
context.fillRect(documentRect, combinedBackgroundColor, (shouldDrawBackgroundInSeparateBuffer || shouldClearCanvas) ? SkXfermode::kSrc_Mode : SkXfermode::kSrcOver_Mode); context.fillRect(backgroundRect, combinedBackgroundColor, (shouldDrawBackgroundInSeparateBuffer || shouldClearCanvas) ? SkXfermode::kSrc_Mode : SkXfermode::kSrcOver_Mode);
else if (shouldClearCanvas && !shouldDrawBackgroundInSeparateBuffer) else if (shouldClearCanvas && !shouldDrawBackgroundInSeparateBuffer)
context.fillRect(documentRect, Color(), SkXfermode::kClear_Mode); context.fillRect(backgroundRect, Color(), SkXfermode::kClear_Mode);
for (auto it = reversedPaintList.rbegin(); it != reversedPaintList.rend(); ++it) { for (auto it = reversedPaintList.rbegin(); it != reversedPaintList.rend(); ++it) {
ASSERT((*it)->clip() == BorderFillBox); ASSERT((*it)->clip() == BorderFillBox);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment