<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[246348] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/246348">246348</a></dd>
<dt>Author</dt> <dd>wenson_hsieh@apple.com</dd>
<dt>Date</dt> <dd>2019-06-11 21:51:10 -0700 (Tue, 11 Jun 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>[iOS] Idempotent text autosizing needs to react properly to viewport changes
https://bugs.webkit.org/show_bug.cgi?id=198736
<rdar://problem/50591911>

Reviewed by Zalan Bujtas.

Source/WebCore:

Minor refactoring and some adjustments around StyleResolver::adjustRenderStyleForTextAutosizing. See below for
more details, as well as the WebKit ChangeLog.

Test: fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-after-changing-initial-scale.html

* css/StyleResolver.cpp:
(WebCore::StyleResolver::adjustRenderStyleForTextAutosizing):

Rewrite this using early return statements, to make it easier to debug why elements fall out of text autosizing.
Additionally, this function currently bails if the initial scale is exactly 1, whereas we can really avoid text
autosizing in the case where the initial scale is at least 1; handle this by making idempotentTextSize return
immediately with the specified size, in the case where the scale is at least 1.

Lastly, remove the null check for element by making this method take an Element&, and only call this from
adjustRenderStyle if the element is nonnull (which matches adjustRenderStyleForSiteSpecificQuirks).

(WebCore::StyleResolver::adjustRenderStyle):
* css/StyleResolver.h:
* rendering/style/TextSizeAdjustment.cpp:
(WebCore::AutosizeStatus::idempotentTextSize):

Source/WebKit:

If idempotent text autosizing is enabled, respond to viewport initial scale changes by forcing a style recalc,
since the amount by which idempotent text autosizing boosts font sizes depends on the Page's initial scale.

* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::resetIdempotentTextAutosizingIfNeeded):
(WebKit::WebPage::viewportConfigurationChanged):

LayoutTests:

Add a new layout test that programmatically adjusts the meta viewport initial scale, and dumps the resulting
computed sizes of several paragraphs of text, after adjusting for text autosizing.

* fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-after-changing-initial-scale-expected.txt: Added.
* fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-after-changing-initial-scale.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssStyleResolvercpp">trunk/Source/WebCore/css/StyleResolver.cpp</a></li>
<li><a href="#trunkSourceWebCorecssStyleResolverh">trunk/Source/WebCore/css/StyleResolver.h</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleTextSizeAdjustmentcpp">trunk/Source/WebCore/rendering/style/TextSizeAdjustment.cpp</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPageh">trunk/Source/WebKit/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageiosWebPageIOSmm">trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasttextautosizingiosidempotentmodeidempotentautosizingafterchanginginitialscaleexpectedtxt">trunk/LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-after-changing-initial-scale-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasttextautosizingiosidempotentmodeidempotentautosizingafterchanginginitialscalehtml">trunk/LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-after-changing-initial-scale.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (246347 => 246348)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2019-06-12 04:13:36 UTC (rev 246347)
+++ trunk/LayoutTests/ChangeLog 2019-06-12 04:51:10 UTC (rev 246348)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2019-06-11  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [iOS] Idempotent text autosizing needs to react properly to viewport changes
+        https://bugs.webkit.org/show_bug.cgi?id=198736
+        <rdar://problem/50591911>
+
+        Reviewed by Zalan Bujtas.
+
+        Add a new layout test that programmatically adjusts the meta viewport initial scale, and dumps the resulting
+        computed sizes of several paragraphs of text, after adjusting for text autosizing.
+
+        * fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-after-changing-initial-scale-expected.txt: Added.
+        * fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-after-changing-initial-scale.html: Added.
+
</ins><span class="cx"> 2019-06-11  Zalan Bujtas  <zalan@apple.com>
</span><span class="cx"> 
</span><span class="cx">         LayoutTests/fast/events/touch/ios/double-tap-for-double-click* test cases are failing
</span></span></pre></div>
<a id="trunkLayoutTestsfasttextautosizingiosidempotentmodeidempotentautosizingafterchanginginitialscaleexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-after-changing-initial-scale-expected.txt (0 => 246348)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-after-changing-initial-scale-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-after-changing-initial-scale-expected.txt   2019-06-12 04:51:10 UTC (rev 246348)
</span><span class="lines">@@ -0,0 +1,41 @@
</span><ins>+At initial scale 1
+none   auto
+8px    8px
+12px   12px
+14px   14px
+16px   16px
+20px   20px
+
+After changing initial scale to 0.5
+none   auto
+8px    13px
+12px   17px
+14px   19px
+16px   19px
+20px   20px
+
+After changing initial scale to 0.75
+none   auto
+8px    10px
+12px   14px
+14px   16px
+16px   16px
+20px   20px
+
+After changing initial scale back to 1
+none   auto
+8px    8px
+12px   12px
+14px   14px
+16px   16px
+20px   20px
+
+After changing initial scale to 1.25
+none   auto
+8px    8px
+12px   12px
+14px   14px
+16px   16px
+20px   20px
+
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfasttextautosizingiosidempotentmodeidempotentautosizingafterchanginginitialscalehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-after-changing-initial-scale.html (0 => 246348)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-after-changing-initial-scale.html                                (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-after-changing-initial-scale.html   2019-06-12 04:51:10 UTC (rev 246348)
</span><span class="lines">@@ -0,0 +1,158 @@
</span><ins>+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true contentMode=mobile ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>
+body, html {
+    margin: 0;
+}
+
+.no-autosizing {
+    -webkit-text-size-adjust: none;
+}
+
+pre, code {
+    color: white;
+    background-color: black;
+    padding: 4px;
+}
+
+.container {
+    border: 1px solid black;
+    padding: 8px 12px 12px 12px;
+    max-width: 320px;
+}
+
+#text0, #text5 {
+    font-size: 8px;
+}
+
+#text1, #text6 {
+    font-size: 12px;
+}
+
+#text2, #text7 {
+    font-size: 14px;
+}
+
+#text3, #text8 {
+    font-size: 16px;
+}
+
+#text4, #text9 {
+    font-size: 20px;
+}
+
+table, td {
+    border: 1px solid gray;
+}
+
+thead, tfoot {
+    background-color: tomato;
+    color: white;
+}
+
+th, td {
+    padding: 4px;
+}
+</style>
+<script src="../../../../resources/ui-helper.js"></script>
+<script type="text/javascript">
+if (window.internals && window.testRunner) {
+    internals.settings.setTextAutosizingEnabled(true);
+    internals.settings.setTextAutosizingUsesIdempotentMode(true);
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+async function dumpTextSizes(description) {
+    if (window.testRunner)
+        await UIHelper.ensurePresentationUpdate();
+
+    const table = document.querySelector("template#table").content.cloneNode("true").firstElementChild;
+    table.querySelector(".description").textContent = description;
+    for (let index = 0; index < 10; ++index) {
+        const computedFontSize = getComputedStyle(document.querySelector(`#text${index}`)).fontSize;
+        table.querySelector(`.text${index}`).textContent = computedFontSize;
+    }
+
+    document.body.appendChild(table);
+    document.body.appendChild(document.createElement("br"));
+}
+
+addEventListener("load", async () => {
+    const metaViewport = document.querySelector("meta");
+    await dumpTextSizes("At initial scale 1");
+
+    metaViewport.content = "width=device-width, initial-scale=0.5";
+    await dumpTextSizes("After changing initial scale to 0.5");
+
+    metaViewport.content = "width=device-width, initial-scale=0.75";
+    await dumpTextSizes("After changing initial scale to 0.75");
+
+    metaViewport.content = "width=device-width, initial-scale=1.0";
+    await dumpTextSizes("After changing initial scale back to 1");
+
+    metaViewport.content = "width=device-width, initial-scale=1.25";
+    await dumpTextSizes("After changing initial scale to 1.25");
+
+    document.querySelector(".text-containers").remove();
+    if (window.testRunner)
+        testRunner.notifyDone();
+});
+</script>
+</head>
+<body>
+    <template id="table">
+        <table>
+            <thead>
+                <tr>
+                    <th colspan="2" class="description"></th>
+                </tr>
+                <tr>
+                    <th>none</th>
+                    <th>auto</th>
+                </tr>
+            </thead>
+            <tbody>
+                <tr>
+                    <td class="text0"></td>
+                    <td class="text5"></td>
+                </tr>
+                <tr>
+                    <td class="text1"></td>
+                    <td class="text6"></td>
+                </tr>
+                <tr>
+                    <td class="text2"></td>
+                    <td class="text7"></td>
+                </tr>
+                <tr>
+                    <td class="text3"></td>
+                    <td class="text8"></td>
+                </tr>
+                <tr>
+                    <td class="text4"></td>
+                    <td class="text9"></td>
+                </tr>
+            </tbody>
+        </table>
+    </template>
+    <div class="text-containers">
+        <div class="container no-autosizing">
+            <p id="text0">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean laoreet nisi felis, eu scelerisque dolor imperdiet in.</p>
+            <p id="text1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean laoreet nisi felis, eu scelerisque dolor imperdiet in.</p>
+            <p id="text2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean laoreet nisi felis, eu scelerisque dolor imperdiet in.</p>
+            <p id="text3">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean laoreet nisi felis, eu scelerisque dolor imperdiet in.</p>
+            <p id="text4">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean laoreet nisi felis, eu scelerisque dolor imperdiet in.</p>
+        </div>
+        <div class="container">
+            <p id="text5">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean laoreet nisi felis, eu scelerisque dolor imperdiet in.</p>
+            <p id="text6">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean laoreet nisi felis, eu scelerisque dolor imperdiet in.</p>
+            <p id="text7">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean laoreet nisi felis, eu scelerisque dolor imperdiet in.</p>
+            <p id="text8">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean laoreet nisi felis, eu scelerisque dolor imperdiet in.</p>
+            <p id="text9">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean laoreet nisi felis, eu scelerisque dolor imperdiet in.</p>
+        </div>
+    </div>
+</body>
+</html>
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (246347 => 246348)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-06-12 04:13:36 UTC (rev 246347)
+++ trunk/Source/WebCore/ChangeLog      2019-06-12 04:51:10 UTC (rev 246348)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2019-06-11  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [iOS] Idempotent text autosizing needs to react properly to viewport changes
+        https://bugs.webkit.org/show_bug.cgi?id=198736
+        <rdar://problem/50591911>
+
+        Reviewed by Zalan Bujtas.
+
+        Minor refactoring and some adjustments around StyleResolver::adjustRenderStyleForTextAutosizing. See below for
+        more details, as well as the WebKit ChangeLog.
+
+        Test: fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-after-changing-initial-scale.html
+
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::adjustRenderStyleForTextAutosizing):
+
+        Rewrite this using early return statements, to make it easier to debug why elements fall out of text autosizing.
+        Additionally, this function currently bails if the initial scale is exactly 1, whereas we can really avoid text
+        autosizing in the case where the initial scale is at least 1; handle this by making idempotentTextSize return
+        immediately with the specified size, in the case where the scale is at least 1.
+
+        Lastly, remove the null check for element by making this method take an Element&, and only call this from
+        adjustRenderStyle if the element is nonnull (which matches adjustRenderStyleForSiteSpecificQuirks).
+
+        (WebCore::StyleResolver::adjustRenderStyle):
+        * css/StyleResolver.h:
+        * rendering/style/TextSizeAdjustment.cpp:
+        (WebCore::AutosizeStatus::idempotentTextSize):
+
</ins><span class="cx"> 2019-06-11  Timothy Hatcher  <timothy@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Flash when tapping compose button after switching to/from dark mode without restarting Mail.
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.cpp (246347 => 246348)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleResolver.cpp       2019-06-12 04:13:36 UTC (rev 246347)
+++ trunk/Source/WebCore/css/StyleResolver.cpp  2019-06-12 04:51:10 UTC (rev 246348)
</span><span class="lines">@@ -877,16 +877,26 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void StyleResolver::adjustRenderStyleForTextAutosizing(RenderStyle& style, const Element* element)
</del><ins>+void StyleResolver::adjustRenderStyleForTextAutosizing(RenderStyle& style, const Element& element)
</ins><span class="cx"> {
</span><span class="cx">     auto newAutosizeStatus = AutosizeStatus::updateStatus(style);
</span><del>-    auto pageScale = document().page() ? document().page()->initialScale() : 1.0f;
-    if (settings().textAutosizingEnabled() && settings().textAutosizingUsesIdempotentMode() && element && !newAutosizeStatus.shouldSkipSubtree() && !style.textSizeAdjust().isNone() && hasTextChildren(*element) && pageScale != 1.0f) {
-        auto fontDescription = style.fontDescription();
-        fontDescription.setComputedSize(AutosizeStatus::idempotentTextSize(fontDescription.specifiedSize(), pageScale));
-        style.setFontDescription(WTFMove(fontDescription));
-        style.fontCascade().update(&document().fontSelector());
-    }
</del><ins>+    if (!settings().textAutosizingEnabled() || !settings().textAutosizingUsesIdempotentMode())
+        return;
+
+    if (!hasTextChildren(element))
+        return;
+
+    if (style.textSizeAdjust().isNone())
+        return;
+
+    if (newAutosizeStatus.shouldSkipSubtree())
+        return;
+
+    float initialScale = document().page() ? document().page()->initialScale() : 1;
+    auto fontDescription = style.fontDescription();
+    fontDescription.setComputedSize(AutosizeStatus::idempotentTextSize(fontDescription.specifiedSize(), initialScale));
+    style.setFontDescription(WTFMove(fontDescription));
+    style.fontCascade().update(&document().fontSelector());
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -1140,12 +1150,12 @@
</span><span class="cx">     style.setEffectiveTouchActions(computeEffectiveTouchActions(style, parentStyle.effectiveTouchActions()));
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    if (element) {
</ins><span class="cx"> #if ENABLE(TEXT_AUTOSIZING)
</span><del>-    adjustRenderStyleForTextAutosizing(style, element);
</del><ins>+        adjustRenderStyleForTextAutosizing(style, *element);
</ins><span class="cx"> #endif
</span><del>-
-    if (element)
</del><span class="cx">         adjustRenderStyleForSiteSpecificQuirks(style, *element);
</span><ins>+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void StyleResolver::adjustRenderStyleForSiteSpecificQuirks(RenderStyle& style, const Element& element)
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.h (246347 => 246348)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleResolver.h 2019-06-12 04:13:36 UTC (rev 246347)
+++ trunk/Source/WebCore/css/StyleResolver.h    2019-06-12 04:51:10 UTC (rev 246348)
</span><span class="lines">@@ -500,7 +500,7 @@
</span><span class="cx">     // the last reference to a style declaration are garbage collected.
</span><span class="cx">     void sweepMatchedPropertiesCache();
</span><span class="cx"> 
</span><del>-    void adjustRenderStyleForTextAutosizing(RenderStyle&, const Element*);
</del><ins>+    void adjustRenderStyleForTextAutosizing(RenderStyle&, const Element&);
</ins><span class="cx"> 
</span><span class="cx">     typedef HashMap<unsigned, MatchedPropertiesCacheItem> MatchedPropertiesCache;
</span><span class="cx">     MatchedPropertiesCache m_matchedPropertiesCache;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleTextSizeAdjustmentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/TextSizeAdjustment.cpp (246347 => 246348)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/TextSizeAdjustment.cpp      2019-06-12 04:13:36 UTC (rev 246347)
+++ trunk/Source/WebCore/rendering/style/TextSizeAdjustment.cpp 2019-06-12 04:51:10 UTC (rev 246348)
</span><span class="lines">@@ -70,6 +70,9 @@
</span><span class="cx"> 
</span><span class="cx"> float AutosizeStatus::idempotentTextSize(float specifiedSize, float pageScale)
</span><span class="cx"> {
</span><ins>+    if (pageScale >= 1)
+        return specifiedSize;
+
</ins><span class="cx">     // This describes a piecewise curve when the page scale is 2/3.
</span><span class="cx">     FloatPoint points[] = { {0.0f, 0.0f}, {6.0f, 9.0f}, {14.0f, 17.0f} };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (246347 => 246348)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2019-06-12 04:13:36 UTC (rev 246347)
+++ trunk/Source/WebKit/ChangeLog       2019-06-12 04:51:10 UTC (rev 246348)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2019-06-11  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [iOS] Idempotent text autosizing needs to react properly to viewport changes
+        https://bugs.webkit.org/show_bug.cgi?id=198736
+        <rdar://problem/50591911>
+
+        Reviewed by Zalan Bujtas.
+
+        If idempotent text autosizing is enabled, respond to viewport initial scale changes by forcing a style recalc,
+        since the amount by which idempotent text autosizing boosts font sizes depends on the Page's initial scale.
+
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::resetIdempotentTextAutosizingIfNeeded):
+        (WebKit::WebPage::viewportConfigurationChanged):
+
</ins><span class="cx"> 2019-06-11  Zalan Bujtas  <zalan@apple.com>
</span><span class="cx"> 
</span><span class="cx">         LayoutTests/fast/events/touch/ios/double-tap-for-double-click* test cases are failing
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (246347 => 246348)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-06-12 04:13:36 UTC (rev 246347)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h    2019-06-12 04:51:10 UTC (rev 246348)
</span><span class="lines">@@ -1244,6 +1244,7 @@
</span><span class="cx">     void completeSyntheticClick(WebCore::Node& nodeRespondingToClick, const WebCore::FloatPoint& location, OptionSet<WebKit::WebEvent::Modifier>, WebCore::SyntheticClickType, WebCore::PointerID = WebCore::mousePointerID);
</span><span class="cx">     void sendTapHighlightForNodeIfNecessary(uint64_t requestID, WebCore::Node*);
</span><span class="cx">     void resetTextAutosizing();
</span><ins>+    void resetIdempotentTextAutosizingIfNeeded(double previousInitialScale);
</ins><span class="cx">     WebCore::VisiblePosition visiblePositionInFocusedNodeForPoint(const WebCore::Frame&, const WebCore::IntPoint&, bool isInteractingWithFocusedElement);
</span><span class="cx">     RefPtr<WebCore::Range> rangeForGranularityAtPoint(WebCore::Frame&, const WebCore::IntPoint&, uint32_t granularity, bool isInteractingWithFocusedElement);
</span><span class="cx">     void dispatchSyntheticMouseEventsForSelectionGesture(SelectionTouch, const WebCore::IntPoint&);
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageiosWebPageIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (246347 => 246348)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2019-06-12 04:13:36 UTC (rev 246347)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm    2019-06-12 04:51:10 UTC (rev 246348)
</span><span class="lines">@@ -3333,10 +3333,27 @@
</span><span class="cx">     return m_page->settings().shouldIgnoreMetaViewport();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPage::resetIdempotentTextAutosizingIfNeeded(double previousInitialScale)
+{
+    if (!m_page->settings().textAutosizingUsesIdempotentMode())
+        return;
+
+    const float minimumScaleChangeBeforeRecomputingTextAutosizing = 0.01;
+    if (std::abs(previousInitialScale - m_page->initialScale()) < minimumScaleChangeBeforeRecomputingTextAutosizing)
+        return;
+
+    if (m_page->initialScale() >= 1 && previousInitialScale >= 1)
+        return;
+
+    m_page->setNeedsRecalcStyleInAllFrames();
+}
+
</ins><span class="cx"> void WebPage::viewportConfigurationChanged(ZoomToInitialScale zoomToInitialScale)
</span><span class="cx"> {
</span><ins>+    double previousInitialScale = m_page->initialScale();
</ins><span class="cx">     double initialScale = m_viewportConfiguration.initialScale();
</span><span class="cx">     m_page->setInitialScale(initialScale);
</span><ins>+    resetIdempotentTextAutosizingIfNeeded(previousInitialScale);
</ins><span class="cx"> 
</span><span class="cx">     if (setFixedLayoutSize(m_viewportConfiguration.layoutSize()))
</span><span class="cx">         resetTextAutosizing();
</span></span></pre>
</div>
</div>

</body>
</html>