No subject


Mon Jan 28 08:41:14 PST 2013


3700">r153700</a> by &lt;ager at chromium.org&gt;:

In my measurements the mapping is adding more overhead than just having a=
 field
in all MutableStylePropertySet objects. So this saves memory and makes ac=
cess
faster.

* css/StylePropertySet.cpp:
(WebCore::MutableStylePropertySet::MutableStylePropertySet):
(WebCore::MutableStylePropertySet::~MutableStylePropertySet):
(WebCore::StylePropertySet::hasCSSOMWrapper):
(WebCore::MutableStylePropertySet::cssStyleDeclaration):
(WebCore::MutableStylePropertySet::ensureCSSStyleDeclaration):
(WebCore::MutableStylePropertySet::ensureInlineCSSStyleDeclaration):
* css/StylePropertySet.h:
(WebCore::StylePropertySet::StylePropertySet):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href=3D"#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeL=
og</a></li>
<li><a href=3D"#trunkSourceWebCorecssStylePropertySetcpp">trunk/Source/We=
bCore/css/StylePropertySet.cpp</a></li>
<li><a href=3D"#trunkSourceWebCorecssStylePropertySeth">trunk/Source/WebC=
ore/css/StylePropertySet.h</a></li>
</ul>

</div>
<div id=3D"patch">
<h3>Diff</h3>
<a id=3D"trunkSourceWebCoreChangeLog"></a>
<div class=3D"modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (1529=
34 =3D> 152935)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/Source/WebCore/ChangeLog	2013-07-20 00:11:=
32 UTC (rev 152934)
+++ trunk/Source/WebCore/ChangeLog	2013-07-20 00:58:36 UTC (rev 152935)
</span><span class=3D"lines">@@ -1,3 +1,27 @@
</span><ins>+2013-07-19  Andreas Kling  &lt;akling at apple.com&gt;
+
+        Cache style declaration CSSOM wrappers directly on MutableStyleP=
ropertySet.
+        &lt;http://webkit.org/b/118883&gt;
+
+        Reviewed by Gavin Barraclough
+
+        Merge https://chromium.googlesource.com/chromium/blink/+/183bcd5=
1eb0e79cab930cf46695df05dc793630f
+        From Blink r153700 by &lt;ager at chromium.org&gt;:
+
+        In my measurements the mapping is adding more overhead than just=
 having a field
+        in all MutableStylePropertySet objects. So this saves memory and=
 makes access
+        faster.
+
+        * css/StylePropertySet.cpp:
+        (WebCore::MutableStylePropertySet::MutableStylePropertySet):
+        (WebCore::MutableStylePropertySet::~MutableStylePropertySet):
+        (WebCore::StylePropertySet::hasCSSOMWrapper):
+        (WebCore::MutableStylePropertySet::cssStyleDeclaration):
+        (WebCore::MutableStylePropertySet::ensureCSSStyleDeclaration):
+        (WebCore::MutableStylePropertySet::ensureInlineCSSStyleDeclarati=
on):
+        * css/StylePropertySet.h:
+        (WebCore::StylePropertySet::StylePropertySet):
+
</ins><span class=3D"cx"> 2013-07-19  Brent Fulgham  &lt;bfulgham at apple.c=
om&gt;
</span><span class=3D"cx">=20
</span><span class=3D"cx">         [Windows] Avoid passing addresses of t=
emporaries to Windows API.
</span></span></pre></div>
<a id=3D"trunkSourceWebCorecssStylePropertySetcpp"></a>
<div class=3D"modfile"><h4>Modified: trunk/Source/WebCore/css/StyleProper=
tySet.cpp (152934 =3D> 152935)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/Source/WebCore/css/StylePropertySet.cpp	20=
13-07-20 00:11:32 UTC (rev 152934)
+++ trunk/Source/WebCore/css/StylePropertySet.cpp	2013-07-20 00:58:36 UTC=
 (rev 152935)
