Title: [200588] trunk
Revision
200588
Author
[email protected]
Date
2016-05-09 13:22:47 -0700 (Mon, 09 May 2016)

Log Message

[iOS WK2] Font size increases on some pages after navigating then going back
https://bugs.webkit.org/show_bug.cgi?id=157441
rdar://problem/22873240

Reviewed by Darin Adler.

Source/WebCore:

Sometimes I want to dump ViewportConfigurations from WebKit2 so export dump().

Test: fast/text-autosizing/ios/text-autosizing-after-back.html

* page/ViewportConfiguration.h:

Source/WebKit2:

There's an ordering dependency between setting the viewport configuration and doing
layouts when going back to a page from the page cache that is incorrectly handled.

In FrameLoader::commitProvisionalLoad(), CachedPage::restore() triggers a layout under
updateContentsSize(), but this happens before dispatchDidCommitLoad() which updates
the viewport arguments via ViewportConfiguration::setViewportArguments().

This issue is not addressed by the current commit. But a second problem is:
if the inputs to text autosizing change, we need to invalidate the autosizing state.
The relevant input here is the fixed layout width (which is determined from the viewport
configuration).

The current code invalidated text autosizing when m_viewportConfiguration.minimumLayoutSize()
changed, but the correct behavior is to invalidate based on fixed layout size changing.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::sendViewportAttributesChanged):
(WebKit::WebPage::setFixedLayoutSize):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::resetTextAutosizing):
(WebKit::WebPage::dynamicViewportSizeUpdate):
(WebKit::WebPage::viewportConfigurationChanged):
(WebKit::WebPage::setViewportConfigurationMinimumLayoutSize): Deleted.
(WebKit::WebPage::resetTextAutosizingBeforeLayoutIfNeeded): Deleted.

LayoutTests:

* fast/text-autosizing/ios/text-autosizing-after-back-expected.html: Added.
* fast/text-autosizing/ios/text-autosizing-after-back.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (200587 => 200588)


--- trunk/LayoutTests/ChangeLog	2016-05-09 20:18:15 UTC (rev 200587)
+++ trunk/LayoutTests/ChangeLog	2016-05-09 20:22:47 UTC (rev 200588)
@@ -1,3 +1,14 @@
+2016-05-06  Simon Fraser  <[email protected]>
+
+        [iOS WK2] Font size increases on some pages after navigating then going back
+        https://bugs.webkit.org/show_bug.cgi?id=157441
+        rdar://problem/22873240
+
+        Reviewed by Darin Adler.
+
+        * fast/text-autosizing/ios/text-autosizing-after-back-expected.html: Added.
+        * fast/text-autosizing/ios/text-autosizing-after-back.html: Added.
+
 2016-05-09  Ryan Haddad  <[email protected]>
 
         Rebaseline failing LayoutTests after r200580

Added: trunk/LayoutTests/fast/text-autosizing/ios/text-autosizing-after-back-expected.html (0 => 200588)


--- trunk/LayoutTests/fast/text-autosizing/ios/text-autosizing-after-back-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/ios/text-autosizing-after-back-expected.html	2016-05-09 20:22:47 UTC (rev 200588)
@@ -0,0 +1,19 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+<head>
+<meta name="viewport" content="width=device-width"/>
+<script>
+if (window.internals) {
+    window.internals.settings.setTextAutosizingEnabled(true);
+    window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
+}
+</script>
+</head>
+<body>
+    <div id="content"><a id='anchor' href=''>Anchor to another page</a></div>
+    <div>
+        Lorem ipsum dolor sit amet, consectetur adipisicing elit.
+    </div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/text-autosizing/ios/text-autosizing-after-back.html (0 => 200588)


--- trunk/LayoutTests/fast/text-autosizing/ios/text-autosizing-after-back.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/ios/text-autosizing-after-back.html	2016-05-09 20:22:47 UTC (rev 200588)
@@ -0,0 +1,54 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+<head>
+<meta name="viewport" content="width=device-width"/>
+    <script>
+        function navigateAwayAndBack() 
+        {
+            // Simulate a link click to create a history entry
+            var evt = new MouseEvent("click", {
+                bubbles: true,
+                cancelable: true,
+                view: window
+            });
+            document.getElementById('anchor').dispatchEvent(evt);
+        }
+
+        function runTest() 
+        {
+            if (window.testRunner) {
+                testRunner.waitUntilDone();
+                testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+            }
+
+            if (window.internals) {
+                window.internals.settings.setTextAutosizingEnabled(true);
+                window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
+            }
+            window.setTimeout("navigateAwayAndBack()", 0);
+        }
+
+        var showCount = 0;
+        function pageShowed()
+        {
+            if (++showCount == 2) {
+                // Timeout required to get rendering in WK1.
+                window.setTimeout(function() {
+                    if (window.testRunner)
+                        testRunner.notifyDone();
+                }, 0)
+            }
+        }
+
+        window.addEventListener('load', runTest, false);
+        window.addEventListener('pageshow', pageShowed, false);
+    </script>
+</head>
+<body>
+    <div id="content"><a id='anchor' href=''>Anchor to another page</a></div>
+    <div>
+        Lorem ipsum dolor sit amet, consectetur adipisicing elit.
+    </div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (200587 => 200588)


