Split author style code out from DocumentStyleSheetCollection
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Sep 2015 15:04:16 +0000 (15:04 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Sep 2015 15:04:16 +0000 (15:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=149446

Reviewed by Andreas Kling.

Shadow trees may have their own author style. Factor the related code out so we can use
it outside the document context.

DocumentStyleSheetCollection is replaced by two classes:

AuthorStyleSheets - author stylesheets and mutation optimization code
ExtensionStyleSheets - user stylesheets, injected author stylesheets, content extension stylesheets

* WebCore.xcodeproj/project.pbxproj:
* contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::processContentExtensionRulesForLoad):
* css/CSSStyleSheet.cpp:
(WebCore::CSSStyleSheet::didMutateRules):
* css/DocumentRuleSets.cpp:
(WebCore::DocumentRuleSets::~DocumentRuleSets):
(WebCore::DocumentRuleSets::initUserStyle):
* css/DocumentRuleSets.h:
(WebCore::DocumentRuleSets::sibling):
(WebCore::DocumentRuleSets::uncommonAttribute):
* css/InspectorCSSOMWrappers.cpp:
(WebCore::InspectorCSSOMWrappers::collectFromStyleSheets):
(WebCore::InspectorCSSOMWrappers::getWrapperForRuleInSheets):
(WebCore::InspectorCSSOMWrappers::collectFromDocumentStyleSheetCollection): Deleted.
* css/InspectorCSSOMWrappers.h:
* css/StyleResolver.cpp:
(WebCore::StyleResolver::StyleResolver):
(WebCore::StyleResolver::appendAuthorStyleSheets):
* css/StyleSheetList.cpp:
(WebCore::StyleSheetList::styleSheets):
(WebCore::StyleSheetList::detachFromDocument):
(WebCore::StyleSheetList::length):
* dom/AuthorStyleSheets.cpp: Added.
(WebCore::AuthorStyleSheets::AuthorStyleSheets):
(WebCore::AuthorStyleSheets::combineCSSFeatureFlags):
(WebCore::AuthorStyleSheets::resetCSSFeatureFlags):
(WebCore::AuthorStyleSheets::addAuthorSheet):
(WebCore::AuthorStyleSheets::removePendingSheet):
(WebCore::AuthorStyleSheets::addStyleSheetCandidateNode):
(WebCore::AuthorStyleSheets::removeStyleSheetCandidateNode):
(WebCore::AuthorStyleSheets::collectActiveStyleSheets):
(WebCore::AuthorStyleSheets::analyzeStyleSheetChange):
(WebCore::filterEnabledNonemptyCSSStyleSheets):
(WebCore::AuthorStyleSheets::updateActiveStyleSheets):
(WebCore::AuthorStyleSheets::activeStyleSheetsForInspector):
(WebCore::AuthorStyleSheets::activeStyleSheetsContains):
(WebCore::AuthorStyleSheets::detachFromDocument):
* dom/AuthorStyleSheets.h: Added.
(WebCore::AuthorStyleSheets::activeStyleSheets):
(WebCore::AuthorStyleSheets::styleSheets):
(WebCore::AuthorStyleSheets::styleSheetsForStyleSheetList):
(WebCore::AuthorStyleSheets::pendingUpdateType):
(WebCore::AuthorStyleSheets::setPendingUpdateType):
(WebCore::AuthorStyleSheets::flushPendingUpdates):
(WebCore::AuthorStyleSheets::preferredStylesheetSetName):
(WebCore::AuthorStyleSheets::selectedStylesheetSetName):
(WebCore::AuthorStyleSheets::setPreferredStylesheetSetName):
(WebCore::AuthorStyleSheets::setSelectedStylesheetSetName):
(WebCore::AuthorStyleSheets::addPendingSheet):
(WebCore::AuthorStyleSheets::hasPendingSheets):
(WebCore::AuthorStyleSheets::usesFirstLineRules):
(WebCore::AuthorStyleSheets::usesFirstLetterRules):
(WebCore::AuthorStyleSheets::usesRemUnits):
(WebCore::AuthorStyleSheets::setUsesRemUnit):
(WebCore::AuthorStyleSheets::usesStyleBasedEditability):
(WebCore::AuthorStyleSheets::setUsesStyleBasedEditability):
* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::~Document):
(WebCore::Document::setCompatibilityMode):
(WebCore::Document::recalcStyle):
(WebCore::Document::createStyleResolver):
(WebCore::Document::fontsNeedUpdate):
(WebCore::Document::usesStyleBasedEditability):
(WebCore::Document::processHttpEquiv):
(WebCore::Document::preferredStylesheetSet):
(WebCore::Document::selectedStylesheetSet):
(WebCore::Document::setSelectedStylesheetSet):
(WebCore::Document::scheduleOptimizedStyleSheetUpdate):
(WebCore::Document::styleResolverChanged):
(WebCore::Document::haveStylesheetsLoaded):
(WebCore::Document::getCachedLocale):
* dom/Document.h:
(WebCore::Document::authorStyleSheets):
(WebCore::Document::extensionStyleSheets):
(WebCore::Document::gotoAnchorNeededAfterStylesheetsLoad):
(WebCore::Document::setGotoAnchorNeededAfterStylesheetsLoad):
(WebCore::Document::styleSheetCollection): Deleted.
* dom/DocumentStyleSheetCollection.cpp: Removed.
* dom/DocumentStyleSheetCollection.h: Removed.
* dom/ExtensionStyleSheets.cpp: Copied from Source/WebCore/dom/DocumentStyleSheetCollection.cpp.
(WebCore::ExtensionStyleSheets::ExtensionStyleSheets):
(WebCore::ExtensionStyleSheets::pageUserSheet):
(WebCore::ExtensionStyleSheets::clearPageUserSheet):
(WebCore::ExtensionStyleSheets::updatePageUserSheet):
(WebCore::ExtensionStyleSheets::injectedUserStyleSheets):
(WebCore::ExtensionStyleSheets::injectedAuthorStyleSheets):
(WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache):
(WebCore::ExtensionStyleSheets::invalidateInjectedStyleSheetCache):
(WebCore::ExtensionStyleSheets::addUserSheet):
(WebCore::ExtensionStyleSheets::addDisplayNoneSelector):
(WebCore::ExtensionStyleSheets::maybeAddContentExtensionSheet):
(WebCore::ExtensionStyleSheets::styleResolverChangedTimerFired):
(WebCore::ExtensionStyleSheets::detachFromDocument):
(WebCore::DocumentStyleSheetCollection::DocumentStyleSheetCollection): Deleted.
(WebCore::DocumentStyleSheetCollection::combineCSSFeatureFlags): Deleted.
(WebCore::DocumentStyleSheetCollection::resetCSSFeatureFlags): Deleted.
(WebCore::DocumentStyleSheetCollection::pageUserSheet): Deleted.
(WebCore::DocumentStyleSheetCollection::clearPageUserSheet): Deleted.
(WebCore::DocumentStyleSheetCollection::updatePageUserSheet): Deleted.
(WebCore::DocumentStyleSheetCollection::injectedUserStyleSheets): Deleted.
(WebCore::DocumentStyleSheetCollection::injectedAuthorStyleSheets): Deleted.
(WebCore::DocumentStyleSheetCollection::updateInjectedStyleSheetCache): Deleted.
(WebCore::DocumentStyleSheetCollection::invalidateInjectedStyleSheetCache): Deleted.
(WebCore::DocumentStyleSheetCollection::addAuthorSheet): Deleted.
(WebCore::DocumentStyleSheetCollection::addUserSheet): Deleted.
(WebCore::DocumentStyleSheetCollection::addDisplayNoneSelector): Deleted.
(WebCore::DocumentStyleSheetCollection::maybeAddContentExtensionSheet): Deleted.
(WebCore::DocumentStyleSheetCollection::styleResolverChangedTimerFired): Deleted.
(WebCore::DocumentStyleSheetCollection::removePendingSheet): Deleted.
(WebCore::DocumentStyleSheetCollection::addStyleSheetCandidateNode): Deleted.
(WebCore::DocumentStyleSheetCollection::removeStyleSheetCandidateNode): Deleted.
(WebCore::DocumentStyleSheetCollection::collectActiveStyleSheets): Deleted.
(WebCore::DocumentStyleSheetCollection::analyzeStyleSheetChange): Deleted.
(WebCore::filterEnabledNonemptyCSSStyleSheets): Deleted.
(WebCore::DocumentStyleSheetCollection::updateActiveStyleSheets): Deleted.
(WebCore::DocumentStyleSheetCollection::activeStyleSheetsForInspector): Deleted.
(WebCore::DocumentStyleSheetCollection::activeStyleSheetsContains): Deleted.
(WebCore::DocumentStyleSheetCollection::detachFromDocument): Deleted.
* dom/ExtensionStyleSheets.h: Copied from Source/WebCore/dom/DocumentStyleSheetCollection.h.
(WebCore::ExtensionStyleSheets::documentUserStyleSheets):
(WebCore::DocumentStyleSheetCollection::styleSheetsForStyleSheetList): Deleted.
(WebCore::DocumentStyleSheetCollection::activeAuthorStyleSheets): Deleted.
(WebCore::DocumentStyleSheetCollection::documentUserStyleSheets): Deleted.
(WebCore::DocumentStyleSheetCollection::documentAuthorStyleSheets): Deleted.
(WebCore::DocumentStyleSheetCollection::pendingUpdateType): Deleted.
(WebCore::DocumentStyleSheetCollection::setPendingUpdateType): Deleted.
(WebCore::DocumentStyleSheetCollection::flushPendingUpdates): Deleted.
(WebCore::DocumentStyleSheetCollection::preferredStylesheetSetName): Deleted.
(WebCore::DocumentStyleSheetCollection::selectedStylesheetSetName): Deleted.
(WebCore::DocumentStyleSheetCollection::setPreferredStylesheetSetName): Deleted.
(WebCore::DocumentStyleSheetCollection::setSelectedStylesheetSetName): Deleted.
(WebCore::DocumentStyleSheetCollection::addPendingSheet): Deleted.
(WebCore::DocumentStyleSheetCollection::hasPendingSheets): Deleted.
(WebCore::DocumentStyleSheetCollection::usesFirstLineRules): Deleted.
(WebCore::DocumentStyleSheetCollection::usesFirstLetterRules): Deleted.
(WebCore::DocumentStyleSheetCollection::usesRemUnits): Deleted.
(WebCore::DocumentStyleSheetCollection::setUsesRemUnit): Deleted.
(WebCore::DocumentStyleSheetCollection::usesStyleBasedEditability): Deleted.
(WebCore::DocumentStyleSheetCollection::setUsesStyleBasedEditability): Deleted.
* dom/InlineStyleSheetOwner.cpp:
(WebCore::InlineStyleSheetOwner::insertedIntoDocument):
(WebCore::InlineStyleSheetOwner::removedFromDocument):
(WebCore::InlineStyleSheetOwner::clearDocumentData):
(WebCore::InlineStyleSheetOwner::childrenChanged):
(WebCore::InlineStyleSheetOwner::createSheet):
(WebCore::InlineStyleSheetOwner::sheetLoaded):
(WebCore::InlineStyleSheetOwner::startLoadingDynamicSheet):
* dom/ProcessingInstruction.cpp:
(WebCore::ProcessingInstruction::~ProcessingInstruction):
(WebCore::ProcessingInstruction::nodeName):
(WebCore::ProcessingInstruction::checkStyleSheet):
(WebCore::ProcessingInstruction::sheetLoaded):
(WebCore::ProcessingInstruction::insertedInto):
(WebCore::ProcessingInstruction::removedFrom):
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::~HTMLLinkElement):
(WebCore::HTMLLinkElement::insertedInto):
(WebCore::HTMLLinkElement::removedFrom):
(WebCore::HTMLLinkElement::addPendingSheet):
(WebCore::HTMLLinkElement::removePendingSheet):
* html/HTMLQuoteElement.cpp:
* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::collectAllDocumentStyleSheets):
(WebCore::InspectorCSSAgent::buildObjectForRule):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::commitData):
* page/Page.cpp:
(WebCore::Page::userStyleSheetLocationChanged):
(WebCore::Page::setUserContentController):
* page/PageGroup.cpp:
* page/UserContentController.cpp:
(WebCore::UserContentController::invalidateInjectedStyleSheetCacheInAllFrames):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::lineHeight):
(WebCore::RenderBlock::getFirstLetter):
* rendering/RenderElement.cpp:
(WebCore::RenderElement::uncachedFirstLineStyle):
(WebCore::RenderElement::cachedFirstLineStyle):
* rendering/RenderElement.h:
(WebCore::RenderElement::firstLineStyle):
(WebCore::RenderElement::setAncestorLineBoxDirty):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::updateAlwaysCreateLineBoxes):
(WebCore::RenderInline::lineHeight):
* rendering/RenderLineBreak.cpp:
(WebCore::RenderLineBreak::lineHeight):
* rendering/RootInlineBox.cpp:
(WebCore::RootInlineBox::verticalPositionForBox):
* style/StyleResolveTree.cpp:
(WebCore::Style::resolveLocal):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc

37 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/contentextensions/ContentExtensionsBackend.cpp
Source/WebCore/css/CSSStyleSheet.cpp
Source/WebCore/css/DocumentRuleSets.cpp
Source/WebCore/css/DocumentRuleSets.h
Source/WebCore/css/InspectorCSSOMWrappers.cpp
Source/WebCore/css/InspectorCSSOMWrappers.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/StyleSheetList.cpp
Source/WebCore/dom/AuthorStyleSheets.cpp [moved from Source/WebCore/dom/DocumentStyleSheetCollection.cpp with 58% similarity]
Source/WebCore/dom/AuthorStyleSheets.h [moved from Source/WebCore/dom/DocumentStyleSheetCollection.h with 59% similarity]
Source/WebCore/dom/DOMAllInOne.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/ExtensionStyleSheets.cpp [new file with mode: 0644]
Source/WebCore/dom/ExtensionStyleSheets.h [new file with mode: 0644]
Source/WebCore/dom/InlineStyleSheetOwner.cpp
Source/WebCore/dom/ProcessingInstruction.cpp
Source/WebCore/html/HTMLLinkElement.cpp
Source/WebCore/html/HTMLQuoteElement.cpp
Source/WebCore/inspector/InspectorCSSAgent.cpp
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/page/PageGroup.cpp
Source/WebCore/page/UserContentController.cpp
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderElement.h
Source/WebCore/rendering/RenderInline.cpp
Source/WebCore/rendering/RenderLineBreak.cpp
Source/WebCore/rendering/RenderView.h
Source/WebCore/rendering/RootInlineBox.cpp
Source/WebCore/style/StyleResolveTree.cpp
Source/WebCore/testing/Internals.cpp