</span><span class=3D"lines">@@ -48,13 +48,6 @@
</span><span class=3D"cx">=20
</span><span class=3D"cx"> namespace WebCore {
</span><span class=3D"cx">=20
</span><del>-typedef HashMap&lt;MutableStylePropertySet*, OwnPtr&lt;Prope=
rtySetCSSStyleDeclaration&gt; &gt; PropertySetCSSOMWrapperMap;
-static PropertySetCSSOMWrapperMap&amp; propertySetCSSOMWrapperMap()
-{
-    DEFINE_STATIC_LOCAL(PropertySetCSSOMWrapperMap, propertySetCSSOMWrap=
perMapInstance, ());
-    return propertySetCSSOMWrapperMapInstance;
-}
-
</del><span class=3D"cx"> static size_t sizeForImmutableStylePropertySetW=
ithPropertyCount(unsigned count)
</span><span class=3D"cx"> {
</span><span class=3D"cx">     return sizeof(ImmutableStylePropertySet) -=
 sizeof(void*) + sizeof(CSSValue*) * count + sizeof(StylePropertyMetadata=
) * count;
</span><span class=3D"lines">@@ -81,6 +74,11 @@
</span><span class=3D"cx">     return ImmutableStylePropertySet::create(m=
utableThis-&gt;m_propertyVector.data(), mutableThis-&gt;m_propertyVector.=
size(), cssParserMode());
</span><span class=3D"cx"> }
</span><span class=3D"cx">=20
</span><ins>+MutableStylePropertySet::MutableStylePropertySet(CSSParserMo=
de cssParserMode)
+    : StylePropertySet(cssParserMode)
+{
+}
+
</ins><span class=3D"cx"> MutableStylePropertySet::MutableStylePropertySe=
t(const CSSProperty* properties, unsigned length)
</span><span class=3D"cx">     : StylePropertySet(CSSStrictMode)
</span><span class=3D"cx"> {
</span><span class=3D"lines">@@ -89,6 +87,10 @@
</span><span class=3D"cx">         m_propertyVector.uncheckedAppend(prope=
rties[i]);
</span><span class=3D"cx"> }
</span><span class=3D"cx">=20
</span><ins>+MutableStylePropertySet::~MutableStylePropertySet()
+{
+}
+
</ins><span class=3D"cx"> ImmutableStylePropertySet::ImmutableStyleProper=
tySet(const CSSProperty* properties, unsigned length, CSSParserMode cssPa=
rserMode)
</span><span class=3D"cx">     : StylePropertySet(cssParserMode, length)
</span><span class=3D"cx"> {
</span><span class=3D"lines">@@ -120,13 +122,6 @@
</span><span class=3D"cx">     }
</span><span class=3D"cx"> }
</span><span class=3D"cx">=20
</span><del>-MutableStylePropertySet::~MutableStylePropertySet()
-{
-    ASSERT(!m_ownsCSSOMWrapper || propertySetCSSOMWrapperMap().contains(=
this));
-    if (m_ownsCSSOMWrapper)
-        propertySetCSSOMWrapperMap().remove(this);
-}
-
</del><span class=3D"cx"> String StylePropertySet::getPropertyValue(CSSPr=
opertyID propertyID) const
</span><span class=3D"cx"> {
</span><span class=3D"cx">     RefPtr&lt;CSSValue&gt; value =3D getProper=
tyCSSValue(propertyID);
</span><span class=3D"lines">@@ -1023,6 +1018,11 @@
</span><span class=3D"cx">     return result.toString();
</span><span class=3D"cx"> }
</span><span class=3D"cx">=20
</span><ins>+bool StylePropertySet::hasCSSOMWrapper() const
+{
+    return m_isMutable &amp;&amp; static_cast&lt;const MutableStylePrope=
rtySet*&gt;(this)-&gt;m_cssomWrapper;
+}
+
</ins><span class=3D"cx"> void MutableStylePropertySet::mergeAndOverrideO=
nConflict(const StylePropertySet* other)
</span><span class=3D"cx"> {
</span><span class=3D"cx">     unsigned size =3D other-&gt;propertyCount(=
);
</span><span class=3D"lines">@@ -1197,34 +1197,28 @@
</span><span class=3D"cx">=20
</span><span class=3D"cx"> PropertySetCSSStyleDeclaration* MutableStylePr=
opertySet::cssStyleDeclaration()
</span><span class=3D"cx"> {
</span><del>-    if (!m_ownsCSSOMWrapper)
-        return 0;
-    return propertySetCSSOMWrapperMap().get(this);
</del><ins>+    return m_cssomWrapper.get();
</ins><span class=3D"cx"> }
</span><span class=3D"cx">=20
</span><span class=3D"cx"> CSSStyleDeclaration* MutableStylePropertySet::=
ensureCSSStyleDeclaration()
</span><span class=3D"cx"> {
</span><del>-    if (m_ownsCSSOMWrapper) {
-        ASSERT(!static_cast&lt;CSSStyleDeclaration*&gt;(propertySetCSSOM=
WrapperMap().get(this))-&gt;parentRule());
-        ASSERT(!propertySetCSSOMWrapperMap().get(this)-&gt;parentElement=
());
-        return propertySetCSSOMWrapperMap().get(this);
</del><ins>+    if (m_cssomWrapper) {
+        ASSERT(!static_cast&lt;CSSStyleDeclaration*&gt;(m_cssomWrapper.g=
et())-&gt;parentRule());
+        ASSERT(!m_cssomWrapper-&gt;parentElement());
+        return m_cssomWrapper.get();
</ins><span class=3D"cx">     }
</span><del>-    m_ownsCSSOMWrapper =3D true;
-    PropertySetCSSStyleDeclaration* cssomWrapper =3D new PropertySetCSSS=
tyleDeclaration(this);
-    propertySetCSSOMWrapperMap().add(this, adoptPtr(cssomWrapper));
-    return cssomWrapper;
</del><ins>+    m_cssomWrapper =3D adoptPtr(new PropertySetCSSStyleDeclar=
ation(this));
+    return m_cssomWrapper.get();
</ins><span class=3D"cx"> }
</span><span class=3D"cx">=20
</span><span class=3D"cx"> CSSStyleDeclaration* MutableStylePropertySet::=
ensureInlineCSSStyleDeclaration(StyledElement* parentElement)
</span><span class=3D"cx"> {
</span><del>-    if (m_ownsCSSOMWrapper) {
-        ASSERT(propertySetCSSOMWrapperMap().get(this)-&gt;parentElement(=
) =3D=3D parentElement);
-        return propertySetCSSOMWrapperMap().get(this);
</del><ins>+    if (m_cssomWrapper) {
+        ASSERT(m_cssomWrapper-&gt;parentElement() =3D=3D parentElement);
+        return m_cssomWrapper.get();
</ins><span class=3D"cx">     }
</span><del>-    m_ownsCSSOMWrapper =3D true;
-    PropertySetCSSStyleDeclaration* cssomWrapper =3D new InlineCSSStyleD=
eclaration(this, parentElement);
-    propertySetCSSOMWrapperMap().add(this, adoptPtr(cssomWrapper));
-    return cssomWrapper;
</del><ins>+    m_cssomWrapper =3D adoptPtr(new InlineCSSStyleDeclaration=
(this, parentElement));
+    return m_cssomWrapper.get();
</ins><span class=3D"cx"> }
</span><span class=3D"cx">=20
</span><span class=3D"cx"> unsigned StylePropertySet::averageSizeInBytes(=
)
</span></span></pre></div>
<a id=3D"trunkSourceWebCorecssStylePropertySeth"></a>
<div class=3D"modfile"><h4>Modified: trunk/Source/WebCore/css/StyleProper=
tySet.h (152934 =3D> 152935)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/Source/WebCore/css/StylePropertySet.h	2013=
-07-20 00:11:32 UTC (rev 152934)
+++ trunk/Source/WebCore/css/StylePropertySet.h	2013-07-20 00:58:36 UTC (=
rev 152935)
</span><span class=3D"lines">@@ -107,7 +107,7 @@
</span><span class=3D"cx">     String asText() const;
</span><span class=3D"cx">=20
</span><span class=3D"cx">     bool isMutable() const { return m_isMutabl=
e; }
</span><del>-    bool hasCSSOMWrapper() const { return m_ownsCSSOMWrapper=
; }
</del><ins>+    bool hasCSSOMWrapper() const;
</ins><span class=3D"cx">=20
</span><span class=3D"cx">     bool hasFailedOrCanceledSubresources() con=
st;
</span><span class=3D"cx">=20
</span><span class=3D"lines">@@ -122,14 +122,12 @@
</span><span class=3D"cx"> protected:
</span><span class=3D"cx">     StylePropertySet(CSSParserMode cssParserMo=
de)
</span><span class=3D"cx">         : m_cssParserMode(cssParserMode)
</span><del>-        , m_ownsCSSOMWrapper(false)
</del><span class=3D"cx">         , m_isMutable(true)
</span><span class=3D"cx">         , m_arraySize(0)
</span><span class=3D"cx">     { }
</span><span class=3D"cx">=20
</span><span class=3D"cx">     StylePropertySet(CSSParserMode cssParserMo=
de, unsigned immutableArraySize)
</span><span class=3D"cx">         : m_cssParserMode(cssParserMode)
</span><del>-        , m_ownsCSSOMWrapper(false)
</del><span class=3D"cx">         , m_isMutable(false)
</span><span class=3D"cx">         , m_arraySize(immutableArraySize)
</span><span class=3D"cx">     { }
</span><span class=3D"lines">@@ -137,9 +135,8 @@
</span><span class=3D"cx">     int findPropertyIndex(CSSPropertyID) const=
;
</span><span class=3D"cx">=20
</span><span class=3D"cx">     unsigned m_cssParserMode : 2;
</span><del>-    mutable unsigned m_ownsCSSOMWrapper : 1;
</del><span class=3D"cx">     mutable unsigned m_isMutable : 1;
</span><del>-    unsigned m_arraySize : 28;
</del><ins>+    unsigned m_arraySize : 29;
</ins><span class=3D"cx">    =20
</span><span class=3D"cx"> private:
</span><span class=3D"cx">     String getShorthandValue(const StyleProper=
tyShorthand&amp;) const;
</span><span class=3D"lines">@@ -183,12 +180,10 @@
</span><span class=3D"cx">=20
</span><span class=3D"cx"> class MutableStylePropertySet : public StylePr=
opertySet {
</span><span class=3D"cx"> public:
</span><del>-    ~MutableStylePropertySet();
-
</del><span class=3D"cx">     static PassRefPtr&lt;MutableStylePropertySe=
t&gt; create(CSSParserMode =3D CSSQuirksMode);
</span><span class=3D"cx">     static PassRefPtr&lt;MutableStylePropertyS=
et&gt; create(const CSSProperty* properties, unsigned count);
</span><span class=3D"cx">=20
</span><del>-    MutableStylePropertySet(const StylePropertySet&amp;);
</del><ins>+    ~MutableStylePropertySet();
</ins><span class=3D"cx">=20
</span><span class=3D"cx">     unsigned propertyCount() const { return m_=
propertyVector.size(); }
</span><span class=3D"cx">=20
</span><span class=3D"lines">@@ -228,14 +223,15 @@
</span><span class=3D"cx">     Vector&lt;CSSProperty, 4&gt; m_propertyVec=
tor;
</span><span class=3D"cx">=20
</span><span class=3D"cx"> private:
</span><del>-    MutableStylePropertySet(CSSParserMode cssParserMode)
-        : StylePropertySet(cssParserMode)
-    { }
-
</del><ins>+    explicit MutableStylePropertySet(CSSParserMode);
+    explicit MutableStylePropertySet(const StylePropertySet&amp;);
</ins><span class=3D"cx">     MutableStylePropertySet(const CSSProperty* =
properties, unsigned count);
</span><span class=3D"cx">=20
</span><span class=3D"cx">     bool removeShorthandProperty(CSSPropertyID=
);
</span><span class=3D"cx">     CSSProperty* findCSSPropertyWithID(CSSProp=
ertyID);
</span><ins>+    OwnPtr&lt;PropertySetCSSStyleDeclaration&gt; m_cssomWrap=
per;
+
+    friend class StylePropertySet;
</ins><span class=3D"cx"> };
</span><span class=3D"cx">=20
</span><span class=3D"cx"> inline StylePropertyMetadata StylePropertySet:=
:PropertyReference::propertyMetadata() const
</span></span></pre>
</div>
</div>

</body>
</html>


More information about the webkit-changes mailing list