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

Unified Diff: sky/engine/core/css/StyleSheetContents.cpp

Issue 791633010: StyleSheetContents doesn't need a set of clients. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/engine/core/css/StyleSheetContents.h ('k') | sky/engine/core/css/resolver/StyleResolver.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/css/StyleSheetContents.cpp
diff --git a/sky/engine/core/css/StyleSheetContents.cpp b/sky/engine/core/css/StyleSheetContents.cpp
index 6b89ae86b0055c5c3fc9a8b635191419998d1b76..fa1a37acf7da1568b9afc5ba490a0208968210e1 100644
--- a/sky/engine/core/css/StyleSheetContents.cpp
+++ b/sky/engine/core/css/StyleSheetContents.cpp
@@ -35,8 +35,9 @@
namespace blink {
-StyleSheetContents::StyleSheetContents(const CSSParserContext& context)
+StyleSheetContents::StyleSheetContents(Document* document, const CSSParserContext& context)
: m_parserContext(context)
+ , m_document(document)
{
}
@@ -45,6 +46,9 @@ StyleSheetContents::~StyleSheetContents()
// TODO(esprehn): Why is this here? The rules will be cleared immediately
// after this destructor runs anyway.
m_childRules.clear();
+
+ if (m_document && m_document->isActive())
+ m_document->styleEngine()->removeSheet(this);
}
void StyleSheetContents::parserAppendRule(PassRefPtr<StyleRuleBase> rule)
@@ -60,25 +64,6 @@ bool StyleSheetContents::parseString(const String& sheetText)
return true;
}
-void StyleSheetContents::registerClient(CSSStyleSheet* sheet)
-{
- ASSERT(!m_clients.contains(sheet));
-
- // InspectorCSSAgent::buildObjectForRule creates CSSStyleSheet without any owner node.
- if (!sheet->ownerDocument())
- return;
- m_clients.add(sheet);
-}
-
-void StyleSheetContents::unregisterClient(CSSStyleSheet* sheet)
-{
- m_clients.remove(sheet);
-
- if (!sheet->ownerDocument() || !m_clients.isEmpty())
- return;
- sheet->ownerDocument()->styleEngine()->removeSheet(this);
-}
-
void StyleSheetContents::shrinkToFit()
{
m_childRules.shrinkToFit();
@@ -93,21 +78,4 @@ RuleSet& StyleSheetContents::ensureRuleSet(AddRuleFlags addRuleFlags)
return *m_ruleSet.get();
}
-void StyleSheetContents::clearRuleSet()
-{
- // Don't want to clear the StyleResolver if the RuleSet hasn't been created
- // since we only clear the StyleResolver so that it's members are properly
- // updated in ScopedStyleResolver::addRulesFromSheet.
- if (!m_ruleSet)
- return;
-
- // Clearing the ruleSet means we need to recreate the styleResolver data structures.
- // See the StyleResolver calls in ScopedStyleResolver::addRulesFromSheet.
- for (RawPtr<CSSStyleSheet> client : m_clients) {
- if (Document* document = client->ownerDocument())
- document->styleEngine()->clearResolver();
- }
- m_ruleSet.clear();
-}
-
}
« no previous file with comments | « sky/engine/core/css/StyleSheetContents.h ('k') | sky/engine/core/css/resolver/StyleResolver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698