Title: [124330] trunk/Source/WebCore
Revision
124330
Author
yu...@chromium.org
Date
2012-08-01 06:29:59 -0700 (Wed, 01 Aug 2012)

Log Message

Web Inspector: add CSSStyleSheet memory instrumentation
https://bugs.webkit.org/show_bug.cgi?id=92748

Reviewed by Antti Koivisto.

Added MemoryInstrumentation for CSSStyleSheet, StyleSheetContents, StyleRule,
CSSSelectorList and StylePropertySet. The coverage is not complete as the
patch was growing too big.

* css/CSSSelectorList.cpp:
(WebCore::CSSSelectorList::CSSSelectorList):
(WebCore::CSSSelectorList::length):
(WebCore):
(WebCore::CSSSelectorList::reportMemoryUsage):
* css/CSSSelectorList.h:
(WebCore):
(CSSSelectorList):
* css/CSSStyleSheet.cpp:
(WebCore::CSSStyleSheet::reportMemoryUsage):
(WebCore):
* css/CSSStyleSheet.h:
(WebCore):
(CSSStyleSheet):
* css/MediaList.cpp:
(WebCore):
(WebCore::MediaQuerySet::reportMemoryUsage):
(WebCore::MediaList::reportMemoryUsage):
* css/MediaList.h:
(WebCore):
(MediaQuerySet):
(MediaList):
* css/MediaQuery.cpp:
(WebCore::MediaQuery::reportMemoryUsage):
(WebCore):
* css/MediaQuery.h:
(WebCore):
(MediaQuery):
* css/MediaQueryExp.cpp:
(WebCore::MediaQueryExp::reportMemoryUsage):
(WebCore):
* css/MediaQueryExp.h:
(WebCore):
(MediaQueryExp):
* css/StylePropertySet.cpp:
(WebCore::StylePropertySet::reportMemoryUsage):
(WebCore):
* css/StylePropertySet.h:
(WebCore):
(StylePropertySet):
* css/StyleRule.cpp:
(WebCore::StyleRuleBase::reportMemoryUsage): We cannot make
reportMemoryUsage virtual as it would add vtable to StyleRuleBase
and its descendants and would blow its memory footprint. This
is why we have a switch over StyleRule type here.
(WebCore):
(WebCore::StyleRule::reportMemoryUsage):
(WebCore::StyleRulePage::reportMemoryUsage):
(WebCore::StyleRuleFontFace::reportMemoryUsage):
(WebCore::StyleRuleBlock::reportMemoryUsage):
(WebCore::StyleRuleMedia::reportMemoryUsage):
(WebCore::StyleRuleRegion::reportMemoryUsage):
* css/StyleRule.h:
(WebCore):
(StyleRuleBase):
(StyleRule):
(StyleRuleFontFace):
(StyleRulePage):
(StyleRuleBlock):
(StyleRuleMedia):
(StyleRuleRegion):
* css/StyleSheetContents.cpp:
(WebCore::StyleSheetContents::reportMemoryUsage):
(WebCore):
* css/StyleSheetContents.h:
(WebCore):
(StyleSheetContents):
* dom/Document.cpp:
(WebCore::Document::reportMemoryUsage):
* dom/MemoryInstrumentation.h:
(WebCore::MemoryClassInfo::addInstrumentedVectorPtr):
(WebCore::MemoryClassInfo::addVectorPtr):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (124329 => 124330)


