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

Unified Diff: Source/core/dom/StyleSheetCollections.cpp

Issue 23890025: WIP (Introduce WTF::NonNullPtr<T>.) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/StyleSheetCollections.h ('k') | Source/core/dom/TreeScope.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/StyleSheetCollections.cpp
diff --git a/Source/core/dom/StyleSheetCollections.cpp b/Source/core/dom/StyleSheetCollections.cpp
index 665c2402d636c54fe1cd7114a53b97b7512b7406..129f727e82dbb18f40650a322a522a5829e7cb3a 100644
--- a/Source/core/dom/StyleSheetCollections.cpp
+++ b/Source/core/dom/StyleSheetCollections.cpp
@@ -97,7 +97,7 @@ void StyleSheetCollections::insertTreeScopeInDocumentOrder(TreeScopeSet& treeSco
do {
--it;
TreeScope* n = *it;
- unsigned short position = n->comparePosition(*treeScope);
+ unsigned short position = n->comparePosition(treeScope);
if (position & Node::DOCUMENT_POSITION_FOLLOWING) {
treeScopes.insertBefore(followingTreeScope, treeScope);
return;
@@ -108,23 +108,23 @@ void StyleSheetCollections::insertTreeScopeInDocumentOrder(TreeScopeSet& treeSco
treeScopes.insertBefore(followingTreeScope, treeScope);
}
-StyleSheetCollection* StyleSheetCollections::ensureStyleSheetCollectionFor(TreeScope& treeScope)
+StyleSheetCollection* StyleSheetCollections::ensureStyleSheetCollectionFor(NonNullPtr<TreeScope> treeScope)
{
- if (&treeScope == &m_document)
+ if (treeScope == &m_document)
return &m_documentStyleSheetCollection;
- HashMap<TreeScope*, OwnPtr<StyleSheetCollection> >::AddResult result = m_styleSheetCollectionMap.add(&treeScope, nullptr);
+ HashMap<TreeScope*, OwnPtr<StyleSheetCollection> >::AddResult result = m_styleSheetCollectionMap.add(treeScope.get(), nullptr);
if (result.isNewEntry)
- result.iterator->value = adoptPtr(new ShadowTreeStyleSheetCollection(toShadowRoot(treeScope)));
+ result.iterator->value = adoptPtr(new ShadowTreeStyleSheetCollection(*toShadowRoot(treeScope.get())));
return result.iterator->value.get();
}
-StyleSheetCollection* StyleSheetCollections::styleSheetCollectionFor(TreeScope& treeScope)
+StyleSheetCollection* StyleSheetCollections::styleSheetCollectionFor(NonNullPtr<TreeScope> treeScope)
{
- if (&treeScope == &m_document)
+ if (treeScope == &m_document)
return &m_documentStyleSheetCollection;
- HashMap<TreeScope*, OwnPtr<StyleSheetCollection> >::iterator it = m_styleSheetCollectionMap.find(&treeScope);
+ HashMap<TreeScope*, OwnPtr<StyleSheetCollection> >::iterator it = m_styleSheetCollectionMap.find(treeScope.get());
if (it == m_styleSheetCollectionMap.end())
return 0;
return it->value.get();
@@ -279,11 +279,11 @@ void StyleSheetCollections::removePendingSheet(Node* styleSheetCandidateNode, Re
m_pendingStylesheets--;
- TreeScope* treeScope = isHTMLStyleElement(styleSheetCandidateNode) ? &styleSheetCandidateNode->treeScope() : &m_document;
+ NonNullPtr<TreeScope> treeScope = isHTMLStyleElement(styleSheetCandidateNode) ? styleSheetCandidateNode->treeScope() : &m_document;
if (treeScope == &m_document)
m_needsDocumentStyleSheetsUpdate = true;
else
- m_dirtyTreeScopes.add(treeScope);
+ m_dirtyTreeScopes.add(treeScope.get());
if (m_pendingStylesheets)
return;
@@ -303,37 +303,37 @@ void StyleSheetCollections::addStyleSheetCandidateNode(Node* node, bool createdB
if (!node->inDocument())
return;
- TreeScope& treeScope = isHTMLStyleElement(node) ? node->treeScope() : m_document;
- ASSERT(isHTMLStyleElement(node) || &treeScope == &m_document);
+ NonNullPtr<TreeScope> treeScope = isHTMLStyleElement(node) ? node->treeScope() : &m_document;
+ ASSERT(isHTMLStyleElement(node) || treeScope == &m_document);
StyleSheetCollection* collection = ensureStyleSheetCollectionFor(treeScope);
ASSERT(collection);
collection->addStyleSheetCandidateNode(node, createdByParser);
- if (&treeScope == &m_document) {
+ if (treeScope == &m_document) {
m_needsDocumentStyleSheetsUpdate = true;
return;
}
- insertTreeScopeInDocumentOrder(m_activeTreeScopes, &treeScope);
- m_dirtyTreeScopes.add(&treeScope);
+ insertTreeScopeInDocumentOrder(m_activeTreeScopes, treeScope.get());
+ m_dirtyTreeScopes.add(treeScope.get());
}
void StyleSheetCollections::removeStyleSheetCandidateNode(Node* node, ContainerNode* scopingNode)
{
- TreeScope& treeScope = scopingNode ? scopingNode->treeScope() : m_document;
- ASSERT(isHTMLStyleElement(node) || &treeScope == &m_document);
+ NonNullPtr<TreeScope> treeScope = scopingNode ? scopingNode->treeScope() : &m_document;
+ ASSERT(isHTMLStyleElement(node) || treeScope == &m_document);
StyleSheetCollection* collection = styleSheetCollectionFor(treeScope);
ASSERT(collection);
collection->removeStyleSheetCandidateNode(node, scopingNode);
- if (&treeScope == &m_document) {
+ if (treeScope == &m_document) {
m_needsDocumentStyleSheetsUpdate = true;
return;
}
- m_dirtyTreeScopes.add(&treeScope);
- m_activeTreeScopes.remove(&treeScope);
+ m_dirtyTreeScopes.add(treeScope.get());
+ m_activeTreeScopes.remove(treeScope.get());
}
void StyleSheetCollections::modifiedStyleSheetCandidateNode(Node* node)
@@ -341,13 +341,13 @@ void StyleSheetCollections::modifiedStyleSheetCandidateNode(Node* node)
if (!node->inDocument())
return;
- TreeScope& treeScope = isHTMLStyleElement(node) ? node->treeScope() : m_document;
- ASSERT(isHTMLStyleElement(node) || &treeScope == &m_document);
- if (&treeScope == &m_document) {
+ NonNullPtr<TreeScope> treeScope = isHTMLStyleElement(node) ? node->treeScope() : &m_document;
+ ASSERT(isHTMLStyleElement(node) || treeScope == &m_document);
+ if (treeScope == &m_document) {
m_needsDocumentStyleSheetsUpdate = true;
return;
}
- m_dirtyTreeScopes.add(&treeScope);
+ m_dirtyTreeScopes.add(treeScope.get());
}
bool StyleSheetCollections::shouldUpdateShadowTreeStyleSheetCollection(StyleResolverUpdateMode updateMode)
@@ -377,13 +377,13 @@ bool StyleSheetCollections::updateActiveStyleSheets(StyleResolverUpdateMode upda
HashSet<TreeScope*> treeScopesRemoved;
for (TreeScopeSet::iterator it = treeScopes.begin(); it != treeScopes.end(); ++it) {
- TreeScope* treeScope = *it;
+ NonNullPtr<TreeScope> treeScope(*it);
ASSERT(treeScope != &m_document);
- ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeStyleSheetCollection*>(styleSheetCollectionFor(*treeScope));
+ ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeStyleSheetCollection*>(styleSheetCollectionFor(treeScope));
ASSERT(collection);
collection->updateActiveStyleSheets(this, updateMode);
if (!collection->hasStyleSheetCandidateNodes())
- treeScopesRemoved.add(treeScope);
+ treeScopesRemoved.add(treeScope.get());
}
if (!treeScopesRemoved.isEmpty())
for (HashSet<TreeScope*>::iterator it = treeScopesRemoved.begin(); it != treeScopesRemoved.end(); ++it)
« no previous file with comments | « Source/core/dom/StyleSheetCollections.h ('k') | Source/core/dom/TreeScope.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698