source: trunk/Source/WebCore/css/StyleResolver.h @ 119949

Revision 119949, 21.8 KB checked in by hayato@chromium.org, 2 years ago (diff)

An inheritance of '-webkit-user-modify' does not stop at shadow boundary.
https://bugs.webkit.org/show_bug.cgi?id=88514

Reviewed by Ryosuke Niwa.

Source/WebCore:

In StyleResolver::styleForElement(), we reset '-webkit-user-modify'
CSS property after inheriting a parent style, but that is not
enough. We also have to reset '-webkit-user-modify' when we use a
cached result in applying matched properties.

Test: fast/dom/shadow/user-modify-inheritance.html

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::applyMatchedProperties):
(WebCore::StyleResolver::styleForElement):

  • css/StyleResolver.h:

(StyleResolver):

  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::inheritFrom):

  • rendering/style/RenderStyle.h:

LayoutTests:

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