diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-08-12 09:27:39 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-08-12 09:27:39 +0200 |
commit | 3749d61e1f7a59f5ec5067e560af1eb610c82015 (patch) | |
tree | 73dc228333948738bbe02976cacca8cd382bc978 /Source/WebCore/css | |
parent | b32b4dcd9a51ab8de6afc53d9e17f8707e1f7a5e (diff) | |
download | qtwebkit-3749d61e1f7a59f5ec5067e560af1eb610c82015.tar.gz |
Imported WebKit commit a77350243e054f3460d1137301d8b3faee3d2052 (http://svn.webkit.org/repository/webkit/trunk@125365)
New snapshot with build fixes for latest API changes in Qt and all WK1 Win MSVC fixes upstream
Diffstat (limited to 'Source/WebCore/css')
125 files changed, 2229 insertions, 529 deletions
diff --git a/Source/WebCore/css/CSSAspectRatioValue.cpp b/Source/WebCore/css/CSSAspectRatioValue.cpp index 18b0ded67..5897f5111 100644 --- a/Source/WebCore/css/CSSAspectRatioValue.cpp +++ b/Source/WebCore/css/CSSAspectRatioValue.cpp @@ -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 info(memoryObjectInfo, this, MemoryInstrumentation::CSS); +} + } diff --git a/Source/WebCore/css/CSSAspectRatioValue.h b/Source/WebCore/css/CSSAspectRatioValue.h index 2f6b426d8..5cc339249 100644 --- a/Source/WebCore/css/CSSAspectRatioValue.h +++ b/Source/WebCore/css/CSSAspectRatioValue.h @@ -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) diff --git a/Source/WebCore/css/CSSBorderImageSliceValue.cpp b/Source/WebCore/css/CSSBorderImageSliceValue.cpp index 04ef2d366..551df1f60 100644 --- a/Source/WebCore/css/CSSBorderImageSliceValue.cpp +++ b/Source/WebCore/css/CSSBorderImageSliceValue.cpp @@ -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 info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedMember(m_slices); +} + } // namespace WebCore diff --git a/Source/WebCore/css/CSSBorderImageSliceValue.h b/Source/WebCore/css/CSSBorderImageSliceValue.h index d8230f474..488b4a41d 100644 --- a/Source/WebCore/css/CSSBorderImageSliceValue.h +++ b/Source/WebCore/css/CSSBorderImageSliceValue.h @@ -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; diff --git a/Source/WebCore/css/CSSCalculationValue.cpp b/Source/WebCore/css/CSSCalculationValue.cpp index 54247e035..5a10c5985 100755 --- a/Source/WebCore/css/CSSCalculationValue.cpp +++ b/Source/WebCore/css/CSSCalculationValue.cpp @@ -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 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 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 info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedMember(m_leftSide); + info.addInstrumentedMember(m_rightSide); + } + virtual String customCssText() const { StringBuilder result; diff --git a/Source/WebCore/css/CSSCalculationValue.h b/Source/WebCore/css/CSSCalculationValue.h index 57a249f89..b25f7b31a 100755 --- a/Source/WebCore/css/CSSCalculationValue.h +++ b/Source/WebCore/css/CSSCalculationValue.h @@ -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) diff --git a/Source/WebCore/css/CSSCanvasValue.cpp b/Source/WebCore/css/CSSCanvasValue.cpp index 783ceef82..4925b3938 100644 --- a/Source/WebCore/css/CSSCanvasValue.cpp +++ b/Source/WebCore/css/CSSCanvasValue.cpp @@ -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 info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + CSSImageGeneratorValue::reportBaseClassMemoryUsage(memoryObjectInfo); + info.addMember(m_name); + info.addInstrumentedMember(m_element); +} + } // namespace WebCore diff --git a/Source/WebCore/css/CSSCanvasValue.h b/Source/WebCore/css/CSSCanvasValue.h index 159e61956..13fb58741 100644 --- a/Source/WebCore/css/CSSCanvasValue.h +++ b/Source/WebCore/css/CSSCanvasValue.h @@ -47,6 +47,8 @@ public: bool isPending() const { return false; } void loadSubimages(CachedResourceLoader*) { } + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: CSSCanvasValue(const String& name) : CSSImageGeneratorValue(CanvasClass) diff --git a/Source/WebCore/css/CSSCharsetRule.cpp b/Source/WebCore/css/CSSCharsetRule.cpp index b7a77ac52..b7d201c86 100644 --- a/Source/WebCore/css/CSSCharsetRule.cpp +++ b/Source/WebCore/css/CSSCharsetRule.cpp @@ -21,6 +21,8 @@ #include "config.h" #include "CSSCharsetRule.h" +#include "MemoryInstrumentation.h" + namespace WebCore { CSSCharsetRule::CSSCharsetRule(CSSStyleSheet* parent, const String& encoding) @@ -34,4 +36,11 @@ String CSSCharsetRule::cssText() const return "@charset \"" + m_encoding + "\";"; } +void CSSCharsetRule::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + CSSRule::reportBaseClassMemoryUsage(memoryObjectInfo); + info.addMember(m_encoding); +} + } // namespace WebCore diff --git a/Source/WebCore/css/CSSCharsetRule.h b/Source/WebCore/css/CSSCharsetRule.h index d08efa7df..0dad47c9e 100644 --- a/Source/WebCore/css/CSSCharsetRule.h +++ b/Source/WebCore/css/CSSCharsetRule.h @@ -39,6 +39,8 @@ public: String cssText() const; + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: CSSCharsetRule(CSSStyleSheet* parent, const String& encoding); diff --git a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp index ae248ed09..7a050682d 100644 --- a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp +++ b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp @@ -46,6 +46,7 @@ #include "FontFeatureSettings.h" #include "FontFeatureValue.h" #include "FontValue.h" +#include "MemoryInstrumentation.h" #include "Pair.h" #include "Rect.h" #include "RenderBox.h" @@ -67,6 +68,7 @@ #include "CustomFilterNumberParameter.h" #include "CustomFilterOperation.h" #include "CustomFilterParameter.h" +#include "WebKitCSSMixFunctionValue.h" #endif #if ENABLE(CSS_FILTERS) @@ -74,7 +76,7 @@ #include "WebKitCSSFilterValue.h" #endif -#if ENABLE(DASHBOARD_SUPPORT) +#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION) #include "DashboardRegion.h" #endif @@ -174,6 +176,7 @@ static const CSSPropertyID computedProperties[] = { CSSPropertyTabSize, CSSPropertyTextAlign, CSSPropertyTextDecoration, + CSSPropertyWebkitTextDecorationLine, CSSPropertyTextIndent, CSSPropertyTextRendering, CSSPropertyTextShadow, @@ -340,6 +343,9 @@ static const CSSPropertyID computedProperties[] = { CSSPropertyWebkitRegionBreakBefore, CSSPropertyWebkitRegionBreakInside, #endif +#if ENABLE(WIDGET_REGION) + CSSPropertyWebkitWidgetRegion, +#endif #if ENABLE(CSS_EXCLUSIONS) CSSPropertyWebkitWrapFlow, CSSPropertyWebkitWrapMargin, @@ -874,10 +880,19 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForFilter(RenderStyle* st shadersList->append(program->vertexShader()->cssValue()); else shadersList->append(cssValuePool().createIdentifierValue(CSSValueNone)); - if (program->fragmentShader()) + + const CustomFilterProgramMixSettings mixSettings = program->mixSettings(); + if (mixSettings.enabled) { + RefPtr<WebKitCSSMixFunctionValue> mixFunction = WebKitCSSMixFunctionValue::create(); + mixFunction->append(program->fragmentShader()->cssValue()); + mixFunction->append(cssValuePool().createValue(mixSettings.blendMode)); + mixFunction->append(cssValuePool().createValue(mixSettings.compositeOperator)); + shadersList->append(mixFunction.release()); + } else if (program->fragmentShader()) shadersList->append(program->fragmentShader()->cssValue()); else shadersList->append(cssValuePool().createIdentifierValue(CSSValueNone)); + filterValue->append(shadersList.release()); RefPtr<CSSValueList> meshParameters = CSSValueList::createSpaceSeparated(); @@ -1176,6 +1191,7 @@ static PassRefPtr<CSSValue> renderUnicodeBidiFlagsToCSSValue(EUnicodeBidi unicod static PassRefPtr<CSSValue> renderTextDecorationFlagsToCSSValue(int textDecoration) { + // Blink value is ignored. RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); if (textDecoration & UNDERLINE) list->append(cssValuePool().createIdentifierValue(CSSValueUnderline)); @@ -1183,8 +1199,6 @@ static PassRefPtr<CSSValue> renderTextDecorationFlagsToCSSValue(int textDecorati list->append(cssValuePool().createIdentifierValue(CSSValueOverline)); if (textDecoration & LINE_THROUGH) list->append(cssValuePool().createIdentifierValue(CSSValueLineThrough)); - if (textDecoration & BLINK) - list->append(cssValuePool().createIdentifierValue(CSSValueBlink)); if (!list->length()) return cssValuePool().createIdentifierValue(CSSValueNone); @@ -1689,7 +1703,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert case CSSPropertyWebkitJustifyContent: return cssValuePool().createValue(style->justifyContent()); case CSSPropertyWebkitOrder: - return cssValuePool().createValue(style->order()); + return cssValuePool().createValue(style->order(), CSSPrimitiveValue::CSS_NUMBER); #endif case CSSPropertyFloat: return cssValuePool().createValue(style->floating()); @@ -1934,6 +1948,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert case CSSPropertyTextAlign: return cssValuePool().createValue(style->textAlign()); case CSSPropertyTextDecoration: + case CSSPropertyWebkitTextDecorationLine: return renderTextDecorationFlagsToCSSValue(style->textDecoration()); case CSSPropertyWebkitTextDecorationsInEffect: return renderTextDecorationFlagsToCSSValue(style->textDecorationsInEffect()); @@ -2072,8 +2087,13 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert if (style->boxSizing() == CONTENT_BOX) return cssValuePool().createIdentifierValue(CSSValueContentBox); return cssValuePool().createIdentifierValue(CSSValueBorderBox); +#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION) #if ENABLE(DASHBOARD_SUPPORT) case CSSPropertyWebkitDashboardRegion: +#endif +#if ENABLE(WIDGET_REGION) + case CSSPropertyWebkitWidgetRegion: +#endif { const Vector<StyleDashboardRegion>& regions = style->dashboardRegions(); unsigned count = regions.size(); @@ -2676,6 +2696,12 @@ PassRefPtr<StylePropertySet> CSSComputedStyleDeclaration::copyPropertiesInSet(co return StylePropertySet::create(list.data(), list.size()); } +void CSSComputedStyleDeclaration::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedMember(m_node); +} + CSSRule* CSSComputedStyleDeclaration::parentRule() const { return 0; diff --git a/Source/WebCore/css/CSSComputedStyleDeclaration.h b/Source/WebCore/css/CSSComputedStyleDeclaration.h index a236a7d21..10d01590a 100644 --- a/Source/WebCore/css/CSSComputedStyleDeclaration.h +++ b/Source/WebCore/css/CSSComputedStyleDeclaration.h @@ -72,6 +72,8 @@ public: PassRefPtr<StylePropertySet> copyPropertiesInSet(const CSSPropertyID* set, unsigned length) const; + virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE; + private: CSSComputedStyleDeclaration(PassRefPtr<Node>, bool allowVisitedStyle, const String&); diff --git a/Source/WebCore/css/CSSCrossfadeValue.cpp b/Source/WebCore/css/CSSCrossfadeValue.cpp index 4ff08afca..5ed7da18d 100644 --- a/Source/WebCore/css/CSSCrossfadeValue.cpp +++ b/Source/WebCore/css/CSSCrossfadeValue.cpp @@ -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 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()) @@ -172,4 +186,13 @@ void CSSCrossfadeValue::CrossfadeSubimageObserverProxy::imageChanged(CachedImage m_ownerValue->crossfadeChanged(*rect); } +bool CSSCrossfadeValue::hasFailedOrCanceledSubresources() const +{ + if (m_cachedFromImage && m_cachedFromImage->loadFailedOrCanceled()) + return true; + if (m_cachedToImage && m_cachedToImage->loadFailedOrCanceled()) + return true; + return false; +} + } // namespace WebCore diff --git a/Source/WebCore/css/CSSCrossfadeValue.h b/Source/WebCore/css/CSSCrossfadeValue.h index fb4c2e0d7..cb07abc3b 100644 --- a/Source/WebCore/css/CSSCrossfadeValue.h +++ b/Source/WebCore/css/CSSCrossfadeValue.h @@ -27,6 +27,7 @@ #define CSSCrossfadeValue_h #include "CachedImage.h" +#include "CachedImageClient.h" #include "CachedResourceHandle.h" #include "CSSImageGeneratorValue.h" #include "CSSPrimitiveValue.h" @@ -61,6 +62,10 @@ public: void setPercentage(PassRefPtr<CSSPrimitiveValue> percentageValue) { m_percentageValue = percentageValue; } + bool hasFailedOrCanceledSubresources() const; + + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: CSSCrossfadeValue(PassRefPtr<CSSValue> fromValue, PassRefPtr<CSSValue> toValue) : CSSImageGeneratorValue(CrossfadeClass) diff --git a/Source/WebCore/css/CSSCursorImageValue.cpp b/Source/WebCore/css/CSSCursorImageValue.cpp index f8506848f..35038fcd3 100644 --- a/Source/WebCore/css/CSSCursorImageValue.cpp +++ b/Source/WebCore/css/CSSCursorImageValue.cpp @@ -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 info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + CSSImageValue::reportDescendantMemoryUsage(memoryObjectInfo); +#if ENABLE(SVG) + info.addInstrumentedHashSet(m_referencedElements); +#endif +} + } // namespace WebCore diff --git a/Source/WebCore/css/CSSCursorImageValue.h b/Source/WebCore/css/CSSCursorImageValue.h index cb26919e4..dc8d1ff4c 100644 --- a/Source/WebCore/css/CSSCursorImageValue.h +++ b/Source/WebCore/css/CSSCursorImageValue.h @@ -48,6 +48,8 @@ public: void removeReferencedElement(SVGElement*); #endif + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: CSSCursorImageValue(const String& url, const IntPoint& hotSpot); diff --git a/Source/WebCore/css/CSSFontFaceRule.cpp b/Source/WebCore/css/CSSFontFaceRule.cpp index bcc8639ed..e85a6e44c 100644 --- a/Source/WebCore/css/CSSFontFaceRule.cpp +++ b/Source/WebCore/css/CSSFontFaceRule.cpp @@ -22,6 +22,7 @@ #include "config.h" #include "CSSFontFaceRule.h" +#include "MemoryInstrumentation.h" #include "StylePropertySet.h" #include "StyleRule.h" @@ -63,4 +64,12 @@ void CSSFontFaceRule::reattach(StyleRuleFontFace* rule) m_propertiesCSSOMWrapper->reattach(m_fontFaceRule->mutableProperties()); } +void CSSFontFaceRule::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + CSSRule::reportBaseClassMemoryUsage(memoryObjectInfo); + info.addInstrumentedMember(m_fontFaceRule); + info.addInstrumentedMember(m_propertiesCSSOMWrapper); +} + } // namespace WebCore diff --git a/Source/WebCore/css/CSSFontFaceRule.h b/Source/WebCore/css/CSSFontFaceRule.h index 6414c872c..f67362bb4 100644 --- a/Source/WebCore/css/CSSFontFaceRule.h +++ b/Source/WebCore/css/CSSFontFaceRule.h @@ -45,6 +45,8 @@ public: void reattach(StyleRuleFontFace*); + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: CSSFontFaceRule(StyleRuleFontFace*, CSSStyleSheet* parent); diff --git a/Source/WebCore/css/CSSFontFaceSrcValue.cpp b/Source/WebCore/css/CSSFontFaceSrcValue.cpp index 79ae0e741..a00115db1 100644 --- a/Source/WebCore/css/CSSFontFaceSrcValue.cpp +++ b/Source/WebCore/css/CSSFontFaceSrcValue.cpp @@ -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 { @@ -79,6 +81,13 @@ void CSSFontFaceSrcValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const addSubresourceURL(urls, styleSheet->completeURL(m_resource)); } +bool CSSFontFaceSrcValue::hasFailedOrCanceledSubresources() const +{ + if (!m_cachedFont) + return false; + return m_cachedFont->loadFailedOrCanceled(); +} + CachedFont* CSSFontFaceSrcValue::cachedFont(Document* document) { if (!m_cachedFont) { @@ -88,5 +97,16 @@ CachedFont* CSSFontFaceSrcValue::cachedFont(Document* document) return m_cachedFont.get(); } +void CSSFontFaceSrcValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo 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 +} + } diff --git a/Source/WebCore/css/CSSFontFaceSrcValue.h b/Source/WebCore/css/CSSFontFaceSrcValue.h index 94607fed0..4444c8606 100644 --- a/Source/WebCore/css/CSSFontFaceSrcValue.h +++ b/Source/WebCore/css/CSSFontFaceSrcValue.h @@ -67,8 +67,12 @@ public: void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*) const; + bool hasFailedOrCanceledSubresources() const; + CachedFont* cachedFont(Document*); + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: CSSFontFaceSrcValue(const String& resource, bool local) : CSSValue(FontFaceSrcClass) diff --git a/Source/WebCore/css/CSSFontSelector.cpp b/Source/WebCore/css/CSSFontSelector.cpp index 0a9a3a078..cc5ffa06c 100644 --- a/Source/WebCore/css/CSSFontSelector.cpp +++ b/Source/WebCore/css/CSSFontSelector.cpp @@ -578,6 +578,9 @@ void CSSFontSelector::beginLoadTimerFired(Timer<WebCore::CSSFontSelector>*) Vector<CachedResourceHandle<CachedFont> > fontsToBeginLoading; fontsToBeginLoading.swap(m_fontsToBeginLoading); + // CSSFontSelector could get deleted via beginLoadIfNeeded() or loadDone() unless protected. + RefPtr<CSSFontSelector> protect(this); + CachedResourceLoader* cachedResourceLoader = m_document->cachedResourceLoader(); for (size_t i = 0; i < fontsToBeginLoading.size(); ++i) { fontsToBeginLoading[i]->beginLoadIfNeeded(cachedResourceLoader); diff --git a/Source/WebCore/css/CSSFunctionValue.cpp b/Source/WebCore/css/CSSFunctionValue.cpp index 522ad9fd1..628a989ba 100644 --- a/Source/WebCore/css/CSSFunctionValue.cpp +++ b/Source/WebCore/css/CSSFunctionValue.cpp @@ -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 info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addMember(m_name); + info.addInstrumentedMember(m_args); +} + } diff --git a/Source/WebCore/css/CSSFunctionValue.h b/Source/WebCore/css/CSSFunctionValue.h index a35a1b17b..6b7fbc65e 100644 --- a/Source/WebCore/css/CSSFunctionValue.h +++ b/Source/WebCore/css/CSSFunctionValue.h @@ -42,6 +42,8 @@ public: String customCssText() const; + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: explicit CSSFunctionValue(CSSParserFunction*); diff --git a/Source/WebCore/css/CSSGradientValue.cpp b/Source/WebCore/css/CSSGradientValue.cpp index 3f1979fee..c7daacc87 100644 --- a/Source/WebCore/css/CSSGradientValue.cpp +++ b/Source/WebCore/css/CSSGradientValue.cpp @@ -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 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 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 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 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 diff --git a/Source/WebCore/css/CSSGradientValue.h b/Source/WebCore/css/CSSGradientValue.h index 0c7ef7764..882cc628f 100644 --- a/Source/WebCore/css/CSSGradientValue.h +++ b/Source/WebCore/css/CSSGradientValue.h @@ -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) diff --git a/Source/WebCore/css/CSSGrammar.y b/Source/WebCore/css/CSSGrammar.y index c7c10b541..29fab4ffe 100644 --- a/Source/WebCore/css/CSSGrammar.y +++ b/Source/WebCore/css/CSSGrammar.y @@ -53,14 +53,13 @@ using namespace HTMLNames; #define YYMAXDEPTH 10000 #define YYDEBUG 0 -// FIXME: Replace with %parse-param { CSSParser* parser } once we can depend on bison 2.x -#define YYPARSE_PARAM parser -#define YYLEX_PARAM parser - %} %pure_parser +%parse-param { CSSParser* parser } +%lex-param { CSSParser* parser } + %union { bool boolean; char character; @@ -71,7 +70,7 @@ using namespace HTMLNames; StyleRuleBase* rule; Vector<RefPtr<StyleRuleBase> >* ruleList; CSSParserSelector* selector; - Vector<OwnPtr<CSSParserSelector> >* selectorList; + CSSSelectorVector* selectorList; CSSSelector::MarginBoxType marginBox; CSSSelector::Relation relation; MediaQuerySet* mediaList; @@ -89,14 +88,14 @@ using namespace HTMLNames; %{ -static inline int cssyyerror(const char*) +static inline int cssyyerror(void*, const char*) { return 1; } -static int cssyylex(YYSTYPE* yylval, void* parser) +static int cssyylex(YYSTYPE* yylval, CSSParser* parser) { - return static_cast<CSSParser*>(parser)->lex(yylval); + return parser->lex(yylval); } %} @@ -314,13 +313,13 @@ stylesheet: webkit_rule: WEBKIT_RULE_SYM '{' maybe_space valid_rule maybe_space '}' { - static_cast<CSSParser*>(parser)->m_rule = $4; + parser->m_rule = $4; } ; webkit_keyframe_rule: WEBKIT_KEYFRAME_RULE_SYM '{' maybe_space keyframe_rule maybe_space '}' { - static_cast<CSSParser*>(parser)->m_keyframe = $4; + parser->m_keyframe = $4; } ; @@ -332,30 +331,27 @@ webkit_decls: webkit_value: WEBKIT_VALUE_SYM '{' maybe_space expr '}' { - CSSParser* p = static_cast<CSSParser*>(parser); if ($4) { - p->m_valueList = p->sinkFloatingValueList($4); - int oldParsedProperties = p->m_parsedProperties.size(); - if (!p->parseValue(p->m_id, p->m_important)) - p->rollbackLastProperties(p->m_parsedProperties.size() - oldParsedProperties); - p->m_valueList = nullptr; + parser->m_valueList = parser->sinkFloatingValueList($4); + int oldParsedProperties = parser->m_parsedProperties->size(); + if (!parser->parseValue(parser->m_id, parser->m_important)) + parser->rollbackLastProperties(parser->m_parsedProperties->size() - oldParsedProperties); + parser->m_valueList = nullptr; } } ; webkit_mediaquery: WEBKIT_MEDIAQUERY_SYM WHITESPACE maybe_space media_query '}' { - CSSParser* p = static_cast<CSSParser*>(parser); - p->m_mediaQuery = p->sinkFloatingMediaQuery($4); + parser->m_mediaQuery = parser->sinkFloatingMediaQuery($4); } ; webkit_selector: WEBKIT_SELECTOR_SYM '{' maybe_space selector_list '}' { if ($4) { - CSSParser* p = static_cast<CSSParser*>(parser); - if (p->m_selectorListForParseSelector) - p->m_selectorListForParseSelector->adoptSelectorVector(*$4); + if (parser->m_selectorListForParseSelector) + parser->m_selectorListForParseSelector->adoptSelectorVector(*$4); } } ; @@ -384,11 +380,10 @@ closing_brace: charset: CHARSET_SYM maybe_space STRING maybe_space ';' { - CSSParser* p = static_cast<CSSParser*>(parser); - if (p->m_styleSheet) - p->m_styleSheet->parserSetEncodingFromCharsetRule($3); - if (p->isExtractingSourceData() && p->m_currentRuleDataStack->isEmpty() && p->m_ruleSourceDataResult) - p->addNewRuleToSourceTree(CSSRuleSourceData::createUnknown()); + if (parser->m_styleSheet) + parser->m_styleSheet->parserSetEncodingFromCharsetRule($3); + if (parser->isExtractingSourceData() && parser->m_currentRuleDataStack->isEmpty() && parser->m_ruleSourceDataResult) + parser->addNewRuleToSourceTree(CSSRuleSourceData::createUnknown()); $$ = 0; } | CHARSET_SYM error invalid_block { @@ -410,9 +405,8 @@ ignored_charset: rule_list: /* empty */ | rule_list rule maybe_sgml { - CSSParser* p = static_cast<CSSParser*>(parser); - if ($2 && p->m_styleSheet) - p->m_styleSheet->parserAppendRule($2); + if ($2 && parser->m_styleSheet) + parser->m_styleSheet->parserAppendRule($2); } ; @@ -429,7 +423,7 @@ valid_rule: rule: valid_rule { - static_cast<CSSParser*>(parser)->m_hadSyntacticallyValidCSSRule = true; + parser->m_hadSyntacticallyValidCSSRule = true; } | ignored_charset | invalid_rule @@ -442,7 +436,7 @@ block_rule_list: $$ = $1; if ($2) { if (!$$) - $$ = static_cast<CSSParser*>(parser)->createRuleList(); + $$ = parser->createRuleList(); $$->append($2); } } @@ -466,42 +460,41 @@ block_rule: at_import_header_end_maybe_space: maybe_space { - CSSParser* p = static_cast<CSSParser*>(parser); - p->markRuleHeaderEnd(); - p->markRuleBodyStart(); + parser->markRuleHeaderEnd(); + parser->markRuleBodyStart(); } ; before_import_rule: /* empty */ { - static_cast<CSSParser*>(parser)->markRuleHeaderStart(CSSRuleSourceData::IMPORT_RULE); + parser->markRuleHeaderStart(CSSRuleSourceData::IMPORT_RULE); } ; import: before_import_rule IMPORT_SYM at_import_header_end_maybe_space string_or_uri maybe_space maybe_media_list ';' { - $$ = static_cast<CSSParser*>(parser)->createImportRule($4, $6); + $$ = parser->createImportRule($4, $6); } | before_import_rule IMPORT_SYM at_import_header_end_maybe_space string_or_uri maybe_space maybe_media_list TOKEN_EOF { - $$ = static_cast<CSSParser*>(parser)->createImportRule($4, $6); + $$ = parser->createImportRule($4, $6); } | before_import_rule IMPORT_SYM at_import_header_end_maybe_space string_or_uri maybe_space maybe_media_list invalid_block { $$ = 0; - static_cast<CSSParser*>(parser)->popRuleData(); + parser->popRuleData(); } | before_import_rule IMPORT_SYM error ';' { $$ = 0; - static_cast<CSSParser*>(parser)->popRuleData(); + parser->popRuleData(); } | before_import_rule IMPORT_SYM error invalid_block { $$ = 0; - static_cast<CSSParser*>(parser)->popRuleData(); + parser->popRuleData(); } ; namespace: NAMESPACE_SYM maybe_space maybe_ns_prefix string_or_uri maybe_space ';' { - static_cast<CSSParser*>(parser)->addNamespace($3, $4); + parser->addNamespace($3, $4); $$ = 0; } | NAMESPACE_SYM maybe_space maybe_ns_prefix string_or_uri maybe_space invalid_block { @@ -543,25 +536,24 @@ maybe_media_value: media_query_exp: '(' maybe_space media_feature maybe_space maybe_media_value ')' maybe_space { $3.lower(); - $$ = static_cast<CSSParser*>(parser)->createFloatingMediaQueryExp($3, $5); + $$ = parser->createFloatingMediaQueryExp($3, $5); } ; media_query_exp_list: media_query_exp { - CSSParser* p = static_cast<CSSParser*>(parser); - $$ = p->createFloatingMediaQueryExpList(); - $$->append(p->sinkFloatingMediaQueryExp($1)); + $$ = parser->createFloatingMediaQueryExpList(); + $$->append(parser->sinkFloatingMediaQueryExp($1)); } | media_query_exp_list maybe_space MEDIA_AND maybe_space media_query_exp { $$ = $1; - $$->append(static_cast<CSSParser*>(parser)->sinkFloatingMediaQueryExp($5)); + $$->append(parser->sinkFloatingMediaQueryExp($5)); } ; maybe_and_media_query_exp_list: /*empty*/ { - $$ = static_cast<CSSParser*>(parser)->createFloatingMediaQueryExpList(); + $$ = parser->createFloatingMediaQueryExpList(); } | MEDIA_AND maybe_space media_query_exp_list { $$ = $3; @@ -582,37 +574,33 @@ maybe_media_restrictor: media_query: media_query_exp_list { - CSSParser* p = static_cast<CSSParser*>(parser); - $$ = p->createFloatingMediaQuery(p->sinkFloatingMediaQueryExpList($1)); + $$ = parser->createFloatingMediaQuery(parser->sinkFloatingMediaQueryExpList($1)); } | maybe_media_restrictor maybe_space medium maybe_and_media_query_exp_list { - CSSParser* p = static_cast<CSSParser*>(parser); $3.lower(); - $$ = p->createFloatingMediaQuery($1, $3, p->sinkFloatingMediaQueryExpList($4)); + $$ = parser->createFloatingMediaQuery($1, $3, parser->sinkFloatingMediaQueryExpList($4)); } ; maybe_media_list: /* empty */ { - $$ = static_cast<CSSParser*>(parser)->createMediaQuerySet(); + $$ = parser->createMediaQuerySet(); } | media_list ; media_list: media_query { - CSSParser* p = static_cast<CSSParser*>(parser); - $$ = p->createMediaQuerySet(); - $$->addMediaQuery(p->sinkFloatingMediaQuery($1)); - p->updateLastMediaLine($$); + $$ = parser->createMediaQuerySet(); + $$->addMediaQuery(parser->sinkFloatingMediaQuery($1)); + parser->updateLastMediaLine($$); } | media_list ',' maybe_space media_query { $$ = $1; if ($$) { - CSSParser* p = static_cast<CSSParser*>(parser); - $$->addMediaQuery(p->sinkFloatingMediaQuery($4)); - p->updateLastMediaLine($$); + $$->addMediaQuery(parser->sinkFloatingMediaQuery($4)); + parser->updateLastMediaLine($$); } } | media_list error { @@ -622,32 +610,32 @@ media_list: at_rule_body_start: /* empty */ { - static_cast<CSSParser*>(parser)->markRuleBodyStart(); + parser->markRuleBodyStart(); } ; before_media_rule: /* empty */ { - static_cast<CSSParser*>(parser)->markRuleHeaderStart(CSSRuleSourceData::MEDIA_RULE); + parser->markRuleHeaderStart(CSSRuleSourceData::MEDIA_RULE); } ; at_rule_header_end_maybe_space: maybe_space { - static_cast<CSSParser*>(parser)->markRuleHeaderEnd(); + parser->markRuleHeaderEnd(); } ; media: before_media_rule MEDIA_SYM maybe_space media_list at_rule_header_end '{' at_rule_body_start maybe_space block_rule_list save_block { - $$ = static_cast<CSSParser*>(parser)->createMediaRule($4, $9); + $$ = parser->createMediaRule($4, $9); } | before_media_rule MEDIA_SYM at_rule_header_end_maybe_space '{' at_rule_body_start maybe_space block_rule_list save_block { - $$ = static_cast<CSSParser*>(parser)->createMediaRule(0, $7); + $$ = parser->createMediaRule(0, $7); } | before_media_rule MEDIA_SYM at_rule_header_end_maybe_space ';' { $$ = 0; - static_cast<CSSParser*>(parser)->popRuleData(); + parser->popRuleData(); } ; @@ -659,13 +647,13 @@ medium: before_keyframes_rule: /* empty */ { - static_cast<CSSParser*>(parser)->markRuleHeaderStart(CSSRuleSourceData::KEYFRAMES_RULE); + parser->markRuleHeaderStart(CSSRuleSourceData::KEYFRAMES_RULE); } ; keyframes: before_keyframes_rule WEBKIT_KEYFRAMES_SYM maybe_space keyframe_name at_rule_header_end_maybe_space '{' at_rule_body_start maybe_space keyframes_rule closing_brace { - $$ = static_cast<CSSParser*>(parser)->createKeyframesRule($4, static_cast<CSSParser*>(parser)->sinkFloatingKeyframeVector($9)); + $$ = parser->createKeyframesRule($4, parser->sinkFloatingKeyframeVector($9)); } ; @@ -675,7 +663,7 @@ keyframe_name: ; keyframes_rule: - /* empty */ { $$ = static_cast<CSSParser*>(parser)->createFloatingKeyframeVector(); } + /* empty */ { $$ = parser->createFloatingKeyframeVector(); } | keyframes_rule keyframe_rule maybe_space { $$ = $1; if ($2) @@ -685,21 +673,19 @@ keyframes_rule: keyframe_rule: key_list maybe_space '{' maybe_space declaration_list '}' { - $$ = static_cast<CSSParser*>(parser)->createKeyframe($1); + $$ = parser->createKeyframe($1); } ; key_list: key { - CSSParser* p = static_cast<CSSParser*>(parser); - $$ = p->createFloatingValueList(); - $$->addValue(p->sinkFloatingValue($1)); + $$ = parser->createFloatingValueList(); + $$->addValue(parser->sinkFloatingValue($1)); } | key_list maybe_space ',' maybe_space key { - CSSParser* p = static_cast<CSSParser*>(parser); $$ = $1; if ($$) - $$->addValue(p->sinkFloatingValue($5)); + $$->addValue(parser->sinkFloatingValue($5)); } ; @@ -719,46 +705,43 @@ key: before_page_rule: /* empty */ { - static_cast<CSSParser*>(parser)->markRuleHeaderStart(CSSRuleSourceData::PAGE_RULE); + parser->markRuleHeaderStart(CSSRuleSourceData::PAGE_RULE); } ; page: before_page_rule PAGE_SYM maybe_space page_selector at_rule_header_end_maybe_space '{' at_rule_body_start maybe_space_before_declaration declarations_and_margins closing_brace { - CSSParser* p = static_cast<CSSParser*>(parser); if ($4) - $$ = p->createPageRule(p->sinkFloatingSelector($4)); + $$ = parser->createPageRule(parser->sinkFloatingSelector($4)); else { // Clear properties in the invalid @page rule. - p->clearProperties(); + parser->clearProperties(); // Also clear margin at-rules here once we fully implement margin at-rules parsing. $$ = 0; - static_cast<CSSParser*>(parser)->popRuleData(); + parser->popRuleData(); } } | before_page_rule PAGE_SYM error invalid_block { - static_cast<CSSParser*>(parser)->popRuleData(); + parser->popRuleData(); $$ = 0; } | before_page_rule PAGE_SYM error ';' { - static_cast<CSSParser*>(parser)->popRuleData(); + parser->popRuleData(); $$ = 0; } ; page_selector: IDENT { - CSSParser* p = static_cast<CSSParser*>(parser); - $$ = p->createFloatingSelector(); - $$->setTag(QualifiedName(nullAtom, $1, p->m_defaultNamespace)); + $$ = parser->createFloatingSelector(); + $$->setTag(QualifiedName(nullAtom, $1, parser->m_defaultNamespace)); $$->setForPage(); } | IDENT pseudo_page { - CSSParser* p = static_cast<CSSParser*>(parser); $$ = $2; if ($$) { - $$->setTag(QualifiedName(nullAtom, $1, p->m_defaultNamespace)); + $$->setTag(QualifiedName(nullAtom, $1, parser->m_defaultNamespace)); $$->setForPage(); } } @@ -768,8 +751,7 @@ page_selector: $$->setForPage(); } | /* empty */ { - CSSParser* p = static_cast<CSSParser*>(parser); - $$ = p->createFloatingSelector(); + $$ = parser->createFloatingSelector(); $$->setForPage(); } ; @@ -781,9 +763,9 @@ declarations_and_margins: margin_box: margin_sym { - static_cast<CSSParser*>(parser)->startDeclarationsForMarginBox(); + parser->startDeclarationsForMarginBox(); } maybe_space '{' maybe_space declaration_list closing_brace { - $$ = static_cast<CSSParser*>(parser)->createMarginAtRule($1); + $$ = parser->createMarginAtRule($1); } ; @@ -840,42 +822,50 @@ margin_sym : before_font_face_rule: /* empty */ { - static_cast<CSSParser*>(parser)->markRuleHeaderStart(CSSRuleSourceData::FONT_FACE_RULE); + parser->markRuleHeaderStart(CSSRuleSourceData::FONT_FACE_RULE); } ; font_face: before_font_face_rule FONT_FACE_SYM at_rule_header_end_maybe_space '{' at_rule_body_start maybe_space_before_declaration declaration_list closing_brace { - $$ = static_cast<CSSParser*>(parser)->createFontFaceRule(); + $$ = parser->createFontFaceRule(); } | before_font_face_rule FONT_FACE_SYM error invalid_block { $$ = 0; - static_cast<CSSParser*>(parser)->popRuleData(); + parser->popRuleData(); } | before_font_face_rule FONT_FACE_SYM error ';' { $$ = 0; - static_cast<CSSParser*>(parser)->popRuleData(); + parser->popRuleData(); } ; region_selector: selector_list { if ($1) { - static_cast<CSSParser*>(parser)->setReusableRegionSelectorVector($1); - $$ = static_cast<CSSParser*>(parser)->reusableRegionSelectorVector(); + parser->setReusableRegionSelectorVector($1); + $$ = parser->reusableRegionSelectorVector(); } else $$ = 0; } ; +before_region_rule: + /* empty */ { + parser->markRuleHeaderStart(CSSRuleSourceData::REGION_RULE); + } + ; + region: - WEBKIT_REGION_RULE_SYM WHITESPACE region_selector '{' maybe_space block_rule_list save_block { - if ($3) - $$ = static_cast<CSSParser*>(parser)->createRegionRule($3, $6); - else + before_region_rule WEBKIT_REGION_RULE_SYM WHITESPACE region_selector at_rule_header_end '{' at_rule_body_start maybe_space block_rule_list save_block { + if ($4) + $$ = parser->createRegionRule($4, $9); + else { $$ = 0; + parser->popRuleData(); + } } ; @@ -897,45 +887,42 @@ unary_operator: maybe_space_before_declaration: maybe_space { - static_cast<CSSParser*>(parser)->markPropertyStart(); + parser->markPropertyStart(); } ; before_selector_list: /* empty */ { - static_cast<CSSParser*>(parser)->markRuleHeaderStart(CSSRuleSourceData::STYLE_RULE); + parser->markRuleHeaderStart(CSSRuleSourceData::STYLE_RULE); } ; at_rule_header_end: /* empty */ { - static_cast<CSSParser*>(parser)->markRuleHeaderEnd(); + parser->markRuleHeaderEnd(); } ; ruleset: - before_selector_list selector_list at_rule_header_end '{' maybe_space_before_declaration declaration_list closing_brace { - CSSParser* p = static_cast<CSSParser*>(parser); - $$ = p->createStyleRule($2); + before_selector_list selector_list at_rule_header_end '{' at_rule_body_start maybe_space_before_declaration declaration_list closing_brace { + $$ = parser->createStyleRule($2); } ; selector_list: selector %prec UNIMPORTANT_TOK { if ($1) { - CSSParser* p = static_cast<CSSParser*>(parser); - $$ = p->reusableSelectorVector(); + $$ = parser->selectorVector(); $$->shrink(0); - $$->append(p->sinkFloatingSelector($1)); - p->updateLastSelectorLineAndPosition(); + $$->append(parser->sinkFloatingSelector($1)); + parser->updateLastSelectorLineAndPosition(); } } | selector_list ',' maybe_space selector %prec UNIMPORTANT_TOK { if ($1 && $4) { - CSSParser* p = static_cast<CSSParser*>(parser); $$ = $1; - $$->append(p->sinkFloatingSelector($4)); - p->updateLastSelectorLineAndPosition(); + $$->append(parser->sinkFloatingSelector($4)); + parser->updateLastSelectorLineAndPosition(); } else $$ = 0; } @@ -964,12 +951,11 @@ selector: if (!$1) $$ = 0; else if ($$) { - CSSParser* p = static_cast<CSSParser*>(parser); CSSParserSelector* end = $$; while (end->tagHistory()) end = end->tagHistory(); end->setRelation(CSSSelector::Descendant); - end->setTagHistory(p->sinkFloatingSelector($1)); + end->setTagHistory(parser->sinkFloatingSelector($1)); } } | selector combinator simple_selector { @@ -977,12 +963,11 @@ selector: if (!$1) $$ = 0; else if ($$) { - CSSParser* p = static_cast<CSSParser*>(parser); CSSParserSelector* end = $$; while (end->tagHistory()) end = end->tagHistory(); end->setRelation($2); - end->setTagHistory(p->sinkFloatingSelector($1)); + end->setTagHistory(parser->sinkFloatingSelector($1)); } } | selector error { @@ -998,51 +983,47 @@ namespace_selector: simple_selector: element_name { - CSSParser* p = static_cast<CSSParser*>(parser); - $$ = p->createFloatingSelector(); - $$->setTag(QualifiedName(nullAtom, $1, p->m_defaultNamespace)); + $$ = parser->createFloatingSelector(); + $$->setTag(QualifiedName(nullAtom, $1, parser->m_defaultNamespace)); } | element_name specifier_list { $$ = $2; if ($$) - static_cast<CSSParser*>(parser)->updateSpecifiersWithElementName(nullAtom, $1, $$); + parser->updateSpecifiersWithElementName(nullAtom, $1, $$); } | specifier_list { $$ = $1; if ($$) - static_cast<CSSParser*>(parser)->updateSpecifiersWithElementName(nullAtom, starAtom, $$); + parser->updateSpecifiersWithElementName(nullAtom, starAtom, $$); } | namespace_selector element_name { - CSSParser* p = static_cast<CSSParser*>(parser); - $$ = p->createFloatingSelector(); - $$->setTag(p->determineNameInNamespace($1, $2)); + $$ = parser->createFloatingSelector(); + $$->setTag(parser->determineNameInNamespace($1, $2)); } | namespace_selector element_name specifier_list { $$ = $3; if ($$) - static_cast<CSSParser*>(parser)->updateSpecifiersWithElementName($1, $2, $$); + parser->updateSpecifiersWithElementName($1, $2, $$); } | namespace_selector specifier_list { $$ = $2; if ($$) - static_cast<CSSParser*>(parser)->updateSpecifiersWithElementName($1, starAtom, $$); + parser->updateSpecifiersWithElementName($1, starAtom, $$); } ; simple_selector_list: simple_selector %prec UNIMPORTANT_TOK { if ($1) { - CSSParser* p = static_cast<CSSParser*>(parser); - $$ = p->createFloatingSelectorVector(); - $$->append(p->sinkFloatingSelector($1)); + $$ = parser->createFloatingSelectorVector(); + $$->append(parser->sinkFloatingSelector($1)); } else $$ = 0; } | simple_selector_list maybe_space ',' maybe_space simple_selector %prec UNIMPORTANT_TOK { if ($1 && $5) { - CSSParser* p = static_cast<CSSParser*>(parser); $$ = $1; - $$->append(p->sinkFloatingSelector($5)); + $$->append(parser->sinkFloatingSelector($5)); } else $$ = 0; } @@ -1054,8 +1035,7 @@ simple_selector_list: element_name: IDENT { CSSParserString& str = $1; - CSSParser* p = static_cast<CSSParser*>(parser); - if (p->m_context.isHTMLDocument) + if (parser->m_context.isHTMLDocument) str.lower(); $$ = str; } @@ -1074,7 +1054,7 @@ specifier_list: if (!$2) $$ = 0; else if ($1) - $$ = static_cast<CSSParser*>(parser)->updateSpecifiers($1, $2); + $$ = parser->updateSpecifiers($1, $2); } | specifier_list error { $$ = 0; @@ -1083,10 +1063,9 @@ specifier_list: specifier: IDSEL { - CSSParser* p = static_cast<CSSParser*>(parser); - $$ = p->createFloatingSelector(); + $$ = parser->createFloatingSelector(); $$->setMatch(CSSSelector::Id); - if (p->m_context.mode == CSSQuirksMode) + if (parser->m_context.mode == CSSQuirksMode) $1.lower(); $$->setValue($1); } @@ -1094,10 +1073,9 @@ specifier: if ($1.characters[0] >= '0' && $1.characters[0] <= '9') { $$ = 0; } else { - CSSParser* p = static_cast<CSSParser*>(parser); - $$ = p->createFloatingSelector(); + $$ = parser->createFloatingSelector(); $$->setMatch(CSSSelector::Id); - if (p->m_context.mode == CSSQuirksMode) + if (parser->m_context.mode == CSSQuirksMode) $1.lower(); $$->setValue($1); } @@ -1109,10 +1087,9 @@ specifier: class: '.' IDENT { - CSSParser* p = static_cast<CSSParser*>(parser); - $$ = p->createFloatingSelector(); + $$ = parser->createFloatingSelector(); $$->setMatch(CSSSelector::Class); - if (p->m_context.mode == CSSQuirksMode) + if (parser->m_context.mode == CSSQuirksMode) $2.lower(); $$->setValue($2); } @@ -1121,8 +1098,7 @@ class: attr_name: IDENT maybe_space { CSSParserString& str = $1; - CSSParser* p = static_cast<CSSParser*>(parser); - if (p->m_context.isHTMLDocument) + if (parser->m_context.isHTMLDocument) str.lower(); $$ = str; } @@ -1130,26 +1106,24 @@ attr_name: attrib: '[' maybe_space attr_name ']' { - $$ = static_cast<CSSParser*>(parser)->createFloatingSelector(); + $$ = parser->createFloatingSelector(); $$->setAttribute(QualifiedName(nullAtom, $3, nullAtom)); $$->setMatch(CSSSelector::Set); } | '[' maybe_space attr_name match maybe_space ident_or_string maybe_space ']' { - $$ = static_cast<CSSParser*>(parser)->createFloatingSelector(); + $$ = parser->createFloatingSelector(); $$->setAttribute(QualifiedName(nullAtom, $3, nullAtom)); $$->setMatch((CSSSelector::Match)$4); $$->setValue($6); } | '[' maybe_space namespace_selector attr_name ']' { - CSSParser* p = static_cast<CSSParser*>(parser); - $$ = p->createFloatingSelector(); - $$->setAttribute(p->determineNameInNamespace($3, $4)); + $$ = parser->createFloatingSelector(); + $$->setAttribute(parser->determineNameInNamespace($3, $4)); $$->setMatch(CSSSelector::Set); } | '[' maybe_space namespace_selector attr_name match maybe_space ident_or_string maybe_space ']' { - CSSParser* p = static_cast<CSSParser*>(parser); - $$ = p->createFloatingSelector(); - $$->setAttribute(p->determineNameInNamespace($3, $4)); + $$ = parser->createFloatingSelector(); + $$->setAttribute(parser->determineNameInNamespace($3, $4)); $$->setMatch((CSSSelector::Match)$5); $$->setValue($7); } @@ -1183,7 +1157,7 @@ ident_or_string: pseudo_page: ':' IDENT { - $$ = static_cast<CSSParser*>(parser)->createFloatingSelector(); + $$ = parser->createFloatingSelector(); $$->setMatch(CSSSelector::PagePseudoClass); $2.lower(); $$->setValue($2); @@ -1194,7 +1168,7 @@ pseudo_page: pseudo: ':' IDENT { - $$ = static_cast<CSSParser*>(parser)->createFloatingSelector(); + $$ = parser->createFloatingSelector(); $$->setMatch(CSSSelector::PseudoClass); $2.lower(); $$->setValue($2); @@ -1203,7 +1177,7 @@ pseudo: $$ = 0; } | ':' ':' IDENT { - $$ = static_cast<CSSParser*>(parser)->createFloatingSelector(); + $$ = parser->createFloatingSelector(); $$->setMatch(CSSSelector::PseudoElement); $3.lower(); $$->setValue($3); @@ -1217,10 +1191,9 @@ pseudo: // related discussion with respect to :not. | ':' ANYFUNCTION maybe_space simple_selector_list maybe_space ')' { if ($4) { - CSSParser *p = static_cast<CSSParser*>(parser); - $$ = p->createFloatingSelector(); + $$ = parser->createFloatingSelector(); $$->setMatch(CSSSelector::PseudoClass); - $$->adoptSelectorVector(*p->sinkFloatingSelectorVector($4)); + $$->adoptSelectorVector(*parser->sinkFloatingSelectorVector($4)); $2.lower(); $$->setValue($2); CSSSelector::PseudoType type = $$->pseudoType(); @@ -1231,8 +1204,7 @@ pseudo: } // used by :nth-*(ax+b) | ':' FUNCTION maybe_space NTH maybe_space ')' { - CSSParser *p = static_cast<CSSParser*>(parser); - $$ = p->createFloatingSelector(); + $$ = parser->createFloatingSelector(); $$->setMatch(CSSSelector::PseudoClass); $$->setArgument($4); $$->setValue($2); @@ -1242,8 +1214,7 @@ pseudo: } // used by :nth-* | ':' FUNCTION maybe_space maybe_unary_operator INTEGER maybe_space ')' { - CSSParser *p = static_cast<CSSParser*>(parser); - $$ = p->createFloatingSelector(); + $$ = parser->createFloatingSelector(); $$->setMatch(CSSSelector::PseudoClass); $$->setArgument(String::number($4 * $5)); $$->setValue($2); @@ -1253,8 +1224,7 @@ pseudo: } // used by :nth-*(odd/even) and :lang | ':' FUNCTION maybe_space IDENT maybe_space ')' { - CSSParser *p = static_cast<CSSParser*>(parser); - $$ = p->createFloatingSelector(); + $$ = parser->createFloatingSelector(); $$->setMatch(CSSSelector::PseudoClass); $$->setArgument($4); $2.lower(); @@ -1275,12 +1245,11 @@ pseudo: if (!$4 || !$4->isSimple()) $$ = 0; else { - CSSParser* p = static_cast<CSSParser*>(parser); - $$ = p->createFloatingSelector(); + $$ = parser->createFloatingSelector(); $$->setMatch(CSSSelector::PseudoClass); - Vector<OwnPtr<CSSParserSelector> > selectorVector; - selectorVector.append(p->sinkFloatingSelector($4)); + CSSSelectorVector selectorVector; + selectorVector.append(parser->sinkFloatingSelector($4)); $$->adoptSelectorVector(selectorVector); $2.lower(); @@ -1317,8 +1286,7 @@ declaration_list: decl_list: declaration ';' maybe_space { - CSSParser* p = static_cast<CSSParser*>(parser); - p->markPropertyStart(); + parser->markPropertyStart(); $$ = $1; } | declaration invalid_block_list maybe_space { @@ -1328,28 +1296,24 @@ decl_list: $$ = false; } | error ';' maybe_space { - CSSParser* p = static_cast<CSSParser*>(parser); - p->markPropertyStart(); + parser->markPropertyStart(); $$ = false; } | error invalid_block_list error ';' maybe_space { $$ = false; } | decl_list declaration ';' maybe_space { - CSSParser* p = static_cast<CSSParser*>(parser); - p->markPropertyStart(); + parser->markPropertyStart(); $$ = $1; if ($2) $$ = $2; } | decl_list error ';' maybe_space { - CSSParser* p = static_cast<CSSParser*>(parser); - p->markPropertyStart(); + parser->markPropertyStart(); $$ = $1; } | decl_list error invalid_block_list error ';' maybe_space { - CSSParser* p = static_cast<CSSParser*>(parser); - p->markPropertyStart(); + parser->markPropertyStart(); $$ = $1; } ; @@ -1357,10 +1321,9 @@ decl_list: declaration: VAR_DEFINITION ':' maybe_space expr prio { #if ENABLE(CSS_VARIABLES) - CSSParser* p = static_cast<CSSParser*>(parser); - p->storeVariableDeclaration($1, p->sinkFloatingValueList($4), $5); + parser->storeVariableDeclaration($1, parser->sinkFloatingValueList($4), $5); $$ = true; - p->markPropertyEnd($5, true); + parser->markPropertyEnd($5, true); #else $$ = false; #endif @@ -1368,19 +1331,18 @@ declaration: | property ':' maybe_space expr prio { $$ = false; - CSSParser* p = static_cast<CSSParser*>(parser); bool isPropertyParsed = false; if ($1 && $4) { - p->m_valueList = p->sinkFloatingValueList($4); - int oldParsedProperties = p->m_parsedProperties.size(); - $$ = p->parseValue(static_cast<CSSPropertyID>($1), $5); + parser->m_valueList = parser->sinkFloatingValueList($4); + int oldParsedProperties = parser->m_parsedProperties->size(); + $$ = parser->parseValue(static_cast<CSSPropertyID>($1), $5); if (!$$) - p->rollbackLastProperties(p->m_parsedProperties.size() - oldParsedProperties); + parser->rollbackLastProperties(parser->m_parsedProperties->size() - oldParsedProperties); else isPropertyParsed = true; - p->m_valueList = nullptr; + parser->m_valueList = nullptr; } - p->markPropertyEnd($5, isPropertyParsed); + parser->markPropertyEnd($5, isPropertyParsed); } | property error { @@ -1391,15 +1353,13 @@ declaration: /* The default movable type template has letter-spacing: .none; Handle this by looking for error tokens at the start of an expr, recover the expr and then treat as an error, cleaning up and deleting the shifted expr. */ - CSSParser* p = static_cast<CSSParser*>(parser); - p->markPropertyEnd(false, false); + parser->markPropertyEnd(false, false); $$ = false; } | property ':' maybe_space expr prio error { /* When we encounter something like p {color: red !important fail;} we should drop the declaration */ - CSSParser* p = static_cast<CSSParser*>(parser); - p->markPropertyEnd(false, false); + parser->markPropertyEnd(false, false); $$ = false; } | @@ -1410,15 +1370,13 @@ declaration: | property ':' maybe_space { /* div { font-family: } Just reduce away this property with no value. */ - CSSParser* p = static_cast<CSSParser*>(parser); - p->markPropertyEnd(false, false); + parser->markPropertyEnd(false, false); $$ = false; } | property ':' maybe_space error { /* if we come across rules with invalid values like this case: p { weight: *; }, just discard the rule */ - CSSParser* p = static_cast<CSSParser*>(parser); - p->markPropertyEnd(false, false); + parser->markPropertyEnd(false, false); $$ = false; } | @@ -1441,12 +1399,10 @@ prio: expr: term { - CSSParser* p = static_cast<CSSParser*>(parser); - $$ = p->createFloatingValueList(); - $$->addValue(p->sinkFloatingValue($1)); + $$ = parser->createFloatingValueList(); + $$->addValue(parser->sinkFloatingValue($1)); } | expr operator term { - CSSParser* p = static_cast<CSSParser*>(parser); $$ = $1; if ($$) { if ($2) { @@ -1456,7 +1412,7 @@ expr: v.iValue = $2; $$->addValue(v); } - $$->addValue(p->sinkFloatingValue($3)); + $$->addValue(parser->sinkFloatingValue($3)); } } | expr invalid_block_list { @@ -1545,9 +1501,8 @@ unary_term: $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_REMS; - CSSParser* p = static_cast<CSSParser*>(parser); - if (p->m_styleSheet) - p->m_styleSheet->parserSetUsesRemUnits(true); + if (parser->m_styleSheet) + parser->m_styleSheet->parserSetUsesRemUnits(true); } | VW maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VW; } | VH maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VH; } @@ -1559,36 +1514,32 @@ unary_term: function: FUNCTION maybe_space expr ')' maybe_space { - CSSParser* p = static_cast<CSSParser*>(parser); - CSSParserFunction* f = p->createFloatingFunction(); + CSSParserFunction* f = parser->createFloatingFunction(); f->name = $1; - f->args = p->sinkFloatingValueList($3); + f->args = parser->sinkFloatingValueList($3); $$.id = 0; $$.unit = CSSParserValue::Function; $$.function = f; } | FUNCTION maybe_space expr TOKEN_EOF { - CSSParser* p = static_cast<CSSParser*>(parser); - CSSParserFunction* f = p->createFloatingFunction(); + CSSParserFunction* f = parser->createFloatingFunction(); f->name = $1; - f->args = p->sinkFloatingValueList($3); + f->args = parser->sinkFloatingValueList($3); $$.id = 0; $$.unit = CSSParserValue::Function; $$.function = f; } | FUNCTION maybe_space ')' maybe_space { - CSSParser* p = static_cast<CSSParser*>(parser); - CSSParserFunction* f = p->createFloatingFunction(); + CSSParserFunction* f = parser->createFloatingFunction(); f->name = $1; - CSSParserValueList* valueList = p->createFloatingValueList(); - f->args = p->sinkFloatingValueList(valueList); + CSSParserValueList* valueList = parser->createFloatingValueList(); + f->args = parser->sinkFloatingValueList(valueList); $$.id = 0; $$.unit = CSSParserValue::Function; $$.function = f; } | FUNCTION maybe_space error { - CSSParser* p = static_cast<CSSParser*>(parser); - CSSParserFunction* f = p->createFloatingFunction(); + CSSParserFunction* f = parser->createFloatingFunction(); f->name = $1; f->args = nullptr; $$.id = 0; @@ -1634,12 +1585,10 @@ calc_func_paren_expr: calc_func_expr: calc_func_term maybe_space { - CSSParser* p = static_cast<CSSParser*>(parser); - $$ = p->createFloatingValueList(); - $$->addValue(p->sinkFloatingValue($1)); + $$ = parser->createFloatingValueList(); + $$->addValue(parser->sinkFloatingValue($1)); } | calc_func_expr calc_func_operator calc_func_term { - CSSParser* p = static_cast<CSSParser*>(parser); if ($1 && $2) { $$ = $1; CSSParserValue v; @@ -1647,7 +1596,7 @@ calc_func_expr: v.unit = CSSParserValue::Operator; v.iValue = $2; $$->addValue(v); - $$->addValue(p->sinkFloatingValue($3)); + $$->addValue(parser->sinkFloatingValue($3)); } else $$ = 0; @@ -1690,10 +1639,9 @@ calc_func_expr_list: calc_function: CALCFUNCTION maybe_space calc_func_expr ')' maybe_space { - CSSParser* p = static_cast<CSSParser*>(parser); - CSSParserFunction* f = p->createFloatingFunction(); + CSSParserFunction* f = parser->createFloatingFunction(); f->name = $1; - f->args = p->sinkFloatingValueList($3); + f->args = parser->sinkFloatingValueList($3); $$.id = 0; $$.unit = CSSParserValue::Function; $$.function = f; @@ -1715,10 +1663,9 @@ min_or_max: min_or_max_function: min_or_max maybe_space calc_func_expr_list ')' maybe_space { - CSSParser* p = static_cast<CSSParser*>(parser); - CSSParserFunction* f = p->createFloatingFunction(); + CSSParserFunction* f = parser->createFloatingFunction(); f->name = $1; - f->args = p->sinkFloatingValueList($3); + f->args = parser->sinkFloatingValueList($3); $$.id = 0; $$.unit = CSSParserValue::Function; $$.function = f; @@ -1768,10 +1715,10 @@ invalid_rule: invalid_block: '{' error invalid_block_list error closing_brace { - static_cast<CSSParser*>(parser)->invalidBlockHit(); + parser->invalidBlockHit(); } | '{' error closing_brace { - static_cast<CSSParser*>(parser)->invalidBlockHit(); + parser->invalidBlockHit(); } ; diff --git a/Source/WebCore/css/CSSImageGeneratorValue.cpp b/Source/WebCore/css/CSSImageGeneratorValue.cpp index 9be446bd0..63040f3be 100644 --- a/Source/WebCore/css/CSSImageGeneratorValue.cpp +++ b/Source/WebCore/css/CSSImageGeneratorValue.cpp @@ -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 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()) { diff --git a/Source/WebCore/css/CSSImageGeneratorValue.h b/Source/WebCore/css/CSSImageGeneratorValue.h index b3d84eab2..cdf405a1c 100644 --- a/Source/WebCore/css/CSSImageGeneratorValue.h +++ b/Source/WebCore/css/CSSImageGeneratorValue.h @@ -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. diff --git a/Source/WebCore/css/CSSImageSetValue.cpp b/Source/WebCore/css/CSSImageSetValue.cpp index 0f48d010a..c3163f55c 100644 --- a/Source/WebCore/css/CSSImageSetValue.cpp +++ b/Source/WebCore/css/CSSImageSetValue.cpp @@ -30,8 +30,10 @@ #include "CSSImageValue.h" #include "CSSPrimitiveValue.h" +#include "CachedImage.h" #include "CachedResourceLoader.h" #include "Document.h" +#include "MemoryInstrumentation.h" #include "Page.h" #include "StyleCachedImageSet.h" #include "StylePendingImage.h" @@ -139,6 +141,16 @@ String CSSImageSetValue::customCssText() const return "-webkit-image-set(" + CSSValueList::customCssText() + ")"; } +bool CSSImageSetValue::hasFailedOrCanceledSubresources() const +{ + if (!m_imageSet || !m_imageSet->isCachedImageSet()) + return false; + CachedResource* cachedResource = static_cast<StyleCachedImageSet*>(m_imageSet.get())->cachedImage(); + if (!cachedResource) + return true; + return cachedResource->loadFailedOrCanceled(); +} + CSSImageSetValue::CSSImageSetValue(const CSSImageSetValue& cloneFrom) : CSSValueList(cloneFrom) , m_accessedBestFitImage(false) @@ -152,6 +164,19 @@ PassRefPtr<CSSImageSetValue> CSSImageSetValue::cloneForCSSOM() const return adoptRef(new CSSImageSetValue(*this)); } +void CSSImageSetValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + CSSValueList::reportDescendantMemoryUsage(memoryObjectInfo); + info.addInstrumentedVector(m_imagesInSet); +} + +void CSSImageSetValue::ImageWithScale::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addMember(imageURL); +} + } // namespace WebCore #endif // ENABLE(CSS_IMAGE_SET) diff --git a/Source/WebCore/css/CSSImageSetValue.h b/Source/WebCore/css/CSSImageSetValue.h index 404d3f9ee..a791d1ea1 100644 --- a/Source/WebCore/css/CSSImageSetValue.h +++ b/Source/WebCore/css/CSSImageSetValue.h @@ -58,10 +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(); diff --git a/Source/WebCore/css/CSSImageValue.cpp b/Source/WebCore/css/CSSImageValue.cpp index 61964630c..542192d5d 100644 --- a/Source/WebCore/css/CSSImageValue.cpp +++ b/Source/WebCore/css/CSSImageValue.cpp @@ -24,10 +24,11 @@ #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" @@ -102,6 +103,16 @@ void CSSImageValue::clearCachedImage() m_accessedImage = false; } +bool CSSImageValue::hasFailedOrCanceledSubresources() const +{ + if (!m_image || !m_image->isCachedImage()) + return false; + CachedResource* cachedResource = static_cast<StyleCachedImage*>(m_image.get())->cachedImage(); + if (!cachedResource) + return true; + return cachedResource->loadFailedOrCanceled(); +} + String CSSImageValue::customCssText() const { return "url(" + quoteCSSURLIfNeeded(m_url) + ")"; @@ -115,4 +126,11 @@ PassRefPtr<CSSValue> CSSImageValue::cloneForCSSOM() const return uriValue.release(); } +void CSSImageValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo 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 diff --git a/Source/WebCore/css/CSSImageValue.h b/Source/WebCore/css/CSSImageValue.h index 5b2ce4760..8c82f2c67 100644 --- a/Source/WebCore/css/CSSImageValue.h +++ b/Source/WebCore/css/CSSImageValue.h @@ -46,6 +46,10 @@ public: PassRefPtr<CSSValue> cloneForCSSOM() const; + bool hasFailedOrCanceledSubresources() const; + + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + protected: CSSImageValue(ClassType, const String& url); diff --git a/Source/WebCore/css/CSSImportRule.cpp b/Source/WebCore/css/CSSImportRule.cpp index fa10a287c..f7e711ba2 100644 --- a/Source/WebCore/css/CSSImportRule.cpp +++ b/Source/WebCore/css/CSSImportRule.cpp @@ -27,6 +27,7 @@ #include "CachedResourceLoader.h" #include "Document.h" #include "MediaList.h" +#include "MemoryInstrumentation.h" #include "SecurityOrigin.h" #include "StyleRuleImport.h" #include "StyleSheetContents.h" @@ -76,6 +77,15 @@ String CSSImportRule::cssText() const return result.toString(); } +void CSSImportRule::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + CSSRule::reportBaseClassMemoryUsage(memoryObjectInfo); + info.addInstrumentedMember(m_importRule); + info.addInstrumentedMember(m_mediaCSSOMWrapper); + info.addInstrumentedMember(m_styleSheetCSSOMWrapper); +} + CSSStyleSheet* CSSImportRule::styleSheet() const { if (!m_importRule->styleSheet()) diff --git a/Source/WebCore/css/CSSImportRule.h b/Source/WebCore/css/CSSImportRule.h index 9ee306611..c835f7dd5 100644 --- a/Source/WebCore/css/CSSImportRule.h +++ b/Source/WebCore/css/CSSImportRule.h @@ -43,6 +43,8 @@ public: String cssText() const; + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: CSSImportRule(StyleRuleImport*, CSSStyleSheet*); diff --git a/Source/WebCore/css/CSSInheritedValue.cpp b/Source/WebCore/css/CSSInheritedValue.cpp index 8c4be6d4b..f7a426de6 100644 --- a/Source/WebCore/css/CSSInheritedValue.cpp +++ b/Source/WebCore/css/CSSInheritedValue.cpp @@ -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 info(memoryObjectInfo, this, MemoryInstrumentation::CSS); +} + } // namespace WebCore diff --git a/Source/WebCore/css/CSSInheritedValue.h b/Source/WebCore/css/CSSInheritedValue.h index 5aa906367..68c001f53 100644 --- a/Source/WebCore/css/CSSInheritedValue.h +++ b/Source/WebCore/css/CSSInheritedValue.h @@ -35,6 +35,8 @@ public: String customCssText() const; + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: CSSInheritedValue() : CSSValue(InheritedClass) diff --git a/Source/WebCore/css/CSSInitialValue.cpp b/Source/WebCore/css/CSSInitialValue.cpp index 8de3f3182..775fe0f80 100644 --- a/Source/WebCore/css/CSSInitialValue.cpp +++ b/Source/WebCore/css/CSSInitialValue.cpp @@ -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 info(memoryObjectInfo, this, MemoryInstrumentation::CSS); +} + } // namespace WebCore diff --git a/Source/WebCore/css/CSSInitialValue.h b/Source/WebCore/css/CSSInitialValue.h index dd86d8424..d523343d3 100644 --- a/Source/WebCore/css/CSSInitialValue.h +++ b/Source/WebCore/css/CSSInitialValue.h @@ -41,6 +41,8 @@ public: bool isImplicit() const { return m_isImplicit; } + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: CSSInitialValue(bool implicit) : CSSValue(InitialClass) diff --git a/Source/WebCore/css/CSSLineBoxContainValue.cpp b/Source/WebCore/css/CSSLineBoxContainValue.cpp index 53132eb19..85f385d71 100644 --- a/Source/WebCore/css/CSSLineBoxContainValue.cpp +++ b/Source/WebCore/css/CSSLineBoxContainValue.cpp @@ -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 info(memoryObjectInfo, this, MemoryInstrumentation::CSS); +} + } diff --git a/Source/WebCore/css/CSSLineBoxContainValue.h b/Source/WebCore/css/CSSLineBoxContainValue.h index ddc0c60f3..eeb6470c8 100644 --- a/Source/WebCore/css/CSSLineBoxContainValue.h +++ b/Source/WebCore/css/CSSLineBoxContainValue.h @@ -50,6 +50,8 @@ public: LineBoxContain value() const { return m_value; } + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: LineBoxContain m_value; diff --git a/Source/WebCore/css/CSSMediaRule.cpp b/Source/WebCore/css/CSSMediaRule.cpp index 55bbaa5fd..278670f41 100644 --- a/Source/WebCore/css/CSSMediaRule.cpp +++ b/Source/WebCore/css/CSSMediaRule.cpp @@ -27,6 +27,7 @@ #include "CSSRuleList.h" #include "CSSStyleSheet.h" #include "ExceptionCode.h" +#include "MemoryInstrumentation.h" #include "StyleRule.h" #include <wtf/text/StringBuilder.h> @@ -174,4 +175,13 @@ void CSSMediaRule::reattach(StyleRuleMedia* rule) } } +void CSSMediaRule::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + CSSRule::reportBaseClassMemoryUsage(memoryObjectInfo); + info.addInstrumentedMember(m_mediaCSSOMWrapper); + info.addInstrumentedVector(m_childRuleCSSOMWrappers); + info.addInstrumentedMember(m_ruleListCSSOMWrapper); +} + } // namespace WebCore diff --git a/Source/WebCore/css/CSSMediaRule.h b/Source/WebCore/css/CSSMediaRule.h index fda23cae2..69faf1a50 100644 --- a/Source/WebCore/css/CSSMediaRule.h +++ b/Source/WebCore/css/CSSMediaRule.h @@ -52,6 +52,8 @@ public: void reattach(StyleRuleMedia*); + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: CSSMediaRule(StyleRuleMedia*, CSSStyleSheet*); diff --git a/Source/WebCore/css/CSSPageRule.cpp b/Source/WebCore/css/CSSPageRule.cpp index 42859aa2a..f5e63276d 100644 --- a/Source/WebCore/css/CSSPageRule.cpp +++ b/Source/WebCore/css/CSSPageRule.cpp @@ -95,4 +95,12 @@ void CSSPageRule::reattach(StyleRulePage* rule) m_propertiesCSSOMWrapper->reattach(m_pageRule->mutableProperties()); } +void CSSPageRule::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + CSSRule::reportBaseClassMemoryUsage(memoryObjectInfo); + info.addInstrumentedMember(m_pageRule); + info.addInstrumentedMember(m_propertiesCSSOMWrapper); +} + } // namespace WebCore diff --git a/Source/WebCore/css/CSSPageRule.h b/Source/WebCore/css/CSSPageRule.h index 163900cd1..aed4df4ae 100644 --- a/Source/WebCore/css/CSSPageRule.h +++ b/Source/WebCore/css/CSSPageRule.h @@ -48,6 +48,8 @@ public: void reattach(StyleRulePage*); + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: CSSPageRule(StyleRulePage*, CSSStyleSheet*); diff --git a/Source/WebCore/css/CSSParser.cpp b/Source/WebCore/css/CSSParser.cpp index c3ff2ab57..aa08c18e7 100644 --- a/Source/WebCore/css/CSSParser.cpp +++ b/Source/WebCore/css/CSSParser.cpp @@ -101,10 +101,11 @@ #endif #if ENABLE(CSS_SHADERS) +#include "WebKitCSSMixFunctionValue.h" #include "WebKitCSSShaderValue.h" #endif -#if ENABLE(DASHBOARD_SUPPORT) +#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION) #include "DashboardRegion.h" #endif @@ -114,7 +115,7 @@ extern int cssyydebug; #endif -extern int cssyyparse(void* parser); +extern int cssyyparse(WebCore::CSSParser*); using namespace std; using namespace WTF; @@ -243,6 +244,7 @@ CSSParser::CSSParser(const CSSParserContext& context) , m_important(false) , m_id(CSSPropertyInvalid) , m_styleSheet(0) + , m_parsedProperties(adoptPtr(new ParsedPropertyVector)) , m_selectorListForParseSelector(0) , m_numParsedPropertiesBeforeMarginBox(INVALID_NUM_PARSED_PROPERTIES) , m_inParseShorthand(0) @@ -262,6 +264,7 @@ CSSParser::CSSParser(const CSSParserContext& context) , m_lastSelectorLineNumber(0) , m_allowImportRules(true) , m_allowNamespaceDeclarations(true) + , m_selectorVector(adoptPtr(new CSSSelectorVector)) { #if YYDEBUG > 0 cssyydebug = 1; @@ -833,8 +836,8 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int if (valueID == CSSValueReadOnly || valueID == CSSValueReadWrite || valueID == CSSValueReadWritePlaintextOnly) return true; break; - case CSSPropertyWebkitUserSelect: // auto | none | text - if (valueID == CSSValueAuto || valueID == CSSValueNone || valueID == CSSValueText) + case CSSPropertyWebkitUserSelect: // auto | none | text | all + if (valueID == CSSValueAuto || valueID == CSSValueNone || valueID == CSSValueText || valueID == CSSValueAll) return true; break; #if ENABLE(CSS_EXCLUSIONS) @@ -1151,9 +1154,9 @@ bool CSSParser::parseValue(StylePropertySet* declaration, CSSPropertyID property bool ok = false; if (m_hasFontFaceOnlyValues) deleteFontFaceOnlyValues(); - if (!m_parsedProperties.isEmpty()) { + if (!m_parsedProperties->isEmpty()) { ok = true; - declaration->addParsedProperties(m_parsedProperties); + declaration->addParsedProperties(*m_parsedProperties); clearProperties(); } @@ -1174,7 +1177,7 @@ bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict) if (!parser.parseColor(string)) return false; - CSSValue* value = parser.m_parsedProperties.first().value(); + CSSValue* value = parser.m_parsedProperties->first().value(); if (!value->isPrimitiveValue()) return false; @@ -1192,7 +1195,7 @@ bool CSSParser::parseColor(const String& string) cssyyparse(this); m_rule = 0; - return !m_parsedProperties.isEmpty() && m_parsedProperties.first().id() == CSSPropertyColor; + return !m_parsedProperties->isEmpty() && m_parsedProperties->first().id() == CSSPropertyColor; } bool CSSParser::parseSystemColor(RGBA32& color, const String& string, Document* document) @@ -1242,9 +1245,9 @@ bool CSSParser::parseDeclaration(StylePropertySet* declaration, const String& st bool ok = false; if (m_hasFontFaceOnlyValues) deleteFontFaceOnlyValues(); - if (!m_parsedProperties.isEmpty()) { + if (!m_parsedProperties->isEmpty()) { ok = true; - declaration->addParsedProperties(m_parsedProperties); + declaration->addParsedProperties(*m_parsedProperties); clearProperties(); } @@ -1281,14 +1284,14 @@ PassOwnPtr<MediaQuery> CSSParser::parseMediaQuery(const String& string) } #if ENABLE(CSS_VARIABLES) -static inline void filterProperties(bool important, const CSSParser::ParsedPropertyVector& input, Vector<CSSProperty, 256>& output, size_t& unusedEntries, BitArray<numCSSProperties>& seenProperties, HashSet<AtomicString>& seenVariables) +static inline void filterProperties(bool important, const CSSParser::ParsedPropertyVector* input, Vector<CSSProperty, 256>& output, size_t& unusedEntries, BitArray<numCSSProperties>& seenProperties, HashSet<AtomicString>& seenVariables) #else -static inline void filterProperties(bool important, const CSSParser::ParsedPropertyVector& input, Vector<CSSProperty, 256>& output, size_t& unusedEntries, BitArray<numCSSProperties>& seenProperties) +static inline void filterProperties(bool important, const CSSParser::ParsedPropertyVector* input, Vector<CSSProperty, 256>& output, size_t& unusedEntries, BitArray<numCSSProperties>& seenProperties) #endif { // Add properties in reverse order so that highest priority definitions are reached first. Duplicate definitions can then be ignored when found. - for (int i = input.size() - 1; i >= 0; --i) { - const CSSProperty& property = input[i]; + for (int i = input->size() - 1; i >= 0; --i) { + const CSSProperty& property = input->at(i); if (property.isImportant() != important) continue; #if ENABLE(CSS_VARIABLES) @@ -1312,17 +1315,17 @@ static inline void filterProperties(bool important, const CSSParser::ParsedPrope PassRefPtr<StylePropertySet> CSSParser::createStylePropertySet() { BitArray<numCSSProperties> seenProperties; - size_t unusedEntries = m_parsedProperties.size(); + size_t unusedEntries = m_parsedProperties->size(); Vector<CSSProperty, 256> results(unusedEntries); // Important properties have higher priority, so add them first. Duplicate definitions can then be ignored when found. #if ENABLE(CSS_VARIABLES) HashSet<AtomicString> seenVariables; - filterProperties(true, m_parsedProperties, results, unusedEntries, seenProperties, seenVariables); - filterProperties(false, m_parsedProperties, results, unusedEntries, seenProperties, seenVariables); + filterProperties(true, m_parsedProperties.get(), results, unusedEntries, seenProperties, seenVariables); + filterProperties(false, m_parsedProperties.get(), results, unusedEntries, seenProperties, seenVariables); #else - filterProperties(true, m_parsedProperties, results, unusedEntries, seenProperties); - filterProperties(false, m_parsedProperties, results, unusedEntries, seenProperties); + filterProperties(true, m_parsedProperties.get(), results, unusedEntries, seenProperties); + filterProperties(false, m_parsedProperties.get(), results, unusedEntries, seenProperties); #endif if (unusedEntries) results.remove(0, unusedEntries); @@ -1332,19 +1335,19 @@ PassRefPtr<StylePropertySet> CSSParser::createStylePropertySet() void CSSParser::addProperty(CSSPropertyID propId, PassRefPtr<CSSValue> value, bool important, bool implicit) { - m_parsedProperties.append(CSSProperty(propId, value, important, m_currentShorthand, m_implicitShorthand || implicit)); + m_parsedProperties->append(CSSProperty(propId, value, important, m_currentShorthand, m_implicitShorthand || implicit)); } void CSSParser::rollbackLastProperties(int num) { ASSERT(num >= 0); - ASSERT(m_parsedProperties.size() >= static_cast<unsigned>(num)); - m_parsedProperties.shrink(m_parsedProperties.size() - num); + ASSERT(m_parsedProperties->size() >= static_cast<unsigned>(num)); + m_parsedProperties->shrink(m_parsedProperties->size() - num); } void CSSParser::clearProperties() { - m_parsedProperties.clear(); + m_parsedProperties->clear(); m_numParsedPropertiesBeforeMarginBox = INVALID_NUM_PARSED_PROPERTIES; m_hasFontFaceOnlyValues = false; } @@ -1638,6 +1641,10 @@ inline PassRefPtr<CSSPrimitiveValue> CSSParser::parseValidPrimitive(int identifi if (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiveValue::CSS_DPCM) return createPrimitiveNumericValue(value); #endif +#if ENABLE(CSS_VARIABLES) + if (value->unit == CSSPrimitiveValue::CSS_VARIABLE_NAME) + return CSSPrimitiveValue::create(value->string, CSSPrimitiveValue::CSS_VARIABLE_NAME); +#endif if (value->unit >= CSSParserValue::Q_EMS) return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPrimitiveValue::CSS_EMS); if (isCalculation(value)) @@ -1756,7 +1763,7 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) ShorthandScope scope(this, propId); if (num != 1 || !parseValue(CSSPropertyOverflowX, important)) return false; - CSSValue* value = m_parsedProperties.last().value(); + CSSValue* value = m_parsedProperties->last().value(); addProperty(CSSPropertyOverflowY, value, important); return true; } @@ -1779,7 +1786,7 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) ShorthandScope scope(this, CSSPropertyBorderSpacing); if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important)) return false; - CSSValue* value = m_parsedProperties.last().value(); + CSSValue* value = m_parsedProperties->last().value(); addProperty(CSSPropertyWebkitBorderVerticalSpacing, value, important); return true; } @@ -2095,31 +2102,11 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) case CSSPropertyTextDecoration: case CSSPropertyWebkitTextDecorationsInEffect: // none | [ underline || overline || line-through || blink ] | inherit - if (id == CSSValueNone) { - validPrimitive = true; - } else { - RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); - bool isValid = true; - while (isValid && value) { - switch (value->id) { - case CSSValueBlink: - break; - case CSSValueUnderline: - case CSSValueOverline: - case CSSValueLineThrough: - list->append(cssValuePool().createIdentifierValue(value->id)); - break; - default: - isValid = false; - } - value = m_valueList->next(); - } - if (list->length() && isValid) { - parsedValue = list.release(); - m_valueList->next(); - } - } - break; + return parseTextDecoration(propId, important); + + case CSSPropertyWebkitTextDecorationLine: + // none | [ underline || overline || line-through ] | inherit + return parseTextDecoration(propId, important); case CSSPropertyZoom: // normal | reset | document | <number> | <percentage> | inherit if (id == CSSValueNormal || id == CSSValueReset || id == CSSValueDocument) @@ -2291,7 +2278,12 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) validPrimitive = validUnit(value, FNumber | FNonNeg); break; case CSSPropertyWebkitOrder: - validPrimitive = validUnit(value, FNumber); + if (validUnit(value, FInteger, CSSStrictMode)) { + // We restrict the smallest value to int min + 2 because we use int min and int min + 1 as special values in a hash set. + parsedValue = cssValuePool().createValue(max(static_cast<double>(std::numeric_limits<int>::min() + 2), value->fValue), + static_cast<CSSPrimitiveValue::UnitTypes>(value->unit)); + m_valueList->next(); + } break; #endif case CSSPropertyWebkitMarquee: @@ -2328,9 +2320,9 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) if (id == CSSValueNone) validPrimitive = true; else { - PassRefPtr<CSSValue> val = parseTransform(); - if (val) { - addProperty(propId, val, important); + RefPtr<CSSValue> transformValue = parseTransform(m_valueList.get()); + if (transformValue) { + addProperty(propId, transformValue.release(), important); return true; } return false; @@ -2421,7 +2413,7 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse); if (!parseValue(webkitMarginCollapseShorthand().properties()[0], important)) return false; - CSSValue* value = m_parsedProperties.last().value(); + CSSValue* value = m_parsedProperties->last().value(); addProperty(webkitMarginCollapseShorthand().properties()[1], value, important); return true; } @@ -2525,8 +2517,13 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) validPrimitive = true; break; +#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION) #if ENABLE(DASHBOARD_SUPPORT) case CSSPropertyWebkitDashboardRegion: // <dashboard-region> | <dashboard-region> +#endif +#if ENABLE(WIDGET_REGION) + case CSSPropertyWebkitWidgetRegion: +#endif if (value->unit == CSSParserValue::Function || id == CSSValueNone) return parseDashboardRegions(propId, important); break; @@ -3015,6 +3012,10 @@ bool CSSParser::cssVariablesEnabled() const void CSSParser::storeVariableDeclaration(const CSSParserString& name, PassOwnPtr<CSSParserValueList> value, bool important) { + // When CSSGrammar.y encounters an invalid declaration it passes null for the CSSParserValueList, just bail. + if (!value) + return; + ASSERT(name.length > 12); AtomicString variableName = String(name.characters + 12, name.length - 12); @@ -3245,7 +3246,7 @@ bool CSSParser::parse4Values(CSSPropertyID propId, const CSSPropertyID *properti case 1: { if (!parseValue(properties[0], important)) return false; - CSSValue *value = m_parsedProperties.last().value(); + CSSValue* value = m_parsedProperties->last().value(); ImplicitScope implicitScope(this, PropertyImplicit); addProperty(properties[1], value, important); addProperty(properties[2], value, important); @@ -3255,17 +3256,17 @@ bool CSSParser::parse4Values(CSSPropertyID propId, const CSSPropertyID *properti case 2: { if (!parseValue(properties[0], important) || !parseValue(properties[1], important)) return false; - CSSValue *value = m_parsedProperties[m_parsedProperties.size() - 2].value(); + CSSValue* value = m_parsedProperties->at(m_parsedProperties->size() - 2).value(); ImplicitScope implicitScope(this, PropertyImplicit); addProperty(properties[2], value, important); - value = m_parsedProperties[m_parsedProperties.size() - 2].value(); + value = m_parsedProperties->at(m_parsedProperties->size() - 2).value(); addProperty(properties[3], value, important); break; } case 3: { if (!parseValue(properties[0], important) || !parseValue(properties[1], important) || !parseValue(properties[2], important)) return false; - CSSValue *value = m_parsedProperties[m_parsedProperties.size() - 2].value(); + CSSValue* value = m_parsedProperties->at(m_parsedProperties->size() - 2).value(); ImplicitScope implicitScope(this, PropertyImplicit); addProperty(properties[3], value, important); break; @@ -3841,7 +3842,7 @@ bool CSSParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& propId1, } case CSSPropertyWebkitBackgroundComposite: case CSSPropertyWebkitMaskComposite: - if ((val->id >= CSSValueClear && val->id <= CSSValuePlusLighter) || val->id == CSSValueHighlight) { + if (val->id >= CSSValueClear && val->id <= CSSValuePlusLighter) { currValue = cssValuePool().createIdentifierValue(val->id); m_valueList->next(); } @@ -4215,7 +4216,7 @@ bool CSSParser::parseGridTrackList(CSSPropertyID propId, bool important) } -#if ENABLE(DASHBOARD_SUPPORT) +#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION) #define DASHBOARD_REGION_NUM_PARAMETERS 6 #define DASHBOARD_REGION_SHORT_NUM_PARAMETERS 2 @@ -4261,14 +4262,39 @@ bool CSSParser::parseDashboardRegions(CSSPropertyID propId, bool important) break; } - // Commas count as values, so allow: + // Commas count as values, so allow (function name is dashboard-region for DASHBOARD_SUPPORT feature): // dashboard-region(label, type, t, r, b, l) or dashboard-region(label type t r b l) // dashboard-region(label, type, t, r, b, l) or dashboard-region(label type t r b l) // also allow // dashboard-region(label, type) or dashboard-region(label type) // dashboard-region(label, type) or dashboard-region(label type) CSSParserValueList* args = value->function->args.get(); - if (!equalIgnoringCase(value->function->name, "dashboard-region(") || !args) { + if (!args) { + valid = false; + break; + } + bool validFunctionName = false; +#if ENABLE(DASHBOARD_SUPPORT) + static const char* const dashboardRegionFunctionName = "dashboard-region("; + if (equalIgnoringCase(value->function->name, dashboardRegionFunctionName)) { + validFunctionName = true; +#if ENABLE(DASHBOARD_SUPPORT) && ENABLE(WIDGET_REGION) + // Keep track of function name when both features are enabled. + region->m_cssFunctionName = dashboardRegionFunctionName; +#endif + } +#endif +#if ENABLE(WIDGET_REGION) + static const char* const widgetRegionFunctionName = "region("; + if (equalIgnoringCase(value->function->name, widgetRegionFunctionName)) { + validFunctionName = true; +#if ENABLE(DASHBOARD_SUPPORT) && ENABLE(WIDGET_REGION) + // Keep track of function name when both features are enabled. + region->m_cssFunctionName = widgetRegionFunctionName; +#endif + } +#endif + if (!validFunctionName) { valid = false; break; } @@ -4354,7 +4380,7 @@ bool CSSParser::parseDashboardRegions(CSSPropertyID propId, bool important) return valid; } -#endif /* ENABLE(DASHBOARD_SUPPORT) */ +#endif /* ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION) */ PassRefPtr<CSSValue> CSSParser::parseCounterContent(CSSParserValueList* args, bool counters) { @@ -4810,7 +4836,7 @@ PassRefPtr<CSSValueList> CSSParser::parseFontFamily() bool inFamily = false; while (value) { - if (value->id == CSSValueInitial || value->id == CSSValueInherit) + if (value->id == CSSValueInitial || value->id == CSSValueInherit || value->id == CSSValueDefault) return 0; CSSParserValue* nextValue = m_valueList->next(); bool nextValBreaksFont = !nextValue || @@ -6105,6 +6131,7 @@ bool CSSParser::parseBorderImageRepeat(RefPtr<CSSValue>& result) // We need to rewind the value list, so that when its advanced we'll // end up back at this value. m_valueList->previous(); + secondValue = firstValue; } } else secondValue = firstValue; @@ -7239,15 +7266,15 @@ private: CSSParser::Units m_unit; }; -PassRefPtr<CSSValueList> CSSParser::parseTransform() +PassRefPtr<CSSValueList> CSSParser::parseTransform(CSSParserValueList* valueList) { - if (!m_valueList) + if (!valueList) return 0; // The transform is a list of functional primitives that specify transform operations. // We collect a list of WebKitCSSTransformValues, where each value specifies a single operation. RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); - for (CSSParserValue* value = m_valueList->current(); value; value = m_valueList->next()) { + for (CSSParserValue* value = valueList->current(); value; value = valueList->next()) { if (value->unit != CSSParserValue::Function || !value->function) return 0; @@ -7310,6 +7337,19 @@ PassRefPtr<CSSValueList> CSSParser::parseTransform() return list.release(); } +bool CSSParser::isBlendMode(int ident) +{ + return (ident >= CSSValueMultiply && ident <= CSSValueLuminosity) + || ident == CSSValueNormal + || ident == CSSValueOverlay; +} + +bool CSSParser::isCompositeOperator(int ident) +{ + // FIXME: Add CSSValueDestination and CSSValueLighter when the Compositing spec updates. + return ident >= CSSValueClear && ident <= CSSValueXor; +} + #if ENABLE(CSS_FILTERS) static void filterInfoForName(const CSSParserString& name, WebKitCSSFilterValue::FilterOperationType& filterType, unsigned& maximumArgumentCount) @@ -7353,6 +7393,53 @@ static bool acceptCommaOperator(CSSParserValueList* argsList) return true; } +PassRefPtr<WebKitCSSMixFunctionValue> CSSParser::parseMixFunction(CSSParserValue* value) +{ + ASSERT(value->unit == CSSParserValue::Function && value->function); + + if (!equalIgnoringCase(value->function->name, "mix(")) + return 0; + + CSSParserValueList* argsList = value->function->args.get(); + unsigned numArgs = argsList->size(); + if (numArgs < 1 || numArgs > 3) + return 0; + + RefPtr<WebKitCSSMixFunctionValue> mixFunction = WebKitCSSMixFunctionValue::create(); + + bool hasBlendMode = false; + bool hasAlphaCompositing = false; + CSSParserValue* arg; + while ((arg = argsList->current())) { + RefPtr<CSSValue> value; + + unsigned argNumber = argsList->currentIndex(); + if (!argNumber) { + if (arg->unit == CSSPrimitiveValue::CSS_URI) { + KURL shaderURL = completeURL(arg->string); + value = WebKitCSSShaderValue::create(shaderURL.string()); + } + } else if (argNumber == 1 || argNumber == 2) { + if (!hasBlendMode && isBlendMode(arg->id)) { + hasBlendMode = true; + value = cssValuePool().createIdentifierValue(arg->id); + } else if (!hasAlphaCompositing && isCompositeOperator(arg->id)) { + hasAlphaCompositing = true; + value = cssValuePool().createIdentifierValue(arg->id); + } + } + + if (!value) + return 0; + + mixFunction->append(value.release()); + + arg = argsList->next(); + } + + return mixFunction; +} + PassRefPtr<WebKitCSSFilterValue> CSSParser::parseCustomFilter(CSSParserValue* value) { CSSParserValueList* argsList = value->function->args.get(); @@ -7364,7 +7451,13 @@ PassRefPtr<WebKitCSSFilterValue> CSSParser::parseCustomFilter(CSSParserValue* va // Custom filter syntax: // // vertexShader: <uri> | none - // fragmentShader: <uri> | none + // fragmentShader: <uri> | none | mix(<uri> [ <blend-mode> || <alpha-compositing> ]?) + // + // blend-mode: normal | multiply | screen | overlay | darken | lighten | color-dodge | + // color-burn | hard-light | soft-light | difference | exclusion | hue | + // saturation | color | luminosity + // alpha-compositing: clear | src | dst | src-over | dst-over | src-in | dst-in | + // src-out | dst-out | src-atop | dst-atop | xor | plus // // box: filter-box | border-box | padding-box | content-box // vertexMesh: +<integer>{1,2}[wsp<box>][wsp'detached'] @@ -7398,7 +7491,12 @@ PassRefPtr<WebKitCSSFilterValue> CSSParser::parseCustomFilter(CSSParserValue* va KURL shaderURL = completeURL(arg->string); value = WebKitCSSShaderValue::create(shaderURL.string()); hadAtLeastOneCustomShader = true; + } else if (argsList->currentIndex() == 1 && arg->unit == CSSParserValue::Function) { + if (!(value = parseMixFunction(arg))) + return 0; + hadAtLeastOneCustomShader = true; } + if (!value) break; shadersList->append(value.release()); @@ -7448,7 +7546,7 @@ PassRefPtr<WebKitCSSFilterValue> CSSParser::parseCustomFilter(CSSParserValue* va RefPtr<CSSValueList> paramList = CSSValueList::createCommaSeparated(); while ((arg = argsList->current())) { - if (arg->id || arg->unit != CSSPrimitiveValue::CSS_IDENT) + if (arg->unit != CSSPrimitiveValue::CSS_IDENT) return 0; RefPtr<CSSValueList> parameter = CSSValueList::createSpaceSeparated(); @@ -7672,7 +7770,7 @@ bool CSSParser::parseFlowThread(const String& flowName) m_rule = 0; - return ((m_parsedProperties.size() == 1) && (m_parsedProperties.first().id() == CSSPropertyWebkitFlowInto)); + return ((m_parsedProperties->size() == 1) && (m_parsedProperties->first().id() == CSSPropertyWebkitFlowInto)); } // none | <ident> @@ -7816,6 +7914,56 @@ bool CSSParser::parsePerspectiveOrigin(CSSPropertyID propId, CSSPropertyID& prop return value; } +void CSSParser::addTextDecorationProperty(CSSPropertyID propId, PassRefPtr<CSSValue> value, bool important) +{ + // The text-decoration-line property takes priority over text-decoration, unless the latter has important priority set. + if (propId == CSSPropertyTextDecoration && !important && m_currentShorthand == CSSPropertyInvalid) { + for (unsigned i = 0; i < m_parsedProperties->size(); ++i) { + if (m_parsedProperties->at(i).id() == CSSPropertyWebkitTextDecorationLine) + return; + } + } + addProperty(propId, value, important); +} + +bool CSSParser::parseTextDecoration(CSSPropertyID propId, bool important) +{ + CSSParserValue* value = m_valueList->current(); + if (value->id == CSSValueNone) { + addTextDecorationProperty(propId, cssValuePool().createExplicitInitialValue(), important); + m_valueList->next(); + return true; + } + + RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); + bool isValid = true; + while (isValid && value) { + switch (value->id) { + case CSSValueBlink: + // Blink value is not accepted by -webkit-text-decoration-line. + isValid = propId != CSSPropertyWebkitTextDecorationLine; + break; + case CSSValueUnderline: + case CSSValueOverline: + case CSSValueLineThrough: + list->append(cssValuePool().createIdentifierValue(value->id)); + break; + default: + isValid = false; + break; + } + if (isValid) + value = m_valueList->next(); + } + + if (list->length() && isValid) { + addTextDecorationProperty(propId, list.release(), important); + return true; + } + + return false; +} + bool CSSParser::parseTextEmphasisStyle(bool important) { unsigned valueListSize = m_valueList->size(); @@ -9331,14 +9479,14 @@ PassOwnPtr<CSSParserSelector> CSSParser::sinkFloatingSelector(CSSParserSelector* return adoptPtr(selector); } -Vector<OwnPtr<CSSParserSelector> >* CSSParser::createFloatingSelectorVector() +CSSSelectorVector* CSSParser::createFloatingSelectorVector() { - Vector<OwnPtr<CSSParserSelector> >* selectorVector = new Vector<OwnPtr<CSSParserSelector> >; + CSSSelectorVector* selectorVector = new CSSSelectorVector; m_floatingSelectorVectors.add(selectorVector); return selectorVector; } -PassOwnPtr<Vector<OwnPtr<CSSParserSelector> > > CSSParser::sinkFloatingSelectorVector(Vector<OwnPtr<CSSParserSelector> >* selectorVector) +PassOwnPtr<CSSSelectorVector > CSSParser::sinkFloatingSelectorVector(CSSSelectorVector* selectorVector) { if (selectorVector) { ASSERT(m_floatingSelectorVectors.contains(selectorVector)); @@ -9531,7 +9679,7 @@ StyleRuleKeyframes* CSSParser::createKeyframesRule(const String& name, PassOwnPt return rulePtr; } -StyleRuleBase* CSSParser::createStyleRule(Vector<OwnPtr<CSSParserSelector> >* selectors) +StyleRuleBase* CSSParser::createStyleRule(CSSSelectorVector* selectors) { StyleRule* result = 0; if (selectors) { @@ -9553,8 +9701,8 @@ StyleRuleBase* CSSParser::createStyleRule(Vector<OwnPtr<CSSParserSelector> >* se StyleRuleBase* CSSParser::createFontFaceRule() { m_allowImportRules = m_allowNamespaceDeclarations = false; - for (unsigned i = 0; i < m_parsedProperties.size(); ++i) { - CSSProperty& property = m_parsedProperties[i]; + for (unsigned i = 0; i < m_parsedProperties->size(); ++i) { + CSSProperty& property = m_parsedProperties->at(i); if (property.id() == CSSPropertyFontVariant && property.value()->isPrimitiveValue()) property.wrapValueInCommaSeparatedList(); else if (property.id() == CSSPropertyFontFamily && (!property.value()->isValueList() || static_cast<CSSValueList*>(property.value())->length() != 1)) { @@ -9645,7 +9793,7 @@ StyleRuleBase* CSSParser::createPageRule(PassOwnPtr<CSSParserSelector> pageSelec StyleRulePage* pageRule = 0; if (pageSelector) { RefPtr<StyleRulePage> rule = StyleRulePage::create(); - Vector<OwnPtr<CSSParserSelector> > selectorVector; + CSSSelectorVector selectorVector; selectorVector.append(pageSelector); rule->parserAdoptSelectorVector(selectorVector); rule->setProperties(createStylePropertySet()); @@ -9657,7 +9805,7 @@ StyleRuleBase* CSSParser::createPageRule(PassOwnPtr<CSSParserSelector> pageSelec return pageRule; } -void CSSParser::setReusableRegionSelectorVector(Vector<OwnPtr<CSSParserSelector> >* selectors) +void CSSParser::setReusableRegionSelectorVector(CSSSelectorVector* selectors) { if (selectors) m_reusableRegionSelectorVector.swap(*selectors); @@ -9693,22 +9841,22 @@ StyleRuleBase* CSSParser::createMarginAtRule(CSSSelector::MarginBoxType /* margi void CSSParser::startDeclarationsForMarginBox() { - m_numParsedPropertiesBeforeMarginBox = m_parsedProperties.size(); + m_numParsedPropertiesBeforeMarginBox = m_parsedProperties->size(); } void CSSParser::endDeclarationsForMarginBox() { - rollbackLastProperties(m_parsedProperties.size() - m_numParsedPropertiesBeforeMarginBox); + rollbackLastProperties(m_parsedProperties->size() - m_numParsedPropertiesBeforeMarginBox); m_numParsedPropertiesBeforeMarginBox = INVALID_NUM_PARSED_PROPERTIES; } void CSSParser::deleteFontFaceOnlyValues() { ASSERT(m_hasFontFaceOnlyValues); - for (unsigned i = 0; i < m_parsedProperties.size();) { - CSSProperty& property = m_parsedProperties[i]; + for (unsigned i = 0; i < m_parsedProperties->size();) { + CSSProperty& property = m_parsedProperties->at(i); if (property.id() == CSSPropertyFontVariant && property.value()->isValueList()) { - m_parsedProperties.remove(i); + m_parsedProperties->remove(i); continue; } ++i; @@ -9747,7 +9895,6 @@ void CSSParser::invalidBlockHit() void CSSParser::updateLastSelectorLineAndPosition() { m_lastSelectorLineNumber = m_lineNumber; - markRuleBodyStart(); } void CSSParser::updateLastMediaLine(MediaQuerySet* media) diff --git a/Source/WebCore/css/CSSParser.h b/Source/WebCore/css/CSSParser.h index 6acbba252..5a1ed97b8 100644 --- a/Source/WebCore/css/CSSParser.h +++ b/Source/WebCore/css/CSSParser.h @@ -64,6 +64,10 @@ class StyleKeyframe; class StyleSheetContents; class StyledElement; +#if ENABLE(CSS_SHADERS) +class WebKitCSSMixFunctionValue; +#endif + class CSSParser { public: CSSParser(const CSSParserContext&); @@ -83,7 +87,7 @@ public: void addProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important, bool implicit = false); void rollbackLastProperties(int num); - bool hasProperties() const { return !m_parsedProperties.isEmpty(); } + bool hasProperties() const { return !m_parsedProperties->isEmpty(); } bool parseValue(CSSPropertyID, bool important); bool parseShorthand(CSSPropertyID, const StylePropertyShorthand&, bool important); @@ -213,16 +217,23 @@ public: PassRefPtr<CSSValueList> parseFilter(); PassRefPtr<WebKitCSSFilterValue> parseBuiltinFilterArguments(CSSParserValueList*, WebKitCSSFilterValue::FilterOperationType); #if ENABLE(CSS_SHADERS) + PassRefPtr<WebKitCSSMixFunctionValue> parseMixFunction(CSSParserValue*); PassRefPtr<WebKitCSSFilterValue> parseCustomFilter(CSSParserValue*); #endif #endif - PassRefPtr<CSSValueList> parseTransform(); + static bool isBlendMode(int ident); + static bool isCompositeOperator(int ident); + + PassRefPtr<CSSValueList> parseTransform(CSSParserValueList*); bool parseTransformOrigin(CSSPropertyID propId, CSSPropertyID& propId1, CSSPropertyID& propId2, CSSPropertyID& propId3, RefPtr<CSSValue>&, RefPtr<CSSValue>&, RefPtr<CSSValue>&); bool parsePerspectiveOrigin(CSSPropertyID propId, CSSPropertyID& propId1, CSSPropertyID& propId2, RefPtr<CSSValue>&, RefPtr<CSSValue>&); bool parseTextEmphasisStyle(bool important); + void addTextDecorationProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important); + bool parseTextDecoration(CSSPropertyID propId, bool important); + bool parseLineBoxContain(bool important); bool parseCalculation(CSSParserValue*, CalculationPermittedValueRange); @@ -241,8 +252,8 @@ public: CSSParserSelector* createFloatingSelector(); PassOwnPtr<CSSParserSelector> sinkFloatingSelector(CSSParserSelector*); - Vector<OwnPtr<CSSParserSelector> >* createFloatingSelectorVector(); - PassOwnPtr<Vector<OwnPtr<CSSParserSelector> > > sinkFloatingSelectorVector(Vector<OwnPtr<CSSParserSelector> >*); + CSSSelectorVector* createFloatingSelectorVector(); + PassOwnPtr<CSSSelectorVector> sinkFloatingSelectorVector(CSSSelectorVector*); CSSParserValueList* createFloatingValueList(); PassOwnPtr<CSSParserValueList> sinkFloatingValueList(CSSParserValueList*); @@ -260,10 +271,10 @@ public: typedef Vector<RefPtr<StyleRuleBase> > RuleList; StyleRuleBase* createMediaRule(MediaQuerySet*, RuleList*); RuleList* createRuleList(); - StyleRuleBase* createStyleRule(Vector<OwnPtr<CSSParserSelector> >* selectors); + StyleRuleBase* createStyleRule(CSSSelectorVector* selectors); StyleRuleBase* createFontFaceRule(); StyleRuleBase* createPageRule(PassOwnPtr<CSSParserSelector> pageSelector); - StyleRuleBase* createRegionRule(Vector<OwnPtr<CSSParserSelector> >* regionSelector, RuleList* rules); + StyleRuleBase* createRegionRule(CSSSelectorVector* regionSelector, RuleList* rules); StyleRuleBase* createMarginAtRule(CSSSelector::MarginBoxType); void startDeclarationsForMarginBox(); void endDeclarationsForMarginBox(); @@ -286,10 +297,10 @@ public: void invalidBlockHit(); - Vector<OwnPtr<CSSParserSelector> >* reusableSelectorVector() { return &m_reusableSelectorVector; } + CSSSelectorVector* selectorVector() { return m_selectorVector.get(); } - void setReusableRegionSelectorVector(Vector<OwnPtr<CSSParserSelector> >* selectors); - Vector<OwnPtr<CSSParserSelector> >* reusableRegionSelectorVector() { return &m_reusableRegionSelectorVector; } + void setReusableRegionSelectorVector(CSSSelectorVector* selectors); + CSSSelectorVector* reusableRegionSelectorVector() { return &m_reusableRegionSelectorVector; } void updateLastSelectorLineAndPosition(); void updateLastMediaLine(MediaQuerySet*); @@ -307,8 +318,9 @@ public: RefPtr<StyleKeyframe> m_keyframe; OwnPtr<MediaQuery> m_mediaQuery; OwnPtr<CSSParserValueList> m_valueList; + typedef Vector<CSSProperty, 256> ParsedPropertyVector; - ParsedPropertyVector m_parsedProperties; + OwnPtr<ParsedPropertyVector> m_parsedProperties; CSSSelectorList* m_selectorListForParseSelector; unsigned m_numParsedPropertiesBeforeMarginBox; @@ -430,7 +442,7 @@ private: Vector<RefPtr<MediaQuerySet> > m_parsedMediaQuerySets; Vector<OwnPtr<RuleList> > m_parsedRuleLists; HashSet<CSSParserSelector*> m_floatingSelectors; - HashSet<Vector<OwnPtr<CSSParserSelector> >*> m_floatingSelectorVectors; + HashSet<CSSSelectorVector*> m_floatingSelectorVectors; HashSet<CSSParserValueList*> m_floatingValueLists; HashSet<CSSParserFunction*> m_floatingFunctions; @@ -440,8 +452,8 @@ private: OwnPtr<Vector<RefPtr<StyleKeyframe> > > m_floatingKeyframeVector; - Vector<OwnPtr<CSSParserSelector> > m_reusableSelectorVector; - Vector<OwnPtr<CSSParserSelector> > m_reusableRegionSelectorVector; + OwnPtr<CSSSelectorVector> m_selectorVector; + CSSSelectorVector m_reusableRegionSelectorVector; RefPtr<CSSCalcValue> m_parsedCalculation; diff --git a/Source/WebCore/css/CSSParserValues.cpp b/Source/WebCore/css/CSSParserValues.cpp index 37a0d452c..1ab4dfefd 100644 --- a/Source/WebCore/css/CSSParserValues.cpp +++ b/Source/WebCore/css/CSSParserValues.cpp @@ -114,7 +114,7 @@ CSSParserSelector::~CSSParserSelector() } } -void CSSParserSelector::adoptSelectorVector(Vector<OwnPtr<CSSParserSelector> >& selectorVector) +void CSSParserSelector::adoptSelectorVector(CSSSelectorVector& selectorVector) { CSSSelectorList* selectorList = fastNew<CSSSelectorList>(); selectorList->adoptSelectorVector(selectorVector); diff --git a/Source/WebCore/css/CSSParserValues.h b/Source/WebCore/css/CSSParserValues.h index 90d26a46d..a736abb89 100644 --- a/Source/WebCore/css/CSSParserValues.h +++ b/Source/WebCore/css/CSSParserValues.h @@ -77,6 +77,7 @@ public: void extend(CSSParserValueList&); unsigned size() const { return m_values.size(); } + unsigned currentIndex() { return m_current; } CSSParserValue* current() { return m_current < m_values.size() ? &m_values[m_current] : 0; } CSSParserValue* next() { ++m_current; return current(); } CSSParserValue* previous() @@ -103,6 +104,10 @@ public: OwnPtr<CSSParserValueList> args; }; +class CSSParserSelector; + +typedef Vector<OwnPtr<CSSParserSelector> > CSSSelectorVector; + class CSSParserSelector { WTF_MAKE_FAST_ALLOCATED; public: @@ -119,7 +124,7 @@ public: void setRelation(CSSSelector::Relation value) { m_selector->m_relation = value; } void setForPage() { m_selector->setForPage(); } - void adoptSelectorVector(Vector<OwnPtr<CSSParserSelector> >& selectorVector); + void adoptSelectorVector(CSSSelectorVector&); CSSSelector::PseudoType pseudoType() const { return m_selector->pseudoType(); } bool isUnknownPseudoElement() const { return m_selector->isUnknownPseudoElement(); } diff --git a/Source/WebCore/css/CSSPrimitiveValue.cpp b/Source/WebCore/css/CSSPrimitiveValue.cpp index d5e6eb654..65ca80427 100644 --- a/Source/WebCore/css/CSSPrimitiveValue.cpp +++ b/Source/WebCore/css/CSSPrimitiveValue.cpp @@ -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" @@ -43,7 +44,7 @@ #include <wtf/text/StringBuffer.h> #include <wtf/text/StringBuilder.h> -#if ENABLE(DASHBOARD_SUPPORT) +#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION) #include "DashboardRegion.h" #endif @@ -330,7 +331,7 @@ void CSSPrimitiveValue::init(PassRefPtr<Quad> quad) m_value.quad = quad.leakRef(); } -#if ENABLE(DASHBOARD_SUPPORT) +#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION) void CSSPrimitiveValue::init(PassRefPtr<DashboardRegion> r) { m_primitiveUnitType = CSS_DASHBOARD_REGION; @@ -827,17 +828,26 @@ Pair* CSSPrimitiveValue::getPairValue(ExceptionCode& ec) const return m_value.pair; } -static String formatNumber(double number) +static String formatNumber(double number, const char* suffix, unsigned suffixLength) { DecimalNumber decimal(number); - StringBuffer<UChar> buffer(decimal.bufferLengthForStringDecimal()); + StringBuffer<LChar> buffer(decimal.bufferLengthForStringDecimal() + suffixLength); unsigned length = decimal.toStringDecimal(buffer.characters(), buffer.length()); - ASSERT_UNUSED(length, length == buffer.length()); + ASSERT(length + suffixLength == buffer.length()); + + for (unsigned i = 0; i < suffixLength; ++i) + buffer[length + i] = static_cast<LChar>(suffix[i]); return String::adopt(buffer); } +template <unsigned characterCount> +ALWAYS_INLINE static String formatNumber(double number, const char (&characters)[characterCount]) +{ + return formatNumber(number, characters, characterCount - 1); +} + String CSSPrimitiveValue::customCssText() const { // FIXME: return the original value instead of a generated one (e.g. color @@ -855,72 +865,72 @@ String CSSPrimitiveValue::customCssText() const break; case CSS_NUMBER: case CSS_PARSER_INTEGER: - text = formatNumber(m_value.num); + text = formatNumber(m_value.num, ""); break; case CSS_PERCENTAGE: - text = formatNumber(m_value.num) + "%"; + text = formatNumber(m_value.num, "%"); break; case CSS_EMS: - text = formatNumber(m_value.num) + "em"; + text = formatNumber(m_value.num, "em"); break; case CSS_EXS: - text = formatNumber(m_value.num) + "ex"; + text = formatNumber(m_value.num, "ex"); break; case CSS_REMS: - text = formatNumber(m_value.num) + "rem"; + text = formatNumber(m_value.num, "rem"); break; case CSS_PX: - text = formatNumber(m_value.num) + "px"; + text = formatNumber(m_value.num, "px"); break; case CSS_CM: - text = formatNumber(m_value.num) + "cm"; + text = formatNumber(m_value.num, "cm"); break; #if ENABLE(CSS_IMAGE_RESOLUTION) case CSS_DPPX: - text = formatNumber(m_value.num) + "dppx"; + text = formatNumber(m_value.num, "dppx"); break; case CSS_DPI: - text = formatNumber(m_value.num) + "dpi"; + text = formatNumber(m_value.num, "dpi"); break; case CSS_DPCM: - text = formatNumber(m_value.num) + "dpcm"; + text = formatNumber(m_value.num, "dpcm"); break; #endif case CSS_MM: - text = formatNumber(m_value.num) + "mm"; + text = formatNumber(m_value.num, "mm"); break; case CSS_IN: - text = formatNumber(m_value.num) + "in"; + text = formatNumber(m_value.num, "in"); break; case CSS_PT: - text = formatNumber(m_value.num) + "pt"; + text = formatNumber(m_value.num, "pt"); break; case CSS_PC: - text = formatNumber(m_value.num) + "pc"; + text = formatNumber(m_value.num, "pc"); break; case CSS_DEG: - text = formatNumber(m_value.num) + "deg"; + text = formatNumber(m_value.num, "deg"); break; case CSS_RAD: - text = formatNumber(m_value.num) + "rad"; + text = formatNumber(m_value.num, "rad"); break; case CSS_GRAD: - text = formatNumber(m_value.num) + "grad"; + text = formatNumber(m_value.num, "grad"); break; case CSS_MS: - text = formatNumber(m_value.num) + "ms"; + text = formatNumber(m_value.num, "ms"); break; case CSS_S: - text = formatNumber(m_value.num) + "s"; + text = formatNumber(m_value.num, "s"); break; case CSS_HZ: - text = formatNumber(m_value.num) + "hz"; + text = formatNumber(m_value.num, "hz"); break; case CSS_KHZ: - text = formatNumber(m_value.num) + "khz"; + text = formatNumber(m_value.num, "khz"); break; case CSS_TURN: - text = formatNumber(m_value.num) + "turn"; + text = formatNumber(m_value.num, "turn"); break; case CSS_DIMENSION: // FIXME @@ -1060,12 +1070,18 @@ String CSSPrimitiveValue::customCssText() const text += m_value.pair->second()->cssText(); } break; -#if ENABLE(DASHBOARD_SUPPORT) +#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION) case CSS_DASHBOARD_REGION: for (DashboardRegion* region = getDashboardRegionValue(); region; region = region->m_next.get()) { if (!text.isEmpty()) text.append(' '); +#if ENABLE(DASHBOARD_SUPPORT) && ENABLE(WIDGET_REGION) + text += region->m_cssFunctionName; +#elif ENABLE(DASHBOARD_SUPPORT) text += "dashboard-region("; +#else + text += "region("; +#endif text += region->m_label; if (region->m_isCircle) text += " circle"; @@ -1106,13 +1122,13 @@ String CSSPrimitiveValue::customCssText() const text = m_value.shape->cssText(); break; case CSS_VW: - text = formatNumber(m_value.num) + "vw"; + text = formatNumber(m_value.num, "vw"); break; case CSS_VH: - text = formatNumber(m_value.num) + "vh"; + text = formatNumber(m_value.num, "vh"); break; case CSS_VMIN: - text = formatNumber(m_value.num) + "vmin"; + text = formatNumber(m_value.num, "vmin"); break; #if ENABLE(CSS_VARIABLES) case CSS_VARIABLE_NAME: @@ -1188,7 +1204,7 @@ PassRefPtr<CSSPrimitiveValue> CSSPrimitiveValue::cloneForCSSOM() const // Pair is not exposed to the CSSOM, no need for a deep clone. result = CSSPrimitiveValue::create(m_value.pair); break; -#if ENABLE(DASHBOARD_SUPPORT) +#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION) case CSS_DASHBOARD_REGION: // DashboardRegion is not exposed to the CSSOM, no need for a deep clone. result = CSSPrimitiveValue::create(m_value.region); @@ -1252,4 +1268,48 @@ PassRefPtr<CSSPrimitiveValue> CSSPrimitiveValue::cloneForCSSOM() const return result; } +void CSSPrimitiveValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo 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 diff --git a/Source/WebCore/css/CSSPrimitiveValue.h b/Source/WebCore/css/CSSPrimitiveValue.h index 87069c043..fd0832d34 100644 --- a/Source/WebCore/css/CSSPrimitiveValue.h +++ b/Source/WebCore/css/CSSPrimitiveValue.h @@ -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); diff --git a/Source/WebCore/css/CSSPrimitiveValueMappings.h b/Source/WebCore/css/CSSPrimitiveValueMappings.h index e8638456a..6a337602b 100644 --- a/Source/WebCore/css/CSSPrimitiveValueMappings.h +++ b/Source/WebCore/css/CSSPrimitiveValueMappings.h @@ -2366,6 +2366,9 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUserSelect e) case SELECT_TEXT: m_value.ident = CSSValueText; break; + case SELECT_ALL: + m_value.ident = CSSValueAll; + break; } } @@ -2378,6 +2381,8 @@ template<> inline CSSPrimitiveValue::operator EUserSelect() const return SELECT_NONE; case CSSValueText: return SELECT_TEXT; + case CSSValueAll: + return SELECT_ALL; default: ASSERT_NOT_REACHED(); return SELECT_TEXT; @@ -3379,6 +3384,103 @@ template<> inline CSSPrimitiveValue::operator CustomFilterOperation::MeshBoxType } #endif // ENABLE(CSS_SHADERS) +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(BlendMode blendMode) + : CSSValue(PrimitiveClass) +{ + m_primitiveUnitType = CSS_IDENT; + switch (blendMode) { + case BlendModeNormal: + m_value.ident = CSSValueNormal; + break; + case BlendModeMultiply: + m_value.ident = CSSValueMultiply; + break; + case BlendModeScreen: + m_value.ident = CSSValueScreen; + break; + case BlendModeOverlay: + m_value.ident = CSSValueOverlay; + break; + case BlendModeDarken: + m_value.ident = CSSValueDarken; + break; + case BlendModeLighten: + m_value.ident = CSSValueLighten; + break; + case BlendModeColorDodge: + m_value.ident = CSSValueColorDodge; + break; + case BlendModeColorBurn: + m_value.ident = CSSValueColorBurn; + break; + case BlendModeHardLight: + m_value.ident = CSSValueHardLight; + break; + case BlendModeSoftLight: + m_value.ident = CSSValueSoftLight; + break; + case BlendModeDifference: + m_value.ident = CSSValueDifference; + break; + case BlendModeExclusion: + m_value.ident = CSSValueExclusion; + break; + case BlendModeHue: + m_value.ident = CSSValueHue; + break; + case BlendModeSaturation: + m_value.ident = CSSValueSaturation; + break; + case BlendModeColor: + m_value.ident = CSSValueColor; + break; + case BlendModeLuminosity: + m_value.ident = CSSValueLuminosity; + break; + } +} + +template<> inline CSSPrimitiveValue::operator BlendMode() const +{ + switch (m_value.ident) { + case CSSValueNormal: + return BlendModeNormal; + case CSSValueMultiply: + return BlendModeMultiply; + case CSSValueScreen: + return BlendModeScreen; + case CSSValueOverlay: + return BlendModeOverlay; + case CSSValueDarken: + return BlendModeDarken; + case CSSValueLighten: + return BlendModeLighten; + case CSSValueColorDodge: + return BlendModeColorDodge; + case CSSValueColorBurn: + return BlendModeColorBurn; + case CSSValueHardLight: + return BlendModeHardLight; + case CSSValueSoftLight: + return BlendModeSoftLight; + case CSSValueDifference: + return BlendModeDifference; + case CSSValueExclusion: + return BlendModeExclusion; + case CSSValueHue: + return BlendModeHue; + case CSSValueSaturation: + return BlendModeSaturation; + case CSSValueColor: + return BlendModeColor; + case CSSValueLuminosity: + return BlendModeLuminosity; + default: + ASSERT_NOT_REACHED(); + return BlendModeNormal; + } +} + #if ENABLE(SVG) template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineCap e) diff --git a/Source/WebCore/css/CSSProperty.cpp b/Source/WebCore/css/CSSProperty.cpp index 8c82dc65a..0b87cea30 100644 --- a/Source/WebCore/css/CSSProperty.cpp +++ b/Source/WebCore/css/CSSProperty.cpp @@ -22,6 +22,7 @@ #include "CSSProperty.h" #include "CSSValueList.h" +#include "MemoryInstrumentation.h" #include "PlatformString.h" #include "RenderStyleConstants.h" #include "StylePropertyShorthand.h" @@ -339,6 +340,7 @@ bool CSSProperty::isInheritedProperty(CSSPropertyID propertyID) case CSSPropertyWebkitPrintColorAdjust: case CSSPropertyWebkitRtlOrdering: case CSSPropertyWebkitTextCombine: + case CSSPropertyWebkitTextDecorationLine: case CSSPropertyWebkitTextDecorationsInEffect: case CSSPropertyWebkitTextEmphasis: case CSSPropertyWebkitTextEmphasisColor: @@ -682,6 +684,9 @@ bool CSSProperty::isInheritedProperty(CSSPropertyID propertyID) #if ENABLE(DASHBOARD_SUPPORT) case CSSPropertyWebkitDashboardRegion: #endif +#if ENABLE(WIDGET_REGION) + case CSSPropertyWebkitWidgetRegion: +#endif return false; case CSSPropertyInvalid: ASSERT_NOT_REACHED(); @@ -691,4 +696,10 @@ bool CSSProperty::isInheritedProperty(CSSPropertyID propertyID) return false; } +void CSSProperty::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedMember(m_value); +} + } // namespace WebCore diff --git a/Source/WebCore/css/CSSProperty.h b/Source/WebCore/css/CSSProperty.h index 712414666..57a30124f 100644 --- a/Source/WebCore/css/CSSProperty.h +++ b/Source/WebCore/css/CSSProperty.h @@ -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; diff --git a/Source/WebCore/css/CSSPropertyNames.in b/Source/WebCore/css/CSSPropertyNames.in index 547907efb..0ee20df2b 100644 --- a/Source/WebCore/css/CSSPropertyNames.in +++ b/Source/WebCore/css/CSSPropertyNames.in @@ -351,6 +351,7 @@ z-index -webkit-rtl-ordering -webkit-text-combine -epub-text-combine = -webkit-text-combine +-webkit-text-decoration-line -webkit-text-decorations-in-effect -webkit-text-emphasis -epub-text-emphasis = -webkit-text-emphasis @@ -401,6 +402,9 @@ z-index #if defined(ENABLE_DASHBOARD_SUPPORT) && ENABLE_DASHBOARD_SUPPORT -webkit-dashboard-region #endif +#if defined(ENABLE_WIDGET_REGION) && ENABLE_WIDGET_REGION +-webkit-widget-region +#endif #if defined(ENABLE_OVERFLOW_SCROLLING) && ENABLE_OVERFLOW_SCROLLING -webkit-overflow-scrolling #endif diff --git a/Source/WebCore/css/CSSPropertySourceData.h b/Source/WebCore/css/CSSPropertySourceData.h index 69ee94da0..24daef4a9 100644 --- a/Source/WebCore/css/CSSPropertySourceData.h +++ b/Source/WebCore/css/CSSPropertySourceData.h @@ -93,7 +93,8 @@ struct CSSRuleSourceData : public RefCounted<CSSRuleSourceData> { MEDIA_RULE, FONT_FACE_RULE, PAGE_RULE, - KEYFRAMES_RULE + KEYFRAMES_RULE, + REGION_RULE }; static PassRefPtr<CSSRuleSourceData> create(Type type) diff --git a/Source/WebCore/css/CSSReflectValue.cpp b/Source/WebCore/css/CSSReflectValue.cpp index b36c3ad7b..ede3c9a1f 100644 --- a/Source/WebCore/css/CSSReflectValue.cpp +++ b/Source/WebCore/css/CSSReflectValue.cpp @@ -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 info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedMember(m_offset); + info.addInstrumentedMember(m_mask); +} + } // namespace WebCore diff --git a/Source/WebCore/css/CSSReflectValue.h b/Source/WebCore/css/CSSReflectValue.h index 5cfb20e27..1bdfd5fe7 100644 --- a/Source/WebCore/css/CSSReflectValue.h +++ b/Source/WebCore/css/CSSReflectValue.h @@ -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) diff --git a/Source/WebCore/css/CSSRule.cpp b/Source/WebCore/css/CSSRule.cpp index c3105a05e..2915a6e4a 100644 --- a/Source/WebCore/css/CSSRule.cpp +++ b/Source/WebCore/css/CSSRule.cpp @@ -164,10 +164,59 @@ void CSSRule::reattach(StyleRuleBase* rule) ASSERT_NOT_REACHED(); } +void CSSRule::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + switch (type()) { + case UNKNOWN_RULE: + static_cast<const CSSUnknownRule*>(this)->reportDescendantMemoryUsage(memoryObjectInfo); + return; + case STYLE_RULE: + static_cast<const CSSStyleRule*>(this)->reportDescendantMemoryUsage(memoryObjectInfo); + return; + case PAGE_RULE: + static_cast<const CSSPageRule*>(this)->reportDescendantMemoryUsage(memoryObjectInfo); + return; + case CHARSET_RULE: + static_cast<const CSSCharsetRule*>(this)->reportDescendantMemoryUsage(memoryObjectInfo); + return; + case IMPORT_RULE: + static_cast<const CSSImportRule*>(this)->reportDescendantMemoryUsage(memoryObjectInfo); + return; + case MEDIA_RULE: + static_cast<const CSSMediaRule*>(this)->reportDescendantMemoryUsage(memoryObjectInfo); + return; + case FONT_FACE_RULE: + static_cast<const CSSFontFaceRule*>(this)->reportDescendantMemoryUsage(memoryObjectInfo); + return; + case WEBKIT_KEYFRAMES_RULE: + static_cast<const WebKitCSSKeyframesRule*>(this)->reportDescendantMemoryUsage(memoryObjectInfo); + return; + case WEBKIT_KEYFRAME_RULE: + static_cast<const WebKitCSSKeyframeRule*>(this)->reportDescendantMemoryUsage(memoryObjectInfo); + return; +#if ENABLE(CSS_REGIONS) + case WEBKIT_REGION_RULE: + static_cast<const WebKitCSSRegionRule*>(this)->reportDescendantMemoryUsage(memoryObjectInfo); + return; +#endif + } + ASSERT_NOT_REACHED(); + return; +} + const CSSParserContext& CSSRule::parserContext() const { CSSStyleSheet* styleSheet = parentStyleSheet(); return styleSheet ? styleSheet->contents()->parserContext() : strictCSSParserContext(); } +void CSSRule::reportBaseClassMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + if (m_parentIsRule) + info.addInstrumentedMember(m_parentRule); + else + info.addInstrumentedMember(m_parentStyleSheet); +} + } // namespace WebCore diff --git a/Source/WebCore/css/CSSRule.h b/Source/WebCore/css/CSSRule.h index e38e161dc..65df6221c 100644 --- a/Source/WebCore/css/CSSRule.h +++ b/Source/WebCore/css/CSSRule.h @@ -30,6 +30,7 @@ namespace WebCore { class CSSStyleSheet; +class MemoryObjectInfo; class StyleRuleBase; struct CSSParserContext; typedef int ExceptionCode; @@ -103,6 +104,8 @@ public: void reattach(StyleRuleBase*); + void reportMemoryUsage(MemoryObjectInfo*) const; + protected: CSSRule(CSSStyleSheet* parent, Type type) : m_hasCachedSelectorText(false) @@ -122,6 +125,8 @@ protected: const CSSParserContext& parserContext() const; + void reportBaseClassMemoryUsage(MemoryObjectInfo*) const; + private: mutable unsigned m_hasCachedSelectorText : 1; unsigned m_parentIsRule : 1; diff --git a/Source/WebCore/css/CSSRuleList.cpp b/Source/WebCore/css/CSSRuleList.cpp index a158d6f2e..aed1a7cd9 100644 --- a/Source/WebCore/css/CSSRuleList.cpp +++ b/Source/WebCore/css/CSSRuleList.cpp @@ -51,4 +51,10 @@ void StaticCSSRuleList::deref() delete this; } +void StaticCSSRuleList::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedVector(m_rules); +} + } // namespace WebCore diff --git a/Source/WebCore/css/CSSRuleList.h b/Source/WebCore/css/CSSRuleList.h index c6e75c86e..311ead529 100644 --- a/Source/WebCore/css/CSSRuleList.h +++ b/Source/WebCore/css/CSSRuleList.h @@ -22,6 +22,7 @@ #ifndef CSSRuleList_h #define CSSRuleList_h +#include "MemoryInstrumentation.h" #include <wtf/PassRefPtr.h> #include <wtf/RefCounted.h> #include <wtf/RefPtr.h> @@ -45,6 +46,8 @@ public: virtual CSSRule* item(unsigned index) const = 0; virtual CSSStyleSheet* styleSheet() const = 0; + + virtual void reportMemoryUsage(MemoryObjectInfo*) const = 0; protected: CSSRuleList(); @@ -61,6 +64,8 @@ public: virtual CSSStyleSheet* styleSheet() const { return 0; } + virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE; + private: StaticCSSRuleList(); ~StaticCSSRuleList(); @@ -80,6 +85,12 @@ public: virtual void ref() { m_rule->ref(); } virtual void deref() { m_rule->deref(); } + + virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const OVERRIDE + { + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedMember(m_rule); + } private: virtual unsigned length() const { return m_rule->length(); } diff --git a/Source/WebCore/css/CSSSelectorList.cpp b/Source/WebCore/css/CSSSelectorList.cpp index fb3d1f12f..3cf020a72 100644 --- a/Source/WebCore/css/CSSSelectorList.cpp +++ b/Source/WebCore/css/CSSSelectorList.cpp @@ -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() 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]); @@ -60,7 +58,7 @@ void CSSSelectorList::adopt(CSSSelectorList& list) list.m_selectorArray = 0; } -void CSSSelectorList::adoptSelectorVector(Vector<OwnPtr<CSSParserSelector> >& selectorVector) +void CSSSelectorList::adoptSelectorVector(CSSSelectorVector& selectorVector) { deleteSelectors(); const size_t vectorSize = selectorVector.size(); @@ -97,6 +95,16 @@ void CSSSelectorList::adoptSelectorVector(Vector<OwnPtr<CSSParserSelector> >& se 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 @@ String CSSSelectorList::selectorsText() const return result.toString(); } +void CSSSelectorList::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addRawBuffer(m_selectorArray, length() * sizeof(CSSSelector)); +} + template <typename Functor> static bool forEachTagSelector(Functor& functor, CSSSelector* selector) { diff --git a/Source/WebCore/css/CSSSelectorList.h b/Source/WebCore/css/CSSSelectorList.h index e0aa65c02..c160020e3 100644 --- a/Source/WebCore/css/CSSSelectorList.h +++ b/Source/WebCore/css/CSSSelectorList.h @@ -26,11 +26,13 @@ #ifndef CSSSelectorList_h #define CSSSelectorList_h +#include "CSSParserValues.h" #include "CSSSelector.h" namespace WebCore { class CSSParserSelector; +class MemoryObjectInfo; class CSSSelectorList { WTF_MAKE_FAST_ALLOCATED; @@ -41,18 +43,31 @@ public: ~CSSSelectorList(); void adopt(CSSSelectorList& list); - void adoptSelectorVector(Vector<OwnPtr<CSSParserSelector> >& selectorVector); + void adoptSelectorVector(CSSSelectorVector&); CSSSelector* first() const { return m_selectorArray ? m_selectorArray : 0; } static CSSSelector* next(CSSSelector*); bool hasOneSelector() const { return m_selectorArray && !next(m_selectorArray); } + CSSSelector* selectorAt(size_t index) const { return &m_selectorArray[index]; } + + size_t indexOfNextSelectorAfter(size_t index) const + { + CSSSelector* current = selectorAt(index); + current = next(current); + if (!current) + return notFound; + return current - m_selectorArray; + } bool selectorsNeedNamespaceResolution(); bool hasUnknownPseudoElements() const; 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. diff --git a/Source/WebCore/css/CSSStyleDeclaration.h b/Source/WebCore/css/CSSStyleDeclaration.h index 5d88ebd07..35a08fe52 100644 --- a/Source/WebCore/css/CSSStyleDeclaration.h +++ b/Source/WebCore/css/CSSStyleDeclaration.h @@ -30,6 +30,7 @@ namespace WebCore { class CSSProperty; class CSSStyleSheet; class CSSValue; +class MemoryObjectInfo; class StylePropertySet; class StyledElement; @@ -69,6 +70,8 @@ public: virtual bool cssPropertyMatches(const CSSProperty*) const = 0; virtual CSSStyleSheet* parentStyleSheet() const { return 0; } + virtual void reportMemoryUsage(MemoryObjectInfo*) const = 0; + protected: CSSStyleDeclaration() { } }; diff --git a/Source/WebCore/css/CSSStyleRule.cpp b/Source/WebCore/css/CSSStyleRule.cpp index 1eeb32d42..7f82ae593 100644 --- a/Source/WebCore/css/CSSStyleRule.cpp +++ b/Source/WebCore/css/CSSStyleRule.cpp @@ -26,6 +26,7 @@ #include "CSSSelector.h" #include "CSSStyleSheet.h" #include "Document.h" +#include "MemoryInstrumentation.h" #include "PropertySetCSSStyleDeclaration.h" #include "StylePropertySet.h" #include "StyleRule.h" @@ -127,4 +128,12 @@ void CSSStyleRule::reattach(StyleRule* rule) m_propertiesCSSOMWrapper->reattach(m_styleRule->mutableProperties()); } +void CSSStyleRule::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + CSSRule::reportBaseClassMemoryUsage(memoryObjectInfo); + info.addInstrumentedMember(m_styleRule); + info.addInstrumentedMember(m_propertiesCSSOMWrapper); +} + } // namespace WebCore diff --git a/Source/WebCore/css/CSSStyleRule.h b/Source/WebCore/css/CSSStyleRule.h index d76a802fa..f96cb16cf 100644 --- a/Source/WebCore/css/CSSStyleRule.h +++ b/Source/WebCore/css/CSSStyleRule.h @@ -50,6 +50,8 @@ public: void reattach(StyleRule*); + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: CSSStyleRule(StyleRule*, CSSStyleSheet*); diff --git a/Source/WebCore/css/CSSStyleSheet.cpp b/Source/WebCore/css/CSSStyleSheet.cpp index 00b2d91c5..523a895f5 100644 --- a/Source/WebCore/css/CSSStyleSheet.cpp +++ b/Source/WebCore/css/CSSStyleSheet.cpp @@ -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" @@ -52,6 +53,12 @@ private: virtual CSSRule* item(unsigned index) const { return m_styleSheet->item(index); } virtual CSSStyleSheet* styleSheet() const { return m_styleSheet; } + + virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const OVERRIDE + { + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedMember(m_styleSheet); + } CSSStyleSheet* m_styleSheet; }; @@ -168,6 +175,18 @@ void CSSStyleSheet::reattachChildRuleCSSOMWrappers() } } +void CSSStyleSheet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedMember(m_contents); + info.addMember(m_title); + info.addInstrumentedMember(m_mediaQueries); + info.addInstrumentedMember(m_ownerNode); + info.addInstrumentedMember(m_ownerRule); + info.addInstrumentedMember(m_mediaCSSOMWrapper); + info.addInstrumentedVector(m_childRuleCSSOMWrappers); +} + void CSSStyleSheet::setDisabled(bool disabled) { if (disabled == m_isDisabled) diff --git a/Source/WebCore/css/CSSStyleSheet.h b/Source/WebCore/css/CSSStyleSheet.h index 5a839e0ee..f38472dca 100644 --- a/Source/WebCore/css/CSSStyleSheet.h +++ b/Source/WebCore/css/CSSStyleSheet.h @@ -39,6 +39,7 @@ class CSSStyleSheet; class CachedCSSStyleSheet; class Document; class MediaQuerySet; +class MemoryObjectInfo; class SecurityOrigin; class StyleSheetContents; @@ -105,6 +106,8 @@ public: StyleSheetContents* contents() const { return m_contents.get(); } + void reportMemoryUsage(MemoryObjectInfo*) const; + private: CSSStyleSheet(PassRefPtr<StyleSheetContents>, CSSImportRule* ownerRule); CSSStyleSheet(PassRefPtr<StyleSheetContents>, Node* ownerNode); diff --git a/Source/WebCore/css/CSSTimingFunctionValue.cpp b/Source/WebCore/css/CSSTimingFunctionValue.cpp index dcf7bb29b..9abb19e69 100644 --- a/Source/WebCore/css/CSSTimingFunctionValue.cpp +++ b/Source/WebCore/css/CSSTimingFunctionValue.cpp @@ -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 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 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 info(memoryObjectInfo, this, MemoryInstrumentation::CSS); +} + } // namespace WebCore diff --git a/Source/WebCore/css/CSSTimingFunctionValue.h b/Source/WebCore/css/CSSTimingFunctionValue.h index e544c5ff0..3eb4b2295 100644 --- a/Source/WebCore/css/CSSTimingFunctionValue.h +++ b/Source/WebCore/css/CSSTimingFunctionValue.h @@ -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) diff --git a/Source/WebCore/css/CSSUnicodeRangeValue.cpp b/Source/WebCore/css/CSSUnicodeRangeValue.cpp index 2c2c44d27..abd806df4 100644 --- a/Source/WebCore/css/CSSUnicodeRangeValue.cpp +++ b/Source/WebCore/css/CSSUnicodeRangeValue.cpp @@ -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 info(memoryObjectInfo, this, MemoryInstrumentation::CSS); +} + } diff --git a/Source/WebCore/css/CSSUnicodeRangeValue.h b/Source/WebCore/css/CSSUnicodeRangeValue.h index 4fe1db77c..d50f5b681 100644 --- a/Source/WebCore/css/CSSUnicodeRangeValue.h +++ b/Source/WebCore/css/CSSUnicodeRangeValue.h @@ -44,6 +44,8 @@ public: String customCssText() const; + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: CSSUnicodeRangeValue(UChar32 from, UChar32 to) : CSSValue(UnicodeRangeClass) diff --git a/Source/WebCore/css/CSSUnknownRule.h b/Source/WebCore/css/CSSUnknownRule.h index 9f746ba0e..ab68aef9e 100644 --- a/Source/WebCore/css/CSSUnknownRule.h +++ b/Source/WebCore/css/CSSUnknownRule.h @@ -23,12 +23,19 @@ #define CSSUnknownRule_h #include "CSSRule.h" +#include "MemoryInstrumentation.h" namespace WebCore { class CSSUnknownRule : public CSSRule { public: CSSUnknownRule() : CSSRule(0, CSSRule::UNKNOWN_RULE) { } + + void reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const + { + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + CSSRule::reportBaseClassMemoryUsage(memoryObjectInfo); + } }; } // namespace WebCore diff --git a/Source/WebCore/css/CSSValue.cpp b/Source/WebCore/css/CSSValue.cpp index cda43b9cf..da1ac3314 100644 --- a/Source/WebCore/css/CSSValue.cpp +++ b/Source/WebCore/css/CSSValue.cpp @@ -52,10 +52,12 @@ #endif #include "FontValue.h" #include "FontFeatureValue.h" +#include "MemoryInstrumentation.h" #include "ShadowValue.h" #include "SVGColor.h" #include "SVGPaint.h" #include "WebKitCSSFilterValue.h" +#include "WebKitCSSMixFunctionValue.h" #include "WebKitCSSShaderValue.h" #include "WebKitCSSTransformValue.h" @@ -77,6 +79,12 @@ public: String cssText() const { return m_cssText; } + void reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const + { + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addMember(m_cssText); + } + private: TextCloneCSSValue(ClassType classType, const String& text) : CSSValue(classType, /*isCSSOMSafe*/ true) @@ -121,6 +129,149 @@ void CSSValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheet static_cast<const CSSReflectValue*>(this)->addSubresourceStyleURLs(urls, styleSheet); } +bool CSSValue::hasFailedOrCanceledSubresources() const +{ + // This should get called for internal instances only. + ASSERT(!isCSSOMSafe()); + + if (isValueList()) + return static_cast<const CSSValueList*>(this)->hasFailedOrCanceledSubresources(); + if (classType() == FontFaceSrcClass) + return static_cast<const CSSFontFaceSrcValue*>(this)->hasFailedOrCanceledSubresources(); + if (classType() == ImageClass) + return static_cast<const CSSImageValue*>(this)->hasFailedOrCanceledSubresources(); + if (classType() == CrossfadeClass) + return static_cast<const CSSCrossfadeValue*>(this)->hasFailedOrCanceledSubresources(); +#if ENABLE(CSS_IMAGE_SET) + if (classType() == ImageSetClass) + return static_cast<const CSSImageSetValue*>(this)->hasFailedOrCanceledSubresources(); +#endif + 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 WebKitCSSMixFunctionValueClass: + static_cast<const WebKitCSSMixFunctionValue*>(this)->reportDescendantMemoryUsage(memoryObjectInfo); + return; + 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) { @@ -188,6 +339,8 @@ String CSSValue::cssText() const case WebKitCSSFilterClass: return static_cast<const WebKitCSSFilterValue*>(this)->customCssText(); #if ENABLE(CSS_SHADERS) + case WebKitCSSMixFunctionValueClass: + return static_cast<const WebKitCSSMixFunctionValue*>(this)->customCssText(); case WebKitCSSShaderClass: return static_cast<const WebKitCSSShaderValue*>(this)->customCssText(); #endif @@ -320,6 +473,9 @@ void CSSValue::destroy() delete static_cast<WebKitCSSFilterValue*>(this); return; #if ENABLE(CSS_SHADERS) + case WebKitCSSMixFunctionValueClass: + delete static_cast<WebKitCSSMixFunctionValue*>(this); + return; case WebKitCSSShaderClass: delete static_cast<WebKitCSSShaderValue*>(this); return; @@ -358,6 +514,10 @@ PassRefPtr<CSSValue> CSSValue::cloneForCSSOM() const #if ENABLE(CSS_FILTERS) case WebKitCSSFilterClass: return static_cast<const WebKitCSSFilterValue*>(this)->cloneForCSSOM(); +#if ENABLE(CSS_SHADERS) + case WebKitCSSMixFunctionValueClass: + return static_cast<const WebKitCSSMixFunctionValue*>(this)->cloneForCSSOM(); +#endif #endif case WebKitCSSTransformClass: return static_cast<const WebKitCSSTransformValue*>(this)->cloneForCSSOM(); diff --git a/Source/WebCore/css/CSSValue.h b/Source/WebCore/css/CSSValue.h index 93a6d4a91..63b8a2586 100644 --- a/Source/WebCore/css/CSSValue.h +++ b/Source/WebCore/css/CSSValue.h @@ -29,6 +29,7 @@ namespace WebCore { +class MemoryObjectInfo; class StyleSheetContents; // FIXME: The current CSSValue and subclasses should be turned into internal types (StyleValue). @@ -91,6 +92,7 @@ public: #if ENABLE(CSS_FILTERS) bool isWebKitCSSFilterValue() const { return m_classType == WebKitCSSFilterClass; } #if ENABLE(CSS_SHADERS) + bool isWebKitCSSMixFunctionValue() const { return m_classType == WebKitCSSMixFunctionValueClass; } bool isWebKitCSSShaderValue() const { return m_classType == WebKitCSSShaderClass; } #endif #endif // ENABLE(CSS_FILTERS) @@ -117,9 +119,13 @@ public: void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*) const; + bool hasFailedOrCanceledSubresources() const; + + void reportMemoryUsage(MemoryObjectInfo*) const; + protected: - static const size_t ClassTypeBits = 5; + static const size_t ClassTypeBits = 6; enum ClassType { PrimitiveClass, @@ -173,6 +179,9 @@ protected: #endif #if ENABLE(CSS_FILTERS) WebKitCSSFilterClass, +#if ENABLE(CSS_SHADERS) + WebKitCSSMixFunctionValueClass, +#endif #endif WebKitCSSTransformClass, // Do not append non-list class types here. diff --git a/Source/WebCore/css/CSSValueKeywords.in b/Source/WebCore/css/CSSValueKeywords.in index b6350722b..4af25f80c 100644 --- a/Source/WebCore/css/CSSValueKeywords.in +++ b/Source/WebCore/css/CSSValueKeywords.in @@ -937,6 +937,23 @@ filter-box detached #endif // CSS_SHADERS #endif // CSS_FILTERS +// blend modes +// normal +multiply +screen +// overlay +darken +lighten +color-dodge +color-burn +hard-light +soft-light +difference +exclusion +hue +saturation +color +luminosity #if defined(ENABLE_CSS_IMAGE_RESOLUTION) && ENABLE_CSS_IMAGE_RESOLUTION from-image diff --git a/Source/WebCore/css/CSSValueList.cpp b/Source/WebCore/css/CSSValueList.cpp index 06f093e1f..0b7ac7380 100644 --- a/Source/WebCore/css/CSSValueList.cpp +++ b/Source/WebCore/css/CSSValueList.cpp @@ -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> @@ -173,6 +174,15 @@ void CSSValueList::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleS m_values[i]->addSubresourceStyleURLs(urls, styleSheet); } +bool CSSValueList::hasFailedOrCanceledSubresources() const +{ + for (unsigned i = 0; i < m_values.size(); ++i) { + if (m_values[i]->hasFailedOrCanceledSubresources()) + return true; + } + return false; +} + CSSValueList::CSSValueList(const CSSValueList& cloneFrom) : CSSValue(cloneFrom.classType(), /* isCSSOMSafe */ true) { @@ -187,4 +197,10 @@ PassRefPtr<CSSValueList> CSSValueList::cloneForCSSOM() const return adoptRef(new CSSValueList(*this)); } +void CSSValueList::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedVector(m_values); +} + } // namespace WebCore diff --git a/Source/WebCore/css/CSSValueList.h b/Source/WebCore/css/CSSValueList.h index 94643daad..e988d6c2e 100644 --- a/Source/WebCore/css/CSSValueList.h +++ b/Source/WebCore/css/CSSValueList.h @@ -64,9 +64,13 @@ public: #endif void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*) const; + + bool hasFailedOrCanceledSubresources() const; PassRefPtr<CSSValueList> cloneForCSSOM() const; + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + protected: CSSValueList(ClassType, ValueListSeparator); CSSValueList(const CSSValueList& cloneFrom); diff --git a/Source/WebCore/css/CSSVariableValue.h b/Source/WebCore/css/CSSVariableValue.h index 2c5b66a6b..e0b97d3ff 100644 --- a/Source/WebCore/css/CSSVariableValue.h +++ b/Source/WebCore/css/CSSVariableValue.h @@ -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 info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addMember(m_name); + info.addMember(m_value); + } + private: CSSVariableValue(const AtomicString& name, const String& value) : CSSValue(VariableClass) diff --git a/Source/WebCore/css/DashboardRegion.h b/Source/WebCore/css/DashboardRegion.h index 91e5d7ae1..a698e4919 100644 --- a/Source/WebCore/css/DashboardRegion.h +++ b/Source/WebCore/css/DashboardRegion.h @@ -23,7 +23,7 @@ #include "Rect.h" -#if ENABLE(DASHBOARD_SUPPORT) +#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION) namespace WebCore { @@ -37,6 +37,11 @@ public: bool m_isCircle : 1; bool m_isRectangle : 1; +#if ENABLE(DASHBOARD_SUPPORT) && ENABLE(WIDGET_REGION) + // Used to tell different CSS function name when both features are enabled. + String m_cssFunctionName; +#endif + private: DashboardRegion() : m_isCircle(false), m_isRectangle(false) { } }; diff --git a/Source/WebCore/css/FontFeatureValue.cpp b/Source/WebCore/css/FontFeatureValue.cpp index 62c396068..491b192e6 100644 --- a/Source/WebCore/css/FontFeatureValue.cpp +++ b/Source/WebCore/css/FontFeatureValue.cpp @@ -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 info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addMember(m_tag); +} + } diff --git a/Source/WebCore/css/FontFeatureValue.h b/Source/WebCore/css/FontFeatureValue.h index 7d5e036c0..28d89f423 100644 --- a/Source/WebCore/css/FontFeatureValue.h +++ b/Source/WebCore/css/FontFeatureValue.h @@ -42,6 +42,8 @@ public: int value() const { return m_value; } String customCssText() const; + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: FontFeatureValue(const String&, int); diff --git a/Source/WebCore/css/FontValue.cpp b/Source/WebCore/css/FontValue.cpp index 8841a7993..4f8742c70 100644 --- a/Source/WebCore/css/FontValue.cpp +++ b/Source/WebCore/css/FontValue.cpp @@ -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 info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedMember(style); + info.addInstrumentedMember(variant); + info.addInstrumentedMember(weight); + info.addInstrumentedMember(size); + info.addInstrumentedMember(lineHeight); + info.addInstrumentedMember(family); +} + } diff --git a/Source/WebCore/css/FontValue.h b/Source/WebCore/css/FontValue.h index 5f8336921..03a61268a 100644 --- a/Source/WebCore/css/FontValue.h +++ b/Source/WebCore/css/FontValue.h @@ -39,6 +39,8 @@ public: String customCssText() const; + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + RefPtr<CSSPrimitiveValue> style; RefPtr<CSSPrimitiveValue> variant; RefPtr<CSSPrimitiveValue> weight; diff --git a/Source/WebCore/css/MediaList.cpp b/Source/WebCore/css/MediaList.cpp index 5fc793e31..5ba7341eb 100644 --- a/Source/WebCore/css/MediaList.cpp +++ b/Source/WebCore/css/MediaList.cpp @@ -26,6 +26,7 @@ #include "ExceptionCode.h" #include "MediaQuery.h" #include "MediaQueryExp.h" +#include "MemoryInstrumentation.h" namespace WebCore { @@ -209,6 +210,12 @@ String MediaQuerySet::mediaText() const } return text; } + +void MediaQuerySet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedVector(m_queries); +} MediaList::MediaList(MediaQuerySet* mediaQueries, CSSStyleSheet* parentSheet) : m_mediaQueries(mediaQueries) @@ -282,4 +289,10 @@ void MediaList::reattach(MediaQuerySet* mediaQueries) m_mediaQueries = mediaQueries; } +void MediaList::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedMember(m_mediaQueries); +} + } diff --git a/Source/WebCore/css/MediaList.h b/Source/WebCore/css/MediaList.h index 32d0ec37d..55f0fc14b 100644 --- a/Source/WebCore/css/MediaList.h +++ b/Source/WebCore/css/MediaList.h @@ -34,6 +34,7 @@ class CSSRule; class CSSStyleSheet; class MediaList; class MediaQuery; +class MemoryObjectInfo; class MediaQuerySet : public RefCounted<MediaQuerySet> { public: @@ -66,6 +67,8 @@ public: 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 @@ public: void reattach(MediaQuerySet*); + void reportMemoryUsage(MemoryObjectInfo*) const; + private: MediaList(); MediaList(MediaQuerySet*, CSSStyleSheet* parentSheet); diff --git a/Source/WebCore/css/MediaQuery.cpp b/Source/WebCore/css/MediaQuery.cpp index 704c00a59..1aabd69d4 100644 --- a/Source/WebCore/css/MediaQuery.cpp +++ b/Source/WebCore/css/MediaQuery.cpp @@ -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 @@ String MediaQuery::cssText() const return m_serializationCache; } +void MediaQuery::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addMember(m_mediaType); + info.addInstrumentedVectorPtr(m_expressions); + info.addMember(m_serializationCache); +} + } //namespace diff --git a/Source/WebCore/css/MediaQuery.h b/Source/WebCore/css/MediaQuery.h index 398e84527..f37c76492 100644 --- a/Source/WebCore/css/MediaQuery.h +++ b/Source/WebCore/css/MediaQuery.h @@ -36,6 +36,7 @@ namespace WebCore { class MediaQueryExp; +class MemoryObjectInfo; class MediaQuery { WTF_MAKE_FAST_ALLOCATED; @@ -58,6 +59,8 @@ public: PassOwnPtr<MediaQuery> copy() const { return adoptPtr(new MediaQuery(*this)); } + void reportMemoryUsage(MemoryObjectInfo*) const; + private: MediaQuery(const MediaQuery&); diff --git a/Source/WebCore/css/MediaQueryExp.cpp b/Source/WebCore/css/MediaQueryExp.cpp index 770d88273..3c778956c 100644 --- a/Source/WebCore/css/MediaQueryExp.cpp +++ b/Source/WebCore/css/MediaQueryExp.cpp @@ -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,12 @@ String MediaQueryExp::serialize() const return m_serializationCache; } +void MediaQueryExp::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addMember(m_mediaFeature); + info.addMember(m_serializationCache); + info.addInstrumentedMember(m_value); +} + } // namespace diff --git a/Source/WebCore/css/MediaQueryExp.h b/Source/WebCore/css/MediaQueryExp.h index 003de02b5..e77ea1790 100644 --- a/Source/WebCore/css/MediaQueryExp.h +++ b/Source/WebCore/css/MediaQueryExp.h @@ -37,6 +37,7 @@ namespace WebCore { class CSSParserValueList; +class MemoryObjectInfo; class MediaQueryExp { WTF_MAKE_FAST_ALLOCATED; @@ -72,6 +73,8 @@ public: PassOwnPtr<MediaQueryExp> copy() const { return adoptPtr(new MediaQueryExp(*this)); } + void reportMemoryUsage(MemoryObjectInfo*) const; + private: MediaQueryExp(const AtomicString& mediaFeature, CSSParserValueList* values); diff --git a/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp b/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp index 8a0afd6e8..0c555804e 100644 --- a/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp +++ b/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp @@ -26,6 +26,7 @@ #include "CSSStyleSheet.h" #include "HTMLNames.h" #include "InspectorInstrumentation.h" +#include "MemoryInstrumentation.h" #include "MutationObserverInterestGroup.h" #include "MutationRecord.h" #include "StylePropertySet.h" @@ -130,21 +131,29 @@ void PropertySetCSSStyleDeclaration::deref() m_propertySet->deref(); } +void PropertySetCSSStyleDeclaration::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedMember(m_propertySet); + if (m_cssomCSSValueClones) + info.addInstrumentedMapEntries(*m_cssomCSSValueClones); +} + unsigned PropertySetCSSStyleDeclaration::length() const { - return propertySet()->propertyCount(); + return m_propertySet->propertyCount(); } String PropertySetCSSStyleDeclaration::item(unsigned i) const { - if (i >= propertySet()->propertyCount()) + if (i >= m_propertySet->propertyCount()) return ""; - return getPropertyName(propertySet()->propertyAt(i).id()); + return getPropertyName(m_propertySet->propertyAt(i).id()); } String PropertySetCSSStyleDeclaration::cssText() const { - return propertySet()->asText(); + return m_propertySet->asText(); } void PropertySetCSSStyleDeclaration::setCssText(const String& text, ExceptionCode& ec) @@ -156,7 +165,7 @@ void PropertySetCSSStyleDeclaration::setCssText(const String& text, ExceptionCod ec = 0; // FIXME: Detect syntax errors and set ec. - ensureMutablePropertySet()->parseDeclaration(text, contextStyleSheet()); + m_propertySet->parseDeclaration(text, contextStyleSheet()); didMutate(PropertyChanged); @@ -170,7 +179,7 @@ PassRefPtr<CSSValue> PropertySetCSSStyleDeclaration::getPropertyCSSValue(const S CSSPropertyID propertyID = cssPropertyID(propertyName); if (!propertyID) return 0; - return cloneAndCacheForCSSOM(propertySet()->getPropertyCSSValue(propertyID).get()); + return cloneAndCacheForCSSOM(m_propertySet->getPropertyCSSValue(propertyID).get()); } String PropertySetCSSStyleDeclaration::getPropertyValue(const String &propertyName) @@ -178,7 +187,7 @@ String PropertySetCSSStyleDeclaration::getPropertyValue(const String &propertyNa CSSPropertyID propertyID = cssPropertyID(propertyName); if (!propertyID) return String(); - return propertySet()->getPropertyValue(propertyID); + return m_propertySet->getPropertyValue(propertyID); } String PropertySetCSSStyleDeclaration::getPropertyPriority(const String& propertyName) @@ -186,7 +195,7 @@ String PropertySetCSSStyleDeclaration::getPropertyPriority(const String& propert CSSPropertyID propertyID = cssPropertyID(propertyName); if (!propertyID) return String(); - return propertySet()->propertyIsImportant(propertyID) ? "important" : ""; + return m_propertySet->propertyIsImportant(propertyID) ? "important" : ""; } String PropertySetCSSStyleDeclaration::getPropertyShorthand(const String& propertyName) @@ -194,7 +203,7 @@ String PropertySetCSSStyleDeclaration::getPropertyShorthand(const String& proper CSSPropertyID propertyID = cssPropertyID(propertyName); if (!propertyID) return String(); - CSSPropertyID shorthandID = propertySet()->getPropertyShorthand(propertyID); + CSSPropertyID shorthandID = m_propertySet->getPropertyShorthand(propertyID); if (!shorthandID) return String(); return getPropertyName(shorthandID); @@ -205,7 +214,7 @@ bool PropertySetCSSStyleDeclaration::isPropertyImplicit(const String& propertyNa CSSPropertyID propertyID = cssPropertyID(propertyName); if (!propertyID) return false; - return propertySet()->isPropertyImplicit(propertyID); + return m_propertySet->isPropertyImplicit(propertyID); } void PropertySetCSSStyleDeclaration::setProperty(const String& propertyName, const String& value, const String& priority, ExceptionCode& ec) @@ -222,7 +231,7 @@ void PropertySetCSSStyleDeclaration::setProperty(const String& propertyName, con willMutate(); ec = 0; - bool changed = ensureMutablePropertySet()->setProperty(propertyID, value, important, contextStyleSheet()); + bool changed = m_propertySet->setProperty(propertyID, value, important, contextStyleSheet()); didMutate(changed ? PropertyChanged : NoChanges); @@ -248,7 +257,7 @@ String PropertySetCSSStyleDeclaration::removeProperty(const String& propertyName ec = 0; String result; - bool changed = ensureMutablePropertySet()->removeProperty(propertyID, &result); + bool changed = m_propertySet->removeProperty(propertyID, &result); didMutate(changed ? PropertyChanged : NoChanges); @@ -262,12 +271,12 @@ String PropertySetCSSStyleDeclaration::removeProperty(const String& propertyName PassRefPtr<CSSValue> PropertySetCSSStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID) { - return propertySet()->getPropertyCSSValue(propertyID); + return m_propertySet->getPropertyCSSValue(propertyID); } String PropertySetCSSStyleDeclaration::getPropertyValueInternal(CSSPropertyID propertyID) { - return propertySet()->getPropertyValue(propertyID); + return m_propertySet->getPropertyValue(propertyID); } void PropertySetCSSStyleDeclaration::setPropertyInternal(CSSPropertyID propertyID, const String& value, bool important, ExceptionCode& ec) @@ -278,7 +287,7 @@ void PropertySetCSSStyleDeclaration::setPropertyInternal(CSSPropertyID propertyI willMutate(); ec = 0; - bool changed = ensureMutablePropertySet()->setProperty(propertyID, value, important, contextStyleSheet()); + bool changed = m_propertySet->setProperty(propertyID, value, important, contextStyleSheet()); didMutate(changed ? PropertyChanged : NoChanges); @@ -313,17 +322,18 @@ StyleSheetContents* PropertySetCSSStyleDeclaration::contextStyleSheet() const PassRefPtr<StylePropertySet> PropertySetCSSStyleDeclaration::copy() const { - return propertySet()->copy(); + return m_propertySet->copy(); } PassRefPtr<StylePropertySet> PropertySetCSSStyleDeclaration::makeMutable() { - return ensureMutablePropertySet(); + ASSERT(m_propertySet->isMutable()); + return m_propertySet; } bool PropertySetCSSStyleDeclaration::cssPropertyMatches(const CSSProperty* property) const { - return propertySet()->propertyMatches(property); + return m_propertySet->propertyMatches(property); } StyleRuleCSSStyleDeclaration::StyleRuleCSSStyleDeclaration(StylePropertySet* propertySet, CSSRule* parentRule) @@ -380,6 +390,20 @@ void StyleRuleCSSStyleDeclaration::reattach(StylePropertySet* propertySet) m_propertySet->ref(); } +void StyleRuleCSSStyleDeclaration::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + PropertySetCSSStyleDeclaration::reportMemoryUsage(memoryObjectInfo); + info.addInstrumentedMember(m_parentRule); +} + +void InlineCSSStyleDeclaration::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + PropertySetCSSStyleDeclaration::reportMemoryUsage(memoryObjectInfo); + info.addInstrumentedMember(m_parentElement); +} + void InlineCSSStyleDeclaration::didMutate(MutationType type) { if (type == NoChanges) @@ -400,11 +424,4 @@ CSSStyleSheet* InlineCSSStyleDeclaration::parentStyleSheet() const return m_parentElement ? m_parentElement->document()->elementSheet() : 0; } -StylePropertySet* InlineCSSStyleDeclaration::ensureMutablePropertySet() -{ - ASSERT(m_propertySet); - ASSERT(m_propertySet->isMutable()); - return m_propertySet; -} - } // namespace WebCore diff --git a/Source/WebCore/css/PropertySetCSSStyleDeclaration.h b/Source/WebCore/css/PropertySetCSSStyleDeclaration.h index 44b73de6f..0bbd64b7c 100644 --- a/Source/WebCore/css/PropertySetCSSStyleDeclaration.h +++ b/Source/WebCore/css/PropertySetCSSStyleDeclaration.h @@ -48,9 +48,7 @@ public: virtual void ref() OVERRIDE; virtual void deref() OVERRIDE; -protected: - const StylePropertySet* propertySet() const { return m_propertySet; } - virtual StylePropertySet* ensureMutablePropertySet() { return m_propertySet; } + virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE; private: virtual CSSRule* parentRule() const OVERRIDE { return 0; }; @@ -99,6 +97,8 @@ public: void reattach(StylePropertySet*); + virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE; + private: StyleRuleCSSStyleDeclaration(StylePropertySet*, CSSRule*); virtual ~StyleRuleCSSStyleDeclaration(); @@ -110,8 +110,6 @@ private: virtual void willMutate() OVERRIDE; virtual void didMutate(MutationType) OVERRIDE; - virtual StylePropertySet* ensureMutablePropertySet() OVERRIDE { return m_propertySet; } - unsigned m_refCount; CSSRule* m_parentRule; }; @@ -124,6 +122,8 @@ public: , m_parentElement(parentElement) { } + + virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE; private: virtual CSSStyleSheet* parentStyleSheet() const OVERRIDE; @@ -132,8 +132,6 @@ private: virtual void didMutate(MutationType) OVERRIDE; - virtual StylePropertySet* ensureMutablePropertySet() OVERRIDE; - StyledElement* m_parentElement; }; diff --git a/Source/WebCore/css/SVGCSSParser.cpp b/Source/WebCore/css/SVGCSSParser.cpp index d06bb203b..c7ec6d9f9 100644 --- a/Source/WebCore/css/SVGCSSParser.cpp +++ b/Source/WebCore/css/SVGCSSParser.cpp @@ -281,7 +281,7 @@ bool CSSParser::parseSVGValue(CSSPropertyID propId, bool important) rollbackLastProperties(1); return false; } - CSSValue* value = m_parsedProperties.last().value(); + CSSValue* value = m_parsedProperties->last().value(); addProperty(CSSPropertyMarkerMid, value, important); addProperty(CSSPropertyMarkerEnd, value, important); m_implicitShorthand = false; diff --git a/Source/WebCore/css/SelectorChecker.cpp b/Source/WebCore/css/SelectorChecker.cpp index ef6ea8236..9a32d6080 100644 --- a/Source/WebCore/css/SelectorChecker.cpp +++ b/Source/WebCore/css/SelectorChecker.cpp @@ -1066,11 +1066,11 @@ bool SelectorChecker::checkOneSelector(const SelectorCheckingContext& context, P case CSSSelector::PseudoReadOnly: if (!element || !element->isFormControlElement()) return false; - return element->isTextFormControl() && element->isReadOnlyFormControl(); + return element->isTextFormControl() && element->shouldMatchReadOnlySelector(); case CSSSelector::PseudoReadWrite: if (!element || !element->isFormControlElement()) return false; - return element->isTextFormControl() && !element->isReadOnlyFormControl(); + return element->isTextFormControl() && element->shouldMatchReadWriteSelector(); case CSSSelector::PseudoOptional: return element && element->isOptionalFormControl(); case CSSSelector::PseudoRequired: diff --git a/Source/WebCore/css/ShadowValue.cpp b/Source/WebCore/css/ShadowValue.cpp index 14c7cda8c..5db003651 100644 --- a/Source/WebCore/css/ShadowValue.cpp +++ b/Source/WebCore/css/ShadowValue.cpp @@ -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 info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedMember(x); + info.addInstrumentedMember(y); + info.addInstrumentedMember(blur); + info.addInstrumentedMember(spread); + info.addInstrumentedMember(style); + info.addInstrumentedMember(color); +} + } diff --git a/Source/WebCore/css/ShadowValue.h b/Source/WebCore/css/ShadowValue.h index 21547a571..f2d8e6f6f 100644 --- a/Source/WebCore/css/ShadowValue.h +++ b/Source/WebCore/css/ShadowValue.h @@ -44,6 +44,8 @@ public: String customCssText() const; + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + RefPtr<CSSPrimitiveValue> x; RefPtr<CSSPrimitiveValue> y; RefPtr<CSSPrimitiveValue> blur; diff --git a/Source/WebCore/css/StyleBuilder.cpp b/Source/WebCore/css/StyleBuilder.cpp index b6bf332a5..25c134990 100644 --- a/Source/WebCore/css/StyleBuilder.cpp +++ b/Source/WebCore/css/StyleBuilder.cpp @@ -1933,6 +1933,7 @@ StyleBuilder::StyleBuilder() setPropertyHandler(CSSPropertyTabSize, ApplyPropertyDefault<unsigned, &RenderStyle::tabSize, unsigned, &RenderStyle::setTabSize, unsigned, &RenderStyle::initialTabSize>::createHandler()); setPropertyHandler(CSSPropertyTextAlign, ApplyPropertyTextAlign::createHandler()); setPropertyHandler(CSSPropertyTextDecoration, ApplyPropertyTextDecoration::createHandler()); + setPropertyHandler(CSSPropertyWebkitTextDecorationLine, ApplyPropertyTextDecoration::createHandler()); setPropertyHandler(CSSPropertyTextIndent, ApplyPropertyLength<&RenderStyle::textIndent, &RenderStyle::setTextIndent, &RenderStyle::initialTextIndent>::createHandler()); setPropertyHandler(CSSPropertyTextOverflow, ApplyPropertyDefault<TextOverflow, &RenderStyle::textOverflow, TextOverflow, &RenderStyle::setTextOverflow, TextOverflow, &RenderStyle::initialTextOverflow>::createHandler()); setPropertyHandler(CSSPropertyTextRendering, ApplyPropertyFont<TextRenderingMode, &FontDescription::textRenderingMode, &FontDescription::setTextRenderingMode, AutoTextRendering>::createHandler()); @@ -1990,13 +1991,15 @@ StyleBuilder::StyleBuilder() setPropertyHandler(CSSPropertyWebkitAlignContent, ApplyPropertyDefault<EAlignContent, &RenderStyle::alignContent, EAlignContent, &RenderStyle::setAlignContent, EAlignContent, &RenderStyle::initialAlignContent>::createHandler()); setPropertyHandler(CSSPropertyWebkitAlignItems, ApplyPropertyDefault<EAlignItems, &RenderStyle::alignItems, EAlignItems, &RenderStyle::setAlignItems, EAlignItems, &RenderStyle::initialAlignItems>::createHandler()); setPropertyHandler(CSSPropertyWebkitAlignSelf, ApplyPropertyDefault<EAlignItems, &RenderStyle::alignSelf, EAlignItems, &RenderStyle::setAlignSelf, EAlignItems, &RenderStyle::initialAlignSelf>::createHandler()); + setPropertyHandler(CSSPropertyWebkitFlex, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitFlexGrow, CSSPropertyWebkitFlexShrink, CSSPropertyWebkitFlexBasis>::createHandler()); setPropertyHandler(CSSPropertyWebkitFlexBasis, ApplyPropertyLength<&RenderStyle::flexBasis, &RenderStyle::setFlexBasis, &RenderStyle::initialFlexBasis, AutoEnabled>::createHandler()); setPropertyHandler(CSSPropertyWebkitFlexDirection, ApplyPropertyDefault<EFlexDirection, &RenderStyle::flexDirection, EFlexDirection, &RenderStyle::setFlexDirection, EFlexDirection, &RenderStyle::initialFlexDirection>::createHandler()); + setPropertyHandler(CSSPropertyWebkitFlexFlow, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitFlexDirection, CSSPropertyWebkitFlexWrap>::createHandler()); setPropertyHandler(CSSPropertyWebkitFlexGrow, ApplyPropertyDefault<float, &RenderStyle::flexGrow, float, &RenderStyle::setFlexGrow, float, &RenderStyle::initialFlexGrow>::createHandler()); setPropertyHandler(CSSPropertyWebkitFlexShrink, ApplyPropertyDefault<float, &RenderStyle::flexShrink, float, &RenderStyle::setFlexShrink, float, &RenderStyle::initialFlexShrink>::createHandler()); setPropertyHandler(CSSPropertyWebkitFlexWrap, ApplyPropertyDefault<EFlexWrap, &RenderStyle::flexWrap, EFlexWrap, &RenderStyle::setFlexWrap, EFlexWrap, &RenderStyle::initialFlexWrap>::createHandler()); setPropertyHandler(CSSPropertyWebkitJustifyContent, ApplyPropertyDefault<EJustifyContent, &RenderStyle::justifyContent, EJustifyContent, &RenderStyle::setJustifyContent, EJustifyContent, &RenderStyle::initialJustifyContent>::createHandler()); - setPropertyHandler(CSSPropertyWebkitOrder, ApplyPropertyDefault<float, &RenderStyle::order, float, &RenderStyle::setOrder, float, &RenderStyle::initialOrder>::createHandler()); + setPropertyHandler(CSSPropertyWebkitOrder, ApplyPropertyDefault<int, &RenderStyle::order, int, &RenderStyle::setOrder, int, &RenderStyle::initialOrder>::createHandler()); #endif #if ENABLE(CSS_REGIONS) setPropertyHandler(CSSPropertyWebkitFlowFrom, ApplyPropertyString<MapNoneToNull, &RenderStyle::regionThread, &RenderStyle::setRegionThread, &RenderStyle::initialRegionThread>::createHandler()); diff --git a/Source/WebCore/css/StylePropertySet.cpp b/Source/WebCore/css/StylePropertySet.cpp index 0c25a5a9c..a48728ae6 100644 --- a/Source/WebCore/css/StylePropertySet.cpp +++ b/Source/WebCore/css/StylePropertySet.cpp @@ -894,6 +894,16 @@ void StylePropertySet::addSubresourceStyleURLs(ListHashSet<KURL>& urls, StyleShe propertyAt(i).value()->addSubresourceStyleURLs(urls, contextStyleSheet); } +bool StylePropertySet::hasFailedOrCanceledSubresources() const +{ + unsigned size = propertyCount(); + for (unsigned i = 0; i < size; ++i) { + if (propertyAt(i).value()->hasFailedOrCanceledSubresources()) + return true; + } + return false; +} + // This is the list of properties we want to copy in the copyBlockProperties() function. // It is the list of CSS properties that apply specially to block-level elements. static const CSSPropertyID blockProperties[] = { @@ -1036,8 +1046,10 @@ PassRefPtr<StylePropertySet> StylePropertySet::copyPropertiesInSet(const CSSProp return StylePropertySet::create(list.data(), list.size()); } -CSSStyleDeclaration* StylePropertySet::ensureCSSStyleDeclaration() const +CSSStyleDeclaration* StylePropertySet::ensureCSSStyleDeclaration() { + ASSERT(isMutable()); + if (m_ownsCSSOMWrapper) { ASSERT(!static_cast<CSSStyleDeclaration*>(propertySetCSSOMWrapperMap().get(this))->parentRule()); ASSERT(!propertySetCSSOMWrapperMap().get(this)->parentElement()); @@ -1049,8 +1061,10 @@ CSSStyleDeclaration* StylePropertySet::ensureCSSStyleDeclaration() const return cssomWrapper; } -CSSStyleDeclaration* StylePropertySet::ensureInlineCSSStyleDeclaration(const StyledElement* parentElement) const +CSSStyleDeclaration* StylePropertySet::ensureInlineCSSStyleDeclaration(const StyledElement* parentElement) { + ASSERT(isMutable()); + if (m_ownsCSSOMWrapper) { ASSERT(propertySetCSSOMWrapperMap().get(this)->parentElement() == parentElement); return propertySetCSSOMWrapperMap().get(this); @@ -1075,6 +1089,18 @@ unsigned StylePropertySet::averageSizeInBytes() return sizeof(StylePropertySet) + sizeof(CSSProperty) * 2; } +void StylePropertySet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + if (m_isMutable) + 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. struct SameSizeAsStylePropertySet : public RefCounted<SameSizeAsStylePropertySet> { unsigned bitfield; diff --git a/Source/WebCore/css/StylePropertySet.h b/Source/WebCore/css/StylePropertySet.h index a4a13ef5e..307a3ef80 100644 --- a/Source/WebCore/css/StylePropertySet.h +++ b/Source/WebCore/css/StylePropertySet.h @@ -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 @@ namespace WebCore { class CSSRule; class CSSStyleDeclaration; class KURL; +class MemoryObjectInfo; class PropertySetCSSStyleDeclaration; class StyledElement; class StylePropertyShorthand; @@ -105,24 +105,20 @@ public: void clearParentElement(StyledElement*); - CSSStyleDeclaration* ensureCSSStyleDeclaration() const; - CSSStyleDeclaration* ensureInlineCSSStyleDeclaration(const StyledElement* parentElement) const; + CSSStyleDeclaration* ensureCSSStyleDeclaration(); + CSSStyleDeclaration* ensureInlineCSSStyleDeclaration(const StyledElement* parentElement); bool isMutable() const { return m_isMutable; } + bool hasFailedOrCanceledSubresources() const; + 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); diff --git a/Source/WebCore/css/StyleResolver.cpp b/Source/WebCore/css/StyleResolver.cpp index 92b925ca2..ff9213aa8 100644 --- a/Source/WebCore/css/StyleResolver.cpp +++ b/Source/WebCore/css/StyleResolver.cpp @@ -132,7 +132,7 @@ #include "WebKitCSSFilterValue.h" #endif -#if ENABLE(DASHBOARD_SUPPORT) +#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION) #include "DashboardRegion.h" #endif @@ -153,6 +153,7 @@ #include "StyleCustomFilterProgram.h" #include "StylePendingShader.h" #include "StyleShader.h" +#include "WebKitCSSMixFunctionValue.h" #include "WebKitCSSShaderValue.h" #endif @@ -198,11 +199,12 @@ if (primitiveValue) \ class RuleData { public: - RuleData(StyleRule*, CSSSelector*, unsigned position, bool hasDocumentSecurityOrigin, bool canUseFastCheckSelector, bool inRegionRule); + RuleData(StyleRule*, unsigned selectorIndex, unsigned position, bool hasDocumentSecurityOrigin, bool canUseFastCheckSelector, bool inRegionRule); unsigned position() const { return m_position; } StyleRule* rule() const { return m_rule; } - CSSSelector* selector() const { return m_selector; } + CSSSelector* selector() const { return m_rule->selectorList().selectorAt(m_selectorIndex); } + unsigned selectorIndex() const { return m_selectorIndex; } bool hasFastCheckableSelector() const { return m_hasFastCheckableSelector; } bool hasMultipartSelector() const { return m_hasMultipartSelector; } @@ -221,11 +223,11 @@ public: private: StyleRule* m_rule; - CSSSelector* m_selector; - unsigned m_specificity; + unsigned m_selectorIndex : 12; // This number was picked fairly arbitrarily. We can probably lower it if we need to. // Some simple testing showed <100,000 RuleData's on large sites. - unsigned m_position : 24; + unsigned m_position : 20; + unsigned m_specificity : 24; unsigned m_hasFastCheckableSelector : 1; unsigned m_hasMultipartSelector : 1; unsigned m_hasRightmostSelectorMatchingHTMLBasedOnRuleHash : 1; @@ -239,10 +241,9 @@ private: struct SameSizeAsRuleData { void* a; - void* b; + unsigned b; unsigned c; - unsigned d; - unsigned e[4]; + unsigned d[4]; }; COMPILE_ASSERT(sizeof(RuleData) == sizeof(SameSizeAsRuleData), RuleData_should_stay_small); @@ -257,7 +258,7 @@ public: void addRulesFromSheet(StyleSheetContents*, const MediaQueryEvaluator&, StyleResolver* = 0, const ContainerNode* = 0); void addStyleRule(StyleRule*, bool hasDocumentSecurityOrigin, bool canUseFastCheckSelector, bool isInRegionRule = false); - void addRule(StyleRule*, CSSSelector*, bool hasDocumentSecurityOrigin, bool canUseFastCheckSelector, bool isInRegionRule = false); + void addRule(StyleRule*, unsigned selectorIndex, bool hasDocumentSecurityOrigin, bool canUseFastCheckSelector, bool isInRegionRule = false); void addPageRule(StyleRulePage*); void addToRuleSet(AtomicStringImpl* key, AtomRuleMap&, const RuleData&); void addRegionRule(StyleRuleRegion*, bool hasDocumentSecurityOrigin); @@ -480,7 +481,7 @@ static PassOwnPtr<RuleSet> makeRuleSet(const Vector<StyleResolver::RuleFeature>& return nullptr; OwnPtr<RuleSet> ruleSet = RuleSet::create(); for (size_t i = 0; i < size; ++i) - ruleSet->addRule(rules[i].rule, rules[i].selector, rules[i].hasDocumentSecurityOrigin, false); + ruleSet->addRule(rules[i].rule, rules[i].selectorIndex, rules[i].hasDocumentSecurityOrigin, false); ruleSet->shrinkToFit(); return ruleSet.release(); } @@ -737,7 +738,7 @@ void StyleResolver::Features::clear() void StyleResolver::Features::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const { - MemoryClassInfo<StyleResolver::Features> info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); info.addHashSet(idsInRules); info.addHashSet(attrsInRules); info.addVector(siblingRules); @@ -863,7 +864,7 @@ void StyleResolver::addMatchedProperties(MatchResult& matchResult, const StylePr matchResult.matchedRules.append(rule); } -inline void StyleResolver::addElementStyleProperties(MatchResult& result, StylePropertySet* propertySet, bool isCacheable) +inline void StyleResolver::addElementStyleProperties(MatchResult& result, const StylePropertySet* propertySet, bool isCacheable) { if (!propertySet) return; @@ -886,10 +887,8 @@ void StyleResolver::collectMatchingRules(RuleSet* rules, int& firstRuleIndex, in collectMatchingRulesForList(rules->idRules(m_element->idForStyleResolution().impl()), firstRuleIndex, lastRuleIndex, options); if (m_element->hasClass()) { ASSERT(m_styledElement); - const SpaceSplitString& classNames = m_styledElement->classNames(); - size_t size = classNames.size(); - for (size_t i = 0; i < size; ++i) - collectMatchingRulesForList(rules->classRules(classNames[i].impl()), firstRuleIndex, lastRuleIndex, options); + for (size_t i = 0; i < m_styledElement->classNames().size(); ++i) + collectMatchingRulesForList(rules->classRules(m_styledElement->classNames()[i].impl()), firstRuleIndex, lastRuleIndex, options); } const AtomicString& pseudoId = m_element->shadowPseudoId(); if (!pseudoId.isEmpty()) { @@ -1186,7 +1185,7 @@ void StyleResolver::matchAllRules(MatchResult& result, bool includeSMILPropertie // FIXME: Media control shadow trees seem to have problems with caching. bool isInlineStyleCacheable = !m_styledElement->inlineStyle()->isMutable() && !m_styledElement->isInShadowTree(); // FIXME: Constify. - addElementStyleProperties(result, const_cast<StylePropertySet*>(m_styledElement->inlineStyle()), isInlineStyleCacheable); + addElementStyleProperties(result, m_styledElement->inlineStyle(), isInlineStyleCacheable); } #if ENABLE(SVG) @@ -1350,7 +1349,7 @@ bool StyleResolver::canShareStyleWithControl(StyledElement* element) const } // This function makes some assumptions that only make sense for attribute styles (we only compare CSSProperty::id() and CSSProperty::value().) -static inline bool attributeStylesEqual(StylePropertySet* a, StylePropertySet* b) +static inline bool attributeStylesEqual(const StylePropertySet* a, const StylePropertySet* b) { if (a == b) return true; @@ -1395,14 +1394,16 @@ bool StyleResolver::canShareStyleWithElement(StyledElement* element) const return false; if (element->inlineStyle()) return false; + if (element->needsStyleRecalc()) + return false; #if ENABLE(SVG) if (element->isSVGElement() && static_cast<SVGElement*>(element)->animatedSMILStyleProperties()) return false; #endif if (!!element->attributeStyle() != !!m_styledElement->attributeStyle()) return false; - StylePropertySet* additionalAttributeStyleA = element->additionalAttributeStyle(); - StylePropertySet* additionalAttributeStyleB = m_styledElement->additionalAttributeStyle(); + const StylePropertySet* additionalAttributeStyleA = element->additionalAttributeStyle(); + const StylePropertySet* additionalAttributeStyleB = m_styledElement->additionalAttributeStyle(); if (!additionalAttributeStyleA != !additionalAttributeStyleB) return false; if (element->isLink() != m_element->isLink()) @@ -1482,8 +1483,17 @@ bool StyleResolver::canShareStyleWithElement(StyledElement* element) const if (elementHasDirectionAuto(element) || elementHasDirectionAuto(m_element)) return false; - if (element->hasClass() && m_element->getAttribute(classAttr) != element->getAttribute(classAttr)) - return false; + if (element->hasClass()) { +#if ENABLE(SVG) + // SVG elements require a (slow!) getAttribute comparision because "class" is an animatable attribute for SVG. + if (element->isSVGElement()) { + if (element->getAttribute(classAttr) != m_element->getAttribute(classAttr)) + return false; + } else +#endif + if (element->fastGetAttribute(classAttr) != m_element->fastGetAttribute(classAttr)) + return false; + } if (element->attributeStyle() && !attributeStylesEqual(element->attributeStyle(), m_styledElement->attributeStyle())) return false; @@ -2143,8 +2153,10 @@ void StyleResolver::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty if (style->writingMode() != TopToBottomWritingMode && (style->display() == BOX || style->display() == INLINE_BOX)) style->setWritingMode(TopToBottomWritingMode); - if (e && e->parentNode() && e->parentNode()->renderer() && e->parentNode()->renderer()->isFlexibleBox()) + if (e && e->parentNode() && e->parentNode()->renderer() && e->parentNode()->renderer()->isFlexibleBox()) { + style->setFloating(NoFloat); style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloating(), m_checker.strictParsing())); + } } // Make sure our z-index value is only applied if the object is positioned. @@ -2483,25 +2495,27 @@ static inline bool containsUncommonAttributeSelector(const CSSSelector* selector return false; } -RuleData::RuleData(StyleRule* rule, CSSSelector* selector, unsigned position, bool hasDocumentSecurityOrigin, bool canUseFastCheckSelector, bool inRegionRule) +RuleData::RuleData(StyleRule* rule, unsigned selectorIndex, unsigned position, bool hasDocumentSecurityOrigin, bool canUseFastCheckSelector, bool inRegionRule) : m_rule(rule) - , m_selector(selector) - , m_specificity(selector->specificity()) + , m_selectorIndex(selectorIndex) , m_position(position) - , m_hasFastCheckableSelector(canUseFastCheckSelector && SelectorChecker::isFastCheckableSelector(selector)) - , m_hasMultipartSelector(!!selector->tagHistory()) - , m_hasRightmostSelectorMatchingHTMLBasedOnRuleHash(isSelectorMatchingHTMLBasedOnRuleHash(selector)) - , m_containsUncommonAttributeSelector(WebCore::containsUncommonAttributeSelector(selector)) - , m_linkMatchType(SelectorChecker::determineLinkMatchType(selector)) + , m_specificity(selector()->specificity()) + , m_hasFastCheckableSelector(canUseFastCheckSelector && SelectorChecker::isFastCheckableSelector(selector())) + , m_hasMultipartSelector(!!selector()->tagHistory()) + , m_hasRightmostSelectorMatchingHTMLBasedOnRuleHash(isSelectorMatchingHTMLBasedOnRuleHash(selector())) + , m_containsUncommonAttributeSelector(WebCore::containsUncommonAttributeSelector(selector())) + , m_linkMatchType(SelectorChecker::determineLinkMatchType(selector())) , m_hasDocumentSecurityOrigin(hasDocumentSecurityOrigin) , m_isInRegionRule(inRegionRule) { - SelectorChecker::collectIdentifierHashes(m_selector, m_descendantSelectorIdentifierHashes, maximumIdentifierCount); + ASSERT(m_position == position); + ASSERT(m_selectorIndex == selectorIndex); + SelectorChecker::collectIdentifierHashes(selector(), m_descendantSelectorIdentifierHashes, maximumIdentifierCount); } void RuleData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const { - MemoryClassInfo<RuleData> info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); } RuleSet::RuleSet() @@ -2510,8 +2524,7 @@ RuleSet::RuleSet() { } - -static void reportAtomRuleMap(MemoryClassInfo<RuleSet>* info, const RuleSet::AtomRuleMap& atomicRuleMap) +static void reportAtomRuleMap(MemoryClassInfo* info, const RuleSet::AtomRuleMap& atomicRuleMap) { info->addHashMap(atomicRuleMap); for (RuleSet::AtomRuleMap::const_iterator it = atomicRuleMap.begin(); it != atomicRuleMap.end(); ++it) @@ -2520,7 +2533,7 @@ static void reportAtomRuleMap(MemoryClassInfo<RuleSet>* info, const RuleSet::Ato void RuleSet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const { - MemoryClassInfo<RuleSet> info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); reportAtomRuleMap(&info, m_idRules); reportAtomRuleMap(&info, m_classRules); reportAtomRuleMap(&info, m_tagRules); @@ -2534,7 +2547,7 @@ void RuleSet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const void RuleSet::RuleSetSelectorPair::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const { - MemoryClassInfo<RuleSet::RuleSetSelectorPair> info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); info.addInstrumentedMember(ruleSet); } @@ -2577,9 +2590,9 @@ static void collectFeaturesFromRuleData(StyleResolver::Features& features, const foundSiblingSelector = true; } if (foundSiblingSelector) - features.siblingRules.append(StyleResolver::RuleFeature(ruleData.rule(), ruleData.selector(), ruleData.hasDocumentSecurityOrigin())); + features.siblingRules.append(StyleResolver::RuleFeature(ruleData.rule(), ruleData.selectorIndex(), ruleData.hasDocumentSecurityOrigin())); if (ruleData.containsUncommonAttributeSelector()) - features.uncommonAttributeRules.append(StyleResolver::RuleFeature(ruleData.rule(), ruleData.selector(), ruleData.hasDocumentSecurityOrigin())); + features.uncommonAttributeRules.append(StyleResolver::RuleFeature(ruleData.rule(), ruleData.selectorIndex(), ruleData.hasDocumentSecurityOrigin())); } void RuleSet::addToRuleSet(AtomicStringImpl* key, AtomRuleMap& map, const RuleData& ruleData) @@ -2592,11 +2605,13 @@ void RuleSet::addToRuleSet(AtomicStringImpl* key, AtomRuleMap& map, const RuleDa rules->append(ruleData); } -void RuleSet::addRule(StyleRule* rule, CSSSelector* selector, bool hasDocumentSecurityOrigin, bool canUseFastCheckSelector, bool inRegionRule) +void RuleSet::addRule(StyleRule* rule, unsigned selectorIndex, bool hasDocumentSecurityOrigin, bool canUseFastCheckSelector, bool inRegionRule) { - RuleData ruleData(rule, selector, m_ruleCount++, hasDocumentSecurityOrigin, canUseFastCheckSelector, inRegionRule); + RuleData ruleData(rule, selectorIndex, m_ruleCount++, hasDocumentSecurityOrigin, canUseFastCheckSelector, inRegionRule); collectFeaturesFromRuleData(m_features, ruleData); + CSSSelector* selector = ruleData.selector(); + if (selector->m_match == CSSSelector::Id) { addToRuleSet(selector->value().impl(), m_idRules, ruleData); return; @@ -2737,8 +2752,8 @@ void RuleSet::addRulesFromSheet(StyleSheetContents* sheet, const MediaQueryEvalu void RuleSet::addStyleRule(StyleRule* rule, bool hasDocumentSecurityOrigin, bool canUseFastCheckSelector, bool isInRegionRule) { - for (CSSSelector* s = rule->selectorList().first(); s; s = CSSSelectorList::next(s)) - addRule(rule, s, hasDocumentSecurityOrigin, canUseFastCheckSelector, isInRegionRule); + for (size_t selectorIndex = 0; selectorIndex != notFound; selectorIndex = rule->selectorList().indexOfNextSelectorAfter(selectorIndex)) + addRule(rule, selectorIndex, hasDocumentSecurityOrigin, canUseFastCheckSelector, isInRegionRule); } static inline void shrinkMapVectorsToFit(RuleSet::AtomRuleMap& map) @@ -3501,22 +3516,25 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) } if (value->isValueList()) { CSSValueList* list = static_cast<CSSValueList*>(value); - QuotesData* data = QuotesData::create(list->length()); - if (!data) - return; // Out of memory - String* quotes = data->data(); - for (CSSValueListIterator i = list; i.hasMore(); i.advance()) { - CSSValue* item = i.value(); - ASSERT(item->isPrimitiveValue()); - primitiveValue = static_cast<CSSPrimitiveValue*>(item); - ASSERT(primitiveValue->isString()); - quotes[i.index()] = primitiveValue->getStringValue(); + RefPtr<QuotesData> quotes = QuotesData::create(); + for (size_t i = 0; i < list->length(); i += 2) { + CSSValue* first = list->itemWithoutBoundsCheck(i); + // item() returns null if out of bounds so this is safe. + CSSValue* second = list->item(i + 1); + if (!second) + continue; + ASSERT(first->isPrimitiveValue()); + ASSERT(second->isPrimitiveValue()); + String startQuote = static_cast<CSSPrimitiveValue*>(first)->getStringValue(); + String endQuote = static_cast<CSSPrimitiveValue*>(second)->getStringValue(); + quotes->addPair(std::make_pair(startQuote, endQuote)); } - m_style->setQuotes(adoptRef(data)); - } else if (primitiveValue) { - ASSERT(primitiveValue->isIdent()); + m_style->setQuotes(quotes); + return; + } + if (primitiveValue) { if (primitiveValue->getIdent() == CSSValueNone) - m_style->setQuotes(adoptRef(QuotesData::create(0))); + m_style->setQuotes(QuotesData::create()); } return; case CSSPropertyFontFamily: { @@ -3856,8 +3874,14 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) setTextSizeAdjust(primitiveValue->getIdent() == CSSValueAuto); return; } +#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION) #if ENABLE(DASHBOARD_SUPPORT) - case CSSPropertyWebkitDashboardRegion: { + case CSSPropertyWebkitDashboardRegion: +#endif +#if ENABLE(WIDGET_REGION) + case CSSPropertyWebkitWidgetRegion: +#endif + { HANDLE_INHERIT_AND_INITIAL(dashboardRegions, DashboardRegions) if (!primitiveValue) return; @@ -3989,19 +4013,6 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) return; } #endif -#if ENABLE(CSS3_FLEXBOX) - case CSSPropertyWebkitFlex: - if (isInherit) { - m_style->setFlexGrow(m_parentStyle->flexGrow()); - m_style->setFlexShrink(m_parentStyle->flexShrink()); - m_style->setFlexBasis(m_parentStyle->flexBasis()); - } else if (isInitial) { - m_style->setFlexGrow(RenderStyle::initialFlexGrow()); - m_style->setFlexShrink(RenderStyle::initialFlexShrink()); - m_style->setFlexBasis(RenderStyle::initialFlexBasis()); - } - return; -#endif case CSSPropertyInvalid: return; // Directional properties are resolved by resolveDirectionAwareProperty() before the switch. @@ -4332,6 +4343,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) case CSSPropertyWebkitAlignContent: case CSSPropertyWebkitAlignItems: case CSSPropertyWebkitAlignSelf: + case CSSPropertyWebkitFlex: case CSSPropertyWebkitFlexBasis: case CSSPropertyWebkitFlexDirection: case CSSPropertyWebkitFlexFlow: @@ -4391,6 +4403,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) #endif case CSSPropertyWebkitRtlOrdering: case CSSPropertyWebkitTextCombine: + case CSSPropertyWebkitTextDecorationLine: case CSSPropertyWebkitTextEmphasisColor: case CSSPropertyWebkitTextEmphasisPosition: case CSSPropertyWebkitTextEmphasisStyle: @@ -4461,14 +4474,14 @@ PassRefPtr<StyleImage> StyleResolver::cachedOrPendingFromValue(CSSPropertyID pro { RefPtr<StyleImage> image = value->cachedOrPendingImage(); if (image && image->isPendingImage()) - m_pendingImageProperties.add(property); + m_pendingImageProperties.set(property, value); return image.release(); } PassRefPtr<StyleImage> StyleResolver::generatedOrPendingFromValue(CSSPropertyID property, CSSImageGeneratorValue* value) { if (value->isPending()) { - m_pendingImageProperties.add(property); + m_pendingImageProperties.set(property, value); return StylePendingImage::create(value); } return StyleGeneratedImage::create(value); @@ -4479,7 +4492,7 @@ PassRefPtr<StyleImage> StyleResolver::setOrPendingFromValue(CSSPropertyID proper { RefPtr<StyleImage> image = value->cachedOrPendingImageSet(document()); if (image && image->isPendingImage()) - m_pendingImageProperties.add(property); + m_pendingImageProperties.set(property, value); return image.release(); } #endif @@ -5279,7 +5292,34 @@ PassRefPtr<CustomFilterOperation> StyleResolver::createCustomFilterOperation(Web ASSERT(shadersList->length()); RefPtr<StyleShader> vertexShader = styleShader(shadersList->itemWithoutBoundsCheck(0)); - RefPtr<StyleShader> fragmentShader = (shadersList->length() > 1) ? styleShader(shadersList->itemWithoutBoundsCheck(1)) : 0; + + RefPtr<StyleShader> fragmentShader; + CustomFilterProgramMixSettings mixSettings; + if (shadersList->length() > 1) { + CSSValue* fragmentShaderOrMixFunction = shadersList->itemWithoutBoundsCheck(1); + if (fragmentShaderOrMixFunction->isWebKitCSSMixFunctionValue()) { + mixSettings.enabled = true; + WebKitCSSMixFunctionValue* mixFunction = static_cast<WebKitCSSMixFunctionValue*>(fragmentShaderOrMixFunction); + CSSValueListIterator iterator(mixFunction); + + ASSERT(mixFunction->length()); + fragmentShader = styleShader(iterator.value()); + iterator.advance(); + + ASSERT(mixFunction->length() <= 3); + while (iterator.hasMore()) { + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(iterator.value()); + if (CSSParser::isBlendMode(primitiveValue->getIdent())) + mixSettings.blendMode = *primitiveValue; + else if (CSSParser::isCompositeOperator(primitiveValue->getIdent())) + mixSettings.compositeOperator = *primitiveValue; + else + ASSERT_NOT_REACHED(); + iterator.advance(); + } + } else + fragmentShader = styleShader(fragmentShaderOrMixFunction); + } unsigned meshRows = 1; unsigned meshColumns = 1; @@ -5348,7 +5388,7 @@ PassRefPtr<CustomFilterOperation> StyleResolver::createCustomFilterOperation(Web if (parametersValue && !parseCustomFilterParameterList(parametersValue, parameterList)) return 0; - RefPtr<StyleCustomFilterProgram> program = StyleCustomFilterProgram::create(vertexShader.release(), fragmentShader.release()); + RefPtr<StyleCustomFilterProgram> program = StyleCustomFilterProgram::create(vertexShader.release(), fragmentShader.release(), mixSettings); return CustomFilterOperation::create(program.release(), parameterList, meshRows, meshColumns, meshBoxType, meshType); } #endif @@ -5536,8 +5576,8 @@ void StyleResolver::loadPendingImages() if (m_pendingImageProperties.isEmpty()) return; - HashSet<CSSPropertyID>::const_iterator end = m_pendingImageProperties.end(); - for (HashSet<CSSPropertyID>::const_iterator it = m_pendingImageProperties.begin(); it != end; ++it) { + PendingImagePropertyMap::const_iterator::Keys end = m_pendingImageProperties.end().keys(); + for (PendingImagePropertyMap::const_iterator::Keys it = m_pendingImageProperties.begin().keys(); it != end; ++it) { CSSPropertyID currentProperty = *it; switch (currentProperty) { @@ -5629,9 +5669,27 @@ void StyleResolver::loadPendingResources() #endif } +void StyleResolver::MatchedProperties::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedMember(properties); +} + +void StyleResolver::MatchedPropertiesCacheItem::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedVector(matchedProperties); +} + +void MediaQueryResult::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedMember(m_expression); +} + void StyleResolver::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const { - MemoryClassInfo<StyleResolver> info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); info.addMember(m_style); info.addInstrumentedMember(m_authorStyle); info.addInstrumentedMember(m_userStyle); @@ -5639,18 +5697,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.addHashSet(m_pendingImageProperties); - info.addVector(m_viewportDependentMediaQueryResults); + info.addInstrumentedMember(m_ruleList); + info.addHashMap(m_pendingImageProperties); + 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 diff --git a/Source/WebCore/css/StyleResolver.h b/Source/WebCore/css/StyleResolver.h index f181eb60e..46f909ad2 100644 --- a/Source/WebCore/css/StyleResolver.h +++ b/Source/WebCore/css/StyleResolver.h @@ -102,6 +102,7 @@ public: , m_result(result) { } + void reportMemoryUsage(MemoryObjectInfo*) const; MediaQueryExp m_expression; bool m_result; @@ -273,14 +274,14 @@ public: void loadPendingResources(); struct RuleFeature { - RuleFeature(StyleRule* rule, CSSSelector* selector, bool hasDocumentSecurityOrigin) + RuleFeature(StyleRule* rule, unsigned selectorIndex, bool hasDocumentSecurityOrigin) : rule(rule) - , selector(selector) + , selectorIndex(selectorIndex) , hasDocumentSecurityOrigin(hasDocumentSecurityOrigin) { } StyleRule* rule; - CSSSelector* selector; + unsigned selectorIndex; bool hasDocumentSecurityOrigin; }; struct Features { @@ -320,6 +321,7 @@ private: struct MatchedProperties { MatchedProperties() : possiblyPaddedMember(0) { } + void reportMemoryUsage(MemoryObjectInfo*) const; RefPtr<StylePropertySet> properties; union { @@ -347,7 +349,7 @@ private: }; static void addMatchedProperties(MatchResult&, const StylePropertySet* properties, StyleRule* = 0, unsigned linkMatchType = SelectorChecker::MatchAll, bool inRegionRule = false); - void addElementStyleProperties(MatchResult&, StylePropertySet*, bool isCacheable = true); + void addElementStyleProperties(MatchResult&, const StylePropertySet*, bool isCacheable = true); void matchAllRules(MatchResult&, bool includeSMILProperties); void matchUARules(MatchResult&); @@ -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; @@ -470,7 +473,8 @@ private: RefPtr<StaticCSSRuleList> m_ruleList; - HashSet<CSSPropertyID> m_pendingImageProperties; + typedef HashMap<CSSPropertyID, RefPtr<CSSValue> > PendingImagePropertyMap; + PendingImagePropertyMap m_pendingImageProperties; OwnPtr<MediaQueryEvaluator> m_medium; RefPtr<RenderStyle> m_rootDefaultStyle; diff --git a/Source/WebCore/css/StyleRule.cpp b/Source/WebCore/css/StyleRule.cpp index 3427f0559..03efc3a34 100644 --- a/Source/WebCore/css/StyleRule.cpp +++ b/Source/WebCore/css/StyleRule.cpp @@ -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 @@ PassRefPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSRule* parentRule) const return createCSSOMWrapper(0, parentRule); } +void StyleRuleBase::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + switch (type()) { + case Style: + static_cast<const StyleRule*>(this)->reportDescendantMemoryUsage(memoryObjectInfo); + return; + case Page: + static_cast<const StyleRulePage*>(this)->reportDescendantMemoryUsage(memoryObjectInfo); + return; + case FontFace: + static_cast<const StyleRuleFontFace*>(this)->reportDescendantMemoryUsage(memoryObjectInfo); + return; + case Media: + static_cast<const StyleRuleMedia*>(this)->reportDescendantMemoryUsage(memoryObjectInfo); + return; +#if ENABLE(CSS_REGIONS) + case Region: + static_cast<const StyleRuleRegion*>(this)->reportDescendantMemoryUsage(memoryObjectInfo); + return; +#endif + case Import: + static_cast<const StyleRuleImport*>(this)->reportDescendantMemoryUsage(memoryObjectInfo); + return; + case Keyframes: + static_cast<const StyleRuleKeyframes*>(this)->reportDescendantMemoryUsage(memoryObjectInfo); + return; + case Unknown: + case Charset: + case Keyframe: + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + return; + } + ASSERT_NOT_REACHED(); +} + void StyleRuleBase::destroy() { switch (type()) { @@ -170,6 +206,13 @@ unsigned StyleRule::averageSizeInBytes() return sizeof(StyleRule) + StylePropertySet::averageSizeInBytes(); } +void StyleRule::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedMember(m_properties); + info.addInstrumentedMember(m_selectorList); +} + StyleRule::StyleRule(int sourceLine) : StyleRuleBase(Style, sourceLine) { @@ -226,6 +269,13 @@ void StyleRulePage::setProperties(PassRefPtr<StylePropertySet> properties) m_properties = properties; } +void StyleRulePage::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedMember(m_properties); + info.addInstrumentedMember(m_selectorList); +} + StyleRuleFontFace::StyleRuleFontFace() : StyleRuleBase(FontFace, 0) { @@ -253,6 +303,13 @@ void StyleRuleFontFace::setProperties(PassRefPtr<StylePropertySet> properties) m_properties = properties; } +void StyleRuleFontFace::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedMember(m_properties); +} + + StyleRuleBlock::StyleRuleBlock(Type type, Vector<RefPtr<StyleRuleBase> >& adoptRule) : StyleRuleBase(type, 0) { @@ -277,6 +334,12 @@ void StyleRuleBlock::wrapperRemoveRule(unsigned index) m_childRules.remove(index); } +void StyleRuleBlock::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo 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,7 +353,13 @@ StyleRuleMedia::StyleRuleMedia(const StyleRuleMedia& o) m_mediaQueries = o.m_mediaQueries->copy(); } -StyleRuleRegion::StyleRuleRegion(Vector<OwnPtr<CSSParserSelector> >* selectors, Vector<RefPtr<StyleRuleBase> >& adoptRules) +void StyleRuleMedia::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedMember(m_mediaQueries); +} + +StyleRuleRegion::StyleRuleRegion(CSSSelectorVector* selectors, Vector<RefPtr<StyleRuleBase> >& adoptRules) : StyleRuleBlock(Region, adoptRules) { m_selectorList.adoptSelectorVector(*selectors); @@ -302,4 +371,10 @@ StyleRuleRegion::StyleRuleRegion(const StyleRuleRegion& o) { } +void StyleRuleRegion::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedMember(m_selectorList); +} + } // namespace WebCore diff --git a/Source/WebCore/css/StyleRule.h b/Source/WebCore/css/StyleRule.h index 7fc20a303..7b6025042 100644 --- a/Source/WebCore/css/StyleRule.h +++ b/Source/WebCore/css/StyleRule.h @@ -31,6 +31,7 @@ namespace WebCore { class CSSRule; class CSSStyleRule; class CSSStyleSheet; +class MemoryObjectInfo; class StylePropertySet; class StyleRuleBase : public WTF::RefCountedBase { @@ -72,6 +73,8 @@ public: 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) { } @@ -97,13 +100,14 @@ public: const StylePropertySet* properties() const { return m_properties.get(); } StylePropertySet* mutableProperties(); - void parserAdoptSelectorVector(Vector<OwnPtr<CSSParserSelector> >& selectors) { m_selectorList.adoptSelectorVector(selectors); } + void parserAdoptSelectorVector(CSSSelectorVector& selectors) { m_selectorList.adoptSelectorVector(selectors); } void wrapperAdoptSelectorList(CSSSelectorList& selectors) { m_selectorList.adopt(selectors); } void setProperties(PassRefPtr<StylePropertySet>); PassRefPtr<StyleRule> copy() const { return adoptRef(new StyleRule(*this)); } static unsigned averageSizeInBytes(); + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; private: StyleRule(int sourceLine); @@ -126,6 +130,8 @@ public: PassRefPtr<StyleRuleFontFace> copy() const { return adoptRef(new StyleRuleFontFace(*this)); } + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: StyleRuleFontFace(); StyleRuleFontFace(const StyleRuleFontFace&); @@ -143,12 +149,14 @@ public: const StylePropertySet* properties() const { return m_properties.get(); } StylePropertySet* mutableProperties(); - void parserAdoptSelectorVector(Vector<OwnPtr<CSSParserSelector> >& selectors) { m_selectorList.adoptSelectorVector(selectors); } + void parserAdoptSelectorVector(CSSSelectorVector& selectors) { m_selectorList.adoptSelectorVector(selectors); } void wrapperAdoptSelectorList(CSSSelectorList& selectors) { m_selectorList.adopt(selectors); } void setProperties(PassRefPtr<StylePropertySet>); PassRefPtr<StyleRulePage> copy() const { return adoptRef(new StyleRulePage(*this)); } + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: StyleRulePage(); StyleRulePage(const StyleRulePage&); @@ -163,6 +171,8 @@ public: void wrapperInsertRule(unsigned, PassRefPtr<StyleRuleBase>); void wrapperRemoveRule(unsigned); + + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; protected: StyleRuleBlock(Type, Vector<RefPtr<StyleRuleBase> >& adoptRule); @@ -183,6 +193,8 @@ public: PassRefPtr<StyleRuleMedia> copy() const { return adoptRef(new StyleRuleMedia(*this)); } + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: StyleRuleMedia(PassRefPtr<MediaQuerySet>, Vector<RefPtr<StyleRuleBase> >& adoptRules); StyleRuleMedia(const StyleRuleMedia&); @@ -192,7 +204,7 @@ private: class StyleRuleRegion : public StyleRuleBlock { public: - static PassRefPtr<StyleRuleRegion> create(Vector<OwnPtr<CSSParserSelector> >* selectors, Vector<RefPtr<StyleRuleBase> >& adoptRules) + static PassRefPtr<StyleRuleRegion> create(CSSSelectorVector* selectors, Vector<RefPtr<StyleRuleBase> >& adoptRules) { return adoptRef(new StyleRuleRegion(selectors, adoptRules)); } @@ -201,8 +213,10 @@ public: PassRefPtr<StyleRuleRegion> copy() const { return adoptRef(new StyleRuleRegion(*this)); } + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: - StyleRuleRegion(Vector<OwnPtr<CSSParserSelector> >*, Vector<RefPtr<StyleRuleBase> >& adoptRules); + StyleRuleRegion(CSSSelectorVector*, Vector<RefPtr<StyleRuleBase> >& adoptRules); StyleRuleRegion(const StyleRuleRegion&); CSSSelectorList m_selectorList; diff --git a/Source/WebCore/css/StyleRuleImport.cpp b/Source/WebCore/css/StyleRuleImport.cpp index df8fa0774..70ee9c3df 100644 --- a/Source/WebCore/css/StyleRuleImport.cpp +++ b/Source/WebCore/css/StyleRuleImport.cpp @@ -128,4 +128,12 @@ void StyleRuleImport::requestStyleSheet() } } +void StyleRuleImport::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addMember(m_strHref); + info.addInstrumentedMember(m_mediaQueries); + info.addInstrumentedMember(m_styleSheet); +} + } // namespace WebCore diff --git a/Source/WebCore/css/StyleRuleImport.h b/Source/WebCore/css/StyleRuleImport.h index 3a8d01389..c0f898c65 100644 --- a/Source/WebCore/css/StyleRuleImport.h +++ b/Source/WebCore/css/StyleRuleImport.h @@ -30,6 +30,7 @@ namespace WebCore { class CachedCSSStyleSheet; class MediaQuerySet; +class MemoryObjectInfo; class StyleSheetContents; class StyleRuleImport : public StyleRuleBase { @@ -50,6 +51,8 @@ public: void requestStyleSheet(); + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: // NOTE: We put the CachedStyleSheetClient in a member instead of inheriting from it // to avoid adding a vptr to StyleRuleImport. diff --git a/Source/WebCore/css/StyleSheetContents.cpp b/Source/WebCore/css/StyleSheetContents.cpp index 970c828ca..292debb94 100644 --- a/Source/WebCore/css/StyleSheetContents.cpp +++ b/Source/WebCore/css/StyleSheetContents.cpp @@ -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" @@ -409,6 +410,46 @@ void StyleSheetContents::addSubresourceStyleURLs(ListHashSet<KURL>& urls) } } +static bool childRulesHaveFailedOrCanceledSubresources(const Vector<RefPtr<StyleRuleBase> >& rules) +{ + for (unsigned i = 0; i < rules.size(); ++i) { + const StyleRuleBase* rule = rules[i].get(); + switch (rule->type()) { + case StyleRuleBase::Style: + if (static_cast<const StyleRule*>(rule)->properties()->hasFailedOrCanceledSubresources()) + return true; + break; + case StyleRuleBase::FontFace: + if (static_cast<const StyleRuleFontFace*>(rule)->properties()->hasFailedOrCanceledSubresources()) + return true; + break; + case StyleRuleBase::Media: + if (childRulesHaveFailedOrCanceledSubresources(static_cast<const StyleRuleMedia*>(rule)->childRules())) + return true; + break; + case StyleRuleBase::Region: + if (childRulesHaveFailedOrCanceledSubresources(static_cast<const StyleRuleRegion*>(rule)->childRules())) + return true; + break; + case StyleRuleBase::Import: + ASSERT_NOT_REACHED(); + case StyleRuleBase::Page: + case StyleRuleBase::Keyframes: + case StyleRuleBase::Unknown: + case StyleRuleBase::Charset: + case StyleRuleBase::Keyframe: + break; + } + } + return false; +} + +bool StyleSheetContents::hasFailedOrCanceledSubresources() const +{ + ASSERT(isCacheable()); + return childRulesHaveFailedOrCanceledSubresources(m_childRules); +} + StyleSheetContents* StyleSheetContents::parentStyleSheet() const { return m_ownerRule ? m_ownerRule->parentStyleSheet() : 0; @@ -441,4 +482,16 @@ void StyleSheetContents::removedFromMemoryCache() m_isInMemoryCache = false; } +void StyleSheetContents::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addMember(m_originalURL); + info.addMember(m_finalURL); + info.addMember(m_encodingFromCharsetRule); + info.addVector(m_importRules); + info.addInstrumentedVector(m_childRules); + info.addHashMap(m_namespaces); + info.addVector(m_clients); +} + } diff --git a/Source/WebCore/css/StyleSheetContents.h b/Source/WebCore/css/StyleSheetContents.h index 7df34b703..b1ddb8ccb 100644 --- a/Source/WebCore/css/StyleSheetContents.h +++ b/Source/WebCore/css/StyleSheetContents.h @@ -34,6 +34,7 @@ namespace WebCore { class CSSStyleSheet; class CachedCSSStyleSheet; class Document; +class MemoryObjectInfo; class Node; class SecurityOrigin; class StyleRuleBase; @@ -78,6 +79,7 @@ public: const String& charset() const { return m_parserContext.charset; } bool loadCompleted() const { return m_loadCompleted; } + bool hasFailedOrCanceledSubresources() const; KURL completeURL(const String& url) const; void addSubresourceStyleURLs(ListHashSet<KURL>&); @@ -137,6 +139,8 @@ public: void addedToMemoryCache(); void removedFromMemoryCache(); + void reportMemoryUsage(MemoryObjectInfo*) const; + private: StyleSheetContents(StyleRuleImport* ownerRule, const String& originalURL, const KURL& baseURL, const CSSParserContext&); StyleSheetContents(const StyleSheetContents&); diff --git a/Source/WebCore/css/WebKitCSSFilterValue.cpp b/Source/WebCore/css/WebKitCSSFilterValue.cpp index 2916dc2d1..f70b2673a 100644 --- a/Source/WebCore/css/WebKitCSSFilterValue.cpp +++ b/Source/WebCore/css/WebKitCSSFilterValue.cpp @@ -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 info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + CSSValueList::reportDescendantMemoryUsage(memoryObjectInfo); +} + } #endif // ENABLE(CSS_FILTERS) diff --git a/Source/WebCore/css/WebKitCSSFilterValue.h b/Source/WebCore/css/WebKitCSSFilterValue.h index a34d5745c..08b3e9f9a 100644 --- a/Source/WebCore/css/WebKitCSSFilterValue.h +++ b/Source/WebCore/css/WebKitCSSFilterValue.h @@ -68,6 +68,8 @@ public: PassRefPtr<WebKitCSSFilterValue> cloneForCSSOM() const; + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: WebKitCSSFilterValue(FilterOperationType); WebKitCSSFilterValue(const WebKitCSSFilterValue& cloneFrom); diff --git a/Source/WebCore/css/WebKitCSSKeyframeRule.cpp b/Source/WebCore/css/WebKitCSSKeyframeRule.cpp index 0577b46f0..5c093022c 100644 --- a/Source/WebCore/css/WebKitCSSKeyframeRule.cpp +++ b/Source/WebCore/css/WebKitCSSKeyframeRule.cpp @@ -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 @@ String StyleKeyframe::cssText() const return result; } +void StyleKeyframe::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedMember(m_properties); + info.addMember(m_key); +} + WebKitCSSKeyframeRule::WebKitCSSKeyframeRule(StyleKeyframe* keyframe, WebKitCSSKeyframesRule* parent) : CSSRule(0, CSSRule::WEBKIT_KEYFRAME_RULE) , m_keyframe(keyframe) @@ -105,4 +113,12 @@ CSSStyleDeclaration* WebKitCSSKeyframeRule::style() const return m_propertiesCSSOMWrapper.get(); } +void WebKitCSSKeyframeRule::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + CSSRule::reportBaseClassMemoryUsage(memoryObjectInfo); + info.addInstrumentedMember(m_keyframe); + info.addInstrumentedMember(m_propertiesCSSOMWrapper); +} + } // namespace WebCore diff --git a/Source/WebCore/css/WebKitCSSKeyframeRule.h b/Source/WebCore/css/WebKitCSSKeyframeRule.h index 444b64820..f0e697e7a 100644 --- a/Source/WebCore/css/WebKitCSSKeyframeRule.h +++ b/Source/WebCore/css/WebKitCSSKeyframeRule.h @@ -34,6 +34,7 @@ namespace WebCore { +class MemoryInstrumentation; class StyleRuleCSSStyleDeclaration; class WebKitCSSKeyframesRule; @@ -55,6 +56,8 @@ public: String cssText() const; + void reportMemoryUsage(MemoryObjectInfo*) const; + private: StyleKeyframe() { } @@ -77,6 +80,8 @@ public: String cssText() const { return m_keyframe->cssText(); } + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: WebKitCSSKeyframeRule(StyleKeyframe*, WebKitCSSKeyframesRule* parent); diff --git a/Source/WebCore/css/WebKitCSSKeyframesRule.cpp b/Source/WebCore/css/WebKitCSSKeyframesRule.cpp index 12700e9fd..383068da6 100644 --- a/Source/WebCore/css/WebKitCSSKeyframesRule.cpp +++ b/Source/WebCore/css/WebKitCSSKeyframesRule.cpp @@ -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 @@ int StyleRuleKeyframes::findKeyframeIndex(const String& key) const return -1; } +void StyleRuleKeyframes::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addInstrumentedVector(m_keyframes); + info.addMember(m_name); +} + WebKitCSSKeyframesRule::WebKitCSSKeyframesRule(StyleRuleKeyframes* keyframesRule, CSSStyleSheet* parent) : CSSRule(parent, CSSRule::WEBKIT_KEYFRAMES_RULE) , m_keyframesRule(keyframesRule) @@ -198,4 +206,13 @@ void WebKitCSSKeyframesRule::reattach(StyleRuleKeyframes* rule) m_keyframesRule = rule; } +void WebKitCSSKeyframesRule::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + CSSRule::reportBaseClassMemoryUsage(memoryObjectInfo); + info.addInstrumentedMember(m_keyframesRule); + info.addInstrumentedVector(m_childRuleCSSOMWrappers); + info.addInstrumentedMember(m_ruleListCSSOMWrapper); +} + } // namespace WebCore diff --git a/Source/WebCore/css/WebKitCSSKeyframesRule.h b/Source/WebCore/css/WebKitCSSKeyframesRule.h index 2f9365c80..e83c08cbd 100644 --- a/Source/WebCore/css/WebKitCSSKeyframesRule.h +++ b/Source/WebCore/css/WebKitCSSKeyframesRule.h @@ -36,6 +36,7 @@ namespace WebCore { class CSSRuleList; +class MemoryObjectInfo; class StyleKeyframe; class WebKitCSSKeyframeRule; @@ -58,6 +59,8 @@ public: PassRefPtr<StyleRuleKeyframes> copy() const { return adoptRef(new StyleRuleKeyframes(*this)); } + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: StyleRuleKeyframes(); StyleRuleKeyframes(const StyleRuleKeyframes&); @@ -89,6 +92,8 @@ public: void reattach(StyleRuleKeyframes*); + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: WebKitCSSKeyframesRule(StyleRuleKeyframes*, CSSStyleSheet* parent); diff --git a/Source/WebCore/css/WebKitCSSMixFunctionValue.cpp b/Source/WebCore/css/WebKitCSSMixFunctionValue.cpp new file mode 100644 index 000000000..7f8d27d85 --- /dev/null +++ b/Source/WebCore/css/WebKitCSSMixFunctionValue.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "config.h" +#include "WebKitCSSMixFunctionValue.h" + +#include "MemoryInstrumentation.h" + +#if ENABLE(CSS_SHADERS) + +namespace WebCore { + +WebKitCSSMixFunctionValue::WebKitCSSMixFunctionValue() + : CSSValueList(WebKitCSSMixFunctionValueClass, SpaceSeparator) +{ +} + +WebKitCSSMixFunctionValue::WebKitCSSMixFunctionValue(const WebKitCSSMixFunctionValue& cloneFrom) + : CSSValueList(cloneFrom) +{ +} + +String WebKitCSSMixFunctionValue::customCssText() const +{ + return "mix(" + CSSValueList::customCssText() + ")"; +} + +PassRefPtr<WebKitCSSMixFunctionValue> WebKitCSSMixFunctionValue::cloneForCSSOM() const +{ + return adoptRef(new WebKitCSSMixFunctionValue(*this)); +} + +void WebKitCSSMixFunctionValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + CSSValueList::reportDescendantMemoryUsage(memoryObjectInfo); +} + +} // namespace WebCore + +#endif // ENABLE(CSS_SHADERS) diff --git a/Source/WebCore/css/WebKitCSSMixFunctionValue.h b/Source/WebCore/css/WebKitCSSMixFunctionValue.h new file mode 100644 index 000000000..af9794a19 --- /dev/null +++ b/Source/WebCore/css/WebKitCSSMixFunctionValue.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef WebKitCSSMixFunctionValue_h +#define WebKitCSSMixFunctionValue_h + +#if ENABLE(CSS_SHADERS) + +#include "CSSValueList.h" +#include <wtf/PassRefPtr.h> + +namespace WebCore { + +class WebKitCSSMixFunctionValue : public CSSValueList { +public: + static PassRefPtr<WebKitCSSMixFunctionValue> create() + { + return adoptRef(new WebKitCSSMixFunctionValue()); + } + + String customCssText() const; + + PassRefPtr<WebKitCSSMixFunctionValue> cloneForCSSOM() const; + + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + +private: + WebKitCSSMixFunctionValue(); + WebKitCSSMixFunctionValue(const WebKitCSSMixFunctionValue& cloneFrom); +}; + +} // namespace WebCore + +#endif // ENABLE(CSS_SHADERS) + +#endif diff --git a/Source/WebCore/css/WebKitCSSRegionRule.cpp b/Source/WebCore/css/WebKitCSSRegionRule.cpp index bdab5acce..2db2059f1 100644 --- a/Source/WebCore/css/WebKitCSSRegionRule.cpp +++ b/Source/WebCore/css/WebKitCSSRegionRule.cpp @@ -108,6 +108,15 @@ void WebKitCSSRegionRule::reattach(StyleRuleRegion* rule) } } +void WebKitCSSRegionRule::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const +{ + MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + CSSRule::reportBaseClassMemoryUsage(memoryObjectInfo); + info.addInstrumentedMember(m_regionRule); + info.addInstrumentedVector(m_childRuleCSSOMWrappers); + info.addInstrumentedMember(m_ruleListCSSOMWrapper); +} + } // namespace WebCore #endif diff --git a/Source/WebCore/css/WebKitCSSRegionRule.h b/Source/WebCore/css/WebKitCSSRegionRule.h index 2b4216699..c02f4c4c2 100644 --- a/Source/WebCore/css/WebKitCSSRegionRule.h +++ b/Source/WebCore/css/WebKitCSSRegionRule.h @@ -57,6 +57,8 @@ public: void reattach(StyleRuleRegion*); + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: WebKitCSSRegionRule(StyleRuleRegion*, CSSStyleSheet* parent); diff --git a/Source/WebCore/css/WebKitCSSSVGDocumentValue.cpp b/Source/WebCore/css/WebKitCSSSVGDocumentValue.cpp index 490250496..3e16bbd32 100644 --- a/Source/WebCore/css/WebKitCSSSVGDocumentValue.cpp +++ b/Source/WebCore/css/WebKitCSSSVGDocumentValue.cpp @@ -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 info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addMember(m_url); + // FIXME: add m_document when cached resources are instrumented. +} + } // namespace WebCore #endif // ENABLE(SVG) diff --git a/Source/WebCore/css/WebKitCSSSVGDocumentValue.h b/Source/WebCore/css/WebKitCSSSVGDocumentValue.h index cb03f56ee..96bcc8c30 100644 --- a/Source/WebCore/css/WebKitCSSSVGDocumentValue.h +++ b/Source/WebCore/css/WebKitCSSSVGDocumentValue.h @@ -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); diff --git a/Source/WebCore/css/WebKitCSSShaderValue.cpp b/Source/WebCore/css/WebKitCSSShaderValue.cpp index 8651758ed..482a36089 100644 --- a/Source/WebCore/css/WebKitCSSShaderValue.cpp +++ b/Source/WebCore/css/WebKitCSSShaderValue.cpp @@ -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 info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + info.addMember(m_url); +} + } // namespace WebCore #endif // ENABLE(CSS_SHADERS) diff --git a/Source/WebCore/css/WebKitCSSShaderValue.h b/Source/WebCore/css/WebKitCSSShaderValue.h index fd95bc63c..c43201ca2 100644 --- a/Source/WebCore/css/WebKitCSSShaderValue.h +++ b/Source/WebCore/css/WebKitCSSShaderValue.h @@ -50,6 +50,8 @@ public: String customCssText() const; + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: WebKitCSSShaderValue(const String& url); diff --git a/Source/WebCore/css/WebKitCSSTransformValue.cpp b/Source/WebCore/css/WebKitCSSTransformValue.cpp index 87ded7da6..8e196e5ac 100644 --- a/Source/WebCore/css/WebKitCSSTransformValue.cpp +++ b/Source/WebCore/css/WebKitCSSTransformValue.cpp @@ -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 info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + CSSValueList::reportDescendantMemoryUsage(memoryObjectInfo); +} + } diff --git a/Source/WebCore/css/WebKitCSSTransformValue.h b/Source/WebCore/css/WebKitCSSTransformValue.h index 5fc4f7d6b..fd117f232 100644 --- a/Source/WebCore/css/WebKitCSSTransformValue.h +++ b/Source/WebCore/css/WebKitCSSTransformValue.h @@ -74,6 +74,8 @@ public: PassRefPtr<WebKitCSSTransformValue> cloneForCSSOM() const; + void reportDescendantMemoryUsage(MemoryObjectInfo*) const; + private: WebKitCSSTransformValue(TransformOperationType); WebKitCSSTransformValue(const WebKitCSSTransformValue& cloneFrom); diff --git a/Source/WebCore/css/html.css b/Source/WebCore/css/html.css index e5ad78cff..43b65a139 100644 --- a/Source/WebCore/css/html.css +++ b/Source/WebCore/css/html.css @@ -435,6 +435,7 @@ input[type="search"] { input::-webkit-textfield-decoration-container { display: -webkit-box; -webkit-box-align: center; + -webkit-user-modify: read-only !important; } input[type="search"]::-webkit-textfield-decoration-container { @@ -445,24 +446,28 @@ input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: searchfield-cancel-button; display: block; -webkit-box-flex: 0; + -webkit-user-modify: read-only !important; } input[type="search"]::-webkit-search-decoration { -webkit-appearance: searchfield-decoration; display: block; -webkit-box-flex: 0; + -webkit-user-modify: read-only !important; } input[type="search"]::-webkit-search-results-decoration { -webkit-appearance: searchfield-results-decoration; display: block; -webkit-box-flex: 0; + -webkit-user-modify: read-only !important; } input[type="search"]::-webkit-search-results-button { -webkit-appearance: searchfield-results-button; display: block; -webkit-box-flex: 0; + -webkit-user-modify: read-only !important; } #if defined(ENABLE_DATALIST_ELEMENT) && ENABLE_DATALIST_ELEMENT @@ -471,14 +476,84 @@ datalist { } #endif +#if defined(ENABLE_INPUT_TYPE_TIME_MULTIPLE_FIELDS) && ENABLE_INPUT_TYPE_TIME_MULTIPLE_FIELDS +input[type="time"] { + font-family: monospace; +} + +input::-webkit-datetime-edit { + -webkit-user-modify: read-only !important; + display: -webkit-box; + -webkit-box-align: center; +} + +input::-webkit-datetime-edit-ampm-field { + -webkit-user-modify: read-only !important; + border: none; + width: 2em; + padding: 2px; +} + +input::-webkit-datetime-edit-hour-field { + -webkit-user-modify: read-only !important; + display: inline-block; + border: none; + text-align: center; + width: 1.2em; + padding: 2px; +} + +input::-webkit-datetime-edit-millisecond-field { + -webkit-user-modify: read-only !important; + display: inline-block; + border: none; + text-align: center; + width: 1.8em; + padding: 2px; +} + +input::-webkit-datetime-edit-minute-field { + -webkit-user-modify: read-only !important; + display: inline-block; + border: none; + text-align: center; + width: 1.2em; + padding: 2px; +} + +/* This selector is used when step >= 3600 second but format contains minute field. */ +input::-webkit-datetime-edit-minute-field[readonly] { + color: GrayText; +} + +input::-webkit-datetime-edit-second-field { + -webkit-user-modify: read-only !important; + display: inline-block; + border: none; + text-align: center; + width: 1.2em; + padding: 2px; +} + +/* This selector is used when step >= 60 second but format contains second field. */ +input::-webkit-datetime-edit-second-field[readonly] { + color: GrayText; +} +#endif + input::-webkit-inner-spin-button { -webkit-appearance: inner-spin-button; display: block; position: relative; cursor: default; + /* This height property is ignored for input type "number" and others which + * use RenderTextControlSingleLine as renderer which sets height of spin + * button in layout(). */ + height: 1.5em; vertical-align: top; -webkit-box-flex: 0; -webkit-user-select: none; + -webkit-user-modify: read-only !important; } #if defined(ENABLE_INPUT_SPEECH) && ENABLE_INPUT_SPEECH @@ -487,6 +562,7 @@ input::-webkit-input-speech-button { display: block; vertical-align: top; -webkit-box-flex: 0; + -webkit-user-modify: read-only !important; } #endif @@ -523,6 +599,7 @@ input::-webkit-input-placeholder, isindex::-webkit-input-placeholder { white-space: pre; word-wrap: normal; overflow: hidden; + -webkit-user-modify: read-only !important; } input[type="password"] { @@ -562,6 +639,7 @@ input[type="button"], input[type="submit"], input[type="reset"] { input[type="file"]::-webkit-file-upload-button { -webkit-appearance: push-button; + -webkit-user-modify: read-only !important; white-space: nowrap; margin: 0; font-size: inherit; @@ -590,6 +668,7 @@ input[type="range"]::-webkit-slider-container, input[type="range"]::-webkit-medi -webkit-box-align: center; -webkit-box-orient: horizontal; /* This property is updated by C++ code. */ -webkit-box-sizing: border-box; + -webkit-user-modify: read-only !important; display: -webkit-box; height: 100%; width: 100%; @@ -598,19 +677,22 @@ input[type="range"]::-webkit-slider-container, input[type="range"]::-webkit-medi input[type="range"]::-webkit-slider-runnable-track { -webkit-box-flex: 1; -webkit-box-sizing: border-box; + -webkit-user-modify: read-only !important; display: block; } input[type="range"]::-webkit-slider-thumb, input[type="range"]::-webkit-media-slider-thumb { -webkit-appearance: sliderthumb-horizontal; -webkit-box-sizing: border-box; + -webkit-user-modify: read-only !important; display: block; position: relative; } input[type="button"]:disabled, input[type="submit"]:disabled, input[type="reset"]:disabled, input[type="file"]:disabled::-webkit-file-upload-button, button:disabled, -select:disabled, keygen:disabled, optgroup:disabled, option:disabled { +select:disabled, keygen:disabled, optgroup:disabled, option:disabled, +select[disabled]>option { color: GrayText } @@ -648,6 +730,7 @@ input[type="color"]::-webkit-color-swatch-wrapper { display:-webkit-box; padding: 4px 2px; -webkit-box-sizing: border-box; + -webkit-user-modify: read-only !important; width: 100%; height: 100% } @@ -656,6 +739,7 @@ input[type="color"]::-webkit-color-swatch { background-color: #000000; border: 1px solid #777777; -webkit-box-flex: 1; + -webkit-user-modify: read-only !important; } #if defined(ENABLE_DATALIST_ELEMENT) && ENABLE_DATALIST_ELEMENT @@ -684,6 +768,7 @@ input::-webkit-calendar-picker-indicator { width: 0.66em; height: 0.66em; padding: 0.17em 0.34em; + -webkit-user-modify: read-only !important; } input::-webkit-calendar-picker-indicator:hover { @@ -857,6 +942,14 @@ progress { vertical-align: -0.2em; } +progress::-webkit-progress-inner-element { + -webkit-appearance: inherit; + -webkit-box-sizing: inherit; + -webkit-user-modify: read-only; + height: 100%; + width: 100%; +} + progress::-webkit-progress-bar { background-color: gray; height: 100%; diff --git a/Source/WebCore/css/mathml.css b/Source/WebCore/css/mathml.css index a96e3fa4b..fa4288f51 100644 --- a/Source/WebCore/css/mathml.css +++ b/Source/WebCore/css/mathml.css @@ -1,13 +1,20 @@ @namespace "http://www.w3.org/1998/Math/MathML"; math { + -webkit-line-box-contain: glyphs replaced; + line-height: 0; +} +mtext { + line-height: 1.0; +} + +math { font-family: STIXGeneral, Symbol, "Times New Roman", sans-serif; display: inline-block; padding: 0px; margin: 0px; text-align: left; vertical-align: baseline; - line-height: 1.0; padding-left: 1px; padding-right: 1px; } @@ -160,11 +167,7 @@ mroot > * + * { top: 0; padding-right: 0.4em; padding-left: 0.2em; - padding-bottom: 0.2em; /* FIXME: change to 0.25em */ -} - -mroot > * + mrow, mroot > * + mfenced { /* FIXME: eliminate */ - padding-bottom: 0.4em; + padding-bottom: 0.35em; } mtable { @@ -179,7 +182,7 @@ mtr { mtd { display: table-cell; - padding: 0 0.5ex; + padding: 0.5ex; } mtable[columnalign="left"], mtr[columnalign="left"], mtd[columnalign="left"] { |