Web Inspector: add memory instrumentation for CSSValue and its descendants
authoryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Aug 2012 14:09:59 +0000 (14:09 +0000)
committeryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Aug 2012 14:09:59 +0000 (14:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=93130

Reviewed by Pavel Feldman.

Added memory footprint reporting routine to CSSValue and its descendants.

Memory reporing for CSSValue is organized in a following way:
- CSSValue implements reportMemoryUsage method that switches by the value
  type and calls reportDescendantMemoryUsage on the concrete type
- There may be some intermediate classes in the inheritance chain between
  CSSValue and the leaf class implementing reportDescendantMemoryUsage. Those
  intermediate classes implement reportBaseClassMemoryUsage method that can
  be called from a descendant to collect memory information for the base class
  members. Having reportDescendantMemoryUsage only on the leaf classes prevents
  us from accidentally adding the intermediate classes to the switch block
  in the CSSValue::reportMemoryUsage.

* css/CSSAspectRatioValue.cpp:
(WebCore::CSSAspectRatioValue::reportDescendantMemoryUsage):
(WebCore):
* css/CSSAspectRatioValue.h:
(CSSAspectRatioValue):
* css/CSSBorderImageSliceValue.cpp:
(WebCore::CSSBorderImageSliceValue::reportDescendantMemoryUsage):
(WebCore):
* css/CSSBorderImageSliceValue.h:
(CSSBorderImageSliceValue):
* css/CSSCalculationValue.cpp:
(WebCore):
(WebCore::CSSCalcValue::reportDescendantMemoryUsage):
(CSSCalcPrimitiveValue):
* css/CSSCalculationValue.h:
(CSSCalcExpressionNode):
(CSSCalcValue):
* css/CSSCanvasValue.cpp:
(WebCore::CSSCanvasValue::reportDescendantMemoryUsage):
(WebCore):
* css/CSSCanvasValue.h:
(CSSCanvasValue):
* css/CSSCrossfadeValue.cpp:
(WebCore::CSSCrossfadeValue::reportDescendantMemoryUsage):
(WebCore):
* css/CSSCrossfadeValue.h:
(CSSCrossfadeValue):
* css/CSSCursorImageValue.cpp:
(WebCore::CSSCursorImageValue::reportDescendantMemoryUsage):
(WebCore):
* css/CSSCursorImageValue.h:
(CSSCursorImageValue):
* css/CSSFontFaceSrcValue.cpp:
(WebCore::CSSFontFaceSrcValue::reportDescendantMemoryUsage):
(WebCore):
* css/CSSFontFaceSrcValue.h:
(CSSFontFaceSrcValue):
* css/CSSFunctionValue.cpp:
(WebCore::CSSFunctionValue::reportDescendantMemoryUsage):
(WebCore):
* css/CSSFunctionValue.h:
(CSSFunctionValue):
* css/CSSGradientValue.cpp:
(WebCore::CSSGradientColorStop::reportMemoryUsage):
(WebCore):
(WebCore::CSSGradientValue::reportBaseClassMemoryUsage):
(WebCore::CSSLinearGradientValue::reportDescendantMemoryUsage):
(WebCore::CSSRadialGradientValue::reportDescendantMemoryUsage):
* css/CSSGradientValue.h:
(CSSGradientColorStop):
(CSSGradientValue):
(CSSLinearGradientValue):
(CSSRadialGradientValue):
* css/CSSImageGeneratorValue.cpp:
(WebCore::CSSImageGeneratorValue::reportBaseClassMemoryUsage):
(WebCore):
* css/CSSImageGeneratorValue.h:
(CSSImageGeneratorValue):
* css/CSSImageSetValue.cpp:
(WebCore::CSSImageSetValue::reportDescendantMemoryUsage):
(WebCore):
(WebCore::CSSImageSetValue::ImageWithScale::reportMemoryUsage):
* css/CSSImageSetValue.h:
(ImageWithScale):
(CSSImageSetValue):
* css/CSSImageValue.cpp:
(WebCore::CSSImageValue::reportDescendantMemoryUsage):
(WebCore):
* css/CSSImageValue.h:
(CSSImageValue):
* css/CSSInheritedValue.cpp:
(WebCore::CSSInheritedValue::reportDescendantMemoryUsage):
(WebCore):
* css/CSSInheritedValue.h:
(CSSInheritedValue):
* css/CSSInitialValue.cpp:
(WebCore::CSSInitialValue::reportDescendantMemoryUsage):
(WebCore):
* css/CSSInitialValue.h:
(CSSInitialValue):
* css/CSSLineBoxContainValue.cpp:
(WebCore::CSSLineBoxContainValue::reportDescendantMemoryUsage):
(WebCore):
* css/CSSLineBoxContainValue.h:
(CSSLineBoxContainValue):
* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::reportDescendantMemoryUsage):
(WebCore):
* css/CSSPrimitiveValue.h:
(CSSPrimitiveValue):
* css/CSSReflectValue.cpp:
(WebCore::CSSReflectValue::reportDescendantMemoryUsage):
(WebCore):
* css/CSSReflectValue.h:
(CSSReflectValue):
* css/CSSTimingFunctionValue.cpp:
(WebCore::CSSLinearTimingFunctionValue::reportDescendantMemoryUsage):
(WebCore):
(WebCore::CSSCubicBezierTimingFunctionValue::reportDescendantMemoryUsage):
(WebCore::CSSStepsTimingFunctionValue::reportDescendantMemoryUsage):
* css/CSSTimingFunctionValue.h:
(CSSLinearTimingFunctionValue):
(CSSCubicBezierTimingFunctionValue):
(CSSStepsTimingFunctionValue):
* css/CSSUnicodeRangeValue.cpp:
(WebCore::CSSUnicodeRangeValue::reportDescendantMemoryUsage):
(WebCore):
* css/CSSUnicodeRangeValue.h:
(CSSUnicodeRangeValue):
* css/CSSValue.cpp:
(WebCore::TextCloneCSSValue::reportDescendantMemoryUsage):
(TextCloneCSSValue):
(WebCore::CSSValue::reportMemoryUsage):
(WebCore):
* css/CSSValue.h:
(WebCore):
(CSSValue):
* css/CSSValueList.cpp:
(WebCore::CSSValueList::reportDescendantMemoryUsage):
(WebCore):
* css/CSSValueList.h:
(CSSValueList):
* css/CSSVariableValue.h:
(WebCore::CSSVariableValue::reportDescendantMemoryUsage):
(CSSVariableValue):
* css/FontFeatureValue.cpp:
(WebCore::FontFeatureValue::reportDescendantMemoryUsage):
(WebCore):
* css/FontFeatureValue.h:
(FontFeatureValue):
* css/FontValue.cpp:
(WebCore::FontValue::reportDescendantMemoryUsage):
(WebCore):
* css/FontValue.h:
(FontValue):
* css/MediaQueryExp.cpp:
(WebCore::MediaQueryExp::reportMemoryUsage):
* css/ShadowValue.cpp:
(WebCore::ShadowValue::reportDescendantMemoryUsage):
(WebCore):
* css/ShadowValue.h:
(ShadowValue):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::collectMatchingRulesForList):
* css/WebKitCSSFilterValue.cpp:
(WebCore::WebKitCSSFilterValue::reportDescendantMemoryUsage):
(WebCore):
* css/WebKitCSSFilterValue.h:
(WebKitCSSFilterValue):
* css/WebKitCSSSVGDocumentValue.cpp:
(WebCore::WebKitCSSSVGDocumentValue::reportDescendantMemoryUsage):
(WebCore):
* css/WebKitCSSSVGDocumentValue.h:
(WebKitCSSSVGDocumentValue):
* css/WebKitCSSShaderValue.cpp:
(WebCore::WebKitCSSShaderValue::reportDescendantMemoryUsage):
(WebCore):
* css/WebKitCSSShaderValue.h:
(WebKitCSSShaderValue):
* css/WebKitCSSTransformValue.cpp:
(WebCore::WebKitCSSTransformValue::reportDescendantMemoryUsage):
(WebCore):
* css/WebKitCSSTransformValue.h:
(WebKitCSSTransformValue):
* dom/MemoryInstrumentation.cpp:
(WebCore::MemoryInstrumentation::addString):
(WebCore):
* dom/MemoryInstrumentation.h:
(MemoryInstrumentation):
(WebCore::MemoryClassInfo::addHashCountedSet):
(WebCore::MemoryClassInfo::addMember):
* svg/SVGColor.cpp:
(WebCore::SVGColor::reportDescendantMemoryUsage):
(WebCore):
* svg/SVGColor.h:
(SVGColor):
* svg/SVGPaint.cpp:
(WebCore::SVGPaint::reportDescendantMemoryUsage):
(WebCore):
* svg/SVGPaint.h:
(SVGPaint):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@124768 268f45cc-cd09-0410-ab3c-d52691b4dbfc

