<!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>[210826] 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/210826">210826</a></dd>
<dt>Author</dt> <dd>akling@apple.com</dd>
<dt>Date</dt> <dd>2017-01-17 15:24:46 -0800 (Tue, 17 Jan 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Kill the presentation attribute cache.
&lt;https://webkit.org/b/119542&gt;

Reviewed by Antti Koivisto.

This cache was added to placate some old page cycler test that was measuring load times
on pages captured in 2000. That content is not super relevant anymore, and I think
we can live without this cache.

* dom/StyledElement.cpp:
(WebCore::StyledElement::rebuildPresentationAttributeStyle):
(WebCore::presentationAttributeCache): Deleted.
(WebCore::PresentationAttributeCacheCleaner::PresentationAttributeCacheCleaner): Deleted.
(WebCore::PresentationAttributeCacheCleaner::didHitPresentationAttributeCache): Deleted.
(WebCore::PresentationAttributeCacheCleaner::cleanCache): Deleted.
(WebCore::presentationAttributeCacheCleaner): Deleted.
(WebCore::StyledElement::clearPresentationAttributeCache): Deleted.
(WebCore::attributeNameSort): Deleted.
(WebCore::StyledElement::makePresentationAttributeCacheKey): Deleted.
(WebCore::computePresentationAttributeCacheHash): Deleted.
* dom/StyledElement.h:
* page/MemoryRelease.cpp:
(WebCore::releaseNoncriticalMemory):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomStyledElementcpp">trunk/Source/WebCore/dom/StyledElement.cpp</a></li>
<li><a href="#trunkSourceWebCoredomStyledElementh">trunk/Source/WebCore/dom/StyledElement.h</a></li>
<li><a href="#trunkSourceWebCorepageMemoryReleasecpp">trunk/Source/WebCore/page/MemoryRelease.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (210825 => 210826)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-17 20:57:53 UTC (rev 210825)
+++ trunk/Source/WebCore/ChangeLog        2017-01-17 23:24:46 UTC (rev 210826)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2017-01-17  Andreas Kling  &lt;akling@apple.com&gt;
+
+        Kill the presentation attribute cache.
+        &lt;https://webkit.org/b/119542&gt;
+
+        Reviewed by Antti Koivisto.
+
+        This cache was added to placate some old page cycler test that was measuring load times
+        on pages captured in 2000. That content is not super relevant anymore, and I think
+        we can live without this cache.
+
+        * dom/StyledElement.cpp:
+        (WebCore::StyledElement::rebuildPresentationAttributeStyle):
+        (WebCore::presentationAttributeCache): Deleted.
+        (WebCore::PresentationAttributeCacheCleaner::PresentationAttributeCacheCleaner): Deleted.
+        (WebCore::PresentationAttributeCacheCleaner::didHitPresentationAttributeCache): Deleted.
+        (WebCore::PresentationAttributeCacheCleaner::cleanCache): Deleted.
+        (WebCore::presentationAttributeCacheCleaner): Deleted.
+        (WebCore::StyledElement::clearPresentationAttributeCache): Deleted.
+        (WebCore::attributeNameSort): Deleted.
+        (WebCore::StyledElement::makePresentationAttributeCacheKey): Deleted.
+        (WebCore::computePresentationAttributeCacheHash): Deleted.
+        * dom/StyledElement.h:
+        * page/MemoryRelease.cpp:
+        (WebCore::releaseNoncriticalMemory):
+
</ins><span class="cx"> 2017-01-17  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, roll out http://trac.webkit.org/changeset/210821
</span></span></pre></div>
<a id="trunkSourceWebCoredomStyledElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/StyledElement.cpp (210825 => 210826)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/StyledElement.cpp        2017-01-17 20:57:53 UTC (rev 210825)
+++ trunk/Source/WebCore/dom/StyledElement.cpp        2017-01-17 23:24:46 UTC (rev 210826)
</span><span class="lines">@@ -46,83 +46,6 @@
</span><span class="cx"> 
</span><span class="cx"> using namespace HTMLNames;
</span><span class="cx"> 
</span><del>-struct PresentationAttributeCacheKey {
-    AtomicStringImpl* tagName { nullptr };
-    // Only the values need refcounting.
-    Vector&lt;std::pair&lt;AtomicStringImpl*, AtomicString&gt;, 3&gt; attributesAndValues;
-};
-
-struct PresentationAttributeCacheEntry {
-    WTF_MAKE_FAST_ALLOCATED;
-public:
-    PresentationAttributeCacheKey key;
-    RefPtr&lt;StyleProperties&gt; value;
-};
-
-typedef HashMap&lt;unsigned, std::unique_ptr&lt;PresentationAttributeCacheEntry&gt;, AlreadyHashed&gt; PresentationAttributeCache;
-    
-static bool operator!=(const PresentationAttributeCacheKey&amp; a, const PresentationAttributeCacheKey&amp; b)
-{
-    if (a.tagName != b.tagName)
-        return true;
-    return a.attributesAndValues != b.attributesAndValues;
-}
-
-static PresentationAttributeCache&amp; presentationAttributeCache()
-{
-    static NeverDestroyed&lt;PresentationAttributeCache&gt; cache;
-    return cache;
-}
-
-class PresentationAttributeCacheCleaner {
-    WTF_MAKE_NONCOPYABLE(PresentationAttributeCacheCleaner); WTF_MAKE_FAST_ALLOCATED;
-public:
-    PresentationAttributeCacheCleaner()
-        : m_hitCount(0)
-        , m_cleanTimer(*this, &amp;PresentationAttributeCacheCleaner::cleanCache)
-    {
-    }
-
-    void didHitPresentationAttributeCache()
-    {
-        if (presentationAttributeCache().size() &lt; minimumPresentationAttributeCacheSizeForCleaning)
-            return;
-
-        m_hitCount++;
-
-        if (!m_cleanTimer.isActive())
-            m_cleanTimer.startOneShot(presentationAttributeCacheCleanTimeInSeconds);
-     }
-
-private:
-    static const unsigned presentationAttributeCacheCleanTimeInSeconds = 60;
-    static const int minimumPresentationAttributeCacheSizeForCleaning = 100;
-    static const unsigned minimumPresentationAttributeCacheHitCountPerMinute = (100 * presentationAttributeCacheCleanTimeInSeconds) / 60;
-
-    void cleanCache()
-    {
-        unsigned hitCount = m_hitCount;
-        m_hitCount = 0;
-        if (hitCount &gt; minimumPresentationAttributeCacheHitCountPerMinute)
-            return;
-        presentationAttributeCache().clear();
-    }
-
-    unsigned m_hitCount;
-    Timer m_cleanTimer;
-};
-
-static PresentationAttributeCacheCleaner&amp; presentationAttributeCacheCleaner()
-{
-    static NeverDestroyed&lt;PresentationAttributeCacheCleaner&gt; cleaner;
-    return cleaner;
-}
-
-void StyledElement::clearPresentationAttributeCache()
-{
-    presentationAttributeCache().clear();
-}
-
</del><span class="cx"> void StyledElement::synchronizeStyleAttributeInternal(StyledElement* styledElement)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(styledElement-&gt;elementData());
</span><span class="lines">@@ -295,92 +218,17 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline bool attributeNameSort(const std::pair&lt;AtomicStringImpl*, AtomicString&gt;&amp; p1, const std::pair&lt;AtomicStringImpl*, AtomicString&gt;&amp; p2)
-{
-    // Sort based on the attribute name pointers. It doesn't matter what the order is as long as it is always the same. 
-    return p1.first &lt; p2.first;
-}
-
-void StyledElement::makePresentationAttributeCacheKey(PresentationAttributeCacheKey&amp; result) const
-{    
-    // FIXME: Enable for SVG.
-    if (namespaceURI() != xhtmlNamespaceURI)
-        return;
-    // Interpretation of the size attributes on &lt;input&gt; depends on the type attribute.
-    if (hasTagName(inputTag))
-        return;
-    for (const Attribute&amp; attribute : attributesIterator()) {
-        if (!isPresentationAttribute(attribute.name()))
-            continue;
-        if (!attribute.namespaceURI().isNull())
-            return;
-        // FIXME: Background URL may depend on the base URL and can't be shared. Disallow caching.
-        if (attribute.name() == backgroundAttr)
-            return;
-        result.attributesAndValues.append(std::make_pair(attribute.localName().impl(), attribute.value()));
-    }
-    if (result.attributesAndValues.isEmpty())
-        return;
-    // Attribute order doesn't matter. Sort for easy equality comparison.
-    std::sort(result.attributesAndValues.begin(), result.attributesAndValues.end(), attributeNameSort);
-    // The cache key is non-null when the tagName is set.
-    result.tagName = localName().impl();
-}
-
-static unsigned computePresentationAttributeCacheHash(const PresentationAttributeCacheKey&amp; key)
-{
-    if (!key.tagName)
-        return 0;
-    ASSERT(key.attributesAndValues.size());
-    unsigned attributeHash = StringHasher::hashMemory(key.attributesAndValues.data(), key.attributesAndValues.size() * sizeof(key.attributesAndValues[0]));
-    return WTF::pairIntHash(key.tagName-&gt;existingHash(), attributeHash);
-}
-
</del><span class="cx"> void StyledElement::rebuildPresentationAttributeStyle()
</span><span class="cx"> {
</span><del>-    PresentationAttributeCacheKey cacheKey;
-    makePresentationAttributeCacheKey(cacheKey);
</del><ins>+    RefPtr&lt;StyleProperties&gt; style = MutableStyleProperties::create(isSVGElement() ? SVGAttributeMode : HTMLQuirksMode);
+    for (const Attribute&amp; attribute : attributesIterator())
+        collectStyleForPresentationAttribute(attribute.name(), attribute.value(), static_cast&lt;MutableStyleProperties&amp;&gt;(*style));
</ins><span class="cx"> 
</span><del>-    unsigned cacheHash = computePresentationAttributeCacheHash(cacheKey);
-
-    PresentationAttributeCache::iterator cacheIterator;
-    if (cacheHash) {
-        cacheIterator = presentationAttributeCache().add(cacheHash, nullptr).iterator;
-        if (cacheIterator-&gt;value &amp;&amp; cacheIterator-&gt;value-&gt;key != cacheKey)
-            cacheHash = 0;
-    } else
-        cacheIterator = presentationAttributeCache().end();
-
-    RefPtr&lt;StyleProperties&gt; style;
-    if (cacheHash &amp;&amp; cacheIterator-&gt;value) {
-        style = cacheIterator-&gt;value-&gt;value;
-        presentationAttributeCacheCleaner().didHitPresentationAttributeCache();
-    } else {
-        style = MutableStyleProperties::create(isSVGElement() ? SVGAttributeMode : HTMLQuirksMode);
-        for (const Attribute&amp; attribute : attributesIterator())
-            collectStyleForPresentationAttribute(attribute.name(), attribute.value(), static_cast&lt;MutableStyleProperties&amp;&gt;(*style));
-    }
-
</del><span class="cx">     // ShareableElementData doesn't store presentation attribute style, so make sure we have a UniqueElementData.
</span><span class="cx">     UniqueElementData&amp; elementData = ensureUniqueElementData();
</span><span class="cx"> 
</span><span class="cx">     elementData.setPresentationAttributeStyleIsDirty(false);
</span><del>-    elementData.m_presentationAttributeStyle = style-&gt;isEmpty() ? nullptr : style;
-
-    if (!cacheHash || cacheIterator-&gt;value)
-        return;
-
-    std::unique_ptr&lt;PresentationAttributeCacheEntry&gt; newEntry = std::make_unique&lt;PresentationAttributeCacheEntry&gt;();
-    newEntry-&gt;key = cacheKey;
-    newEntry-&gt;value = WTFMove(style);
-
-    static const int presentationAttributeCacheMaximumSize = 4096;
-    if (presentationAttributeCache().size() &gt; presentationAttributeCacheMaximumSize) {
-        // Start building from scratch if the cache ever gets big.
-        presentationAttributeCache().clear();
-        presentationAttributeCache().set(cacheHash, WTFMove(newEntry));
-    } else
-        cacheIterator-&gt;value = WTFMove(newEntry);
</del><ins>+    elementData.m_presentationAttributeStyle = style-&gt;isEmpty() ? nullptr : WTFMove(style);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void StyledElement::addPropertyToPresentationAttributeStyle(MutableStyleProperties&amp; style, CSSPropertyID propertyID, CSSValueID identifier)
</span></span></pre></div>
<a id="trunkSourceWebCoredomStyledElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/StyledElement.h (210825 => 210826)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/StyledElement.h        2017-01-17 20:57:53 UTC (rev 210825)
+++ trunk/Source/WebCore/dom/StyledElement.h        2017-01-17 23:24:46 UTC (rev 210826)
</span><span class="lines">@@ -36,8 +36,6 @@
</span><span class="cx"> class PropertySetCSSStyleDeclaration;
</span><span class="cx"> class StyleProperties;
</span><span class="cx"> 
</span><del>-struct PresentationAttributeCacheKey;
-
</del><span class="cx"> class StyledElement : public Element {
</span><span class="cx"> public:
</span><span class="cx">     virtual ~StyledElement();
</span><span class="lines">@@ -62,8 +60,6 @@
</span><span class="cx">     const StyleProperties* presentationAttributeStyle() const;
</span><span class="cx">     virtual void collectStyleForPresentationAttribute(const QualifiedName&amp;, const AtomicString&amp;, MutableStyleProperties&amp;) { }
</span><span class="cx"> 
</span><del>-    static void clearPresentationAttributeCache();
-
</del><span class="cx"> protected:
</span><span class="cx">     StyledElement(const QualifiedName&amp; name, Document&amp; document, ConstructionType type)
</span><span class="cx">         : Element(name, document, type)
</span><span class="lines">@@ -88,7 +84,6 @@
</span><span class="cx">     void setInlineStyleFromString(const AtomicString&amp;);
</span><span class="cx">     MutableStyleProperties&amp; ensureMutableInlineStyle();
</span><span class="cx"> 
</span><del>-    void makePresentationAttributeCacheKey(PresentationAttributeCacheKey&amp;) const;
</del><span class="cx">     void rebuildPresentationAttributeStyle();
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepageMemoryReleasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/MemoryRelease.cpp (210825 => 210826)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/MemoryRelease.cpp        2017-01-17 20:57:53 UTC (rev 210825)
+++ trunk/Source/WebCore/page/MemoryRelease.cpp        2017-01-17 23:24:46 UTC (rev 210826)
</span><span class="lines">@@ -60,8 +60,6 @@
</span><span class="cx"> 
</span><span class="cx">     MemoryCache::singleton().pruneDeadResourcesToSize(0);
</span><span class="cx"> 
</span><del>-    StyledElement::clearPresentationAttributeCache();
-
</del><span class="cx">     InlineStyleSheetOwner::clearCache();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>