index f59065d..57d5d18 100644 (file)
@@ -1377,6 +1377,7 @@ set(WebCore_SOURCES
     dom/ActiveDOMObject.cpp
     dom/AnimationEvent.cpp
     dom/Attr.cpp
+    dom/AuthorStyleSheets.cpp
     dom/BeforeTextInsertedEvent.cpp
     dom/BeforeUnloadEvent.cpp
     dom/CDATASection.cpp
@@ -1418,7 +1419,6 @@ set(WebCore_SOURCES
     dom/DocumentOrderedMap.cpp
     dom/DocumentParser.cpp
     dom/DocumentSharedObjectPool.cpp
-    dom/DocumentStyleSheetCollection.cpp
     dom/DocumentType.cpp
     dom/Element.cpp
     dom/ElementData.cpp
@@ -1434,6 +1434,7 @@ set(WebCore_SOURCES
     dom/EventTarget.cpp
     dom/ExceptionBase.cpp
     dom/ExceptionCodePlaceholder.cpp
+    dom/ExtensionStyleSheets.cpp
     dom/FocusEvent.cpp
     dom/GenericEventQueue.cpp
     dom/IdTargetObserver.cpp
index d94a40f..2f49613 100644 (file)
@@ -1,3 +1,211 @@
+2015-09-22  Antti Koivisto  <antti@apple.com>
+
+        Split author style code out from DocumentStyleSheetCollection
+        https://bugs.webkit.org/show_bug.cgi?id=149446
+
+        Reviewed by Andreas Kling.
+
+        Shadow trees may have their own author style. Factor the related code out so we can use
+        it outside the document context.
+
+        DocumentStyleSheetCollection is replaced by two classes:
+
+        AuthorStyleSheets - author stylesheets and mutation optimization code
+        ExtensionStyleSheets - user stylesheets, injected author stylesheets, content extension stylesheets
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * contentextensions/ContentExtensionsBackend.cpp:
+        (WebCore::ContentExtensions::ContentExtensionsBackend::processContentExtensionRulesForLoad):
+        * css/CSSStyleSheet.cpp:
+        (WebCore::CSSStyleSheet::didMutateRules):
+        * css/DocumentRuleSets.cpp:
+        (WebCore::DocumentRuleSets::~DocumentRuleSets):
+        (WebCore::DocumentRuleSets::initUserStyle):
+        * css/DocumentRuleSets.h:
+        (WebCore::DocumentRuleSets::sibling):
+        (WebCore::DocumentRuleSets::uncommonAttribute):
+        * css/InspectorCSSOMWrappers.cpp:
+        (WebCore::InspectorCSSOMWrappers::collectFromStyleSheets):
+        (WebCore::InspectorCSSOMWrappers::getWrapperForRuleInSheets):
+        (WebCore::InspectorCSSOMWrappers::collectFromDocumentStyleSheetCollection): Deleted.
+        * css/InspectorCSSOMWrappers.h:
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::StyleResolver):
+        (WebCore::StyleResolver::appendAuthorStyleSheets):
+        * css/StyleSheetList.cpp:
+        (WebCore::StyleSheetList::styleSheets):
+        (WebCore::StyleSheetList::detachFromDocument):
+        (WebCore::StyleSheetList::length):
+        * dom/AuthorStyleSheets.cpp: Added.
+        (WebCore::AuthorStyleSheets::AuthorStyleSheets):
+        (WebCore::AuthorStyleSheets::combineCSSFeatureFlags):
+        (WebCore::AuthorStyleSheets::resetCSSFeatureFlags):
+        (WebCore::AuthorStyleSheets::addAuthorSheet):
+        (WebCore::AuthorStyleSheets::removePendingSheet):
+        (WebCore::AuthorStyleSheets::addStyleSheetCandidateNode):
+        (WebCore::AuthorStyleSheets::removeStyleSheetCandidateNode):
+        (WebCore::AuthorStyleSheets::collectActiveStyleSheets):
+        (WebCore::AuthorStyleSheets::analyzeStyleSheetChange):
+        (WebCore::filterEnabledNonemptyCSSStyleSheets):
+        (WebCore::AuthorStyleSheets::updateActiveStyleSheets):
+        (WebCore::AuthorStyleSheets::activeStyleSheetsForInspector):
+        (WebCore::AuthorStyleSheets::activeStyleSheetsContains):
+        (WebCore::AuthorStyleSheets::detachFromDocument):
+        * dom/AuthorStyleSheets.h: Added.
+        (WebCore::AuthorStyleSheets::activeStyleSheets):
+        (WebCore::AuthorStyleSheets::styleSheets):
+        (WebCore::AuthorStyleSheets::styleSheetsForStyleSheetList):
+        (WebCore::AuthorStyleSheets::pendingUpdateType):
+        (WebCore::AuthorStyleSheets::setPendingUpdateType):
+        (WebCore::AuthorStyleSheets::flushPendingUpdates):
+        (WebCore::AuthorStyleSheets::preferredStylesheetSetName):
+        (WebCore::AuthorStyleSheets::selectedStylesheetSetName):
+        (WebCore::AuthorStyleSheets::setPreferredStylesheetSetName):
+        (WebCore::AuthorStyleSheets::setSelectedStylesheetSetName):
+        (WebCore::AuthorStyleSheets::addPendingSheet):
+        (WebCore::AuthorStyleSheets::hasPendingSheets):
+        (WebCore::AuthorStyleSheets::usesFirstLineRules):
+        (WebCore::AuthorStyleSheets::usesFirstLetterRules):
+        (WebCore::AuthorStyleSheets::usesRemUnits):
+        (WebCore::AuthorStyleSheets::setUsesRemUnit):
+        (WebCore::AuthorStyleSheets::usesStyleBasedEditability):
+        (WebCore::AuthorStyleSheets::setUsesStyleBasedEditability):
+        * dom/Document.cpp:
+        (WebCore::Document::Document):
+        (WebCore::Document::~Document):
+        (WebCore::Document::setCompatibilityMode):
+        (WebCore::Document::recalcStyle):
+        (WebCore::Document::createStyleResolver):
+        (WebCore::Document::fontsNeedUpdate):
+        (WebCore::Document::usesStyleBasedEditability):
+        (WebCore::Document::processHttpEquiv):
+        (WebCore::Document::preferredStylesheetSet):
+        (WebCore::Document::selectedStylesheetSet):
+        (WebCore::Document::setSelectedStylesheetSet):
+        (WebCore::Document::scheduleOptimizedStyleSheetUpdate):
+        (WebCore::Document::styleResolverChanged):
+        (WebCore::Document::haveStylesheetsLoaded):
+        (WebCore::Document::getCachedLocale):
+        * dom/Document.h:
+        (WebCore::Document::authorStyleSheets):
+        (WebCore::Document::extensionStyleSheets):
+        (WebCore::Document::gotoAnchorNeededAfterStylesheetsLoad):
+        (WebCore::Document::setGotoAnchorNeededAfterStylesheetsLoad):
+        (WebCore::Document::styleSheetCollection): Deleted.
+        * dom/DocumentStyleSheetCollection.cpp: Removed.
+        * dom/DocumentStyleSheetCollection.h: Removed.
+        * dom/ExtensionStyleSheets.cpp: Copied from Source/WebCore/dom/DocumentStyleSheetCollection.cpp.
+        (WebCore::ExtensionStyleSheets::ExtensionStyleSheets):
+        (WebCore::ExtensionStyleSheets::pageUserSheet):
+        (WebCore::ExtensionStyleSheets::clearPageUserSheet):
+        (WebCore::ExtensionStyleSheets::updatePageUserSheet):
+        (WebCore::ExtensionStyleSheets::injectedUserStyleSheets):
+        (WebCore::ExtensionStyleSheets::injectedAuthorStyleSheets):
+        (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache):
+        (WebCore::ExtensionStyleSheets::invalidateInjectedStyleSheetCache):
+        (WebCore::ExtensionStyleSheets::addUserSheet):
+        (WebCore::ExtensionStyleSheets::addDisplayNoneSelector):
+        (WebCore::ExtensionStyleSheets::maybeAddContentExtensionSheet):
+        (WebCore::ExtensionStyleSheets::styleResolverChangedTimerFired):
+        (WebCore::ExtensionStyleSheets::detachFromDocument):
+        (WebCore::DocumentStyleSheetCollection::DocumentStyleSheetCollection): Deleted.
+        (WebCore::DocumentStyleSheetCollection::combineCSSFeatureFlags): Deleted.
+        (WebCore::DocumentStyleSheetCollection::resetCSSFeatureFlags): Deleted.
+        (WebCore::DocumentStyleSheetCollection::pageUserSheet): Deleted.
+        (WebCore::DocumentStyleSheetCollection::clearPageUserSheet): Deleted.
+        (WebCore::DocumentStyleSheetCollection::updatePageUserSheet): Deleted.
+        (WebCore::DocumentStyleSheetCollection::injectedUserStyleSheets): Deleted.
+        (WebCore::DocumentStyleSheetCollection::injectedAuthorStyleSheets): Deleted.
+        (WebCore::DocumentStyleSheetCollection::updateInjectedStyleSheetCache): Deleted.
+        (WebCore::DocumentStyleSheetCollection::invalidateInjectedStyleSheetCache): Deleted.
+        (WebCore::DocumentStyleSheetCollection::addAuthorSheet): Deleted.
+        (WebCore::DocumentStyleSheetCollection::addUserSheet): Deleted.
+        (WebCore::DocumentStyleSheetCollection::addDisplayNoneSelector): Deleted.
+        (WebCore::DocumentStyleSheetCollection::maybeAddContentExtensionSheet): Deleted.
+        (WebCore::DocumentStyleSheetCollection::styleResolverChangedTimerFired): Deleted.
+        (WebCore::DocumentStyleSheetCollection::removePendingSheet): Deleted.
+        (WebCore::DocumentStyleSheetCollection::addStyleSheetCandidateNode): Deleted.
+        (WebCore::DocumentStyleSheetCollection::removeStyleSheetCandidateNode): Deleted.
+        (WebCore::DocumentStyleSheetCollection::collectActiveStyleSheets): Deleted.
+        (WebCore::DocumentStyleSheetCollection::analyzeStyleSheetChange): Deleted.
+        (WebCore::filterEnabledNonemptyCSSStyleSheets): Deleted.
+        (WebCore::DocumentStyleSheetCollection::updateActiveStyleSheets): Deleted.
+        (WebCore::DocumentStyleSheetCollection::activeStyleSheetsForInspector): Deleted.
+        (WebCore::DocumentStyleSheetCollection::activeStyleSheetsContains): Deleted.
+        (WebCore::DocumentStyleSheetCollection::detachFromDocument): Deleted.
+        * dom/ExtensionStyleSheets.h: Copied from Source/WebCore/dom/DocumentStyleSheetCollection.h.
+        (WebCore::ExtensionStyleSheets::documentUserStyleSheets):
+        (WebCore::DocumentStyleSheetCollection::styleSheetsForStyleSheetList): Deleted.
+        (WebCore::DocumentStyleSheetCollection::activeAuthorStyleSheets): Deleted.
+        (WebCore::DocumentStyleSheetCollection::documentUserStyleSheets): Deleted.
+        (WebCore::DocumentStyleSheetCollection::documentAuthorStyleSheets): Deleted.
+        (WebCore::DocumentStyleSheetCollection::pendingUpdateType): Deleted.
+        (WebCore::DocumentStyleSheetCollection::setPendingUpdateType): Deleted.
+        (WebCore::DocumentStyleSheetCollection::flushPendingUpdates): Deleted.
+        (WebCore::DocumentStyleSheetCollection::preferredStylesheetSetName): Deleted.
+        (WebCore::DocumentStyleSheetCollection::selectedStylesheetSetName): Deleted.
+        (WebCore::DocumentStyleSheetCollection::setPreferredStylesheetSetName): Deleted.
+        (WebCore::DocumentStyleSheetCollection::setSelectedStylesheetSetName): Deleted.
+        (WebCore::DocumentStyleSheetCollection::addPendingSheet): Deleted.
+        (WebCore::DocumentStyleSheetCollection::hasPendingSheets): Deleted.
+        (WebCore::DocumentStyleSheetCollection::usesFirstLineRules): Deleted.
+        (WebCore::DocumentStyleSheetCollection::usesFirstLetterRules): Deleted.
+        (WebCore::DocumentStyleSheetCollection::usesRemUnits): Deleted.
+        (WebCore::DocumentStyleSheetCollection::setUsesRemUnit): Deleted.
+        (WebCore::DocumentStyleSheetCollection::usesStyleBasedEditability): Deleted.
+        (WebCore::DocumentStyleSheetCollection::setUsesStyleBasedEditability): Deleted.
+        * dom/InlineStyleSheetOwner.cpp:
+        (WebCore::InlineStyleSheetOwner::insertedIntoDocument):
+        (WebCore::InlineStyleSheetOwner::removedFromDocument):
+        (WebCore::InlineStyleSheetOwner::clearDocumentData):
+        (WebCore::InlineStyleSheetOwner::childrenChanged):
+        (WebCore::InlineStyleSheetOwner::createSheet):
+        (WebCore::InlineStyleSheetOwner::sheetLoaded):
+        (WebCore::InlineStyleSheetOwner::startLoadingDynamicSheet):
+        * dom/ProcessingInstruction.cpp:
+        (WebCore::ProcessingInstruction::~ProcessingInstruction):
+        (WebCore::ProcessingInstruction::nodeName):
+        (WebCore::ProcessingInstruction::checkStyleSheet):
+        (WebCore::ProcessingInstruction::sheetLoaded):
+        (WebCore::ProcessingInstruction::insertedInto):
+        (WebCore::ProcessingInstruction::removedFrom):
+        * html/HTMLLinkElement.cpp:
+        (WebCore::HTMLLinkElement::~HTMLLinkElement):
+        (WebCore::HTMLLinkElement::insertedInto):
+        (WebCore::HTMLLinkElement::removedFrom):
+        (WebCore::HTMLLinkElement::addPendingSheet):
+        (WebCore::HTMLLinkElement::removePendingSheet):
+        * html/HTMLQuoteElement.cpp:
+        * inspector/InspectorCSSAgent.cpp:
+        (WebCore::InspectorCSSAgent::collectAllDocumentStyleSheets):
+        (WebCore::InspectorCSSAgent::buildObjectForRule):
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::commitData):
+        * page/Page.cpp:
+        (WebCore::Page::userStyleSheetLocationChanged):
+        (WebCore::Page::setUserContentController):
+        * page/PageGroup.cpp:
+        * page/UserContentController.cpp:
+        (WebCore::UserContentController::invalidateInjectedStyleSheetCacheInAllFrames):
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::lineHeight):
+        (WebCore::RenderBlock::getFirstLetter):
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::uncachedFirstLineStyle):
+        (WebCore::RenderElement::cachedFirstLineStyle):
+        * rendering/RenderElement.h:
+        (WebCore::RenderElement::firstLineStyle):
+        (WebCore::RenderElement::setAncestorLineBoxDirty):
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::updateAlwaysCreateLineBoxes):
+        (WebCore::RenderInline::lineHeight):
+        * rendering/RenderLineBreak.cpp:
+        (WebCore::RenderLineBreak::lineHeight):
+        * rendering/RootInlineBox.cpp:
+        (WebCore::RootInlineBox::verticalPositionForBox):
+        * style/StyleResolveTree.cpp:
+        (WebCore::Style::resolveLocal):
+
 2015-09-23  Chris Dumez  <cdumez@apple.com>
 
         HTMLOutputElement.htmlFor should be settable
index 6c550e2..21a9d42 100644 (file)
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="..\dom\AuthorStyleSheets.cpp">
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
+    </ClCompile>
     <ClCompile Include="..\dom\BeforeTextInsertedEvent.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
     </ClCompile>
-    <ClCompile Include="..\dom\DocumentStyleSheetCollection.cpp">
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
-    </ClCompile>
     <ClCompile Include="..\dom\DocumentType.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="..\dom\ExtensionStyleSheets.cpp">
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
+    </ClCompile>
     <ClCompile Include="..\dom\GenericEventQueue.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
     <ClInclude Include="..\dom\AnimationEvent.h" />
     <ClInclude Include="..\dom\Attr.h" />
     <ClInclude Include="..\dom\Attribute.h" />
+    <ClInclude Include="..\dom\AuthorStyleSheets.h" />
     <ClInclude Include="..\dom\BeforeLoadEvent.h" />
     <ClInclude Include="..\dom\BeforeTextInsertedEvent.h" />
     <ClInclude Include="..\dom\BeforeUnloadEvent.h" />
     <ClInclude Include="..\dom\DocumentOrderedMap.h" />
     <ClInclude Include="..\dom\DocumentParser.h" />
     <ClInclude Include="..\dom\DocumentSharedObjectPool.h" />
-    <ClInclude Include="..\dom\DocumentStyleSheetCollection.h" />
     <ClInclude Include="..\dom\DocumentTiming.h" />
     <ClInclude Include="..\dom\DocumentType.h" />
     <ClInclude Include="..\dom\DOMCoreException.h" />
     <ClInclude Include="..\dom\ExceptionBase.h" />
     <ClInclude Include="..\dom\ExceptionCode.h" />
     <ClInclude Include="..\dom\ExceptionCodePlaceholder.h" />
+    <ClInclude Include="..\dom\ExtensionStyleSheets.h" />
     <ClInclude Include="..\dom\GenericEventQueue.h" />
     <ClInclude Include="..\dom\HashChangeEvent.h" />
     <ClInclude Include="..\dom\IconURL.h" />
index 82416b2..c0541e1 100644 (file)
                E45390490EAFD637003695C8 /* WebCoreSystemInterfaceIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = E45390380EAFD637003695C8 /* WebCoreSystemInterfaceIOS.mm */; };
                E453904D0EAFD637003695C8 /* WidgetIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = E453903C0EAFD637003695C8 /* WidgetIOS.mm */; };
                E45390AE0EAFF4B5003695C8 /* SystemMemoryIOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E45390AD0EAFF4B5003695C8 /* SystemMemoryIOS.cpp */; };