71 files changed:
Source/WebCore/ChangeLog
Source/WebCore/css/CSSAspectRatioValue.cpp
Source/WebCore/css/CSSAspectRatioValue.h
Source/WebCore/css/CSSBorderImageSliceValue.cpp
Source/WebCore/css/CSSBorderImageSliceValue.h
Source/WebCore/css/CSSCalculationValue.cpp
Source/WebCore/css/CSSCalculationValue.h
Source/WebCore/css/CSSCanvasValue.cpp
Source/WebCore/css/CSSCanvasValue.h
Source/WebCore/css/CSSCrossfadeValue.cpp
Source/WebCore/css/CSSCrossfadeValue.h
Source/WebCore/css/CSSCursorImageValue.cpp
Source/WebCore/css/CSSCursorImageValue.h
Source/WebCore/css/CSSFontFaceSrcValue.cpp
Source/WebCore/css/CSSFontFaceSrcValue.h
Source/WebCore/css/CSSFunctionValue.cpp
Source/WebCore/css/CSSFunctionValue.h
Source/WebCore/css/CSSGradientValue.cpp
Source/WebCore/css/CSSGradientValue.h
Source/WebCore/css/CSSImageGeneratorValue.cpp
Source/WebCore/css/CSSImageGeneratorValue.h
Source/WebCore/css/CSSImageSetValue.cpp
Source/WebCore/css/CSSImageSetValue.h
Source/WebCore/css/CSSImageValue.cpp
Source/WebCore/css/CSSImageValue.h
Source/WebCore/css/CSSInheritedValue.cpp
Source/WebCore/css/CSSInheritedValue.h
Source/WebCore/css/CSSInitialValue.cpp
Source/WebCore/css/CSSInitialValue.h
Source/WebCore/css/CSSLineBoxContainValue.cpp
Source/WebCore/css/CSSLineBoxContainValue.h
Source/WebCore/css/CSSPrimitiveValue.cpp
Source/WebCore/css/CSSPrimitiveValue.h
Source/WebCore/css/CSSProperty.cpp
Source/WebCore/css/CSSProperty.h
Source/WebCore/css/CSSReflectValue.cpp
Source/WebCore/css/CSSReflectValue.h
Source/WebCore/css/CSSTimingFunctionValue.cpp
Source/WebCore/css/CSSTimingFunctionValue.h
Source/WebCore/css/CSSUnicodeRangeValue.cpp
Source/WebCore/css/CSSUnicodeRangeValue.h
Source/WebCore/css/CSSValue.cpp
Source/WebCore/css/CSSValue.h
Source/WebCore/css/CSSValueList.cpp
Source/WebCore/css/CSSValueList.h
Source/WebCore/css/CSSVariableValue.h
Source/WebCore/css/FontFeatureValue.cpp
Source/WebCore/css/FontFeatureValue.h
Source/WebCore/css/FontValue.cpp
Source/WebCore/css/FontValue.h
Source/WebCore/css/MediaQueryExp.cpp
Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp
Source/WebCore/css/ShadowValue.cpp
Source/WebCore/css/ShadowValue.h
Source/WebCore/css/StylePropertySet.cpp
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/StyleResolver.h
Source/WebCore/css/WebKitCSSFilterValue.cpp
Source/WebCore/css/WebKitCSSFilterValue.h
Source/WebCore/css/WebKitCSSSVGDocumentValue.cpp
Source/WebCore/css/WebKitCSSSVGDocumentValue.h
Source/WebCore/css/WebKitCSSShaderValue.cpp
Source/WebCore/css/WebKitCSSShaderValue.h
Source/WebCore/css/WebKitCSSTransformValue.cpp
Source/WebCore/css/WebKitCSSTransformValue.h
Source/WebCore/dom/MemoryInstrumentation.cpp
Source/WebCore/dom/MemoryInstrumentation.h
Source/WebCore/svg/SVGColor.cpp
Source/WebCore/svg/SVGColor.h
Source/WebCore/svg/SVGPaint.cpp
Source/WebCore/svg/SVGPaint.h