--- trunk/Source/WebCore/ChangeLog	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/ChangeLog	2012-08-01 13:29:59 UTC (rev 124330)
@@ -1,3 +1,87 @@
+2012-07-31  Yury Semikhatsky  <yu...@chromium.org>
+
+        Web Inspector: add CSSStyleSheet memory instrumentation
+        https://bugs.webkit.org/show_bug.cgi?id=92748
+
+        Reviewed by Antti Koivisto.
+
+        Added MemoryInstrumentation for CSSStyleSheet, StyleSheetContents, StyleRule,
+        CSSSelectorList and StylePropertySet. The coverage is not complete as the
+        patch was growing too big.
+
+        * css/CSSSelectorList.cpp:
+        (WebCore::CSSSelectorList::CSSSelectorList):
+        (WebCore::CSSSelectorList::length):
+        (WebCore):
+        (WebCore::CSSSelectorList::reportMemoryUsage):
+        * css/CSSSelectorList.h:
+        (WebCore):
+        (CSSSelectorList):
+        * css/CSSStyleSheet.cpp:
+        (WebCore::CSSStyleSheet::reportMemoryUsage):
+        (WebCore):
+        * css/CSSStyleSheet.h:
+        (WebCore):
+        (CSSStyleSheet):
+        * css/MediaList.cpp:
+        (WebCore):
+        (WebCore::MediaQuerySet::reportMemoryUsage):
+        (WebCore::MediaList::reportMemoryUsage):
+        * css/MediaList.h:
+        (WebCore):
+        (MediaQuerySet):
+        (MediaList):
+        * css/MediaQuery.cpp:
+        (WebCore::MediaQuery::reportMemoryUsage):
+        (WebCore):
+        * css/MediaQuery.h:
+        (WebCore):
+        (MediaQuery):
+        * css/MediaQueryExp.cpp:
+        (WebCore::MediaQueryExp::reportMemoryUsage):
+        (WebCore):
+        * css/MediaQueryExp.h:
+        (WebCore):
+        (MediaQueryExp):
+        * css/StylePropertySet.cpp:
+        (WebCore::StylePropertySet::reportMemoryUsage):
+        (WebCore):
+        * css/StylePropertySet.h:
+        (WebCore):
+        (StylePropertySet):
+        * css/StyleRule.cpp:
+        (WebCore::StyleRuleBase::reportMemoryUsage): We cannot make
+        reportMemoryUsage virtual as it would add vtable to StyleRuleBase
+        and its descendants and would blow its memory footprint. This
+        is why we have a switch over StyleRule type here.
+        (WebCore):
+        (WebCore::StyleRule::reportMemoryUsage):
+        (WebCore::StyleRulePage::reportMemoryUsage):
+        (WebCore::StyleRuleFontFace::reportMemoryUsage):
+        (WebCore::StyleRuleBlock::reportMemoryUsage):
+        (WebCore::StyleRuleMedia::reportMemoryUsage):
+        (WebCore::StyleRuleRegion::reportMemoryUsage):
+        * css/StyleRule.h:
+        (WebCore):
+        (StyleRuleBase):
+        (StyleRule):
+        (StyleRuleFontFace):
+        (StyleRulePage):
+        (StyleRuleBlock):
+        (StyleRuleMedia):
+        (StyleRuleRegion):
+        * css/StyleSheetContents.cpp:
+        (WebCore::StyleSheetContents::reportMemoryUsage):
+        (WebCore):
+        * css/StyleSheetContents.h:
+        (WebCore):
+        (StyleSheetContents):
+        * dom/Document.cpp:
+        (WebCore::Document::reportMemoryUsage):
+        * dom/MemoryInstrumentation.h:
+        (WebCore::MemoryClassInfo::addInstrumentedVectorPtr):
+        (WebCore::MemoryClassInfo::addVectorPtr):
+
 2012-08-01  Keishi Hattori  <kei...@webkit.org>
 
         Attempt to fix flakiness of color-suggestion-picker-appearance.html

Modified: trunk/Source/WebCore/css/CSSSelectorList.cpp (124329 => 124330)


--- trunk/Source/WebCore/css/CSSSelectorList.cpp	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/CSSSelectorList.cpp	2012-08-01 13:29:59 UTC (rev 124330)
@@ -28,6 +28,7 @@
 #include "CSSSelectorList.h"
 
 #include "CSSParserValues.h"
+#include "MemoryInstrumentation.h"
 #include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
