| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 class CSSAnimationUpdate; | 41 class CSSAnimationUpdate; |
| 42 class FontDescription; | 42 class FontDescription; |
| 43 | 43 |
| 44 class StyleResolverState { | 44 class StyleResolverState { |
| 45 STACK_ALLOCATED(); | 45 STACK_ALLOCATED(); |
| 46 WTF_MAKE_NONCOPYABLE(StyleResolverState); | 46 WTF_MAKE_NONCOPYABLE(StyleResolverState); |
| 47 public: | 47 public: |
| 48 StyleResolverState(Document&, Element*, RenderStyle* parentStyle = 0); | 48 StyleResolverState(const ElementResolveContext&); |
| 49 StyleResolverState(Document&, Element*, PassRefPtr<RenderStyle>, RenderStyle
* parentStyle = nullptr); |
| 49 ~StyleResolverState(); | 50 ~StyleResolverState(); |
| 50 | 51 |
| 51 // In FontFaceSet and CanvasRenderingContext2D, we don't have an element to
grab the document from. | 52 static PassRefPtr<RenderStyle> defaultStyleForElement(Document&); |
| 52 // This is why we have to store the document separately. | 53 |
| 53 Document& document() const { return *m_document; } | |
| 54 // These are all just pass-through methods to ElementResolveContext. | 54 // These are all just pass-through methods to ElementResolveContext. |
| 55 Document& document() const { return m_elementContext.document(); } |
| 55 Element* element() const { return m_elementContext.element(); } | 56 Element* element() const { return m_elementContext.element(); } |
| 56 const ContainerNode* parentNode() const { return m_elementContext.parentNode
(); } | 57 const ContainerNode* parentNode() const { return m_elementContext.parentNode
(); } |
| 57 const RenderStyle* rootElementStyle() const { return m_elementContext.rootEl
ementStyle(); } | 58 const RenderStyle* rootElementStyle() const { return m_elementContext.rootEl
ementStyle(); } |
| 58 EInsideLink elementLinkState() const { return m_elementContext.elementLinkSt
ate(); } | 59 EInsideLink elementLinkState() const { return m_elementContext.elementLinkSt
ate(); } |
| 59 bool distributedToInsertionPoint() const { return m_elementContext.distribut
edToInsertionPoint(); } | 60 bool distributedToInsertionPoint() const { return m_elementContext.distribut
edToInsertionPoint(); } |
| 60 | 61 |
| 61 const ElementResolveContext& elementContext() const { return m_elementContex
t; } | 62 const ElementResolveContext& elementContext() const { return m_elementContex
t; } |
| 62 | 63 |
| 63 void setStyle(PassRefPtr<RenderStyle> style) | |
| 64 { | |
| 65 m_style = style; | |
| 66 m_cssToLengthConversionData.setStyle(m_style.get()); | |
| 67 m_fontBuilder.setStyle(m_style.get()); | |
| 68 } | |
| 69 const RenderStyle* style() const { return m_style.get(); } | 64 const RenderStyle* style() const { return m_style.get(); } |
| 70 RenderStyle* style() { return m_style.get(); } | 65 RenderStyle* style() { return m_style.get(); } |
| 71 PassRefPtr<RenderStyle> takeStyle() { return m_style.release(); } | 66 PassRefPtr<RenderStyle> takeStyle() { return m_style.release(); } |
| 72 | 67 |
| 73 const CSSToLengthConversionData& cssToLengthConversionData() const { return
m_cssToLengthConversionData; } | 68 const CSSToLengthConversionData& cssToLengthConversionData() const { return
m_cssToLengthConversionData; } |
| 74 | 69 |
| 75 void setAnimationUpdate(PassOwnPtrWillBeRawPtr<CSSAnimationUpdate>); | 70 void setAnimationUpdate(PassOwnPtrWillBeRawPtr<CSSAnimationUpdate>); |
| 76 const CSSAnimationUpdate* animationUpdate() { return m_animationUpdate.get()
; } | 71 const CSSAnimationUpdate* animationUpdate() { return m_animationUpdate.get()
; } |
| 77 PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> takeAnimationUpdate(); | 72 PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> takeAnimationUpdate(); |
| 78 | 73 |
| 79 void setParentStyle(PassRefPtr<RenderStyle> parentStyle) { m_parentStyle = p
arentStyle; } | |
| 80 const RenderStyle* parentStyle() const { return m_parentStyle.get(); } | 74 const RenderStyle* parentStyle() const { return m_parentStyle.get(); } |
| 81 RenderStyle* parentStyle() { return m_parentStyle.get(); } | 75 RenderStyle* parentStyle() { return m_parentStyle.get(); } |
| 82 | 76 |
| 83 // FIXME: These are effectively side-channel "out parameters" for the variou
s | 77 // FIXME: These are effectively side-channel "out parameters" for the variou
s |
| 84 // map functions. When we map from CSS to style objects we use this state ob
ject | 78 // map functions. When we map from CSS to style objects we use this state ob
ject |
| 85 // to track various meta-data about that mapping (e.g. if it's cache-able). | 79 // to track various meta-data about that mapping (e.g. if it's cache-able). |
| 86 // We need to move this data off of StyleResolverState and closer to the | 80 // We need to move this data off of StyleResolverState and closer to the |
| 87 // objects it applies to. Possibly separating (immutable) inputs from (mutab
le) outputs. | 81 // objects it applies to. Possibly separating (immutable) inputs from (mutab
le) outputs. |
| 88 void setApplyPropertyToRegularStyle(bool isApply) { m_applyPropertyToRegular
Style = isApply; } | 82 void setApplyPropertyToRegularStyle(bool isApply) { m_applyPropertyToRegular
Style = isApply; } |
| 89 void setApplyPropertyToVisitedLinkStyle(bool isApply) { m_applyPropertyToVis
itedLinkStyle = isApply; } | 83 void setApplyPropertyToVisitedLinkStyle(bool isApply) { m_applyPropertyToVis
itedLinkStyle = isApply; } |
| 90 bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularSt
yle; } | 84 bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularSt
yle; } |
| 91 bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisit
edLinkStyle; } | 85 bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisit
edLinkStyle; } |
| 92 | 86 |
| 93 // Holds all attribute names found while applying "content" properties that
contain an "attr()" value. | 87 // Holds all attribute names found while applying "content" properties that
contain an "attr()" value. |
| 94 Vector<AtomicString>& contentAttrValues() { return m_contentAttrValues; } | 88 Vector<AtomicString>& contentAttrValues() { return m_contentAttrValues; } |
| 95 | 89 |
| 96 void setLineHeightValue(CSSValue* value) { m_lineHeightValue = value; } | |
| 97 CSSValue* lineHeightValue() { return m_lineHeightValue; } | |
| 98 | |
| 99 void cacheUserAgentBorderAndBackground() | 90 void cacheUserAgentBorderAndBackground() |
| 100 { | 91 { |
| 101 // RenderTheme only needs the cached style if it has an appearance, | 92 // RenderTheme only needs the cached style if it has an appearance, |
| 102 // and constructing it is expensive so we avoid it if possible. | 93 // and constructing it is expensive so we avoid it if possible. |
| 103 if (!style()->hasAppearance()) | 94 if (!style()->hasAppearance()) |
| 104 return; | 95 return; |
| 105 | 96 |
| 106 m_cachedUAStyle = CachedUAStyle::create(style()); | 97 m_cachedUAStyle = CachedUAStyle::create(style()); |
| 107 } | 98 } |
| 108 | 99 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 130 // want to design a better wrapper around RenderStyle for tracking these mut
ations | 121 // want to design a better wrapper around RenderStyle for tracking these mut
ations |
| 131 // and separate it from StyleResolverState. | 122 // and separate it from StyleResolverState. |
| 132 const FontDescription& parentFontDescription() { return m_parentStyle->fontD
escription(); } | 123 const FontDescription& parentFontDescription() { return m_parentStyle->fontD
escription(); } |
| 133 void setZoom(float f) { m_fontBuilder.didChangeFontParameters(m_style->setZo
om(f)); } | 124 void setZoom(float f) { m_fontBuilder.didChangeFontParameters(m_style->setZo
om(f)); } |
| 134 void setEffectiveZoom(float f) { m_fontBuilder.didChangeFontParameters(m_sty
le->setEffectiveZoom(f)); } | 125 void setEffectiveZoom(float f) { m_fontBuilder.didChangeFontParameters(m_sty
le->setEffectiveZoom(f)); } |
| 135 void setWritingMode(WritingMode writingMode) { m_fontBuilder.didChangeFontPa
rameters(m_style->setWritingMode(writingMode)); } | 126 void setWritingMode(WritingMode writingMode) { m_fontBuilder.didChangeFontPa
rameters(m_style->setWritingMode(writingMode)); } |
| 136 void setTextOrientation(TextOrientation textOrientation) { m_fontBuilder.did
ChangeFontParameters(m_style->setTextOrientation(textOrientation)); } | 127 void setTextOrientation(TextOrientation textOrientation) { m_fontBuilder.did
ChangeFontParameters(m_style->setTextOrientation(textOrientation)); } |
| 137 | 128 |
| 138 private: | 129 private: |
| 139 ElementResolveContext m_elementContext; | 130 ElementResolveContext m_elementContext; |
| 140 RawPtrWillBeMember<Document> m_document; | |
| 141 | 131 |
| 142 // m_style is the primary output for each element's style resolve. | 132 // m_style is the primary output for each element's style resolve. |
| 143 RefPtr<RenderStyle> m_style; | 133 RefPtr<RenderStyle> m_style; |
| 144 | 134 |
| 145 CSSToLengthConversionData m_cssToLengthConversionData; | 135 CSSToLengthConversionData m_cssToLengthConversionData; |
| 146 | 136 |
| 147 // m_parentStyle is not always just element->parentNode()->style() | 137 // m_parentStyle is not always just element->parentNode()->style() |
| 148 // so we keep it separate from m_elementContext. | 138 // so we keep it separate from m_elementContext. |
| 149 RefPtr<RenderStyle> m_parentStyle; | 139 RefPtr<RenderStyle> m_parentStyle; |
| 150 | 140 |
| 151 OwnPtrWillBeMember<CSSAnimationUpdate> m_animationUpdate; | 141 OwnPtrWillBeMember<CSSAnimationUpdate> m_animationUpdate; |
| 152 | 142 |
| 153 bool m_applyPropertyToRegularStyle; | 143 bool m_applyPropertyToRegularStyle; |
| 154 bool m_applyPropertyToVisitedLinkStyle; | 144 bool m_applyPropertyToVisitedLinkStyle; |
| 155 | 145 |
| 156 RawPtrWillBeMember<CSSValue> m_lineHeightValue; | |
| 157 | |
| 158 FontBuilder m_fontBuilder; | 146 FontBuilder m_fontBuilder; |
| 159 | 147 |
| 160 OwnPtr<CachedUAStyle> m_cachedUAStyle; | 148 OwnPtr<CachedUAStyle> m_cachedUAStyle; |
| 161 | 149 |
| 162 ElementStyleResources m_elementStyleResources; | 150 ElementStyleResources m_elementStyleResources; |
| 163 // CSSToStyleMap is a pure-logic class and only contains | 151 // CSSToStyleMap is a pure-logic class and only contains |
| 164 // a back-pointer to this object. | 152 // a back-pointer to this object. |
| 165 CSSToStyleMap m_styleMap; | 153 CSSToStyleMap m_styleMap; |
| 166 Vector<AtomicString> m_contentAttrValues; | 154 Vector<AtomicString> m_contentAttrValues; |
| 167 }; | 155 }; |
| 168 | 156 |
| 169 } // namespace blink | 157 } // namespace blink |
| 170 | 158 |
| 171 #endif // StyleResolverState_h | 159 #endif // StyleResolverState_h |
| OLD | NEW |