<!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>[206641] trunk/Source/WebCore</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/206641">206641</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2016-09-30 10:00:22 -0700 (Fri, 30 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Remove &quot;rem&quot; unit optimization for document element font size changes
https://bugs.webkit.org/show_bug.cgi?id=162778

Reviewed by Alex Christensen.

We awkwardly track from the parser level if any stylesheet in a document uses any rem units. This is only used to minimally
optimize a case where document element's (&lt;html&gt;) font size changes dynamically.

In practice such changes are rare. Browsing around I couldn't find a single case where this optimization got used.
Even if it was used it would be of low value as a full style resolution is likely to happen anyway (as font inherits)
and the only thing really saved is that we don't need to invalidate the matched properties cache.

* css/CSSGrammar.y.in:
* css/StyleSheetContents.cpp:
(WebCore::StyleSheetContents::StyleSheetContents):
* css/StyleSheetContents.h:
* dom/AuthorStyleSheets.cpp:
(WebCore::AuthorStyleSheets::updateActiveStyleSheets):
* dom/AuthorStyleSheets.h:
(WebCore::AuthorStyleSheets::usesRemUnits): Deleted.
(WebCore::AuthorStyleSheets::setUsesRemUnit): Deleted.
* dom/Document.cpp:
(WebCore::Document::recalcStyle):
(WebCore::Document::updateBaseURL):
* style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::resolveElement):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssCSSGrammaryin">trunk/Source/WebCore/css/CSSGrammar.y.in</a></li>
<li><a href="#trunkSourceWebCorecssStyleSheetContentscpp">trunk/Source/WebCore/css/StyleSheetContents.cpp</a></li>
<li><a href="#trunkSourceWebCorecssStyleSheetContentsh">trunk/Source/WebCore/css/StyleSheetContents.h</a></li>
<li><a href="#trunkSourceWebCoredomAuthorStyleSheetscpp">trunk/Source/WebCore/dom/AuthorStyleSheets.cpp</a></li>
<li><a href="#trunkSourceWebCoredomAuthorStyleSheetsh">trunk/Source/WebCore/dom/AuthorStyleSheets.h</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleStyleTreeResolvercpp">trunk/Source/WebCore/style/StyleTreeResolver.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (206640 => 206641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-30 16:59:24 UTC (rev 206640)
+++ trunk/Source/WebCore/ChangeLog        2016-09-30 17:00:22 UTC (rev 206641)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2016-09-30  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Remove &quot;rem&quot; unit optimization for document element font size changes
+        https://bugs.webkit.org/show_bug.cgi?id=162778
+
+        Reviewed by Alex Christensen.
+
+        We awkwardly track from the parser level if any stylesheet in a document uses any rem units. This is only used to minimally
+        optimize a case where document element's (&lt;html&gt;) font size changes dynamically.
+
+        In practice such changes are rare. Browsing around I couldn't find a single case where this optimization got used.
+        Even if it was used it would be of low value as a full style resolution is likely to happen anyway (as font inherits)
+        and the only thing really saved is that we don't need to invalidate the matched properties cache.
+
+        * css/CSSGrammar.y.in:
+        * css/StyleSheetContents.cpp:
+        (WebCore::StyleSheetContents::StyleSheetContents):
+        * css/StyleSheetContents.h:
+        * dom/AuthorStyleSheets.cpp:
+        (WebCore::AuthorStyleSheets::updateActiveStyleSheets):
+        * dom/AuthorStyleSheets.h:
+        (WebCore::AuthorStyleSheets::usesRemUnits): Deleted.
+        (WebCore::AuthorStyleSheets::setUsesRemUnit): Deleted.
+        * dom/Document.cpp:
+        (WebCore::Document::recalcStyle):
+        (WebCore::Document::updateBaseURL):
+        * style/StyleTreeResolver.cpp:
+        (WebCore::Style::TreeResolver::resolveElement):
+
</ins><span class="cx"> 2016-09-30  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         RenderLayer::clipRects may return nullptr.
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSGrammaryin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSGrammar.y.in (206640 => 206641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSGrammar.y.in        2016-09-30 16:59:24 UTC (rev 206640)
+++ trunk/Source/WebCore/css/CSSGrammar.y.in        2016-09-30 17:00:22 UTC (rev 206641)
</span><span class="lines">@@ -1728,8 +1728,6 @@
</span><span class="cx">       $$.id = CSSValueInvalid;
</span><span class="cx">       $$.fValue = $1;
</span><span class="cx">       $$.unit = CSSPrimitiveValue::CSS_REMS;
</span><del>-      if (parser-&gt;m_styleSheet)
-          parser-&gt;m_styleSheet-&gt;parserSetUsesRemUnits();
</del><span class="cx">   }
</span><span class="cx">   | CHS { $$.id = CSSValueInvalid; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_CHS; }
</span><span class="cx">   | VW { $$.id = CSSValueInvalid; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VW; }
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleSheetContentscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleSheetContents.cpp (206640 => 206641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleSheetContents.cpp        2016-09-30 16:59:24 UTC (rev 206640)
+++ trunk/Source/WebCore/css/StyleSheetContents.cpp        2016-09-30 17:00:22 UTC (rev 206641)
</span><span class="lines">@@ -67,7 +67,6 @@
</span><span class="cx">     , m_isUserStyleSheet(ownerRule &amp;&amp; ownerRule-&gt;parentStyleSheet() &amp;&amp; ownerRule-&gt;parentStyleSheet()-&gt;isUserStyleSheet())
</span><span class="cx">     , m_hasSyntacticallyValidCSSHeader(true)
</span><span class="cx">     , m_didLoadErrorOccur(false)
</span><del>-    , m_usesRemUnits(false)
</del><span class="cx">     , m_usesStyleBasedEditability(false)
</span><span class="cx">     , m_isMutable(false)
</span><span class="cx">     , m_isInMemoryCache(false)
</span><span class="lines">@@ -88,7 +87,6 @@
</span><span class="cx">     , m_isUserStyleSheet(o.m_isUserStyleSheet)
</span><span class="cx">     , m_hasSyntacticallyValidCSSHeader(o.m_hasSyntacticallyValidCSSHeader)
</span><span class="cx">     , m_didLoadErrorOccur(false)
</span><del>-    , m_usesRemUnits(o.m_usesRemUnits)
</del><span class="cx">     , m_usesStyleBasedEditability(o.m_usesStyleBasedEditability)
</span><span class="cx">     , m_isMutable(false)
</span><span class="cx">     , m_isInMemoryCache(false)
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleSheetContentsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleSheetContents.h (206640 => 206641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleSheetContents.h        2016-09-30 16:59:24 UTC (rev 206640)
+++ trunk/Source/WebCore/css/StyleSheetContents.h        2016-09-30 17:00:22 UTC (rev 206641)
</span><span class="lines">@@ -96,7 +96,6 @@
</span><span class="cx">     void parserAddNamespace(const AtomicString&amp; prefix, const AtomicString&amp; uri);
</span><span class="cx">     void parserAppendRule(Ref&lt;StyleRuleBase&gt;&amp;&amp;);
</span><span class="cx">     void parserSetEncodingFromCharsetRule(const String&amp; encoding); 
</span><del>-    void parserSetUsesRemUnits() { m_usesRemUnits = true; }
</del><span class="cx">     void parserSetUsesStyleBasedEditability() { m_usesStyleBasedEditability = true; }
</span><span class="cx"> 
</span><span class="cx">     void clearRules();
</span><span class="lines">@@ -122,7 +121,6 @@
</span><span class="cx">     unsigned ruleCount() const;
</span><span class="cx">     StyleRuleBase* ruleAt(unsigned index) const;
</span><span class="cx"> 
</span><del>-    bool usesRemUnits() const { return m_usesRemUnits; }
</del><span class="cx">     bool usesStyleBasedEditability() const { return m_usesStyleBasedEditability; }
</span><span class="cx"> 
</span><span class="cx">     unsigned estimatedSizeInBytes() const;
</span><span class="lines">@@ -166,7 +164,6 @@
</span><span class="cx">     bool m_isUserStyleSheet : 1;
</span><span class="cx">     bool m_hasSyntacticallyValidCSSHeader : 1;
</span><span class="cx">     bool m_didLoadErrorOccur : 1;
</span><del>-    bool m_usesRemUnits : 1;
</del><span class="cx">     bool m_usesStyleBasedEditability : 1;
</span><span class="cx">     bool m_isMutable : 1;
</span><span class="cx">     bool m_isInMemoryCache : 1;
</span></span></pre></div>
<a id="trunkSourceWebCoredomAuthorStyleSheetscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/AuthorStyleSheets.cpp (206640 => 206641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/AuthorStyleSheets.cpp        2016-09-30 16:59:24 UTC (rev 206640)
+++ trunk/Source/WebCore/dom/AuthorStyleSheets.cpp        2016-09-30 17:00:22 UTC (rev 206641)
</span><span class="lines">@@ -330,8 +330,6 @@
</span><span class="cx">     InspectorInstrumentation::activeStyleSheetsUpdated(m_document);
</span><span class="cx"> 
</span><span class="cx">     for (const auto&amp; sheet : m_activeStyleSheets) {
</span><del>-        if (sheet-&gt;contents().usesRemUnits())
-            m_usesRemUnits = true;
</del><span class="cx">         if (sheet-&gt;contents().usesStyleBasedEditability())
</span><span class="cx">             m_usesStyleBasedEditability = true;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCoredomAuthorStyleSheetsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/AuthorStyleSheets.h (206640 => 206641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/AuthorStyleSheets.h        2016-09-30 16:59:24 UTC (rev 206640)
+++ trunk/Source/WebCore/dom/AuthorStyleSheets.h        2016-09-30 17:00:22 UTC (rev 206641)
</span><span class="lines">@@ -76,8 +76,6 @@
</span><span class="cx"> 
</span><span class="cx">     bool hasPendingSheets() const { return m_pendingStyleSheetCount &gt; 0; }
</span><span class="cx"> 
</span><del>-    bool usesRemUnits() const { return m_usesRemUnits; }
-    void setUsesRemUnit(bool b) { m_usesRemUnits = b; }
</del><span class="cx">     bool usesStyleBasedEditability() { return m_usesStyleBasedEditability; }
</span><span class="cx"> 
</span><span class="cx">     bool activeStyleSheetsContains(const CSSStyleSheet*) const;
</span><span class="lines">@@ -131,7 +129,6 @@
</span><span class="cx">     String m_preferredStylesheetSetName;
</span><span class="cx">     String m_selectedStylesheetSetName;
</span><span class="cx"> 
</span><del>-    bool m_usesRemUnits { false };
</del><span class="cx">     bool m_usesStyleBasedEditability { false };
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (206640 => 206641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp        2016-09-30 16:59:24 UTC (rev 206640)
+++ trunk/Source/WebCore/dom/Document.cpp        2016-09-30 17:00:22 UTC (rev 206641)
</span><span class="lines">@@ -1866,12 +1866,6 @@
</span><span class="cx"> 
</span><span class="cx">     InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalculateStyle(*this);
</span><span class="cx"> 
</span><del>-    // FIXME: We never reset this flags.
-    if (m_elementSheet &amp;&amp; m_elementSheet-&gt;contents().usesRemUnits())
-        authorStyleSheets().setUsesRemUnit(true);
-    // We don't call setUsesStyleBasedEditability here because the whole point of the flag is to avoid style recalc.
-    // i.e. updating the flag here would be too late.
-
</del><span class="cx">     m_inStyleRecalc = true;
</span><span class="cx">     bool updatedCompositingLayers = false;
</span><span class="cx">     {
</span><span class="lines">@@ -2972,12 +2966,9 @@
</span><span class="cx">     if (m_elementSheet) {
</span><span class="cx">         // Element sheet is silly. It never contains anything.
</span><span class="cx">         ASSERT(!m_elementSheet-&gt;contents().ruleCount());
</span><del>-        bool usesRemUnits = m_elementSheet-&gt;contents().usesRemUnits();
</del><span class="cx">         bool usesStyleBasedEditability = m_elementSheet-&gt;contents().usesStyleBasedEditability();
</span><span class="cx">         m_elementSheet = CSSStyleSheet::createInline(*this, m_baseURL);
</span><span class="cx">         // FIXME: So we are not really the parser. The right fix is to eliminate the element sheet completely.
</span><del>-        if (usesRemUnits)
-            m_elementSheet-&gt;contents().parserSetUsesRemUnits();
</del><span class="cx">         if (usesStyleBasedEditability)
</span><span class="cx">             m_elementSheet-&gt;contents().parserSetUsesStyleBasedEditability();
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCorestyleStyleTreeResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/StyleTreeResolver.cpp (206640 => 206641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleTreeResolver.cpp        2016-09-30 16:59:24 UTC (rev 206640)
+++ trunk/Source/WebCore/style/StyleTreeResolver.cpp        2016-09-30 17:00:22 UTC (rev 206641)
</span><span class="lines">@@ -214,10 +214,9 @@
</span><span class="cx">         m_documentElementStyle = RenderStyle::clonePtr(*update.style);
</span><span class="cx">         scope().styleResolver.setOverrideDocumentElementStyle(m_documentElementStyle.get());
</span><span class="cx"> 
</span><del>-        // If &quot;rem&quot; units are used anywhere in the document, and if the document element's font size changes, then force font updating
-        // all the way down the tree. This is simpler than having to maintain a cache of objects (and such font size changes should be rare anyway).
-        if (m_document.authorStyleSheets().usesRemUnits() &amp;&amp; update.change != NoChange &amp;&amp; existingStyle &amp;&amp; existingStyle-&gt;fontSize() != update.style-&gt;fontSize()) {
-            // Cached RenderStyles may depend on the rem units.
</del><ins>+        if (update.change != NoChange &amp;&amp; existingStyle &amp;&amp; existingStyle-&gt;fontSize() != update.style-&gt;fontSize()) {
+            // &quot;rem&quot; units are relative to the document element's font size so we need to recompute everything.
+            // In practice this is rare.
</ins><span class="cx">             scope().styleResolver.invalidateMatchedPropertiesCache();
</span><span class="cx">             update.change = Force;
</span><span class="cx">         }
</span></span></pre>
</div>
</div>

</body>
</html>