@@ -39,10 +40,7 @@
 
 CSSSelectorList::CSSSelectorList(const CSSSelectorList& o)
 {
-    CSSSelector* current = o.m_selectorArray;
-    while (!current->isLastInSelectorList())
-        ++current;
-    unsigned length = (current - o.m_selectorArray) + 1;
+    unsigned length = o.length();
     if (length == 1) {
         // Destructor expects a single selector to be allocated by new, multiple with fastMalloc.
         m_selectorArray = new CSSSelector(o.m_selectorArray[0]);
@@ -97,6 +95,16 @@
     selectorVector.shrink(0);
 }
 
+unsigned CSSSelectorList::length() const
+{
+    if (!m_selectorArray)
+        return 0;
+    CSSSelector* current = m_selectorArray;
+    while (!current->isLastInSelectorList())
+        ++current;
+    return (current - m_selectorArray) + 1;
+}
+
 void CSSSelectorList::deleteSelectors()
 {
     if (!m_selectorArray)
@@ -135,6 +143,12 @@
     return result.toString();
 }
 
+void CSSSelectorList::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSSelectorList> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addRawBuffer(m_selectorArray, length() * sizeof(CSSSelector));
+}
+
 template <typename Functor>
 static bool forEachTagSelector(Functor& functor, CSSSelector* selector)
 {

Modified: trunk/Source/WebCore/css/CSSSelectorList.h (124329 => 124330)


--- trunk/Source/WebCore/css/CSSSelectorList.h	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/CSSSelectorList.h	2012-08-01 13:29:59 UTC (rev 124330)
@@ -31,6 +31,7 @@
 namespace WebCore {
 
 class CSSParserSelector;
+class MemoryObjectInfo;
 
 class CSSSelectorList {
     WTF_MAKE_FAST_ALLOCATED;
@@ -52,7 +53,10 @@
 
     String selectorsText() const;
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
+    unsigned length() const;
     void deleteSelectors();
 
     // End of a multipart selector is indicated by m_isLastInTagHistory bit in the last item.

Modified: trunk/Source/WebCore/css/CSSStyleSheet.cpp (124329 => 124330)


--- trunk/Source/WebCore/css/CSSStyleSheet.cpp	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/CSSStyleSheet.cpp	2012-08-01 13:29:59 UTC (rev 124330)
@@ -32,6 +32,7 @@
 #include "ExceptionCode.h"
 #include "HTMLNames.h"
 #include "MediaList.h"
+#include "MemoryInstrumentation.h"
 #include "Node.h"
 #include "SVGNames.h"
 #include "SecurityOrigin.h"
@@ -168,6 +169,16 @@
     }
 }
 
+void CSSStyleSheet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSStyleSheet> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addInstrumentedMember(m_contents);
+    info.addString(m_title);
+    info.addInstrumentedMember(m_mediaQueries);
+    info.addInstrumentedMember(m_ownerNode);
+    info.addInstrumentedMember(m_mediaCSSOMWrapper);
+}
+
 void CSSStyleSheet::setDisabled(bool disabled)
 { 
     if (disabled == m_isDisabled)

Modified: trunk/Source/WebCore/css/CSSStyleSheet.h (124329 => 124330)


--- trunk/Source/WebCore/css/CSSStyleSheet.h	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/CSSStyleSheet.h	2012-08-01 13:29:59 UTC (rev 124330)
@@ -39,6 +39,7 @@
 class CachedCSSStyleSheet;
 class Document;
 class MediaQuerySet;
+class MemoryObjectInfo;
 class SecurityOrigin;
 class StyleSheetContents;
 
@@ -105,6 +106,8 @@
 
     StyleSheetContents* contents() const { return m_contents.get(); }
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     CSSStyleSheet(PassRefPtr<StyleSheetContents>, CSSImportRule* ownerRule);
     CSSStyleSheet(PassRefPtr<StyleSheetContents>, Node* ownerNode);

Modified: trunk/Source/WebCore/css/MediaList.cpp (124329 => 124330)


--- trunk/Source/WebCore/css/MediaList.cpp	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/MediaList.cpp	2012-08-01 13:29:59 UTC (rev 124330)
@@ -26,6 +26,7 @@
 #include "ExceptionCode.h"
 #include "MediaQuery.h"
 #include "MediaQueryExp.h"
+#include "MemoryInstrumentation.h"
 
 namespace WebCore {
 
@@ -209,6 +210,12 @@
     }
     return text;
 }
+
+void MediaQuerySet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<MediaQuerySet> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addInstrumentedVector(m_queries);
+}
     
 MediaList::MediaList(MediaQuerySet* mediaQueries, CSSStyleSheet* parentSheet)
     : m_mediaQueries(mediaQueries)
@@ -282,4 +289,10 @@
     m_mediaQueries = mediaQueries;
 }
 
+void MediaList::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<MediaList> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addInstrumentedMember(m_mediaQueries);
 }
+
+}

Modified: trunk/Source/WebCore/css/MediaList.h (124329 => 124330)


--- trunk/Source/WebCore/css/MediaList.h	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/MediaList.h	2012-08-01 13:29:59 UTC (rev 124330)
@@ -34,6 +34,7 @@
 class CSSStyleSheet;
 class MediaList;
 class MediaQuery;
