Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: Source/core/css/resolver/ScopedStyleTree.h

Issue 102953007: Selectors in styles in shadowRoots should match in all of the host's shadowRoots. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 * Copyright (C) 2012 Google Inc. All rights reserved. 4 * Copyright (C) 2012 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 ScopedStyleResolver* scopedStyleResolverFor(const ContainerNode& scopingNode ); 49 ScopedStyleResolver* scopedStyleResolverFor(const ContainerNode& scopingNode );
50 ScopedStyleResolver* addScopedStyleResolver(ContainerNode& scopingNode, bool & isNewEntry); 50 ScopedStyleResolver* addScopedStyleResolver(ContainerNode& scopingNode, bool & isNewEntry);
51 void clear(); 51 void clear();
52 52
53 // for fast-path. 53 // for fast-path.
54 bool hasOnlyScopedResolverForDocument() const { return m_scopedResolverForDo cument && m_authorStyles.size() == 1; } 54 bool hasOnlyScopedResolverForDocument() const { return m_scopedResolverForDo cument && m_authorStyles.size() == 1; }
55 ScopedStyleResolver* scopedStyleResolverForDocument() const { return m_scope dResolverForDocument; } 55 ScopedStyleResolver* scopedStyleResolverForDocument() const { return m_scope dResolverForDocument; }
56 56
57 void resolveScopedStyles(const Element*, Vector<ScopedStyleResolver*, 8>&); 57 void resolveScopedStyles(const Element*, Vector<ScopedStyleResolver*, 8>&);
58 void collectScopedResolversForHostedShadowTrees(const Element*, Vector<Scope dStyleResolver*, 8>&);
59 void resolveScopedKeyframesRules(const Element*, Vector<ScopedStyleResolver* , 8>&); 58 void resolveScopedKeyframesRules(const Element*, Vector<ScopedStyleResolver* , 8>&);
60 ScopedStyleResolver* scopedResolverFor(const Element*); 59 ScopedStyleResolver* scopedResolverFor(const ContainerNode*);
61 60
62 void remove(const ContainerNode* scopingNode); 61 void remove(const ContainerNode* scopingNode);
63 62
64 void pushStyleCache(const ContainerNode& scopingNode, const ContainerNode* p arent); 63 void pushStyleCache(const ContainerNode& scopingNode, const ContainerNode* p arent);
65 void popStyleCache(const ContainerNode& scopingNode); 64 void popStyleCache(const ContainerNode& scopingNode);
66 65
67 void collectFeaturesTo(RuleFeatureSet& features); 66 void collectFeaturesTo(RuleFeatureSet& features);
68 void setBuildInDocumentOrder(bool enabled) { m_buildInDocumentOrder = enable d; } 67 void setBuildInDocumentOrder(bool enabled) { m_buildInDocumentOrder = enable d; }
69 bool buildInDocumentOrder() const { return m_buildInDocumentOrder; } 68 bool buildInDocumentOrder() const { return m_buildInDocumentOrder; }
70 69
71 private: 70 private:
71 ContainerNode* traverseParent(const ContainerNode*) const;
72 void setupScopedStylesTree(ScopedStyleResolver* target); 72 void setupScopedStylesTree(ScopedStyleResolver* target);
73 73
74 bool cacheIsValid(const ContainerNode* parent) const { return parent && pare nt == m_cache.nodeForScopedStyles; } 74 bool cacheIsValid(const ContainerNode* parent) const { return parent && pare nt == m_cache.nodeForScopedStyles; }
75 void resolveStyleCache(const ContainerNode* scopingNode); 75 void resolveStyleCache(const ContainerNode* scopingNode);
76 ScopedStyleResolver* enclosingScopedStyleResolverFor(const ContainerNode* sc opingNode); 76 ScopedStyleResolver* enclosingScopedStyleResolverFor(const ContainerNode* sc opingNode);
77 77
78 void reparentNodes(const ScopedStyleResolver* oldParent, ScopedStyleResolver * newParent); 78 void reparentNodes(const ScopedStyleResolver* oldParent, ScopedStyleResolver * newParent);
79 79
80 private: 80 private:
81 HashMap<const ContainerNode*, OwnPtr<ScopedStyleResolver> > m_authorStyles; 81 HashMap<const ContainerNode*, OwnPtr<ScopedStyleResolver> > m_authorStyles;
82 ScopedStyleResolver* m_scopedResolverForDocument; 82 ScopedStyleResolver* m_scopedResolverForDocument;
83 bool m_buildInDocumentOrder; 83 bool m_buildInDocumentOrder;
84 84
85 struct ScopedStyleCache { 85 struct ScopedStyleCache {
86 ScopedStyleResolver* scopedResolver; 86 ScopedStyleResolver* scopedResolver;
87 const ContainerNode* nodeForScopedStyles; 87 const ContainerNode* nodeForScopedStyles;
88 88
89 void clear() 89 void clear()
90 { 90 {
91 scopedResolver = 0; 91 scopedResolver = 0;
92 nodeForScopedStyles = 0; 92 nodeForScopedStyles = 0;
93 } 93 }
94 }; 94 };
95 ScopedStyleCache m_cache; 95 ScopedStyleCache m_cache;
96 }; 96 };
97 97
98 inline ScopedStyleResolver* ScopedStyleTree::scopedResolverFor(const Element* el ement) 98 inline ScopedStyleResolver* ScopedStyleTree::scopedResolverFor(const ContainerNo de* node)
99 { 99 {
100 if (!cacheIsValid(element)) 100 if (!cacheIsValid(node))
101 resolveStyleCache(element); 101 resolveStyleCache(node);
102 102
103 return m_cache.scopedResolver; 103 return m_cache.scopedResolver;
104 } 104 }
105 105
106 } // namespace WebCore 106 } // namespace WebCore
107 107
108 #endif // ScopedStyleTree_h 108 #endif // ScopedStyleTree_h
OLDNEW
« no previous file with comments | « Source/core/css/resolver/ScopedStyleResolver.h ('k') | Source/core/css/resolver/ScopedStyleTree.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698