[WK2] Pinch-zoom shadows can overlap headers and footers
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jun 2014 02:05:15 +0000 (02:05 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jun 2014 02:05:15 +0000 (02:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=134372
<rdar://problem/16004095>

Reviewed by Simon Fraser.

* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::shadowLayerPositionForFrame):
(WebKit::shadowLayerBoundsForFrame):
Compute the initial shadow layer and shadow bounds exactly as RenderLayerCompositor does
(in updateRootLayerPosition and friends). Also, clip the shadow layer to the old document rect,
otherwise it can extend over top of the header/footers. The content is automatically clipped to
this rect by the root content layer, but the shadow is outside of that.

(WebKit::TiledCoreAnimationDrawingArea::applyTransientZoomToLayers):
(WebKit::TiledCoreAnimationDrawingArea::commitTransientZoom):
Pass all of the arguments to constrainScrollPositionForOverhang, not just half of them.
There's still a bug where we constrain incorrectly with header/footer layers, but that
will be addressed elsewhere.

(WebKit::TiledCoreAnimationDrawingArea::applyTransientZoomToPage):
Make use of the new helpers.

* WebCore.exp.in:
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::updateLayerForHeader):
(WebCore::RenderLayerCompositor::updateLayerForFooter):
Put header/footer layers in front of the root content layer instead of behind.
Ideally nothing would ever overlap them, but this will give them precedence regardless.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170514 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm

index 8453611cbbdda4db430c2af695bf022ad0d47666..b7c87e60aa2abe4b6530e8d91588a1b19727587e 100644 (file)
@@ -1,3 +1,18 @@
+2014-06-26  Tim Horton  <timothy_horton@apple.com>
+
+        [WK2] Pinch-zoom shadows can overlap headers and footers
+        https://bugs.webkit.org/show_bug.cgi?id=134372
+        <rdar://problem/16004095>
+
+        Reviewed by Simon Fraser.
+
+        * WebCore.exp.in:
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::updateLayerForHeader):
+        (WebCore::RenderLayerCompositor::updateLayerForFooter):
+        Put header/footer layers in front of the root content layer instead of behind.
+        Ideally nothing would ever overlap them, but this will give them precedence regardless.
+
 2014-06-26  David Kilzer  <ddkilzer@apple.com>
 
         [Win] Always NULL-terminate the string in createUTF8String()
index f7c3ac142ee181684e6d0c7d3dad1fc427390da0..200a3e77a42e460a3d94355a8ae5feb77a0edd11 100644 (file)
@@ -1405,6 +1405,7 @@ __ZN7WebCore9FrameView24paintContentsForSnapshotEPNS_15GraphicsContextERKNS_7Int
 __ZN7WebCore9FrameView24setScrollPinningBehaviorENS_21ScrollPinningBehaviorE
 __ZN7WebCore9FrameView26adjustPageHeightDeprecatedEPffff
 __ZN7WebCore9FrameView26adjustTiledBackingCoverageEv
+__ZN7WebCore9FrameView28yPositionForRootContentLayerERKNS_10FloatPointEff
 __ZN7WebCore9FrameView29setAutoSizeFixedMinimumHeightEi
 __ZN7WebCore9FrameView29setShouldUpdateWhileOffscreenEb
 __ZN7WebCore9FrameView31setVisualUpdatesAllowedByClientEb
@@ -1998,6 +1999,7 @@ __ZNK7WebCore9FrameView12tiledBackingEv
 __ZNK7WebCore9FrameView13isTransparentEv
 __ZNK7WebCore9FrameView13paintBehaviorEv
 __ZNK7WebCore9FrameView14didFirstLayoutEv
+__ZNK7WebCore9FrameView15topContentInsetEv
 __ZNK7WebCore9FrameView17convertToRendererEPKNS_13RenderElementERKNS_7IntRectE
 __ZNK7WebCore9FrameView17convertToRendererEPKNS_13RenderElementERKNS_8IntPointE
 __ZNK7WebCore9FrameView19baseBackgroundColorEv