+class MemoryObjectInfo;
 
 class MediaQuerySet : public RefCounted<MediaQuerySet> {
 public:
@@ -66,6 +67,8 @@
 
     PassRefPtr<MediaQuerySet> copy() const { return adoptRef(new MediaQuerySet(*this)); }
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     MediaQuerySet();
     MediaQuerySet(const String& mediaQuery, bool fallbackToDescription);
@@ -106,6 +109,8 @@
 
     void reattach(MediaQuerySet*);
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     MediaList();
     MediaList(MediaQuerySet*, CSSStyleSheet* parentSheet);

Modified: trunk/Source/WebCore/css/MediaQuery.cpp (124329 => 124330)


--- trunk/Source/WebCore/css/MediaQuery.cpp	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/MediaQuery.cpp	2012-08-01 13:29:59 UTC (rev 124330)
@@ -30,6 +30,7 @@
 #include "MediaQuery.h"
 
 #include "MediaQueryExp.h"
+#include "MemoryInstrumentation.h"
 #include <wtf/NonCopyingSort.h>
 #include <wtf/text/StringBuilder.h>
 
@@ -133,4 +134,12 @@
     return m_serializationCache;
 }
 
+void MediaQuery::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<MediaQuery> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addString(m_mediaType);
+    info.addInstrumentedVectorPtr(m_expressions);
+    info.addString(m_serializationCache);
+}
+
 } //namespace

Modified: trunk/Source/WebCore/css/MediaQuery.h (124329 => 124330)


--- trunk/Source/WebCore/css/MediaQuery.h	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/MediaQuery.h	2012-08-01 13:29:59 UTC (rev 124330)
@@ -36,6 +36,7 @@
 
 namespace WebCore {
 class MediaQueryExp;
+class MemoryObjectInfo;
 
 class MediaQuery {
     WTF_MAKE_FAST_ALLOCATED;
@@ -58,6 +59,8 @@
 
     PassOwnPtr<MediaQuery> copy() const { return adoptPtr(new MediaQuery(*this)); }
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
  private:
     MediaQuery(const MediaQuery&);
 

Modified: trunk/Source/WebCore/css/MediaQueryExp.cpp (124329 => 124330)


--- trunk/Source/WebCore/css/MediaQueryExp.cpp	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/MediaQueryExp.cpp	2012-08-01 13:29:59 UTC (rev 124330)
@@ -32,6 +32,7 @@
 #include "CSSParser.h"
 #include "CSSPrimitiveValue.h"
 #include "CSSValueList.h"
+#include "MemoryInstrumentation.h"
 #include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
@@ -108,4 +109,11 @@
     return m_serializationCache;
 }
 
+void MediaQueryExp::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<MediaQueryExp> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addString(m_mediaFeature);
+    info.addString(m_serializationCache);
+}
+
 } // namespace

Modified: trunk/Source/WebCore/css/MediaQueryExp.h (124329 => 124330)


--- trunk/Source/WebCore/css/MediaQueryExp.h	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/MediaQueryExp.h	2012-08-01 13:29:59 UTC (rev 124330)
@@ -37,6 +37,7 @@
 
 namespace WebCore {
 class CSSParserValueList;
+class MemoryObjectInfo;
 
 class MediaQueryExp {
     WTF_MAKE_FAST_ALLOCATED;
@@ -72,6 +73,8 @@
 
     PassOwnPtr<MediaQueryExp> copy() const { return adoptPtr(new MediaQueryExp(*this)); }
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     MediaQueryExp(const AtomicString& mediaFeature, CSSParserValueList* values);
 

Modified: trunk/Source/WebCore/css/StylePropertySet.cpp (124329 => 124330)


--- trunk/Source/WebCore/css/StylePropertySet.cpp	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/StylePropertySet.cpp	2012-08-01 13:29:59 UTC (rev 124330)
@@ -1075,6 +1075,15 @@
     return sizeof(StylePropertySet) + sizeof(CSSProperty) * 2;
 }
 
+void StylePropertySet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<StylePropertySet> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    if (m_isMutable)
+        info.addVectorPtr(m_mutablePropertyVector);
+    else
+        info.addRawBuffer(m_properties, m_arraySize * sizeof(CSSProperty));
+}
+
 // See the function above if you need to update this.
 struct SameSizeAsStylePropertySet : public RefCounted<SameSizeAsStylePropertySet> {
     unsigned bitfield;

Modified: trunk/Source/WebCore/css/StylePropertySet.h (124329 => 124330)


--- trunk/Source/WebCore/css/StylePropertySet.h	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/StylePropertySet.h	2012-08-01 13:29:59 UTC (rev 124330)
@@ -25,7 +25,6 @@
 #include "CSSPrimitiveValue.h"
 #include "CSSProperty.h"
 #include "CSSPropertyNames.h"
-#include "MemoryInstrumentation.h"
 #include <wtf/ListHashSet.h>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
@@ -35,6 +34,7 @@
 class CSSRule;
 class CSSStyleDeclaration;
 class KURL;
+class MemoryObjectInfo;
 class PropertySetCSSStyleDeclaration;
 class StyledElement;
 class StylePropertyShorthand;
@@ -111,18 +111,12 @@
     bool isMutable() const { return m_isMutable; }
 
     static unsigned averageSizeInBytes();
+    void reportMemoryUsage(MemoryObjectInfo*) const;
 
 #ifndef NDEBUG
     void showStyle();
 #endif
     
-    void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
-    {
-        MemoryClassInfo<StylePropertySet> info(memoryObjectInfo, this, MemoryInstrumentation::CSS, m_arraySize * sizeof(CSSProperty));
-        if (m_isMutable)
-            info.addMember(m_mutablePropertyVector);
-    }
-
 private:
     StylePropertySet(CSSParserMode);
     StylePropertySet(const CSSProperty* properties, unsigned count, CSSParserMode, bool makeMutable);

Modified: trunk/Source/WebCore/css/StyleRule.cpp (124329 => 124330)


--- trunk/Source/WebCore/css/StyleRule.cpp	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/StyleRule.cpp	2012-08-01 13:29:59 UTC (rev 124330)
@@ -28,6 +28,7 @@
 #include "CSSMediaRule.h"
 #include "CSSPageRule.h"
 #include "CSSStyleRule.h"
+#include "MemoryInstrumentation.h"
 #include "StyleRuleImport.h"
 #include "WebKitCSSKeyframeRule.h"
 #include "WebKitCSSKeyframesRule.h"
@@ -51,6 +52,41 @@
     return createCSSOMWrapper(0, parentRule);
 }
 
