LayoutTests/ChangeLog

 12011-06-09 James Robinson <jamesr@chromium.org>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 [chromium] Scissor rect not set for clipping layers set offscreen
 6 https://bugs.webkit.org/show_bug.cgi?id=62339
 7
 8 Tests that a layer that should clip its children actually does clip even when scrolled offscreen.
 9
 10 * platform/chromium/compositing/scissor-out-of-viewport-expected.png: Added.
 11 * platform/chromium/compositing/scissor-out-of-viewport-expected.txt: Added.
 12 * platform/chromium/compositing/scissor-out-of-viewport.html: Added.
 13
1142011-06-09 Chang Shu <cshu@webkit.org>
215
316 Reviewed by Andreas Kling.

LayoutTests/platform/chromium/compositing/scissor-out-of-viewport-expected.png

Exception raised during decoding git binary patch:
Error running git apply --directory=/tmp
with patch:
diff --git a/PrettyPatch20260622-426859-iruym9.bin b/PrettyPatch20260622-426859-iruym9.bin
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 0
HcmV?d00001

...
error: invalid path '/tmp/PrettyPatch20260622-426859-iruym9.bin'

/var/www/bugs.webkit.org/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb:924:in `run_git_apply_on_patch'
/var/www/bugs.webkit.org/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb:935:in `extract_contents_from_git_binary_literal_chunk'
/var/www/bugs.webkit.org/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb:950:in `extract_contents_from_remote'
/var/www/bugs.webkit.org/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb:713:in `initialize'
/var/www/bugs.webkit.org/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb:845:in `new'
/var/www/bugs.webkit.org/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb:845:in `block in parse'
/var/www/bugs.webkit.org/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb:845:in `collect'
/var/www/bugs.webkit.org/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb:845:in `parse'
/var/www/bugs.webkit.org/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb:21:in `prettify'
/var/www/html/PrettyPatch/prettify.rb:30:in `<main>'

LayoutTests/platform/chromium/compositing/scissor-out-of-viewport-expected.txt

 1
 2

LayoutTests/platform/chromium/compositing/scissor-out-of-viewport.html

 1<!DOCTYPE html>
 2<!-- This test has a 16px tall div with overflow:hidden set and a child image. When the test loads the div is scrolled out of view.
 3 The test is a pass if the image does not appear. -->
 4<body style="overflow:hidden">
 5<canvas style="position: absolute;"></canvas>
 6<script>
 7 document.querySelector("canvas").getContext("2d");
 8</script>
 9<div style="top:0px; height: 16px; overflow: hidden; position: relative;">
 10 <img style="position: absolute; left: -16px;" id="i"></img>
 11</div>
 12<br>
 13<div style="height:2000px"></div>
 14<script>
 15var can = document.createElement("canvas");
 16can.width = can.height = 500;
 17var ctx = can.getContext("2d");
 18ctx.fillStyle = "red";
 19ctx.fillRect(0, 0, 500, 500);
 20document.getElementById("i").src = can.toDataURL();
 21document.body.scrollTop = 50;
 22if (window.layoutTestController)
 23 layoutTestController.dumpAsText(true);
 24</script>

Source/WebCore/ChangeLog

 12011-06-09 James Robinson <jamesr@chromium.org>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 [chromium] Scissor rect not set for clipping layers set offscreen
 6 https://bugs.webkit.org/show_bug.cgi?id=62339
 7
 8 We set a scissorRect on each layer, but only layers with masksToBounds and their descendants should actually set
 9 a scissor. Layers that didn't need to scissor had empty scissorRects. Unfortunately layers with masksToBounds
 10 and their descendants that are scrolled offscreen also end up with an empty clipped scissor rect.
 11
 12 This patch sets an explicit bit on each layer that should scissor and then checks that bit instead of checking
 13 for an empty scissor rect at draw time. RenderSurfaceChromiums have different requirements for
 14 setScissorToRect, so the old behavior is still available with a flag. This can probably be cleaned up more.
 15
 16 Test: platform/chromium/compositing/scissor-out-of-viewport.html
 17
 18 * platform/graphics/chromium/LayerRendererChromium.cpp:
 19 (WebCore::LayerRendererChromium::updatePropertiesAndRenderSurfaces):
 20 (WebCore::LayerRendererChromium::drawLayer):
 21 (WebCore::LayerRendererChromium::setScissorToRect):
 22 * platform/graphics/chromium/LayerRendererChromium.h:
 23 * platform/graphics/chromium/RenderSurfaceChromium.cpp:
 24 (WebCore::RenderSurfaceChromium::draw):
 25 * platform/graphics/chromium/cc/CCLayerImpl.cpp:
 26 (WebCore::CCLayerImpl::CCLayerImpl):
 27 * platform/graphics/chromium/cc/CCLayerImpl.h:
 28 (WebCore::CCLayerImpl::setUsesLayerScissor):
 29 (WebCore::CCLayerImpl::usesLayerScissor):
 30
1312011-06-09 Dave Tapuska <dtapuska@rim.com>
232
333 Reviewed by Daniel Bates.

Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp

