#ifndef StyleResolverState_h
#define StyleResolverState_h
#include "CSSPropertyNames.h"
#include "core/css/CSSSVGDocumentValue.h"
#include "core/css/CSSToLengthConversionData.h"
#include "core/css/resolver/CSSToStyleMap.h"
#include "core/css/resolver/ElementResolveContext.h"
#include "core/css/resolver/ElementStyleResources.h"
#include "core/css/resolver/FontBuilder.h"
#include "core/dom/Element.h"
#include "core/rendering/style/CachedUAStyle.h"
#include "core/rendering/style/RenderStyle.h"
#include "core/rendering/style/StyleInheritedData.h"
namespace WebCore {
class CSSAnimationUpdate;
class FontDescription;
class StyleRule;
class StyleResolverState {
STACK_ALLOCATED();
WTF_MAKE_NONCOPYABLE(StyleResolverState);
public:
StyleResolverState(Document&, Element*, RenderStyle* parentStyle = 0);
~StyleResolverState();
Document& document() const { return m_document; }
Element* element() const { return m_elementContext.element(); }
const ContainerNode* parentNode() const { return m_elementContext.parentNode(); }
const RenderStyle* rootElementStyle() const { return m_elementContext.rootElementStyle(); }
EInsideLink elementLinkState() const { return m_elementContext.elementLinkState(); }
bool distributedToInsertionPoint() const { return m_elementContext.distributedToInsertionPoint(); }
const ElementResolveContext& elementContext() const { return m_elementContext; }
void setStyle(PassRefPtr<RenderStyle> style) { m_style = style; m_cssToLengthConversionData.setStyle(m_style.get()); }
const RenderStyle* style() const { return m_style.get(); }
RenderStyle* style() { return m_style.get(); }
PassRefPtr<RenderStyle> takeStyle() { return m_style.release(); }
const CSSToLengthConversionData& cssToLengthConversionData() const { return m_cssToLengthConversionData; }
void setAnimationUpdate(PassOwnPtrWillBeRawPtr<CSSAnimationUpdate>);
const CSSAnimationUpdate* animationUpdate() { return m_animationUpdate.get(); }
PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> takeAnimationUpdate();
void setParentStyle(PassRefPtr<RenderStyle> parentStyle) { m_parentStyle = parentStyle; }
const RenderStyle* parentStyle() const { return m_parentStyle.get(); }
RenderStyle* parentStyle() { return m_parentStyle.get(); }
void setCurrentRule(StyleRule* currentRule) { m_currentRule = currentRule; }
const StyleRule* currentRule() const { return m_currentRule; }
void setApplyPropertyToRegularStyle(bool isApply) { m_applyPropertyToRegularStyle = isApply; }
void setApplyPropertyToVisitedLinkStyle(bool isApply) { m_applyPropertyToVisitedLinkStyle = isApply; }
bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularStyle; }
bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisitedLinkStyle; }
Vector<AtomicString>& contentAttrValues() { return m_contentAttrValues; }
void setLineHeightValue(CSSValue* value) { m_lineHeightValue = value; }
CSSValue* lineHeightValue() { return m_lineHeightValue; }
void cacheUserAgentBorderAndBackground()
{
if (!style()->hasAppearance())
return;
m_cachedUAStyle = CachedUAStyle(style());
}
const CachedUAStyle& cachedUAStyle() const { return m_cachedUAStyle; }
ElementStyleResources& elementStyleResources() { return m_elementStyleResources; }
const CSSToStyleMap& styleMap() const { return m_styleMap; }
CSSToStyleMap& styleMap() { return m_styleMap; }
PassRefPtr<StyleImage> styleImage(CSSPropertyID propertyId, CSSValue* value)
{
return m_elementStyleResources.styleImage(document().textLinkColors(), style()->color(), propertyId, value);
}
FontBuilder& fontBuilder() { return m_fontBuilder; }
const FontDescription& parentFontDescription() { return m_parentStyle->fontDescription(); }
void setZoom(float f) { m_fontBuilder.didChangeFontParameters(m_style->setZoom(f)); }
void setEffectiveZoom(float f) { m_fontBuilder.didChangeFontParameters(m_style->setEffectiveZoom(f)); }
void setWritingMode(WritingMode writingMode) { m_fontBuilder.didChangeFontParameters(m_style->setWritingMode(writingMode)); }
void setTextOrientation(TextOrientation textOrientation) { m_fontBuilder.didChangeFontParameters(m_style->setTextOrientation(textOrientation)); }
bool useSVGZoomRules() const { return element() && element()->isSVGElement(); }
private:
ElementResolveContext m_elementContext;
Document& m_document;
RefPtr<RenderStyle> m_style;
CSSToLengthConversionData m_cssToLengthConversionData;
RefPtr<RenderStyle> m_parentStyle;
OwnPtrWillBeMember<CSSAnimationUpdate> m_animationUpdate;
bool m_applyPropertyToRegularStyle;
bool m_applyPropertyToVisitedLinkStyle;
RawPtrWillBeMember<CSSValue> m_lineHeightValue;
FontBuilder m_fontBuilder;
CachedUAStyle m_cachedUAStyle;
ElementStyleResources m_elementStyleResources;
CSSToStyleMap m_styleMap;
Vector<AtomicString> m_contentAttrValues;
RawPtrWillBeMember<StyleRule> m_currentRule;
};
}
#endif