+void StyleRuleBase::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    switch (type()) {
+    case Style:
+        static_cast<const StyleRule*>(this)->reportMemoryUsage(memoryObjectInfo);
+        return;
+    case Page:
+        static_cast<const StyleRulePage*>(this)->reportMemoryUsage(memoryObjectInfo);
+        return;
+    case FontFace:
+        static_cast<const StyleRuleFontFace*>(this)->reportMemoryUsage(memoryObjectInfo);
+        return;
+    case Media:
+        static_cast<const StyleRuleMedia*>(this)->reportMemoryUsage(memoryObjectInfo);
+        return;
+#if ENABLE(CSS_REGIONS)
+    case Region:
+        static_cast<const StyleRuleRegion*>(this)->reportMemoryUsage(memoryObjectInfo);
+        return;
+#endif
+    case Import:
+        static_cast<const StyleRuleImport*>(this)->reportMemoryUsage(memoryObjectInfo);
+        return;
+    case Keyframes:
+        static_cast<const StyleRuleKeyframes*>(this)->reportMemoryUsage(memoryObjectInfo);
+        return;
+    case Unknown:
+    case Charset:
+    case Keyframe:
+        MemoryClassInfo<StyleRuleBase> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+        return;
+    }
+    ASSERT_NOT_REACHED();
+}
+
 void StyleRuleBase::destroy()
 {
     switch (type()) {
@@ -170,6 +206,13 @@
     return sizeof(StyleRule) + StylePropertySet::averageSizeInBytes();
 }
 
+void StyleRule::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<StyleRule> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addInstrumentedMember(m_properties);
+    info.addInstrumentedMember(m_selectorList);
+}
+
 StyleRule::StyleRule(int sourceLine)
     : StyleRuleBase(Style, sourceLine)
 {
@@ -226,6 +269,13 @@
     m_properties = properties;
 }
 
+void StyleRulePage::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<StyleRulePage> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addInstrumentedMember(m_properties);
+    info.addInstrumentedMember(m_selectorList);
+}
+
 StyleRuleFontFace::StyleRuleFontFace()
     : StyleRuleBase(FontFace, 0)
 {
@@ -253,6 +303,13 @@
     m_properties = properties;
 }
 
+void StyleRuleFontFace::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<StyleRuleFontFace> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addInstrumentedMember(m_properties);
+}
+
+
 StyleRuleBlock::StyleRuleBlock(Type type, Vector<RefPtr<StyleRuleBase> >& adoptRule)
     : StyleRuleBase(type, 0)
 {
@@ -277,6 +334,12 @@
     m_childRules.remove(index);
 }
 
+void StyleRuleBlock::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<StyleRuleBlock> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addInstrumentedVector(m_childRules);
+}
+
 StyleRuleMedia::StyleRuleMedia(PassRefPtr<MediaQuerySet> media, Vector<RefPtr<StyleRuleBase> >& adoptRules)
     : StyleRuleBlock(Media, adoptRules)
     , m_mediaQueries(media)