index e403874..5c20628 100644 (file)
@@ -1,3 +1,205 @@
+2012-08-03  Yury Semikhatsky  <yurys@chromium.org>
+
+        Web Inspector: add memory instrumentation for CSSValue and its descendants
+        https://bugs.webkit.org/show_bug.cgi?id=93130
+
+        Reviewed by Pavel Feldman.
+
+        Added memory footprint reporting routine to CSSValue and its descendants.
+
+        Memory reporing for CSSValue is organized in a following way:
+        - CSSValue implements reportMemoryUsage method that switches by the value
+          type and calls reportDescendantMemoryUsage on the concrete type
+        - There may be some intermediate classes in the inheritance chain between
+          CSSValue and the leaf class implementing reportDescendantMemoryUsage. Those
+          intermediate classes implement reportBaseClassMemoryUsage method that can
+          be called from a descendant to collect memory information for the base class
+          members. Having reportDescendantMemoryUsage only on the leaf classes prevents
+          us from accidentally adding the intermediate classes to the switch block
+          in the CSSValue::reportMemoryUsage.
+
+        * css/CSSAspectRatioValue.cpp:
+        (WebCore::CSSAspectRatioValue::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/CSSAspectRatioValue.h:
+        (CSSAspectRatioValue):
+        * css/CSSBorderImageSliceValue.cpp:
+        (WebCore::CSSBorderImageSliceValue::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/CSSBorderImageSliceValue.h:
+        (CSSBorderImageSliceValue):
+        * css/CSSCalculationValue.cpp:
+        (WebCore):
+        (WebCore::CSSCalcValue::reportDescendantMemoryUsage):
+        (CSSCalcPrimitiveValue):
+        * css/CSSCalculationValue.h:
+        (CSSCalcExpressionNode):
+        (CSSCalcValue):
+        * css/CSSCanvasValue.cpp:
+        (WebCore::CSSCanvasValue::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/CSSCanvasValue.h:
+        (CSSCanvasValue):
+        * css/CSSCrossfadeValue.cpp:
+        (WebCore::CSSCrossfadeValue::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/CSSCrossfadeValue.h:
+        (CSSCrossfadeValue):
+        * css/CSSCursorImageValue.cpp:
+        (WebCore::CSSCursorImageValue::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/CSSCursorImageValue.h:
+        (CSSCursorImageValue):
+        * css/CSSFontFaceSrcValue.cpp:
+        (WebCore::CSSFontFaceSrcValue::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/CSSFontFaceSrcValue.h:
+        (CSSFontFaceSrcValue):
+        * css/CSSFunctionValue.cpp:
+        (WebCore::CSSFunctionValue::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/CSSFunctionValue.h:
+        (CSSFunctionValue):
+        * css/CSSGradientValue.cpp:
+        (WebCore::CSSGradientColorStop::reportMemoryUsage):
+        (WebCore):
+        (WebCore::CSSGradientValue::reportBaseClassMemoryUsage):
+        (WebCore::CSSLinearGradientValue::reportDescendantMemoryUsage):
+        (WebCore::CSSRadialGradientValue::reportDescendantMemoryUsage):
+        * css/CSSGradientValue.h:
+        (CSSGradientColorStop):
+        (CSSGradientValue):
+        (CSSLinearGradientValue):
+        (CSSRadialGradientValue):
+        * css/CSSImageGeneratorValue.cpp:
+        (WebCore::CSSImageGeneratorValue::reportBaseClassMemoryUsage):
+        (WebCore):
+        * css/CSSImageGeneratorValue.h:
+        (CSSImageGeneratorValue):
+        * css/CSSImageSetValue.cpp:
+        (WebCore::CSSImageSetValue::reportDescendantMemoryUsage):
+        (WebCore):
+        (WebCore::CSSImageSetValue::ImageWithScale::reportMemoryUsage):
+        * css/CSSImageSetValue.h:
+        (ImageWithScale):
+        (CSSImageSetValue):
+        * css/CSSImageValue.cpp:
+        (WebCore::CSSImageValue::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/CSSImageValue.h:
+        (CSSImageValue):
+        * css/CSSInheritedValue.cpp:
+        (WebCore::CSSInheritedValue::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/CSSInheritedValue.h:
+        (CSSInheritedValue):
+        * css/CSSInitialValue.cpp:
+        (WebCore::CSSInitialValue::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/CSSInitialValue.h:
+        (CSSInitialValue):
+        * css/CSSLineBoxContainValue.cpp:
+        (WebCore::CSSLineBoxContainValue::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/CSSLineBoxContainValue.h:
+        (CSSLineBoxContainValue):
+        * css/CSSPrimitiveValue.cpp:
+        (WebCore::CSSPrimitiveValue::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/CSSPrimitiveValue.h:
+        (CSSPrimitiveValue):
+        * css/CSSReflectValue.cpp:
+        (WebCore::CSSReflectValue::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/CSSReflectValue.h:
+        (CSSReflectValue):
+        * css/CSSTimingFunctionValue.cpp:
+        (WebCore::CSSLinearTimingFunctionValue::reportDescendantMemoryUsage):
+        (WebCore):
+        (WebCore::CSSCubicBezierTimingFunctionValue::reportDescendantMemoryUsage):
+        (WebCore::CSSStepsTimingFunctionValue::reportDescendantMemoryUsage):
+        * css/CSSTimingFunctionValue.h:
+        (CSSLinearTimingFunctionValue):
+        (CSSCubicBezierTimingFunctionValue):
+        (CSSStepsTimingFunctionValue):
+        * css/CSSUnicodeRangeValue.cpp:
+        (WebCore::CSSUnicodeRangeValue::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/CSSUnicodeRangeValue.h:
+        (CSSUnicodeRangeValue):
+        * css/CSSValue.cpp:
+        (WebCore::TextCloneCSSValue::reportDescendantMemoryUsage):
+        (TextCloneCSSValue):
+        (WebCore::CSSValue::reportMemoryUsage):
+        (WebCore):
+        * css/CSSValue.h:
+        (WebCore):
+        (CSSValue):
+        * css/CSSValueList.cpp:
+        (WebCore::CSSValueList::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/CSSValueList.h:
+        (CSSValueList):
+        * css/CSSVariableValue.h:
+        (WebCore::CSSVariableValue::reportDescendantMemoryUsage):
+        (CSSVariableValue):
+        * css/FontFeatureValue.cpp:
+        (WebCore::FontFeatureValue::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/FontFeatureValue.h:
+        (FontFeatureValue):
+        * css/FontValue.cpp:
+        (WebCore::FontValue::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/FontValue.h:
+        (FontValue):
+        * css/MediaQueryExp.cpp:
+        (WebCore::MediaQueryExp::reportMemoryUsage):
+        * css/ShadowValue.cpp:
+        (WebCore::ShadowValue::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/ShadowValue.h:
+        (ShadowValue):
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::collectMatchingRulesForList):
+        * css/WebKitCSSFilterValue.cpp:
+        (WebCore::WebKitCSSFilterValue::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/WebKitCSSFilterValue.h:
+        (WebKitCSSFilterValue):
+        * css/WebKitCSSSVGDocumentValue.cpp:
+        (WebCore::WebKitCSSSVGDocumentValue::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/WebKitCSSSVGDocumentValue.h:
+        (WebKitCSSSVGDocumentValue):
+        * css/WebKitCSSShaderValue.cpp:
+        (WebCore::WebKitCSSShaderValue::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/WebKitCSSShaderValue.h:
+        (WebKitCSSShaderValue):
+        * css/WebKitCSSTransformValue.cpp:
+        (WebCore::WebKitCSSTransformValue::reportDescendantMemoryUsage):
+        (WebCore):
+        * css/WebKitCSSTransformValue.h:
+        (WebKitCSSTransformValue):
+        * dom/MemoryInstrumentation.cpp:
+        (WebCore::MemoryInstrumentation::addString):
+        (WebCore):
+        * dom/MemoryInstrumentation.h:
+        (MemoryInstrumentation):
+        (WebCore::MemoryClassInfo::addHashCountedSet):
+        (WebCore::MemoryClassInfo::addMember):
+        * svg/SVGColor.cpp:
+        (WebCore::SVGColor::reportDescendantMemoryUsage):
+        (WebCore):
+        * svg/SVGColor.h:
+        (SVGColor):
+        * svg/SVGPaint.cpp:
+        (WebCore::SVGPaint::reportDescendantMemoryUsage):
+        (WebCore):
+        * svg/SVGPaint.h:
+        (SVGPaint):
+
 2012-08-06  Yury Semikhatsky  <yurys@chromium.org>
 
         Web Inspector: rename WorkerAgent.setWorkerInspectionEnabled to WorkerAgent.enable and make it return error
index 18b0ded..b07f7ba 100644 (file)
@@ -29,6 +29,7 @@
 #include "config.h"
 #include "CSSAspectRatioValue.h"
 
+#include "MemoryInstrumentation.h"
 #include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
@@ -42,4 +43,9 @@ String CSSAspectRatioValue::customCssText() const
     return result.toString();
 }
 
+void CSSAspectRatioValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSAspectRatioValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+}
+
 }
index 2f6b426..5cc3392 100644 (file)
@@ -46,6 +46,8 @@ public:
     float numeratorValue() const { return m_numeratorValue; }
     float denominatorValue() const { return m_denominatorValue; }
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     CSSAspectRatioValue(float numeratorValue, float denominatorValue)
         : CSSValue(AspectRatioClass)
index 04ef2d3..ff73aca 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "CSSBorderImageSliceValue.h"
 
+#include "MemoryInstrumentation.h"
 #include "PlatformString.h"
 #include "Rect.h"
 
@@ -49,4 +50,10 @@ String CSSBorderImageSliceValue::customCssText() const
     return text;
 }
 
+void CSSBorderImageSliceValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSBorderImageSliceValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addInstrumentedMember(m_slices);
+}
+
 } // namespace WebCore
index d8230f4..488b4a4 100644 (file)
@@ -45,6 +45,8 @@ public:
 
     Quad* slices() { return m_slices ? m_slices->getQuadValue() : 0; }
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
     // These four values are used to make "cuts" in the border image. They can be numbers
     // or percentages.
     RefPtr<CSSPrimitiveValue> m_slices;
index 54247e0..bc8edd9 100755 (executable)
@@ -33,6 +33,7 @@
 
 #include "CSSValueList.h"
 #include "Length.h"
+#include "MemoryInstrumentation.h"
 #include "StyleResolver.h"
 
 #include <wtf/OwnPtr.h>
@@ -86,6 +87,11 @@ String CSSCalcValue::customCssText() const
         result.append(')');
     return result.toString(); 
 }
+
+void CSSCalcValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSCalcValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+}
     
 double CSSCalcValue::clampToPermittedRange(double value) const
 {
@@ -175,6 +181,12 @@ public:
         }
         return 0;        
     }
+
+    virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const OVERRIDE
+    {
+        MemoryClassInfo<CSSCalcPrimitiveValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+        info.addInstrumentedMember(m_value);
+    }
     
 private:
     explicit CSSCalcPrimitiveValue(CSSPrimitiveValue* value, bool isInteger)
@@ -260,6 +272,13 @@ public:
         return evaluate(leftValue, rightValue);
     }
 
+    virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const OVERRIDE
+    {
+        MemoryClassInfo<CSSCalcBinaryOperation> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+        info.addInstrumentedMember(m_leftSide);
+        info.addInstrumentedMember(m_rightSide);
+    }
+
     virtual String customCssText() const
     {
         StringBuilder result;
index 57a249f..b25f7b3 100755 (executable)
@@ -64,6 +64,8 @@ public:
     virtual double doubleValue() const = 0;
     virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const = 0;
     virtual String customCssText() const = 0;
+
+    virtual void reportMemoryUsage(MemoryObjectInfo*) const = 0;
     
     CalculationCategory category() const { return m_category; }    
     bool isInteger() const { return m_isInteger; }
@@ -95,6 +97,8 @@ public:
     double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const;
         
     String customCssText() const;
+
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
     
 private:    
     CSSCalcValue(PassRefPtr<CSSCalcExpressionNode> expression, CalculationPermittedValueRange range)
index 783ceef..c0ade42 100644 (file)
@@ -27,6 +27,7 @@
 #include "CSSCanvasValue.h"
 
 #include "ImageBuffer.h"
+#include "MemoryInstrumentation.h"
 #include "RenderObject.h"
 
 namespace WebCore {
@@ -92,4 +93,12 @@ PassRefPtr<Image> CSSCanvasValue::image(RenderObject* renderer, const IntSize& /
     return elt->copiedImage();
 }
 
+void CSSCanvasValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSCanvasValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    CSSImageGeneratorValue::reportBaseClassMemoryUsage(memoryObjectInfo);
+    info.addMember(m_name);
+    info.addInstrumentedMember(m_element);
+}
+
 } // namespace WebCore
index 159e619..13fb587 100644 (file)
@@ -47,6 +47,8 @@ public:
     bool isPending() const { return false; }
     void loadSubimages(CachedResourceLoader*) { }
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     CSSCanvasValue(const String& name)
         : CSSImageGeneratorValue(CanvasClass)
index a95d1e7..66b3d3e 100644 (file)
@@ -31,6 +31,7 @@
 #include "CachedResourceLoader.h"
 #include "CrossfadeGeneratedImage.h"
 #include "ImageBuffer.h"
+#include "MemoryInstrumentation.h"
 #include "RenderObject.h"
 #include "StyleCachedImage.h"
 #include "StyleGeneratedImage.h"
@@ -134,6 +135,19 @@ void CSSCrossfadeValue::loadSubimages(CachedResourceLoader* cachedResourceLoader
     m_crossfadeSubimageObserver.setReady(true);
 }
 
+void CSSCrossfadeValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSCrossfadeValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    CSSImageGeneratorValue::reportBaseClassMemoryUsage(memoryObjectInfo);
+    info.addInstrumentedMember(m_fromValue);
+    info.addInstrumentedMember(m_toValue);
+    info.addInstrumentedMember(m_percentageValue);
+    // FIXME: add instrumentation for
+    // m_cachedFromImage
+    // m_cachedToImage
+    // m_generatedImage
+}
+
 PassRefPtr<Image> CSSCrossfadeValue::image(RenderObject* renderer, const IntSize& size)
 {
     if (size.isEmpty())
index 89a72c4..f5267eb 100644 (file)
@@ -63,6 +63,8 @@ public:
 
     bool hasFailedOrCanceledSubresources() const;
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     CSSCrossfadeValue(PassRefPtr<CSSValue> fromValue, PassRefPtr<CSSValue> toValue)
         : CSSImageGeneratorValue(CrossfadeClass)
index f850684..77c3c93 100644 (file)
@@ -23,6 +23,7 @@
 #include "CSSCursorImageValue.h"
 
 #include "CachedResourceLoader.h"
+#include "MemoryInstrumentation.h"
 #include "TreeScope.h"
 #include "PlatformString.h"
 #include <wtf/MathExtras.h>
@@ -132,4 +133,13 @@ void CSSCursorImageValue::removeReferencedElement(SVGElement* element)
 }
 #endif
 
+void CSSCursorImageValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSCursorImageValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    CSSImageValue::reportDescendantMemoryUsage(memoryObjectInfo);
+#if ENABLE(SVG)
+    info.addInstrumentedHashSet(m_referencedElements);
+#endif
+}
+
 } // namespace WebCore
index cb26919..dc8d1ff 100644 (file)
@@ -48,6 +48,8 @@ public:
     void removeReferencedElement(SVGElement*);
 #endif
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     CSSCursorImageValue(const String& url, const IntPoint& hotSpot);
 
index 605b2fc..9716140 100644 (file)
@@ -29,7 +29,9 @@
 #include "CachedResourceLoader.h"
 #include "Document.h"
 #include "FontCustomPlatformData.h"
+#include "MemoryInstrumentation.h"
 #include "Node.h"
+#include "SVGFontFaceElement.h"
 #include "StyleSheetContents.h"
 
 namespace WebCore {
@@ -95,5 +97,16 @@ CachedFont* CSSFontFaceSrcValue::cachedFont(Document* document)
     return m_cachedFont.get();
 }
 
+void CSSFontFaceSrcValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSFontFaceSrcValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addMember(m_resource);
+    info.addMember(m_format);
+    // FIXME: add m_cachedFont when MemoryCache is instrumented.
+#if ENABLE(SVG_FONTS)
+    info.addInstrumentedMember(m_svgFontFaceElement);
+#endif
+}
+
 }
 
index 06ef4b3..4444c86 100644 (file)
@@ -71,6 +71,8 @@ public:
 
     CachedFont* cachedFont(Document*);
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     CSSFontFaceSrcValue(const String& resource, bool local)
         : CSSValue(FontFaceSrcClass)
index 522ad9f..53dc43f 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "CSSParserValues.h"
 #include "CSSValueList.h"
+#include "MemoryInstrumentation.h"
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
@@ -49,4 +50,11 @@ String CSSFunctionValue::customCssText() const
     return result;
 }
 
+void CSSFunctionValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSFunctionValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addMember(m_name);
+    info.addInstrumentedMember(m_args);
+}
+
 }
index a35a1b1..6b7fbc6 100644 (file)
@@ -42,6 +42,8 @@ public:
 
     String customCssText() const;
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     explicit CSSFunctionValue(CSSParserFunction*);
 
index 3f1979f..3076d2a 100644 (file)
@@ -33,6 +33,7 @@
 #include "Image.h"
 #include "IntSize.h"
 #include "IntSizeHash.h"
+#include "MemoryInstrumentation.h"
 #include "NodeRenderStyle.h"
 #include "PlatformString.h"
 #include "RenderObject.h"
@@ -42,6 +43,13 @@ using namespace std;
 
 namespace WebCore {
 
+void CSSGradientColorStop::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSGradientColorStop> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addInstrumentedMember(m_position);
+    info.addInstrumentedMember(m_color);
+}
+
 PassRefPtr<Image> CSSGradientValue::image(RenderObject* renderer, const IntSize& size)
 {
     if (size.isEmpty())
@@ -452,6 +460,17 @@ bool CSSGradientValue::isCacheable() const
     return true;
 }
 
+void CSSGradientValue::reportBaseClassMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSGradientValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    CSSImageGeneratorValue::reportBaseClassMemoryUsage(memoryObjectInfo);
+    info.addInstrumentedMember(m_firstX);
+    info.addInstrumentedMember(m_firstY);
+    info.addInstrumentedMember(m_secondX);
+    info.addInstrumentedMember(m_secondY);
+    info.addInstrumentedVector(m_stops);
+}
+
 String CSSLinearGradientValue::customCssText() const
 {
     String result;
@@ -594,6 +613,13 @@ PassRefPtr<Gradient> CSSLinearGradientValue::createGradient(RenderObject* render
     return gradient.release();
 }
 
+void CSSLinearGradientValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSLinearGradientValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    CSSGradientValue::reportBaseClassMemoryUsage(memoryObjectInfo);
+    info.addInstrumentedMember(m_angle);
+}
+
 String CSSRadialGradientValue::customCssText() const
 {
     String result;
@@ -891,4 +917,16 @@ PassRefPtr<Gradient> CSSRadialGradientValue::createGradient(RenderObject* render
     return gradient.release();
 }
 
+void CSSRadialGradientValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSRadialGradientValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    CSSGradientValue::reportBaseClassMemoryUsage(memoryObjectInfo);
+    info.addInstrumentedMember(m_firstRadius);
+    info.addInstrumentedMember(m_secondRadius);
+    info.addInstrumentedMember(m_shape);
+    info.addInstrumentedMember(m_sizingBehavior);
+    info.addInstrumentedMember(m_endHorizontalSize);
+    info.addInstrumentedMember(m_endVerticalSize);
+}
+
 } // namespace WebCore
