| 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&, const ElementResolveContext&, RenderStyle* par
entStyle); | 48 StyleResolverState(Document&, const ElementResolveContext&, const RenderStyl
e* parentStyle); |
| 49 StyleResolverState(Document&, Element*, RenderStyle* parentStyle = 0); | 49 StyleResolverState(Document&, Element*, const RenderStyle* parentStyle = 0); |
| 50 ~StyleResolverState(); | 50 ~StyleResolverState(); |
| 51 | 51 |
| 52 // In FontFaceSet and CanvasRenderingContext2D, we don't have an element to
grab the document from. | 52 // In FontFaceSet and CanvasRenderingContext2D, we don't have an element to
grab the document from. |
| 53 // This is why we have to store the document separately. | 53 // This is why we have to store the document separately. |
| 54 Document& document() const { return *m_document; } | 54 Document& document() const { return *m_document; } |
| 55 // These are all just pass-through methods to ElementResolveContext. | 55 // These are all just pass-through methods to ElementResolveContext. |
| 56 Element* element() const { return m_elementContext.element(); } | 56 Element* element() const { return m_elementContext.element(); } |
| 57 const ContainerNode* parentNode() const { return m_elementContext.parentNode
(); } | 57 const ContainerNode* parentNode() const { return m_elementContext.parentNode
(); } |
| 58 const RenderStyle* rootElementStyle() const { return m_elementContext.rootEl
ementStyle(); } | 58 const RenderStyle* rootElementStyle() const { return m_elementContext.rootEl
ementStyle(); } |
| 59 EInsideLink elementLinkState() const { return m_elementContext.elementLinkSt
ate(); } | 59 EInsideLink elementLinkState() const { return m_elementContext.elementLinkSt
ate(); } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 74 | 74 |
| 75 const CSSToLengthConversionData& cssToLengthConversionData() const { return
m_cssToLengthConversionData; } | 75 const CSSToLengthConversionData& cssToLengthConversionData() const { return
m_cssToLengthConversionData; } |
| 76 | 76 |
| 77 void setConversionFontSizes(const CSSToLengthConversionData::FontSizes& font
Sizes) { m_cssToLengthConversionData.setFontSizes(fontSizes); } | 77 void setConversionFontSizes(const CSSToLengthConversionData::FontSizes& font
Sizes) { m_cssToLengthConversionData.setFontSizes(fontSizes); } |
| 78 void setConversionZoom(float zoom) { m_cssToLengthConversionData.setZoom(zoo
m); } | 78 void setConversionZoom(float zoom) { m_cssToLengthConversionData.setZoom(zoo
m); } |
| 79 | 79 |
| 80 void setAnimationUpdate(PassOwnPtrWillBeRawPtr<CSSAnimationUpdate>); | 80 void setAnimationUpdate(PassOwnPtrWillBeRawPtr<CSSAnimationUpdate>); |
| 81 const CSSAnimationUpdate* animationUpdate() { return m_animationUpdate.get()
; } | 81 const CSSAnimationUpdate* animationUpdate() { return m_animationUpdate.get()
; } |
| 82 PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> takeAnimationUpdate(); | 82 PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> takeAnimationUpdate(); |
| 83 | 83 |
| 84 void setParentStyle(PassRefPtr<RenderStyle> parentStyle) { m_parentStyle = p
arentStyle; } | 84 void setParentStyle(PassRefPtr<RenderStyle> parentStyle) { m_overrideParentS
tyle = parentStyle; } |
| 85 const RenderStyle* parentStyle() const { return m_parentStyle.get(); } | 85 const RenderStyle* parentStyle() const |
| 86 RenderStyle* parentStyle() { return m_parentStyle.get(); } | 86 { |
| 87 if (m_overrideParentStyle) |
| 88 return m_overrideParentStyle.get(); |
| 89 return m_parentStyle; |
| 90 } |
| 87 | 91 |
| 88 // FIXME: These are effectively side-channel "out parameters" for the variou
s | 92 // FIXME: These are effectively side-channel "out parameters" for the variou
s |
| 89 // map functions. When we map from CSS to style objects we use this state ob
ject | 93 // map functions. When we map from CSS to style objects we use this state ob
ject |
| 90 // to track various meta-data about that mapping (e.g. if it's cache-able). | 94 // to track various meta-data about that mapping (e.g. if it's cache-able). |
| 91 // We need to move this data off of StyleResolverState and closer to the | 95 // We need to move this data off of StyleResolverState and closer to the |
| 92 // objects it applies to. Possibly separating (immutable) inputs from (mutab
le) outputs. | 96 // objects it applies to. Possibly separating (immutable) inputs from (mutab
le) outputs. |
| 93 void setApplyPropertyToRegularStyle(bool isApply) { m_applyPropertyToRegular
Style = isApply; } | 97 void setApplyPropertyToRegularStyle(bool isApply) { m_applyPropertyToRegular
Style = isApply; } |
| 94 void setApplyPropertyToVisitedLinkStyle(bool isApply) { m_applyPropertyToVis
itedLinkStyle = isApply; } | 98 void setApplyPropertyToVisitedLinkStyle(bool isApply) { m_applyPropertyToVis
itedLinkStyle = isApply; } |
| 95 bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularSt
yle; } | 99 bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularSt
yle; } |
| 96 bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisit
edLinkStyle; } | 100 bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisit
edLinkStyle; } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 119 { | 123 { |
| 120 return m_elementStyleResources.styleImage(document(), document().textLin
kColors(), style()->color(), propertyId, value); | 124 return m_elementStyleResources.styleImage(document(), document().textLin
kColors(), style()->color(), propertyId, value); |
| 121 } | 125 } |
| 122 | 126 |
| 123 FontBuilder& fontBuilder() { return m_fontBuilder; } | 127 FontBuilder& fontBuilder() { return m_fontBuilder; } |
| 124 // FIXME: These exist as a primitive way to track mutations to font-related
properties | 128 // FIXME: These exist as a primitive way to track mutations to font-related
properties |
| 125 // on a RenderStyle. As designed, these are very error-prone, as some caller
s | 129 // on a RenderStyle. As designed, these are very error-prone, as some caller
s |
| 126 // set these directly on the RenderStyle w/o telling us. Presumably we'll | 130 // set these directly on the RenderStyle w/o telling us. Presumably we'll |
| 127 // want to design a better wrapper around RenderStyle for tracking these mut
ations | 131 // want to design a better wrapper around RenderStyle for tracking these mut
ations |
| 128 // and separate it from StyleResolverState. | 132 // and separate it from StyleResolverState. |
| 129 const FontDescription& parentFontDescription() { return m_parentStyle->fontD
escription(); } | 133 const FontDescription& parentFontDescription() { return parentStyle()->fontD
escription(); } |
| 130 void setZoom(float f) { m_fontBuilder.didChangeFontParameters(m_style->setZo
om(f)); } | 134 void setZoom(float f) { m_fontBuilder.didChangeFontParameters(m_style->setZo
om(f)); } |
| 131 void setEffectiveZoom(float f) { m_fontBuilder.didChangeFontParameters(m_sty
le->setEffectiveZoom(f)); } | 135 void setEffectiveZoom(float f) { m_fontBuilder.didChangeFontParameters(m_sty
le->setEffectiveZoom(f)); } |
| 132 void setWritingMode(WritingMode writingMode) { m_fontBuilder.didChangeFontPa
rameters(m_style->setWritingMode(writingMode)); } | 136 void setWritingMode(WritingMode writingMode) { m_fontBuilder.didChangeFontPa
rameters(m_style->setWritingMode(writingMode)); } |
| 133 void setTextOrientation(TextOrientation textOrientation) { m_fontBuilder.did
ChangeFontParameters(m_style->setTextOrientation(textOrientation)); } | 137 void setTextOrientation(TextOrientation textOrientation) { m_fontBuilder.did
ChangeFontParameters(m_style->setTextOrientation(textOrientation)); } |
| 134 | 138 |
| 135 private: | 139 private: |
| 136 ElementResolveContext m_elementContext; | 140 ElementResolveContext m_elementContext; |
| 137 RawPtrWillBeMember<Document> m_document; | 141 RawPtrWillBeMember<Document> m_document; |
| 138 | 142 |
| 139 // m_style is the primary output for each element's style resolve. | 143 // m_style is the primary output for each element's style resolve. |
| 140 RefPtr<RenderStyle> m_style; | 144 RefPtr<RenderStyle> m_style; |
| 141 | 145 |
| 142 CSSToLengthConversionData m_cssToLengthConversionData; | 146 CSSToLengthConversionData m_cssToLengthConversionData; |
| 143 | 147 |
| 144 // m_parentStyle is not always just ElementResolveContext::parentStyle, | 148 // m_parentStyle is not always just ElementResolveContext::parentStyle, |
| 145 // so we keep it separate. | 149 // so we keep it separate. |
| 146 RefPtr<RenderStyle> m_parentStyle; | 150 const RenderStyle* m_parentStyle; |
| 151 RefPtr<RenderStyle> m_overrideParentStyle; |
| 147 | 152 |
| 148 OwnPtrWillBeMember<CSSAnimationUpdate> m_animationUpdate; | 153 OwnPtrWillBeMember<CSSAnimationUpdate> m_animationUpdate; |
| 149 | 154 |
| 150 bool m_applyPropertyToRegularStyle; | 155 bool m_applyPropertyToRegularStyle; |
| 151 bool m_applyPropertyToVisitedLinkStyle; | 156 bool m_applyPropertyToVisitedLinkStyle; |
| 152 | 157 |
| 153 FontBuilder m_fontBuilder; | 158 FontBuilder m_fontBuilder; |
| 154 | 159 |
| 155 OwnPtr<CachedUAStyle> m_cachedUAStyle; | 160 OwnPtr<CachedUAStyle> m_cachedUAStyle; |
| 156 | 161 |
| 157 ElementStyleResources m_elementStyleResources; | 162 ElementStyleResources m_elementStyleResources; |
| 158 }; | 163 }; |
| 159 | 164 |
| 160 } // namespace blink | 165 } // namespace blink |
| 161 | 166 |
| 162 #endif // StyleResolverState_h | 167 #endif // StyleResolverState_h |
| OLD | NEW |