@@ -290,6 +353,12 @@
         m_mediaQueries = o.m_mediaQueries->copy();
 }
 
+void StyleRuleMedia::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<StyleRuleMedia> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addInstrumentedMember(m_mediaQueries);
+}
+
 StyleRuleRegion::StyleRuleRegion(Vector<OwnPtr<CSSParserSelector> >* selectors, Vector<RefPtr<StyleRuleBase> >& adoptRules)
     : StyleRuleBlock(Region, adoptRules)
 {
@@ -302,4 +371,10 @@
 {
 }
 
+void StyleRuleRegion::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<StyleRuleRegion> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addInstrumentedMember(m_selectorList);
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/css/StyleRule.h (124329 => 124330)


--- trunk/Source/WebCore/css/StyleRule.h	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/StyleRule.h	2012-08-01 13:29:59 UTC (rev 124330)
@@ -31,6 +31,7 @@
 class CSSRule;
 class CSSStyleRule;
 class CSSStyleSheet;
+class MemoryObjectInfo;
 class StylePropertySet;
 
 class StyleRuleBase : public WTF::RefCountedBase {
@@ -72,6 +73,8 @@
     PassRefPtr<CSSRule> createCSSOMWrapper(CSSStyleSheet* parentSheet = 0) const;
     PassRefPtr<CSSRule> createCSSOMWrapper(CSSRule* parentRule) const;
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 protected:
     StyleRuleBase(Type type, signed sourceLine = 0) : m_type(type), m_sourceLine(sourceLine) { }
     StyleRuleBase(const StyleRuleBase& o) : WTF::RefCountedBase(), m_type(o.m_type), m_sourceLine(o.m_sourceLine) { }
@@ -104,6 +107,7 @@
     PassRefPtr<StyleRule> copy() const { return adoptRef(new StyleRule(*this)); }
 
     static unsigned averageSizeInBytes();
+    void reportMemoryUsage(MemoryObjectInfo*) const;
 
 private:
     StyleRule(int sourceLine);
@@ -126,6 +130,8 @@
 
     PassRefPtr<StyleRuleFontFace> copy() const { return adoptRef(new StyleRuleFontFace(*this)); }
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     StyleRuleFontFace();
     StyleRuleFontFace(const StyleRuleFontFace&);
@@ -149,6 +155,8 @@
 
     PassRefPtr<StyleRulePage> copy() const { return adoptRef(new StyleRulePage(*this)); }
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     StyleRulePage();
     StyleRulePage(const StyleRulePage&);
@@ -163,6 +171,8 @@
     
     void wrapperInsertRule(unsigned, PassRefPtr<StyleRuleBase>);
     void wrapperRemoveRule(unsigned);
+
+    void reportMemoryUsage(MemoryObjectInfo*) const;
     
 protected:
     StyleRuleBlock(Type, Vector<RefPtr<StyleRuleBase> >& adoptRule);
@@ -183,6 +193,8 @@
 
     PassRefPtr<StyleRuleMedia> copy() const { return adoptRef(new StyleRuleMedia(*this)); }
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     StyleRuleMedia(PassRefPtr<MediaQuerySet>, Vector<RefPtr<StyleRuleBase> >& adoptRules);
     StyleRuleMedia(const StyleRuleMedia&);
@@ -201,6 +213,8 @@
 
     PassRefPtr<StyleRuleRegion> copy() const { return adoptRef(new StyleRuleRegion(*this)); }
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     StyleRuleRegion(Vector<OwnPtr<CSSParserSelector> >*, Vector<RefPtr<StyleRuleBase> >& adoptRules);
     StyleRuleRegion(const StyleRuleRegion&);

Modified: trunk/Source/WebCore/css/StyleRuleImport.cpp (124329 => 124330)


--- trunk/Source/WebCore/css/StyleRuleImport.cpp	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/StyleRuleImport.cpp	2012-08-01 13:29:59 UTC (rev 124330)
@@ -128,4 +128,12 @@
     }
 }
 
+void StyleRuleImport::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<StyleRuleImport> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addString(m_strHref);
+    info.addInstrumentedMember(m_mediaQueries);
+    info.addInstrumentedMember(m_styleSheet);
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/css/StyleRuleImport.h (124329 => 124330)


