Remove single client special cases for StyleSheetContents.
We can also remove all single document checks since in Sky we
don't have the cross document cache so all sheets are always
connected to a single document.
I also did some minor code simplification and removed an
OILPAN ifdef.
R=ojan@chromium.org
Review URL: https://codereview.chromium.org/799143002
diff --git a/sky/engine/core/css/StyleSheetContents.cpp b/sky/engine/core/css/StyleSheetContents.cpp
index 990a227..559cd21 100644
--- a/sky/engine/core/css/StyleSheetContents.cpp
+++ b/sky/engine/core/css/StyleSheetContents.cpp
@@ -38,26 +38,21 @@
StyleSheetContents::StyleSheetContents(const CSSParserContext& context)
: m_usesRemUnits(false)
, m_hasMediaQueries(false)
- , m_hasSingleOwnerDocument(true)
, m_parserContext(context)
{
}
StyleSheetContents::~StyleSheetContents()
{
-#if !ENABLE(OILPAN)
- clearRules();
-#endif
+ // TODO(esprehn): Why is this here? The rules will be cleared immediately
+ // after this destructor runs anyway.
+ m_childRules.clear();
}
void StyleSheetContents::parserAppendRule(PassRefPtr<StyleRuleBase> rule)
{
- // Add warning message to inspector if dpi/dpcm values are used for screen media.
- if (rule->isMediaRule()) {
+ if (rule->isMediaRule())
setHasMediaQueries();
- reportMediaQueryWarningIfNeeded(singleOwnerDocument(), toStyleRuleMedia(rule.get())->mediaQueries());
- }
-
m_childRules.append(rule);
}
@@ -77,11 +72,6 @@
return m_childRules.size();
}
-void StyleSheetContents::clearRules()
-{
- m_childRules.clear();
-}
-
bool StyleSheetContents::parseString(const String& sheetText)
{
CSSParserContext context(parserContext(), UseCounter::getFrom(this));
@@ -90,35 +80,6 @@
return true;
}
-bool StyleSheetContents::hasSingleOwnerNode() const
-{
- return hasOneClient();
-}
-
-Node* StyleSheetContents::singleOwnerNode() const
-{
- if (!hasOneClient())
- return 0;
- if (m_loadingClients.size())
- return (*m_loadingClients.begin())->ownerNode();
- return (*m_completedClients.begin())->ownerNode();
-}
-
-Document* StyleSheetContents::singleOwnerDocument() const
-{
- return clientSingleOwnerDocument();
-}
-
-Document* StyleSheetContents::clientSingleOwnerDocument() const
-{
- if (!m_hasSingleOwnerDocument || clientSize() <= 0)
- return 0;
-
- if (m_loadingClients.size())
- return (*m_loadingClients.begin())->ownerDocument();
- return (*m_completedClients.begin())->ownerDocument();
-}
-
void StyleSheetContents::registerClient(CSSStyleSheet* sheet)
{
ASSERT(!m_loadingClients.contains(sheet) && !m_completedClients.contains(sheet));
@@ -126,11 +87,6 @@
// InspectorCSSAgent::buildObjectForRule creates CSSStyleSheet without any owner node.
if (!sheet->ownerDocument())
return;
-
- if (Document* document = clientSingleOwnerDocument()) {
- if (sheet->ownerDocument() != document)
- m_hasSingleOwnerDocument = false;
- }
m_loadingClients.add(sheet);
}
@@ -141,16 +97,7 @@
if (!sheet->ownerDocument() || !m_loadingClients.isEmpty() || !m_completedClients.isEmpty())
return;
-
- if (m_hasSingleOwnerDocument)
- removeSheetFromCache(sheet->ownerDocument());
- m_hasSingleOwnerDocument = true;
-}
-
-void StyleSheetContents::removeSheetFromCache(Document* document)
-{
- ASSERT(document);
- document->styleEngine()->removeSheet(this);
+ sheet->ownerDocument()->styleEngine()->removeSheet(this);
}
void StyleSheetContents::shrinkToFit()
diff --git a/sky/engine/core/css/StyleSheetContents.h b/sky/engine/core/css/StyleSheetContents.h
index 63748df..2fff934 100644
--- a/sky/engine/core/css/StyleSheetContents.h
+++ b/sky/engine/core/css/StyleSheetContents.h
@@ -55,15 +55,9 @@
bool parseString(const String&);
bool parseStringAtPosition(const String&, const TextPosition&, bool);
- bool hasSingleOwnerNode() const;
- Node* singleOwnerNode() const;
- Document* singleOwnerDocument() const;
-
void parserAppendRule(PassRefPtr<StyleRuleBase>);
void parserSetUsesRemUnits(bool b) { m_usesRemUnits = b; }
- void clearRules();
-
// Rules other than @charset and @import.
const Vector<RefPtr<StyleRuleBase> >& childRules() const { return m_childRules; }
@@ -74,10 +68,6 @@
void registerClient(CSSStyleSheet*);
void unregisterClient(CSSStyleSheet*);
- size_t clientSize() const { return m_loadingClients.size() + m_completedClients.size(); }
- bool hasOneClient() const { return clientSize() == 1; }
-
- void removeSheetFromCache(Document*);
void setHasMediaQueries();
bool hasMediaQueries() const { return m_hasMediaQueries; }
@@ -92,11 +82,8 @@
void notifyRemoveFontFaceRule(const StyleRuleFontFace*);
- Document* clientSingleOwnerDocument() const;
-
bool m_usesRemUnits : 1;
bool m_hasMediaQueries : 1;
- bool m_hasSingleOwnerDocument : 1;
OwnPtr<RuleSet> m_ruleSet;
Vector<RefPtr<StyleRuleBase> > m_childRules;
diff --git a/sky/engine/core/css/resolver/ScopedStyleResolver.cpp b/sky/engine/core/css/resolver/ScopedStyleResolver.cpp
index 92d891d..c14ea18 100644
--- a/sky/engine/core/css/resolver/ScopedStyleResolver.cpp
+++ b/sky/engine/core/css/resolver/ScopedStyleResolver.cpp
@@ -55,7 +55,7 @@
{
for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) {
StyleSheetContents* contents = m_authorStyleSheets[i]->contents();
- if (contents->hasOneClient() || visitedSharedStyleSheetContents.add(contents).isNewEntry)
+ if (visitedSharedStyleSheetContents.add(contents).isNewEntry)
features.add(contents->ruleSet().features());
}
}
diff --git a/sky/engine/core/dom/StyleEngine.cpp b/sky/engine/core/dom/StyleEngine.cpp
index a2d551b..0f4d91a 100644
--- a/sky/engine/core/dom/StyleEngine.cpp
+++ b/sky/engine/core/dom/StyleEngine.cpp
@@ -390,7 +390,6 @@
} else {
StyleSheetContents* contents = result.storedValue->value;
ASSERT(contents);
- ASSERT(contents->singleOwnerDocument() == e->document());
styleSheet = CSSStyleSheet::create(contents, e);
}
diff --git a/sky/engine/core/frame/UseCounter.cpp b/sky/engine/core/frame/UseCounter.cpp
index a934e03..1c5d24d 100644
--- a/sky/engine/core/frame/UseCounter.cpp
+++ b/sky/engine/core/frame/UseCounter.cpp
@@ -254,10 +254,7 @@
UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents)
{
- // FIXME: We may want to handle stylesheets that have multiple owners
- // http://crbug.com/242125
- if (sheetContents && sheetContents->hasSingleOwnerNode())
- return getFrom(sheetContents->singleOwnerDocument());
+ // TODO(esprehn): Support this in Sky.
return 0;
}