Don't use StyleSheetList internally.
https://bugs.webkit.org/show_bug.cgi?id=97504
Reviewed by Ryosuke Niwa.
StyleSheetList is a DOM type and should not be used internally. Use plain Vector instead and construct StyleSheetList on DOM access only.
* css/StyleResolver.cpp:
(WebCore::StyleResolver::StyleResolver):
(WebCore::StyleResolver::addStylesheetsFromSeamlessParents):
(WebCore::StyleResolver::collectMatchingRulesForList):
* css/StyleSheetList.cpp:
(WebCore::StyleSheetList::StyleSheetList):
(WebCore::StyleSheetList::styleSheets):
(WebCore):
(WebCore::StyleSheetList::detachFromDocument):
Use live stylesheet vector of the documents stylesheet collection as long as we are attached to a document.
When detached copy the stylesheet vector to a member field and use that instead.
(WebCore::StyleSheetList::length):
(WebCore::StyleSheetList::item):
(WebCore::StyleSheetList::getNamedItem):
* css/StyleSheetList.h:
Removed StyleSheetVector typedef as Vector<RefPtr<StyleSheet> > is less opaque and not much longer.
(WebCore):
(WebCore::StyleSheetList::create):
(StyleSheetList):
(WebCore::StyleSheetList::document):
* dom/Document.cpp:
(WebCore::Document::~Document):
(WebCore::Document::setCompatibilityMode):
(WebCore::Document::styleSheets):
* dom/Document.h:
(Document):
* dom/DocumentStyleSheetCollection.cpp:
(WebCore::DocumentStyleSheetCollection::DocumentStyleSheetCollection):
(WebCore::DocumentStyleSheetCollection::~DocumentStyleSheetCollection):
(WebCore::DocumentStyleSheetCollection::analyzeStyleSheetChange):
(WebCore::DocumentStyleSheetCollection::updateActiveStyleSheets):
* dom/DocumentStyleSheetCollection.h:
(WebCore::DocumentStyleSheetCollec
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@129452 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp
index dc8df42..2d35776 100644
--- a/Source/WebCore/dom/Document.cpp
+++ b/Source/WebCore/dom/Document.cpp
@@ -630,6 +630,9 @@
m_decoder = 0;
+ if (m_styleSheetList)
+ m_styleSheetList->detachFromDocument();
+
m_styleSheetCollection.clear();
if (m_namedFlows)
@@ -778,7 +781,7 @@
{
if (m_compatibilityModeLocked || mode == m_compatibilityMode)
return;
- ASSERT(!m_styleSheetCollection->authorStyleSheets()->length());
+ ASSERT(m_styleSheetCollection->authorStyleSheets().isEmpty());
bool wasInQuirksMode = inQuirksMode();
m_compatibilityMode = mode;
selectorQueryCache()->invalidate();
@@ -3193,7 +3196,9 @@
StyleSheetList* Document::styleSheets()
{
- return m_styleSheetCollection->authorStyleSheets();
+ if (!m_styleSheetList)
+ m_styleSheetList = StyleSheetList::create(this);
+ return m_styleSheetList.get();
}
String Document::preferredStylesheetSet() const