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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 STACK_ALLOCATED(); | 83 STACK_ALLOCATED(); |
84 public: | 84 public: |
85 CSSPropertyValue(CSSPropertyID property, CSSValue* value) | 85 CSSPropertyValue(CSSPropertyID property, CSSValue* value) |
86 : property(property), value(value) { } | 86 : property(property), value(value) { } |
87 // Stores value=propertySet.getPropertyCSSValue(id).get(). | 87 // Stores value=propertySet.getPropertyCSSValue(id).get(). |
88 CSSPropertyValue(CSSPropertyID, const StylePropertySet&); | 88 CSSPropertyValue(CSSPropertyID, const StylePropertySet&); |
89 CSSPropertyID property; | 89 CSSPropertyID property; |
90 RawPtrWillBeMember<CSSValue> value; | 90 RawPtrWillBeMember<CSSValue> value; |
91 }; | 91 }; |
92 | 92 |
93 // This class selects a LayoutStyle for a given element based on a collection of
stylesheets. | 93 // This class selects a ComputedStyle for a given element based on a collection
of stylesheets. |
94 class StyleResolver final : public NoBaseWillBeGarbageCollectedFinalized<StyleRe
solver> { | 94 class StyleResolver final : public NoBaseWillBeGarbageCollectedFinalized<StyleRe
solver> { |
95 WTF_MAKE_NONCOPYABLE(StyleResolver); WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED
(StyleResolver); | 95 WTF_MAKE_NONCOPYABLE(StyleResolver); WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED
(StyleResolver); |
96 public: | 96 public: |
97 explicit StyleResolver(Document&); | 97 explicit StyleResolver(Document&); |
98 virtual ~StyleResolver(); | 98 virtual ~StyleResolver(); |
99 | 99 |
100 // FIXME: StyleResolver should not be keeping tree-walk state. | 100 // FIXME: StyleResolver should not be keeping tree-walk state. |
101 // These should move to some global tree-walk state, or should be contained
in a | 101 // These should move to some global tree-walk state, or should be contained
in a |
102 // TreeWalkContext or similar which is passed in to StyleResolver methods wh
en available. | 102 // TreeWalkContext or similar which is passed in to StyleResolver methods wh
en available. |
103 // Using these during tree walk will allow style selector to optimize child
and descendant selector lookups. | 103 // Using these during tree walk will allow style selector to optimize child
and descendant selector lookups. |
104 void pushParentElement(Element&); | 104 void pushParentElement(Element&); |
105 void popParentElement(Element&); | 105 void popParentElement(Element&); |
106 | 106 |
107 PassRefPtr<LayoutStyle> styleForElement(Element*, const LayoutStyle* parentS
tyle = 0, StyleSharingBehavior = AllowStyleSharing, | 107 PassRefPtr<ComputedStyle> styleForElement(Element*, const ComputedStyle* par
entStyle = 0, StyleSharingBehavior = AllowStyleSharing, |
108 RuleMatchingBehavior = MatchAllRules); | 108 RuleMatchingBehavior = MatchAllRules); |
109 | 109 |
110 PassRefPtr<LayoutStyle> styleForKeyframe(Element&, const LayoutStyle&, const
LayoutStyle* parentStyle, const StyleRuleKeyframe*, const AtomicString& animati
onName); | 110 PassRefPtr<ComputedStyle> styleForKeyframe(Element&, const ComputedStyle&, c
onst ComputedStyle* parentStyle, const StyleRuleKeyframe*, const AtomicString& a
nimationName); |
111 static PassRefPtrWillBeRawPtr<AnimatableValue> createAnimatableValueSnapshot
(Element&, const LayoutStyle* baseStyle, CSSPropertyID, CSSValue*); | 111 static PassRefPtrWillBeRawPtr<AnimatableValue> createAnimatableValueSnapshot
(Element&, const ComputedStyle* baseStyle, CSSPropertyID, CSSValue*); |
112 static PassRefPtrWillBeRawPtr<AnimatableValue> createAnimatableValueSnapshot
(StyleResolverState&, CSSPropertyID, CSSValue*); | 112 static PassRefPtrWillBeRawPtr<AnimatableValue> createAnimatableValueSnapshot
(StyleResolverState&, CSSPropertyID, CSSValue*); |
113 | 113 |
114 PassRefPtr<LayoutStyle> pseudoStyleForElement(Element*, const PseudoStyleReq
uest&, const LayoutStyle* parentStyle); | 114 PassRefPtr<ComputedStyle> pseudoStyleForElement(Element*, const PseudoStyleR
equest&, const ComputedStyle* parentStyle); |
115 | 115 |
116 PassRefPtr<LayoutStyle> styleForPage(int pageIndex); | 116 PassRefPtr<ComputedStyle> styleForPage(int pageIndex); |
117 PassRefPtr<LayoutStyle> styleForText(Text*); | 117 PassRefPtr<ComputedStyle> styleForText(Text*); |
118 | 118 |
119 static PassRefPtr<LayoutStyle> styleForDocument(Document&); | 119 static PassRefPtr<ComputedStyle> styleForDocument(Document&); |
120 | 120 |
121 // FIXME: It could be better to call appendAuthorStyleSheets() directly afte
r we factor StyleResolver further. | 121 // FIXME: It could be better to call appendAuthorStyleSheets() directly afte
r we factor StyleResolver further. |
122 // https://bugs.webkit.org/show_bug.cgi?id=108890 | 122 // https://bugs.webkit.org/show_bug.cgi?id=108890 |
123 void appendAuthorStyleSheets(const WillBeHeapVector<RefPtrWillBeMember<CSSSt
yleSheet>>&); | 123 void appendAuthorStyleSheets(const WillBeHeapVector<RefPtrWillBeMember<CSSSt
yleSheet>>&); |
124 void resetAuthorStyle(TreeScope&); | 124 void resetAuthorStyle(TreeScope&); |
125 void finishAppendAuthorStyleSheets(); | 125 void finishAppendAuthorStyleSheets(); |
126 | 126 |
127 void lazyAppendAuthorStyleSheets(unsigned firstNew, const WillBeHeapVector<R
efPtrWillBeMember<CSSStyleSheet>>&); | 127 void lazyAppendAuthorStyleSheets(unsigned firstNew, const WillBeHeapVector<R
efPtrWillBeMember<CSSStyleSheet>>&); |
128 void removePendingAuthorStyleSheets(const WillBeHeapVector<RefPtrWillBeMembe
r<CSSStyleSheet>>&); | 128 void removePendingAuthorStyleSheets(const WillBeHeapVector<RefPtrWillBeMembe
r<CSSStyleSheet>>&); |
129 void appendPendingAuthorStyleSheets(); | 129 void appendPendingAuthorStyleSheets(); |
(...skipping 10 matching lines...) Expand all Loading... |
140 EmptyCSSRules = 1 << 3, | 140 EmptyCSSRules = 1 << 3, |
141 CrossOriginCSSRules = 1 << 4, | 141 CrossOriginCSSRules = 1 << 4, |
142 AllButEmptyCSSRules = UAAndUserCSSRules | AuthorCSSRules | CrossOriginCS
SRules, | 142 AllButEmptyCSSRules = UAAndUserCSSRules | AuthorCSSRules | CrossOriginCS
SRules, |
143 AllCSSRules = AllButEmptyCSSRules | EmptyCSSRules, | 143 AllCSSRules = AllButEmptyCSSRules | EmptyCSSRules, |
144 }; | 144 }; |
145 PassRefPtrWillBeRawPtr<CSSRuleList> cssRulesForElement(Element*, unsigned ru
lesToInclude = AllButEmptyCSSRules); | 145 PassRefPtrWillBeRawPtr<CSSRuleList> cssRulesForElement(Element*, unsigned ru
lesToInclude = AllButEmptyCSSRules); |
146 PassRefPtrWillBeRawPtr<CSSRuleList> pseudoCSSRulesForElement(Element*, Pseud
oId, unsigned rulesToInclude = AllButEmptyCSSRules); | 146 PassRefPtrWillBeRawPtr<CSSRuleList> pseudoCSSRulesForElement(Element*, Pseud
oId, unsigned rulesToInclude = AllButEmptyCSSRules); |
147 PassRefPtrWillBeRawPtr<StyleRuleList> styleRulesForElement(Element*, unsigne
d rulesToInclude); | 147 PassRefPtrWillBeRawPtr<StyleRuleList> styleRulesForElement(Element*, unsigne
d rulesToInclude); |
148 | 148 |
149 // |properties| is an array with |count| elements. | 149 // |properties| is an array with |count| elements. |
150 void applyPropertiesToStyle(const CSSPropertyValue* properties, size_t count
, LayoutStyle*); | 150 void applyPropertiesToStyle(const CSSPropertyValue* properties, size_t count
, ComputedStyle*); |
151 | 151 |
152 ViewportStyleResolver* viewportStyleResolver() { return m_viewportStyleResol
ver.get(); } | 152 ViewportStyleResolver* viewportStyleResolver() { return m_viewportStyleResol
ver.get(); } |
153 | 153 |
154 void addMediaQueryResults(const MediaQueryResultList&); | 154 void addMediaQueryResults(const MediaQueryResultList&); |
155 MediaQueryResultList* viewportDependentMediaQueryResults() { return &m_viewp
ortDependentMediaQueryResults; } | 155 MediaQueryResultList* viewportDependentMediaQueryResults() { return &m_viewp
ortDependentMediaQueryResults; } |
156 bool hasViewportDependentMediaQueries() const { return !m_viewportDependentM
ediaQueryResults.isEmpty(); } | 156 bool hasViewportDependentMediaQueries() const { return !m_viewportDependentM
ediaQueryResults.isEmpty(); } |
157 bool mediaQueryAffectedByViewportChange() const; | 157 bool mediaQueryAffectedByViewportChange() const; |
158 | 158 |
159 // FIXME: Rename to reflect the purpose, like didChangeFontSize or something
. | 159 // FIXME: Rename to reflect the purpose, like didChangeFontSize or something
. |
160 void invalidateMatchedPropertiesCache(); | 160 void invalidateMatchedPropertiesCache(); |
161 | 161 |
162 void notifyResizeForViewportUnits(); | 162 void notifyResizeForViewportUnits(); |
163 | 163 |
164 // Exposed for LayoutStyle::isStyleAvilable(). | 164 // Exposed for ComputedStyle::isStyleAvilable(). |
165 static LayoutStyle* styleNotYetAvailable() { return s_styleNotYetAvailable;
} | 165 static ComputedStyle* styleNotYetAvailable() { return s_styleNotYetAvailable
; } |
166 | 166 |
167 RuleFeatureSet& ensureUpdatedRuleFeatureSet() | 167 RuleFeatureSet& ensureUpdatedRuleFeatureSet() |
168 { | 168 { |
169 if (hasPendingAuthorStyleSheets()) | 169 if (hasPendingAuthorStyleSheets()) |
170 appendPendingAuthorStyleSheets(); | 170 appendPendingAuthorStyleSheets(); |
171 return m_features; | 171 return m_features; |
172 } | 172 } |
173 | 173 |
174 RuleFeatureSet& ruleFeatureSet() | 174 RuleFeatureSet& ruleFeatureSet() |
175 { | 175 { |
(...skipping 20 matching lines...) Expand all Loading... |
196 void increaseStyleSharingDepth() { ++m_styleSharingDepth; } | 196 void increaseStyleSharingDepth() { ++m_styleSharingDepth; } |
197 void decreaseStyleSharingDepth() { --m_styleSharingDepth; } | 197 void decreaseStyleSharingDepth() { --m_styleSharingDepth; } |
198 | 198 |
199 PassRefPtrWillBeRawPtr<PseudoElement> createPseudoElementIfNeeded(Element& p
arent, PseudoId); | 199 PassRefPtrWillBeRawPtr<PseudoElement> createPseudoElementIfNeeded(Element& p
arent, PseudoId); |
200 | 200 |
201 DECLARE_TRACE(); | 201 DECLARE_TRACE(); |
202 | 202 |
203 void addTreeBoundaryCrossingScope(ContainerNode& scope); | 203 void addTreeBoundaryCrossingScope(ContainerNode& scope); |
204 | 204 |
205 private: | 205 private: |
206 PassRefPtr<LayoutStyle> initialStyleForElement(); | 206 PassRefPtr<ComputedStyle> initialStyleForElement(); |
207 | 207 |
208 void initWatchedSelectorRules(const WillBeHeapVector<RefPtrWillBeMember<Styl
eRule>>& watchedSelectors); | 208 void initWatchedSelectorRules(const WillBeHeapVector<RefPtrWillBeMember<Styl
eRule>>& watchedSelectors); |
209 | 209 |
210 // FIXME: This should probably go away, folded into FontBuilder. | 210 // FIXME: This should probably go away, folded into FontBuilder. |
211 void updateFont(StyleResolverState&); | 211 void updateFont(StyleResolverState&); |
212 | 212 |
213 static AuthorStyleInfo authorStyleInfo(StyleResolverState&); | 213 static AuthorStyleInfo authorStyleInfo(StyleResolverState&); |
214 | 214 |
215 void loadPendingResources(StyleResolverState&); | 215 void loadPendingResources(StyleResolverState&); |
216 void adjustLayoutStyle(StyleResolverState&, Element*); | 216 void adjustComputedStyle(StyleResolverState&, Element*); |
217 | 217 |
218 void appendCSSStyleSheet(CSSStyleSheet&); | 218 void appendCSSStyleSheet(CSSStyleSheet&); |
219 void addRulesFromSheet(CSSStyleSheet&, TreeScope*, unsigned); | 219 void addRulesFromSheet(CSSStyleSheet&, TreeScope*, unsigned); |
220 | 220 |
221 void collectPseudoRulesForElement(Element*, ElementRuleCollector&, PseudoId,
unsigned rulesToInclude); | 221 void collectPseudoRulesForElement(Element*, ElementRuleCollector&, PseudoId,
unsigned rulesToInclude); |
222 void matchRuleSet(ElementRuleCollector&, RuleSet*); | 222 void matchRuleSet(ElementRuleCollector&, RuleSet*); |
223 void matchUARules(ElementRuleCollector&); | 223 void matchUARules(ElementRuleCollector&); |
224 void matchAuthorRules(Element*, ElementRuleCollector&, bool includeEmptyRule
s); | 224 void matchAuthorRules(Element*, ElementRuleCollector&, bool includeEmptyRule
s); |
225 void matchAllRules(StyleResolverState&, ElementRuleCollector&, bool includeS
MILProperties); | 225 void matchAllRules(StyleResolverState&, ElementRuleCollector&, bool includeS
MILProperties); |
226 void collectFeatures(); | 226 void collectFeatures(); |
(...skipping 16 matching lines...) Expand all Loading... |
243 | 243 |
244 void matchPageRules(MatchResult&, RuleSet*, bool isLeftPage, bool isFirstPag
e, const String& pageName); | 244 void matchPageRules(MatchResult&, RuleSet*, bool isLeftPage, bool isFirstPag
e, const String& pageName); |
245 void matchPageRulesForList(WillBeHeapVector<RawPtrWillBeMember<StyleRulePage
>>& matchedRules, const WillBeHeapVector<RawPtrWillBeMember<StyleRulePage>>&, bo
ol isLeftPage, bool isFirstPage, const String& pageName); | 245 void matchPageRulesForList(WillBeHeapVector<RawPtrWillBeMember<StyleRulePage
>>& matchedRules, const WillBeHeapVector<RawPtrWillBeMember<StyleRulePage>>&, bo
ol isLeftPage, bool isFirstPage, const String& pageName); |
246 void collectViewportRules(); | 246 void collectViewportRules(); |
247 | 247 |
248 bool isLeftPage(int pageIndex) const; | 248 bool isLeftPage(int pageIndex) const; |
249 bool isRightPage(int pageIndex) const { return !isLeftPage(pageIndex); } | 249 bool isRightPage(int pageIndex) const { return !isLeftPage(pageIndex); } |
250 bool isFirstPage(int pageIndex) const; | 250 bool isFirstPage(int pageIndex) const; |
251 String pageName(int pageIndex) const; | 251 String pageName(int pageIndex) const; |
252 | 252 |
253 bool pseudoStyleForElementInternal(Element&, const PseudoStyleRequest&, cons
t LayoutStyle* parentStyle, StyleResolverState&); | 253 bool pseudoStyleForElementInternal(Element&, const PseudoStyleRequest&, cons
t ComputedStyle* parentStyle, StyleResolverState&); |
254 | 254 |
255 PassRefPtrWillBeRawPtr<PseudoElement> createPseudoElement(Element* parent, P
seudoId); | 255 PassRefPtrWillBeRawPtr<PseudoElement> createPseudoElement(Element* parent, P
seudoId); |
256 | 256 |
257 Document& document() { return *m_document; } | 257 Document& document() { return *m_document; } |
258 | 258 |
259 static LayoutStyle* s_styleNotYetAvailable; | 259 static ComputedStyle* s_styleNotYetAvailable; |
260 | 260 |
261 void cacheBorderAndBackground(); | 261 void cacheBorderAndBackground(); |
262 | 262 |
263 MatchedPropertiesCache m_matchedPropertiesCache; | 263 MatchedPropertiesCache m_matchedPropertiesCache; |
264 | 264 |
265 OwnPtr<MediaQueryEvaluator> m_medium; | 265 OwnPtr<MediaQueryEvaluator> m_medium; |
266 MediaQueryResultList m_viewportDependentMediaQueryResults; | 266 MediaQueryResultList m_viewportDependentMediaQueryResults; |
267 | 267 |
268 RawPtrWillBeMember<Document> m_document; | 268 RawPtrWillBeMember<Document> m_document; |
269 SelectorFilter m_selectorFilter; | 269 SelectorFilter m_selectorFilter; |
(...skipping 22 matching lines...) Expand all Loading... |
292 OwnPtr<StyleResolverStats> m_styleResolverStatsTotals; | 292 OwnPtr<StyleResolverStats> m_styleResolverStatsTotals; |
293 unsigned m_styleResolverStatsSequence; | 293 unsigned m_styleResolverStatsSequence; |
294 | 294 |
295 // Use only for Internals::updateStyleAndReturnAffectedElementCount. | 295 // Use only for Internals::updateStyleAndReturnAffectedElementCount. |
296 unsigned m_accessCount; | 296 unsigned m_accessCount; |
297 }; | 297 }; |
298 | 298 |
299 } // namespace blink | 299 } // namespace blink |
300 | 300 |
301 #endif // StyleResolver_h | 301 #endif // StyleResolver_h |
OLD | NEW |