Merge "[CherryPick] [WEBGL] Rename WEBKIT_WEBGL_compressed_texture_s3tc to WEBGL_comp...
[framework/web/webkit-efl.git] / Source / WebCore / css / StyleResolver.h
1 /*
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.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB.  If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  *
20  */
21
22 #ifndef StyleResolver_h
23 #define StyleResolver_h
24
25 #include "CSSRule.h"
26 #include "CSSToStyleMap.h"
27 #include "CSSValueList.h"
28 #include "LinkHash.h"
29 #include "MediaQueryExp.h"
30 #include "RenderStyle.h"
31 #include "SelectorChecker.h"
32 #include <wtf/HashMap.h>
33 #include <wtf/HashSet.h>
34 #include <wtf/RefPtr.h>
35 #include <wtf/Vector.h>
36 #include <wtf/text/AtomicStringHash.h>
37 #include <wtf/text/StringHash.h>
38
39 namespace WebCore {
40
41 enum ESmartMinimumForFontSize { DoNotUseSmartMinimumForFontSize, UseSmartMinimumForFontFize };
42
43 class CSSFontSelector;
44 class CSSPageRule;
45 class CSSPrimitiveValue;
46 class CSSProperty;
47 class CSSRuleList;
48 class CSSFontFace;
49 class CSSFontFaceRule;
50 class CSSImageGeneratorValue;
51 class CSSImageSetValue;
52 class CSSImageValue;
53 class CSSSelector;
54 class CSSStyleRule;
55 class CSSStyleSheet;
56 class CSSValue;
57 class ContainerNode;
58 class CustomFilterOperation;
59 class CustomFilterParameter;
60 class Document;
61 class Element;
62 class Frame;
63 class FrameView;
64 class KURL;
65 class KeyframeList;
66 class KeyframeValue;
67 class MediaQueryEvaluator;
68 class MemoryObjectInfo;
69 class Node;
70 class RenderRegion;
71 class RuleData;
72 class RuleSet;
73 class Settings;
74 class StaticCSSRuleList;
75 class StyleBuilder;
76 class StyleImage;
77 class StyleKeyframe;
78 class StylePendingImage;
79 class StylePropertySet;
80 class StyleRule;
81 class StyleRuleKeyframes;
82 class StyleRulePage;
83 class StyleRuleRegion;
84 class StyleShader;
85 class StyleSheet;
86 class StyleSheetContents;
87 class StyleSheetList;
88 class StyledElement;
89 class WebKitCSSFilterValue;
90 class WebKitCSSShaderValue;
91 class WebKitCSSSVGDocumentValue;
92
93 #if ENABLE(CSS_SHADERS)
94 typedef Vector<RefPtr<CustomFilterParameter> > CustomFilterParameterList;
95 #endif
96
97 class MediaQueryResult {
98     WTF_MAKE_NONCOPYABLE(MediaQueryResult); WTF_MAKE_FAST_ALLOCATED;
99 public:
100     MediaQueryResult(const MediaQueryExp& expr, bool result)
101         : m_expression(expr)
102         , m_result(result)
103     {
104     }
105
106     MediaQueryExp m_expression;
107     bool m_result;
108 };
109
110 enum StyleSharingBehavior {
111     AllowStyleSharing,
112     DisallowStyleSharing,
113 };
114
115 // MatchOnlyUserAgentRules is used in media queries, where relative units
116 // are interpreted according to the document root element style, and styled only
117 // from the User Agent Stylesheet rules.
118
119 enum RuleMatchingBehavior {
120     MatchAllRules,
121     MatchAllRulesExcludingSMIL,
122     MatchOnlyUserAgentRules,
123 };
124
125 // This class selects a RenderStyle for a given element based on a collection of stylesheets.
126 class StyleResolver {
127     WTF_MAKE_NONCOPYABLE(StyleResolver); WTF_MAKE_FAST_ALLOCATED;
128 public:
129     StyleResolver(Document*, bool matchAuthorAndUserStyles);
130     ~StyleResolver();
131
132     // Using these during tree walk will allow style selector to optimize child and descendant selector lookups.
133     void pushParentElement(Element*);
134     void popParentElement(Element*);
135     void pushParentShadowRoot(const ShadowRoot*);
136     void popParentShadowRoot(const ShadowRoot*);
137
138     PassRefPtr<RenderStyle> styleForElement(Element*, RenderStyle* parentStyle = 0, StyleSharingBehavior = AllowStyleSharing,
139         RuleMatchingBehavior = MatchAllRules, RenderRegion* regionForStyling = 0);
140
141     void keyframeStylesForAnimation(Element*, const RenderStyle*, KeyframeList&);
142
143     PassRefPtr<RenderStyle> pseudoStyleForElement(PseudoId, Element*, RenderStyle* parentStyle = 0);
144
145     PassRefPtr<RenderStyle> styleForPage(int pageIndex);
146
147     static PassRefPtr<RenderStyle> styleForDocument(Document*, CSSFontSelector* = 0);
148
149     RenderStyle* style() const { return m_style.get(); }
150     RenderStyle* parentStyle() const { return m_parentStyle; }
151     RenderStyle* rootElementStyle() const { return m_rootElementStyle; }
152     Element* element() const { return m_element; }
153     Document* document() const { return m_checker.document(); }
154     const FontDescription& fontDescription() { return style()->fontDescription(); }
155     const FontDescription& parentFontDescription() { return parentStyle()->fontDescription(); }
156     void setFontDescription(const FontDescription& fontDescription) { m_fontDirty |= style()->setFontDescription(fontDescription); }
157     void setZoom(float f) { m_fontDirty |= style()->setZoom(f); }
158     void setEffectiveZoom(float f) { m_fontDirty |= style()->setEffectiveZoom(f); }
159     void setTextSizeAdjust(bool b) { m_fontDirty |= style()->setTextSizeAdjust(b); }
160     bool hasParentNode() const { return m_parentNode; }
161     
162     void appendAuthorStylesheets(unsigned firstNew, const Vector<RefPtr<StyleSheet> >&);
163     
164     // Find the ids or classes the selectors on a stylesheet are scoped to. The selectors only apply to elements in subtrees where the root element matches the scope.
165     static bool determineStylesheetSelectorScopes(StyleSheetContents*, HashSet<AtomicStringImpl*>& idScopes, HashSet<AtomicStringImpl*>& classScopes);
166
167 private:
168     void initForStyleResolve(Element*, RenderStyle* parentStyle = 0, PseudoId = NOPSEUDO);
169     void initElement(Element*);
170     void collectFeatures();
171     RenderStyle* locateSharedStyle();
172     bool matchesRuleSet(RuleSet*);
173     Node* locateCousinList(Element* parent, unsigned& visitedNodeCount) const;
174     StyledElement* findSiblingForStyleSharing(Node*, unsigned& count) const;
175     bool canShareStyleWithElement(StyledElement*) const;
176
177     PassRefPtr<RenderStyle> styleForKeyframe(const RenderStyle*, const StyleKeyframe*, KeyframeValue&);
178
179 #if ENABLE(STYLE_SCOPED)
180     void pushScope(const ContainerNode* scope, const ContainerNode* scopeParent);
181     void popScope(const ContainerNode* scope);
182 #else
183     void pushScope(const ContainerNode*, const ContainerNode*) { }
184     void popScope(const ContainerNode*) { }
185 #endif
186
187 public:
188     // These methods will give back the set of rules that matched for a given element (or a pseudo-element).
189     enum CSSRuleFilter {
190         UAAndUserCSSRules   = 1 << 1,
191         AuthorCSSRules      = 1 << 2,
192         EmptyCSSRules       = 1 << 3,
193         CrossOriginCSSRules = 1 << 4,
194         AllButEmptyCSSRules = UAAndUserCSSRules | AuthorCSSRules | CrossOriginCSSRules,
195         AllCSSRules         = AllButEmptyCSSRules | EmptyCSSRules,
196     };
197     PassRefPtr<CSSRuleList> styleRulesForElement(Element*, unsigned rulesToInclude = AllButEmptyCSSRules);
198     PassRefPtr<CSSRuleList> pseudoStyleRulesForElement(Element*, PseudoId, unsigned rulesToInclude = AllButEmptyCSSRules);
199
200     // Given a CSS keyword in the range (xx-small to -webkit-xxx-large), this function will return
201     // the correct font size scaled relative to the user's default (medium).
202     static float fontSizeForKeyword(Document*, int keyword, bool shouldUseFixedDefaultSize);
203
204     // Given a font size in pixel, this function will return legacy font size between 1 and 7.
205     static int legacyFontSize(Document*, int pixelFontSize, bool shouldUseFixedDefaultSize);
206
207 public:
208     void setStyle(PassRefPtr<RenderStyle> s) { m_style = s; } // Used by the document when setting up its root style.
209
210     void applyPropertyToStyle(CSSPropertyID, CSSValue*, RenderStyle*);
211
212     void applyPropertyToCurrentStyle(CSSPropertyID, CSSValue*);
213
214     void updateFont();
215     void initializeFontStyle(Settings*);
216
217     static float getComputedSizeFromSpecifiedSize(Document*, float zoomFactor, bool isAbsoluteSize, float specifiedSize, ESmartMinimumForFontSize = UseSmartMinimumForFontFize);
218
219     void setFontSize(FontDescription&, float size);
220
221 private:
222     static float getComputedSizeFromSpecifiedSize(Document*, RenderStyle*, bool isAbsoluteSize, float specifiedSize, bool useSVGZoomRules);
223
224 public:
225     bool useSVGZoomRules();
226
227     static bool colorFromPrimitiveValueIsDerivedFromElement(CSSPrimitiveValue*);
228     Color colorFromPrimitiveValue(CSSPrimitiveValue*, bool forVisitedLink = false) const;
229
230     bool hasSelectorForAttribute(const AtomicString&) const;
231
232     CSSFontSelector* fontSelector() const { return m_fontSelector.get(); }
233
234     void addViewportDependentMediaQueryResult(const MediaQueryExp*, bool result);
235
236     bool affectedByViewportChange() const;
237
238     void allVisitedStateChanged() { m_checker.allVisitedStateChanged(); }
239     void visitedStateChanged(LinkHash visitedHash) { m_checker.visitedStateChanged(visitedHash); }
240
241     void addKeyframeStyle(PassRefPtr<StyleRuleKeyframes>);
242
243     bool checkRegionStyle(Element* regionElement);
244
245     bool usesSiblingRules() const { return !m_features.siblingRules.isEmpty(); }
246     bool usesFirstLineRules() const { return m_features.usesFirstLineRules; }
247     bool usesBeforeAfterRules() const { return m_features.usesBeforeAfterRules; }
248     bool usesLinkRules() const { return m_features.usesLinkRules; }
249
250     static bool createTransformOperations(CSSValue* inValue, RenderStyle* inStyle, RenderStyle* rootStyle, TransformOperations& outOperations);
251     
252     void invalidateMatchedPropertiesCache();
253     
254     // WARNING. This will construct CSSOM wrappers for all style rules and cache then in a map for significant memory cost.
255     // It is here to support inspector. Don't use for any regular engine functions.
256     CSSStyleRule* ensureFullCSSOMWrapperForInspector(StyleRule*);
257
258 #if ENABLE(CSS_FILTERS)
259     bool createFilterOperations(CSSValue* inValue, RenderStyle* inStyle, RenderStyle* rootStyle, FilterOperations& outOperations);
260 #if ENABLE(CSS_SHADERS)
261     StyleShader* styleShader(CSSValue*);
262     StyleShader* cachedOrPendingStyleShaderFromValue(WebKitCSSShaderValue*);
263     bool parseCustomFilterParameterList(CSSValue*, CustomFilterParameterList&);
264     PassRefPtr<CustomFilterParameter> parseCustomFilterNumberParamter(const String& name, CSSValueList*);
265     PassRefPtr<CustomFilterOperation> createCustomFilterOperation(WebKitCSSFilterValue*);
266     void loadPendingShaders();
267 #endif
268 #if ENABLE(SVG)
269     void loadPendingSVGDocuments();
270 #endif
271 #endif // ENABLE(CSS_FILTERS)
272
273     void loadPendingResources();
274
275     struct RuleFeature {
276         RuleFeature(StyleRule* rule, CSSSelector* selector, bool hasDocumentSecurityOrigin)
277             : rule(rule)
278             , selector(selector)
279             , hasDocumentSecurityOrigin(hasDocumentSecurityOrigin) 
280         { 
281         }
282         StyleRule* rule;
283         CSSSelector* selector;
284         bool hasDocumentSecurityOrigin;
285     };
286     struct Features {
287         Features();
288         ~Features();
289         void add(const StyleResolver::Features&);
290         void clear();
291         void reportMemoryUsage(MemoryObjectInfo*) const;
292         HashSet<AtomicStringImpl*> idsInRules;
293         HashSet<AtomicStringImpl*> attrsInRules;
294         Vector<RuleFeature> siblingRules;
295         Vector<RuleFeature> uncommonAttributeRules;
296         bool usesFirstLineRules;
297         bool usesBeforeAfterRules;
298         bool usesLinkRules;
299     };
300
301 private:
302     // This function fixes up the default font size if it detects that the current generic font family has changed. -dwh
303     void checkForGenericFamilyChange(RenderStyle*, RenderStyle* parentStyle);
304     void checkForZoomChange(RenderStyle*, RenderStyle* parentStyle);
305     void checkForTextSizeAdjust();
306
307     void adjustRenderStyle(RenderStyle* styleToAdjust, RenderStyle* parentStyle, Element*);
308
309     void addMatchedRule(const RuleData* rule) { m_matchedRules.append(rule); }
310
311     struct MatchRanges {
312         MatchRanges() : firstUARule(-1), lastUARule(-1), firstAuthorRule(-1), lastAuthorRule(-1), firstUserRule(-1), lastUserRule(-1) { }
313         int firstUARule;
314         int lastUARule;
315         int firstAuthorRule;
316         int lastAuthorRule;
317         int firstUserRule;
318         int lastUserRule;
319     };
320
321     struct MatchedProperties {
322         MatchedProperties() : possiblyPaddedMember(0) { }
323         
324         RefPtr<StylePropertySet> properties;
325         union {
326             struct {
327                 unsigned linkMatchType : 2;
328                 unsigned isInRegionRule : 1;
329             };
330             // Used to make sure all memory is zero-initialized since we compute the hash over the bytes of this object.
331             void* possiblyPaddedMember;
332         };
333     };
334
335     struct MatchResult {
336         MatchResult() : isCacheable(true) { }
337         Vector<MatchedProperties, 64> matchedProperties;
338         Vector<StyleRule*, 64> matchedRules;
339         MatchRanges ranges;
340         bool isCacheable;
341     };
342
343     struct MatchOptions {
344         MatchOptions(bool includeEmptyRules, const ContainerNode* scope = 0) : scope(scope), includeEmptyRules(includeEmptyRules) { }
345         const ContainerNode* scope;
346         bool includeEmptyRules;
347     };
348
349     static void addMatchedProperties(MatchResult&, const StylePropertySet* properties, StyleRule* = 0, unsigned linkMatchType = SelectorChecker::MatchAll, bool inRegionRule = false);
350     void addElementStyleProperties(MatchResult&, const StylePropertySet*, bool isCacheable = true);
351
352     void matchAllRules(MatchResult&, bool includeSMILProperties);
353     void matchUARules(MatchResult&);
354     void matchUARules(MatchResult&, RuleSet*);
355     void matchAuthorRules(MatchResult&, bool includeEmptyRules);
356     void matchUserRules(MatchResult&, bool includeEmptyRules);
357     void matchScopedAuthorRules(MatchResult&, bool includeEmptyRules);
358     void collectMatchingRules(RuleSet*, int& firstRuleIndex, int& lastRuleIndex, const MatchOptions&);
359     void collectMatchingRulesForRegion(RuleSet*, int& firstRuleIndex, int& lastRuleIndex, const MatchOptions&);
360     void collectMatchingRulesForList(const Vector<RuleData>*, int& firstRuleIndex, int& lastRuleIndex, const MatchOptions&);
361     bool fastRejectSelector(const RuleData&) const;
362     void sortMatchedRules();
363     void sortAndTransferMatchedRules(MatchResult&);
364
365     bool checkSelector(const RuleData&, const ContainerNode* scope = 0);
366     bool checkRegionSelector(CSSSelector* regionSelector, Element* regionElement);
367     void applyMatchedProperties(const MatchResult&, const Element*);
368     enum StyleApplicationPass {
369 #if ENABLE(CSS_VARIABLES)
370         VariableDefinitions,
371 #endif
372         HighPriorityProperties,
373         LowPriorityProperties
374     };
375     template <StyleApplicationPass pass>
376     void applyMatchedProperties(const MatchResult&, bool important, int startIndex, int endIndex, bool inheritedOnly);
377     template <StyleApplicationPass pass>
378     void applyProperties(const StylePropertySet* properties, StyleRule*, bool isImportant, bool inheritedOnly, bool filterRegionProperties);
379 #if ENABLE(CSS_VARIABLES)
380     void resolveVariables(CSSPropertyID, CSSValue*, Vector<std::pair<CSSPropertyID, String> >& knownExpressions);
381 #endif
382     static bool isValidRegionStyleProperty(CSSPropertyID);
383
384     void matchPageRules(MatchResult&, RuleSet*, bool isLeftPage, bool isFirstPage, const String& pageName);
385     void matchPageRulesForList(Vector<StyleRulePage*>& matchedRules, const Vector<StyleRulePage*>&, bool isLeftPage, bool isFirstPage, const String& pageName);
386     Settings* documentSettings() { return m_checker.document()->settings(); }
387
388     bool isLeftPage(int pageIndex) const;
389     bool isRightPage(int pageIndex) const { return !isLeftPage(pageIndex); }
390     bool isFirstPage(int pageIndex) const;
391     String pageName(int pageIndex) const;
392
393     OwnPtr<RuleSet> m_authorStyle;
394     OwnPtr<RuleSet> m_userStyle;
395
396     Features m_features;
397     OwnPtr<RuleSet> m_siblingRuleSet;
398     OwnPtr<RuleSet> m_uncommonAttributeRuleSet;
399
400     bool m_hasUAAppearance;
401     BorderData m_borderData;
402     FillLayer m_backgroundData;
403     Color m_backgroundColor;
404
405     typedef HashMap<AtomicStringImpl*, RefPtr<StyleRuleKeyframes> > KeyframesRuleMap;
406     KeyframesRuleMap m_keyframesRuleMap;
407
408 public:
409     static RenderStyle* styleNotYetAvailable() { return s_styleNotYetAvailable; }
410
411     PassRefPtr<StyleImage> styleImage(CSSPropertyID, CSSValue*);
412     PassRefPtr<StyleImage> cachedOrPendingFromValue(CSSPropertyID, CSSImageValue*);
413     PassRefPtr<StyleImage> generatedOrPendingFromValue(CSSPropertyID, CSSImageGeneratorValue*);
414 #if ENABLE(CSS_IMAGE_SET)
415     PassRefPtr<StyleImage> setOrPendingFromValue(CSSPropertyID, CSSImageSetValue*);
416 #endif
417
418     bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularStyle; }
419     bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisitedLinkStyle; }
420
421     static Length convertToIntLength(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, double multiplier = 1);
422     static Length convertToFloatLength(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, double multiplier = 1);
423
424     CSSToStyleMap* styleMap() { return &m_styleMap; }
425
426     void reportMemoryUsage(MemoryObjectInfo*) const;
427     
428 private:
429     static RenderStyle* s_styleNotYetAvailable;
430
431     void addStylesheetsFromSeamlessParents();
432     void addAuthorRulesAndCollectUserRulesFromSheets(const Vector<RefPtr<CSSStyleSheet> >*, RuleSet& userStyle);
433
434     void cacheBorderAndBackground();
435
436 private:
437     bool canShareStyleWithControl(StyledElement*) const;
438
439     void applyProperty(CSSPropertyID, CSSValue*);
440
441 #if ENABLE(SVG)
442     void applySVGProperty(CSSPropertyID, CSSValue*);
443 #endif
444
445     PassRefPtr<StyleImage> loadPendingImage(StylePendingImage*);
446     void loadPendingImages();
447
448     static unsigned computeMatchedPropertiesHash(const MatchedProperties*, unsigned size);
449     struct MatchedPropertiesCacheItem {
450         Vector<MatchedProperties> matchedProperties;
451         MatchRanges ranges;
452         RefPtr<RenderStyle> renderStyle;
453         RefPtr<RenderStyle> parentRenderStyle;
454     };
455     const MatchedPropertiesCacheItem* findFromMatchedPropertiesCache(unsigned hash, const MatchResult&);
456     void addToMatchedPropertiesCache(const RenderStyle*, const RenderStyle* parentStyle, unsigned hash, const MatchResult&);
457
458     // Every N additions to the matched declaration cache trigger a sweep where entries holding
459     // the last reference to a style declaration are garbage collected.
460     void sweepMatchedPropertiesCache();
461
462     unsigned m_matchedPropertiesCacheAdditionsSinceLastSweep;
463
464     typedef HashMap<unsigned, MatchedPropertiesCacheItem> MatchedPropertiesCache;
465     MatchedPropertiesCache m_matchedPropertiesCache;
466
467     // A buffer used to hold the set of matched rules for an element, and a temporary buffer used for
468     // merge sorting.
469     Vector<const RuleData*, 32> m_matchedRules;
470
471     RefPtr<StaticCSSRuleList> m_ruleList;
472
473     HashSet<CSSPropertyID> m_pendingImageProperties;
474
475     OwnPtr<MediaQueryEvaluator> m_medium;
476     RefPtr<RenderStyle> m_rootDefaultStyle;
477
478     PseudoId m_dynamicPseudo;
479
480     SelectorChecker m_checker;
481
482     RefPtr<RenderStyle> m_style;
483     RenderStyle* m_parentStyle;
484     RenderStyle* m_rootElementStyle;
485     Element* m_element;
486     StyledElement* m_styledElement;
487     RenderRegion* m_regionForStyling;
488     EInsideLink m_elementLinkState;
489     ContainerNode* m_parentNode;
490     CSSValue* m_lineHeightValue;
491     bool m_fontDirty;
492     bool m_matchAuthorAndUserStyles;
493     bool m_sameOriginOnly;
494
495     RefPtr<CSSFontSelector> m_fontSelector;
496     Vector<OwnPtr<MediaQueryResult> > m_viewportDependentMediaQueryResults;
497
498     bool m_applyPropertyToRegularStyle;
499     bool m_applyPropertyToVisitedLinkStyle;
500     const StyleBuilder& m_styleBuilder;
501     
502     HashMap<StyleRule*, RefPtr<CSSStyleRule> > m_styleRuleToCSSOMWrapperMap;
503     HashSet<RefPtr<CSSStyleSheet> > m_styleSheetCSSOMWrapperSet;
504
505 #if ENABLE(CSS_SHADERS)
506     bool m_hasPendingShaders;
507 #endif
508
509 #if ENABLE(CSS_FILTERS) && ENABLE(SVG)
510     HashMap<FilterOperation*, WebKitCSSSVGDocumentValue*> m_pendingSVGDocuments;
511 #endif
512
513 #if ENABLE(STYLE_SCOPED)
514     const ContainerNode* determineScope(const CSSStyleSheet*);
515
516     typedef HashMap<const ContainerNode*, OwnPtr<RuleSet> > ScopedRuleSetMap;
517
518     RuleSet* ruleSetForScope(const ContainerNode*) const;
519
520     void setupScopeStack(const ContainerNode*);
521     bool scopeStackIsConsistent(const ContainerNode* parent) const { return parent && parent == m_scopeStackParent; }
522
523     ScopedRuleSetMap m_scopedAuthorStyles;
524     
525     struct ScopeStackFrame {
526         ScopeStackFrame() : m_scope(0), m_authorStyleBoundsIndex(0), m_ruleSet(0) { }
527         ScopeStackFrame(const ContainerNode* scope, int authorStyleBoundsIndex, RuleSet* ruleSet) : m_scope(scope), m_authorStyleBoundsIndex(authorStyleBoundsIndex), m_ruleSet(ruleSet) { }
528         const ContainerNode* m_scope;
529         int m_authorStyleBoundsIndex;
530         RuleSet* m_ruleSet;
531     };
532     // Vector (used as stack) that keeps track of scoping elements (i.e., elements with a <style scoped> child)
533     // encountered during tree iteration for style resolution.
534     Vector<ScopeStackFrame> m_scopeStack;
535     // Element last seen as parent element when updating m_scopingElementStack.
536     // This is used to decide whether m_scopingElementStack is consistent, separately from SelectorChecker::m_parentStack.
537     const ContainerNode* m_scopeStackParent;
538     int m_scopeStackParentBoundsIndex;
539 #endif
540
541     CSSToStyleMap m_styleMap;
542
543     friend class StyleBuilder;
544     friend bool operator==(const MatchedProperties&, const MatchedProperties&);
545     friend bool operator!=(const MatchedProperties&, const MatchedProperties&);
546     friend bool operator==(const MatchRanges&, const MatchRanges&);
547     friend bool operator!=(const MatchRanges&, const MatchRanges&);
548 };
549
550 } // namespace WebCore
551
552 #endif // StyleResolver_h