index 0c7ef77..882cc62 100644 (file)
@@ -45,6 +45,7 @@ struct CSSGradientColorStop {
     RefPtr<CSSPrimitiveValue> m_color;
     Color m_resolvedColor;
     bool m_colorIsDerivedFromElement;
+    void reportMemoryUsage(MemoryObjectInfo*) const;
 };
 
 class CSSGradientValue : public CSSImageGeneratorValue {
@@ -105,6 +106,8 @@ protected:
 
     bool isCacheable() const;
 
+    void reportBaseClassMemoryUsage(MemoryObjectInfo*) const;
+
     // Points. Some of these may be null for linear gradients.
     RefPtr<CSSPrimitiveValue> m_firstX;
     RefPtr<CSSPrimitiveValue> m_firstY;
@@ -139,6 +142,8 @@ public:
         return adoptRef(new CSSLinearGradientValue(*this));
     }
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     CSSLinearGradientValue(CSSGradientRepeat repeat, bool deprecatedType = false)
         : CSSGradientValue(LinearGradientClass, repeat, deprecatedType)
@@ -180,6 +185,8 @@ public:
     // Create the gradient for a given size.
     PassRefPtr<Gradient> createGradient(RenderObject*, const IntSize&);
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     CSSRadialGradientValue(CSSGradientRepeat repeat, bool deprecatedType = false)
         : CSSGradientValue(RadialGradientClass, repeat, deprecatedType)
index 9be446b..c2ad501 100644 (file)
@@ -30,6 +30,7 @@
 #include "CSSCrossfadeValue.h"
 #include "CSSGradientValue.h"
 #include "Image.h"
+#include "MemoryInstrumentation.h"
 #include "RenderObject.h"
 #include <wtf/text/WTFString.h>
 
@@ -108,6 +109,14 @@ void CSSImageGeneratorValue::putImage(const IntSize& size, PassRefPtr<Image> ima
     m_images.add(size, image);
 }
 