--- trunk/Source/WebCore/css/StyleRuleImport.h	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/StyleRuleImport.h	2012-08-01 13:29:59 UTC (rev 124330)
@@ -30,6 +30,7 @@
 
 class CachedCSSStyleSheet;
 class MediaQuerySet;
+class MemoryObjectInfo;
 class StyleSheetContents;
 
 class StyleRuleImport : public StyleRuleBase {
@@ -50,6 +51,8 @@
 
     void requestStyleSheet();
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     // NOTE: We put the CachedStyleSheetClient in a member instead of inheriting from it
     // to avoid adding a vptr to StyleRuleImport.

Modified: trunk/Source/WebCore/css/StyleSheetContents.cpp (124329 => 124330)


--- trunk/Source/WebCore/css/StyleSheetContents.cpp	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/StyleSheetContents.cpp	2012-08-01 13:29:59 UTC (rev 124330)
@@ -26,6 +26,7 @@
 #include "CSSStyleSheet.h"
 #include "CachedCSSStyleSheet.h"
 #include "Document.h"
+#include "MemoryInstrumentation.h"
 #include "Node.h"
 #include "SecurityOrigin.h"
 #include "StylePropertySet.h"
@@ -441,4 +442,15 @@
     m_isInMemoryCache = false;
 }
 
+void StyleSheetContents::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<StyleSheetContents> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addString(m_originalURL);
+    info.addString(m_encodingFromCharsetRule);
+    info.addVector(m_importRules);
+    info.addInstrumentedVector(m_childRules);
+    info.addHashMap(m_namespaces);
+    info.addVector(m_clients);
 }
+
+}

Modified: trunk/Source/WebCore/css/StyleSheetContents.h (124329 => 124330)


--- trunk/Source/WebCore/css/StyleSheetContents.h	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/StyleSheetContents.h	2012-08-01 13:29:59 UTC (rev 124330)
@@ -34,6 +34,7 @@
 class CSSStyleSheet;
 class CachedCSSStyleSheet;
 class Document;
+class MemoryObjectInfo;
 class Node;
 class SecurityOrigin;
 class StyleRuleBase;
@@ -137,6 +138,8 @@
     void addedToMemoryCache();
     void removedFromMemoryCache();
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     StyleSheetContents(StyleRuleImport* ownerRule, const String& originalURL, const KURL& baseURL, const CSSParserContext&);
     StyleSheetContents(const StyleSheetContents&);

Modified: trunk/Source/WebCore/css/WebKitCSSKeyframeRule.cpp (124329 => 124330)


--- trunk/Source/WebCore/css/WebKitCSSKeyframeRule.cpp	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/WebKitCSSKeyframeRule.cpp	2012-08-01 13:29:59 UTC (rev 124330)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "WebKitCSSKeyframeRule.h"
 
+#include "MemoryInstrumentation.h"
 #include "PropertySetCSSStyleDeclaration.h"
 #include "StylePropertySet.h"
 #include "WebKitCSSKeyframesRule.h"
@@ -85,6 +86,13 @@
     return result;
 }
 
+void StyleKeyframe::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<StyleKeyframe> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addInstrumentedMember(m_properties);
+    info.addString(m_key);
+}
+
 WebKitCSSKeyframeRule::WebKitCSSKeyframeRule(StyleKeyframe* keyframe, WebKitCSSKeyframesRule* parent)
     : CSSRule(0, CSSRule::WEBKIT_KEYFRAME_RULE)
     , m_keyframe(keyframe)

Modified: trunk/Source/WebCore/css/WebKitCSSKeyframeRule.h (124329 => 124330)


--- trunk/Source/WebCore/css/WebKitCSSKeyframeRule.h	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/WebKitCSSKeyframeRule.h	2012-08-01 13:29:59 UTC (rev 124330)
@@ -34,6 +34,7 @@
 
 namespace WebCore {
 
+class MemoryInstrumentation;
 class StyleRuleCSSStyleDeclaration;
 class WebKitCSSKeyframesRule;
 
@@ -55,6 +56,8 @@
     
     String cssText() const;
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:    
     StyleKeyframe() { }
     

Modified: trunk/Source/WebCore/css/WebKitCSSKeyframesRule.cpp (124329 => 124330)


--- trunk/Source/WebCore/css/WebKitCSSKeyframesRule.cpp	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/WebKitCSSKeyframesRule.cpp	2012-08-01 13:29:59 UTC (rev 124330)
@@ -29,6 +29,7 @@
 #include "CSSParser.h"
 #include "CSSRuleList.h"
 #include "CSSStyleSheet.h"
+#include "MemoryInstrumentation.h"
 #include "StylePropertySet.h"
 #include "StyleSheet.h"
 #include "WebKitCSSKeyframeRule.h"
@@ -86,6 +87,13 @@
     return -1;
 }
 
