#ifndef StyledElement_h
#define StyledElement_h
#include "CSSPrimitiveValue.h"
#include "CSSPropertyNames.h"
#include "Element.h"
namespace WebCore {
class Attribute;
class MutableStylePropertySet;
class PropertySetCSSStyleDeclaration;
class StylePropertySet;
struct PresentationAttributeCacheKey;
class StyledElement : public Element {
public:
virtual ~StyledElement();
virtual const StylePropertySet* additionalPresentationAttributeStyle() { return 0; }
void invalidateStyleAttribute();
const StylePropertySet* inlineStyle() const { return elementData() ? elementData()->m_inlineStyle.get() : 0; }
bool setInlineStyleProperty(CSSPropertyID, int identifier, bool important = false);
bool setInlineStyleProperty(CSSPropertyID, double value, CSSPrimitiveValue::UnitTypes, bool important = false);
bool setInlineStyleProperty(CSSPropertyID, const String& value, bool important = false);
bool removeInlineStyleProperty(CSSPropertyID);
void removeAllInlineStyleProperties();
void synchronizeStyleAttributeInternal() const;
virtual CSSStyleDeclaration* style() OVERRIDE FINAL;
const StylePropertySet* presentationAttributeStyle();
virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) { }
protected:
StyledElement(const QualifiedName& name, Document* document, ConstructionType type)
: Element(name, document, type)
{
}
virtual void attributeChanged(const QualifiedName&, const AtomicString&, AttributeModificationReason = ModifiedDirectly) OVERRIDE;
virtual bool isPresentationAttribute(const QualifiedName&) const { return false; }
void addPropertyToPresentationAttributeStyle(MutableStylePropertySet*, CSSPropertyID, int identifier);
void addPropertyToPresentationAttributeStyle(MutableStylePropertySet*, CSSPropertyID, double value, CSSPrimitiveValue::UnitTypes);
void addPropertyToPresentationAttributeStyle(MutableStylePropertySet*, CSSPropertyID, const String& value);
virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
private:
void styleAttributeChanged(const AtomicString& newStyleString, AttributeModificationReason);
void inlineStyleChanged();
PropertySetCSSStyleDeclaration* inlineStyleCSSOMWrapper();
void setInlineStyleFromString(const AtomicString&);
MutableStylePropertySet* ensureMutableInlineStyle();
void makePresentationAttributeCacheKey(PresentationAttributeCacheKey&) const;
void rebuildPresentationAttributeStyle();
};
inline void StyledElement::invalidateStyleAttribute()
{
ASSERT(elementData());
elementData()->m_styleAttributeIsDirty = true;
}
inline const StylePropertySet* StyledElement::presentationAttributeStyle()
{
if (!elementData())
return 0;
if (elementData()->m_presentationAttributeStyleIsDirty)
rebuildPresentationAttributeStyle();
return elementData()->presentationAttributeStyle();
}
}
#endif