@@ -2408,6 +2410,11 @@ __ZN7WebCore7IntSizeC1ERK7_NSSize
 __ZNK7WebCore7IntSizecv7_NSSizeEv
 #endif
 
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 10100
+__ZN7WebCore32shouldRegisterInsertionUndoGroupEP18NSAttributedString
+__ZN7WebCore44registerInsertionUndoGroupingWithUndoManagerEP13NSUndoManager
+#endif
+
 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
 __ZN7WebCore24TextAlternativeWithRangeC1EP18NSTextAlternatives8_NSRange
 __ZN7WebCore27AlternativeTextUIController15addAlternativesERKN3WTF9RetainPtrI18NSTextAlternativesEE
@@ -2427,11 +2434,6 @@ _wkNSReboundDeltaForElasticDelta
 _wkCreateMemoryStatusPressureCriticalDispatchOnMainQueue
 #endif
 
-#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 10100
-__ZN7WebCore32shouldRegisterInsertionUndoGroupEP18NSAttributedString
-__ZN7WebCore44registerInsertionUndoGroupingWithUndoManagerEP13NSUndoManager
-#endif
-
 #if PLATFORM(MAC) || PLATFORM(IOS_SIMULATOR)
 _wkSetCrashReportApplicationSpecificInformation
 #endif
index f90c7492497367f636f27bbad8a9565d6b83b343..54732404b5b5b1d32adddd03d92a72e65ad71252 100644 (file)
@@ -3001,7 +3001,7 @@ GraphicsLayer* RenderLayerCompositor::updateLayerForHeader(bool wantsLayer)
 #ifndef NDEBUG
         m_layerForHeader->setName("header");
 #endif
-        m_scrollLayer->addChildBelow(m_layerForHeader.get(), m_rootContentLayer.get());
+        m_scrollLayer->addChildAbove(m_layerForHeader.get(), m_rootContentLayer.get());
         m_renderView.frameView().addPaintPendingMilestones(DidFirstFlushForHeaderLayer);
     }
 
@@ -3042,7 +3042,7 @@ GraphicsLayer* RenderLayerCompositor::updateLayerForFooter(bool wantsLayer)
 #ifndef NDEBUG
         m_layerForFooter->setName("footer");
 #endif
-        m_scrollLayer->addChildBelow(m_layerForFooter.get(), m_rootContentLayer.get());
+        m_scrollLayer->addChildAbove(m_layerForFooter.get(), m_rootContentLayer.get());
     }
 
     float totalContentHeight = m_rootContentLayer->size().height() + m_renderView.frameView().headerHeight() + m_renderView.frameView().footerHeight();
index 12d8b10faea66b24b878bd476348a0b9ff10b881..c8a8af813875b52418bfb344ffba7910daaece07 100644 (file)
@@ -1,3 +1,28 @@
+2014-06-26  Tim Horton  <timothy_horton@apple.com>
+
+        [WK2] Pinch-zoom shadows can overlap headers and footers
+        https://bugs.webkit.org/show_bug.cgi?id=134372
+        <rdar://problem/16004095>
+
+        Reviewed by Simon Fraser.
+
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::shadowLayerPositionForFrame):
+        (WebKit::shadowLayerBoundsForFrame):
+        Compute the initial shadow layer and shadow bounds exactly as RenderLayerCompositor does
+        (in updateRootLayerPosition and friends). Also, clip the shadow layer to the old document rect,
+        otherwise it can extend over top of the header/footers. The content is automatically clipped to
+        this rect by the root content layer, but the shadow is outside of that.
+
+        (WebKit::TiledCoreAnimationDrawingArea::applyTransientZoomToLayers):
+        (WebKit::TiledCoreAnimationDrawingArea::commitTransientZoom):
+        Pass all of the arguments to constrainScrollPositionForOverhang, not just half of them.
+        There's still a bug where we constrain incorrectly with header/footer layers, but that
+        will be addressed elsewhere.
+
+        (WebKit::TiledCoreAnimationDrawingArea::applyTransientZoomToPage):
+        Make use of the new helpers.
+
 2014-06-26  Tim Horton  <timothy_horton@apple.com>
 
         Don't leak WKBrowsingContextControllers
