diff options
author | chrishtr@chromium.org <chrishtr@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2014-05-02 01:31:12 +0000 |
---|---|---|
committer | chrishtr@chromium.org <chrishtr@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2014-05-02 01:31:12 +0000 |
commit | d356f6de6c3a231d2a11853b98e8662ae65bf0fb (patch) | |
tree | d27d3e8ff53f278186842e6652c528b4efb6c4c7 | |
parent | f064d34c9bddaaefac45137e0967623183544a34 (diff) | |
download | chromium_src-d356f6de6c3a231d2a11853b98e8662ae65bf0fb.zip chromium_src-d356f6de6c3a231d2a11853b98e8662ae65bf0fb.tar.gz chromium_src-d356f6de6c3a231d2a11853b98e8662ae65bf0fb.tar.bz2 |
Clip paints of squashed layers to the bounds of the squashed layer.
RenderLayer::paint* methods assume that the caller will clip to the bounds of the dirt rect.
BUG=368410
Review URL: https://codereview.chromium.org/261753004
git-svn-id: svn://svn.chromium.org/blink/trunk@173154 bbb929c8-8fbe-4397-9dbb-9b2b20218538
10 files changed, 54 insertions, 242 deletions
diff --git a/third_party/WebKit/LayoutTests/compositing/fixed-position-changed-to-absolute-expected.txt b/third_party/WebKit/LayoutTests/compositing/fixed-position-changed-to-absolute-expected.txt index b26b473..2eed795 100644 --- a/third_party/WebKit/LayoutTests/compositing/fixed-position-changed-to-absolute-expected.txt +++ b/third_party/WebKit/LayoutTests/compositing/fixed-position-changed-to-absolute-expected.txt @@ -5,26 +5,19 @@ (bounds 800.00 600.00) (contentsOpaque 1) (drawsContent 1) - (children 2 - (GraphicsLayer - (position 8.00 13.00) - (bounds 150.00 150.00) - (contentsOpaque 1) - (drawsContent 1) - (backgroundColor #D9CCA7) - ) + (children 1 (GraphicsLayer (children 2 (GraphicsLayer - (position 20.00 20.00) - (bounds 60.00 60.00) + (position 8.00 13.00) + (bounds 150.00 150.00) (contentsOpaque 1) (drawsContent 1) - (backgroundColor #6AA6A6) + (backgroundColor #D9CCA7) ) (GraphicsLayer - (position 40.00 40.00) - (bounds 206.00 160.00) + (position 20.00 20.00) + (bounds 226.00 180.00) (drawsContent 1) ) ) diff --git a/third_party/WebKit/LayoutTests/compositing/geometry/limit-layer-bounds-transformed-overflow-expected.txt b/third_party/WebKit/LayoutTests/compositing/geometry/limit-layer-bounds-transformed-overflow-expected.txt deleted file mode 100644 index d22a31c..0000000 --- a/third_party/WebKit/LayoutTests/compositing/geometry/limit-layer-bounds-transformed-overflow-expected.txt +++ /dev/null @@ -1,40 +0,0 @@ -middle -(GraphicsLayer - (bounds 800.00 600.00) - (children 1 - (GraphicsLayer - (bounds 800.00 600.00) - (contentsOpaque 1) - (drawsContent 1) - (children 2 - (GraphicsLayer - (children 2 - (GraphicsLayer - (position 129.00 29.00) - (bounds 100.00 100.00) - ) - (GraphicsLayer - (position 129.00 29.00) - (bounds 200.00 100.00) - (drawsContent 1) - ) - ) - ) - (GraphicsLayer - (position 8.00 8.00) - (bounds 242.00 162.00) - (drawsContent 1) - (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [100.00 0.00 0.00 1.00]) - (children 1 - (GraphicsLayer - (position 1.00 146.00) - (bounds 240.00 15.00) - (drawsContent 1) - ) - ) - ) - ) - ) - ) -) - diff --git a/third_party/WebKit/LayoutTests/compositing/geometry/limit-layer-bounds-transformed-overflow.html b/third_party/WebKit/LayoutTests/compositing/geometry/limit-layer-bounds-transformed-overflow.html deleted file mode 100644 index b8a1d3e..0000000 --- a/third_party/WebKit/LayoutTests/compositing/geometry/limit-layer-bounds-transformed-overflow.html +++ /dev/null @@ -1,82 +0,0 @@ -<!DOCTYPE html> - -<html> -<head> - <style type="text/css" media="screen"> - body { - position: relative; - } - .container { - position: relative; - width: 200px; - height: 120px; - padding: 20px; - overflow-x: scroll; - border: 1px solid black; - -webkit-transform: translate(100px, 0); - } - - .compositing { - position: absolute; - top: 21px; - left: 121px; - width: 100px; - height: 100px; - -webkit-transform: translateZ(0); - } - - .far-left { - position: relative; - left: -1000px; - width: 2050px; - height: 100px; - background-color: green; - } - - p.middle { - position: absolute; - left: 50%; - } - - .indicator { - position: absolute; - top: 21px; - left: 121px; - width: 200px; - height: 100px; - background-color: red; - } - </style> - <script type="text/javascript" charset="utf-8"> - if (window.testRunner) - testRunner.dumpAsText(); - - function doTest() - { - if (window.testRunner) { - document.getElementById('layers').innerText = window.internals.layerTreeAsText(document); - } - } - - window.addEventListener('load', doTest, false); - </script> -</head> - -<body> - - <!-- Go into compositing. --> - <div class="compositing"></div> - - <div class="indicator"></div> - - <!-- Test clipping to viewport with some intermediate layers. --> - <!-- Green box should extend to the left edge. No red visible. "middle" should be visible --> - <div class="container"> - <div class="far-left"> - <p class="middle">middle</p> - </div> - </div> - <pre id="layers">Layer tree goes here in DRT</pre> -</body> -</html> - diff --git a/third_party/WebKit/LayoutTests/compositing/layer-creation/overflow-scroll-overlap-expected.txt b/third_party/WebKit/LayoutTests/compositing/layer-creation/overflow-scroll-overlap-expected.txt index 471b16a..13cb8e2 100644 --- a/third_party/WebKit/LayoutTests/compositing/layer-creation/overflow-scroll-overlap-expected.txt +++ b/third_party/WebKit/LayoutTests/compositing/layer-creation/overflow-scroll-overlap-expected.txt @@ -5,19 +5,16 @@ (bounds 800.00 600.00) (contentsOpaque 1) (drawsContent 1) - (children 3 + (children 2 (GraphicsLayer - (position 8.00 8.00) - (bounds 30.00 30.00) - ) - (GraphicsLayer - (position 20.00 20.00) - (bounds 306.00 206.00) - (drawsContent 1) - (children 1 + (children 2 + (GraphicsLayer + (position 8.00 8.00) + (bounds 30.00 30.00) + ) (GraphicsLayer - (position 288.00 3.00) - (bounds 15.00 200.00) + (position 20.00 20.00) + (bounds 306.00 206.00) (drawsContent 1) ) ) diff --git a/third_party/WebKit/LayoutTests/compositing/squashing/clip-composited-descendant.html b/third_party/WebKit/LayoutTests/compositing/squashing/clip-composited-descendant.html deleted file mode 100644 index 7ca441e..0000000 --- a/third_party/WebKit/LayoutTests/compositing/squashing/clip-composited-descendant.html +++ /dev/null @@ -1,93 +0,0 @@ -<!DOCTYPE html> -<head> -<script src="../../resources/run-after-display.js"></script> -<style> -.composited { --webkit-transform: translatez(0); -} - -.box { - width: 100px; - height: 100px; -} - -.behind { - position: absolute; - z-index: 0; - top: 50px; - left: 50px; - background-color: blue; -} - -.middle { - position: absolute; - z-index: 1; - top: 20px; - left: 100px; - background-color: cyan; -} - -.top { - position: absolute; - z-index: 2; - top: 130px; - left: 130px; - background-color: cyan; -} - -.inner { - position:absolute; - top:10px; - left: 10px; - height: 50px; width: 50px; - background-color: lightslategray; - z-index: 3; -} - -</style> -<script> - if (window.internals) - internals.settings.setLayerSquashingEnabled(true); - if (window.testRunner) { - testRunner.dumpAsText(); - testRunner.waitUntilDone(); - } - - function runTest() - { - runAfterDisplay(executeTestCases); - } - - function executeTestCases() - { - document.getElementById('Case1').textContent = window.internals.layerTreeAsText(document); - - document.querySelector("#top").style.overflow = 'hidden'; - document.getElementById('Case2').textContent = window.internals.layerTreeAsText(document); - - document.getElementById('testResults').style.display = "block"; - - if (window.testRunner) - testRunner.notifyDone(); - } -</script> -</head> -<body onload="runTest()"> - <div class="composited box behind"></div> - - <div class="box middle"> - </div> - - <div id="top" class="box top"> - <div class="inner"> - </div> - </div> - - <div id="testResults" style="display:none"> - CASE 1, original layer tree - <pre id="Case1"></pre> - - CASE 2, layer tree with overflow:hidden on the parent of a composited box. Parent is no longer squashed. - <pre id="Case2"></pre> - </div> -</body> diff --git a/third_party/WebKit/LayoutTests/compositing/squashing/clip-to-squashed-layer-size-expected.html b/third_party/WebKit/LayoutTests/compositing/squashing/clip-to-squashed-layer-size-expected.html new file mode 100644 index 0000000..2aa37fb --- /dev/null +++ b/third_party/WebKit/LayoutTests/compositing/squashing/clip-to-squashed-layer-size-expected.html @@ -0,0 +1,11 @@ +<!doctype html> +</head> +<body> + <div style=" width: 1px; height: 100px; position:absolute; top:0px; background-color: lightgray"> + </div> + <div style="width: 10px; height: 10px; overflow: hidden; position: absolute; left: 0px; top: 0px; "> + <div style="height: 100px; width:100px; background-color:lightgreen" /> + </div> + </div> + <div style="left: 0px; height: 9px; width: 9px; position:absolute; top:99px; background-color: blue"> +</body> diff --git a/third_party/WebKit/LayoutTests/compositing/squashing/clip-to-squashed-layer-size.html b/third_party/WebKit/LayoutTests/compositing/squashing/clip-to-squashed-layer-size.html new file mode 100644 index 0000000..bce268f --- /dev/null +++ b/third_party/WebKit/LayoutTests/compositing/squashing/clip-to-squashed-layer-size.html @@ -0,0 +1,16 @@ +<!doctype html> +<script> + // Checks that when painting squashed layers, contents are clipped to the size of the squashed layer. + if (window.internals) + internals.settings.setLayerSquashingEnabled(true); +</script> +</head> +<body> + <div style=" width: 1px; height: 100px; -webkit-transform: translateZ(0px); position:absolute; top:0px; background-color: lightgray"> + </div> + <div style="width: 10px; height: 10px; overflow: hidden; position: absolute; left: 0px; top: 0px; "> + <div style="height: 100px; width:100px; background-color:lightgreen" /> + </div> + </div> + <div style="left: 0px; height: 9px; width: 9px; position:absolute; top:99px; background-color: blue"> +</body> diff --git a/third_party/WebKit/Source/core/rendering/RenderLayer.h b/third_party/WebKit/Source/core/rendering/RenderLayer.h index 2f27335..1ab02f0 100644 --- a/third_party/WebKit/Source/core/rendering/RenderLayer.h +++ b/third_party/WebKit/Source/core/rendering/RenderLayer.h @@ -270,6 +270,7 @@ public: // paints the layers that intersect the damage rect from back to // front. The hitTest method looks for mouse events by walking // layers that intersect the point from front to back. + // paint() assumes that the caller will clip to the bounds of damageRect if necessary. void paint(GraphicsContext*, const LayoutRect& damageRect, PaintBehavior = PaintBehaviorNormal, RenderObject* paintingRoot = 0, PaintLayerFlags = 0); bool hitTest(const HitTestRequest&, HitTestResult&); bool hitTest(const HitTestRequest&, const HitTestLocation&, HitTestResult&); @@ -446,6 +447,7 @@ public: return isRootLayer() || layerRenderer->isPositioned() || hasTransform(); } + // paintLayer() assumes that the caller will clip to the bounds of the painting dirty if necessary. void paintLayer(GraphicsContext*, const LayerPaintingInfo&, PaintLayerFlags); PassOwnPtr<Vector<FloatRect> > collectTrackedRepaintRects() const; @@ -506,6 +508,7 @@ public: void updateSelfPaintingLayer(); + // paintLayerContents() assumes that the caller will clip to the bounds of the painting dirty rect if necessary. void paintLayerContents(GraphicsContext*, const LayerPaintingInfo&, PaintLayerFlags); RenderLayer* enclosingTransformedAncestor() const; diff --git a/third_party/WebKit/Source/core/rendering/compositing/CompositedLayerMapping.cpp b/third_party/WebKit/Source/core/rendering/compositing/CompositedLayerMapping.cpp index 2e0126aa..88f8017 100644 --- a/third_party/WebKit/Source/core/rendering/compositing/CompositedLayerMapping.cpp +++ b/third_party/WebKit/Source/core/rendering/compositing/CompositedLayerMapping.cpp @@ -1900,7 +1900,15 @@ void CompositedLayerMapping::doPaintTask(GraphicsLayerPaintInfo& paintInfo, Grap } else { ASSERT(compositor()->layerSquashingEnabled()); LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBehaviorNormal, paintInfo.renderLayer->subpixelAccumulation()); + + // RenderLayer::paintLayer assumes that the caller clips to the passed rect. Squashed layers need to do this clipping in software, + // since there is no graphics layer to clip them precisely. + // FIXME: in some cases this clip is not necessary. For example if the dirty rect is not the same as the bounds of the layer, + // RenderLayer will clip it (see RenderLayer::clipToRect). Put in more work if this becomes a performance issue. + context->save(); + context->clip(dirtyRect); paintInfo.renderLayer->paintLayer(context, paintingInfo, paintFlags); + context->restore(); } ASSERT(!paintInfo.renderLayer->usedTransparency()); diff --git a/third_party/WebKit/Source/core/rendering/compositing/RenderLayerCompositor.cpp b/third_party/WebKit/Source/core/rendering/compositing/RenderLayerCompositor.cpp index e9eeaa3..347ab8d 100644 --- a/third_party/WebKit/Source/core/rendering/compositing/RenderLayerCompositor.cpp +++ b/third_party/WebKit/Source/core/rendering/compositing/RenderLayerCompositor.cpp @@ -692,9 +692,8 @@ bool RenderLayerCompositor::canSquashIntoCurrentSquashingOwner(const RenderLayer if (layer->renderer()->clippingContainer() != squashingLayer.renderer()->clippingContainer()) return false; - // FIXME: this seems to be overly aggressive. clipsCompositingDescendants() should suffice. However, it does not fix all testcases, - // in particular crbug.com/366101. - if (layer->renderer()->hasClipOrOverflowClip()) + // Composited descendants need to be clipped by a child contianment graphics layer, which would not be available if the layer is squashed. + if (clipsCompositingDescendants(layer)) return false; if (layer->scrollsWithRespectTo(&squashingLayer)) |