@@void LayerRendererChromium::updatePropertiesAndRenderSurfaces(CCLayerImpl* layer
658658 FloatRect layerRect(-0.5 * layer->bounds().width(), -0.5 * layer->bounds().height(), layer->bounds().width(), layer->bounds().height());
659659 IntRect transformedLayerRect;
660660
 661 // FIXME: This seems like the wrong place to set this
 662 layer->setUsesLayerScissor(false);
 663
661664 // The layer and its descendants render on a new RenderSurface if any of
662665 // these conditions hold:
663666 // 1. The layer clips its descendants and its transform is not a simple translation.

@@void LayerRendererChromium::updatePropertiesAndRenderSurfaces(CCLayerImpl* layer
694697 TransformationMatrix layerOriginTransform = combinedTransform;
695698 layerOriginTransform.translate3d(-0.5 * bounds.width(), -0.5 * bounds.height(), 0);
696699 renderSurface->m_originTransform = layerOriginTransform;
697  layer->setScissorRect(IntRect());
698700
699701 // The render surface scissor rect is the scissor rect that needs to
700702 // be applied before drawing the render surface onto its containing

@@void LayerRendererChromium::updatePropertiesAndRenderSurfaces(CCLayerImpl* layer
726728
727729 // Layers inherit the scissor rect from their parent.
728730 layer->setScissorRect(layer->parent()->scissorRect());
 731 if (layer->parent()->usesLayerScissor())
 732 layer->setUsesLayerScissor(true);
729733
730734 layer->setTargetRenderSurface(layer->parent()->targetRenderSurface());
731735 }

@@void LayerRendererChromium::updatePropertiesAndRenderSurfaces(CCLayerImpl* layer
738742 if (!layer->scissorRect().isEmpty())
739743 scissor.intersect(layer->scissorRect());
740744 layer->setScissorRect(scissor);
 745 layer->setUsesLayerScissor(true);
741746 }
742747 }
743748

@@void LayerRendererChromium::drawLayer(CCLayerImpl* layer, RenderSurfaceChromium*
973978 return;
974979 }
975980
976  setScissorToRect(layer->scissorRect());
977 
 981 if (layer->usesLayerScissor())
 982 setScissorToRect(layer->scissorRect());
 983 else
 984 GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST));
978985 IntRect targetSurfaceRect = m_currentRenderSurface ? m_currentRenderSurface->contentRect() : m_defaultRenderSurface->contentRect();
979  IntRect scissorRect = layer->scissorRect();
980  if (!scissorRect.isEmpty())
981  targetSurfaceRect.intersect(scissorRect);
982986
983987 // Check if the layer falls within the visible bounds of the page.
984988 IntRect layerRect = layer->getDrawRect();

@@void LayerRendererChromium::drawLayer(CCLayerImpl* layer, RenderSurfaceChromium*
10141018
10151019// Sets the scissor region to the given rectangle. The coordinate system for the
10161020// scissorRect has its origin at the top left corner of the current visible rect.
1017 void LayerRendererChromium::setScissorToRect(const IntRect& requestedScissor)
 1021void LayerRendererChromium::setScissorToRect(const IntRect& scissorRect)
10181022{
10191023 IntRect contentRect = (m_currentRenderSurface ? m_currentRenderSurface->m_contentRect : m_defaultRenderSurface->m_contentRect);
10201024
1021  const IntRect scissorRect = requestedScissor.isEmpty() ? contentRect : requestedScissor;
 1025 GLC(m_context.get(), m_context->enable(GraphicsContext3D::SCISSOR_TEST));
10221026
10231027 // The scissor coordinates must be supplied in viewport space so we need to offset
10241028 // by the relative position of the top left corner of the current render surface.

Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp

@@void RenderSurfaceChromium::draw(const IntRect&)
152152 if (!m_maskLayer && m_owningLayer->replicaLayer())
153153 replicaMaskLayer = m_owningLayer->replicaLayer()->maskLayer();
154154
155  layerRenderer()->setScissorToRect(m_scissorRect);
 155 if (m_owningLayer->parent() && m_owningLayer->parent()->usesLayerScissor())
 156 layerRenderer()->setScissorToRect(m_scissorRect);
 157 else
 158 GLC(layerRenderer()->context(), layerRenderer()->context()->disable(GraphicsContext3D::SCISSOR_TEST));
 159
156160
157161 // Reflection draws before the layer.
158162 if (m_owningLayer->replicaLayer())

Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp

@@CCLayerImpl::CCLayerImpl(LayerChromium* owner, int id)
7070 , m_masksToBounds(false)
7171 , m_opacity(1.0)
7272 , m_preserves3D(false)
 73 , m_usesLayerScissor(false)
7374 , m_targetRenderSurface(0)
7475 , m_drawDepth(0)
7576 , m_drawOpacity(0)

Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h

@@public:
100100 void setPreserves3D(bool preserves3D) { m_preserves3D = preserves3D; }
101101 bool preserves3D() const { return m_preserves3D; }
102102
 103 void setUsesLayerScissor(bool usesLayerScissor) { m_usesLayerScissor = usesLayerScissor; }
 104 bool usesLayerScissor() const { return m_usesLayerScissor; }
 105
103106 void setSublayerTransform(const TransformationMatrix& sublayerTransform) { m_sublayerTransform = sublayerTransform; }
104107 const TransformationMatrix& sublayerTransform() const { return m_sublayerTransform; }
105108

@@private:
183186 bool m_preserves3D;
184187 TransformationMatrix m_sublayerTransform;
185188 TransformationMatrix m_transform;
 189 bool m_usesLayerScissor;
186190
187191 // Properties owned exclusively by this CCLayerImpl.
188192 // Debugging.