+void CSSImageGeneratorValue::reportBaseClassMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSImageGeneratorValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addHashCountedSet(m_sizes);
+    info.addHashMap(m_clients);
+    info.addHashMap(m_images); // FIXME: instrument Image
+}
+
 PassRefPtr<Image> CSSImageGeneratorValue::image(RenderObject* renderer, const IntSize& size)
 {
     switch (classType()) {
index b3d84ea..cdf405a 100644 (file)
@@ -73,6 +73,8 @@ protected:
     void putImage(const IntSize&, PassRefPtr<Image>);
     const RenderObjectSizeCountMap& clients() const { return m_clients; }
 
+    void reportBaseClassMemoryUsage(MemoryObjectInfo*) const;
+
     HashCountedSet<IntSize> m_sizes; // A count of how many times a given image size is in use.
     RenderObjectSizeCountMap m_clients; // A map from RenderObjects (with entry count) to image sizes.
     HashMap<IntSize, RefPtr<Image> > m_images; // A cache of Image objects by image size.
index 89a6462..343d9d7 100644 (file)
@@ -32,6 +32,7 @@
 #include "CSSPrimitiveValue.h"
 #include "CachedResourceLoader.h"
 #include "Document.h"
+#include "MemoryInstrumentation.h"
 #include "Page.h"
 #include "StyleCachedImageSet.h"
 #include "StylePendingImage.h"
@@ -162,6 +163,19 @@ PassRefPtr<CSSImageSetValue> CSSImageSetValue::cloneForCSSOM() const
     return adoptRef(new CSSImageSetValue(*this));
 }
 
+void CSSImageSetValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSImageSetValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    CSSValueList::reportDescendantMemoryUsage(memoryObjectInfo);
+    info.addInstrumentedVector(m_imagesInSet);
+}
+
+void CSSImageSetValue::ImageWithScale::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSImageSetValue::ImageWithScale> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addMember(imageURL);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(CSS_IMAGE_SET)
index 95270a6..a791d1e 100644 (file)
@@ -58,12 +58,15 @@ public:
     struct ImageWithScale {
         String imageURL;
         float scaleFactor;
+        void reportMemoryUsage(MemoryObjectInfo*) const;
     };
 
     bool hasFailedOrCanceledSubresources() const;
 
     PassRefPtr<CSSImageSetValue> cloneForCSSOM() const;
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 protected:
     ImageWithScale bestImageForScaleFactor();
 
index 07bd4b3..f6f5485 100644 (file)
 #include "CSSCursorImageValue.h"
 #include "CSSParser.h"
 #include "CSSValueKeywords.h"
-#include "Document.h"
-#include "MemoryCache.h"
 #include "CachedImage.h"
 #include "CachedResourceLoader.h"
+#include "Document.h"
+#include "MemoryCache.h"
+#include "MemoryInstrumentation.h"
 #include "StyleCachedImage.h"
 #include "StylePendingImage.h"
 
@@ -125,4 +126,11 @@ PassRefPtr<CSSValue> CSSImageValue::cloneForCSSOM() const
     return uriValue.release();
 }
 
+void CSSImageValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSImageValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addMember(m_url);
+    // No need to report m_image as it is counted as part of RenderArena.
+}
+
 } // namespace WebCore
index 75063d2..8c82f2c 100644 (file)
@@ -48,6 +48,8 @@ public:
 
     bool hasFailedOrCanceledSubresources() const;
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 protected:
     CSSImageValue(ClassType, const String& url);
 
index 8c4be6d..2680f2f 100644 (file)
@@ -21,6 +21,7 @@
 #include "config.h"
 #include "CSSInheritedValue.h"
 
+#include "MemoryInstrumentation.h"
 #include "PlatformString.h"
 
 namespace WebCore {
@@ -30,4 +31,9 @@ String CSSInheritedValue::customCssText() const
     return "inherit";
 }
 
+void CSSInheritedValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSInheritedValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+}
+
 } // namespace WebCore
index 5aa9063..68c001f 100644 (file)
@@ -35,6 +35,8 @@ public:
 
     String customCssText() const;
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     CSSInheritedValue()
         : CSSValue(InheritedClass)
index 8de3f31..36bd950 100644 (file)
@@ -21,6 +21,7 @@
 #include "config.h"
 #include "CSSInitialValue.h"
 
+#include "MemoryInstrumentation.h"
 #include "PlatformString.h"
 
 namespace WebCore {
@@ -30,4 +31,9 @@ String CSSInitialValue::customCssText() const
     return "initial";
 }
 
+void CSSInitialValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSInitialValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+}
+
 } // namespace WebCore
index dd86d84..d523343 100644 (file)
@@ -41,6 +41,8 @@ public:
 
     bool isImplicit() const { return m_isImplicit; }
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     CSSInitialValue(bool implicit)
         : CSSValue(InitialClass)
index 53132eb..2cffe53 100644 (file)
@@ -27,6 +27,7 @@
 #include "CSSLineBoxContainValue.h"
 
 #include "CSSPrimitiveValue.h"
+#include "MemoryInstrumentation.h"
 #include "PlatformString.h"
 
 namespace WebCore {
@@ -72,4 +73,9 @@ String CSSLineBoxContainValue::customCssText() const
     return text;
 }
 
+void CSSLineBoxContainValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSLineBoxContainValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+}
+
 }
index ddc0c60..eeb6470 100644 (file)
@@ -50,6 +50,8 @@ public:
 
     LineBoxContain value() const { return m_value; }
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     LineBoxContain m_value;
 
index d5bde82..259a505 100644 (file)
@@ -31,6 +31,7 @@
 #include "Color.h"
 #include "Counter.h"
 #include "ExceptionCode.h"
+#include "MemoryInstrumentation.h"
 #include "Node.h"
 #include "Pair.h"
 #include "RGBColor.h"
@@ -1258,4 +1259,48 @@ PassRefPtr<CSSPrimitiveValue> CSSPrimitiveValue::cloneForCSSOM() const
     return result;
 }
 
+void CSSPrimitiveValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSPrimitiveValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    switch (m_primitiveUnitType) {
+    case CSS_ATTR:
+    case CSS_COUNTER_NAME:
+    case CSS_PARSER_IDENTIFIER:
+    case CSS_PARSER_HEXCOLOR:
+    case CSS_STRING:
+    case CSS_URI:
+#if ENABLE(CSS_VARIABLES)
+    case CSS_VARIABLE_NAME:
+#endif
+        // FIXME: detect other cases when m_value is StringImpl*
+        info.addMember(m_value.string);
+        break;
+    case CSS_COUNTER:
+        info.addMember(m_value.counter);
+        break;
+    case CSS_RECT:
+        info.addMember(m_value.rect);
+        break;
+    case CSS_QUAD:
+        info.addMember(m_value.quad);
+        break;
+    case CSS_PAIR:
+        info.addMember(m_value.pair);
+        break;
+#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION)
+    case CSS_DASHBOARD_REGION:
+        info.addMember(m_value.region);
+        break;
+#endif
+    case CSS_SHAPE:
+        info.addMember(m_value.shape);
+        break;
+    case CSS_CALC:
+        info.addMember(m_value.calc);
+        break;
+    default:
+        break;
+    }
+}
+
 } // namespace WebCore
index 87069c0..fd0832d 100644 (file)
@@ -306,6 +306,8 @@ public:
     PassRefPtr<CSSPrimitiveValue> cloneForCSSOM() const;
     void setCSSOMSafe() { m_isCSSOMSafe = true; }
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     // FIXME: int vs. unsigned overloading is too subtle to distinguish the color and identifier cases.
     CSSPrimitiveValue(int ident);
index ab76c32..021add2 100644 (file)
@@ -22,6 +22,7 @@
 #include "CSSProperty.h"
 
 #include "CSSValueList.h"
+#include "MemoryInstrumentation.h"
 #include "PlatformString.h"
 #include "RenderStyleConstants.h"
 #include "StylePropertyShorthand.h"
@@ -694,4 +695,10 @@ bool CSSProperty::isInheritedProperty(CSSPropertyID propertyID)
     return false;
 }
 
+void CSSProperty::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSProperty> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addInstrumentedMember(m_value);
+}
+
 } // namespace WebCore
index 7124146..57a3012 100644 (file)
@@ -30,6 +30,8 @@
 
 namespace WebCore {
 
+class MemoryObjectInfo;
+
 class CSSProperty {
 public:
     CSSProperty(CSSPropertyID propID, PassRefPtr<CSSValue> value, bool important = false, CSSPropertyID shorthandID = CSSPropertyInvalid, bool implicit = false)
@@ -59,6 +61,8 @@ public:
     static CSSPropertyID resolveDirectionAwareProperty(CSSPropertyID, TextDirection, WritingMode);
     static bool isInheritedProperty(CSSPropertyID);
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     // Make sure the following fits in 4 bytes. Really.
     unsigned m_id : 14;
index b36c3ad..0984752 100644 (file)
@@ -27,6 +27,7 @@
 #include "CSSReflectValue.h"
 
 #include "CSSPrimitiveValue.h"
+#include "MemoryInstrumentation.h"
 #include "PlatformString.h"
 
 using namespace std;
@@ -65,4 +66,11 @@ void CSSReflectValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const Sty
         m_mask->addSubresourceStyleURLs(urls, styleSheet);
 }
 
+void CSSReflectValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSReflectValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addInstrumentedMember(m_offset);
+    info.addInstrumentedMember(m_mask);
+}
+
 } // namespace WebCore
