| 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 * 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 Loading... |
| 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 |
| OLD | NEW |