diff options
Diffstat (limited to 'Source/WebCore/css/CSSComputedStyleDeclaration.h')
-rw-r--r-- | Source/WebCore/css/CSSComputedStyleDeclaration.h | 107 |
1 files changed, 51 insertions, 56 deletions
diff --git a/Source/WebCore/css/CSSComputedStyleDeclaration.h b/Source/WebCore/css/CSSComputedStyleDeclaration.h index 9981cf257..67a8e70f2 100644 --- a/Source/WebCore/css/CSSComputedStyleDeclaration.h +++ b/Source/WebCore/css/CSSComputedStyleDeclaration.h @@ -18,11 +18,11 @@ * 02110-1301 USA */ -#ifndef CSSComputedStyleDeclaration_h -#define CSSComputedStyleDeclaration_h +#pragma once #include "CSSStyleDeclaration.h" #include "RenderStyleConstants.h" +#include "SVGRenderStyleDefs.h" #include <wtf/RefPtr.h> #include <wtf/text/WTFString.h> @@ -31,6 +31,7 @@ namespace WebCore { class CSSPrimitiveValue; class CSSValueList; class Color; +class Element; class FilterOperations; class MutableStyleProperties; class Node; @@ -47,88 +48,82 @@ enum AdjustPixelValuesForComputedStyle { AdjustPixelValues, DoNotAdjustPixelValu class ComputedStyleExtractor { public: - ComputedStyleExtractor(PassRefPtr<Node>, bool allowVisitedStyle = false, PseudoId = NOPSEUDO); + ComputedStyleExtractor(Node*, bool allowVisitedStyle = false, PseudoId = NOPSEUDO); + ComputedStyleExtractor(Element*, bool allowVisitedStyle = false, PseudoId = NOPSEUDO); - PassRefPtr<CSSValue> propertyValue(CSSPropertyID, EUpdateLayout = UpdateLayout) const; + RefPtr<CSSValue> propertyValue(CSSPropertyID, EUpdateLayout = UpdateLayout); + String customPropertyText(const String& propertyName); + RefPtr<CSSValue> customPropertyValue(const String& propertyName); // Helper methods for HTML editing. - PassRef<MutableStyleProperties> copyPropertiesInSet(const CSSPropertyID* set, unsigned length) const; - PassRef<MutableStyleProperties> copyProperties() const; - PassRefPtr<CSSPrimitiveValue> getFontSizeCSSValuePreferringKeyword() const; - bool useFixedFontDefaultSize() const; - bool propertyMatches(CSSPropertyID, const CSSValue*) const; + Ref<MutableStyleProperties> copyPropertiesInSet(const CSSPropertyID* set, unsigned length); + Ref<MutableStyleProperties> copyProperties(); + RefPtr<CSSPrimitiveValue> getFontSizeCSSValuePreferringKeyword(); + bool useFixedFontDefaultSize(); + bool propertyMatches(CSSPropertyID, const CSSValue*); -#if ENABLE(CSS_FILTERS) - static PassRef<CSSValue> valueForFilter(const RenderStyle*, const FilterOperations&, AdjustPixelValuesForComputedStyle = AdjustPixelValues); -#endif + static Ref<CSSValue> valueForFilter(const RenderStyle&, const FilterOperations&, AdjustPixelValuesForComputedStyle = AdjustPixelValues); private: - // The styled node is either the node passed into computedPropertyValue, or the + // The styled element is either the element passed into computedPropertyValue, or the // PseudoElement for :before and :after if they exist. - // FIXME: This should be styledElement since in JS getComputedStyle only works - // on Elements, but right now editing creates these for text nodes. We should fix that. - Node* styledNode() const; + Element* styledElement(); -#if ENABLE(SVG) - PassRefPtr<CSSValue> svgPropertyValue(CSSPropertyID, EUpdateLayout) const; - PassRefPtr<SVGPaint> adjustSVGPaintForCurrentColor(PassRefPtr<SVGPaint>, RenderStyle*) const; -#endif + RefPtr<CSSValue> svgPropertyValue(CSSPropertyID, EUpdateLayout); + RefPtr<CSSValue> adjustSVGPaintForCurrentColor(SVGPaintType, const String& url, const Color&, const Color& currentColor) const; + static Ref<CSSValue> valueForShadow(const ShadowData*, CSSPropertyID, const RenderStyle&, AdjustPixelValuesForComputedStyle = AdjustPixelValues); + RefPtr<CSSPrimitiveValue> currentColorOrValidColor(const RenderStyle*, const Color&) const; - static PassRefPtr<CSSValue> valueForShadow(const ShadowData*, CSSPropertyID, const RenderStyle*, AdjustPixelValuesForComputedStyle = AdjustPixelValues); - PassRefPtr<CSSPrimitiveValue> currentColorOrValidColor(RenderStyle*, const Color&) const; + RefPtr<CSSValueList> getCSSPropertyValuesForShorthandProperties(const StylePropertyShorthand&); + RefPtr<CSSValueList> getCSSPropertyValuesForSidesShorthand(const StylePropertyShorthand&); + Ref<CSSValueList> getBackgroundShorthandValue(); + RefPtr<CSSValueList> getCSSPropertyValuesForGridShorthand(const StylePropertyShorthand&); - PassRefPtr<CSSValueList> getCSSPropertyValuesForShorthandProperties(const StylePropertyShorthand&) const; - PassRefPtr<CSSValueList> getCSSPropertyValuesForSidesShorthand(const StylePropertyShorthand&) const; - PassRefPtr<CSSValueList> getBackgroundShorthandValue() const; - PassRefPtr<CSSValueList> getCSSPropertyValuesForGridShorthand(const StylePropertyShorthand&) const; - - RefPtr<Node> m_node; + RefPtr<Element> m_element; PseudoId m_pseudoElementSpecifier; bool m_allowVisitedStyle; }; -class CSSComputedStyleDeclaration : public CSSStyleDeclaration { +class CSSComputedStyleDeclaration final : public CSSStyleDeclaration { public: - static PassRefPtr<CSSComputedStyleDeclaration> create(PassRefPtr<Node> node, bool allowVisitedStyle = false, const String& pseudoElementName = String()) + static Ref<CSSComputedStyleDeclaration> create(Element& element, bool allowVisitedStyle = false, const String& pseudoElementName = String()) { - return adoptRef(new CSSComputedStyleDeclaration(node, allowVisitedStyle, pseudoElementName)); + return adoptRef(*new CSSComputedStyleDeclaration(element, allowVisitedStyle, pseudoElementName)); } virtual ~CSSComputedStyleDeclaration(); - virtual void ref() override; - virtual void deref() override; + WEBCORE_EXPORT void ref() final; + WEBCORE_EXPORT void deref() final; String getPropertyValue(CSSPropertyID) const; private: - CSSComputedStyleDeclaration(PassRefPtr<Node>, bool allowVisitedStyle, const String&); + WEBCORE_EXPORT CSSComputedStyleDeclaration(Element&, bool allowVisitedStyle, const String&); // CSSOM functions. Don't make these public. - virtual CSSRule* parentRule() const override; - virtual unsigned length() const override; - virtual String item(unsigned index) const override; - virtual PassRefPtr<CSSValue> getPropertyCSSValue(const String& propertyName) override; - virtual String getPropertyValue(const String& propertyName) override; - virtual String getPropertyPriority(const String& propertyName) override; - virtual String getPropertyShorthand(const String& propertyName) override; - virtual bool isPropertyImplicit(const String& propertyName) override; - virtual void setProperty(const String& propertyName, const String& value, const String& priority, ExceptionCode&) override; - virtual String removeProperty(const String& propertyName, ExceptionCode&) override; - virtual String cssText() const override; - virtual void setCssText(const String&, ExceptionCode&) override; - virtual PassRefPtr<CSSValue> getPropertyCSSValueInternal(CSSPropertyID) override; - virtual String getPropertyValueInternal(CSSPropertyID) override; - virtual void setPropertyInternal(CSSPropertyID, const String& value, bool important, ExceptionCode&) override; - virtual PassRef<MutableStyleProperties> copyProperties() const override; - - PassRefPtr<CSSValue> getPropertyCSSValue(CSSPropertyID, EUpdateLayout = UpdateLayout) const; - - RefPtr<Node> m_node; + CSSRule* parentRule() const final; + unsigned length() const final; + String item(unsigned index) const final; + RefPtr<DeprecatedCSSOMValue> getPropertyCSSValue(const String& propertyName) final; + String getPropertyValue(const String& propertyName) final; + String getPropertyPriority(const String& propertyName) final; + String getPropertyShorthand(const String& propertyName) final; + bool isPropertyImplicit(const String& propertyName) final; + ExceptionOr<void> setProperty(const String& propertyName, const String& value, const String& priority) final; + ExceptionOr<String> removeProperty(const String& propertyName) final; + String cssText() const final; + ExceptionOr<void> setCssText(const String&) final; + RefPtr<CSSValue> getPropertyCSSValueInternal(CSSPropertyID) final; + String getPropertyValueInternal(CSSPropertyID) final; + ExceptionOr<bool> setPropertyInternal(CSSPropertyID, const String& value, bool important) final; + Ref<MutableStyleProperties> copyProperties() const final; + + RefPtr<CSSValue> getPropertyCSSValue(CSSPropertyID, EUpdateLayout = UpdateLayout) const; + + mutable Ref<Element> m_element; PseudoId m_pseudoElementSpecifier; bool m_allowVisitedStyle; unsigned m_refCount; }; } // namespace WebCore - -#endif // CSSComputedStyleDeclaration_h |