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

Side by Side Diff: sky/engine/core/dom/StyleEngine.cpp

Issue 807933003: Don't sort tree scopes in StyleEngine. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « sky/engine/core/dom/StyleEngine.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 m_scopedStyleResolvers.clear(); 78 m_scopedStyleResolvers.clear();
79 } 79 }
80 80
81 const Vector<RefPtr<CSSStyleSheet>>& StyleEngine::activeAuthorStyleSheetsFor(Tre eScope& treeScope) 81 const Vector<RefPtr<CSSStyleSheet>>& StyleEngine::activeAuthorStyleSheetsFor(Tre eScope& treeScope)
82 { 82 {
83 if (treeScope == m_document) 83 if (treeScope == m_document)
84 return documentStyleSheetCollection()->activeAuthorStyleSheets(); 84 return documentStyleSheetCollection()->activeAuthorStyleSheets();
85 return ensureStyleSheetCollectionFor(treeScope)->activeAuthorStyleSheets(); 85 return ensureStyleSheetCollectionFor(treeScope)->activeAuthorStyleSheets();
86 } 86 }
87 87
88 void StyleEngine::insertTreeScopeInDocumentOrder(TreeScopeSet& treeScopes, TreeS cope* treeScope)
89 {
90 if (treeScopes.isEmpty()) {
91 treeScopes.add(treeScope);
92 return;
93 }
94 if (treeScopes.contains(treeScope))
95 return;
96
97 TreeScopeSet::iterator begin = treeScopes.begin();
98 TreeScopeSet::iterator end = treeScopes.end();
99 TreeScopeSet::iterator it = end;
100 TreeScope* followingTreeScope = 0;
101 do {
102 --it;
103 TreeScope* n = *it;
104 unsigned short position = n->comparePosition(*treeScope);
105 if (position & Node::DOCUMENT_POSITION_FOLLOWING) {
106 treeScopes.insertBefore(followingTreeScope, treeScope);
107 return;
108 }
109 followingTreeScope = n;
110 } while (it != begin);
111
112 treeScopes.insertBefore(followingTreeScope, treeScope);
113 }
114
115 StyleSheetCollection* StyleEngine::ensureStyleSheetCollectionFor(TreeScope& tree Scope) 88 StyleSheetCollection* StyleEngine::ensureStyleSheetCollectionFor(TreeScope& tree Scope)
116 { 89 {
117 if (treeScope == m_document) 90 if (treeScope == m_document)
118 return documentStyleSheetCollection(); 91 return documentStyleSheetCollection();
119 92
120 StyleSheetCollectionMap::AddResult result = m_styleSheetCollectionMap.add(&t reeScope, nullptr); 93 StyleSheetCollectionMap::AddResult result = m_styleSheetCollectionMap.add(&t reeScope, nullptr);
121 if (result.isNewEntry) 94 if (result.isNewEntry)
122 result.storedValue->value = StyleSheetCollection::create(treeScope); 95 result.storedValue->value = StyleSheetCollection::create(treeScope);
123 return result.storedValue->value.get(); 96 return result.storedValue->value.get();
124 } 97 }
(...skipping 30 matching lines...) Expand all
155 return; 128 return;
156 129
157 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_do cument; 130 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_do cument;
158 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); 131 ASSERT(isHTMLStyleElement(node) || treeScope == m_document);
159 StyleSheetCollection* collection = ensureStyleSheetCollectionFor(treeScope); 132 StyleSheetCollection* collection = ensureStyleSheetCollectionFor(treeScope);
160 ASSERT(collection); 133 ASSERT(collection);
161 collection->addStyleSheetCandidateNode(node, createdByParser); 134 collection->addStyleSheetCandidateNode(node, createdByParser);
162 135
163 markTreeScopeDirty(treeScope); 136 markTreeScopeDirty(treeScope);
164 if (treeScope != m_document) 137 if (treeScope != m_document)
165 insertTreeScopeInDocumentOrder(m_activeTreeScopes, &treeScope); 138 m_activeTreeScopes.add(&treeScope);
166 } 139 }
167 140
168 void StyleEngine::removeStyleSheetCandidateNode(Node* node, ContainerNode* scopi ngNode, TreeScope& treeScope) 141 void StyleEngine::removeStyleSheetCandidateNode(Node* node, ContainerNode* scopi ngNode, TreeScope& treeScope)
169 { 142 {
170 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); 143 ASSERT(isHTMLStyleElement(node) || treeScope == m_document);
171 144
172 StyleSheetCollection* collection = styleSheetCollectionFor(treeScope); 145 StyleSheetCollection* collection = styleSheetCollectionFor(treeScope);
173 ASSERT(collection); 146 ASSERT(collection);
174 collection->removeStyleSheetCandidateNode(node, scopingNode); 147 collection->removeStyleSheetCandidateNode(node, scopingNode);
175 148
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 } 325 }
353 326
354 void StyleEngine::fontsNeedUpdate(CSSFontSelector*) 327 void StyleEngine::fontsNeedUpdate(CSSFontSelector*)
355 { 328 {
356 if (m_resolver) 329 if (m_resolver)
357 m_resolver->invalidateMatchedPropertiesCache(); 330 m_resolver->invalidateMatchedPropertiesCache();
358 m_document->setNeedsStyleRecalc(SubtreeStyleChange); 331 m_document->setNeedsStyleRecalc(SubtreeStyleChange);
359 } 332 }
360 333
361 } 334 }
OLDNEW
« no previous file with comments | « sky/engine/core/dom/StyleEngine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698