index 5cfb20e..1bdfd5f 100644 (file)
@@ -51,6 +51,8 @@ public:
 
     void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*) const;
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     CSSReflectValue(CSSReflectionDirection direction, PassRefPtr<CSSPrimitiveValue> offset, PassRefPtr<CSSValue> mask)
         : CSSValue(ReflectClass)
index dcf7bb2..fe8278a 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "CSSTimingFunctionValue.h"
 
+#include "MemoryInstrumentation.h"
 #include "PlatformString.h"
 
 namespace WebCore {
@@ -35,6 +36,11 @@ String CSSLinearTimingFunctionValue::customCssText() const
     return "linear";
 }
 
+void CSSLinearTimingFunctionValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSLinearTimingFunctionValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+}
+
 String CSSCubicBezierTimingFunctionValue::customCssText() const
 {
     String text("cubic-bezier(");
@@ -49,6 +55,11 @@ String CSSCubicBezierTimingFunctionValue::customCssText() const
     return text;
 }
 
+void CSSCubicBezierTimingFunctionValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSCubicBezierTimingFunctionValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+}
+
 String CSSStepsTimingFunctionValue::customCssText() const
 {
     String text("steps(");
@@ -59,4 +70,9 @@ String CSSStepsTimingFunctionValue::customCssText() const
     return text;
 }
 
+void CSSStepsTimingFunctionValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSStepsTimingFunctionValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+}
+
 } // namespace WebCore
index e544c5f..3eb4b22 100644 (file)
@@ -40,6 +40,8 @@ public:
 
     String customCssText() const;
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     CSSLinearTimingFunctionValue()
         : CSSValue(LinearTimingFunctionClass)
@@ -61,6 +63,8 @@ public:
     double x2() const { return m_x2; }
     double y2() const { return m_y2; }
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     CSSCubicBezierTimingFunctionValue(double x1, double y1, double x2, double y2)
         : CSSValue(CubicBezierTimingFunctionClass)
@@ -89,6 +93,8 @@ public:
 
     String customCssText() const;
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     CSSStepsTimingFunctionValue(int steps, bool stepAtStart)
         : CSSValue(StepsTimingFunctionClass)
index 2c2c44d..9b0c95d 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "CSSUnicodeRangeValue.h"
 
+#include "MemoryInstrumentation.h"
 #include "PlatformString.h"
 
 namespace WebCore {
@@ -37,4 +38,9 @@ String CSSUnicodeRangeValue::customCssText() const
     return result;
 }
 
+void CSSUnicodeRangeValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSUnicodeRangeValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+}
+
 }
index 4fe1db7..d50f5b6 100644 (file)
@@ -44,6 +44,8 @@ public:
 
     String customCssText() const;
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     CSSUnicodeRangeValue(UChar32 from, UChar32 to)
         : CSSValue(UnicodeRangeClass)
index 5ffb156..9912baf 100644 (file)
@@ -52,6 +52,7 @@
 #endif
 #include "FontValue.h"
 #include "FontFeatureValue.h"
+#include "MemoryInstrumentation.h"
 #include "ShadowValue.h"
 #include "SVGColor.h"
 #include "SVGPaint.h"
@@ -77,6 +78,12 @@ public:
 
     String cssText() const { return m_cssText; }
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+    {
+        MemoryClassInfo<TextCloneCSSValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+        info.addMember(m_cssText);
+    }
+
 private:
     TextCloneCSSValue(ClassType classType, const String& text) 
         : CSSValue(classType, /*isCSSOMSafe*/ true)
@@ -141,6 +148,126 @@ bool CSSValue::hasFailedOrCanceledSubresources() const
     return false;
 }
 
+void CSSValue::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    if (m_isTextClone) {
+        ASSERT(isCSSOMSafe());
+        static_cast<const TextCloneCSSValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    }
+
+    ASSERT(!isCSSOMSafe() || isSubtypeExposedToCSSOM());
+    switch (classType()) {
+    case PrimitiveClass:
+        static_cast<const CSSPrimitiveValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case ImageClass:
+        static_cast<const CSSImageValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case CursorImageClass:
+        static_cast<const CSSCursorImageValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case CanvasClass:
+        static_cast<const CSSCanvasValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case CrossfadeClass:
+        static_cast<const CSSCrossfadeValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case LinearGradientClass:
+        static_cast<const CSSLinearGradientValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case RadialGradientClass:
+        static_cast<const CSSRadialGradientValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case CubicBezierTimingFunctionClass:
+        static_cast<const CSSCubicBezierTimingFunctionValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case LinearTimingFunctionClass:
+        static_cast<const CSSLinearTimingFunctionValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case StepsTimingFunctionClass:
+        static_cast<const CSSStepsTimingFunctionValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case AspectRatioClass:
+        static_cast<const CSSAspectRatioValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case BorderImageSliceClass:
+        static_cast<const CSSBorderImageSliceValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case FontFeatureClass:
+        static_cast<const FontFeatureValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case FontClass:
+        static_cast<const FontValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case FontFaceSrcClass:
+        static_cast<const CSSFontFaceSrcValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case FunctionClass:
+        static_cast<const CSSFunctionValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case InheritedClass:
+        static_cast<const CSSInheritedValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case InitialClass:
+        static_cast<const CSSInitialValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case ReflectClass:
+        static_cast<const CSSReflectValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case ShadowClass:
+        static_cast<const ShadowValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case UnicodeRangeClass:
+        static_cast<const CSSUnicodeRangeValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case LineBoxContainClass:
+        static_cast<const CSSLineBoxContainValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case CalculationClass:
+        static_cast<const CSSCalcValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+#if ENABLE(CSS_FILTERS) && ENABLE(CSS_SHADERS)
+    case WebKitCSSShaderClass:
+        static_cast<const WebKitCSSShaderValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+#endif
+#if ENABLE(CSS_VARIABLES)
+    case VariableClass:
+        static_cast<const CSSVariableValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+#endif
+#if ENABLE(SVG)
+    case SVGColorClass:
+        static_cast<const SVGColor*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case SVGPaintClass:
+        static_cast<const SVGPaint*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    case WebKitCSSSVGDocumentClass:
+        static_cast<const WebKitCSSSVGDocumentValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+#endif
+    case ValueListClass:
+        static_cast<const CSSValueList*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+#if ENABLE(CSS_IMAGE_SET)
+    case ImageSetClass:
+        static_cast<const CSSImageSetValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+#endif
+#if ENABLE(CSS_FILTERS)
+    case WebKitCSSFilterClass:
+        static_cast<const WebKitCSSFilterValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+#endif
+    case WebKitCSSTransformClass:
+        static_cast<const WebKitCSSTransformValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo);
+        return;
+    }
+    ASSERT_NOT_REACHED();
+}
+
 String CSSValue::cssText() const
 {
     if (m_isTextClone) {
index 83c2e8e..0572e2c 100644 (file)
@@ -29,6 +29,7 @@
 
 namespace WebCore {
 
+class MemoryObjectInfo;
 class StyleSheetContents;
     
 // FIXME: The current CSSValue and subclasses should be turned into internal types (StyleValue).
@@ -119,6 +120,8 @@ public:
 
     bool hasFailedOrCanceledSubresources() const;
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 protected:
 
     static const size_t ClassTypeBits = 5;
index b8d36a4..2ef3d51 100644 (file)
@@ -22,6 +22,7 @@
 #include "CSSValueList.h"
 
 #include "CSSParserValues.h"
+#include "MemoryInstrumentation.h"
 #include "PlatformString.h"
 #include <wtf/PassOwnPtr.h>
 #include <wtf/text/StringBuilder.h>
@@ -196,4 +197,10 @@ PassRefPtr<CSSValueList> CSSValueList::cloneForCSSOM() const
     return adoptRef(new CSSValueList(*this));
 }
 
+void CSSValueList::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<CSSValueList> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addInstrumentedVector(m_values);
+}
+
 } // namespace WebCore
index 40bb437..e988d6c 100644 (file)
@@ -69,6 +69,8 @@ public:
     
     PassRefPtr<CSSValueList> cloneForCSSOM() const;
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 protected:
     CSSValueList(ClassType, ValueListSeparator);
     CSSValueList(const CSSValueList& cloneFrom);