--- trunk/Source/WebCore/ChangeLog	2016-05-09 20:18:15 UTC (rev 200587)
+++ trunk/Source/WebCore/ChangeLog	2016-05-09 20:22:47 UTC (rev 200588)
@@ -1,3 +1,17 @@
+2016-05-06  Simon Fraser  <[email protected]>
+
+        [iOS WK2] Font size increases on some pages after navigating then going back
+        https://bugs.webkit.org/show_bug.cgi?id=157441
+        rdar://problem/22873240
+
+        Reviewed by Darin Adler.
+
+        Sometimes I want to dump ViewportConfigurations from WebKit2 so export dump().
+
+        Test: fast/text-autosizing/ios/text-autosizing-after-back.html
+
+        * page/ViewportConfiguration.h:
+
 2016-05-09  Eric Carlson  <[email protected]>
 
         "Main content" restrictions should not apply to media documents

Modified: trunk/Source/WebCore/page/ViewportConfiguration.h (200587 => 200588)


--- trunk/Source/WebCore/page/ViewportConfiguration.h	2016-05-09 20:18:15 UTC (rev 200587)
+++ trunk/Source/WebCore/page/ViewportConfiguration.h	2016-05-09 20:22:47 UTC (rev 200588)
@@ -103,7 +103,7 @@
     
 #ifndef NDEBUG
     WTF::CString description() const;
-    void dump() const;
+    WEBCORE_EXPORT void dump() const;
 #endif
 
 private:

Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (200587 => 200588)


--- trunk/Source/WebCore/rendering/RenderElement.cpp	2016-05-09 20:18:15 UTC (rev 200587)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp	2016-05-09 20:22:47 UTC (rev 200588)
@@ -31,13 +31,14 @@
 #include "CursorList.h"
 #include "ElementChildIterator.h"
 #include "EventHandler.h"
+#include "FlowThreadController.h"
 #include "FocusController.h"
 #include "Frame.h"
 #include "FrameSelection.h"
 #include "HTMLBodyElement.h"
 #include "HTMLHtmlElement.h"
 #include "HTMLNames.h"
-#include "FlowThreadController.h"
+#include "Logging.h"
 #include "PathUtilities.h"
 #include "RenderBlock.h"
 #include "RenderCounter.h"
@@ -2220,6 +2221,8 @@
     if (!document)
         return;
 
+    LOG(TextAutosizing, "RenderElement::resetTextAutosizing()");
+
     document->resetAutoSizingNodes();
 
     Vector<int> depthStack;

Modified: trunk/Source/WebKit2/ChangeLog (200587 => 200588)


--- trunk/Source/WebKit2/ChangeLog	2016-05-09 20:18:15 UTC (rev 200587)
+++ trunk/Source/WebKit2/ChangeLog	2016-05-09 20:22:47 UTC (rev 200588)
@@ -1,3 +1,37 @@
+2016-05-06  Simon Fraser  <[email protected]>
+
+        [iOS WK2] Font size increases on some pages after navigating then going back
+        https://bugs.webkit.org/show_bug.cgi?id=157441
+        rdar://problem/22873240
+
+        Reviewed by Darin Adler.
+
+        There's an ordering dependency between setting the viewport configuration and doing
+        layouts when going back to a page from the page cache that is incorrectly handled.
+
+        In FrameLoader::commitProvisionalLoad(), CachedPage::restore() triggers a layout under
+        updateContentsSize(), but this happens before dispatchDidCommitLoad() which updates
+        the viewport arguments via ViewportConfiguration::setViewportArguments().
+
+        This issue is not addressed by the current commit. But a second problem is:
+        if the inputs to text autosizing change, we need to invalidate the autosizing state.
+        The relevant input here is the fixed layout width (which is determined from the viewport
+        configuration).
+
+        The current code invalidated text autosizing when m_viewportConfiguration.minimumLayoutSize()
+        changed, but the correct behavior is to invalidate based on fixed layout size changing.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::sendViewportAttributesChanged):
+        (WebKit::WebPage::setFixedLayoutSize):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::resetTextAutosizing):
+        (WebKit::WebPage::dynamicViewportSizeUpdate):
+        (WebKit::WebPage::viewportConfigurationChanged):
+        (WebKit::WebPage::setViewportConfigurationMinimumLayoutSize): Deleted.
+        (WebKit::WebPage::resetTextAutosizingBeforeLayoutIfNeeded): Deleted.
+
 2016-05-09  Alex Christensen  <[email protected]>
 
         Don't use DiskCache for media resource loads

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (200587 => 200588)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2016-05-09 20:18:15 UTC (rev 200587)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2016-05-09 20:22:47 UTC (rev 200588)
@@ -1676,15 +1676,16 @@
     send(Messages::WebPageProxy::UseFixedLayoutDidChange(fixed));
 }
 
