Title: [294690] trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Revision
294690
Author
[email protected]
Date
2022-05-23 15:37:28 -0700 (Mon, 23 May 2022)

Log Message

[iPadOS] Align scroll position to origin on resize in Multitasking mode
https://bugs.webkit.org/show_bug.cgi?id=240815
rdar://92888214

Reviewed by Devin Rousso.

Make a minor adjustment to avoid re-centering the target unobscured content rect on the hit-tested
node in the center of the viewport, when multitasking mode is enabled; instead, we can simply
preserve the existing unobscured content rect offset.

* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:

We can also avoid this hit-test when `usesMultitaskingModeViewportBehaviors()` is enabled, since we
only need to anchor to the origin of the current unobscured rect.

(WebKit::WebPage::dynamicViewportSizeUpdate):

Canonical link: https://commits.webkit.org/250894@main

Modified Paths

Diff

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


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2022-05-23 22:19:23 UTC (rev 294689)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2022-05-23 22:37:28 UTC (rev 294690)
@@ -3643,6 +3643,7 @@
     FrameView& frameView = *m_page->mainFrame().view();
     IntSize oldContentSize = frameView.contentsSize();
     float oldPageScaleFactor = m_page->pageScaleFactor();
+    auto oldUnobscuredContentRect = frameView.unobscuredContentRect();
     bool wasAtInitialScale = areEssentiallyEqualAsFloat(oldPageScaleFactor, m_viewportConfiguration.initialScale());
 
     m_dynamicSizeUpdateHistory.add(std::make_pair(oldContentSize, oldPageScaleFactor), frameView.scrollPosition());
@@ -3651,7 +3652,7 @@
     double visibleHorizontalFraction = 1;
     float relativeHorizontalPositionInNodeAtCenter = 0;
     float relativeVerticalPositionInNodeAtCenter = 0;
-    {
+    if (!usesMultitaskingModeViewportBehaviors()) {
         visibleHorizontalFraction = frameView.unobscuredContentSize().width() / oldContentSize.width();
         IntPoint unobscuredContentRectCenter = frameView.unobscuredContentRect().center();
 
@@ -3705,8 +3706,15 @@
         double scaleDifference = targetScale / scale;
         double newUnobscuredRectWidth = targetUnobscuredRect.width() * scaleDifference;
         double newUnobscuredRectHeight = targetUnobscuredRect.height() * scaleDifference;
-        double newUnobscuredRectX = targetUnobscuredRect.x() - (newUnobscuredRectWidth - targetUnobscuredRect.width()) / 2;
-        double newUnobscuredRectY = targetUnobscuredRect.y() - (newUnobscuredRectHeight - targetUnobscuredRect.height()) / 2;
+        double newUnobscuredRectX;
+        double newUnobscuredRectY;
+        if (usesMultitaskingModeViewportBehaviors()) {
+            newUnobscuredRectX = oldUnobscuredContentRect.x();
+            newUnobscuredRectY = oldUnobscuredContentRect.y();
+        } else {
+            newUnobscuredRectX = targetUnobscuredRect.x() - (newUnobscuredRectWidth - targetUnobscuredRect.width()) / 2;
+            newUnobscuredRectY = targetUnobscuredRect.y() - (newUnobscuredRectHeight - targetUnobscuredRect.height()) / 2;
+        }
         newUnobscuredContentRect = FloatRect(newUnobscuredRectX, newUnobscuredRectY, newUnobscuredRectWidth, newUnobscuredRectHeight);
 
         // 2) Extend our new unobscuredRect by the obscured margins to get a new exposed rect.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to