index 2c5b66a..93e0aa6 100644 (file)
@@ -34,6 +34,7 @@
 #include "CSSParserValues.h"
 #include "CSSPropertyNames.h"
 #include "CSSValue.h"
+#include "MemoryInstrumentation.h"
 
 namespace WebCore {
 
@@ -47,6 +48,13 @@ public:
     const AtomicString& name() const { return m_name; }
     const String& value() const { return m_value; }
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+    {
+        MemoryClassInfo<CSSVariableValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+        info.addMember(m_name);
+        info.addMember(m_value);
+    }
+
 private:
     CSSVariableValue(const AtomicString& name, const String& value)
         : CSSValue(VariableClass)
index 62c3960..69f542f 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "CSSParser.h"
 #include "CSSValueKeywords.h"
+#include "MemoryInstrumentation.h"
 #include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
@@ -49,4 +50,10 @@ String FontFeatureValue::customCssText() const
     return builder.toString();
 }
 
+void FontFeatureValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<FontFeatureValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addMember(m_tag);
+}
+
 }
index 7d5e036..28d89f4 100644 (file)
@@ -42,6 +42,8 @@ public:
     int value() const { return m_value; }
     String customCssText() const;
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     FontFeatureValue(const String&, int);
 
index 8841a79..656c7d8 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "CSSValueList.h"
 #include "CSSPrimitiveValue.h"
+#include "MemoryInstrumentation.h"
 #include "PlatformString.h"
 #include <wtf/text/StringBuilder.h>
 
@@ -65,4 +66,15 @@ String FontValue::customCssText() const
     return result.toString();
 }
 
+void FontValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<FontValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addInstrumentedMember(style);
+    info.addInstrumentedMember(variant);
+    info.addInstrumentedMember(weight);
+    info.addInstrumentedMember(size);
+    info.addInstrumentedMember(lineHeight);
+    info.addInstrumentedMember(family);
+}
+
 }
index 5f83369..03a6126 100644 (file)
@@ -39,6 +39,8 @@ public:
 
     String customCssText() const;
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
     RefPtr<CSSPrimitiveValue> style;
     RefPtr<CSSPrimitiveValue> variant;
     RefPtr<CSSPrimitiveValue> weight;
index 0390420..c269c3b 100644 (file)
@@ -114,6 +114,7 @@ void MediaQueryExp::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     MemoryClassInfo<MediaQueryExp> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
     info.addMember(m_mediaFeature);
     info.addMember(m_serializationCache);
+    info.addInstrumentedMember(m_value);
 }
 
 } // namespace
index 8a24859..73a4332 100644 (file)
@@ -135,7 +135,8 @@ void PropertySetCSSStyleDeclaration::reportMemoryUsage(MemoryObjectInfo* memoryO
 {
     MemoryClassInfo<PropertySetCSSStyleDeclaration> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
     info.addInstrumentedMember(m_propertySet);
-    // FIXME: add info.addInstrumentedHasMap(m_cssomCSSValueClones) when CSSValue is instrumented.
+    if (m_cssomCSSValueClones)
+        info.addInstrumentedMapEntries(*m_cssomCSSValueClones);
 }
 
 unsigned PropertySetCSSStyleDeclaration::length() const
index 14c7cda..db64669 100644 (file)
@@ -21,6 +21,7 @@
 #include "ShadowValue.h"
 
 #include "CSSPrimitiveValue.h"
+#include "MemoryInstrumentation.h"
 #include "PlatformString.h"
 
 namespace WebCore {
@@ -77,4 +78,15 @@ String ShadowValue::customCssText() const
     return text;
 }
 
+void ShadowValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<ShadowValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addInstrumentedMember(x);
+    info.addInstrumentedMember(y);
+    info.addInstrumentedMember(blur);
+    info.addInstrumentedMember(spread);
+    info.addInstrumentedMember(style);
+    info.addInstrumentedMember(color);
+}
+
 }
index 21547a5..f2d8e6f 100644 (file)
@@ -44,6 +44,8 @@ public:
 
     String customCssText() const;
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
     RefPtr<CSSPrimitiveValue> x;
     RefPtr<CSSPrimitiveValue> y;
     RefPtr<CSSPrimitiveValue> blur;
index 1e78aab..37d3971 100644 (file)
@@ -1092,6 +1092,9 @@ void StylePropertySet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) con
         info.addVectorPtr(m_mutablePropertyVector);
     else
         info.addRawBuffer(m_properties, m_arraySize * sizeof(CSSProperty));
+    unsigned count = propertyCount();
+    for (unsigned i = 0; i < count; ++i)
+        info.addInstrumentedMember(propertyAt(i));
 }
 
 // See the function above if you need to update this.
index adca8db..389dc1b 100644 (file)
@@ -5637,6 +5637,24 @@ void StyleResolver::loadPendingResources()
 #endif
 }
 
+void StyleResolver::MatchedProperties::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<StyleResolver::MatchedProperties> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addInstrumentedMember(properties);
+}
+
+void StyleResolver::MatchedPropertiesCacheItem::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<StyleResolver::MatchedPropertiesCacheItem> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addInstrumentedVector(matchedProperties);
+}
+
+void MediaQueryResult::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<MediaQueryResult> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addInstrumentedMember(m_expression);
+}
+
 void StyleResolver::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {
     MemoryClassInfo<StyleResolver> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
@@ -5647,18 +5665,23 @@ void StyleResolver::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     info.addInstrumentedMember(m_uncommonAttributeRuleSet);
     info.addHashMap(m_keyframesRuleMap);
     info.addHashMap(m_matchedPropertiesCache);
+    info.addInstrumentedMapValues(m_matchedPropertiesCache);
     info.addVector(m_matchedRules);
 
-    // FIXME: Instrument StaticCSSRuleList and add m_ruleList here.
+    info.addInstrumentedMember(m_ruleList);
     info.addHashMap(m_pendingImageProperties);
-    info.addVector(m_viewportDependentMediaQueryResults);
+    info.addInstrumentedMapValues(m_pendingImageProperties);
+    info.addInstrumentedMember(m_lineHeightValue);
+    info.addInstrumentedVector(m_viewportDependentMediaQueryResults);
     info.addHashMap(m_styleRuleToCSSOMWrapperMap);
-    info.addHashSet(m_styleSheetCSSOMWrapperSet);
+    info.addInstrumentedMapEntries(m_styleRuleToCSSOMWrapperMap);
+    info.addInstrumentedHashSet(m_styleSheetCSSOMWrapperSet);
 #if ENABLE(CSS_FILTERS) && ENABLE(SVG)
     info.addHashMap(m_pendingSVGDocuments);
 #endif
 #if ENABLE(STYLE_SCOPED)
     info.addHashMap(m_scopedAuthorStyles);
+    info.addInstrumentedMapEntries(m_scopedAuthorStyles);
     info.addVector(m_scopeStack);
 #endif
 
index d12c7b1..472efc9 100644 (file)
@@ -102,6 +102,7 @@ public:
         , m_result(result)
     {
     }
+    void reportMemoryUsage(MemoryObjectInfo*) const;
 
     MediaQueryExp m_expression;
     bool m_result;
@@ -320,6 +321,7 @@ private:
 
     struct MatchedProperties {
         MatchedProperties() : possiblyPaddedMember(0) { }
+        void reportMemoryUsage(MemoryObjectInfo*) const;
         
         RefPtr<StylePropertySet> properties;
         union {
@@ -447,6 +449,7 @@ private:
 
     static unsigned computeMatchedPropertiesHash(const MatchedProperties*, unsigned size);
     struct MatchedPropertiesCacheItem {
+        void reportMemoryUsage(MemoryObjectInfo*) const;
         Vector<MatchedProperties> matchedProperties;
         MatchRanges ranges;
         RefPtr<RenderStyle> renderStyle;
index 2916dc2..71d7b9f 100644 (file)
@@ -29,6 +29,7 @@
 #if ENABLE(CSS_FILTERS)
 
 #include "CSSValueList.h"
+#include "MemoryInstrumentation.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/text/WTFString.h>
 
@@ -110,6 +111,12 @@ PassRefPtr<WebKitCSSFilterValue> WebKitCSSFilterValue::cloneForCSSOM() const
     return adoptRef(new WebKitCSSFilterValue(*this));
 }
 
+void WebKitCSSFilterValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<WebKitCSSFilterValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    CSSValueList::reportDescendantMemoryUsage(memoryObjectInfo);
+}
+
 }
 
 #endif // ENABLE(CSS_FILTERS)
index a34d574..08b3e9f 100644 (file)
@@ -68,6 +68,8 @@ public:
 
     PassRefPtr<WebKitCSSFilterValue> cloneForCSSOM() const;
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     WebKitCSSFilterValue(FilterOperationType);
     WebKitCSSFilterValue(const WebKitCSSFilterValue& cloneFrom);
index 4902504..df41b8d 100644 (file)
@@ -30,6 +30,7 @@
 #include "CSSParser.h"
 #include "CachedResourceLoader.h"
 #include "Document.h"
+#include "MemoryInstrumentation.h"
 
 namespace WebCore {
 
@@ -63,6 +64,13 @@ String WebKitCSSSVGDocumentValue::customCssText() const
     return quoteCSSStringIfNeeded(m_url);
 }
 
+void WebKitCSSSVGDocumentValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<WebKitCSSSVGDocumentValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addMember(m_url);
+    // FIXME: add m_document when cached resources are instrumented.
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(SVG)
index cb03f56..96bcc8c 100644 (file)
@@ -45,6 +45,8 @@ public:
     const String& url() const { return m_url; }
     bool loadRequested() const { return m_loadRequested; }
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     WebKitCSSSVGDocumentValue(const String& url);
 
index 8651758..5ca7733 100644 (file)
@@ -35,6 +35,7 @@
 #include "CachedResourceLoader.h"
 #include "CSSParser.h"
 #include "Document.h"
+#include "MemoryInstrumentation.h"
 #include "StyleCachedShader.h"
 #include "StylePendingShader.h"
 
@@ -79,6 +80,12 @@ String WebKitCSSShaderValue::customCssText() const
     return "url(" + quoteCSSURLIfNeeded(m_url) + ")";
 }
 