+               E461D65D1BB0C7F000CB5645 /* AuthorStyleSheets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461D65C1BB0C7F000CB5645 /* AuthorStyleSheets.cpp */; settings = {ASSET_TAGS = (); }; };
+               E461D65F1BB0C80D00CB5645 /* AuthorStyleSheets.h in Headers */ = {isa = PBXBuildFile; fileRef = E461D65E1BB0C80D00CB5645 /* AuthorStyleSheets.h */; settings = {ASSET_TAGS = (); }; };
                E462A4A1113E71BE004A4220 /* IntPointHash.h in Headers */ = {isa = PBXBuildFile; fileRef = E462A4A0113E71BE004A4220 /* IntPointHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E46A2B1C17CA65B9000DBCD8 /* TypedElementDescendantIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1B17CA65B9000DBCD8 /* TypedElementDescendantIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E46A2B1E17CA76B1000DBCD8 /* ElementChildIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1D17CA76B1000DBCD8 /* ElementChildIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E4778B80115A581A00B5D372 /* JSCustomEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = E4778B7E115A581A00B5D372 /* JSCustomEvent.h */; };
                E47B4BE80E71241600038854 /* CachedResourceHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = E47B4BE60E71241600038854 /* CachedResourceHandle.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E47B4BE90E71241600038854 /* CachedResourceHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E47B4BE70E71241600038854 /* CachedResourceHandle.cpp */; };
