StylePropertySet.h [plain text]
#ifndef StylePropertySet_h
#define StylePropertySet_h
#include "CSSParserMode.h"
#include "CSSPrimitiveValue.h"
#include "CSSProperty.h"
#include "CSSPropertyNames.h"
#include <wtf/ListHashSet.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class CSSRule;
class CSSStyleDeclaration;
class KURL;
class PropertySetCSSStyleDeclaration;
class StyledElement;
class StylePropertyShorthand;
class StyleSheetInternal;
class StylePropertySet : public RefCounted<StylePropertySet> {
public:
~StylePropertySet();
static PassRefPtr<StylePropertySet> create(CSSParserMode cssParserMode = CSSQuirksMode)
{
return adoptRef(new StylePropertySet(cssParserMode));
}
static PassRefPtr<StylePropertySet> create(const CSSProperty* properties, int numProperties, CSSParserMode cssParserMode)
{
return adoptRef(new StylePropertySet(properties, numProperties, cssParserMode));
}
static PassRefPtr<StylePropertySet> create(const Vector<CSSProperty>& properties)
{
return adoptRef(new StylePropertySet(properties));
}
unsigned propertyCount() const { return m_properties.size(); }
bool isEmpty() const { return m_properties.isEmpty(); }
const CSSProperty& propertyAt(unsigned index) const { return m_properties[index]; }
void shrinkToFit() { m_properties.shrinkToFit(); }
PassRefPtr<CSSValue> getPropertyCSSValue(CSSPropertyID) const;
String getPropertyValue(CSSPropertyID) const;
bool propertyIsImportant(CSSPropertyID) const;
CSSPropertyID getPropertyShorthand(CSSPropertyID) const;
bool isPropertyImplicit(CSSPropertyID) const;
bool setProperty(CSSPropertyID, const String& value, bool important = false, StyleSheetInternal* contextStyleSheet = 0);
void setProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important = false);
bool setProperty(CSSPropertyID, int identifier, bool important = false);
void setProperty(const CSSProperty&, CSSProperty* slot = 0);
bool removeProperty(CSSPropertyID, String* returnText = 0);
void parseDeclaration(const String& styleDeclaration, StyleSheetInternal* contextStyleSheet);
void addParsedProperties(const CSSProperty*, int numProperties);
void addParsedProperty(const CSSProperty&);
PassRefPtr<StylePropertySet> copyBlockProperties() const;
void removeBlockProperties();
bool removePropertiesInSet(const CSSPropertyID* set, unsigned length);
void merge(const StylePropertySet*, bool argOverridesOnConflict = true);
void setCSSParserMode(CSSParserMode cssParserMode) { m_cssParserMode = cssParserMode; }
CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cssParserMode); }
void addSubresourceStyleURLs(ListHashSet<KURL>&, StyleSheetInternal* contextStyleSheet);
PassRefPtr<StylePropertySet> copy() const;
void copyPropertiesFrom(const StylePropertySet&);
void removeEquivalentProperties(const StylePropertySet*);
void removeEquivalentProperties(const CSSStyleDeclaration*);
PassRefPtr<StylePropertySet> copyPropertiesInSet(const CSSPropertyID* set, unsigned length) const;
String asText() const;
void clearParentElement(StyledElement*);
CSSStyleDeclaration* ensureCSSStyleDeclaration() const;
CSSStyleDeclaration* ensureInlineCSSStyleDeclaration(const StyledElement* parentElement) const;
bool isMutable() const { return m_ownsCSSOMWrapper; }
static unsigned averageSizeInBytes();
private:
StylePropertySet(CSSParserMode);
StylePropertySet(const Vector<CSSProperty>&);
StylePropertySet(const StylePropertySet&);
StylePropertySet(const CSSProperty*, int numProperties, CSSParserMode);
void setNeedsStyleRecalc();
String getShorthandValue(const StylePropertyShorthand&) const;
String getCommonValue(const StylePropertyShorthand&) const;
enum CommonValueMode { OmitUncommonValues, ReturnNullOnUncommonValues };
String borderPropertyValue(CommonValueMode) const;
String getLayeredShorthandValue(const StylePropertyShorthand&) const;
String get4Values(const StylePropertyShorthand&) const;
String borderSpacingValue(const StylePropertyShorthand&) const;
String fontValue() const;
bool appendFontLonghandValueIfExplicit(CSSPropertyID, StringBuilder& result) const;
bool removeShorthandProperty(CSSPropertyID);
bool propertyMatches(const CSSProperty*) const;
const CSSProperty* findPropertyWithId(CSSPropertyID) const;
CSSProperty* findPropertyWithId(CSSPropertyID);
Vector<CSSProperty, 4> m_properties;
unsigned m_cssParserMode : 2;
mutable unsigned m_ownsCSSOMWrapper : 1;
friend class PropertySetCSSStyleDeclaration;
};
}
#endif // StylePropertySet_h