Title: [167860] trunk/Source/WebKit2
Revision
167860
Author
[email protected]
Date
2014-04-27 13:42:54 -0700 (Sun, 27 Apr 2014)

Log Message

WebKit2 View Gestures (Zoom): Pages with 'background-attachment: fixed' don't behave correctly when zoomed
https://bugs.webkit.org/show_bug.cgi?id=132225
<rdar://problem/15729975>

Reviewed by Darin Adler.

* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::layerForTransientZoom):
(WebKit::TiledCoreAnimationDrawingArea::shadowLayerForTransientZoom):
(WebKit::TiledCoreAnimationDrawingArea::adjustTransientZoom):
(WebKit::TiledCoreAnimationDrawingArea::commitTransientZoom):
(WebKit::TiledCoreAnimationDrawingArea::applyTransientZoomToPage):
Factor out code to choose which layer (and shadow layer) to apply the transient zoom to.
If we have a contentsContainmentLayer (because we have composited background-attachment: fixed),
it applies page scale, so we should apply the transient zoom to that layer
instead of the RenderView's main GraphicsLayer.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (167859 => 167860)


--- trunk/Source/WebKit2/ChangeLog	2014-04-27 19:47:36 UTC (rev 167859)
+++ trunk/Source/WebKit2/ChangeLog	2014-04-27 20:42:54 UTC (rev 167860)
@@ -1,3 +1,23 @@
+2014-04-27  Tim Horton  <[email protected]>
+
+        WebKit2 View Gestures (Zoom): Pages with 'background-attachment: fixed' don't behave correctly when zoomed
+        https://bugs.webkit.org/show_bug.cgi?id=132225
+        <rdar://problem/15729975>
+
+        Reviewed by Darin Adler.
+
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::layerForTransientZoom):
+        (WebKit::TiledCoreAnimationDrawingArea::shadowLayerForTransientZoom):
+        (WebKit::TiledCoreAnimationDrawingArea::adjustTransientZoom):
+        (WebKit::TiledCoreAnimationDrawingArea::commitTransientZoom):
+        (WebKit::TiledCoreAnimationDrawingArea::applyTransientZoomToPage):
+        Factor out code to choose which layer (and shadow layer) to apply the transient zoom to.
+        If we have a contentsContainmentLayer (because we have composited background-attachment: fixed),
+        it applies page scale, so we should apply the transient zoom to that layer
+        instead of the RenderView's main GraphicsLayer.
+
 2014-04-27  Pratik Solanki  <[email protected]>
 
         Unreviewed. iOS build fix.

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h (167859 => 167860)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h	2014-04-27 19:47:36 UTC (rev 167859)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h	2014-04-27 20:42:54 UTC (rev 167860)
@@ -41,6 +41,7 @@
 
 namespace WebCore {
 class FrameView;
+class PlatformCALayer;
 class TiledBacking;
 }
 
@@ -94,6 +95,8 @@
     virtual void adjustTransientZoom(double scale, WebCore::FloatPoint origin) override;
     virtual void commitTransientZoom(double scale, WebCore::FloatPoint origin) override;
     void applyTransientZoomToPage(double scale, WebCore::FloatPoint origin);
+    WebCore::PlatformCALayer* layerForTransientZoom() const;
+    WebCore::PlatformCALayer* shadowLayerForTransientZoom() const;
 
     virtual WebCore::TransformationMatrix rootLayerTransform() const override {  return m_transform; }
     virtual void setRootLayerTransform(const WebCore::TransformationMatrix&) override;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (167859 => 167860)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2014-04-27 19:47:36 UTC (rev 167859)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2014-04-27 20:42:54 UTC (rev 167860)
@@ -486,6 +486,26 @@
     return frameView && frameView->frame().isMainFrame();
 }
 
