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 15 matching lines...) Expand all Loading... |
26 | 26 |
27 #include "core/css/CSSSVGDocumentValue.h" | 27 #include "core/css/CSSSVGDocumentValue.h" |
28 #include "core/css/CSSToLengthConversionData.h" | 28 #include "core/css/CSSToLengthConversionData.h" |
29 #include "core/css/resolver/CSSToStyleMap.h" | 29 #include "core/css/resolver/CSSToStyleMap.h" |
30 #include "core/css/resolver/ElementResolveContext.h" | 30 #include "core/css/resolver/ElementResolveContext.h" |
31 #include "core/css/resolver/ElementStyleResources.h" | 31 #include "core/css/resolver/ElementStyleResources.h" |
32 #include "core/css/resolver/FontBuilder.h" | 32 #include "core/css/resolver/FontBuilder.h" |
33 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
34 #include "core/dom/Element.h" | 34 #include "core/dom/Element.h" |
35 #include "core/layout/style/CachedUAStyle.h" | 35 #include "core/layout/style/CachedUAStyle.h" |
36 #include "core/layout/style/LayoutStyle.h" | 36 #include "core/layout/style/ComputedStyle.h" |
37 #include "core/layout/style/StyleInheritedData.h" | 37 #include "core/layout/style/StyleInheritedData.h" |
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&, const LayoutStyl
e* parentStyle); | 48 StyleResolverState(Document&, const ElementResolveContext&, const ComputedSt
yle* parentStyle); |
49 StyleResolverState(Document&, Element*, const LayoutStyle* parentStyle = 0); | 49 StyleResolverState(Document&, Element*, const ComputedStyle* 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 LayoutStyle* rootElementStyle() const { return m_elementContext.rootEl
ementStyle(); } | 58 const ComputedStyle* rootElementStyle() const { return m_elementContext.root
ElementStyle(); } |
59 EInsideLink elementLinkState() const { return m_elementContext.elementLinkSt
ate(); } | 59 EInsideLink elementLinkState() const { return m_elementContext.elementLinkSt
ate(); } |
60 bool distributedToInsertionPoint() const { return m_elementContext.distribut
edToInsertionPoint(); } | 60 bool distributedToInsertionPoint() const { return m_elementContext.distribut
edToInsertionPoint(); } |
61 | 61 |
62 const ElementResolveContext& elementContext() const { return m_elementContex
t; } | 62 const ElementResolveContext& elementContext() const { return m_elementContex
t; } |
63 | 63 |
64 void setStyle(PassRefPtr<LayoutStyle> style) | 64 void setStyle(PassRefPtr<ComputedStyle> style) |
65 { | 65 { |
66 // FIXME: Improve RAII of StyleResolverState to remove this function. | 66 // FIXME: Improve RAII of StyleResolverState to remove this function. |
67 m_style = style; | 67 m_style = style; |
68 m_cssToLengthConversionData = CSSToLengthConversionData(m_style.get(), r
ootElementStyle(), document().layoutView(), m_style->effectiveZoom()); | 68 m_cssToLengthConversionData = CSSToLengthConversionData(m_style.get(), r
ootElementStyle(), document().layoutView(), m_style->effectiveZoom()); |
69 } | 69 } |
70 const LayoutStyle* style() const { return m_style.get(); } | 70 const ComputedStyle* style() const { return m_style.get(); } |
71 LayoutStyle* style() { return m_style.get(); } | 71 ComputedStyle* style() { return m_style.get(); } |
72 PassRefPtr<LayoutStyle> takeStyle() { return m_style.release(); } | 72 PassRefPtr<ComputedStyle> takeStyle() { return m_style.release(); } |
73 | 73 |
74 LayoutStyle& mutableStyleRef() const { return *m_style; } | 74 ComputedStyle& mutableStyleRef() const { return *m_style; } |
75 const LayoutStyle& styleRef() const { return mutableStyleRef(); } | 75 const ComputedStyle& styleRef() const { return mutableStyleRef(); } |
76 | 76 |
77 const CSSToLengthConversionData& cssToLengthConversionData() const { return
m_cssToLengthConversionData; } | 77 const CSSToLengthConversionData& cssToLengthConversionData() const { return
m_cssToLengthConversionData; } |
78 | 78 |
79 void setConversionFontSizes(const CSSToLengthConversionData::FontSizes& font
Sizes) { m_cssToLengthConversionData.setFontSizes(fontSizes); } | 79 void setConversionFontSizes(const CSSToLengthConversionData::FontSizes& font
Sizes) { m_cssToLengthConversionData.setFontSizes(fontSizes); } |
80 void setConversionZoom(float zoom) { m_cssToLengthConversionData.setZoom(zoo
m); } | 80 void setConversionZoom(float zoom) { m_cssToLengthConversionData.setZoom(zoo
m); } |
81 | 81 |
82 void setAnimationUpdate(PassOwnPtrWillBeRawPtr<CSSAnimationUpdate>); | 82 void setAnimationUpdate(PassOwnPtrWillBeRawPtr<CSSAnimationUpdate>); |
83 const CSSAnimationUpdate* animationUpdate() { return m_animationUpdate.get()
; } | 83 const CSSAnimationUpdate* animationUpdate() { return m_animationUpdate.get()
; } |
84 PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> takeAnimationUpdate(); | 84 PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> takeAnimationUpdate(); |
85 | 85 |
86 void setParentStyle(PassRefPtr<LayoutStyle> parentStyle) { m_parentStyle = p
arentStyle; } | 86 void setParentStyle(PassRefPtr<ComputedStyle> parentStyle) { m_parentStyle =
parentStyle; } |
87 const LayoutStyle* parentStyle() const { return m_parentStyle.get(); } | 87 const ComputedStyle* parentStyle() const { return m_parentStyle.get(); } |
88 LayoutStyle* parentStyle() { return m_parentStyle.get(); } | 88 ComputedStyle* parentStyle() { return m_parentStyle.get(); } |
89 | 89 |
90 // FIXME: These are effectively side-channel "out parameters" for the variou
s | 90 // FIXME: These are effectively side-channel "out parameters" for the variou
s |
91 // map functions. When we map from CSS to style objects we use this state ob
ject | 91 // map functions. When we map from CSS to style objects we use this state ob
ject |
92 // to track various meta-data about that mapping (e.g. if it's cache-able). | 92 // to track various meta-data about that mapping (e.g. if it's cache-able). |
93 // We need to move this data off of StyleResolverState and closer to the | 93 // We need to move this data off of StyleResolverState and closer to the |
94 // objects it applies to. Possibly separating (immutable) inputs from (mutab
le) outputs. | 94 // objects it applies to. Possibly separating (immutable) inputs from (mutab
le) outputs. |
95 void setApplyPropertyToRegularStyle(bool isApply) { m_applyPropertyToRegular
Style = isApply; } | 95 void setApplyPropertyToRegularStyle(bool isApply) { m_applyPropertyToRegular
Style = isApply; } |
96 void setApplyPropertyToVisitedLinkStyle(bool isApply) { m_applyPropertyToVis
itedLinkStyle = isApply; } | 96 void setApplyPropertyToVisitedLinkStyle(bool isApply) { m_applyPropertyToVis
itedLinkStyle = isApply; } |
97 bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularSt
yle; } | 97 bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularSt
yle; } |
98 bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisit
edLinkStyle; } | 98 bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisit
edLinkStyle; } |
(...skipping 18 matching lines...) Expand all Loading... |
117 // FIXME: Once styleImage can be made to not take a StyleResolverState | 117 // FIXME: Once styleImage can be made to not take a StyleResolverState |
118 // this convenience function should be removed. As-is, without this, call | 118 // this convenience function should be removed. As-is, without this, call |
119 // sites are extremely verbose. | 119 // sites are extremely verbose. |
120 PassRefPtr<StyleImage> styleImage(CSSPropertyID propertyId, CSSValue* value) | 120 PassRefPtr<StyleImage> styleImage(CSSPropertyID propertyId, CSSValue* value) |
121 { | 121 { |
122 return m_elementStyleResources.styleImage(document(), document().textLin
kColors(), style()->color(), propertyId, value); | 122 return m_elementStyleResources.styleImage(document(), document().textLin
kColors(), style()->color(), propertyId, value); |
123 } | 123 } |
124 | 124 |
125 FontBuilder& fontBuilder() { return m_fontBuilder; } | 125 FontBuilder& fontBuilder() { return m_fontBuilder; } |
126 // FIXME: These exist as a primitive way to track mutations to font-related
properties | 126 // FIXME: These exist as a primitive way to track mutations to font-related
properties |
127 // on a LayoutStyle. As designed, these are very error-prone, as some caller
s | 127 // on a ComputedStyle. As designed, these are very error-prone, as some call
ers |
128 // set these directly on the LayoutStyle w/o telling us. Presumably we'll | 128 // set these directly on the ComputedStyle w/o telling us. Presumably we'll |
129 // want to design a better wrapper around LayoutStyle for tracking these mut
ations | 129 // want to design a better wrapper around ComputedStyle for tracking these m
utations |
130 // and separate it from StyleResolverState. | 130 // and separate it from StyleResolverState. |
131 const FontDescription& parentFontDescription() { return m_parentStyle->fontD
escription(); } | 131 const FontDescription& parentFontDescription() { return m_parentStyle->fontD
escription(); } |
132 | 132 |
133 void setZoom(float f) | 133 void setZoom(float f) |
134 { | 134 { |
135 if (m_style->setZoom(f)) | 135 if (m_style->setZoom(f)) |
136 m_fontBuilder.didChangeEffectiveZoom(); | 136 m_fontBuilder.didChangeEffectiveZoom(); |
137 } | 137 } |
138 void setEffectiveZoom(float f) | 138 void setEffectiveZoom(float f) |
139 { | 139 { |
(...skipping 12 matching lines...) Expand all Loading... |
152 } | 152 } |
153 | 153 |
154 void setHasDirAutoAttribute(bool value) { m_hasDirAutoAttribute = value; } | 154 void setHasDirAutoAttribute(bool value) { m_hasDirAutoAttribute = value; } |
155 bool hasDirAutoAttribute() const { return m_hasDirAutoAttribute; } | 155 bool hasDirAutoAttribute() const { return m_hasDirAutoAttribute; } |
156 | 156 |
157 private: | 157 private: |
158 ElementResolveContext m_elementContext; | 158 ElementResolveContext m_elementContext; |
159 RawPtrWillBeMember<Document> m_document; | 159 RawPtrWillBeMember<Document> m_document; |
160 | 160 |
161 // m_style is the primary output for each element's style resolve. | 161 // m_style is the primary output for each element's style resolve. |
162 RefPtr<LayoutStyle> m_style; | 162 RefPtr<ComputedStyle> m_style; |
163 | 163 |
164 CSSToLengthConversionData m_cssToLengthConversionData; | 164 CSSToLengthConversionData m_cssToLengthConversionData; |
165 | 165 |
166 // m_parentStyle is not always just ElementResolveContext::parentStyle, | 166 // m_parentStyle is not always just ElementResolveContext::parentStyle, |
167 // so we keep it separate. | 167 // so we keep it separate. |
168 RefPtr<LayoutStyle> m_parentStyle; | 168 RefPtr<ComputedStyle> m_parentStyle; |
169 | 169 |
170 OwnPtrWillBeMember<CSSAnimationUpdate> m_animationUpdate; | 170 OwnPtrWillBeMember<CSSAnimationUpdate> m_animationUpdate; |
171 | 171 |
172 bool m_applyPropertyToRegularStyle; | 172 bool m_applyPropertyToRegularStyle; |
173 bool m_applyPropertyToVisitedLinkStyle; | 173 bool m_applyPropertyToVisitedLinkStyle; |
174 bool m_hasDirAutoAttribute; | 174 bool m_hasDirAutoAttribute; |
175 | 175 |
176 FontBuilder m_fontBuilder; | 176 FontBuilder m_fontBuilder; |
177 | 177 |
178 OwnPtr<CachedUAStyle> m_cachedUAStyle; | 178 OwnPtr<CachedUAStyle> m_cachedUAStyle; |
179 | 179 |
180 ElementStyleResources m_elementStyleResources; | 180 ElementStyleResources m_elementStyleResources; |
181 }; | 181 }; |
182 | 182 |
183 } // namespace blink | 183 } // namespace blink |
184 | 184 |
185 #endif // StyleResolverState_h | 185 #endif // StyleResolverState_h |
OLD | NEW |