+void StyleRuleKeyframes::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<StyleRuleKeyframes> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addInstrumentedVector(m_keyframes);
+    info.addString(m_name);
+}
+
 WebKitCSSKeyframesRule::WebKitCSSKeyframesRule(StyleRuleKeyframes* keyframesRule, CSSStyleSheet* parent)
     : CSSRule(parent, CSSRule::WEBKIT_KEYFRAMES_RULE)
     , m_keyframesRule(keyframesRule)

Modified: trunk/Source/WebCore/css/WebKitCSSKeyframesRule.h (124329 => 124330)


--- trunk/Source/WebCore/css/WebKitCSSKeyframesRule.h	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/css/WebKitCSSKeyframesRule.h	2012-08-01 13:29:59 UTC (rev 124330)
@@ -36,6 +36,7 @@
 namespace WebCore {
 
 class CSSRuleList;
+class MemoryObjectInfo;
 class StyleKeyframe;
 class WebKitCSSKeyframeRule;
 
@@ -58,6 +59,8 @@
 
     PassRefPtr<StyleRuleKeyframes> copy() const { return adoptRef(new StyleRuleKeyframes(*this)); }
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     StyleRuleKeyframes();
     StyleRuleKeyframes(const StyleRuleKeyframes&);

Modified: trunk/Source/WebCore/dom/Document.cpp (124329 => 124330)


--- trunk/Source/WebCore/dom/Document.cpp	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/dom/Document.cpp	2012-08-01 13:29:59 UTC (rev 124330)
@@ -6098,10 +6098,12 @@
     info.addVector(m_customFonts);
     info.addString(m_documentURI);
     info.addString(m_baseTarget);
+    info.addInstrumentedMember(m_elemSheet);
+    info.addInstrumentedMember(m_pageUserSheet);
     if (m_pageGroupUserSheets)
-        info.addVector(*m_pageGroupUserSheets.get());
+        info.addInstrumentedVectorPtr(m_pageGroupUserSheets);
     if (m_userSheets)
-        info.addVector(*m_userSheets.get());
+        info.addInstrumentedVectorPtr(m_userSheets);
     info.addHashSet(m_nodeIterators);
     info.addHashSet(m_ranges);
     info.addListHashSet(m_styleSheetCandidateNodes);

Modified: trunk/Source/WebCore/dom/MemoryInstrumentation.h (124329 => 124330)


--- trunk/Source/WebCore/dom/MemoryInstrumentation.h	2012-08-01 12:28:28 UTC (rev 124329)
+++ trunk/Source/WebCore/dom/MemoryInstrumentation.h	2012-08-01 13:29:59 UTC (rev 124330)
@@ -173,8 +173,11 @@
     template <typename HashSetType> void addHashSet(const HashSetType& set) { m_memoryInstrumentation->addHashSet(set, m_objectType, true); }
     template <typename HashSetType> void addInstrumentedHashSet(const HashSetType& set) { m_memoryInstrumentation->addInstrumentedCollection(set, m_objectType, true); }
     template <typename VectorType> void addInstrumentedVector(const VectorType& vector) { m_memoryInstrumentation->addInstrumentedCollection(vector, m_objectType, true); }
+    template <typename VectorType> void addInstrumentedVectorPtr(const OwnPtr<VectorType>& vector) { m_memoryInstrumentation->addInstrumentedCollection(*vector, m_objectType, false); }
+    template <typename VectorType> void addInstrumentedVectorPtr(const VectorType* const& vector) { m_memoryInstrumentation->addInstrumentedCollection(*vector, m_objectType, false); }
     template <typename ListHashSetType> void addListHashSet(const ListHashSetType& set) { m_memoryInstrumentation->addListHashSet(set, m_objectType, true); }
     template <typename VectorType> void addVector(const VectorType& vector) { m_memoryInstrumentation->addVector(vector, m_objectType, true); }
+    template <typename VectorType> void addVectorPtr(const VectorType* const vector) { m_memoryInstrumentation->addVector(*vector, m_objectType, false); }
     void addRawBuffer(const void* const& buffer, size_t size) { m_memoryInstrumentation->addRawBuffer(buffer, m_objectType, size); }
 
     void addString(const String& string) { m_memoryInstrumentation->addString(string, m_objectType); }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to