Title: [247291] trunk/Source
Revision
247291
Author
timothy_hor...@apple.com
Date
2019-07-09 18:52:23 -0700 (Tue, 09 Jul 2019)

Log Message

Fixed elements appear in the middle of full page screenshots taken when scrolled
https://bugs.webkit.org/show_bug.cgi?id=199649
<rdar://problem/52476226>

Reviewed by Simon Fraser.

Source/WebCore:

* page/FrameView.h:
Expose a getter for the layout viewport override rect.

Source/WebKit:

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::computePagesForPrintingAndDrawToPDF):
Temporarily expand the layout viewport to the size of the snapshotting page,
so that fixed elements sit against the bounds of the page instead of
wherever you're currently scrolled to.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (247290 => 247291)


--- trunk/Source/WebCore/ChangeLog	2019-07-10 01:31:03 UTC (rev 247290)
+++ trunk/Source/WebCore/ChangeLog	2019-07-10 01:52:23 UTC (rev 247291)
@@ -1,3 +1,14 @@
+2019-07-09  Tim Horton  <timothy_hor...@apple.com>
+
+        Fixed elements appear in the middle of full page screenshots taken when scrolled
+        https://bugs.webkit.org/show_bug.cgi?id=199649
+        <rdar://problem/52476226>
+
+        Reviewed by Simon Fraser.
+
+        * page/FrameView.h:
+        Expose a getter for the layout viewport override rect.
+
 2019-07-09  Alex Christensen  <achristen...@webkit.org>
 
         Fix build after r247279

Modified: trunk/Source/WebCore/page/FrameView.h (247290 => 247291)


--- trunk/Source/WebCore/page/FrameView.h	2019-07-10 01:31:03 UTC (rev 247290)
+++ trunk/Source/WebCore/page/FrameView.h	2019-07-10 01:52:23 UTC (rev 247291)
@@ -260,6 +260,7 @@
     // If set, overrides the default "m_layoutViewportOrigin, size of initial containing block" rect.
     // Used with delegated scrolling (i.e. iOS).
     WEBCORE_EXPORT void setLayoutViewportOverrideRect(Optional<LayoutRect>, TriggerLayoutOrNot = TriggerLayoutOrNot::Yes);
+    Optional<LayoutRect> layoutViewportOverrideRect() const { return m_layoutViewportOverrideRect; }
 
     WEBCORE_EXPORT void setVisualViewportOverrideRect(Optional<LayoutRect>);
 

Modified: trunk/Source/WebKit/ChangeLog (247290 => 247291)


--- trunk/Source/WebKit/ChangeLog	2019-07-10 01:31:03 UTC (rev 247290)
+++ trunk/Source/WebKit/ChangeLog	2019-07-10 01:52:23 UTC (rev 247291)
@@ -1,3 +1,17 @@
+2019-07-09  Tim Horton  <timothy_hor...@apple.com>
+
+        Fixed elements appear in the middle of full page screenshots taken when scrolled
+        https://bugs.webkit.org/show_bug.cgi?id=199649
+        <rdar://problem/52476226>
+
+        Reviewed by Simon Fraser.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::computePagesForPrintingAndDrawToPDF):
+        Temporarily expand the layout viewport to the size of the snapshotting page,
+        so that fixed elements sit against the bounds of the page instead of
+        wherever you're currently scrolled to.
+
 2019-07-09  Simon Fraser  <simon.fra...@apple.com>
 
         [iOS WK2] Use Optional<> for two data members of WKWebView

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (247290 => 247291)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-07-10 01:31:03 UTC (rev 247290)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-07-10 01:52:23 UTC (rev 247291)
@@ -3690,7 +3690,14 @@
         reply(1);
         IntSize snapshotSize { FloatSize { printInfo.availablePaperWidth, printInfo.availablePaperHeight } };
         IntRect snapshotRect { {0, 0}, snapshotSize };
+
+        auto& frameView = *m_page->mainFrame().view();
+        auto originalLayoutViewportOverrideRect = frameView.layoutViewportOverrideRect();
+        frameView.setLayoutViewportOverrideRect(LayoutRect(snapshotRect));
+
         auto pdfData = pdfSnapshotAtSize(snapshotRect, snapshotSize, 0);
+
+        frameView.setLayoutViewportOverrideRect(originalLayoutViewportOverrideRect);
         send(Messages::WebPageProxy::DrawToPDFCallback(IPC::DataReference(CFDataGetBytePtr(pdfData.get()), CFDataGetLength(pdfData.get())), callbackID));
         return;
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to