-void WebPage::setFixedLayoutSize(const IntSize& size)
+bool WebPage::setFixedLayoutSize(const IntSize& size)
 {
     FrameView* view = mainFrameView();
     if (!view || view->fixedLayoutSize() == size)
-        return;
+        return false;
 
     view->setFixedLayoutSize(size);
 
     send(Messages::WebPageProxy::FixedLayoutSizeDidChange(size));
+    return true;
 }
 
 IntSize WebPage::fixedLayoutSize() const

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (200587 => 200588)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2016-05-09 20:18:15 UTC (rev 200587)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2016-05-09 20:22:47 UTC (rev 200588)
@@ -393,7 +393,7 @@
 
     void setUseFixedLayout(bool);
     bool useFixedLayout() const { return m_useFixedLayout; }
-    void setFixedLayoutSize(const WebCore::IntSize&);
+    bool setFixedLayoutSize(const WebCore::IntSize&);
     WebCore::IntSize fixedLayoutSize() const;
 
     void listenForLayoutMilestones(uint32_t /* LayoutMilestones */);
@@ -975,7 +975,7 @@
     void handleSyntheticClick(WebCore::Node* nodeRespondingToClick, const WebCore::FloatPoint& location);
     void completeSyntheticClick(WebCore::Node* nodeRespondingToClick, const WebCore::FloatPoint& location);
     void sendTapHighlightForNodeIfNecessary(uint64_t requestID, WebCore::Node*);
-    void resetTextAutosizingBeforeLayoutIfNeeded(const WebCore::FloatSize& oldSize, const WebCore::FloatSize& newSize);
+    void resetTextAutosizing();
     WebCore::VisiblePosition visiblePositionInFocusedNodeForPoint(const WebCore::Frame&, const WebCore::IntPoint&, bool isInteractingWithAssistedNode);
     PassRefPtr<WebCore::Range> rangeForGranularityAtPoint(const WebCore::Frame&, const WebCore::IntPoint&, uint32_t granularity, bool isInteractingWithAssistedNode);
 #endif

Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (200587 => 200588)


--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2016-05-09 20:18:15 UTC (rev 200587)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2016-05-09 20:22:47 UTC (rev 200588)
@@ -2574,8 +2574,6 @@
 
 void WebPage::setViewportConfigurationMinimumLayoutSize(const FloatSize& size)
 {
-    resetTextAutosizingBeforeLayoutIfNeeded(m_viewportConfiguration.minimumLayoutSize(), size);
-    
     if (m_viewportConfiguration.setMinimumLayoutSize(size))
         viewportConfigurationChanged();
 }
@@ -2601,11 +2599,8 @@
     return WTF::areEssentiallyEqual(a, b);
 }
 
-void WebPage::resetTextAutosizingBeforeLayoutIfNeeded(const FloatSize& oldSize, const FloatSize& newSize)
+void WebPage::resetTextAutosizing()
 {
-    if (oldSize.width() == newSize.width())
-        return;
-
     for (Frame* frame = &m_page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
         Document* document = frame->document();
         if (!document || !document->renderView())
@@ -2650,11 +2645,12 @@
         }
     }
 
-    resetTextAutosizingBeforeLayoutIfNeeded(m_viewportConfiguration.minimumLayoutSize(), minimumLayoutSize);
     m_viewportConfiguration.setMinimumLayoutSize(minimumLayoutSize);
     IntSize newLayoutSize = m_viewportConfiguration.layoutSize();
 
-    setFixedLayoutSize(newLayoutSize);
+    if (setFixedLayoutSize(newLayoutSize))
+        resetTextAutosizing();
+
     setMaximumUnobscuredSize(maximumUnobscuredSize);
 
     frameView.updateLayoutAndStyleIfNeededRecursive();
@@ -2811,7 +2807,8 @@
 
 void WebPage::viewportConfigurationChanged()
 {
-    setFixedLayoutSize(m_viewportConfiguration.layoutSize());
+    if (setFixedLayoutSize(m_viewportConfiguration.layoutSize()))
+        resetTextAutosizing();
 
     double initialScale = m_viewportConfiguration.initialScale();
     double scale;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to