+void WebKitCSSShaderValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<WebKitCSSShaderValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addMember(m_url);
+}
+    
 } // namespace WebCore
 
 #endif // ENABLE(CSS_SHADERS)
index fd95bc6..c43201c 100644 (file)
@@ -50,6 +50,8 @@ public:
 
     String customCssText() const;
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     WebKitCSSShaderValue(const String& url);
 
index 87ded7d..1cb73fc 100644 (file)
@@ -27,6 +27,7 @@
 #include "WebKitCSSTransformValue.h"
 
 #include "CSSValueList.h"
+#include "MemoryInstrumentation.h"
 #include "PlatformString.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/text/StringBuilder.h>
@@ -104,4 +105,10 @@ PassRefPtr<WebKitCSSTransformValue> WebKitCSSTransformValue::cloneForCSSOM() con
     return adoptRef(new WebKitCSSTransformValue(*this));
 }
 
+void WebKitCSSTransformValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<WebKitCSSTransformValue> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    CSSValueList::reportDescendantMemoryUsage(memoryObjectInfo);
+}
+
 }
index 5fc4f7d..fd117f2 100644 (file)
@@ -74,6 +74,8 @@ public:
     
     PassRefPtr<WebKitCSSTransformValue> cloneForCSSOM() const;
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     WebKitCSSTransformValue(TransformOperationType);
     WebKitCSSTransformValue(const WebKitCSSTransformValue& cloneFrom);
index 7dca5be..299e614 100644 (file)
@@ -38,9 +38,14 @@ namespace WebCore {
 
 void MemoryInstrumentation::addObject(const String& string, ObjectType objectType)
 {
-    if (string.isNull() || visited(string.impl()))
+    addObject(string.impl(), objectType);
+}
+
+void MemoryInstrumentation::addObject(const StringImpl* stringImpl, ObjectType objectType)
+{
+    if (!stringImpl || visited(stringImpl))
         return;
-    countObjectSize(objectType, string.impl()->sizeInBytes());
+    countObjectSize(objectType, stringImpl->sizeInBytes());
 }
 
 } // namespace WebCore
index 8834d37..6a8ec45 100644 (file)
@@ -102,11 +102,13 @@ private:
         OwningTraits<T>::addObject(this, t, ownerObjectType);
     }
     void addObject(const String&, ObjectType);
+    void addObject(const StringImpl*, ObjectType);
     template <typename T> void addInstrumentedObject(const T& t, ObjectType ownerObjectType) { OwningTraits<T>::addInstrumentedObject(this, t, ownerObjectType); }
-
     template <typename HashMapType> void addHashMap(const HashMapType&, ObjectType, bool contentOnly = false);
     template <typename HashSetType> void addHashSet(const HashSetType&, ObjectType, bool contentOnly = false);
     template <typename CollectionType> void addInstrumentedCollection(const CollectionType&, ObjectType, bool contentOnly = false);
+    template <typename MapType> void addInstrumentedMapEntries(const MapType&, ObjectType);
+    template <typename MapType> void addInstrumentedMapValues(const MapType&, ObjectType);
     template <typename ListHashSetType> void addListHashSet(const ListHashSetType&, ObjectType, bool contentOnly = false);
     template <typename VectorType> void addVector(const VectorType&, ObjectType, bool contentOnly = false);
     void addRawBuffer(const void* const& buffer, ObjectType ownerObjectType, size_t size)
@@ -190,10 +192,13 @@ public:
 
     template <typename HashMapType> void addHashMap(const HashMapType& map) { m_memoryInstrumentation->addHashMap(map, m_objectType, true); }
     template <typename HashSetType> void addHashSet(const HashSetType& set) { m_memoryInstrumentation->addHashSet(set, m_objectType, true); }
+    template <typename HashSetType> void addHashCountedSet(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 MapType> void addInstrumentedMapEntries(const MapType& map) { m_memoryInstrumentation->addInstrumentedMapEntries(map, m_objectType); }
+    template <typename MapType> void addInstrumentedMapValues(const MapType& map) { m_memoryInstrumentation->addInstrumentedMapValues(map, m_objectType); }
     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); }
@@ -201,6 +206,7 @@ public:
 
     void addMember(const String& string) { m_memoryInstrumentation->addObject(string, m_objectType); }
     void addMember(const AtomicString& string) { m_memoryInstrumentation->addObject((const String&)string, m_objectType); }
+    void addMember(const StringImpl* string) { m_memoryInstrumentation->addObject(string, m_objectType); }
 
 private:
     MemoryObjectInfo* m_memoryObjectInfo;
@@ -306,6 +312,24 @@ void MemoryInstrumentation::addInstrumentedCollection(const CollectionType& coll
         addInstrumentedObject(*i, ownerObjectType);
 }
 
+template <typename MapType>
+void MemoryInstrumentation::addInstrumentedMapEntries(const MapType& map, ObjectType ownerObjectType)
+{
+    typename MapType::const_iterator end = map.end();
+    for (typename MapType::const_iterator i = map.begin(); i != end; ++i) {
+        addInstrumentedObject(i->first, ownerObjectType);
+        addInstrumentedObject(i->second, ownerObjectType);
+    }
+}
+
+template <typename MapType>
+void MemoryInstrumentation::addInstrumentedMapValues(const MapType& map, ObjectType ownerObjectType)
+{
+    typename MapType::const_iterator end = map.end();
+    for (typename MapType::const_iterator i = map.begin(); i != end; ++i)
+        addInstrumentedObject(i->second, ownerObjectType);
+}
+
 template<typename ListHashSetType>
 void MemoryInstrumentation::addListHashSet(const ListHashSetType& hashSet, ObjectType ownerObjectType, bool contentOnly)
 {
index 2572b7b..0eded61 100644 (file)
@@ -25,6 +25,7 @@
 #include "SVGColor.h"
 
 #include "CSSParser.h"
+#include "MemoryInstrumentation.h"
 #include "RGBColor.h"
 #include "SVGException.h"
 
@@ -104,6 +105,11 @@ PassRefPtr<SVGColor> SVGColor::cloneForCSSOM() const
     return adoptRef(new SVGColor(SVGColorClass, *this));
 }
 
+void SVGColor::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<SVGColor> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+}
+
 }
 
 #endif // ENABLE(SVG)
index cffac53..7dddcd7 100644 (file)
@@ -75,6 +75,8 @@ public:
     
     PassRefPtr<SVGColor> cloneForCSSOM() const;
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 protected:
     friend class CSSComputedStyleDeclaration;
 
index 8cf3d7e..9c655b3 100644 (file)
@@ -24,6 +24,7 @@
 #if ENABLE(SVG)
 #include "SVGPaint.h"
 
+#include "MemoryInstrumentation.h"
 #include "SVGException.h"
 #include "SVGURIReference.h"
 #include <wtf/text/WTFString.h>
@@ -111,6 +112,12 @@ PassRefPtr<SVGPaint> SVGPaint::cloneForCSSOM() const
     return adoptRef(new SVGPaint(*this));
 }
 
+void SVGPaint::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo<SVGPaint> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+    info.addMember(m_uri);
+}
+
 }
 
 #endif // ENABLE(SVG)
index b053cbd..ac5675b 100644 (file)
@@ -95,6 +95,8 @@ public:
 
     PassRefPtr<SVGPaint> cloneForCSSOM() const;
 
+    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     friend class CSSComputedStyleDeclaration;