index 5d4c384364d23dcf612016e84a1b2b708edd1e97..edd607b05b0a832931c157783dccd38982d662d8 100644 (file)
@@ -524,6 +524,24 @@ PlatformCALayer* TiledCoreAnimationDrawingArea::shadowLayerForTransientZoom() co
 
     return nullptr;
 }
+    
+static FloatPoint shadowLayerPositionForFrame(FrameView& frameView, FloatPoint origin)
+{
+    FloatPoint position = frameView.renderView()->documentRect().location() + FloatPoint(0, FrameView::yPositionForRootContentLayer(frameView.scrollPosition(), frameView.topContentInset(), frameView.headerHeight()));
+
+    return position + origin.expandedTo(FloatPoint());
+}
+
+static FloatRect shadowLayerBoundsForFrame(FrameView& frameView, float transientScale)
+{
+    FloatRect clipLayerFrame(frameView.renderView()->documentRect());
+    FloatRect shadowLayerFrame = clipLayerFrame;
+    
+    shadowLayerFrame.scale(transientScale / frameView.frame().page()->pageScaleFactor());
+    shadowLayerFrame.intersect(clipLayerFrame);
+    
+    return shadowLayerFrame;
+}
 
 void TiledCoreAnimationDrawingArea::applyTransientZoomToLayers(double scale, FloatPoint origin)
 {
@@ -540,14 +558,11 @@ void TiledCoreAnimationDrawingArea::applyTransientZoomToLayers(double scale, Flo
     zoomLayer->setTransform(transform);
     zoomLayer->setAnchorPoint(FloatPoint3D());
     zoomLayer->setPosition(FloatPoint3D());
-
+    
     if (PlatformCALayer* shadowLayer = shadowLayerForTransientZoom()) {
-        RenderView* renderView = m_webPage.mainFrameView()->renderView();
-        FloatRect shadowBounds = FloatRect(FloatPoint(), toFloatSize(renderView->layoutOverflowRect().maxXMaxYCorner()));
-        shadowBounds.scale(scale);
-
-        shadowLayer->setBounds(shadowBounds);
-        shadowLayer->setPosition(origin);
+        FrameView& frameView = *m_webPage.mainFrameView();
+        shadowLayer->setBounds(shadowLayerBoundsForFrame(frameView, scale));
+        shadowLayer->setPosition(shadowLayerPositionForFrame(frameView, origin));
     }
 
     m_transientZoomScale = scale;
@@ -584,20 +599,19 @@ static RetainPtr<CABasicAnimation> transientZoomSnapAnimationForKeyPath(String k
 
 void TiledCoreAnimationDrawingArea::commitTransientZoom(double scale, FloatPoint origin)
 {
-    FrameView* frameView = m_webPage.mainFrameView();
-    FloatRect visibleContentRect = frameView->visibleContentRectIncludingScrollbars();
+    FrameView& frameView = *m_webPage.mainFrameView();
+    FloatRect visibleContentRect = frameView.visibleContentRectIncludingScrollbars();
 
     FloatPoint constrainedOrigin = visibleContentRect.location();
     constrainedOrigin.moveBy(-origin);
 
-    RenderView* renderView = frameView->renderView();
-    IntRect documentRect = renderView->unscaledDocumentRect();
-    documentRect.scale(scale);
+    IntSize scaledTotalContentsSize = frameView.totalContentsSize();
+    scaledTotalContentsSize.scale(scale / m_webPage.pageScaleFactor());
 
     // Scaling may have exposed the overhang area, so we need to constrain the final
     // layer position exactly like scrolling will once it's committed, to ensure that
     // scrolling doesn't make the view jump.
-    constrainedOrigin = ScrollableArea::constrainScrollPositionForOverhang(roundedIntRect(visibleContentRect), documentRect.size(), roundedIntPoint(constrainedOrigin), IntPoint(), 0, 0);
+    constrainedOrigin = ScrollableArea::constrainScrollPositionForOverhang(roundedIntRect(visibleContentRect), scaledTotalContentsSize, roundedIntPoint(constrainedOrigin), frameView.scrollOrigin(), frameView.headerHeight(), frameView.footerHeight());
     constrainedOrigin.moveBy(-visibleContentRect.location());
     constrainedOrigin = -constrainedOrigin;
 
@@ -632,14 +646,13 @@ void TiledCoreAnimationDrawingArea::commitTransientZoom(double scale, FloatPoint
     zoomLayer->addAnimationForKey("transientZoomCommit", renderViewAnimation.get());
 
     if (shadowCALayer) {
-        FloatRect shadowBounds = FloatRect(FloatPoint(), toFloatSize(renderView->layoutOverflowRect().maxXMaxYCorner()));
-        shadowBounds.scale(scale);
+        FloatRect shadowBounds = shadowLayerBoundsForFrame(frameView, scale);
         RetainPtr<CGPathRef> shadowPath = adoptCF(CGPathCreateWithRect(shadowBounds, NULL)).get();
 
         RetainPtr<CABasicAnimation> shadowBoundsAnimation = transientZoomSnapAnimationForKeyPath("bounds");
         [shadowBoundsAnimation setToValue:[NSValue valueWithRect:shadowBounds]];
         RetainPtr<CABasicAnimation> shadowPositionAnimation = transientZoomSnapAnimationForKeyPath("position");
-        [shadowPositionAnimation setToValue:[NSValue valueWithPoint:constrainedOrigin]];
+        [shadowPositionAnimation setToValue:[NSValue valueWithPoint:shadowLayerPositionForFrame(frameView, constrainedOrigin)]];
         RetainPtr<CABasicAnimation> shadowPathAnimation = transientZoomSnapAnimationForKeyPath("shadowPath");
         [shadowPathAnimation setToValue:(id)shadowPath.get()];
 
@@ -658,16 +671,16 @@ void TiledCoreAnimationDrawingArea::applyTransientZoomToPage(double scale, Float
     TransformationMatrix finalTransform;
     finalTransform.scale(scale);
     layerForTransientZoom()->setTransform(finalTransform);
+    
+    FrameView& frameView = *m_webPage.mainFrameView();
 
     if (PlatformCALayer* shadowLayer = shadowLayerForTransientZoom()) {
-        RenderView* renderView = m_webPage.mainFrameView()->renderView();
-        IntRect overflowRect = renderView->pixelSnappedLayoutOverflowRect();
-        shadowLayer->setBounds(IntRect(IntPoint(), toIntSize(overflowRect.maxXMaxYCorner())));
-        shadowLayer->setPosition(FloatPoint());
+        shadowLayer->setBounds(shadowLayerBoundsForFrame(frameView, 1));
+        shadowLayer->setPosition(shadowLayerPositionForFrame(frameView, FloatPoint()));
     }
 
     FloatPoint unscrolledOrigin(origin);
-    FloatRect unobscuredContentRect = m_webPage.mainFrameView()->unobscuredContentRectIncludingScrollbars();
+    FloatRect unobscuredContentRect = frameView.unobscuredContentRectIncludingScrollbars();
     unscrolledOrigin.moveBy(-unobscuredContentRect.location());
     m_webPage.scalePage(scale, roundedIntPoint(-unscrolledOrigin));
     m_transientZoomScale = 1;