+PlatformCALayer* TiledCoreAnimationDrawingArea::layerForTransientZoom() const
+{
+    RenderLayerBacking* renderViewBacking = m_webPage->mainFrameView()->renderView()->layer()->backing();
+
+    if (GraphicsLayer* contentsContainmentLayer = renderViewBacking->contentsContainmentLayer())
+        return toGraphicsLayerCA(contentsContainmentLayer)->platformCALayer();
+
+    return toGraphicsLayerCA(renderViewBacking->graphicsLayer())->platformCALayer();
+}
+
+PlatformCALayer* TiledCoreAnimationDrawingArea::shadowLayerForTransientZoom() const
+{
+    RenderLayerCompositor& renderLayerCompositor = m_webPage->mainFrameView()->renderView()->compositor();
+
+    if (GraphicsLayer* shadowGraphicsLayer = renderLayerCompositor.layerForContentShadow())
+        return toGraphicsLayerCA(shadowGraphicsLayer)->platformCALayer();
+
+    return nullptr;
+}
+
 void TiledCoreAnimationDrawingArea::adjustTransientZoom(double scale, FloatPoint origin)
 {
     // FIXME: Scrollbars should stay in-place and change height while zooming.
@@ -499,16 +519,13 @@
     transform.translate(origin.x(), origin.y());
     transform.scale(scale);
 
-    RenderView* renderView = m_webPage->mainFrameView()->renderView();
-    PlatformCALayer* renderViewLayer = toGraphicsLayerCA(renderView->layer()->backing()->graphicsLayer())->platformCALayer();
-    renderViewLayer->setTransform(transform);
-    renderViewLayer->setAnchorPoint(FloatPoint3D());
-    renderViewLayer->setPosition(FloatPoint3D());
+    PlatformCALayer* zoomLayer = layerForTransientZoom();
+    zoomLayer->setTransform(transform);
+    zoomLayer->setAnchorPoint(FloatPoint3D());
+    zoomLayer->setPosition(FloatPoint3D());
 
-    GraphicsLayerCA* shadowGraphicsLayer = toGraphicsLayerCA(renderView->compositor().layerForContentShadow());
-    if (shadowGraphicsLayer) {
-        PlatformCALayer* shadowLayer = shadowGraphicsLayer->platformCALayer();
-
+    if (PlatformCALayer* shadowLayer = shadowLayerForTransientZoom()) {
+        RenderView* renderView = m_webPage->mainFrameView()->renderView();
         FloatRect shadowBounds = FloatRect(FloatPoint(), toFloatSize(renderView->layoutOverflowRect().maxXMaxYCorner()));
         shadowBounds.scale(scale);
 
@@ -536,15 +553,13 @@
 void TiledCoreAnimationDrawingArea::commitTransientZoom(double scale, FloatPoint origin)
 {
     FrameView* frameView = m_webPage->mainFrameView();
-    RenderView* renderView = frameView->renderView();
-    PlatformCALayer* renderViewLayer = static_cast<GraphicsLayerCA*>(renderView->layer()->backing()->graphicsLayer())->platformCALayer();
-
     FloatRect visibleContentRect = frameView->visibleContentRectIncludingScrollbars();
 
     FloatPoint constrainedOrigin = visibleContentRect.location();
     constrainedOrigin.moveBy(-origin);
 
-    IntRect documentRect = frameView->renderView()->unscaledDocumentRect();
+    RenderView* renderView = frameView->renderView();
+    IntRect documentRect = renderView->unscaledDocumentRect();
     documentRect.scale(scale);
 
     // Scaling may have exposed the overhang area, so we need to constrain the final
@@ -568,21 +583,23 @@
     RefPtr<PlatformCAAnimation> renderViewAnimation = PlatformCAAnimationMac::create(renderViewAnimationCA.get());
     renderViewAnimation->setToValue(transform);
 
-    RetainPtr<CALayer> shadowLayer;
-    if (GraphicsLayerCA* shadowGraphicsLayer = toGraphicsLayerCA(renderView->compositor().layerForContentShadow()))
-        shadowLayer = shadowGraphicsLayer->platformCALayer()->platformLayer();
+    RetainPtr<CALayer> shadowCALayer;
+    if (PlatformCALayer* shadowLayer = shadowLayerForTransientZoom())
+        shadowCALayer = shadowLayer->platformLayer();
 
+    PlatformCALayer* zoomLayer = layerForTransientZoom();
+
     [CATransaction begin];
     [CATransaction setCompletionBlock:^(void) {
-        renderViewLayer->removeAnimationForKey("transientZoomCommit");
-        if (shadowLayer)
-            [shadowLayer removeAllAnimations];
+        zoomLayer->removeAnimationForKey("transientZoomCommit");
+        if (shadowCALayer)
+            [shadowCALayer removeAllAnimations];
         applyTransientZoomToPage(scale, origin);
     }];
 
-    renderViewLayer->addAnimationForKey("transientZoomCommit", renderViewAnimation.get());
+    zoomLayer->addAnimationForKey("transientZoomCommit", renderViewAnimation.get());
 
-    if (shadowLayer) {
+    if (shadowCALayer) {
         FloatRect shadowBounds = FloatRect(FloatPoint(), toFloatSize(renderView->layoutOverflowRect().maxXMaxYCorner()));
         shadowBounds.scale(scale);
         RetainPtr<CGPathRef> shadowPath = adoptCF(CGPathCreateWithRect(shadowBounds, NULL)).get();
@@ -594,9 +611,9 @@
         RetainPtr<CABasicAnimation> shadowPathAnimation = transientZoomSnapAnimationForKeyPath("shadowPath");
         [shadowPathAnimation setToValue:(id)shadowPath.get()];
 
-        [shadowLayer addAnimation:shadowBoundsAnimation.get() forKey:@"transientZoomCommitShadowBounds"];
-        [shadowLayer addAnimation:shadowPositionAnimation.get() forKey:@"transientZoomCommitShadowPosition"];
-        [shadowLayer addAnimation:shadowPathAnimation.get() forKey:@"transientZoomCommitShadowPath"];
+        [shadowCALayer addAnimation:shadowBoundsAnimation.get() forKey:@"transientZoomCommitShadowBounds"];
+        [shadowCALayer addAnimation:shadowPositionAnimation.get() forKey:@"transientZoomCommitShadowPosition"];
+        [shadowCALayer addAnimation:shadowPathAnimation.get() forKey:@"transientZoomCommitShadowPath"];
     }
 
     [CATransaction commit];
@@ -604,19 +621,14 @@
 
 void TiledCoreAnimationDrawingArea::applyTransientZoomToPage(double scale, FloatPoint origin)
 {
-    RenderView* renderView = m_webPage->mainFrameView()->renderView();
-    PlatformCALayer* renderViewLayer = toGraphicsLayerCA(renderView->layer()->backing()->graphicsLayer())->platformCALayer();
-
+    // If the page scale is already the target scale, setPageScaleFactor() will short-circuit
+    // and not apply the transform, so we can't depend on it to do so.
     TransformationMatrix finalTransform;
     finalTransform.scale(scale);
+    layerForTransientZoom()->setTransform(finalTransform);
 
-    // If the page scale is already the target scale, setPageScaleFactor() will short-circuit
-    // and not apply the transform, so we can't depend on it to do so.
-    renderViewLayer->setTransform(finalTransform);
-
-    GraphicsLayerCA* shadowGraphicsLayer = toGraphicsLayerCA(renderView->compositor().layerForContentShadow());
-    if (shadowGraphicsLayer) {
-        PlatformCALayer* shadowLayer = shadowGraphicsLayer->platformCALayer();
+    if (PlatformCALayer* shadowLayer = shadowLayerForTransientZoom()) {
+        RenderView* renderView = m_webPage->mainFrameView()->renderView();
         IntRect overflowRect = renderView->pixelSnappedLayoutOverflowRect();
         shadowLayer->setBounds(IntRect(IntPoint(), toIntSize(overflowRect.maxXMaxYCorner())));
         shadowLayer->setPosition(shadowLayer->bounds().center());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to