-               E47E276516036ED200EE2AFB /* DocumentStyleSheetCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = E47E276416036ED200EE2AFB /* DocumentStyleSheetCollection.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               E47E276816036EDC00EE2AFB /* DocumentStyleSheetCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E47E276716036EDC00EE2AFB /* DocumentStyleSheetCollection.cpp */; };
+               E47E276516036ED200EE2AFB /* ExtensionStyleSheets.h in Headers */ = {isa = PBXBuildFile; fileRef = E47E276416036ED200EE2AFB /* ExtensionStyleSheets.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               E47E276816036EDC00EE2AFB /* ExtensionStyleSheets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E47E276716036EDC00EE2AFB /* ExtensionStyleSheets.cpp */; };
                E48944A2180B57D800F165D8 /* SimpleLineLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E48944A0180B57D800F165D8 /* SimpleLineLayout.cpp */; };
                E48944A3180B57D800F165D8 /* SimpleLineLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = E48944A1180B57D800F165D8 /* SimpleLineLayout.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E4916FF7195DF6A0005AB349 /* LayerFlushThrottleState.h in Headers */ = {isa = PBXBuildFile; fileRef = E4916FF6195DF6A0005AB349 /* LayerFlushThrottleState.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E45390380EAFD637003695C8 /* WebCoreSystemInterfaceIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreSystemInterfaceIOS.mm; sourceTree = "<group>"; };
                E453903C0EAFD637003695C8 /* WidgetIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WidgetIOS.mm; sourceTree = "<group>"; };
                E45390AD0EAFF4B5003695C8 /* SystemMemoryIOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SystemMemoryIOS.cpp; sourceTree = "<group>"; };
+               E461D65C1BB0C7F000CB5645 /* AuthorStyleSheets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AuthorStyleSheets.cpp; sourceTree = "<group>"; };
+               E461D65E1BB0C80D00CB5645 /* AuthorStyleSheets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AuthorStyleSheets.h; sourceTree = "<group>"; };
                E462A4A0113E71BE004A4220 /* IntPointHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntPointHash.h; sourceTree = "<group>"; };
                E46A2B1B17CA65B9000DBCD8 /* TypedElementDescendantIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypedElementDescendantIterator.h; sourceTree = "<group>"; };
                E46A2B1D17CA76B1000DBCD8 /* ElementChildIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementChildIterator.h; sourceTree = "<group>"; };
                E47A97CF163059FC005DCD99 /* StyleInvalidationAnalysis.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleInvalidationAnalysis.h; sourceTree = "<group>"; };
                E47B4BE60E71241600038854 /* CachedResourceHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedResourceHandle.h; sourceTree = "<group>"; };
                E47B4BE70E71241600038854 /* CachedResourceHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedResourceHandle.cpp; sourceTree = "<group>"; };
-               E47E276416036ED200EE2AFB /* DocumentStyleSheetCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentStyleSheetCollection.h; sourceTree = "<group>"; };
-               E47E276716036EDC00EE2AFB /* DocumentStyleSheetCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentStyleSheetCollection.cpp; sourceTree = "<group>"; };
+               E47E276416036ED200EE2AFB /* ExtensionStyleSheets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtensionStyleSheets.h; sourceTree = "<group>"; };
+               E47E276716036EDC00EE2AFB /* ExtensionStyleSheets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExtensionStyleSheets.cpp; sourceTree = "<group>"; };
                E48944A0180B57D800F165D8 /* SimpleLineLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayout.cpp; sourceTree = "<group>"; };
                E48944A1180B57D800F165D8 /* SimpleLineLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayout.h; sourceTree = "<group>"; };
                E4916FF6195DF6A0005AB349 /* LayerFlushThrottleState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayerFlushThrottleState.h; sourceTree = "<group>"; };
                                A8C4A7FB09D563270003AC8D /* Attr.h */,
                                93EEC1E509C2877700C515D1 /* Attr.idl */,
                                A8C4A7F909D563270003AC8D /* Attribute.h */,
+                               E461D65C1BB0C7F000CB5645 /* AuthorStyleSheets.cpp */,
+                               E461D65E1BB0C80D00CB5645 /* AuthorStyleSheets.h */,
                                760847CD19A6A27700428CCC /* AutocompleteErrorEvent.h */,
                                760847CF19A6A28600428CCC /* AutocompleteErrorEvent.idl */,
                                BC9462D7107A7B4C00857193 /* BeforeLoadEvent.h */,
                                BCCFBAE70B5152ED0001F1D7 /* DocumentParser.h */,
                                AD6E71AA1668899D00320C13 /* DocumentSharedObjectPool.cpp */,
                                AD6E71AB1668899D00320C13 /* DocumentSharedObjectPool.h */,
-                               E47E276716036EDC00EE2AFB /* DocumentStyleSheetCollection.cpp */,
-                               E47E276416036ED200EE2AFB /* DocumentStyleSheetCollection.h */,
                                86D982F6125C154000AD9E3D /* DocumentTiming.h */,
                                A8185F3209765765005826D9 /* DocumentType.cpp */,
                                A8185F3109765765005826D9 /* DocumentType.h */,
                                935FBCF109BA143B00E230B1 /* ExceptionCode.h */,
                                A7CACDB013CE875B00BBBE3F /* ExceptionCodePlaceholder.cpp */,
                                A74BB76A13BDA86300FF7BF0 /* ExceptionCodePlaceholder.h */,
+                               E47E276716036EDC00EE2AFB /* ExtensionStyleSheets.cpp */,
+                               E47E276416036ED200EE2AFB /* ExtensionStyleSheets.h */,
                                B6D9D23414EABD260090D75E /* FocusEvent.cpp */,
                                B6D9D23314EABD260090D75E /* FocusEvent.h */,
                                B6D9D27214EABF030090D75E /* FocusEvent.idl */,
                                BCCFBAE80B5152ED0001F1D7 /* DocumentParser.h in Headers */,
                                4A4F48AA16B0DFC000EDBB29 /* DocumentRuleSets.h in Headers */,
                                AD6E71AD1668899D00320C13 /* DocumentSharedObjectPool.h in Headers */,
-                               E47E276516036ED200EE2AFB /* DocumentStyleSheetCollection.h in Headers */,
+                               E47E276516036ED200EE2AFB /* ExtensionStyleSheets.h in Headers */,
                                0B90561A0F2578BF0095FF6A /* DocumentThreadableLoader.h in Headers */,
                                86D982F7125C154000AD9E3D /* DocumentTiming.h in Headers */,
                                A8185F3909765766005826D9 /* DocumentType.h in Headers */,
                                99CC0B5E18BE984A006CEBCC /* SegmentedInputStorage.h in Headers */,
                                B2C3DA2F0D006C1D00EF6F26 /* SegmentedString.h in Headers */,
                                BEA807C90F714A0300524199 /* SelectionRect.h in Headers */,
+                               E461D65F1BB0C80D00CB5645 /* AuthorStyleSheets.h in Headers */,
                                51405C89190B014400754F94 /* SelectionRectGatherer.h in Headers */,
                                CDCFABBD18C0AF78006F8450 /* SelectionSubtreeRoot.h in Headers */,
                                E44B4BB4141650D7002B1D8B /* SelectorChecker.h in Headers */,
                                A8C2280E11D4A59700D5A7D3 /* DocumentParser.cpp in Sources */,
                                4A4F48A916B0DFC000EDBB29 /* DocumentRuleSets.cpp in Sources */,
                                AD6E71AC1668899D00320C13 /* DocumentSharedObjectPool.cpp in Sources */,
-                               E47E276816036EDC00EE2AFB /* DocumentStyleSheetCollection.cpp in Sources */,
+                               E47E276816036EDC00EE2AFB /* ExtensionStyleSheets.cpp in Sources */,
                                0B9056190F2578BE0095FF6A /* DocumentThreadableLoader.cpp in Sources */,
                                A8185F3A09765766005826D9 /* DocumentType.cpp in Sources */,
                                973889A0116EA9DC00ADF313 /* DocumentWriter.cpp in Sources */,
                                85ECBEF80AA7626900544F0B /* DOMHTMLParamElement.mm in Sources */,
                                7C33F3621B4A050400502CAF /* JSDocumentFragmentCustom.cpp in Sources */,
                                85183B490AA6926100F19FA3 /* DOMHTMLPreElement.mm in Sources */,
+                               E461D65D1BB0C7F000CB5645 /* AuthorStyleSheets.cpp in Sources */,
                                A4226E961163D73A008B8397 /* DOMHTMLProgressElement.mm in Sources */,
                                85183B4B0AA6926100F19FA3 /* DOMHTMLQuoteElement.mm in Sources */,
                                85DF819C0AA77E4B00486AD7 /* DOMHTMLScriptElement.mm in Sources */,
index bbe0872..52200de 100644 (file)
@@ -34,6 +34,7 @@
 #include "DFABytecodeInterpreter.h"
 #include "Document.h"
 #include "DocumentLoader.h"
+#include "ExtensionStyleSheets.h"
 #include "Frame.h"
 #include "MainFrame.h"
 #include "ResourceLoadInfo.h"
@@ -176,7 +177,7 @@ void ContentExtensionsBackend::processContentExtensionRulesForLoad(ResourceReque
             if (resourceType == ResourceType::Document)
                 initiatingDocumentLoader.addPendingContentExtensionDisplayNoneSelector(action.extensionIdentifier(), action.stringArgument(), action.actionID());
             else if (currentDocument)
-                currentDocument->styleSheetCollection().addDisplayNoneSelector(action.extensionIdentifier(), action.stringArgument(), action.actionID());
+                currentDocument->extensionStyleSheets().addDisplayNoneSelector(action.extensionIdentifier(), action.stringArgument(), action.actionID());
             break;
         case ContentExtensions::ActionType::CSSDisplayNoneStyleSheet: {
             StyleSheetContents* styleSheetContents = globalDisplayNoneStyleSheet(action.stringArgument());
@@ -184,7 +185,7 @@ void ContentExtensionsBackend::processContentExtensionRulesForLoad(ResourceReque
                 if (resourceType == ResourceType::Document)
                     initiatingDocumentLoader.addPendingContentExtensionSheet(action.stringArgument(), *styleSheetContents);
                 else if (currentDocument)
-                    currentDocument->styleSheetCollection().maybeAddContentExtensionSheet(action.stringArgument(), *styleSheetContents);
+                    currentDocument->extensionStyleSheets().maybeAddContentExtensionSheet(action.stringArgument(), *styleSheetContents);
             }
             break;
         }
index 5c98569..98012be 100644 (file)
@@ -21,6 +21,7 @@
 #include "config.h"
 #include "CSSStyleSheet.h"
 
+#include "AuthorStyleSheets.h"
 #include "CSSCharsetRule.h"
 #include "CSSFontFaceRule.h"
 #include "CSSImportRule.h"
@@ -30,8 +31,8 @@
 #include "CSSStyleRule.h"
 #include "CachedCSSStyleSheet.h"
 #include "Document.h"
-#include "DocumentStyleSheetCollection.h"
 #include "ExceptionCode.h"
+#include "ExtensionStyleSheets.h"
 #include "HTMLNames.h"
 #include "HTMLStyleElement.h"
 #include "MediaList.h"
@@ -170,7 +171,7 @@ void CSSStyleSheet::didMutateRules(RuleMutationType mutationType, WhetherContent
     if (!owner)
         return;
 
-    if (mutationType == RuleInsertion && !contentsWereClonedForMutation && !owner->styleSheetCollection().activeStyleSheetsContains(this)) {
+    if (mutationType == RuleInsertion && !contentsWereClonedForMutation && !owner->authorStyleSheets().activeStyleSheetsContains(this)) {
         if (insertedKeyframesRule) {
             if (StyleResolver* resolver = owner->styleResolverIfExists())
                 resolver->addKeyframeStyle(insertedKeyframesRule);
index 292a9a6..818a4d7 100644 (file)
@@ -31,7 +31,7 @@
 
 #include "CSSDefaultStyleSheets.h"
 #include "CSSStyleSheet.h"
-#include "DocumentStyleSheetCollection.h"
+#include "ExtensionStyleSheets.h"
 #include "MediaQueryEvaluator.h"
 #include "StyleResolver.h"
 #include "StyleSheetContents.h"
@@ -46,13 +46,13 @@ DocumentRuleSets::~DocumentRuleSets()
 {
 }
 
-void DocumentRuleSets::initUserStyle(DocumentStyleSheetCollection& styleSheetCollection, const MediaQueryEvaluator& medium, StyleResolver& resolver)
+void DocumentRuleSets::initUserStyle(ExtensionStyleSheets& extensionStyleSheets, const MediaQueryEvaluator& medium, StyleResolver& resolver)
 {
     auto tempUserStyle = std::make_unique<RuleSet>();
-    if (CSSStyleSheet* pageUserSheet = styleSheetCollection.pageUserSheet())
+    if (CSSStyleSheet* pageUserSheet = extensionStyleSheets.pageUserSheet())
         tempUserStyle->addRulesFromSheet(&pageUserSheet->contents(), medium, &resolver);
-    collectRulesFromUserStyleSheets(styleSheetCollection.injectedUserStyleSheets(), *tempUserStyle, medium, resolver);
-    collectRulesFromUserStyleSheets(styleSheetCollection.documentUserStyleSheets(), *tempUserStyle, medium, resolver);
+    collectRulesFromUserStyleSheets(extensionStyleSheets.injectedUserStyleSheets(), *tempUserStyle, medium, resolver);
+    collectRulesFromUserStyleSheets(extensionStyleSheets.documentUserStyleSheets(), *tempUserStyle, medium, resolver);
     if (tempUserStyle->ruleCount() > 0 || tempUserStyle->pageRules().size() > 0)
         m_userStyle = WTF::move(tempUserStyle);
 }
index c2ca49f..2e14816 100644 (file)
@@ -49,7 +49,7 @@ public:
     RuleSet* sibling() const { return m_siblingRuleSet.get(); }
     RuleSet* uncommonAttribute() const { return m_uncommonAttributeRuleSet.get(); }
 
-    void initUserStyle(DocumentStyleSheetCollection&, const MediaQueryEvaluator&, StyleResolver&);
+    void initUserStyle(ExtensionStyleSheets&, const MediaQueryEvaluator&, StyleResolver&);
     void resetAuthorStyle();
     void appendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyleSheet>>&, MediaQueryEvaluator*, InspectorCSSOMWrappers&, StyleResolver*);
 
index a41e40b..ce98de3 100644 (file)
@@ -29,6 +29,7 @@
 #include "config.h"
 #include "InspectorCSSOMWrappers.h"
 
+#include "AuthorStyleSheets.h"
 #include "CSSDefaultStyleSheets.h"
 #include "CSSImportRule.h"
 #include "CSSMediaRule.h"
@@ -36,7 +37,7 @@
 #include "CSSStyleRule.h"
 #include "CSSStyleSheet.h"
 #include "CSSSupportsRule.h"
-#include "DocumentStyleSheetCollection.h"
+#include "ExtensionStyleSheets.h"
 #include "StyleSheetContents.h"
 #include "WebKitCSSRegionRule.h"
 
@@ -95,15 +96,7 @@ void InspectorCSSOMWrappers::collectFromStyleSheets(const Vector<RefPtr<CSSStyle
         collect(sheets[i].get());
 }
 
-void InspectorCSSOMWrappers::collectFromDocumentStyleSheetCollection(DocumentStyleSheetCollection& styleSheetCollection)
-{
-    collectFromStyleSheets(styleSheetCollection.activeAuthorStyleSheets());
-    collect(styleSheetCollection.pageUserSheet());
-    collectFromStyleSheets(styleSheetCollection.injectedUserStyleSheets());
-    collectFromStyleSheets(styleSheetCollection.documentUserStyleSheets());
-}
-
-CSSStyleRule* InspectorCSSOMWrappers::getWrapperForRuleInSheets(StyleRule* rule, DocumentStyleSheetCollection& styleSheetCollection)
+CSSStyleRule* InspectorCSSOMWrappers::getWrapperForRuleInSheets(StyleRule* rule, AuthorStyleSheets& authorStyleSheets, ExtensionStyleSheets& extensionStyleSheets)
 {
     if (m_styleRuleToCSSOMWrapperMap.isEmpty()) {
         collectFromStyleSheetContents(m_styleSheetCSSOMWrapperSet, CSSDefaultStyleSheets::simpleDefaultStyleSheet);
@@ -115,7 +108,10 @@ CSSStyleRule* InspectorCSSOMWrappers::getWrapperForRuleInSheets(StyleRule* rule,
         collectFromStyleSheetContents(m_styleSheetCSSOMWrapperSet, CSSDefaultStyleSheets::fullscreenStyleSheet);
         collectFromStyleSheetContents(m_styleSheetCSSOMWrapperSet, CSSDefaultStyleSheets::plugInsStyleSheet);
 
-        collectFromDocumentStyleSheetCollection(styleSheetCollection);
+        collectFromStyleSheets(authorStyleSheets.activeStyleSheets());
+        collect(extensionStyleSheets.pageUserSheet());
+        collectFromStyleSheets(extensionStyleSheets.injectedUserStyleSheets());
+        collectFromStyleSheets(extensionStyleSheets.documentUserStyleSheets());
     }
     return m_styleRuleToCSSOMWrapperMap.get(rule);
 }
index fc9652d..ba19d00 100644 (file)
 
 namespace WebCore {
 
+class AuthorStyleSheets;
 class CSSStyleRule;
 class CSSStyleSheet;
-class DocumentStyleSheetCollection;
+class ExtensionStyleSheets;
 class StyleRule;
 class StyleSheetContents;
 
@@ -41,7 +42,7 @@ class InspectorCSSOMWrappers {
 public:
     // WARNING. This will construct CSSOM wrappers for all style rules and cache them in a map for significant memory cost.
     // It is here to support inspector. Don't use for any regular engine functions.
-    CSSStyleRule* getWrapperForRuleInSheets(StyleRule*, DocumentStyleSheetCollection&);
+    CSSStyleRule* getWrapperForRuleInSheets(StyleRule*, AuthorStyleSheets&, ExtensionStyleSheets&);
     void collectFromStyleSheetIfNeeded(CSSStyleSheet*);
 
 private:
@@ -50,7 +51,6 @@ private:
 
     void collectFromStyleSheetContents(HashSet<RefPtr<CSSStyleSheet>>& sheetWrapperSet, StyleSheetContents*);
     void collectFromStyleSheets(const Vector<RefPtr<CSSStyleSheet>>&);
-    void collectFromDocumentStyleSheetCollection(DocumentStyleSheetCollection&);
 
     HashMap<StyleRule*, RefPtr<CSSStyleRule>> m_styleRuleToCSSOMWrapperMap;
     HashSet<RefPtr<CSSStyleSheet>> m_styleSheetCSSOMWrapperSet;
index aac6295..95cca34 100644 (file)
@@ -64,7 +64,6 @@
 #include "Counter.h"
 #include "CounterContent.h"
 #include "CursorList.h"
-#include "DocumentStyleSheetCollection.h"
 #include "ElementRuleCollector.h"
 #include "FilterOperation.h"
 #include "Frame.h"
@@ -301,8 +300,7 @@ StyleResolver::StyleResolver(Document& document, bool matchAuthorAndUserStyles)
 
     m_ruleSets.resetAuthorStyle();
 
-    DocumentStyleSheetCollection& styleSheetCollection = m_document.styleSheetCollection();
-    m_ruleSets.initUserStyle(styleSheetCollection, *m_medium, *this);
+    m_ruleSets.initUserStyle(m_document.extensionStyleSheets(), *m_medium, *this);
 
 #if ENABLE(SVG_FONTS)
     if (m_document.svgExtensions()) {
@@ -311,8 +309,6 @@ StyleResolver::StyleResolver(Document& document, bool matchAuthorAndUserStyles)
             m_document.fontSelector().addFontFaceRule(svgFontFaceElement->fontFaceRule(), svgFontFaceElement->isInUserAgentShadowTree());
     }
 #endif
-
-    appendAuthorStyleSheets(0, styleSheetCollection.activeAuthorStyleSheets());
 }
 
 void StyleResolver::appendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyleSheet>>& styleSheets)
index c2b9f42..c80ca12 100644 (file)
@@ -21,9 +21,9 @@
 #include "config.h"
 #include "StyleSheetList.h"
 
+#include "AuthorStyleSheets.h"
 #include "CSSStyleSheet.h"
 #include "Document.h"
-#include "DocumentStyleSheetCollection.h"
 #include "HTMLNames.h"
 #include "HTMLStyleElement.h"
 #include <wtf/text/WTFString.h>
@@ -45,13 +45,13 @@ inline const Vector<RefPtr<StyleSheet>>& StyleSheetList::styleSheets() const
 {
     if (!m_document)
         return m_detachedStyleSheets;
-    return m_document->styleSheetCollection().styleSheetsForStyleSheetList();
+    return m_document->authorStyleSheets().styleSheetsForStyleSheetList();
 }
 
 void StyleSheetList::detachFromDocument()
 {
-    m_detachedStyleSheets = m_document->styleSheetCollection().styleSheetsForStyleSheetList();
-    m_document = 0;
+    m_detachedStyleSheets = m_document->authorStyleSheets().styleSheetsForStyleSheetList();
+    m_document = nullptr;
 }
 
 unsigned StyleSheetList::length() const
@@ -3,7 +3,7 @@
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2001 Dirk Mueller (mueller@kde.org)
  *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2009, 2011-2012, 2015 Apple Inc. All rights reserved.
  * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
  * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
  */
 
 #include "config.h"
-#include "DocumentStyleSheetCollection.h"
+#include "AuthorStyleSheets.h"
 
 #include "CSSStyleSheet.h"
 #include "Element.h"
+#include "ExtensionStyleSheets.h"
 #include "HTMLIFrameElement.h"
 #include "HTMLLinkElement.h"
 #include "HTMLStyleElement.h"
@@ -53,193 +54,25 @@ namespace WebCore {
 using namespace ContentExtensions;
 using namespace HTMLNames;
 
-DocumentStyleSheetCollection::DocumentStyleSheetCollection(Document& document)
-    : m_document(document)
-    , m_pendingStylesheets(0)
-    , m_injectedStyleSheetCacheValid(false)
-    , m_hadActiveLoadingStylesheet(false)
-    , m_pendingUpdateType(NoUpdate)
-    , m_usesFirstLineRules(false)
-    , m_usesFirstLetterRules(false)
-    , m_usesRemUnits(false)
-    , m_usesStyleBasedEditability(false)
-    , m_styleResolverChangedTimer(*this, &DocumentStyleSheetCollection::styleResolverChangedTimerFired)
+AuthorStyleSheets::AuthorStyleSheets(TreeScope& treeScope)
+    : m_document(treeScope.documentScope())
 {
 }
 
-void DocumentStyleSheetCollection::combineCSSFeatureFlags()
-{
-    // Delay resetting the flags until after next style recalc since unapplying the style may not work without these set (this is true at least with before/after).
-    const StyleResolver& styleResolver = m_document.ensureStyleResolver();
-    m_usesFirstLineRules = m_usesFirstLineRules || styleResolver.usesFirstLineRules();
-    m_usesFirstLetterRules = m_usesFirstLetterRules || styleResolver.usesFirstLetterRules();
-}
-
-void DocumentStyleSheetCollection::resetCSSFeatureFlags()
-{
-    const StyleResolver& styleResolver = m_document.ensureStyleResolver();
-    m_usesFirstLineRules = styleResolver.usesFirstLineRules();
-    m_usesFirstLetterRules = styleResolver.usesFirstLetterRules();
-}
-
-CSSStyleSheet* DocumentStyleSheetCollection::pageUserSheet()
-{
-    if (m_pageUserSheet)
-        return m_pageUserSheet.get();
-    
-    Page* owningPage = m_document.page();
-    if (!owningPage)
-        return 0;
-    
-    String userSheetText = owningPage->userStyleSheet();
-    if (userSheetText.isEmpty())
-        return 0;
-    
-    // Parse the sheet and cache it.
-    m_pageUserSheet = CSSStyleSheet::createInline(m_document, m_document.settings()->userStyleSheetLocation());
-    m_pageUserSheet->contents().setIsUserStyleSheet(true);
-    m_pageUserSheet->contents().parseString(userSheetText);
-    return m_pageUserSheet.get();
-}
-
-void DocumentStyleSheetCollection::clearPageUserSheet()
-{
-    if (m_pageUserSheet) {
-        m_pageUserSheet = nullptr;
-        m_document.styleResolverChanged(DeferRecalcStyle);
-    }
-}
-
-void DocumentStyleSheetCollection::updatePageUserSheet()
-{
-    clearPageUserSheet();
-    if (pageUserSheet())
-        m_document.styleResolverChanged(RecalcStyleImmediately);
-}
-
-const Vector<RefPtr<CSSStyleSheet>>& DocumentStyleSheetCollection::injectedUserStyleSheets() const
-{
-    updateInjectedStyleSheetCache();
-    return m_injectedUserStyleSheets;
-}
-
-const Vector<RefPtr<CSSStyleSheet>>& DocumentStyleSheetCollection::injectedAuthorStyleSheets() const
-{
-    updateInjectedStyleSheetCache();
-    return m_injectedAuthorStyleSheets;
-}
-
-void DocumentStyleSheetCollection::updateInjectedStyleSheetCache() const
-{
-    if (m_injectedStyleSheetCacheValid)
-        return;
-    m_injectedStyleSheetCacheValid = true;
-    m_injectedUserStyleSheets.clear();
-    m_injectedAuthorStyleSheets.clear();
-
-    Page* owningPage = m_document.page();
-    if (!owningPage)
-        return;
-
-    const auto* userContentController = owningPage->userContentController();
-    if (!userContentController)
-        return;
-
-    const UserStyleSheetMap* userStyleSheets = userContentController->userStyleSheets();
-    if (!userStyleSheets)
-        return;
-
-    for (auto& styleSheets : userStyleSheets->values()) {
-        for (const auto& sheet : *styleSheets) {
-            if (sheet->injectedFrames() == InjectInTopFrameOnly && m_document.ownerElement())
-                continue;
-
-            if (!UserContentURLPattern::matchesPatterns(m_document.url(), sheet->whitelist(), sheet->blacklist()))
-                continue;
-
-            RefPtr<CSSStyleSheet> groupSheet = CSSStyleSheet::createInline(const_cast<Document&>(m_document), sheet->url());
-            bool isUserStyleSheet = sheet->level() == UserStyleUserLevel;
-            if (isUserStyleSheet)
-                m_injectedUserStyleSheets.append(groupSheet);
-            else
-                m_injectedAuthorStyleSheets.append(groupSheet);
-
-            groupSheet->contents().setIsUserStyleSheet(isUserStyleSheet);
-            groupSheet->contents().parseString(sheet->source());
-        }
-    }
-}
-
-void DocumentStyleSheetCollection::invalidateInjectedStyleSheetCache()
-{
-    if (!m_injectedStyleSheetCacheValid)
-        return;
-    m_injectedStyleSheetCacheValid = false;
-    if (m_injectedUserStyleSheets.isEmpty() && m_injectedAuthorStyleSheets.isEmpty())
-        return;
-    m_document.styleResolverChanged(DeferRecalcStyle);
-}
-
-void DocumentStyleSheetCollection::addAuthorSheet(Ref<StyleSheetContents>&& authorSheet)
-{
-    ASSERT(!authorSheet.get().isUserStyleSheet());
-    m_authorStyleSheets.append(CSSStyleSheet::create(WTF::move(authorSheet), &m_document));
-    m_document.styleResolverChanged(RecalcStyleImmediately);
-}
-
-void DocumentStyleSheetCollection::addUserSheet(Ref<StyleSheetContents>&& userSheet)
-{
-    ASSERT(userSheet.get().isUserStyleSheet());
-    m_userStyleSheets.append(CSSStyleSheet::create(WTF::move(userSheet), &m_document));
-    m_document.styleResolverChanged(RecalcStyleImmediately);
-}
-
-#if ENABLE(CONTENT_EXTENSIONS)
-void DocumentStyleSheetCollection::addDisplayNoneSelector(const String& identifier, const String& selector, uint32_t selectorID)
-{
-    auto result = m_contentExtensionSelectorSheets.add(identifier, nullptr);
-    if (result.isNewEntry) {
-        result.iterator->value = ContentExtensionStyleSheet::create(m_document);
-        m_userStyleSheets.append(&result.iterator->value->styleSheet());
-    }
-
-    result.iterator->value->addDisplayNoneSelector(selector, selectorID);
-    m_styleResolverChangedTimer.startOneShot(0);
-}
-
-void DocumentStyleSheetCollection::maybeAddContentExtensionSheet(const String& identifier, StyleSheetContents& sheet)
-{
-    ASSERT(sheet.isUserStyleSheet());
-
-    if (m_contentExtensionSheets.contains(identifier))
-        return;
-
-    Ref<CSSStyleSheet> cssSheet = CSSStyleSheet::create(sheet, &m_document);
-    m_contentExtensionSheets.set(identifier, &cssSheet.get());
-    m_userStyleSheets.append(adoptRef(cssSheet.leakRef()));
-    m_styleResolverChangedTimer.startOneShot(0);
-}
-#endif // ENABLE(CONTENT_EXTENSIONS)
-
-void DocumentStyleSheetCollection::styleResolverChangedTimerFired()
-{
-    m_document.styleResolverChanged(RecalcStyleImmediately);
-}
-
 // This method is called whenever a top-level stylesheet has finished loading.
-void DocumentStyleSheetCollection::removePendingSheet(RemovePendingSheetNotificationType notification)
+void AuthorStyleSheets::removePendingSheet(RemovePendingSheetNotificationType notification)
 {
     // Make sure we knew this sheet was pending, and that our count isn't out of sync.
-    ASSERT(m_pendingStylesheets > 0);
+    ASSERT(m_pendingStyleSheetCount > 0);
 
-    m_pendingStylesheets--;
+    m_pendingStyleSheetCount--;
     
 #ifdef INSTRUMENT_LAYOUT_SCHEDULING
     if (!ownerElement())
         printf("Stylesheet loaded at time %d. %d stylesheets still remain.\n", elapsedTime(), m_pendingStylesheets);
 #endif
 
-    if (m_pendingStylesheets)
+    if (m_pendingStyleSheetCount)
         return;
 
     if (notification == RemovePendingSheetNotifyLater) {
@@ -250,7 +83,7 @@ void DocumentStyleSheetCollection::removePendingSheet(RemovePendingSheetNotifica
     m_document.didRemoveAllPendingStylesheet();
 }
 
-void DocumentStyleSheetCollection::addStyleSheetCandidateNode(Node& node, bool createdByParser)
+void AuthorStyleSheets::addStyleSheetCandidateNode(Node& node, bool createdByParser)
 {
     if (!node.inDocument())
         return;
@@ -265,10 +98,10 @@ void DocumentStyleSheetCollection::addStyleSheetCandidateNode(Node& node, bool c
     }
 
     // Determine an appropriate insertion point.
-    StyleSheetCandidateListHashSet::iterator begin = m_styleSheetCandidateNodes.begin();
-    StyleSheetCandidateListHashSet::iterator end = m_styleSheetCandidateNodes.end();
-    StyleSheetCandidateListHashSet::iterator it = end;
-    Node* followingNode = 0;
+    auto begin = m_styleSheetCandidateNodes.begin();
+    auto end = m_styleSheetCandidateNodes.end();
+    auto it = end;
+    Node* followingNode = nullptr;
     do {
         --it;
         Node* n = *it;
@@ -283,12 +116,12 @@ void DocumentStyleSheetCollection::addStyleSheetCandidateNode(Node& node, bool c
     m_styleSheetCandidateNodes.insertBefore(followingNode, &node);
 }
 
-void DocumentStyleSheetCollection::removeStyleSheetCandidateNode(Node& node)
+void AuthorStyleSheets::removeStyleSheetCandidateNode(Node& node)
 {
     m_styleSheetCandidateNodes.remove(&node);
 }
 
-void DocumentStyleSheetCollection::collectActiveStyleSheets(Vector<RefPtr<StyleSheet>>& sheets)
+void AuthorStyleSheets::collectActiveStyleSheets(Vector<RefPtr<StyleSheet>>& sheets)
 {
     if (m_document.settings() && !m_document.settings()->authorAndUserStylesEnabled())
         return;
@@ -366,7 +199,7 @@ void DocumentStyleSheetCollection::collectActiveStyleSheets(Vector<RefPtr<StyleS
     }
 }
 
-void DocumentStyleSheetCollection::analyzeStyleSheetChange(UpdateFlag updateFlag, const Vector<RefPtr<CSSStyleSheet>>& newStylesheets, StyleResolverUpdateType& styleResolverUpdateType, bool& requiresFullStyleRecalc)
+void AuthorStyleSheets::analyzeStyleSheetChange(UpdateFlag updateFlag, const Vector<RefPtr<CSSStyleSheet>>& newStylesheets, StyleResolverUpdateType& styleResolverUpdateType, bool& requiresFullStyleRecalc)
 {
     styleResolverUpdateType = Reconstruct;
     requiresFullStyleRecalc = true;
@@ -391,7 +224,7 @@ void DocumentStyleSheetCollection::analyzeStyleSheetChange(UpdateFlag updateFlag
     StyleResolver& styleResolver = *m_document.styleResolverIfExists();
 
     // Find out which stylesheets are new.
-    unsigned oldStylesheetCount = m_activeAuthorStyleSheets.size();
+    unsigned oldStylesheetCount = m_activeStyleSheets.size();
     if (newStylesheetCount < oldStylesheetCount)
         return;
     Vector<StyleSheetContents*> addedSheets;
@@ -399,7 +232,7 @@ void DocumentStyleSheetCollection::analyzeStyleSheetChange(UpdateFlag updateFlag
     for (unsigned oldIndex = 0; oldIndex < oldStylesheetCount; ++oldIndex) {
         if (newIndex >= newStylesheetCount)
             return;
-        while (m_activeAuthorStyleSheets[oldIndex] != newStylesheets[newIndex]) {
+        while (m_activeStyleSheets[oldIndex] != newStylesheets[newIndex]) {
             addedSheets.append(&newStylesheets[newIndex]->contents());
             ++newIndex;
             if (newIndex == newStylesheetCount)
@@ -440,7 +273,7 @@ static void filterEnabledNonemptyCSSStyleSheets(Vector<RefPtr<CSSStyleSheet>>& r
     }
 }
 
-bool DocumentStyleSheetCollection::updateActiveStyleSheets(UpdateFlag updateFlag)
+bool AuthorStyleSheets::updateActiveStyleSheets(UpdateFlag updateFlag)
 {
     if (m_document.inStyleRecalc()) {
         // SVG <use> element may manage to invalidate style selector in the middle of a style recalc.
@@ -458,8 +291,8 @@ bool DocumentStyleSheetCollection::updateActiveStyleSheets(UpdateFlag updateFlag
     collectActiveStyleSheets(activeStyleSheets);
 
     Vector<RefPtr<CSSStyleSheet>> activeCSSStyleSheets;
-    activeCSSStyleSheets.appendVector(injectedAuthorStyleSheets());
-    activeCSSStyleSheets.appendVector(documentAuthorStyleSheets());
+    activeCSSStyleSheets.appendVector(m_document.extensionStyleSheets().injectedAuthorStyleSheets());
+    activeCSSStyleSheets.appendVector(m_document.extensionStyleSheets().authorStyleSheetsForTesting());
     filterEnabledNonemptyCSSStyleSheets(activeCSSStyleSheets, activeStyleSheets);
 
     StyleResolverUpdateType styleResolverUpdateType;
@@ -475,18 +308,17 @@ bool DocumentStyleSheetCollection::updateActiveStyleSheets(UpdateFlag updateFlag
             styleResolver.appendAuthorStyleSheets(0, activeCSSStyleSheets);
         } else {
             ASSERT(styleResolverUpdateType == Additive);
-            styleResolver.appendAuthorStyleSheets(m_activeAuthorStyleSheets.size(), activeCSSStyleSheets);
+            styleResolver.appendAuthorStyleSheets(m_activeStyleSheets.size(), activeCSSStyleSheets);
         }
-        resetCSSFeatureFlags();
     }
 
     m_weakCopyOfActiveStyleSheetListForFastLookup = nullptr;
-    m_activeAuthorStyleSheets.swap(activeCSSStyleSheets);
+    m_activeStyleSheets.swap(activeCSSStyleSheets);
     m_styleSheetsForStyleSheetList.swap(activeStyleSheets);
 
     InspectorInstrumentation::activeStyleSheetsUpdated(m_document);
 
-    for (const auto& sheet : m_activeAuthorStyleSheets) {
+    for (const auto& sheet : m_activeStyleSheets) {
         if (sheet->contents().usesRemUnits())
             m_usesRemUnits = true;
         if (sheet->contents().usesStyleBasedEditability())
@@ -497,12 +329,12 @@ bool DocumentStyleSheetCollection::updateActiveStyleSheets(UpdateFlag updateFlag
     return requiresFullStyleRecalc;
 }
 
-const Vector<RefPtr<CSSStyleSheet>> DocumentStyleSheetCollection::activeStyleSheetsForInspector() const
+const Vector<RefPtr<CSSStyleSheet>> AuthorStyleSheets::activeStyleSheetsForInspector() const
 {
     Vector<RefPtr<CSSStyleSheet>> result;
 
-    result.appendVector(injectedAuthorStyleSheets());
-    result.appendVector(documentAuthorStyleSheets());
+    result.appendVector(m_document.extensionStyleSheets().injectedAuthorStyleSheets());
+    result.appendVector(m_document.extensionStyleSheets().authorStyleSheetsForTesting());
 
     for (auto& styleSheet : m_styleSheetsForStyleSheetList) {
         if (!is<CSSStyleSheet>(*styleSheet))
@@ -518,28 +350,14 @@ const Vector<RefPtr<CSSStyleSheet>> DocumentStyleSheetCollection::activeStyleShe
     return result;
 }
 
-bool DocumentStyleSheetCollection::activeStyleSheetsContains(const CSSStyleSheet* sheet) const
+bool AuthorStyleSheets::activeStyleSheetsContains(const CSSStyleSheet* sheet) const
 {
     if (!m_weakCopyOfActiveStyleSheetListForFastLookup) {
         m_weakCopyOfActiveStyleSheetListForFastLookup = std::make_unique<HashSet<const CSSStyleSheet*>>();
-        for (unsigned i = 0; i < m_activeAuthorStyleSheets.size(); ++i)
-            m_weakCopyOfActiveStyleSheetListForFastLookup->add(m_activeAuthorStyleSheets[i].get());
+        for (unsigned i = 0; i < m_activeStyleSheets.size(); ++i)
+            m_weakCopyOfActiveStyleSheetListForFastLookup->add(m_activeStyleSheets[i].get());
     }
     return m_weakCopyOfActiveStyleSheetListForFastLookup->contains(sheet);
 }
 
-void DocumentStyleSheetCollection::detachFromDocument()
-{
-    if (m_pageUserSheet)
-        m_pageUserSheet->detachFromDocument();
-    for (unsigned i = 0; i < m_injectedUserStyleSheets.size(); ++i)
-        m_injectedUserStyleSheets[i]->detachFromDocument();
-    for (unsigned i = 0; i < m_injectedAuthorStyleSheets.size(); ++i)
-        m_injectedAuthorStyleSheets[i]->detachFromDocument();
-    for (unsigned i = 0; i < m_userStyleSheets.size(); ++i)
-        m_userStyleSheets[i]->detachFromDocument();
-    for (unsigned i = 0; i < m_authorStyleSheets.size(); ++i)
-        m_authorStyleSheets[i]->detachFromDocument();
-}
-
 }
similarity index 59%
rename from Source/WebCore/dom/DocumentStyleSheetCollection.h
rename to Source/WebCore/dom/AuthorStyleSheets.h
index 79dde5a..5e99bad 100644 (file)
@@ -3,7 +3,7 @@
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2001 Dirk Mueller (mueller@kde.org)
  *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2010, 2012-2013, 2015 Apple Inc. All rights reserved.
  * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
  * Copyright (C) 2011 Google Inc. All rights reserved.
@@ -25,8 +25,8 @@
  *
  */
 
-#ifndef DocumentStyleSheetCollection_h
-#define DocumentStyleSheetCollection_h
+#ifndef AuthorStyleSheets_h
+#define AuthorStyleSheets_h
 
 #include "Timer.h"
 #include <memory>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
 
-#if ENABLE(CONTENT_EXTENSIONS)
-#include "ContentExtensionStyleSheet.h"
-#endif
-
 namespace WebCore {
 
 class CSSStyleSheet;
@@ -49,40 +45,21 @@ class Node;
 class StyleSheet;
 class StyleSheetContents;
 class StyleSheetList;
+class TreeScope;
 
-class DocumentStyleSheetCollection {
+class AuthorStyleSheets {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    explicit DocumentStyleSheetCollection(Document&);
+    explicit AuthorStyleSheets(TreeScope&);
 
-    const Vector<RefPtr<StyleSheet>>& styleSheetsForStyleSheetList() const { return m_styleSheetsForStyleSheetList; }
-
-    const Vector<RefPtr<CSSStyleSheet>>& activeAuthorStyleSheets() const { return m_activeAuthorStyleSheets; }
+    const Vector<RefPtr<CSSStyleSheet>>& activeStyleSheets() const { return m_activeStyleSheets; }
 
+    const Vector<RefPtr<StyleSheet>>& styleSheetsForStyleSheetList() const { return m_styleSheetsForStyleSheetList; }
     const Vector<RefPtr<CSSStyleSheet>> activeStyleSheetsForInspector() const;
 
-    CSSStyleSheet* pageUserSheet();
-    const Vector<RefPtr<CSSStyleSheet>>& documentUserStyleSheets() const { return m_userStyleSheets; }
-    const Vector<RefPtr<CSSStyleSheet>>& documentAuthorStyleSheets() const { return m_authorStyleSheets; }
-    const Vector<RefPtr<CSSStyleSheet>>& injectedUserStyleSheets() const;
-    const Vector<RefPtr<CSSStyleSheet>>& injectedAuthorStyleSheets() const;
-
     void addStyleSheetCandidateNode(Node&, bool createdByParser);
     void removeStyleSheetCandidateNode(Node&);
 
-    void clearPageUserSheet();
-    void updatePageUserSheet();
-    void invalidateInjectedStyleSheetCache();
-    void updateInjectedStyleSheetCache() const;
-
-    WEBCORE_EXPORT void addAuthorSheet(Ref<StyleSheetContents>&& authorSheet);
-    WEBCORE_EXPORT void addUserSheet(Ref<StyleSheetContents>&& userSheet);
-
-#if ENABLE(CONTENT_EXTENSIONS)
-    void addDisplayNoneSelector(const String& identifier, const String& selector, uint32_t selectorID);
-    void maybeAddContentExtensionSheet(const String& identifier, StyleSheetContents&);
-#endif
-
     enum UpdateFlag { NoUpdate = 0, OptimizedUpdate, FullUpdate };
 
     UpdateFlag pendingUpdateType() const { return m_pendingUpdateType; }
@@ -105,29 +82,21 @@ public:
     void setPreferredStylesheetSetName(const String& name) { m_preferredStylesheetSetName = name; }
     void setSelectedStylesheetSetName(const String& name) { m_selectedStylesheetSetName = name; }
 
-    void addPendingSheet() { m_pendingStylesheets++; }
+    void addPendingSheet() { m_pendingStyleSheetCount++; }
     enum RemovePendingSheetNotificationType {
         RemovePendingSheetNotifyImmediately,
         RemovePendingSheetNotifyLater
     };
     void removePendingSheet(RemovePendingSheetNotificationType = RemovePendingSheetNotifyImmediately);
 
-    bool hasPendingSheets() const { return m_pendingStylesheets > 0; }
+    bool hasPendingSheets() const { return m_pendingStyleSheetCount > 0; }
 
-    bool usesFirstLineRules() const { return m_usesFirstLineRules; }
-    bool usesFirstLetterRules() const { return m_usesFirstLetterRules; }
     bool usesRemUnits() const { return m_usesRemUnits; }
     void setUsesRemUnit(bool b) { m_usesRemUnits = b; }
     bool usesStyleBasedEditability() { return m_usesStyleBasedEditability; }
-    void setUsesStyleBasedEditability(bool b) { m_usesStyleBasedEditability = b; }
-
-    void combineCSSFeatureFlags();
-    void resetCSSFeatureFlags();
 
     bool activeStyleSheetsContains(const CSSStyleSheet*) const;
 
-    void detachFromDocument();
-
 private:
     void collectActiveStyleSheets(Vector<RefPtr<StyleSheet>>&);
     enum StyleResolverUpdateType {
@@ -137,12 +106,10 @@ private:
     };
     void analyzeStyleSheetChange(UpdateFlag, const Vector<RefPtr<CSSStyleSheet>>& newStylesheets, StyleResolverUpdateType&, bool& requiresFullStyleRecalc);
 
-    void styleResolverChangedTimerFired();
-
     Document& m_document;
 
     Vector<RefPtr<StyleSheet>> m_styleSheetsForStyleSheetList;
-    Vector<RefPtr<CSSStyleSheet>> m_activeAuthorStyleSheets;
+    Vector<RefPtr<CSSStyleSheet>> m_activeStyleSheets;
 
     // This is a mirror of m_activeAuthorStyleSheets that gets populated on demand for activeStyleSheetsContains().
     mutable std::unique_ptr<HashSet<const CSSStyleSheet*>> m_weakCopyOfActiveStyleSheetListForFastLookup;
@@ -151,37 +118,18 @@ private:
     // Sheets loaded using the @import directive are not included in this count.
     // We use this count of pending sheets to detect when we can begin attaching
     // elements and when it is safe to execute scripts.
-    int m_pendingStylesheets;
+    int m_pendingStyleSheetCount { 0 };
 
-    RefPtr<CSSStyleSheet> m_pageUserSheet;
+    bool m_hadActiveLoadingStylesheet { false };
+    UpdateFlag m_pendingUpdateType { NoUpdate };
 
-    mutable Vector<RefPtr<CSSStyleSheet>> m_injectedUserStyleSheets;
-    mutable Vector<RefPtr<CSSStyleSheet>> m_injectedAuthorStyleSheets;
-    mutable bool m_injectedStyleSheetCacheValid;
-
-    Vector<RefPtr<CSSStyleSheet>> m_userStyleSheets;
-    Vector<RefPtr<CSSStyleSheet>> m_authorStyleSheets;
-
-#if ENABLE(CONTENT_EXTENSIONS)
-    HashMap<String, RefPtr<CSSStyleSheet>> m_contentExtensionSheets;
-    HashMap<String, RefPtr<ContentExtensions::ContentExtensionStyleSheet>> m_contentExtensionSelectorSheets;
-#endif
-
-    bool m_hadActiveLoadingStylesheet;
-    UpdateFlag m_pendingUpdateType;
-
-    typedef ListHashSet<Node*> StyleSheetCandidateListHashSet;
-    StyleSheetCandidateListHashSet m_styleSheetCandidateNodes;
+    ListHashSet<Node*> m_styleSheetCandidateNodes;
 
     String m_preferredStylesheetSetName;
     String m_selectedStylesheetSetName;
 
-    bool m_usesFirstLineRules;
-    bool m_usesFirstLetterRules;
-    bool m_usesRemUnits;
-    bool m_usesStyleBasedEditability;
-
-    Timer m_styleResolverChangedTimer;
+    bool m_usesRemUnits { false };
+    bool m_usesStyleBasedEditability { false };
 };
 
 }
index dccf0b8..e7ed744 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "ActiveDOMObject.cpp"
 #include "AnimationEvent.cpp"
+#include "AuthorStyleSheets.cpp"
 #include "Attr.cpp"
 #include "BeforeTextInsertedEvent.cpp"
 #include "BeforeUnloadEvent.cpp"
@@ -69,7 +70,6 @@
 #include "DocumentOrderedMap.cpp"
 #include "DocumentParser.cpp"
 #include "DocumentSharedObjectPool.cpp"
-#include "DocumentStyleSheetCollection.cpp"
 #include "DocumentType.cpp"
 #include "Element.cpp"
 #include "ElementData.cpp"
@@ -85,6 +85,7 @@
 #include "EventTarget.cpp"
 #include "ExceptionBase.cpp"
 #include "ExceptionCodePlaceholder.cpp"
+#include "ExtensionStyleSheets.cpp"
 #include "FocusEvent.cpp"
 #include "GenericEventQueue.cpp"
 #include "IdTargetObserver.cpp"
index b93e053..7b11e39 100644 (file)
@@ -31,6 +31,7 @@
 #include "AXObjectCache.h"
 #include "AnimationController.h"
 #include "Attr.h"
+#include "AuthorStyleSheets.h"
 #include "CDATASection.h"
 #include "CSSFontSelector.h"
 #include "CSSStyleDeclaration.h"
@@ -57,6 +58,7 @@
 #include "EntityReference.h"
 #include "EventFactory.h"
 #include "EventHandler.h"
+#include "ExtensionStyleSheets.h"
 #include "FocusController.h"
 #include "FontLoader.h"
 #include "FormController.h"
@@ -439,7 +441,8 @@ Document::Document(Frame* frame, const URL& url, unsigned documentClasses, unsig
     , m_domTreeVersion(++s_globalTreeVersion)
     , m_listenerTypes(0)
     , m_mutationObserverTypes(0)
-    , m_styleSheetCollection(*this)
+    , m_authorStyleSheets(std::make_unique<AuthorStyleSheets>(*this))
+    , m_extensionStyleSheets(std::make_unique<ExtensionStyleSheets>(*this))
     , m_visitedLinkState(std::make_unique<VisitedLinkState>(*this))
     , m_visuallyOrdered(false)
     , m_readyState(Complete)
@@ -624,7 +627,7 @@ Document::~Document()
 
     if (m_elementSheet)
         m_elementSheet->detachFromDocument();
-    m_styleSheetCollection.detachFromDocument();
+    extensionStyleSheets().detachFromDocument();
 
     clearStyleResolver(); // We need to destroy CSSFontSelector before destroying m_cachedResourceLoader.
 
@@ -791,8 +794,8 @@ void Document::setCompatibilityMode(DocumentCompatibilityMode mode)
 
     if (inQuirksMode() != wasInQuirksMode) {
         // All user stylesheets have to reparse using the different mode.
-        m_styleSheetCollection.clearPageUserSheet();
-        m_styleSheetCollection.invalidateInjectedStyleSheetCache();
+        extensionStyleSheets().clearPageUserSheet();
+        extensionStyleSheets().invalidateInjectedStyleSheetCache();
     }
 }
 
@@ -1810,7 +1813,7 @@ void Document::recalcStyle(Style::Change change)
     // re-attaching our containing iframe, which when asked HTMLFrameElementBase::isURLAllowed
     // hits a null-dereference due to security code always assuming the document has a SecurityOrigin.
 
-    m_styleSheetCollection.flushPendingUpdates();
+    authorStyleSheets().flushPendingUpdates();
 
     frameView.willRecalcStyle();
 
@@ -1818,7 +1821,7 @@ void Document::recalcStyle(Style::Change change)
 
     // FIXME: We never reset this flags.
     if (m_elementSheet && m_elementSheet->contents().usesRemUnits())
-        m_styleSheetCollection.setUsesRemUnit(true);
+        authorStyleSheets().setUsesRemUnit(true);
     // We don't call setUsesStyleBasedEditability here because the whole point of the flag is to avoid style recalc.
     // i.e. updating the flag here would be too late.
 
@@ -1845,10 +1848,6 @@ void Document::recalcStyle(Style::Change change)
         unscheduleStyleRecalc();
 
         m_inStyleRecalc = false;
-
-        // Pseudo element removal and similar may only work with these flags still set. Reset them after the style recalc.
-        if (m_styleResolver)
-            m_styleSheetCollection.resetCSSFeatureFlags();
     }
 
     // If we wanted to call implicitClose() during recalcStyle, do so now that we're finished.
@@ -2117,7 +2116,7 @@ void Document::createStyleResolver()
     if (Settings* settings = this->settings())
         matchAuthorAndUserStyles = settings->authorAndUserStylesEnabled();
     m_styleResolver = std::make_unique<StyleResolver>(*this, matchAuthorAndUserStyles);
-    m_styleSheetCollection.combineCSSFeatureFlags();
+    m_styleResolver->appendAuthorStyleSheets(0, authorStyleSheets().activeStyleSheets());
 }
 
 void Document::fontsNeedUpdate(FontSelector&)
@@ -3077,9 +3076,9 @@ bool Document::usesStyleBasedEditability() const
     ASSERT(!m_renderView || !m_renderView->frameView().isPainting());
     ASSERT(!m_inStyleRecalc);
 
-    auto& collection = document().styleSheetCollection();
-    collection.flushPendingUpdates();
-    return collection.usesStyleBasedEditability();
+    auto& authorSheets = const_cast<AuthorStyleSheets&>(authorStyleSheets());
+    authorSheets.flushPendingUpdates();
+    return authorSheets.usesStyleBasedEditability();
 }
 
 void Document::processHttpEquiv(const String& equiv, const String& content)
@@ -3119,8 +3118,8 @@ void Document::processHttpEquiv(const String& equiv, const String& content)
         // For more info, see the test at:
         // http://www.hixie.ch/tests/evil/css/import/main/preferred.html
         // -dwh
-        m_styleSheetCollection.setSelectedStylesheetSetName(content);
-        m_styleSheetCollection.setPreferredStylesheetSetName(content);
+        authorStyleSheets().setSelectedStylesheetSetName(content);
+        authorStyleSheets().setPreferredStylesheetSetName(content);
         styleResolverChanged(DeferRecalcStyle);
         break;
 
@@ -3473,17 +3472,17 @@ StyleSheetList& Document::styleSheets()
 
 String Document::preferredStylesheetSet() const
 {
-    return m_styleSheetCollection.preferredStylesheetSetName();
+    return authorStyleSheets().preferredStylesheetSetName();
 }
 
 String Document::selectedStylesheetSet() const
 {
-    return m_styleSheetCollection.selectedStylesheetSetName();
+    return authorStyleSheets().selectedStylesheetSetName();
 }
 
 void Document::setSelectedStylesheetSet(const String& aString)
 {
-    m_styleSheetCollection.setSelectedStylesheetSetName(aString);
+    authorStyleSheets().setSelectedStylesheetSetName(aString);
     styleResolverChanged(DeferRecalcStyle);
 }
 
@@ -3502,7 +3501,7 @@ void Document::scheduleOptimizedStyleSheetUpdate()
 {
     if (m_optimizedStyleSheetUpdateTimer.isActive())
         return;
-    m_styleSheetCollection.setPendingUpdateType(DocumentStyleSheetCollection::OptimizedUpdate);
+    authorStyleSheets().setPendingUpdateType(AuthorStyleSheets::OptimizedUpdate);
     m_optimizedStyleSheetUpdateTimer.startOneShot(0);
 }
 
@@ -3589,10 +3588,10 @@ void Document::styleResolverChanged(StyleResolverUpdateFlag updateFlag)
         printf("Beginning update of style selector at time %lld.\n", elapsedTime().count());
 #endif
 
-    DocumentStyleSheetCollection::UpdateFlag styleSheetUpdate = (updateFlag == RecalcStyleIfNeeded || updateFlag == DeferRecalcStyleIfNeeded)
-        ? DocumentStyleSheetCollection::OptimizedUpdate
-        : DocumentStyleSheetCollection::FullUpdate;
-    bool stylesheetChangeRequiresStyleRecalc = m_styleSheetCollection.updateActiveStyleSheets(styleSheetUpdate);
+    auto styleSheetUpdate = (updateFlag == RecalcStyleIfNeeded || updateFlag == DeferRecalcStyleIfNeeded)
+        ? AuthorStyleSheets::OptimizedUpdate
+        : AuthorStyleSheets::FullUpdate;
+    bool stylesheetChangeRequiresStyleRecalc = authorStyleSheets().updateActiveStyleSheets(styleSheetUpdate);
 
     if (updateFlag == DeferRecalcStyle) {
         scheduleForcedStyleRecalc();
@@ -6487,7 +6486,7 @@ void Document::updateHoverActiveState(const HitTestRequest& request, Element* in
 
 bool Document::haveStylesheetsLoaded() const
 {
-    return !m_styleSheetCollection.hasPendingSheets() || m_ignorePendingStylesheets;
+    return !authorStyleSheets().hasPendingSheets() || m_ignorePendingStylesheets;
 }
 
 Locale& Document::getCachedLocale(const AtomicString& locale)
index 781ef20..f918089 100644 (file)
@@ -3,7 +3,7 @@
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2001 Dirk Mueller (mueller@kde.org)
  *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2010, 2012-2013, 2015 Apple Inc. All rights reserved.
  * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
  * Copyright (C) 2011 Google Inc. All rights reserved.
@@ -32,7 +32,6 @@
 #include "Color.h"
 #include "ContainerNode.h"
 #include "DocumentEventQueue.h"
-#include "DocumentStyleSheetCollection.h"
 #include "DocumentTiming.h"
 #include "FocusDirection.h"
 #include "FontSelector.h"
@@ -70,6 +69,7 @@ namespace WebCore {
 
 class AXObjectCache;
 class Attr;
+class AuthorStyleSheets;
 class CDATASection;
 class CSSFontSelector;
 class CSSStyleDeclaration;
@@ -97,6 +97,7 @@ class Element;
 class EntityReference;
 class Event;
 class EventListener;
+class ExtensionStyleSheets;
 class FloatRect;
 class FloatQuad;
 class FormController;
@@ -503,7 +504,10 @@ public:
     // This is a DOM function.
     StyleSheetList& styleSheets();
 
-    DocumentStyleSheetCollection& styleSheetCollection() { return m_styleSheetCollection; }
+    AuthorStyleSheets& authorStyleSheets() { return *m_authorStyleSheets; }
+    const AuthorStyleSheets& authorStyleSheets() const { return *m_authorStyleSheets; }
+    ExtensionStyleSheets& extensionStyleSheets() { return *m_extensionStyleSheets; }
+    const ExtensionStyleSheets& extensionStyleSheets() const { return *m_extensionStyleSheets; }
 
     bool gotoAnchorNeededAfterStylesheetsLoad() { return m_gotoAnchorNeededAfterStylesheetsLoad; }
     void setGotoAnchorNeededAfterStylesheetsLoad(bool b) { m_gotoAnchorNeededAfterStylesheetsLoad = b; }
@@ -1459,7 +1463,8 @@ private:
 
     MutationObserverOptions m_mutationObserverTypes;
 
-    DocumentStyleSheetCollection m_styleSheetCollection;
+    std::unique_ptr<AuthorStyleSheets> m_authorStyleSheets;
+    std::unique_ptr<ExtensionStyleSheets> m_extensionStyleSheets;
     RefPtr<StyleSheetList> m_styleSheetList;
 
     std::unique_ptr<FormController> m_formController;
diff --git a/Source/WebCore/dom/ExtensionStyleSheets.cpp b/Source/WebCore/dom/ExtensionStyleSheets.cpp
new file mode 100644 (file)
index 0000000..4a9affe
--- /dev/null
@@ -0,0 +1,220 @@
+/*
+ * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
+ *           (C) 1999 Antti Koivisto (koivisto@kde.org)
+ *           (C) 2001 Dirk Mueller (mueller@kde.org)
+ *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
+ * Copyright (C) 2004-2009, 2011-2012, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
+ * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "ExtensionStyleSheets.h"
+
+#include "CSSStyleSheet.h"
+#include "Element.h"
+#include "HTMLIFrameElement.h"
+#include "HTMLLinkElement.h"
+#include "HTMLStyleElement.h"
+#include "InspectorInstrumentation.h"
+#include "Page.h"
+#include "PageGroup.h"
+#include "ProcessingInstruction.h"
+#include "SVGNames.h"
+#include "SVGStyleElement.h"
+#include "Settings.h"
+#include "StyleInvalidationAnalysis.h"
+#include "StyleResolver.h"
+#include "StyleSheetContents.h"
+#include "StyleSheetList.h"
+#include "UserContentController.h"
+#include "UserContentURLPattern.h"
+#include "UserStyleSheet.h"
+
+namespace WebCore {
+
+using namespace ContentExtensions;
+using namespace HTMLNames;
+
+ExtensionStyleSheets::ExtensionStyleSheets(Document& document)
+    : m_document(document)
+    , m_styleResolverChangedTimer(*this, &ExtensionStyleSheets::styleResolverChangedTimerFired)
+{
+}
+
+CSSStyleSheet* ExtensionStyleSheets::pageUserSheet()
+{
+    if (m_pageUserSheet)
+        return m_pageUserSheet.get();
+    
+    Page* owningPage = m_document.page();
+    if (!owningPage)
+        return 0;
+    
+    String userSheetText = owningPage->userStyleSheet();
+    if (userSheetText.isEmpty())
+        return 0;
+    
+    // Parse the sheet and cache it.
+    m_pageUserSheet = CSSStyleSheet::createInline(m_document, m_document.settings()->userStyleSheetLocation());
+    m_pageUserSheet->contents().setIsUserStyleSheet(true);
+    m_pageUserSheet->contents().parseString(userSheetText);
+    return m_pageUserSheet.get();
+}
+
+void ExtensionStyleSheets::clearPageUserSheet()
+{
+    if (m_pageUserSheet) {
+        m_pageUserSheet = nullptr;
+        m_document.styleResolverChanged(DeferRecalcStyle);
+    }
+}
+
+void ExtensionStyleSheets::updatePageUserSheet()
+{
+    clearPageUserSheet();
+    if (pageUserSheet())
+        m_document.styleResolverChanged(RecalcStyleImmediately);
+}
+
+const Vector<RefPtr<CSSStyleSheet>>& ExtensionStyleSheets::injectedUserStyleSheets() const
+{
+    updateInjectedStyleSheetCache();
+    return m_injectedUserStyleSheets;
+}
+
+const Vector<RefPtr<CSSStyleSheet>>& ExtensionStyleSheets::injectedAuthorStyleSheets() const
+{
+    updateInjectedStyleSheetCache();
+    return m_injectedAuthorStyleSheets;
+}
+
+void ExtensionStyleSheets::updateInjectedStyleSheetCache() const
+{
+    if (m_injectedStyleSheetCacheValid)
+        return;
+    m_injectedStyleSheetCacheValid = true;
+    m_injectedUserStyleSheets.clear();
+    m_injectedAuthorStyleSheets.clear();
+
+    Page* owningPage = m_document.page();
+    if (!owningPage)
+        return;
+
+    const auto* userContentController = owningPage->userContentController();
+    if (!userContentController)
+        return;
+
+    const UserStyleSheetMap* userStyleSheets = userContentController->userStyleSheets();
+    if (!userStyleSheets)
+        return;
+
+    for (auto& styleSheets : userStyleSheets->values()) {
+        for (const auto& sheet : *styleSheets) {
+            if (sheet->injectedFrames() == InjectInTopFrameOnly && m_document.ownerElement())
+                continue;
+
+            if (!UserContentURLPattern::matchesPatterns(m_document.url(), sheet->whitelist(), sheet->blacklist()))
+                continue;
+
+            RefPtr<CSSStyleSheet> groupSheet = CSSStyleSheet::createInline(const_cast<Document&>(m_document), sheet->url());
+            bool isUserStyleSheet = sheet->level() == UserStyleUserLevel;
+            if (isUserStyleSheet)
+                m_injectedUserStyleSheets.append(groupSheet);
+            else
+                m_injectedAuthorStyleSheets.append(groupSheet);
+
+            groupSheet->contents().setIsUserStyleSheet(isUserStyleSheet);
+            groupSheet->contents().parseString(sheet->source());
+        }
+    }
+}
+
+void ExtensionStyleSheets::invalidateInjectedStyleSheetCache()
+{
+    if (!m_injectedStyleSheetCacheValid)
+        return;
+    m_injectedStyleSheetCacheValid = false;
+    if (m_injectedUserStyleSheets.isEmpty() && m_injectedAuthorStyleSheets.isEmpty())
+        return;
+    m_document.styleResolverChanged(DeferRecalcStyle);
+}
+
+void ExtensionStyleSheets::addUserStyleSheet(Ref<StyleSheetContents>&& userSheet)
+{
+    ASSERT(userSheet.get().isUserStyleSheet());
+    m_userStyleSheets.append(CSSStyleSheet::create(WTF::move(userSheet), &m_document));
+    m_document.styleResolverChanged(RecalcStyleImmediately);
+}
+
+void ExtensionStyleSheets::addAuthorStyleSheetForTesting(Ref<StyleSheetContents>&& authorSheet)
+{
+    ASSERT(!authorSheet.get().isUserStyleSheet());
+    m_authorStyleSheetsForTesting.append(CSSStyleSheet::create(WTF::move(authorSheet), &m_document));
+    m_document.styleResolverChanged(RecalcStyleImmediately);
+}
+
+#if ENABLE(CONTENT_EXTENSIONS)
+void ExtensionStyleSheets::addDisplayNoneSelector(const String& identifier, const String& selector, uint32_t selectorID)
+{
+    auto result = m_contentExtensionSelectorSheets.add(identifier, nullptr);
+    if (result.isNewEntry) {
+        result.iterator->value = ContentExtensionStyleSheet::create(m_document);
+        m_userStyleSheets.append(&result.iterator->value->styleSheet());
+    }
+
+    result.iterator->value->addDisplayNoneSelector(selector, selectorID);
+    m_styleResolverChangedTimer.startOneShot(0);
+}
+
+void ExtensionStyleSheets::maybeAddContentExtensionSheet(const String& identifier, StyleSheetContents& sheet)
+{
+    ASSERT(sheet.isUserStyleSheet());
+
+    if (m_contentExtensionSheets.contains(identifier))
+        return;
+
+    Ref<CSSStyleSheet> cssSheet = CSSStyleSheet::create(sheet, &m_document);
+    m_contentExtensionSheets.set(identifier, &cssSheet.get());
+    m_userStyleSheets.append(adoptRef(cssSheet.leakRef()));
+    m_styleResolverChangedTimer.startOneShot(0);
+}
+#endif // ENABLE(CONTENT_EXTENSIONS)
+
+void ExtensionStyleSheets::styleResolverChangedTimerFired()
+{
+    m_document.styleResolverChanged(RecalcStyleImmediately);
+}
+
+void ExtensionStyleSheets::detachFromDocument()
+{
+    if (m_pageUserSheet)
+        m_pageUserSheet->detachFromDocument();
+    for (auto& sheet : m_injectedUserStyleSheets)
+        sheet->detachFromDocument();
+    for (auto& sheet :  m_injectedAuthorStyleSheets)
+        sheet->detachFromDocument();
+    for (auto& sheet : m_userStyleSheets)
+        sheet->detachFromDocument();
+    for (auto& sheet : m_authorStyleSheetsForTesting)
+        sheet->detachFromDocument();
+}
+
+}
diff --git a/Source/WebCore/dom/ExtensionStyleSheets.h b/Source/WebCore/dom/ExtensionStyleSheets.h
new file mode 100644 (file)
index 0000000..3fae5a1
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
+ *           (C) 1999 Antti Koivisto (koivisto@kde.org)
+ *           (C) 2001 Dirk Mueller (mueller@kde.org)
+ *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
+ * Copyright (C) 2004-2010, 2012-2013, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ExtensionStyleSheets_h
+#define ExtensionStyleSheets_h
+
+#include "Timer.h"
+#include <memory>
+#include <wtf/FastMalloc.h>
+#include <wtf/HashMap.h>
+#include <wtf/ListHashSet.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+#if ENABLE(CONTENT_EXTENSIONS)
+#include "ContentExtensionStyleSheet.h"
+#endif
+
+namespace WebCore {
+
+class CSSStyleSheet;
+class Document;
+class Node;
+class StyleSheet;
+class StyleSheetContents;
+class StyleSheetList;
+
+class ExtensionStyleSheets {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    explicit ExtensionStyleSheets(Document&);
+
+    CSSStyleSheet* pageUserSheet();
+    const Vector<RefPtr<CSSStyleSheet>>& documentUserStyleSheets() const { return m_userStyleSheets; }
+    const Vector<RefPtr<CSSStyleSheet>>& injectedUserStyleSheets() const;
+    const Vector<RefPtr<CSSStyleSheet>>& injectedAuthorStyleSheets() const;
+    const Vector<RefPtr<CSSStyleSheet>>& authorStyleSheetsForTesting() const { return m_authorStyleSheetsForTesting; }
+
+    void clearPageUserSheet();
+    void updatePageUserSheet();
+    void invalidateInjectedStyleSheetCache();
+    void updateInjectedStyleSheetCache() const;
+
+    WEBCORE_EXPORT void addUserStyleSheet(Ref<StyleSheetContents>&&);
+
+    WEBCORE_EXPORT void addAuthorStyleSheetForTesting(Ref<StyleSheetContents>&&);
+
+#if ENABLE(CONTENT_EXTENSIONS)
+    void addDisplayNoneSelector(const String& identifier, const String& selector, uint32_t selectorID);
+    void maybeAddContentExtensionSheet(const String& identifier, StyleSheetContents&);
+#endif
+
+    void detachFromDocument();
+
+private:
+    void styleResolverChangedTimerFired();
+
+    Document& m_document;
+
+    RefPtr<CSSStyleSheet> m_pageUserSheet;
+
+    mutable Vector<RefPtr<CSSStyleSheet>> m_injectedUserStyleSheets;
+    mutable Vector<RefPtr<CSSStyleSheet>> m_injectedAuthorStyleSheets;
+    mutable bool m_injectedStyleSheetCacheValid { false };
+
+    Vector<RefPtr<CSSStyleSheet>> m_userStyleSheets;
+    Vector<RefPtr<CSSStyleSheet>> m_authorStyleSheetsForTesting;
+
+#if ENABLE(CONTENT_EXTENSIONS)
+    HashMap<String, RefPtr<CSSStyleSheet>> m_contentExtensionSheets;
+    HashMap<String, RefPtr<ContentExtensions::ContentExtensionStyleSheet>> m_contentExtensionSelectorSheets;
+#endif
+
+    Timer m_styleResolverChangedTimer;
+};
+
+}
+
+#endif
+
index 91f6666..e1c6b26 100644 (file)
@@ -21,6 +21,7 @@
 #include "config.h"
 #include "InlineStyleSheetOwner.h"
 
+#include "AuthorStyleSheets.h"
 #include "ContentSecurityPolicy.h"
 #include "Element.h"
 #include "MediaList.h"
@@ -47,7 +48,7 @@ InlineStyleSheetOwner::~InlineStyleSheetOwner()
 
 void InlineStyleSheetOwner::insertedIntoDocument(Document& document, Element& element)
 {
-    document.styleSheetCollection().addStyleSheetCandidateNode(element, m_isParsingChildren);
+    document.authorStyleSheets().addStyleSheetCandidateNode(element, m_isParsingChildren);
 
     if (m_isParsingChildren)
         return;
@@ -56,7 +57,7 @@ void InlineStyleSheetOwner::insertedIntoDocument(Document& document, Element& el
 
 void InlineStyleSheetOwner::removedFromDocument(Document& document, Element& element)
 {
-    document.styleSheetCollection().removeStyleSheetCandidateNode(element);
+    document.authorStyleSheets().removeStyleSheetCandidateNode(element);
 
     if (m_sheet)
         clearSheet();
@@ -73,7 +74,7 @@ void InlineStyleSheetOwner::clearDocumentData(Document& document, Element& eleme
 
     if (!element.inDocument())
         return;
-    document.styleSheetCollection().removeStyleSheetCandidateNode(element);
+    document.authorStyleSheets().removeStyleSheetCandidateNode(element);
 }
 
 void InlineStyleSheetOwner::childrenChanged(Element& element)
@@ -117,7 +118,7 @@ void InlineStyleSheetOwner::createSheet(Element& element, const String& text)
     Document& document = element.document();
     if (m_sheet) {
         if (m_sheet->isLoading())
-            document.styleSheetCollection().removePendingSheet();
+            document.authorStyleSheets().removePendingSheet();
         clearSheet();
     }
 
@@ -137,7 +138,7 @@ void InlineStyleSheetOwner::createSheet(Element& element, const String& text)
     if (!screenEval.eval(mediaQueries.get()) && !printEval.eval(mediaQueries.get()))
         return;
 
-    document.styleSheetCollection().addPendingSheet();
+    document.authorStyleSheets().addPendingSheet();
 
     m_loading = true;
 
@@ -164,13 +165,13 @@ bool InlineStyleSheetOwner::sheetLoaded(Document& document)
     if (isLoading())
         return false;
 
-    document.styleSheetCollection().removePendingSheet();
+    document.authorStyleSheets().removePendingSheet();
     return true;
 }
 
 void InlineStyleSheetOwner::startLoadingDynamicSheet(Document& document)
 {
-    document.styleSheetCollection().addPendingSheet();
+    document.authorStyleSheets().addPendingSheet();
 }
 
 }
index 30009b7..9d77e1b 100644 (file)
@@ -22,6 +22,7 @@
 #include "config.h"
 #include "ProcessingInstruction.h"
 
+#include "AuthorStyleSheets.h"
 #include "CSSStyleSheet.h"
 #include "CachedCSSStyleSheet.h"
 #include "CachedResourceLoader.h"
@@ -66,7 +67,7 @@ ProcessingInstruction::~ProcessingInstruction()
         m_cachedSheet->removeClient(this);
 
     if (inDocument())
-        document().styleSheetCollection().removeStyleSheetCandidateNode(*this);
+        document().authorStyleSheets().removeStyleSheetCandidateNode(*this);
 }
 
 String ProcessingInstruction::nodeName() const
@@ -142,7 +143,7 @@ void ProcessingInstruction::checkStyleSheet()
                 return;
             
             m_loading = true;
-            document().styleSheetCollection().addPendingSheet();
+            document().authorStyleSheets().addPendingSheet();
             
             CachedResourceRequest request(ResourceRequest(document().completeURL(href)));
 #if ENABLE(XSLT)
@@ -163,7 +164,7 @@ void ProcessingInstruction::checkStyleSheet()
             else {
                 // The request may have been denied if (for example) the stylesheet is local and the document is remote.
                 m_loading = false;
-                document().styleSheetCollection().removePendingSheet();
+                document().authorStyleSheets().removePendingSheet();
             }
         }
     }
@@ -181,7 +182,7 @@ bool ProcessingInstruction::isLoading() const
 bool ProcessingInstruction::sheetLoaded()
 {
     if (!isLoading()) {
-        document().styleSheetCollection().removePendingSheet();
+        document().authorStyleSheets().removePendingSheet();
         return true;
     }
     return false;
@@ -265,7 +266,7 @@ Node::InsertionNotificationRequest ProcessingInstruction::insertedInto(Container
     CharacterData::insertedInto(insertionPoint);
     if (!insertionPoint.inDocument())
         return InsertionDone;
-    document().styleSheetCollection().addStyleSheetCandidateNode(*this, m_createdByParser);
+    document().authorStyleSheets().addStyleSheetCandidateNode(*this, m_createdByParser);
     checkStyleSheet();
     return InsertionDone;
 }
@@ -276,7 +277,7 @@ void ProcessingInstruction::removedFrom(ContainerNode& insertionPoint)
     if (!insertionPoint.inDocument())
         return;
     
-    document().styleSheetCollection().removeStyleSheetCandidateNode(*this);
+    document().authorStyleSheets().removeStyleSheetCandidateNode(*this);
 
     if (m_sheet) {
         ASSERT(m_sheet->ownerNode() == this);
index 3abb2ce..4045439 100644 (file)
 
 #include "Attribute.h"
 #include "AttributeDOMTokenList.h"
+#include "AuthorStyleSheets.h"
 #include "CachedCSSStyleSheet.h"
 #include "CachedResource.h"
 #include "CachedResourceLoader.h"
 #include "CachedResourceRequest.h"
 #include "Document.h"
-#include "DocumentStyleSheetCollection.h"
 #include "Event.h"
 #include "EventSender.h"
 #include "Frame.h"
@@ -94,7 +94,7 @@ HTMLLinkElement::~HTMLLinkElement()
         m_cachedSheet->removeClient(this);
 
     if (inDocument())
-        document().styleSheetCollection().removeStyleSheetCandidateNode(*this);
+        document().authorStyleSheets().removeStyleSheetCandidateNode(*this);
 
     linkLoadEventSender().cancelEvent(*this);
 }
@@ -279,7 +279,7 @@ Node::InsertionNotificationRequest HTMLLinkElement::insertedInto(ContainerNode&
     if (m_isInShadowTree)
         return InsertionDone;
 
-    document().styleSheetCollection().addStyleSheetCandidateNode(*this, m_createdByParser);
+    document().authorStyleSheets().addStyleSheetCandidateNode(*this, m_createdByParser);
 
     process();
     return InsertionDone;
@@ -295,7 +295,7 @@ void HTMLLinkElement::removedFrom(ContainerNode& insertionPoint)
         ASSERT(!m_sheet);
         return;
     }
-    document().styleSheetCollection().removeStyleSheetCandidateNode(*this);
+    document().authorStyleSheets().removeStyleSheetCandidateNode(*this);
 
     if (m_sheet)
         clearSheet();
@@ -514,7 +514,7 @@ void HTMLLinkElement::addPendingSheet(PendingSheetType type)
 
     if (m_pendingSheetType == InactiveSheet)
         return;
-    document().styleSheetCollection().addPendingSheet();
+    document().authorStyleSheets().addPendingSheet();
 }
 
 void HTMLLinkElement::removePendingSheet(RemovePendingSheetNotificationType notification)
@@ -527,14 +527,14 @@ void HTMLLinkElement::removePendingSheet(RemovePendingSheetNotificationType noti
 
     if (type == InactiveSheet) {
         // Document just needs to know about the sheet for exposure through document.styleSheets
-        document().styleSheetCollection().updateActiveStyleSheets(DocumentStyleSheetCollection::OptimizedUpdate);
+        document().authorStyleSheets().updateActiveStyleSheets(AuthorStyleSheets::OptimizedUpdate);
         return;
     }
 
-    document().styleSheetCollection().removePendingSheet(
+    document().authorStyleSheets().removePendingSheet(
         notification == RemovePendingSheetNotifyImmediately
-        ? DocumentStyleSheetCollection::RemovePendingSheetNotifyImmediately
-        : DocumentStyleSheetCollection::RemovePendingSheetNotifyLater);
+        ? AuthorStyleSheets::RemovePendingSheetNotifyImmediately
+        : AuthorStyleSheets::RemovePendingSheetNotifyLater);
 }
 
 } // namespace WebCore
index 8126b86..7cddafa 100644 (file)
@@ -24,7 +24,6 @@
 #include "HTMLQuoteElement.h"
 
 #include "Document.h"
-#include "DocumentStyleSheetCollection.h"
 #include "HTMLNames.h"
 
 namespace WebCore {
index 7193349..9583d8f 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "InspectorCSSAgent.h"
 
+#include "AuthorStyleSheets.h"
 #include "CSSComputedStyleDeclaration.h"
 #include "CSSImportRule.h"
 #include "CSSPropertyNames.h"
@@ -665,7 +666,7 @@ void InspectorCSSAgent::collectAllStyleSheets(Vector<InspectorStyleSheet*>& resu
 
 void InspectorCSSAgent::collectAllDocumentStyleSheets(Document& document, Vector<CSSStyleSheet*>& result)
 {
-    Vector<RefPtr<CSSStyleSheet>> cssStyleSheets = document.styleSheetCollection().activeStyleSheetsForInspector();
+    auto cssStyleSheets = document.authorStyleSheets().activeStyleSheetsForInspector();
     for (auto& cssStyleSheet : cssStyleSheets)
         collectStyleSheets(cssStyleSheet.get(), result);
 }
@@ -1015,7 +1016,7 @@ RefPtr<Inspector::Protocol::CSS::CSSRule> InspectorCSSAgent::buildObjectForRule(
 
     // StyleRules returned by StyleResolver::styleRulesForElement lack parent pointers since that infomation is not cheaply available.
     // Since the inspector wants to walk the parent chain, we construct the full wrappers here.
-    CSSStyleRule* cssomWrapper = styleResolver.inspectorCSSOMWrappers().getWrapperForRuleInSheets(styleRule, styleResolver.document().styleSheetCollection());
+    CSSStyleRule* cssomWrapper = styleResolver.inspectorCSSOMWrappers().getWrapperForRuleInSheets(styleRule, styleResolver.document().authorStyleSheets(), styleResolver.document().extensionStyleSheets());
     if (!cssomWrapper)
         return nullptr;
     InspectorStyleSheet* inspectorStyleSheet = bindStyleSheet(cssomWrapper->parentStyleSheet());
index 648bbea..6f7e2a0 100644 (file)
@@ -40,6 +40,7 @@
 #include "DocumentParser.h"
 #include "DocumentWriter.h"
 #include "Event.h"
+#include "ExtensionStyleSheets.h"
 #include "FormState.h"
 #include "FrameLoader.h"
 #include "FrameLoaderClient.h"
@@ -845,13 +846,13 @@ void DocumentLoader::commitData(const char* bytes, size_t length)
     }
 
 #if ENABLE(CONTENT_EXTENSIONS)
-    DocumentStyleSheetCollection& styleSheetCollection = m_frame->document()->styleSheetCollection();
+    auto& extensionStyleSheets = m_frame->document()->extensionStyleSheets();
 
     for (auto& pendingStyleSheet : m_pendingNamedContentExtensionStyleSheets)
-        styleSheetCollection.maybeAddContentExtensionSheet(pendingStyleSheet.key, *pendingStyleSheet.value);
+        extensionStyleSheets.maybeAddContentExtensionSheet(pendingStyleSheet.key, *pendingStyleSheet.value);
     for (auto& pendingSelectorEntry : m_pendingContentExtensionDisplayNoneSelectors) {
         for (const auto& pendingSelector : pendingSelectorEntry.value)
-            styleSheetCollection.addDisplayNoneSelector(pendingSelectorEntry.key, pendingSelector.first, pendingSelector.second);
+            extensionStyleSheets.addDisplayNoneSelector(pendingSelectorEntry.key, pendingSelector.first, pendingSelector.second);
     }
 
     m_pendingNamedContentExtensionStyleSheets.clear();
index d4407fe..90ad963 100644 (file)
@@ -32,7 +32,6 @@
 #include "ContextMenuController.h"
 #include "DatabaseProvider.h"
 #include "DocumentMarkerController.h"
-#include "DocumentStyleSheetCollection.h"
 #include "DragController.h"
 #include "Editor.h"
 #include "EditorClient.h"
@@ -40,6 +39,7 @@
 #include "EventNames.h"
 #include "ExceptionCode.h"
 #include "ExceptionCodePlaceholder.h"
+#include "ExtensionStyleSheets.h"
 #include "FileSystem.h"
 #include "FocusController.h"
 #include "FrameLoader.h"
@@ -1013,7 +1013,7 @@ void Page::userStyleSheetLocationChanged()
 
     for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
         if (frame->document())
-            frame->document()->styleSheetCollection().updatePageUserSheet();
+            frame->document()->extensionStyleSheets().updatePageUserSheet();
     }
 }
 
@@ -1631,7 +1631,7 @@ void Page::setUserContentController(UserContentController* userContentController
 
     for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
         if (Document *document = frame->document()) {
-            document->styleSheetCollection().invalidateInjectedStyleSheetCache();
+            document->extensionStyleSheets().invalidateInjectedStyleSheetCache();
             document->styleResolverChanged(DeferRecalcStyle);
         }
     }
index 9ff7801..3fd35f4 100644 (file)
@@ -30,7 +30,6 @@
 #include "ChromeClient.h"
 #include "DOMWrapperWorld.h"
 #include "Document.h"
-#include "DocumentStyleSheetCollection.h"
 #include "MainFrame.h"
 #include "Page.h"
 #include "PageCache.h"
index a10102e..e6239b5 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "DOMWrapperWorld.h"
 #include "Document.h"
+#include "ExtensionStyleSheets.h"
 #include "MainFrame.h"
 #include "Page.h"
 #include "ResourceLoadInfo.h"
@@ -243,7 +244,7 @@ void UserContentController::invalidateInjectedStyleSheetCacheInAllFrames()
 {
     for (auto& page : m_pages) {
         for (Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
-            frame->document()->styleSheetCollection().invalidateInjectedStyleSheetCache();
+            frame->document()->extensionStyleSheets().invalidateInjectedStyleSheetCache();
             frame->document()->styleResolverChanged(DeferRecalcStyle);
         }
     }
index a995664..80f8245 100644 (file)
@@ -2824,7 +2824,7 @@ LayoutUnit RenderBlock::lineHeight(bool firstLine, LineDirectionMode direction,
     if (isReplaced() && linePositionMode == PositionOnContainingLine)
         return RenderBox::lineHeight(firstLine, direction, linePositionMode);
 
-    if (firstLine && document().styleSheetCollection().usesFirstLineRules()) {
+    if (firstLine && view().usesFirstLineRules()) {
         RenderStyle& s = firstLine ? firstLineStyle() : style();
         if (&s != &style())
             return s.computedLineHeight();
@@ -3161,7 +3161,7 @@ void RenderBlock::getFirstLetter(RenderObject*& firstLetter, RenderElement*& fir
     firstLetter = nullptr;
     firstLetterContainer = nullptr;
 
-    if (!document().styleSheetCollection().usesFirstLetterRules())
+    if (!view().usesFirstLetterRules())
         return;
 
     // Don't recur
index 9557606..3715f7b 100644 (file)
@@ -232,7 +232,7 @@ static PassRefPtr<RenderStyle> firstLineStyleForCachedUncachedType(StyleCacheSta
 
 PassRefPtr<RenderStyle> RenderElement::uncachedFirstLineStyle(RenderStyle* style) const
 {
-    if (!document().styleSheetCollection().usesFirstLineRules())
+    if (!view().usesFirstLineRules())
         return nullptr;
 
     return firstLineStyleForCachedUncachedType(Uncached, *this, style);
@@ -240,7 +240,7 @@ PassRefPtr<RenderStyle> RenderElement::uncachedFirstLineStyle(RenderStyle* style
 
 RenderStyle* RenderElement::cachedFirstLineStyle() const
 {
-    ASSERT(document().styleSheetCollection().usesFirstLineRules());
+    ASSERT(view().usesFirstLineRules());
 
     RenderStyle& style = this->style();
     if (RefPtr<RenderStyle> firstLineStyle = firstLineStyleForCachedUncachedType(Cached, *this, &style))
@@ -249,6 +249,11 @@ RenderStyle* RenderElement::cachedFirstLineStyle() const
     return &style;
 }
 
+RenderStyle& RenderElement::firstLineStyle() const
+{
+    return view().usesFirstLineRules() ? *cachedFirstLineStyle() : style();
+}
+
 StyleDifference RenderElement::adjustStyleDifference(StyleDifference diff, unsigned contextSensitiveProperties) const
 {
     // If transform changed, and we are not composited, need to do a layout.
index 383935e..3b9fd93 100644 (file)
@@ -346,11 +346,6 @@ inline void RenderElement::setAnimatableStyle(Ref<RenderStyle>&& style, StyleDif
     setStyle(WTF::move(animatedStyle), minimalStyleDifference);
 }
 
-inline RenderStyle& RenderElement::firstLineStyle() const
-{
-    return document().styleSheetCollection().usesFirstLineRules() ? *cachedFirstLineStyle() : style();
-}
-
 inline void RenderElement::setAncestorLineBoxDirty(bool f)
 {
     m_ancestorLineBoxDirty = f;
index fe88e76..0d8b95a 100644 (file)
@@ -219,7 +219,7 @@ void RenderInline::updateAlwaysCreateLineBoxes(bool fullLayout)
         || parentStyle->lineHeight() != style().lineHeight()))
         || (flowThread && flowThread->isRenderNamedFlowThread()); // FIXME: Enable the optimization once we make overflow computation for culled inlines in regions.
 
-    if (!alwaysCreateLineBoxes && checkFonts && document().styleSheetCollection().usesFirstLineRules()) {
+    if (!alwaysCreateLineBoxes && checkFonts && view().usesFirstLineRules()) {
         // Have to check the first line style as well.
         parentStyle = &parent()->firstLineStyle();
         RenderStyle& childStyle = firstLineStyle();
@@ -1457,7 +1457,7 @@ InlineFlowBox* RenderInline::createAndAppendInlineFlowBox()
 
 LayoutUnit RenderInline::lineHeight(bool firstLine, LineDirectionMode /*direction*/, LinePositionMode /*linePositionMode*/) const
 {
-    if (firstLine && document().styleSheetCollection().usesFirstLineRules()) {
+    if (firstLine && view().usesFirstLineRules()) {
         const RenderStyle& firstLineStyle = this->firstLineStyle();
         if (&firstLineStyle != &style())
             return firstLineStyle.computedLineHeight();
index 666a0cb..9444620 100644 (file)
@@ -71,7 +71,7 @@ RenderLineBreak::~RenderLineBreak()
 
 LayoutUnit RenderLineBreak::lineHeight(bool firstLine, LineDirectionMode /*direction*/, LinePositionMode /*linePositionMode*/) const
 {
-    if (firstLine && document().styleSheetCollection().usesFirstLineRules()) {
+    if (firstLine && view().usesFirstLineRules()) {
         const RenderStyle& firstLineStyle = this->firstLineStyle();
         if (&firstLineStyle != &style())
             return firstLineStyle.computedLineHeight();
index 1a43e58..dc4f919 100644 (file)
@@ -187,6 +187,11 @@ public:
     WEBCORE_EXPORT RenderLayerCompositor& compositor();
     WEBCORE_EXPORT bool usesCompositing() const;
 
+    bool usesFirstLineRules() const { return m_usesFirstLineRules; }
+    bool usesFirstLetterRules() const { return m_usesFirstLetterRules; }
+    void setUsesFirstLineRules(bool value) { m_usesFirstLineRules = value; }
+    void setUsesFirstLetterRules(bool value) { m_usesFirstLetterRules = value; }
+
     WEBCORE_EXPORT IntRect unscaledDocumentRect() const;
     LayoutRect unextendedBackgroundRect() const;
     LayoutRect backgroundRect() const;
@@ -369,6 +374,8 @@ private:
 
     bool m_selectionWasCaret;
     bool m_hasSoftwareFilters;
+    bool m_usesFirstLineRules { false };
+    bool m_usesFirstLetterRules { false };
 
     HashSet<RenderElement*> m_renderersWithPausedImageAnimation;
     Vector<RefPtr<RenderWidget>> m_protectedRenderWidgets;
index 3d83c99..cfda5cf 100644 (file)
@@ -999,7 +999,7 @@ LayoutUnit RootInlineBox::verticalPositionForBox(InlineBox* box, VerticalPositio
 
     // This method determines the vertical position for inline elements.
     bool firstLine = isFirstLine();
-    if (firstLine && !renderer->document().styleSheetCollection().usesFirstLineRules())
+    if (firstLine && !blockFlow().view().usesFirstLineRules())
         firstLine = false;
 
     // Check the cache.
index 33585bf..4ac4701 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "AXObjectCache.h"
 #include "AnimationController.h"
+#include "AuthorStyleSheets.h"
 #include "CSSFontSelector.h"
 #include "ElementIterator.h"
 #include "ElementRareData.h"
@@ -685,7 +686,7 @@ static Change resolveLocal(Element& current, RenderStyle& inheritedStyle, Render
 
     // If "rem" units are used anywhere in the document, and if the document element's font size changes, then force font updating
     // all the way down the tree. This is simpler than having to maintain a cache of objects (and such font size changes should be rare anyway).
-    if (document.styleSheetCollection().usesRemUnits() && document.documentElement() == &current && localChange != NoChange && currentStyle && newStyle && currentStyle->fontSize() != newStyle->fontSize()) {
+    if (document.authorStyleSheets().usesRemUnits() && document.documentElement() == &current && localChange != NoChange && currentStyle && newStyle && currentStyle->fontSize() != newStyle->fontSize()) {
         // Cached RenderStyles may depend on the re units.
         if (StyleResolver* styleResolver = document.styleResolverIfExists())
             styleResolver->invalidateMatchedPropertiesCache();
@@ -914,6 +915,8 @@ void resolveTree(Element& current, RenderStyle& inheritedStyle, RenderTreePositi
 
 void resolveTree(Document& document, Change change)
 {
+    auto& renderView = *document.renderView();
+
     if (change == Force) {
         auto documentStyle = resolveForDocument(document);
 
@@ -924,9 +927,9 @@ void resolveTree(Document& document, Change change)
                 documentStyle.get().fontCascade().update(&document.fontSelector());
         }
 
-        Style::Change documentChange = determineChange(documentStyle.get(), document.renderView()->style());
+        Style::Change documentChange = determineChange(documentStyle.get(), renderView.style());
         if (documentChange != NoChange)
-            document.renderView()->setStyle(WTF::move(documentStyle));
+            renderView.setStyle(WTF::move(documentStyle));
     }
 
     Element* documentElement = document.documentElement();
@@ -934,8 +937,18 @@ void resolveTree(Document& document, Change change)
         return;
     if (change < Inherit && !documentElement->childNeedsStyleRecalc() && !documentElement->needsStyleRecalc())
         return;
-    RenderTreePosition renderTreePosition(*document.renderView());
+
+    auto& styleResolved = document.ensureStyleResolver();
+
+    // Pseudo element removal and similar may only work with these flags still set. Reset them after the style recalc.
+    renderView.setUsesFirstLineRules(renderView.usesFirstLineRules() || styleResolved.usesFirstLineRules());
+    renderView.setUsesFirstLetterRules(renderView.usesFirstLetterRules() || styleResolved.usesFirstLetterRules());
+
+    RenderTreePosition renderTreePosition(renderView);
     resolveTree(*documentElement, *document.renderStyle(), renderTreePosition, change);
+
+    renderView.setUsesFirstLineRules(styleResolved.usesFirstLineRules());
+    renderView.setUsesFirstLetterRules(styleResolved.usesFirstLetterRules());
 }
 
 void detachRenderTree(Element& element)
index 3edd204..82ab6ef 100644 (file)
@@ -49,6 +49,7 @@
 #include "Element.h"
 #include "EventHandler.h"
 #include "ExceptionCode.h"
+#include "ExtensionStyleSheets.h"
 #include "File.h"
 #include "FontCache.h"
 #include "FormController.h"
@@ -1940,7 +1941,7 @@ void Internals::insertAuthorCSS(const String& css, ExceptionCode& ec) const
     auto parsedSheet = StyleSheetContents::create(*document);
     parsedSheet.get().setIsUserStyleSheet(false);
     parsedSheet.get().parseString(css);
-    document->styleSheetCollection().addAuthorSheet(WTF::move(parsedSheet));
+    document->extensionStyleSheets().addAuthorStyleSheetForTesting(WTF::move(parsedSheet));
 }
 
 void Internals::insertUserCSS(const String& css, ExceptionCode& ec) const
@@ -1954,7 +1955,7 @@ void Internals::insertUserCSS(const String& css, ExceptionCode& ec) const
     auto parsedSheet = StyleSheetContents::create(*document);
     parsedSheet.get().setIsUserStyleSheet(true);
     parsedSheet.get().parseString(css);
-    document->styleSheetCollection().addUserSheet(WTF::move(parsedSheet));
+    document->extensionStyleSheets().addUserStyleSheet(WTF::move(parsedSheet));
 }
 
 String Internals::counterValue(Element* element)