haikuwebkit/Source/WebCore/dom/ExtensionStyleSheets.cpp

242 lines
8.1 KiB
C++
Raw Permalink Normal View History

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): Canonical link: https://commits.webkit.org/167594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-23 15:04:16 +00:00
/*
* 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 "HTMLLinkElement.h"
#include "HTMLStyleElement.h"
#include "Page.h"
#include "ProcessingInstruction.h"
#include "SVGStyleElement.h"
#include "Settings.h"
Rename StyleInvalidationAnalysis to Style::Invalidator https://bugs.webkit.org/show_bug.cgi?id=171601 Reviewed by Žan Doberšek. Also move it to the 'style' directory. * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * css/StyleInvalidationAnalysis.cpp: Removed. * css/StyleInvalidationAnalysis.h: Removed. * dom/ExtensionStyleSheets.cpp: * style/AttributeChangeInvalidation.cpp: (WebCore::Style::AttributeChangeInvalidation::invalidateDescendants): * style/ClassChangeInvalidation.cpp: (WebCore::Style::ClassChangeInvalidation::invalidateDescendantStyle): * style/StyleInvalidator.cpp: Copied from Source/WebCore/css/StyleInvalidationAnalysis.cpp. (WebCore::Style::Invalidator::Invalidator): (WebCore::Style::Invalidator::invalidateIfNeeded): (WebCore::Style::Invalidator::invalidateStyleForTree): (WebCore::Style::Invalidator::invalidateStyle): (WebCore::shouldDirtyAllStyle): Deleted. (WebCore::StyleInvalidationAnalysis::StyleInvalidationAnalysis): Deleted. (WebCore::StyleInvalidationAnalysis::invalidateIfNeeded): Deleted. (WebCore::StyleInvalidationAnalysis::invalidateStyleForTree): Deleted. (WebCore::StyleInvalidationAnalysis::invalidateStyle): Deleted. * style/StyleInvalidator.h: Copied from Source/WebCore/css/StyleInvalidationAnalysis.h. (WebCore::StyleInvalidationAnalysis::dirtiesAllStyle): Deleted. (WebCore::StyleInvalidationAnalysis::hasShadowPseudoElementRulesInAuthorSheet): Deleted. * style/StyleScope.cpp: (WebCore::Style::Scope::resolver): (WebCore::Style::Scope::analyzeStyleSheetChange): Canonical link: https://commits.webkit.org/188503@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216117 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-03 14:04:21 +00:00
#include "StyleInvalidator.h"
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): Canonical link: https://commits.webkit.org/167594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-23 15:04:16 +00:00
#include "StyleResolver.h"
Rename AuthorStyleSheets to Style::Scope https://bugs.webkit.org/show_bug.cgi?id=163108 Reviewed by Andreas Kling. It represents the style scope in DOM. Also move the file under style/. * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * css/CSSStyleSheet.cpp: (WebCore::CSSStyleSheet::styleSheetScope): * css/CSSStyleSheet.h: * css/InspectorCSSOMWrappers.cpp: (WebCore::InspectorCSSOMWrappers::getWrapperForRuleInSheets): * css/InspectorCSSOMWrappers.h: * css/StyleSheetList.cpp: (WebCore::StyleSheetList::styleSheets): (WebCore::StyleSheetList::detachFromDocument): * dom/AuthorStyleSheets.cpp: Removed. * dom/AuthorStyleSheets.h: Removed. * dom/Document.cpp: (WebCore::Document::Document): (WebCore::Document::setContentLanguage): (WebCore::Document::recalcStyle): (WebCore::Document::needsStyleRecalc): (WebCore::Document::updateStyleIfNeeded): (WebCore::Document::updateLayoutIgnorePendingStylesheets): (WebCore::Document::createStyleResolver): (WebCore::Document::didRemoveAllPendingStylesheet): (WebCore::Document::usesStyleBasedEditability): (WebCore::Document::processHttpEquiv): (WebCore::Document::preferredStylesheetSet): (WebCore::Document::selectedStylesheetSet): (WebCore::Document::setSelectedStylesheetSet): (WebCore::Document::haveStylesheetsLoaded): * dom/Document.h: (WebCore::Document::styleScope): (WebCore::Document::authorStyleSheets): Deleted. * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::clearPageUserSheet): (WebCore::ExtensionStyleSheets::updatePageUserSheet): (WebCore::ExtensionStyleSheets::invalidateInjectedStyleSheetCache): (WebCore::ExtensionStyleSheets::addUserStyleSheet): (WebCore::ExtensionStyleSheets::addAuthorStyleSheetForTesting): (WebCore::ExtensionStyleSheets::styleResolverChangedTimerFired): * dom/InlineStyleSheetOwner.cpp: (WebCore::InlineStyleSheetOwner::insertedIntoDocument): (WebCore::InlineStyleSheetOwner::removedFromDocument): (WebCore::InlineStyleSheetOwner::clearDocumentData): (WebCore::InlineStyleSheetOwner::createSheet): (WebCore::InlineStyleSheetOwner::sheetLoaded): (WebCore::InlineStyleSheetOwner::startLoadingDynamicSheet): * dom/InlineStyleSheetOwner.h: (WebCore::InlineStyleSheetOwner::styleScope): (WebCore::InlineStyleSheetOwner::styleSheetScope): Deleted. * dom/ProcessingInstruction.cpp: (WebCore::ProcessingInstruction::~ProcessingInstruction): (WebCore::ProcessingInstruction::checkStyleSheet): (WebCore::ProcessingInstruction::sheetLoaded): (WebCore::ProcessingInstruction::insertedInto): (WebCore::ProcessingInstruction::removedFrom): * dom/ShadowRoot.cpp: (WebCore::ShadowRoot::styleResolver): (WebCore::ShadowRoot::styleScope): (WebCore::ShadowRoot::updateStyle): (WebCore::ShadowRoot::authorStyleSheets): Deleted. * dom/ShadowRoot.h: * html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::~HTMLLinkElement): (WebCore::HTMLLinkElement::setDisabledState): (WebCore::HTMLLinkElement::parseAttribute): (WebCore::HTMLLinkElement::process): (WebCore::HTMLLinkElement::insertedInto): (WebCore::HTMLLinkElement::removedFrom): (WebCore::HTMLLinkElement::addPendingSheet): (WebCore::HTMLLinkElement::removePendingSheet): * html/HTMLStyleElement.cpp: * inspector/InspectorCSSAgent.cpp: (WebCore::InspectorCSSAgent::collectAllDocumentStyleSheets): (WebCore::InspectorCSSAgent::forcePseudoState): (WebCore::InspectorCSSAgent::buildObjectForRule): (WebCore::InspectorCSSAgent::resetPseudoStates): * inspector/InspectorPageAgent.cpp: (WebCore::InspectorPageAgent::setEmulatedMedia): * page/DOMWindow.cpp: (WebCore::DOMWindow::getMatchedCSSRules): * page/Frame.cpp: (WebCore::Frame::setPrinting): * page/FrameView.cpp: (WebCore::FrameView::layout): (WebCore::FrameView::setPagination): (WebCore::FrameView::setViewportSizeForCSSViewportUnits): * page/Page.cpp: (WebCore::Page::setViewMode): (WebCore::Page::setNeedsRecalcStyleInAllFrames): (WebCore::Page::invalidateInjectedStyleSheetCacheInAllFrames): * style/StyleScope.cpp: Copied from dom/AuthorStyleSheets.cpp. (WebCore::Style::Scope::Scope): (WebCore::Style::Scope::styleResolver): (WebCore::Style::Scope::styleResolverIfExists): (WebCore::Style::Scope::forNode): (WebCore::Style::Scope::removePendingSheet): (WebCore::Style::Scope::addStyleSheetCandidateNode): (WebCore::Style::Scope::removeStyleSheetCandidateNode): (WebCore::Style::Scope::collectActiveStyleSheets): (WebCore::Style::Scope::analyzeStyleSheetChange): (WebCore::Style::Scope::updateActiveStyleSheets): (WebCore::Style::Scope::updateStyleResolver): (WebCore::Style::Scope::activeStyleSheetsForInspector): (WebCore::Style::Scope::activeStyleSheetsContains): (WebCore::Style::Scope::flushPendingUpdate): (WebCore::Style::Scope::clearPendingUpdate): (WebCore::Style::Scope::scheduleActiveSetUpdate): (WebCore::Style::Scope::didChangeCandidatesForActiveSet): (WebCore::Style::Scope::didChangeContentsOrInterpretation): (WebCore::Style::Scope::pendingUpdateTimerFired): (WebCore::AuthorStyleSheets::AuthorStyleSheets): Deleted. (WebCore::AuthorStyleSheets::styleResolver): Deleted. (WebCore::AuthorStyleSheets::styleResolverIfExists): Deleted. (WebCore::AuthorStyleSheets::forNode): Deleted. (WebCore::AuthorStyleSheets::removePendingSheet): Deleted. (WebCore::AuthorStyleSheets::addStyleSheetCandidateNode): Deleted. (WebCore::AuthorStyleSheets::removeStyleSheetCandidateNode): Deleted. (WebCore::AuthorStyleSheets::collectActiveStyleSheets): Deleted. (WebCore::AuthorStyleSheets::analyzeStyleSheetChange): Deleted. (WebCore::AuthorStyleSheets::updateActiveStyleSheets): Deleted. (WebCore::AuthorStyleSheets::updateStyleResolver): Deleted. (WebCore::AuthorStyleSheets::activeStyleSheetsForInspector): Deleted. (WebCore::AuthorStyleSheets::activeStyleSheetsContains): Deleted. (WebCore::AuthorStyleSheets::flushPendingUpdate): Deleted. (WebCore::AuthorStyleSheets::clearPendingUpdate): Deleted. (WebCore::AuthorStyleSheets::scheduleActiveSetUpdate): Deleted. (WebCore::AuthorStyleSheets::didChangeCandidatesForActiveSet): Deleted. (WebCore::AuthorStyleSheets::didChangeContentsOrInterpretation): Deleted. (WebCore::AuthorStyleSheets::pendingUpdateTimerFired): Deleted. * style/StyleScope.h: Copied from dom/AuthorStyleSheets.h. * style/StyleTreeResolver.cpp: * svg/SVGFontFaceElement.cpp: (WebCore::SVGFontFaceElement::rebuildFontFace): (WebCore::SVGFontFaceElement::removedFrom): * xml/XMLTreeViewer.cpp: (WebCore::XMLTreeViewer::transformDocumentToTreeView): * xml/parser/XMLDocumentParser.cpp: (WebCore::XMLDocumentParser::end): * xml/parser/XMLDocumentParserLibxml2.cpp: (WebCore::XMLDocumentParser::doEnd): Canonical link: https://commits.webkit.org/180967@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206917 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-07 16:55:11 +00:00
#include "StyleScope.h"
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): Canonical link: https://commits.webkit.org/167594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-23 15:04:16 +00:00
#include "StyleSheetContents.h"
#include "StyleSheetList.h"
#include "UserContentController.h"
#include "UserContentURLPattern.h"
#include "UserStyleSheet.h"
namespace WebCore {
Add ENABLE(CONTENT_EXTENSIONS) and namespace ContentExtensions to ResourceLoadInfo.h https://bugs.webkit.org/show_bug.cgi?id=197165 Reviewed by Youenn Fablet. Source/WebCore: No change in behavior. This will just make it harder for people working on the loader to mistake these ContentExtension specific structures for other structures general to loading. One such mistake was made in r244248. * Modules/websockets/WebSocketChannel.cpp: (WebCore::WebSocketChannel::connect): * contentextensions/ContentExtensionsBackend.h: * css/StyleSheetContents.cpp: (WebCore::StyleSheetContents::subresourcesAllowReuse const): * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::loadResource): * loader/FrameLoader.cpp: (WebCore::FrameLoader::loadResourceSynchronously): * loader/NetscapePlugInStreamLoader.cpp: (WebCore::NetscapePlugInStreamLoader::NetscapePlugInStreamLoader): * loader/PingLoader.cpp: (WebCore::processContentRuleListsForLoad): (WebCore::PingLoader::loadImage): (WebCore::PingLoader::sendPing): (WebCore::PingLoader::sendViolationReport): * loader/ResourceLoadInfo.cpp: (WebCore::toResourceType): Deleted. (WebCore::readResourceType): Deleted. (WebCore::readLoadType): Deleted. (WebCore::ResourceLoadInfo::isThirdParty const): Deleted. (WebCore::ResourceLoadInfo::getResourceFlags const): Deleted. * loader/ResourceLoadInfo.h: * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::willSendRequestInternal): * loader/ResourceLoader.h: * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::SubresourceLoader): * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): * page/DOMWindow.cpp: (WebCore::DOMWindow::open): * page/UserContentProvider.cpp: (WebCore::UserContentProvider::processContentRuleListsForLoad): (WebCore::UserContentProvider::actionsForResourceLoad): * page/UserContentProvider.h: Tools: * TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp: Canonical link: https://commits.webkit.org/211530@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244695 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-04-26 17:03:15 +00:00
#if ENABLE(CONTENT_EXTENSIONS)
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): Canonical link: https://commits.webkit.org/167594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-23 15:04:16 +00:00
using namespace ContentExtensions;
Add ENABLE(CONTENT_EXTENSIONS) and namespace ContentExtensions to ResourceLoadInfo.h https://bugs.webkit.org/show_bug.cgi?id=197165 Reviewed by Youenn Fablet. Source/WebCore: No change in behavior. This will just make it harder for people working on the loader to mistake these ContentExtension specific structures for other structures general to loading. One such mistake was made in r244248. * Modules/websockets/WebSocketChannel.cpp: (WebCore::WebSocketChannel::connect): * contentextensions/ContentExtensionsBackend.h: * css/StyleSheetContents.cpp: (WebCore::StyleSheetContents::subresourcesAllowReuse const): * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::loadResource): * loader/FrameLoader.cpp: (WebCore::FrameLoader::loadResourceSynchronously): * loader/NetscapePlugInStreamLoader.cpp: (WebCore::NetscapePlugInStreamLoader::NetscapePlugInStreamLoader): * loader/PingLoader.cpp: (WebCore::processContentRuleListsForLoad): (WebCore::PingLoader::loadImage): (WebCore::PingLoader::sendPing): (WebCore::PingLoader::sendViolationReport): * loader/ResourceLoadInfo.cpp: (WebCore::toResourceType): Deleted. (WebCore::readResourceType): Deleted. (WebCore::readLoadType): Deleted. (WebCore::ResourceLoadInfo::isThirdParty const): Deleted. (WebCore::ResourceLoadInfo::getResourceFlags const): Deleted. * loader/ResourceLoadInfo.h: * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::willSendRequestInternal): * loader/ResourceLoader.h: * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::SubresourceLoader): * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): * page/DOMWindow.cpp: (WebCore::DOMWindow::open): * page/UserContentProvider.cpp: (WebCore::UserContentProvider::processContentRuleListsForLoad): (WebCore::UserContentProvider::actionsForResourceLoad): * page/UserContentProvider.h: Tools: * TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp: Canonical link: https://commits.webkit.org/211530@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244695 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-04-26 17:03:15 +00:00
#endif
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): Canonical link: https://commits.webkit.org/167594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-23 15:04:16 +00:00
using namespace HTMLNames;
ExtensionStyleSheets::ExtensionStyleSheets(Document& document)
: m_document(document)
{
}
Share inline stylesheets between shadow trees https://bugs.webkit.org/show_bug.cgi?id=163353 Reviewed by Ryosuke Niwa and Andreas Kling. If shadow trees have identical inline stylesheets the data structures can be shared. In future this will also allow sharing style resolvers. * css/CSSStyleSheet.cpp: (WebCore::CSSStyleSheet::createInline): Move StyleSheetContents construction to the client. * css/parser/CSSParserMode.h: (WebCore::CSSParserContextHash::hash): (WebCore::CSSParserContextHash::equal): (WTF::HashTraits<WebCore::CSSParserContext>::constructDeletedValue): (WTF::HashTraits<WebCore::CSSParserContext>::isDeletedValue): (WTF::HashTraits<WebCore::CSSParserContext>::emptyValue): Make CSSParserContext hashable. * dom/ExtensionStyleSheets.cpp: (WebCore::createExtensionsStyleSheet): (WebCore::ExtensionStyleSheets::pageUserSheet): (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache): Don't use CSSStyleSheet::createInline, these are not really inline stylesheets. Code cleanups. * dom/InlineStyleSheetOwner.cpp: (WebCore::parserContextForForElement): (WebCore::makeInlineStyleSheetCacheKey): (WebCore::inlineStyleSheetCache): Implement a simple cache for sharing stylesheets with identical text and context. (WebCore::InlineStyleSheetOwner::createSheet): (WebCore::InlineStyleSheetOwner::clearCache): * dom/InlineStyleSheetOwner.h: * platform/MemoryPressureHandler.cpp: (WebCore::MemoryPressureHandler::releaseNoncriticalMemory): Canonical link: https://commits.webkit.org/181258@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207339 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-14 15:39:04 +00:00
static Ref<CSSStyleSheet> createExtensionsStyleSheet(Document& document, URL url, const String& text, UserStyleLevel level)
{
Prepare to remove automatic URL->String conversion operators https://bugs.webkit.org/show_bug.cgi?id=211007 Patch by Alex Christensen <achristensen@webkit.org> on 2020-04-25 Reviewed by Darin Adler. Source/JavaScriptCore: * API/JSAPIGlobalObject.mm: (JSC::JSAPIGlobalObject::moduleLoaderResolve): (JSC::JSAPIGlobalObject::moduleLoaderImportModule): * API/JSScript.mm: (validateBytecodeCachePath): (+[JSScript scriptOfType:memoryMappedFromASCIIFile:withSourceURL:andBytecodeCache:inVirtualMachine:error:]): * inspector/ScriptDebugServer.cpp: (Inspector::ScriptDebugServer::sourceParsed): * parser/Nodes.h: (JSC::ScopeNode::sourceURL const): * runtime/CachedTypes.cpp: (JSC::CachedSourceProviderShape::encode): * runtime/Error.cpp: (JSC::addErrorInfo): * runtime/ScriptExecutable.h: (JSC::ScriptExecutable::sourceURL const): Source/WebCore: * Modules/cache/DOMCache.cpp: (WebCore::DOMCache::requestFromInfo): * Modules/fetch/FetchRequest.cpp: (WebCore::FetchRequest::urlString const): * Modules/fetch/FetchResponse.cpp: (WebCore::FetchResponse::fetch): * Modules/websockets/WebSocket.cpp: (WebCore::WebSocket::create): * accessibility/AccessibilityImageMapLink.cpp: (WebCore::AccessibilityImageMapLink::stringValueForMSAA const): * bindings/IDLTypes.h: (WebCore::IDLString::isNullValue): * bindings/js/CachedScriptSourceProvider.h: (WebCore::CachedScriptSourceProvider::CachedScriptSourceProvider): * bindings/js/JSDOMConvertStrings.h: (WebCore::JSConverter<IDLDOMString>::convert): (WebCore::Converter<IDLUSVString>::convert): (WebCore::JSConverter<IDLUSVString>::convert): * bindings/js/ScriptController.cpp: (WebCore::ScriptController::evaluateInWorld): (WebCore::ScriptController::evaluateModule): (WebCore::ScriptController::callInWorld): (WebCore::ScriptController::executeIfJavaScriptURL): * bindings/js/SerializedScriptValue.cpp: (WebCore::CloneSerializer::dumpIfTerminal): (WebCore::CloneSerializer::write): * css/CSSCursorImageValue.cpp: (WebCore::CSSCursorImageValue::updateCursorElement): * css/CSSImageValue.cpp: (WebCore::CSSImageValue::customCSSText const): (WebCore::CSSImageValue::createDeprecatedCSSOMWrapper const): * css/parser/CSSPropertyParser.cpp: (WebCore::consumeFontFaceSrcURI): * dom/Document.cpp: (WebCore::Document::processHttpEquiv): * dom/ExtensionStyleSheets.cpp: (WebCore::createExtensionsStyleSheet): * dom/InlineStyleSheetOwner.cpp: (WebCore::InlineStyleSheetOwner::createSheet): * dom/ScriptElement.cpp: (WebCore::ScriptElement::requestModuleScript): (WebCore::ScriptElement::executeClassicScript): * dom/StyledElement.cpp: (WebCore::StyledElement::styleAttributeChanged): * editing/cocoa/WebContentReaderCocoa.mm: (WebCore::sanitizeMarkupWithArchive): (WebCore::WebContentReader::readWebArchive): * html/HTMLFormControlElement.cpp: (WebCore::HTMLFormControlElement::formAction const): * html/HTMLFrameElementBase.cpp: (WebCore::HTMLFrameElementBase::canLoadURL const): * html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::shouldLoadLink): * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::selectNextSourceChild): * html/HTMLPlugInImageElement.cpp: (WebCore::HTMLPlugInImageElement::canLoadURL const): * html/parser/XSSAuditor.cpp: (WebCore::XSSAuditor::filterToken): * inspector/InspectorAuditResourcesObject.cpp: (WebCore::InspectorAuditResourcesObject::getResources): * inspector/InspectorStyleSheet.cpp: (WebCore::buildArrayForGroupings): * inspector/NetworkResourcesData.cpp: (WebCore::NetworkResourcesData::responseReceived): * inspector/agents/InspectorNetworkAgent.cpp: (WebCore::InspectorNetworkAgent::buildObjectForCachedResource): (WebCore::InspectorNetworkAgent::willSendRequest): * inspector/agents/InspectorPageAgent.cpp: (WebCore::InspectorPageAgent::getCookies): (WebCore::InspectorPageAgent::searchInResources): (WebCore::InspectorPageAgent::buildObjectForFrameTree): * inspector/agents/InspectorWorkerAgent.cpp: (WebCore::InspectorWorkerAgent::connectToWorkerInspectorProxy): * inspector/agents/WebConsoleAgent.cpp: (WebCore::WebConsoleAgent::didFailLoading): * inspector/agents/worker/ServiceWorkerAgent.cpp: (WebCore::ServiceWorkerAgent::getInitializationInfo): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::subresources const): * loader/DocumentLoader.h: (WebCore::DocumentLoader::clientRedirectDestinationForHistory const): (WebCore::DocumentLoader::serverRedirectDestinationForHistory const): * loader/FrameLoader.cpp: (WebCore::FrameLoader::submitForm): (WebCore::FrameLoader::receivedFirstData): (WebCore::FrameLoader::loadInSameDocument): (WebCore::FrameLoader::loadedResourceFromMemoryCache): (WebCore::createWindow): * loader/HistoryController.cpp: (WebCore::HistoryController::currentItemShouldBeReplaced const): * loader/ImageLoader.cpp: (WebCore::ImageLoader::updateFromElement): (WebCore::ImageLoader::dispatchPendingBeforeLoadEvent): * loader/LinkLoader.cpp: (WebCore::LinkLoader::preloadIfNeeded): (WebCore::LinkLoader::prefetchIfNeeded): * loader/MixedContentChecker.cpp: (WebCore::MixedContentChecker::checkFormForMixedContent const): * loader/NavigationScheduler.cpp: (WebCore::NavigationScheduler::shouldScheduleNavigation const): (WebCore::NavigationScheduler::scheduleLocationChange): * loader/PingLoader.cpp: (WebCore::PingLoader::loadImage): (WebCore::PingLoader::sendPing): * loader/ResourceLoadNotifier.cpp: (WebCore::ResourceLoadNotifier::dispatchWillSendRequest): * loader/SubframeLoader.cpp: (WebCore::SubframeLoader::requestObject): * loader/TextTrackLoader.cpp: (WebCore::TextTrackLoader::load): * loader/appcache/ApplicationCache.cpp: (WebCore::ApplicationCache::addResource): (WebCore::ApplicationCache::resourceForRequest): * loader/appcache/ApplicationCacheGroup.cpp: (WebCore::ApplicationCacheGroup::selectCache): (WebCore::ApplicationCacheGroup::finishedLoadingMainResource): (WebCore::ApplicationCacheGroup::didFinishLoadingEntry): (WebCore::ApplicationCacheGroup::didFailLoadingEntry): (WebCore::ApplicationCacheGroup::didFinishLoadingManifest): * loader/appcache/ApplicationCacheHost.cpp: (WebCore::ApplicationCacheHost::shouldLoadResourceFromApplicationCache): (WebCore::ApplicationCacheHost::getApplicationCacheFallbackResource): * loader/appcache/ApplicationCacheStorage.cpp: (WebCore::ApplicationCacheStorage::loadCacheGroup): (WebCore::ApplicationCacheStorage::findOrCreateCacheGroup): (WebCore::ApplicationCacheStorage::findInMemoryCacheGroup const): (WebCore::ApplicationCacheStorage::cacheGroupForURL): (WebCore::ApplicationCacheStorage::fallbackCacheGroupForURL): (WebCore::ApplicationCacheStorage::cacheGroupDestroyed): (WebCore::ApplicationCacheStorage::cacheGroupMadeObsolete): (WebCore::ApplicationCacheStorage::store): (WebCore::ApplicationCacheStorage::deleteCacheForOrigin): * loader/archive/ArchiveResourceCollection.cpp: (WebCore::ArchiveResourceCollection::addAllResources): (WebCore::ArchiveResourceCollection::addResource): (WebCore::ArchiveResourceCollection::archiveResourceForURL): * loader/cache/CachedCSSStyleSheet.cpp: (WebCore::CachedCSSStyleSheet::didAddClient): (WebCore::CachedCSSStyleSheet::checkNotify): * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::cachedResource const): (WebCore::CachedResourceLoader::requestResource): (WebCore::CachedResourceLoader::determineRevalidationPolicy const): (WebCore::CachedResourceLoader::notifyFinished): * loader/cache/CachedXSLStyleSheet.cpp: (WebCore::CachedXSLStyleSheet::didAddClient): (WebCore::CachedXSLStyleSheet::checkNotify): * page/ContextMenuController.cpp: (WebCore::ContextMenuController::checkOrEnableIfNeeded const): * page/DOMWindow.cpp: (WebCore::DOMWindow::setLocation): (WebCore::DOMWindow::createWindow): (WebCore::DOMWindow::open): * page/Location.cpp: (WebCore::Location::reload): * page/PageSerializer.cpp: (WebCore::PageSerializer::retrieveResourcesForProperties): * page/SecurityOrigin.cpp: (WebCore::SecurityOrigin::shouldIgnoreHost): * page/SecurityPolicy.cpp: (WebCore::SecurityPolicy::shouldInheritSecurityOriginFromOwner): (WebCore::SecurityPolicy::isBaseURLSchemeAllowed): * page/csp/ContentSecurityPolicy.cpp: (WebCore::ContentSecurityPolicy::reportViolation const): * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h: (WebCore::MediaPlayerPrivateAVFoundation::assetURL const): * platform/network/BlobRegistryImpl.cpp: (WebCore::BlobRegistryImpl::writeBlobToFilePath): * platform/network/mac/ResourceErrorMac.mm: (WebCore::ResourceError::platformLazyInit): * storage/StorageEventDispatcher.cpp: (WebCore::StorageEventDispatcher::dispatchSessionStorageEvents): (WebCore::StorageEventDispatcher::dispatchLocalStorageEvents): * svg/SVGImageLoader.cpp: (WebCore::SVGImageLoader::sourceURI const): * workers/WorkerScriptLoader.cpp: (WebCore::WorkerScriptLoader::loadSynchronously): * workers/service/ServiceWorkerRegistration.cpp: (WebCore::ServiceWorkerRegistration::scope const): * workers/service/ServiceWorkerRegistrationKey.cpp: (WebCore::ServiceWorkerRegistrationKey::hash const): (WebCore::ServiceWorkerRegistrationKey::isMatching const): * workers/service/context/ServiceWorkerDebuggable.cpp: (WebCore::ServiceWorkerDebuggable::ServiceWorkerDebuggable): * workers/service/server/SWServer.cpp: (WebCore::SWServer::startScriptFetch): * xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::send): Source/WebKit: * Shared/API/APIError.h: (API::Error::failingURL const): * Shared/API/c/WKSharedAPICast.h: (WebKit::toCopiedURLAPI): * UIProcess/API/Cocoa/WKBrowsingContextController.mm: (setUpPagePolicyClient): * UIProcess/Cocoa/SafeBrowsingWarningCocoa.mm: (WebKit::reportAnErrorURL): * UIProcess/Cocoa/UIDelegate.mm: (WebKit::requestUserMediaAuthorizationForFrame): (WebKit::UIDelegate::UIClient::checkUserMediaPermissionForOrigin): * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm: (WebKit::WebPasteboardProxy::readURLFromPasteboard): * UIProcess/ProvisionalPageProxy.cpp: (WebKit::ProvisionalPageProxy::cancel): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::maybeInitializeSandboxExtensionHandle): (WebKit::WebPageProxy::loadRequestWithNavigationShared): (WebKit::WebPageProxy::loadAlternateHTML): (WebKit::WebPageProxy::didStartProvisionalLoadForFrameShared): (WebKit::WebPageProxy::didExplicitOpenForFrame): (WebKit::WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrameShared): (WebKit::WebPageProxy::didChangeProvisionalURLForFrameShared): (WebKit::WebPageProxy::didSameDocumentNavigationForFrame): (WebKit::WebPageProxy::decidePolicyForNavigationAction): (WebKit::WebPageProxy::createNewPage): * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm: (-[WKWebProcessPlugInFrame URL]): * WebProcess/Plugins/Netscape/NetscapePluginStream.cpp: (WebKit::NetscapePluginStream::didReceiveResponse): * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::clickedLink): (WebKit::PDFPlugin::openWithNativeApplication): * WebProcess/Plugins/PluginView.cpp: (WebKit::PluginView::performURLRequest): (WebKit::PluginView::performJavaScriptURLRequest): * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: (WebKit::WebFrameLoaderClient::dispatchWillPerformClientRedirect): (WebKit::WebFrameLoaderClient::dispatchDidFailProvisionalLoad): (WebKit::WebFrameLoaderClient::shouldForceUniversalAccessFromLocalURL): * WebProcess/WebPage/WebFrame.cpp: (WebKit::WebFrame::info const): * WebProcess/WebStorage/StorageAreaMap.cpp: (WebKit::StorageAreaMap::setItem): (WebKit::StorageAreaMap::removeItem): (WebKit::StorageAreaMap::clear): * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::origin): Source/WebKitLegacy/mac: * DOM/DOMDocument.mm: (-[DOMDocument URL]): * DOM/DOMHTMLAnchorElement.mm: (-[DOMHTMLAnchorElement href]): * DOM/DOMHTMLAreaElement.mm: (-[DOMHTMLAreaElement href]): * DOM/DOMHTMLEmbedElement.mm: (-[DOMHTMLEmbedElement src]): * DOM/DOMHTMLFormElement.mm: (-[DOMHTMLFormElement action]): * DOM/DOMHTMLFrameElement.mm: (-[DOMHTMLFrameElement src]): (-[DOMHTMLFrameElement location]): * DOM/DOMHTMLHtmlElement.mm: (-[DOMHTMLHtmlElement manifest]): * DOM/DOMHTMLIFrameElement.mm: (-[DOMHTMLIFrameElement src]): * DOM/DOMHTMLImageElement.mm: (-[DOMHTMLImageElement longDesc]): (-[DOMHTMLImageElement src]): (-[DOMHTMLImageElement currentSrc]): (-[DOMHTMLImageElement lowsrc]): * DOM/DOMHTMLInputElement.mm: (-[DOMHTMLInputElement src]): * DOM/DOMHTMLLinkElement.mm: (-[DOMHTMLLinkElement href]): * DOM/DOMHTMLMediaElement.mm: (-[DOMHTMLMediaElement src]): (-[DOMHTMLMediaElement currentSrc]): * DOM/DOMHTMLModElement.mm: (-[DOMHTMLModElement cite]): * DOM/DOMHTMLObjectElement.mm: (-[DOMHTMLObjectElement data]): * DOM/DOMHTMLQuoteElement.mm: (-[DOMHTMLQuoteElement cite]): * DOM/DOMHTMLScriptElement.mm: (-[DOMHTMLScriptElement src]): * DOM/DOMHTMLVideoElement.mm: (-[DOMHTMLVideoElement poster]): * DOM/DOMNode.mm: (-[DOMNode baseURI]): * WebCoreSupport/WebFrameLoaderClient.mm: (WebFrameLoaderClient::updateGlobalHistory): (WebFrameLoaderClient::setTitle): * WebView/WebImmediateActionController.mm: (-[WebImmediateActionController _animationControllerForDataDetectedLink]): * WebView/WebNotification.mm: (-[WebNotification iconURL]): * WebView/WebScriptDebugger.mm: (WebScriptDebugger::sourceParsed): (toNSURL): Deleted. Source/WTF: Too many bugs have been caused by the compiler finding a way to make a String from a URL without being visible in the code. This does all the easy things to prepare to remove operator String& and operator NSString*. The hard things will be done in the smaller patch that actually removes them. * wtf/URL.cpp: (WTF::URL::protocolIsJavaScript const): * wtf/URL.h: Canonical link: https://commits.webkit.org/223910@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260709 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-25 21:28:45 +00:00
auto contents = StyleSheetContents::create(url.string(), CSSParserContext(document, url));
Share inline stylesheets between shadow trees https://bugs.webkit.org/show_bug.cgi?id=163353 Reviewed by Ryosuke Niwa and Andreas Kling. If shadow trees have identical inline stylesheets the data structures can be shared. In future this will also allow sharing style resolvers. * css/CSSStyleSheet.cpp: (WebCore::CSSStyleSheet::createInline): Move StyleSheetContents construction to the client. * css/parser/CSSParserMode.h: (WebCore::CSSParserContextHash::hash): (WebCore::CSSParserContextHash::equal): (WTF::HashTraits<WebCore::CSSParserContext>::constructDeletedValue): (WTF::HashTraits<WebCore::CSSParserContext>::isDeletedValue): (WTF::HashTraits<WebCore::CSSParserContext>::emptyValue): Make CSSParserContext hashable. * dom/ExtensionStyleSheets.cpp: (WebCore::createExtensionsStyleSheet): (WebCore::ExtensionStyleSheets::pageUserSheet): (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache): Don't use CSSStyleSheet::createInline, these are not really inline stylesheets. Code cleanups. * dom/InlineStyleSheetOwner.cpp: (WebCore::parserContextForForElement): (WebCore::makeInlineStyleSheetCacheKey): (WebCore::inlineStyleSheetCache): Implement a simple cache for sharing stylesheets with identical text and context. (WebCore::InlineStyleSheetOwner::createSheet): (WebCore::InlineStyleSheetOwner::clearCache): * dom/InlineStyleSheetOwner.h: * platform/MemoryPressureHandler.cpp: (WebCore::MemoryPressureHandler::releaseNoncriticalMemory): Canonical link: https://commits.webkit.org/181258@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207339 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-14 15:39:04 +00:00
auto styleSheet = CSSStyleSheet::create(contents.get(), document, true);
contents->setIsUserStyleSheet(level == UserStyleUserLevel);
contents->parseString(text);
return styleSheet;
}
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): Canonical link: https://commits.webkit.org/167594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-23 15:04:16 +00:00
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;
Document should always have a Settings. <https://webkit.org/b/120172> Reviewed by Antti Koivisto. Since a Document can't move between Frames, and it's either frameless or partnered with a Frame provided at construction time, we know that it will never need to switch between different Settings objects either. Give Document a Ref<Settings> that contains either the Frame's Settings or a default-constructed Settings object if frameless. Document::settings() is promoted to a reference getter. The bulk of this patch is removing now-unnecessary null checks. * Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp: (WebCore::WebKitMediaKeySession::mediaKeysStorageDirectory): * Modules/plugins/PluginReplacement.h: (WebCore::ReplacementPlugin::isEnabledBySettings): * Modules/plugins/QuickTimePluginReplacement.h: * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::isEnabledBySettings): * Modules/plugins/YouTubePluginReplacement.cpp: (WebCore::YouTubePluginReplacement::isEnabledBySettings): * Modules/plugins/YouTubePluginReplacement.h: * Modules/webaudio/AudioContext.cpp: (WebCore::AudioContext::constructCommon): * bindings/js/CachedScriptFetcher.cpp: (WebCore::CachedScriptFetcher::requestScriptWithCache): * css/CSSFontFace.cpp: (WebCore::CSSFontFace::appendSources): (WebCore::CSSFontFace::webFontsShouldAlwaysFallBack): * css/CSSFontSelector.cpp: (WebCore::CSSFontSelector::fallbackFontCount): (WebCore::CSSFontSelector::fallbackFontAt): * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertResize): * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyValueFontFamily): * css/StyleResolver.cpp: (WebCore::StyleResolver::StyleResolver): (WebCore::StyleResolver::defaultStyleForElement): (WebCore::StyleResolver::adjustRenderStyle): (WebCore::StyleResolver::checkForGenericFamilyChange): (WebCore::StyleResolver::initializeFontStyle): * css/StyleResolver.h: (WebCore::StyleResolver::settings): (WebCore::StyleResolver::documentSettings): Deleted. * css/parser/CSSParser.cpp: (WebCore::CSSParserContext::CSSParserContext): * dom/Document.cpp: (WebCore::Document::Document): (WebCore::Document::setReadyState): (WebCore::Document::setVisualUpdatesAllowed): (WebCore::Document::defaultCharsetForLegacyBindings): (WebCore::Document::recalcStyle): (WebCore::Document::implicitClose): (WebCore::Document::minimumLayoutDelay): (WebCore::Document::setDomain): (WebCore::Document::audioPlaybackRequiresUserGesture): (WebCore::Document::videoPlaybackRequiresUserGesture): (WebCore::Document::storageBlockingStateDidChange): (WebCore::Document::isTelephoneNumberParsingEnabled): (WebCore::Document::initSecurityContext): (WebCore::Document::initDNSPrefetch): (WebCore::Document::getCachedLocale): (WebCore::Document::shouldEnforceContentDispositionAttachmentSandbox): (WebCore::Document::settings): Deleted. * dom/Document.h: (WebCore::Document::settings): * dom/Element.cpp: (WebCore::subpixelMetricsEnabled): * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::pageUserSheet): * dom/ScriptExecutionContext.cpp: (WebCore::ScriptExecutionContext::dispatchErrorEvent): * dom/ScriptableDocumentParser.cpp: (WebCore::ScriptableDocumentParser::ScriptableDocumentParser): * dom/ScriptedAnimationController.cpp: (WebCore::ScriptedAnimationController::requestAnimationFrameEnabled): * dom/make_names.pl: (printConstructorInterior): * editing/Editor.cpp: * editing/markup.cpp: (WebCore::createMarkupInternal): * html/FTPDirectoryDocument.cpp: (WebCore::createTemplateDocumentData): * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::setActive): (WebCore::HTMLAnchorElement::sendPings): (WebCore::HTMLAnchorElement::treatLinkAsLiveForEventType): * html/HTMLAppletElement.cpp: (WebCore::HTMLAppletElement::canEmbedJava): * html/HTMLCanvasElement.cpp: (WebCore::HTMLCanvasElement::getContext2d): (WebCore::shouldEnableWebGL): (WebCore::HTMLCanvasElement::shouldAccelerate): * html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::submitImplicitly): * html/HTMLFrameElementBase.cpp: (WebCore::HTMLFrameElementBase::setLocation): * html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::updateImageControls): * html/HTMLImageLoader.cpp: (WebCore::HTMLImageLoader::sourceURI): * html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::setupDateTimeChooserParameters): * html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::process): * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::mediaPlayerMediaKeysStorageDirectory): (WebCore::HTMLMediaElement::mediaPlayerAcceleratedCompositingEnabled): (WebCore::HTMLMediaElement::enterFullscreen): (WebCore::HTMLMediaElement::exitFullscreen): (WebCore::HTMLMediaElement::mediaPlayerNeedsSiteSpecificHacks): (WebCore::HTMLMediaElement::mediaPlayerNetworkInterfaceName): (WebCore::HTMLMediaElement::setMediaControlsDependOnPageScaleFactor): (WebCore::HTMLMediaElement::doesHaveAttribute): * html/HTMLVideoElement.cpp: (WebCore::HTMLVideoElement::HTMLVideoElement): * html/MediaElementSession.cpp: (WebCore::MediaElementSession::wirelessVideoPlaybackDisabled): (WebCore::MediaElementSession::requiresFullscreenForVideoPlayback): (WebCore::MediaElementSession::allowsAutomaticMediaDataLoading): (WebCore::MediaElementSession::allowsPictureInPicture): (WebCore::MediaElementSession::maximumMediaSourceBufferSize): * html/parser/HTMLParserOptions.cpp: (WebCore::HTMLParserOptions::HTMLParserOptions): * html/shadow/MediaControlElements.cpp: (WebCore::MediaControlFullscreenButtonElement::defaultEventHandler): * loader/LinkLoader.cpp: (WebCore::LinkLoader::loadLink): * page/csp/ContentSecurityPolicy.cpp: (WebCore::ContentSecurityPolicy::allowContentSecurityPolicySourceStarToMatchAnyProtocol): * rendering/SimpleLineLayout.cpp: (WebCore::SimpleLineLayout::toggleSimpleLineLayout): * style/StyleFontSizeFunctions.cpp: (WebCore::Style::computedFontSizeFromSpecifiedSize): (WebCore::Style::fontSizeForKeyword): (WebCore::Style::legacyFontSizeForPixelSize): * style/StyleScope.cpp: (WebCore::Style::Scope::collectActiveStyleSheets): * xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::usesDashboardBackwardCompatibilityMode): Canonical link: https://commits.webkit.org/185080@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211964 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-02-09 17:47:33 +00:00
m_pageUserSheet = createExtensionsStyleSheet(m_document, m_document.settings().userStyleSheetLocation(), userSheetText, UserStyleUserLevel);
Share inline stylesheets between shadow trees https://bugs.webkit.org/show_bug.cgi?id=163353 Reviewed by Ryosuke Niwa and Andreas Kling. If shadow trees have identical inline stylesheets the data structures can be shared. In future this will also allow sharing style resolvers. * css/CSSStyleSheet.cpp: (WebCore::CSSStyleSheet::createInline): Move StyleSheetContents construction to the client. * css/parser/CSSParserMode.h: (WebCore::CSSParserContextHash::hash): (WebCore::CSSParserContextHash::equal): (WTF::HashTraits<WebCore::CSSParserContext>::constructDeletedValue): (WTF::HashTraits<WebCore::CSSParserContext>::isDeletedValue): (WTF::HashTraits<WebCore::CSSParserContext>::emptyValue): Make CSSParserContext hashable. * dom/ExtensionStyleSheets.cpp: (WebCore::createExtensionsStyleSheet): (WebCore::ExtensionStyleSheets::pageUserSheet): (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache): Don't use CSSStyleSheet::createInline, these are not really inline stylesheets. Code cleanups. * dom/InlineStyleSheetOwner.cpp: (WebCore::parserContextForForElement): (WebCore::makeInlineStyleSheetCacheKey): (WebCore::inlineStyleSheetCache): Implement a simple cache for sharing stylesheets with identical text and context. (WebCore::InlineStyleSheetOwner::createSheet): (WebCore::InlineStyleSheetOwner::clearCache): * dom/InlineStyleSheetOwner.h: * platform/MemoryPressureHandler.cpp: (WebCore::MemoryPressureHandler::releaseNoncriticalMemory): Canonical link: https://commits.webkit.org/181258@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207339 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-14 15:39:04 +00:00
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): Canonical link: https://commits.webkit.org/167594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-23 15:04:16 +00:00
return m_pageUserSheet.get();
}
void ExtensionStyleSheets::clearPageUserSheet()
{
if (m_pageUserSheet) {
m_pageUserSheet = nullptr;
Style resolver should be updated lazily https://bugs.webkit.org/show_bug.cgi?id=163721 Reviewed by Andreas Kling. Currently when stylesheets change in some way we generally update style resolvers and invalidate style immediately. We should do this lazily to avoid unnecessary work. Also improve naming of the stylesheet invalidation functions and use more optimal functions in some places. * css/CSSComputedStyleDeclaration.cpp: (WebCore::updateStyleIfNeededForNode): * css/CSSStyleSheet.cpp: (WebCore::CSSStyleSheet::didMutateRules): (WebCore::CSSStyleSheet::didMutate): (WebCore::CSSStyleSheet::setDisabled): * css/StyleResolver.cpp: (WebCore::StyleResolver::StyleResolver): Initialize root style font with null font selector. This avoids hitting a CSSFontSelector assert in fast/media/mq-relative-constraints-08.html where media query evaluation requires font information before it is ready. Exposed by increased laziness in this patch. * dom/Document.cpp: (WebCore::Document::setContentLanguage): (WebCore::Document::updateLayoutIgnorePendingStylesheets): (WebCore::Document::isPageBoxVisible): (WebCore::Document::pageSizeAndMarginsInPixels): (WebCore::Document::processHttpEquiv): (WebCore::Document::setSelectedStylesheetSet): (WebCore::Document::didInsertInDocumentShadowRoot): (WebCore::Document::didRemoveInDocumentShadowRoot): * dom/Document.h: (WebCore::Document::inDocumentShadowRoots): Track all shadow roots in the document. This allows us to find and flush style scopes cheaply. * dom/Element.cpp: (WebCore::Element::computedStyle): * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::ExtensionStyleSheets): (WebCore::ExtensionStyleSheets::clearPageUserSheet): (WebCore::ExtensionStyleSheets::updatePageUserSheet): (WebCore::ExtensionStyleSheets::invalidateInjectedStyleSheetCache): (WebCore::ExtensionStyleSheets::addUserStyleSheet): (WebCore::ExtensionStyleSheets::addAuthorStyleSheetForTesting): (WebCore::ExtensionStyleSheets::addDisplayNoneSelector): (WebCore::ExtensionStyleSheets::maybeAddContentExtensionSheet): (WebCore::ExtensionStyleSheets::styleResolverChangedTimerFired): Deleted. Since updates are now done lazily we don't need a special timer for extension stylesheets. * dom/ExtensionStyleSheets.h: * dom/ProcessingInstruction.cpp: (WebCore::ProcessingInstruction::checkStyleSheet): (WebCore::ProcessingInstruction::sheetLoaded): (WebCore::ProcessingInstruction::removedFrom): * dom/ShadowRoot.cpp: (WebCore::ShadowRoot::ShadowRoot): (WebCore::ShadowRoot::insertedInto): (WebCore::ShadowRoot::removedFrom): (WebCore::ShadowRoot::styleScope): * dom/ShadowRoot.h: * html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::setDisabledState): (WebCore::HTMLLinkElement::parseAttribute): (WebCore::HTMLLinkElement::process): (WebCore::HTMLLinkElement::removePendingSheet): * html/HTMLStyleElement.cpp: (WebCore::HTMLStyleElement::parseAttribute): * inspector/InspectorCSSAgent.cpp: (WebCore::InspectorCSSAgent::createInspectorStyleSheetForDocument): (WebCore::InspectorCSSAgent::forcePseudoState): (WebCore::InspectorCSSAgent::resetPseudoStates): * inspector/InspectorPageAgent.cpp: (WebCore::InspectorPageAgent::setEmulatedMedia): * page/Frame.cpp: (WebCore::Frame::setPrinting): * page/FrameView.cpp: (WebCore::FrameView::layout): (WebCore::FrameView::setPagination): (WebCore::FrameView::setViewportSizeForCSSViewportUnits): * page/Page.cpp: (WebCore::Page::setViewMode): (WebCore::Page::setNeedsRecalcStyleInAllFrames): (WebCore::Page::invalidateInjectedStyleSheetCacheInAllFrames): * style/StyleScope.cpp: (WebCore::Style::Scope::setPreferredStylesheetSetName): (WebCore::Style::Scope::setSelectedStylesheetSetName): (WebCore::Style::Scope::removePendingSheet): (WebCore::Style::Scope::removeStyleSheetCandidateNode): (WebCore::Style::Scope::activeStyleSheetsForInspector): (WebCore::Style::Scope::flushPendingUpdate): Also flush descendant shadow roots. (WebCore::Style::Scope::scheduleUpdate): (WebCore::Style::Scope::didChangeActiveStyleSheetCandidates): Make lazy. (WebCore::Style::Scope::didChangeStyleSheetContents): Make lazy. (WebCore::Style::Scope::didChangeStyleSheetEnvironment): Environment changes also affect author shadow roots. (WebCore::Style::Scope::styleSheetsForStyleSheetList): (WebCore::Style::Scope::scheduleActiveSetUpdate): Deleted. (WebCore::Style::Scope::didChangeCandidatesForActiveSet): Deleted. (WebCore::Style::Scope::didChangeContentsOrInterpretation): Deleted. Improved naming of these and split didChangeContentsOrInterpretation into two separate functions. * style/StyleScope.h: (WebCore::Style::Scope::styleSheetsForStyleSheetList): Deleted. (WebCore::Style::Scope::setPreferredStylesheetSetName): Deleted. (WebCore::Style::Scope::setSelectedStylesheetSetName): Deleted. * svg/SVGFontFaceElement.cpp: (WebCore::SVGFontFaceElement::rebuildFontFace): (WebCore::SVGFontFaceElement::removedFrom): * testing/Internals.cpp: (WebCore::Internals::resetToConsistentState): Ensure that cationsStyleSheetOverride really becomes empty. Some tests rely on not having suprise inserted stylesheets. Previously this was racy and the patch affected order of things. (WebCore::Internals::styleChangeType): * xml/XMLTreeViewer.cpp: (WebCore::XMLTreeViewer::transformDocumentToTreeView): * xml/parser/XMLDocumentParser.cpp: (WebCore::XMLDocumentParser::end): * xml/parser/XMLDocumentParserLibxml2.cpp: (WebCore::XMLDocumentParser::doEnd): Canonical link: https://commits.webkit.org/181549@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207669 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-21 13:36:45 +00:00
m_document.styleScope().didChangeStyleSheetEnvironment();
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): Canonical link: https://commits.webkit.org/167594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-23 15:04:16 +00:00
}
}
void ExtensionStyleSheets::updatePageUserSheet()
{
clearPageUserSheet();
if (pageUserSheet())
Style resolver should be updated lazily https://bugs.webkit.org/show_bug.cgi?id=163721 Reviewed by Andreas Kling. Currently when stylesheets change in some way we generally update style resolvers and invalidate style immediately. We should do this lazily to avoid unnecessary work. Also improve naming of the stylesheet invalidation functions and use more optimal functions in some places. * css/CSSComputedStyleDeclaration.cpp: (WebCore::updateStyleIfNeededForNode): * css/CSSStyleSheet.cpp: (WebCore::CSSStyleSheet::didMutateRules): (WebCore::CSSStyleSheet::didMutate): (WebCore::CSSStyleSheet::setDisabled): * css/StyleResolver.cpp: (WebCore::StyleResolver::StyleResolver): Initialize root style font with null font selector. This avoids hitting a CSSFontSelector assert in fast/media/mq-relative-constraints-08.html where media query evaluation requires font information before it is ready. Exposed by increased laziness in this patch. * dom/Document.cpp: (WebCore::Document::setContentLanguage): (WebCore::Document::updateLayoutIgnorePendingStylesheets): (WebCore::Document::isPageBoxVisible): (WebCore::Document::pageSizeAndMarginsInPixels): (WebCore::Document::processHttpEquiv): (WebCore::Document::setSelectedStylesheetSet): (WebCore::Document::didInsertInDocumentShadowRoot): (WebCore::Document::didRemoveInDocumentShadowRoot): * dom/Document.h: (WebCore::Document::inDocumentShadowRoots): Track all shadow roots in the document. This allows us to find and flush style scopes cheaply. * dom/Element.cpp: (WebCore::Element::computedStyle): * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::ExtensionStyleSheets): (WebCore::ExtensionStyleSheets::clearPageUserSheet): (WebCore::ExtensionStyleSheets::updatePageUserSheet): (WebCore::ExtensionStyleSheets::invalidateInjectedStyleSheetCache): (WebCore::ExtensionStyleSheets::addUserStyleSheet): (WebCore::ExtensionStyleSheets::addAuthorStyleSheetForTesting): (WebCore::ExtensionStyleSheets::addDisplayNoneSelector): (WebCore::ExtensionStyleSheets::maybeAddContentExtensionSheet): (WebCore::ExtensionStyleSheets::styleResolverChangedTimerFired): Deleted. Since updates are now done lazily we don't need a special timer for extension stylesheets. * dom/ExtensionStyleSheets.h: * dom/ProcessingInstruction.cpp: (WebCore::ProcessingInstruction::checkStyleSheet): (WebCore::ProcessingInstruction::sheetLoaded): (WebCore::ProcessingInstruction::removedFrom): * dom/ShadowRoot.cpp: (WebCore::ShadowRoot::ShadowRoot): (WebCore::ShadowRoot::insertedInto): (WebCore::ShadowRoot::removedFrom): (WebCore::ShadowRoot::styleScope): * dom/ShadowRoot.h: * html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::setDisabledState): (WebCore::HTMLLinkElement::parseAttribute): (WebCore::HTMLLinkElement::process): (WebCore::HTMLLinkElement::removePendingSheet): * html/HTMLStyleElement.cpp: (WebCore::HTMLStyleElement::parseAttribute): * inspector/InspectorCSSAgent.cpp: (WebCore::InspectorCSSAgent::createInspectorStyleSheetForDocument): (WebCore::InspectorCSSAgent::forcePseudoState): (WebCore::InspectorCSSAgent::resetPseudoStates): * inspector/InspectorPageAgent.cpp: (WebCore::InspectorPageAgent::setEmulatedMedia): * page/Frame.cpp: (WebCore::Frame::setPrinting): * page/FrameView.cpp: (WebCore::FrameView::layout): (WebCore::FrameView::setPagination): (WebCore::FrameView::setViewportSizeForCSSViewportUnits): * page/Page.cpp: (WebCore::Page::setViewMode): (WebCore::Page::setNeedsRecalcStyleInAllFrames): (WebCore::Page::invalidateInjectedStyleSheetCacheInAllFrames): * style/StyleScope.cpp: (WebCore::Style::Scope::setPreferredStylesheetSetName): (WebCore::Style::Scope::setSelectedStylesheetSetName): (WebCore::Style::Scope::removePendingSheet): (WebCore::Style::Scope::removeStyleSheetCandidateNode): (WebCore::Style::Scope::activeStyleSheetsForInspector): (WebCore::Style::Scope::flushPendingUpdate): Also flush descendant shadow roots. (WebCore::Style::Scope::scheduleUpdate): (WebCore::Style::Scope::didChangeActiveStyleSheetCandidates): Make lazy. (WebCore::Style::Scope::didChangeStyleSheetContents): Make lazy. (WebCore::Style::Scope::didChangeStyleSheetEnvironment): Environment changes also affect author shadow roots. (WebCore::Style::Scope::styleSheetsForStyleSheetList): (WebCore::Style::Scope::scheduleActiveSetUpdate): Deleted. (WebCore::Style::Scope::didChangeCandidatesForActiveSet): Deleted. (WebCore::Style::Scope::didChangeContentsOrInterpretation): Deleted. Improved naming of these and split didChangeContentsOrInterpretation into two separate functions. * style/StyleScope.h: (WebCore::Style::Scope::styleSheetsForStyleSheetList): Deleted. (WebCore::Style::Scope::setPreferredStylesheetSetName): Deleted. (WebCore::Style::Scope::setSelectedStylesheetSetName): Deleted. * svg/SVGFontFaceElement.cpp: (WebCore::SVGFontFaceElement::rebuildFontFace): (WebCore::SVGFontFaceElement::removedFrom): * testing/Internals.cpp: (WebCore::Internals::resetToConsistentState): Ensure that cationsStyleSheetOverride really becomes empty. Some tests rely on not having suprise inserted stylesheets. Previously this was racy and the patch affected order of things. (WebCore::Internals::styleChangeType): * xml/XMLTreeViewer.cpp: (WebCore::XMLTreeViewer::transformDocumentToTreeView): * xml/parser/XMLDocumentParser.cpp: (WebCore::XMLDocumentParser::end): * xml/parser/XMLDocumentParserLibxml2.cpp: (WebCore::XMLDocumentParser::doEnd): Canonical link: https://commits.webkit.org/181549@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207669 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-21 13:36:45 +00:00
m_document.styleScope().didChangeStyleSheetEnvironment();
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): Canonical link: https://commits.webkit.org/167594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-23 15:04:16 +00:00
}
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;
Web Inspector: unable to edit or view the source of style sheets injected by safari app extensions https://bugs.webkit.org/show_bug.cgi?id=205900 <rdar://problem/57898773> Reviewed by Timothy Hatcher. Remove the restrictions around `CSS.StyleSheetOrigin.User` style sheets, thereby allowing Web Inspector to get the source information that is necessary to show the "resource" in the Sources Tab. Source/WebCore: * dom/ExtensionStyleSheets.h: * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache const): (WebCore::ExtensionStyleSheets::contentForInjectedStyleSheet const): Added. Save a copy of the string source of any injected style sheet and provide a way to get it for any given `CSSStyleSheet`. * style/StyleScope.cpp: (WebCore::Style::Scope::activeStyleSheetsForInspector): * style/InspectorCSSOMWrappers.cpp: (WebCore::Style::InspectorCSSOMWrappers::collectDocumentWrappers): Include all types of extension style sheets when collecting active rules and style sheets for Web Inspector to instrument. * inspector/InspectorStyleSheet.cpp: * inspector/InspectorStyleSheet.h: (WebCore::InspectorStyleSheet::buildObjectForRule): (WebCore::InspectorStyleSheet::originalStyleSheetText const): (WebCore::InspectorStyleSheet::resourceStyleSheetText const): (WebCore::InspectorStyleSheet::inlineStyleSheetText const): (WebCore::InspectorStyleSheet::extensionStyleSheetText const): Added. Source/WebInspectorUI: * UserInterface/Models/CSSStyleSheet.js: (WI.CSSStyleSheet.prototype.get displayName): (WI.CSSStyleSheet.prototype.get injected): Added. (WI.CSSStyleSheet.prototype.get anonymous): Added. * UserInterface/Models/DOMNodeStyles.js: (WI.DOMNodeStyles.prototype._parseRulePayload): * UserInterface/Models/CSSRule.js: (WI.CSSRule): (WI.CSSRule.prototype.get editable): (WI.CSSRule.prototype._selectorResolved): Attempt to create a source code location for any style sheet with a source range, not just for the Inspector Style Sheet. * UserInterface/Views/CSSStyleSheetTreeElement.js: (WI.CSSStyleSheetTreeElement): Instead of hardcoding "Inspector Style Sheet", use the associated `WI.CSSStyleSheet`'s info. * UserInterface/Views/FrameTreeElement.js: (WI.FrameTreeElement): (WI.FrameTreeElement.prototype.onattach): (WI.FrameTreeElement.prototype.ondetach): (WI.FrameTreeElement.prototype._styleSheetAdded): (WI.FrameTreeElement.prototype._styleSheetRemoved): Added. Ensure that only non-injected non-anonymous style sheets are shown under frames. * UserInterface/Views/SourcesNavigationSidebarPanel.js: (WI.SourcesNavigationSidebarPanel): (WI.SourcesNavigationSidebarPanel.prototype._compareTreeElements): (WI.SourcesNavigationSidebarPanel.prototype._addResource): (WI.SourcesNavigationSidebarPanel.prototype._addStyleSheet): Added. (WI.SourcesNavigationSidebarPanel.prototype._handleResourceGroupingModeChanged): (WI.SourcesNavigationSidebarPanel.prototype._handleCSSStyleSheetAdded): Added. (WI.SourcesNavigationSidebarPanel.prototype._handleCSSStyleSheetRemoved): Added. Add "Extension Style Sheets", "Extra Style Sheets", and "Anonymous Style Sheets" folders, just like for scripts, with a similar logic as to when style sheets are added to each. * UserInterface/Views/OpenResourceDialog.js: (WI.OpenResourceDialog): (WI.OpenResourceDialog.prototype.representedObjectIsValid): Added. (WI.OpenResourceDialog.prototype._populateResourceTreeOutline): (WI.OpenResourceDialog.prototype._populateResourceTreeOutline.createTreeElement): (WI.OpenResourceDialog.prototype.didDismissDialog): (WI.OpenResourceDialog.prototype.didPresentDialog): (WI.OpenResourceDialog.prototype._removeResource): Added. (WI.OpenResourceDialog.prototype._resourceWasRemoved): Added. (WI.OpenResourceDialog.prototype._scriptAdded): (WI.OpenResourceDialog.prototype._scriptRemoved): Added. (WI.OpenResourceDialog.prototype._handleStyleSheetAdded): Added. (WI.OpenResourceDialog.prototype._handleStyleSheetRemoved): Added. Add any non-injected non-anonymous style sheets when populating the list of resources. Drive-by: remove listings for any resources that are removed from the inspected page. * UserInterface/Views/ResourceTreeElement.js: (WI.ResourceTreeElement.compareResourceTreeElements): (WI.ResourceTreeElement.compareResourceTreeElements.resolvedType): Added. Support comparisons against non-resource tree elements. * Localizations/en.lproj/localizedStrings.js: Canonical link: https://commits.webkit.org/219045@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254186 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-08 05:02:02 +00:00
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): Canonical link: https://commits.webkit.org/167594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-23 15:04:16 +00:00
m_injectedStyleSheetCacheValid = true;
m_injectedUserStyleSheets.clear();
m_injectedAuthorStyleSheets.clear();
Web Inspector: unable to edit or view the source of style sheets injected by safari app extensions https://bugs.webkit.org/show_bug.cgi?id=205900 <rdar://problem/57898773> Reviewed by Timothy Hatcher. Remove the restrictions around `CSS.StyleSheetOrigin.User` style sheets, thereby allowing Web Inspector to get the source information that is necessary to show the "resource" in the Sources Tab. Source/WebCore: * dom/ExtensionStyleSheets.h: * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache const): (WebCore::ExtensionStyleSheets::contentForInjectedStyleSheet const): Added. Save a copy of the string source of any injected style sheet and provide a way to get it for any given `CSSStyleSheet`. * style/StyleScope.cpp: (WebCore::Style::Scope::activeStyleSheetsForInspector): * style/InspectorCSSOMWrappers.cpp: (WebCore::Style::InspectorCSSOMWrappers::collectDocumentWrappers): Include all types of extension style sheets when collecting active rules and style sheets for Web Inspector to instrument. * inspector/InspectorStyleSheet.cpp: * inspector/InspectorStyleSheet.h: (WebCore::InspectorStyleSheet::buildObjectForRule): (WebCore::InspectorStyleSheet::originalStyleSheetText const): (WebCore::InspectorStyleSheet::resourceStyleSheetText const): (WebCore::InspectorStyleSheet::inlineStyleSheetText const): (WebCore::InspectorStyleSheet::extensionStyleSheetText const): Added. Source/WebInspectorUI: * UserInterface/Models/CSSStyleSheet.js: (WI.CSSStyleSheet.prototype.get displayName): (WI.CSSStyleSheet.prototype.get injected): Added. (WI.CSSStyleSheet.prototype.get anonymous): Added. * UserInterface/Models/DOMNodeStyles.js: (WI.DOMNodeStyles.prototype._parseRulePayload): * UserInterface/Models/CSSRule.js: (WI.CSSRule): (WI.CSSRule.prototype.get editable): (WI.CSSRule.prototype._selectorResolved): Attempt to create a source code location for any style sheet with a source range, not just for the Inspector Style Sheet. * UserInterface/Views/CSSStyleSheetTreeElement.js: (WI.CSSStyleSheetTreeElement): Instead of hardcoding "Inspector Style Sheet", use the associated `WI.CSSStyleSheet`'s info. * UserInterface/Views/FrameTreeElement.js: (WI.FrameTreeElement): (WI.FrameTreeElement.prototype.onattach): (WI.FrameTreeElement.prototype.ondetach): (WI.FrameTreeElement.prototype._styleSheetAdded): (WI.FrameTreeElement.prototype._styleSheetRemoved): Added. Ensure that only non-injected non-anonymous style sheets are shown under frames. * UserInterface/Views/SourcesNavigationSidebarPanel.js: (WI.SourcesNavigationSidebarPanel): (WI.SourcesNavigationSidebarPanel.prototype._compareTreeElements): (WI.SourcesNavigationSidebarPanel.prototype._addResource): (WI.SourcesNavigationSidebarPanel.prototype._addStyleSheet): Added. (WI.SourcesNavigationSidebarPanel.prototype._handleResourceGroupingModeChanged): (WI.SourcesNavigationSidebarPanel.prototype._handleCSSStyleSheetAdded): Added. (WI.SourcesNavigationSidebarPanel.prototype._handleCSSStyleSheetRemoved): Added. Add "Extension Style Sheets", "Extra Style Sheets", and "Anonymous Style Sheets" folders, just like for scripts, with a similar logic as to when style sheets are added to each. * UserInterface/Views/OpenResourceDialog.js: (WI.OpenResourceDialog): (WI.OpenResourceDialog.prototype.representedObjectIsValid): Added. (WI.OpenResourceDialog.prototype._populateResourceTreeOutline): (WI.OpenResourceDialog.prototype._populateResourceTreeOutline.createTreeElement): (WI.OpenResourceDialog.prototype.didDismissDialog): (WI.OpenResourceDialog.prototype.didPresentDialog): (WI.OpenResourceDialog.prototype._removeResource): Added. (WI.OpenResourceDialog.prototype._resourceWasRemoved): Added. (WI.OpenResourceDialog.prototype._scriptAdded): (WI.OpenResourceDialog.prototype._scriptRemoved): Added. (WI.OpenResourceDialog.prototype._handleStyleSheetAdded): Added. (WI.OpenResourceDialog.prototype._handleStyleSheetRemoved): Added. Add any non-injected non-anonymous style sheets when populating the list of resources. Drive-by: remove listings for any resources that are removed from the inspected page. * UserInterface/Views/ResourceTreeElement.js: (WI.ResourceTreeElement.compareResourceTreeElements): (WI.ResourceTreeElement.compareResourceTreeElements.resolvedType): Added. Support comparisons against non-resource tree elements. * Localizations/en.lproj/localizedStrings.js: Canonical link: https://commits.webkit.org/219045@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254186 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-08 05:02:02 +00:00
m_injectedStyleSheetToSource.clear();
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): Canonical link: https://commits.webkit.org/167594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-23 15:04:16 +00:00
Page* owningPage = m_document.page();
if (!owningPage)
return;
Add baseURL version of _WKUserStyleSheet forWKWebView. https://bugs.webkit.org/show_bug.cgi?id=211926 rdar://problem/62074675 Reviewed by Devin Rousso. Source/WebCore: Consolidate the paths taken for adding a UserStyleSheet. The m_injectedStyleSheetToSource was missing for page specific style sheets since it was another loop. * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache const): (WebCore::ExtensionStyleSheets::injectPageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::removePageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::detachFromDocument): * dom/ExtensionStyleSheets.h: Source/WebKit: * UIProcess/API/Cocoa/_WKUserStyleSheet.h: * UIProcess/API/Cocoa/_WKUserStyleSheet.mm: (-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:baseURL:level:userContentWorld:]): Added. (-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:level:userContentWorld:]): Clean up WebCore::UserStyleSheet initializer. (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:]): Ditto. (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]): Ditto. (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:userContentWorld:]): Ditto. (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:level:userContentWorld:]): Ditto. Canonical link: https://commits.webkit.org/224820@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261726 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-15 00:33:37 +00:00
auto addStyleSheet = [&](const UserStyleSheet& userStyleSheet) {
auto sheet = createExtensionsStyleSheet(const_cast<Document&>(m_document), userStyleSheet.url(), userStyleSheet.source(), userStyleSheet.level());
m_injectedStyleSheetToSource.set(sheet.copyRef(), userStyleSheet.source());
if (sheet->contents().isUserStyleSheet())
m_injectedUserStyleSheets.append(WTFMove(sheet));
Add an SPI to allow UserStyleSheet injection to target a specific WKWebView https://bugs.webkit.org/show_bug.cgi?id=208575 <rdar://problem/59773690> Reviewed by Brady Eidson. Source/WebCore: Add a new Optional<PageIdentifier> member to UserStyleSheet which indicates whether the UserStyleSheet is supposed to be injected for all WKWebViews, or only a specific top-level WKWebView associated with a Page with the give ID. In ExtensionStyleSheets::updateInjectedStyleSheetCache(), UserStyleSheets with a specified pageID are ignored. Instead, we now also consider CSSStyleSheets listed in the new m_pageSpecificStyleSheets which contains page-specific stylesheets to be injected for the associated Document. The new Page::injectUserStyleSheet() method allows the addition of a UserStyleSheet on its documents' ExtensionStyleSheets, and will call this method either for the main frame's Document, or all Documents, depending on the UserStyleSheet's configuration. Finally, these new targeted UserStyleSheets can be removed via Page::removeInjectedUserStyleSheet() and ExtensionStyleSheets::removePageSpecificUserStyleSheet(). * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache const): (WebCore::ExtensionStyleSheets::injectPageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::removePageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::detachFromDocument): * dom/ExtensionStyleSheets.h: * page/Page.cpp: (WebCore::Page::injectUserStyleSheet): (WebCore::Page::removeInjectedUserStyleSheet): * page/Page.h: * page/UserStyleSheet.h: (WebCore::UserStyleSheet::UserStyleSheet): (WebCore::UserStyleSheet::pageID const): Source/WebKit: Since WebCore adds a new Optional<PageIdentifier> member to UserStyleSheet, we now encode that member to be preserved across UI and Web processes. Using this new member, WebUserContentController now determines that a UserStyleSheet meant to target a specific page was added in addUserStyleSheetInternal(), finds the matching WebPage, and calls injectUserStyleSheet() on its backing Page object. Conversely, WebUserContentController::removeUserStyleSheetInternal() will call into Page::removeInjectedUserStyleSheet(). Finally, we offer a new initializer on _WKUserStyleSheet to target a specific WKWebView, and its page's ID will be set on the backing UserStyleSheet. * Shared/WebCoreArgumentCoders.cpp: (IPC::ArgumentCoder<UserStyleSheet>::encode): (IPC::ArgumentCoder<UserStyleSheet>::decode): * UIProcess/API/Cocoa/_WKUserStyleSheet.h: * UIProcess/API/Cocoa/_WKUserStyleSheet.mm: (-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:userContentWorld:]): * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addUserStyleSheetInternal): (WebKit::WebUserContentController::removeUserStyleSheetInternal): Tools: Add new tests for the new SPI which check: 1. that specifying forWKWebView: when initializing a _WKUserStyleSheet will inject the provided CSS source in the specified WKWebView alone, 2. that the same test works with two WKWebViews with a shared WKWebKitConfiguration, 3. that a WKWebView-specific _WKUserStyleSheet can be removed, 4. that a WKWebView-specific _WKUserStyleSheet can be added twice and removed once and be removed as expected, 5. and that a WKWebView-specific _WKUserStyleSheet is automatically removed when navigating to a new page, 6. and that the same test also works with PSON enabled. * TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm: Canonical link: https://commits.webkit.org/221509@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@257870 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-03-04 20:05:38 +00:00
else
Add baseURL version of _WKUserStyleSheet forWKWebView. https://bugs.webkit.org/show_bug.cgi?id=211926 rdar://problem/62074675 Reviewed by Devin Rousso. Source/WebCore: Consolidate the paths taken for adding a UserStyleSheet. The m_injectedStyleSheetToSource was missing for page specific style sheets since it was another loop. * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache const): (WebCore::ExtensionStyleSheets::injectPageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::removePageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::detachFromDocument): * dom/ExtensionStyleSheets.h: Source/WebKit: * UIProcess/API/Cocoa/_WKUserStyleSheet.h: * UIProcess/API/Cocoa/_WKUserStyleSheet.mm: (-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:baseURL:level:userContentWorld:]): Added. (-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:level:userContentWorld:]): Clean up WebCore::UserStyleSheet initializer. (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:]): Ditto. (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]): Ditto. (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:userContentWorld:]): Ditto. (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:level:userContentWorld:]): Ditto. Canonical link: https://commits.webkit.org/224820@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261726 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-15 00:33:37 +00:00
m_injectedAuthorStyleSheets.append(WTFMove(sheet));
};
for (const auto& userStyleSheet : m_pageSpecificStyleSheets)
addStyleSheet(userStyleSheet);
Add an SPI to allow UserStyleSheet injection to target a specific WKWebView https://bugs.webkit.org/show_bug.cgi?id=208575 <rdar://problem/59773690> Reviewed by Brady Eidson. Source/WebCore: Add a new Optional<PageIdentifier> member to UserStyleSheet which indicates whether the UserStyleSheet is supposed to be injected for all WKWebViews, or only a specific top-level WKWebView associated with a Page with the give ID. In ExtensionStyleSheets::updateInjectedStyleSheetCache(), UserStyleSheets with a specified pageID are ignored. Instead, we now also consider CSSStyleSheets listed in the new m_pageSpecificStyleSheets which contains page-specific stylesheets to be injected for the associated Document. The new Page::injectUserStyleSheet() method allows the addition of a UserStyleSheet on its documents' ExtensionStyleSheets, and will call this method either for the main frame's Document, or all Documents, depending on the UserStyleSheet's configuration. Finally, these new targeted UserStyleSheets can be removed via Page::removeInjectedUserStyleSheet() and ExtensionStyleSheets::removePageSpecificUserStyleSheet(). * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache const): (WebCore::ExtensionStyleSheets::injectPageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::removePageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::detachFromDocument): * dom/ExtensionStyleSheets.h: * page/Page.cpp: (WebCore::Page::injectUserStyleSheet): (WebCore::Page::removeInjectedUserStyleSheet): * page/Page.h: * page/UserStyleSheet.h: (WebCore::UserStyleSheet::UserStyleSheet): (WebCore::UserStyleSheet::pageID const): Source/WebKit: Since WebCore adds a new Optional<PageIdentifier> member to UserStyleSheet, we now encode that member to be preserved across UI and Web processes. Using this new member, WebUserContentController now determines that a UserStyleSheet meant to target a specific page was added in addUserStyleSheetInternal(), finds the matching WebPage, and calls injectUserStyleSheet() on its backing Page object. Conversely, WebUserContentController::removeUserStyleSheetInternal() will call into Page::removeInjectedUserStyleSheet(). Finally, we offer a new initializer on _WKUserStyleSheet to target a specific WKWebView, and its page's ID will be set on the backing UserStyleSheet. * Shared/WebCoreArgumentCoders.cpp: (IPC::ArgumentCoder<UserStyleSheet>::encode): (IPC::ArgumentCoder<UserStyleSheet>::decode): * UIProcess/API/Cocoa/_WKUserStyleSheet.h: * UIProcess/API/Cocoa/_WKUserStyleSheet.mm: (-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:userContentWorld:]): * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addUserStyleSheetInternal): (WebKit::WebUserContentController::removeUserStyleSheetInternal): Tools: Add new tests for the new SPI which check: 1. that specifying forWKWebView: when initializing a _WKUserStyleSheet will inject the provided CSS source in the specified WKWebView alone, 2. that the same test works with two WKWebViews with a shared WKWebKitConfiguration, 3. that a WKWebView-specific _WKUserStyleSheet can be removed, 4. that a WKWebView-specific _WKUserStyleSheet can be added twice and removed once and be removed as expected, 5. and that a WKWebView-specific _WKUserStyleSheet is automatically removed when navigating to a new page, 6. and that the same test also works with PSON enabled. * TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm: Canonical link: https://commits.webkit.org/221509@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@257870 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-03-04 20:05:38 +00:00
Add a baseURL parameter to _WKUserStyleSheet https://bugs.webkit.org/show_bug.cgi?id=155219 Reviewed by Tim Horton. Source/WebCore: - Moves to a model for user content where instead of each page having a WebCore::UserContentController object, we have an abstract WebCore::UserContentProvider interface that can be implemented at the WebKit level. For now, legacy WebKit continues to use the old UserContentController, which implements WebCore::UserContentProvider, and WebKit2 implements its own implementation so it can store additional state. * WebCore.xcodeproj/project.pbxproj: Add new files. * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache): Switch to using forEachUserStyleSheet on the UserContentProvider. * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::loadResource): Remove null check now that we always have a UserContentProvider. * loader/EmptyClients.cpp: (WebCore::fillWithEmptyClients): * loader/EmptyClients.h: Add new EmptyClients. * loader/FrameLoader.cpp: (WebCore::FrameLoader::loadResourceSynchronously): Remove null check now that we always have a UserContentProvider. * loader/PingLoader.cpp: (WebCore::processContentExtensionRulesForLoad): Remove null check now that we always have a UserContentProvider. * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::willSendRequestInternal): Remove null check now that we always have a UserContentProvider. * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): Remove null check now that we always have a UserContentProvider. * page/DOMWindow.cpp: (WebCore::DOMWindow::shouldHaveWebKitNamespaceForWorld): Remove null checks now that we always have a UserContentProvider, and userMessageHandlerDescriptors returns a reference. (WebCore::DOMWindow::open): Remove null check now that we always have a UserContentProvider. * page/Frame.cpp: (WebCore::Frame::injectUserScripts): Simplify by lifting document check out of the main loop and using forEachUserScript. * page/Page.cpp: (WebCore::Page::Page): (WebCore::Page::~Page): (WebCore::Page::userContentProvider): (WebCore::Page::setUserContentProvider): (WebCore::Page::setUserContentController): Deleted. * page/Page.h: (WebCore::Page::userContentController): Deleted. * page/PageConfiguration.h: Store the UserContentProvider in a Ref, and require PageConfigurations to provide one. This removes a bunch of null checks and simplifies the code. * page/UserContentController.cpp: (WebCore::UserContentController::~UserContentController): (WebCore::UserContentController::forEachUserScript): (WebCore::UserContentController::forEachUserStyleSheet): (WebCore::UserContentController::addUserScript): (WebCore::UserContentController::removeUserScript): (WebCore::UserContentController::removeUserScripts): (WebCore::UserContentController::addUserStyleSheet): (WebCore::UserContentController::removeUserStyleSheet): (WebCore::UserContentController::removeUserStyleSheets): (WebCore::UserContentController::addUserMessageHandlerDescriptor): (WebCore::UserContentController::removeUserMessageHandlerDescriptor): (WebCore::UserContentController::addUserContentExtension): (WebCore::UserContentController::removeUserContentExtension): (WebCore::UserContentController::removeAllUserContentExtensions): (WebCore::UserContentController::removeAllUserContent): (WebCore::UserContentController::addPage): Deleted. (WebCore::UserContentController::removePage): Deleted. (WebCore::contentExtensionsEnabled): Deleted. (WebCore::UserContentController::processContentExtensionRulesForLoad): Deleted. (WebCore::UserContentController::actionsForResourceLoad): Deleted. * page/UserContentController.h: (WebCore::UserContentController::userScripts): Deleted. (WebCore::UserContentController::userStyleSheets): Deleted. (WebCore::UserContentController::userMessageHandlerDescriptors): Deleted. Add inheritance from UserContentProvider and simplify things by removing unique_ptrs that were holding the member variables. There is usually only one UserContentController so having these in unique_ptrs doesn't make much sense. * page/UserContentProvider.cpp: Added. (WebCore::UserContentProvider::UserContentProvider): (WebCore::UserContentProvider::~UserContentProvider): (WebCore::UserContentProvider::addPage): (WebCore::UserContentProvider::removePage): (WebCore::UserContentProvider::invalidateInjectedStyleSheetCacheInAllFramesInAllPages): (WebCore::contentExtensionsEnabled): (WebCore::UserContentProvider::processContentExtensionRulesForLoad): (WebCore::UserContentProvider::actionsForResourceLoad): * page/UserContentProvider.h: Added. Add abstract class for providing user content and add some helpers on it. * page/UserMessageHandlerDescriptor.h: (WebCore::UserMessageHandlerDescriptor::create): (WebCore::UserMessageHandlerDescriptor::client): (WebCore::UserMessageHandlerDescriptor::invalidateClient): * page/UserMessageHandlersNamespace.cpp: (WebCore::UserMessageHandlersNamespace::handler): Simplify now that userContentProvider() and userMessageHandlerDescriptors() are references. Source/WebKit/mac: * WebView/WebView.mm: (-[WebView _commonInitializationWithFrameName:groupName:]): (-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]): (-[WebView setGroupName:]): Update to account for the name change from UserContentController -> UserContentProvider. Source/WebKit2: - Moves to a model for user content where instead of using a WebCore::UserContentController object, we implement the new WebCore::UserContentProvider interface (on the existing WebUserContentController object). - Uses this to maintain maps of UserStylesSheets and UserScripts along with their identifiers, freeing up the URL, which had been acting as the identifier, to be used as the baseURL which was what it was intended for. - Adds a baseURL property to _WKUserStyleSheet. * WebKit2.xcodeproj/project.pbxproj: Add new files. * Scripts/webkit/messages.py: (headers_for_type): Add support for sending WebUserContentControllerDataTypes. * Shared/WebUserContentControllerDataTypes.cpp: Added. (WebKit::WebUserScriptData::encode): (WebKit::WebUserScriptData::decode): (WebKit::WebUserStyleSheetData::encode): (WebKit::WebUserStyleSheetData::decode): * Shared/WebUserContentControllerDataTypes.h: Added. Add helper types for sending user content over IPC. * UIProcess/API/APIUserScript.cpp: (API::UserScript::generateUniqueURL): (API::UserScript::UserScript): * UIProcess/API/APIUserScript.h: * UIProcess/API/APIUserStyleSheet.cpp: (API::UserStyleSheet::generateUniqueURL): (API::UserStyleSheet::UserStyleSheet): * UIProcess/API/APIUserStyleSheet.h: Add identifiers for tracking across processes. * UIProcess/API/Cocoa/_WKUserStyleSheet.h: * UIProcess/API/Cocoa/_WKUserStyleSheet.mm: (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:userContentWorld:]): (-[_WKUserStyleSheet baseURL]): Add new initializer which takes a baseURL as well as an accessor for the baseURL. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::addUserScript): (WebKit::WebUserContentControllerProxy::removeUserScript): (WebKit::WebUserContentControllerProxy::addUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeUserStyleSheet): Pass identifiers as well as user content. * WebProcess/InjectedBundle/InjectedBundle.cpp: (WebKit::InjectedBundle::addUserScript): (WebKit::InjectedBundle::addUserStyleSheet): Move user content in via move semantics rather than using a unique_ptr. (WebKit::InjectedBundle::removeUserScript): (WebKit::InjectedBundle::removeUserStyleSheet): (WebKit::InjectedBundle::removeUserScripts): (WebKit::InjectedBundle::removeUserStyleSheets): (WebKit::InjectedBundle::removeAllUserContent): Update for new function signatures. * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::WebUserContentController): (WebKit::WebUserContentController::~WebUserContentController): (WebKit::WebUserContentController::addUserContentWorlds): (WebKit::WebUserContentController::removeUserContentWorlds): (WebKit::WebUserContentController::addUserScripts): (WebKit::WebUserContentController::removeUserScript): (WebKit::WebUserContentController::removeAllUserScripts): (WebKit::WebUserContentController::addUserStyleSheets): (WebKit::WebUserContentController::removeUserStyleSheet): (WebKit::WebUserContentController::removeAllUserStyleSheets): (WebKit::WebUserContentController::addUserScriptMessageHandlers): (WebKit::WebUserContentController::removeUserScriptMessageHandler): (WebKit::WebUserContentController::addUserContentExtensions): (WebKit::WebUserContentController::removeUserContentExtension): (WebKit::WebUserContentController::removeAllUserContentExtensions): (WebKit::WebUserContentController::addUserScriptInternal): (WebKit::WebUserContentController::addUserScript): (WebKit::WebUserContentController::removeUserScriptWithURL): (WebKit::WebUserContentController::removeUserScriptInternal): (WebKit::WebUserContentController::removeUserScripts): (WebKit::WebUserContentController::addUserStyleSheetInternal): (WebKit::WebUserContentController::addUserStyleSheet): (WebKit::WebUserContentController::removeUserStyleSheetWithURL): (WebKit::WebUserContentController::removeUserStyleSheetInternal): (WebKit::WebUserContentController::removeUserStyleSheets): (WebKit::WebUserContentController::removeAllUserContent): (WebKit::WebUserContentController::forEachUserScript): (WebKit::WebUserContentController::forEachUserStyleSheet): * WebProcess/UserContent/WebUserContentController.h: * WebProcess/UserContent/WebUserContentController.messages.in: Convert to inheriting from UserContentProvider, rather than containing a UserContentController. This means adding the storage for the user content, which has been simplified to avoid using unique_ptrs. * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::addUserScript): (WebKit::WebPage::addUserStyleSheet): (WebKit::WebPage::removeAllUserContent): Update to call the WebUserContentController, rather than going to the UserContentController, which no longer exists. * WebProcess/WebPage/WebPageGroupProxy.cpp: (WebKit::WebPageGroupProxy::userContentController): * WebProcess/WebPage/WebPageGroupProxy.h: Return the WebUserContentController rather than old UserContentController. Canonical link: https://commits.webkit.org/173593@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198180 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-03-15 00:48:40 +00:00
owningPage->userContentProvider().forEachUserStyleSheet([&](const UserStyleSheet& userStyleSheet) {
Add an SPI to allow UserStyleSheet injection to target a specific WKWebView https://bugs.webkit.org/show_bug.cgi?id=208575 <rdar://problem/59773690> Reviewed by Brady Eidson. Source/WebCore: Add a new Optional<PageIdentifier> member to UserStyleSheet which indicates whether the UserStyleSheet is supposed to be injected for all WKWebViews, or only a specific top-level WKWebView associated with a Page with the give ID. In ExtensionStyleSheets::updateInjectedStyleSheetCache(), UserStyleSheets with a specified pageID are ignored. Instead, we now also consider CSSStyleSheets listed in the new m_pageSpecificStyleSheets which contains page-specific stylesheets to be injected for the associated Document. The new Page::injectUserStyleSheet() method allows the addition of a UserStyleSheet on its documents' ExtensionStyleSheets, and will call this method either for the main frame's Document, or all Documents, depending on the UserStyleSheet's configuration. Finally, these new targeted UserStyleSheets can be removed via Page::removeInjectedUserStyleSheet() and ExtensionStyleSheets::removePageSpecificUserStyleSheet(). * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache const): (WebCore::ExtensionStyleSheets::injectPageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::removePageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::detachFromDocument): * dom/ExtensionStyleSheets.h: * page/Page.cpp: (WebCore::Page::injectUserStyleSheet): (WebCore::Page::removeInjectedUserStyleSheet): * page/Page.h: * page/UserStyleSheet.h: (WebCore::UserStyleSheet::UserStyleSheet): (WebCore::UserStyleSheet::pageID const): Source/WebKit: Since WebCore adds a new Optional<PageIdentifier> member to UserStyleSheet, we now encode that member to be preserved across UI and Web processes. Using this new member, WebUserContentController now determines that a UserStyleSheet meant to target a specific page was added in addUserStyleSheetInternal(), finds the matching WebPage, and calls injectUserStyleSheet() on its backing Page object. Conversely, WebUserContentController::removeUserStyleSheetInternal() will call into Page::removeInjectedUserStyleSheet(). Finally, we offer a new initializer on _WKUserStyleSheet to target a specific WKWebView, and its page's ID will be set on the backing UserStyleSheet. * Shared/WebCoreArgumentCoders.cpp: (IPC::ArgumentCoder<UserStyleSheet>::encode): (IPC::ArgumentCoder<UserStyleSheet>::decode): * UIProcess/API/Cocoa/_WKUserStyleSheet.h: * UIProcess/API/Cocoa/_WKUserStyleSheet.mm: (-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:userContentWorld:]): * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addUserStyleSheetInternal): (WebKit::WebUserContentController::removeUserStyleSheetInternal): Tools: Add new tests for the new SPI which check: 1. that specifying forWKWebView: when initializing a _WKUserStyleSheet will inject the provided CSS source in the specified WKWebView alone, 2. that the same test works with two WKWebViews with a shared WKWebKitConfiguration, 3. that a WKWebView-specific _WKUserStyleSheet can be removed, 4. that a WKWebView-specific _WKUserStyleSheet can be added twice and removed once and be removed as expected, 5. and that a WKWebView-specific _WKUserStyleSheet is automatically removed when navigating to a new page, 6. and that the same test also works with PSON enabled. * TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm: Canonical link: https://commits.webkit.org/221509@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@257870 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-03-04 20:05:38 +00:00
if (userStyleSheet.pageID())
return;
Add SPI to make WKUserScripts wait for a notification https://bugs.webkit.org/show_bug.cgi?id=209845 <rdar://problem/60342299> Patch by Alex Christensen <achristensen@webkit.org> on 2020-04-03 Reviewed by Chris Dumez. Source/WebCore: There's also SPI on WKWebView to provide this notification, and on WKWebViewConfiguration to start out with this notification. * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache const): * html/ImageDocument.cpp: (WebCore::ImageDocument::createDocumentStructure): * html/MediaDocument.cpp: (WebCore::MediaDocumentParser::createDocumentStructure): * html/PluginDocument.cpp: (WebCore::PluginDocumentParser::createDocumentStructure): * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::dispatchDocumentElementAvailableIfNeeded): * loader/FrameLoader.cpp: (WebCore::FrameLoader::finishedParsing): * page/Frame.cpp: (WebCore::Frame::injectUserScripts): (WebCore::Frame::injectUserScriptImmediately): * page/Page.cpp: (WebCore::m_deviceOrientationUpdateProvider): (WebCore::Page::notifyToInjectUserScripts): (WebCore::Page::addUserScriptAwaitingNotification): (WebCore::Page::injectUserStyleSheet): (WebCore::Page::removeInjectedUserStyleSheet): * page/Page.h: (WebCore::Page::hasBeenNotifiedToInjectUserScripts const): * page/PageConfiguration.h: * page/UserContentTypes.h: (): Deleted. * page/UserScript.h: (WebCore::UserScript::UserScript): (WebCore::UserScript::waitForNotificationBeforeInjecting const): (WebCore::UserScript::encode const): (WebCore::UserScript::decode): * page/UserScriptTypes.h: (): Deleted. * page/UserStyleSheet.h: (WebCore::UserStyleSheet::UserStyleSheet): * xml/parser/XMLDocumentParserLibxml2.cpp: (WebCore::XMLDocumentParser::startElementNs): Source/WebKit: * Shared/API/c/WKSharedAPICast.h: (WebKit::toUserScriptInjectionTime): (WebKit::toWKUserScriptInjectionTime): (WebKit::toUserContentInjectedFrames): * Shared/WebPageCreationParameters.cpp: (WebKit::WebPageCreationParameters::encode const): (WebKit::WebPageCreationParameters::decode): * Shared/WebPageCreationParameters.h: * Shared/WebUserContentControllerDataTypes.cpp: (WebKit::WebUserScriptData::decode): * UIProcess/API/APIPageConfiguration.h: (API::PageConfiguration::userScriptsShouldWaitUntilNotification const): (API::PageConfiguration::setUserScriptsShouldWaitUntilNotification): * UIProcess/API/APIUserScript.h: * UIProcess/API/C/WKPageGroup.cpp: (WKPageGroupAddUserScript): * UIProcess/API/C/WKUserScriptRef.cpp: (WKUserScriptCreateWithSource): (WKUserScriptGetMainFrameOnly): * UIProcess/API/Cocoa/WKUserScript.mm: (-[WKUserScript initWithSource:injectionTime:forMainFrameOnly:]): (-[WKUserScript isForMainFrameOnly]): (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]): (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:userContentWorld:]): (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:contentWorld:]): (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:contentWorld:]): (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:contentWorld:waitForNotification:]): * UIProcess/API/Cocoa/WKUserScriptInternal.h: (API::toWebCoreUserScriptInjectionTime): (API::toWKUserScriptInjectionTime): * UIProcess/API/Cocoa/WKUserScriptPrivate.h: * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _notifyUserScripts]): * UIProcess/API/Cocoa/WKWebViewConfiguration.mm: (-[WKWebViewConfiguration _userScriptsShouldWaitUntilNotification]): (-[WKWebViewConfiguration _setUserScriptsShouldWaitUntilNotification:]): * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h: * UIProcess/API/Cocoa/WKWebViewPrivate.h: * UIProcess/API/Cocoa/_WKUserStyleSheet.mm: (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:]): (-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:userContentWorld:]): (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]): (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:userContentWorld:]): (-[_WKUserStyleSheet isForMainFrameOnly]): * UIProcess/WebPageProxy.cpp: * UIProcess/WebPageProxy.h: * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addUserScriptInternal): * WebProcess/WebPage/WebPage.cpp: (WebKit::m_processDisplayName): (WebKit::WebPage::notifyUserScripts): (WebKit::WebPage::addUserScript): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: Source/WebKitLegacy/mac: * WebView/WebView.mm: (-[WebView _injectOutlookQuirksScript]): Source/WebKitLegacy/win: * WebView.cpp: (WebView::addUserScriptToGroup): (WebView::addUserStyleSheetToGroup): Tools: * TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm: (TEST): Canonical link: https://commits.webkit.org/222914@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259523 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-04 00:44:31 +00:00
if (userStyleSheet.injectedFrames() == UserContentInjectedFrames::InjectInTopFrameOnly && m_document.ownerElement())
Add a baseURL parameter to _WKUserStyleSheet https://bugs.webkit.org/show_bug.cgi?id=155219 Reviewed by Tim Horton. Source/WebCore: - Moves to a model for user content where instead of each page having a WebCore::UserContentController object, we have an abstract WebCore::UserContentProvider interface that can be implemented at the WebKit level. For now, legacy WebKit continues to use the old UserContentController, which implements WebCore::UserContentProvider, and WebKit2 implements its own implementation so it can store additional state. * WebCore.xcodeproj/project.pbxproj: Add new files. * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache): Switch to using forEachUserStyleSheet on the UserContentProvider. * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::loadResource): Remove null check now that we always have a UserContentProvider. * loader/EmptyClients.cpp: (WebCore::fillWithEmptyClients): * loader/EmptyClients.h: Add new EmptyClients. * loader/FrameLoader.cpp: (WebCore::FrameLoader::loadResourceSynchronously): Remove null check now that we always have a UserContentProvider. * loader/PingLoader.cpp: (WebCore::processContentExtensionRulesForLoad): Remove null check now that we always have a UserContentProvider. * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::willSendRequestInternal): Remove null check now that we always have a UserContentProvider. * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): Remove null check now that we always have a UserContentProvider. * page/DOMWindow.cpp: (WebCore::DOMWindow::shouldHaveWebKitNamespaceForWorld): Remove null checks now that we always have a UserContentProvider, and userMessageHandlerDescriptors returns a reference. (WebCore::DOMWindow::open): Remove null check now that we always have a UserContentProvider. * page/Frame.cpp: (WebCore::Frame::injectUserScripts): Simplify by lifting document check out of the main loop and using forEachUserScript. * page/Page.cpp: (WebCore::Page::Page): (WebCore::Page::~Page): (WebCore::Page::userContentProvider): (WebCore::Page::setUserContentProvider): (WebCore::Page::setUserContentController): Deleted. * page/Page.h: (WebCore::Page::userContentController): Deleted. * page/PageConfiguration.h: Store the UserContentProvider in a Ref, and require PageConfigurations to provide one. This removes a bunch of null checks and simplifies the code. * page/UserContentController.cpp: (WebCore::UserContentController::~UserContentController): (WebCore::UserContentController::forEachUserScript): (WebCore::UserContentController::forEachUserStyleSheet): (WebCore::UserContentController::addUserScript): (WebCore::UserContentController::removeUserScript): (WebCore::UserContentController::removeUserScripts): (WebCore::UserContentController::addUserStyleSheet): (WebCore::UserContentController::removeUserStyleSheet): (WebCore::UserContentController::removeUserStyleSheets): (WebCore::UserContentController::addUserMessageHandlerDescriptor): (WebCore::UserContentController::removeUserMessageHandlerDescriptor): (WebCore::UserContentController::addUserContentExtension): (WebCore::UserContentController::removeUserContentExtension): (WebCore::UserContentController::removeAllUserContentExtensions): (WebCore::UserContentController::removeAllUserContent): (WebCore::UserContentController::addPage): Deleted. (WebCore::UserContentController::removePage): Deleted. (WebCore::contentExtensionsEnabled): Deleted. (WebCore::UserContentController::processContentExtensionRulesForLoad): Deleted. (WebCore::UserContentController::actionsForResourceLoad): Deleted. * page/UserContentController.h: (WebCore::UserContentController::userScripts): Deleted. (WebCore::UserContentController::userStyleSheets): Deleted. (WebCore::UserContentController::userMessageHandlerDescriptors): Deleted. Add inheritance from UserContentProvider and simplify things by removing unique_ptrs that were holding the member variables. There is usually only one UserContentController so having these in unique_ptrs doesn't make much sense. * page/UserContentProvider.cpp: Added. (WebCore::UserContentProvider::UserContentProvider): (WebCore::UserContentProvider::~UserContentProvider): (WebCore::UserContentProvider::addPage): (WebCore::UserContentProvider::removePage): (WebCore::UserContentProvider::invalidateInjectedStyleSheetCacheInAllFramesInAllPages): (WebCore::contentExtensionsEnabled): (WebCore::UserContentProvider::processContentExtensionRulesForLoad): (WebCore::UserContentProvider::actionsForResourceLoad): * page/UserContentProvider.h: Added. Add abstract class for providing user content and add some helpers on it. * page/UserMessageHandlerDescriptor.h: (WebCore::UserMessageHandlerDescriptor::create): (WebCore::UserMessageHandlerDescriptor::client): (WebCore::UserMessageHandlerDescriptor::invalidateClient): * page/UserMessageHandlersNamespace.cpp: (WebCore::UserMessageHandlersNamespace::handler): Simplify now that userContentProvider() and userMessageHandlerDescriptors() are references. Source/WebKit/mac: * WebView/WebView.mm: (-[WebView _commonInitializationWithFrameName:groupName:]): (-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]): (-[WebView setGroupName:]): Update to account for the name change from UserContentController -> UserContentProvider. Source/WebKit2: - Moves to a model for user content where instead of using a WebCore::UserContentController object, we implement the new WebCore::UserContentProvider interface (on the existing WebUserContentController object). - Uses this to maintain maps of UserStylesSheets and UserScripts along with their identifiers, freeing up the URL, which had been acting as the identifier, to be used as the baseURL which was what it was intended for. - Adds a baseURL property to _WKUserStyleSheet. * WebKit2.xcodeproj/project.pbxproj: Add new files. * Scripts/webkit/messages.py: (headers_for_type): Add support for sending WebUserContentControllerDataTypes. * Shared/WebUserContentControllerDataTypes.cpp: Added. (WebKit::WebUserScriptData::encode): (WebKit::WebUserScriptData::decode): (WebKit::WebUserStyleSheetData::encode): (WebKit::WebUserStyleSheetData::decode): * Shared/WebUserContentControllerDataTypes.h: Added. Add helper types for sending user content over IPC. * UIProcess/API/APIUserScript.cpp: (API::UserScript::generateUniqueURL): (API::UserScript::UserScript): * UIProcess/API/APIUserScript.h: * UIProcess/API/APIUserStyleSheet.cpp: (API::UserStyleSheet::generateUniqueURL): (API::UserStyleSheet::UserStyleSheet): * UIProcess/API/APIUserStyleSheet.h: Add identifiers for tracking across processes. * UIProcess/API/Cocoa/_WKUserStyleSheet.h: * UIProcess/API/Cocoa/_WKUserStyleSheet.mm: (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:userContentWorld:]): (-[_WKUserStyleSheet baseURL]): Add new initializer which takes a baseURL as well as an accessor for the baseURL. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::addUserScript): (WebKit::WebUserContentControllerProxy::removeUserScript): (WebKit::WebUserContentControllerProxy::addUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeUserStyleSheet): Pass identifiers as well as user content. * WebProcess/InjectedBundle/InjectedBundle.cpp: (WebKit::InjectedBundle::addUserScript): (WebKit::InjectedBundle::addUserStyleSheet): Move user content in via move semantics rather than using a unique_ptr. (WebKit::InjectedBundle::removeUserScript): (WebKit::InjectedBundle::removeUserStyleSheet): (WebKit::InjectedBundle::removeUserScripts): (WebKit::InjectedBundle::removeUserStyleSheets): (WebKit::InjectedBundle::removeAllUserContent): Update for new function signatures. * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::WebUserContentController): (WebKit::WebUserContentController::~WebUserContentController): (WebKit::WebUserContentController::addUserContentWorlds): (WebKit::WebUserContentController::removeUserContentWorlds): (WebKit::WebUserContentController::addUserScripts): (WebKit::WebUserContentController::removeUserScript): (WebKit::WebUserContentController::removeAllUserScripts): (WebKit::WebUserContentController::addUserStyleSheets): (WebKit::WebUserContentController::removeUserStyleSheet): (WebKit::WebUserContentController::removeAllUserStyleSheets): (WebKit::WebUserContentController::addUserScriptMessageHandlers): (WebKit::WebUserContentController::removeUserScriptMessageHandler): (WebKit::WebUserContentController::addUserContentExtensions): (WebKit::WebUserContentController::removeUserContentExtension): (WebKit::WebUserContentController::removeAllUserContentExtensions): (WebKit::WebUserContentController::addUserScriptInternal): (WebKit::WebUserContentController::addUserScript): (WebKit::WebUserContentController::removeUserScriptWithURL): (WebKit::WebUserContentController::removeUserScriptInternal): (WebKit::WebUserContentController::removeUserScripts): (WebKit::WebUserContentController::addUserStyleSheetInternal): (WebKit::WebUserContentController::addUserStyleSheet): (WebKit::WebUserContentController::removeUserStyleSheetWithURL): (WebKit::WebUserContentController::removeUserStyleSheetInternal): (WebKit::WebUserContentController::removeUserStyleSheets): (WebKit::WebUserContentController::removeAllUserContent): (WebKit::WebUserContentController::forEachUserScript): (WebKit::WebUserContentController::forEachUserStyleSheet): * WebProcess/UserContent/WebUserContentController.h: * WebProcess/UserContent/WebUserContentController.messages.in: Convert to inheriting from UserContentProvider, rather than containing a UserContentController. This means adding the storage for the user content, which has been simplified to avoid using unique_ptrs. * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::addUserScript): (WebKit::WebPage::addUserStyleSheet): (WebKit::WebPage::removeAllUserContent): Update to call the WebUserContentController, rather than going to the UserContentController, which no longer exists. * WebProcess/WebPage/WebPageGroupProxy.cpp: (WebKit::WebPageGroupProxy::userContentController): * WebProcess/WebPage/WebPageGroupProxy.h: Return the WebUserContentController rather than old UserContentController. Canonical link: https://commits.webkit.org/173593@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198180 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-03-15 00:48:40 +00:00
return;
Replace instances of whitelist in WebCore with allowlist https://bugs.webkit.org/show_bug.cgi?id=213068 Reviewed by Tim Horton. Source/WebCore: * Modules/webdatabase/DatabaseAuthorizer.cpp: (WebCore::DatabaseAuthorizer::DatabaseAuthorizer): (WebCore::DatabaseAuthorizer::addAllowedFunctions): (WebCore::DatabaseAuthorizer::allowFunction): (WebCore::DatabaseAuthorizer::addWhitelistedFunctions): Deleted. * Modules/webdatabase/DatabaseAuthorizer.h: * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache const): * loader/CrossOriginAccessControl.cpp: (WebCore::isOnAccessControlSimpleRequestMethodAllowlist): (WebCore::isSimpleCrossOriginAccessRequest): (WebCore::isOnAccessControlSimpleRequestMethodWhitelist): Deleted. * loader/CrossOriginAccessControl.h: * loader/CrossOriginPreflightResultCache.cpp: (WebCore::CrossOriginPreflightResultCacheItem::allowsCrossOriginMethod const): * loader/appcache/ApplicationCache.cpp: (WebCore::ApplicationCache::setOnlineAllowlist): (WebCore::ApplicationCache::isURLInOnlineAllowlist): (WebCore::ApplicationCache::setOnlineWhitelist): Deleted. (WebCore::ApplicationCache::isURLInOnlineWhitelist): Deleted. * loader/appcache/ApplicationCache.h: (WebCore::ApplicationCache::onlineAllowlist const): (WebCore::ApplicationCache::onlineWhitelist const): Deleted. * loader/appcache/ApplicationCacheGroup.cpp: (WebCore::ApplicationCacheGroup::didFinishLoadingManifest): * loader/appcache/ApplicationCacheHost.cpp: (WebCore::ApplicationCacheHost::shouldLoadResourceFromApplicationCache): (WebCore::ApplicationCacheHost::getApplicationCacheFallbackResource): * loader/appcache/ApplicationCacheStorage.cpp: (WebCore::ApplicationCacheStorage::fallbackCacheGroupForURL): (WebCore::ApplicationCacheStorage::openDatabase): (WebCore::ApplicationCacheStorage::store): (WebCore::ApplicationCacheStorage::loadCache): * loader/appcache/ManifestParser.cpp: (WebCore::parseManifest): * loader/appcache/ManifestParser.h: * page/Frame.cpp: (WebCore::Frame::injectUserScriptImmediately): * page/SecurityOrigin.cpp: (WebCore::SecurityOrigin::canRequest const): (WebCore::SecurityOrigin::canDisplay const): * page/SecurityPolicy.cpp: (WebCore::SecurityPolicy::isAccessAllowed): (WebCore::SecurityPolicy::addOriginAccessAllowlistEntry): (WebCore::SecurityPolicy::removeOriginAccessAllowlistEntry): (WebCore::SecurityPolicy::resetOriginAccessAllowlists): (WebCore::SecurityPolicy::isAccessWhiteListed): Deleted. (WebCore::SecurityPolicy::addOriginAccessWhitelistEntry): Deleted. (WebCore::SecurityPolicy::removeOriginAccessWhitelistEntry): Deleted. (WebCore::SecurityPolicy::resetOriginAccessWhitelists): Deleted. * page/SecurityPolicy.h: * page/UserContentURLPattern.cpp: (WebCore::UserContentURLPattern::matchesPatterns): * page/UserContentURLPattern.h: * page/UserScript.h: (WebCore::UserScript::UserScript): (WebCore::UserScript::allowlist const): (WebCore::UserScript::encode const): (WebCore::UserScript::decode): (WebCore::UserScript::whitelist const): Deleted. * page/UserStyleSheet.h: (WebCore::UserStyleSheet::UserStyleSheet): (WebCore::UserStyleSheet::allowlist const): (WebCore::UserStyleSheet::whitelist const): Deleted. * platform/graphics/FontCache.h: * platform/graphics/cocoa/FontCacheCoreText.cpp: (WebCore::fontAllowlist): (WebCore::FontCache::setFontAllowlist): (WebCore::platformFontLookupWithFamily): (WebCore::fontWhitelist): Deleted. (WebCore::FontCache::setFontWhitelist): Deleted. * platform/network/HTTPParsers.cpp: (WebCore::isValidAcceptHeaderValue): * rendering/FloatingObjects.h: * style/ElementRuleCollector.cpp: (WebCore::Style::ElementRuleCollector::transferMatchedRules): * style/ElementRuleCollector.h: * style/PropertyCascade.cpp: (WebCore::Style::PropertyCascade::addMatch): * style/RuleData.cpp: (WebCore::Style::determinePropertyAllowlistType): (WebCore::Style::RuleData::RuleData): (WebCore::Style::determinePropertyWhitelistType): Deleted. * style/RuleData.h: (WebCore::Style::RuleData::propertyAllowlistType const): (WebCore::Style::RuleData::propertyWhitelistType const): Deleted. Source/WebKit: * NetworkProcess/NetworkConnectionToWebProcess.cpp: (WebKit::NetworkConnectionToWebProcess::addOriginAccessWhitelistEntry): (WebKit::NetworkConnectionToWebProcess::removeOriginAccessWhitelistEntry): (WebKit::NetworkConnectionToWebProcess::resetOriginAccessWhitelists): * Shared/WebCoreArgumentCoders.cpp: (IPC::ArgumentCoder<UserStyleSheet>::encode): (IPC::ArgumentCoder<UserStyleSheet>::decode): * WebProcess/InjectedBundle/InjectedBundle.cpp: (WebKit::InjectedBundle::addOriginAccessWhitelistEntry): (WebKit::InjectedBundle::removeOriginAccessWhitelistEntry): (WebKit::InjectedBundle::resetOriginAccessWhitelists): * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): Source/WebKitLegacy/mac: * WebView/WebView.mm: (+[WebView _addOriginAccessWhitelistEntryWithSourceOrigin:destinationProtocol:destinationHost:allowDestinationSubdomains:]): (+[WebView _removeOriginAccessWhitelistEntryWithSourceOrigin:destinationProtocol:destinationHost:allowDestinationSubdomains:]): (+[WebView _resetOriginAccessWhitelists]): (+[WebView _setFontWhitelist:]): Canonical link: https://commits.webkit.org/225877@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262922 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-06-11 20:47:21 +00:00
if (!UserContentURLPattern::matchesPatterns(m_document.url(), userStyleSheet.allowlist(), userStyleSheet.blocklist()))
Add a baseURL parameter to _WKUserStyleSheet https://bugs.webkit.org/show_bug.cgi?id=155219 Reviewed by Tim Horton. Source/WebCore: - Moves to a model for user content where instead of each page having a WebCore::UserContentController object, we have an abstract WebCore::UserContentProvider interface that can be implemented at the WebKit level. For now, legacy WebKit continues to use the old UserContentController, which implements WebCore::UserContentProvider, and WebKit2 implements its own implementation so it can store additional state. * WebCore.xcodeproj/project.pbxproj: Add new files. * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache): Switch to using forEachUserStyleSheet on the UserContentProvider. * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::loadResource): Remove null check now that we always have a UserContentProvider. * loader/EmptyClients.cpp: (WebCore::fillWithEmptyClients): * loader/EmptyClients.h: Add new EmptyClients. * loader/FrameLoader.cpp: (WebCore::FrameLoader::loadResourceSynchronously): Remove null check now that we always have a UserContentProvider. * loader/PingLoader.cpp: (WebCore::processContentExtensionRulesForLoad): Remove null check now that we always have a UserContentProvider. * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::willSendRequestInternal): Remove null check now that we always have a UserContentProvider. * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): Remove null check now that we always have a UserContentProvider. * page/DOMWindow.cpp: (WebCore::DOMWindow::shouldHaveWebKitNamespaceForWorld): Remove null checks now that we always have a UserContentProvider, and userMessageHandlerDescriptors returns a reference. (WebCore::DOMWindow::open): Remove null check now that we always have a UserContentProvider. * page/Frame.cpp: (WebCore::Frame::injectUserScripts): Simplify by lifting document check out of the main loop and using forEachUserScript. * page/Page.cpp: (WebCore::Page::Page): (WebCore::Page::~Page): (WebCore::Page::userContentProvider): (WebCore::Page::setUserContentProvider): (WebCore::Page::setUserContentController): Deleted. * page/Page.h: (WebCore::Page::userContentController): Deleted. * page/PageConfiguration.h: Store the UserContentProvider in a Ref, and require PageConfigurations to provide one. This removes a bunch of null checks and simplifies the code. * page/UserContentController.cpp: (WebCore::UserContentController::~UserContentController): (WebCore::UserContentController::forEachUserScript): (WebCore::UserContentController::forEachUserStyleSheet): (WebCore::UserContentController::addUserScript): (WebCore::UserContentController::removeUserScript): (WebCore::UserContentController::removeUserScripts): (WebCore::UserContentController::addUserStyleSheet): (WebCore::UserContentController::removeUserStyleSheet): (WebCore::UserContentController::removeUserStyleSheets): (WebCore::UserContentController::addUserMessageHandlerDescriptor): (WebCore::UserContentController::removeUserMessageHandlerDescriptor): (WebCore::UserContentController::addUserContentExtension): (WebCore::UserContentController::removeUserContentExtension): (WebCore::UserContentController::removeAllUserContentExtensions): (WebCore::UserContentController::removeAllUserContent): (WebCore::UserContentController::addPage): Deleted. (WebCore::UserContentController::removePage): Deleted. (WebCore::contentExtensionsEnabled): Deleted. (WebCore::UserContentController::processContentExtensionRulesForLoad): Deleted. (WebCore::UserContentController::actionsForResourceLoad): Deleted. * page/UserContentController.h: (WebCore::UserContentController::userScripts): Deleted. (WebCore::UserContentController::userStyleSheets): Deleted. (WebCore::UserContentController::userMessageHandlerDescriptors): Deleted. Add inheritance from UserContentProvider and simplify things by removing unique_ptrs that were holding the member variables. There is usually only one UserContentController so having these in unique_ptrs doesn't make much sense. * page/UserContentProvider.cpp: Added. (WebCore::UserContentProvider::UserContentProvider): (WebCore::UserContentProvider::~UserContentProvider): (WebCore::UserContentProvider::addPage): (WebCore::UserContentProvider::removePage): (WebCore::UserContentProvider::invalidateInjectedStyleSheetCacheInAllFramesInAllPages): (WebCore::contentExtensionsEnabled): (WebCore::UserContentProvider::processContentExtensionRulesForLoad): (WebCore::UserContentProvider::actionsForResourceLoad): * page/UserContentProvider.h: Added. Add abstract class for providing user content and add some helpers on it. * page/UserMessageHandlerDescriptor.h: (WebCore::UserMessageHandlerDescriptor::create): (WebCore::UserMessageHandlerDescriptor::client): (WebCore::UserMessageHandlerDescriptor::invalidateClient): * page/UserMessageHandlersNamespace.cpp: (WebCore::UserMessageHandlersNamespace::handler): Simplify now that userContentProvider() and userMessageHandlerDescriptors() are references. Source/WebKit/mac: * WebView/WebView.mm: (-[WebView _commonInitializationWithFrameName:groupName:]): (-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]): (-[WebView setGroupName:]): Update to account for the name change from UserContentController -> UserContentProvider. Source/WebKit2: - Moves to a model for user content where instead of using a WebCore::UserContentController object, we implement the new WebCore::UserContentProvider interface (on the existing WebUserContentController object). - Uses this to maintain maps of UserStylesSheets and UserScripts along with their identifiers, freeing up the URL, which had been acting as the identifier, to be used as the baseURL which was what it was intended for. - Adds a baseURL property to _WKUserStyleSheet. * WebKit2.xcodeproj/project.pbxproj: Add new files. * Scripts/webkit/messages.py: (headers_for_type): Add support for sending WebUserContentControllerDataTypes. * Shared/WebUserContentControllerDataTypes.cpp: Added. (WebKit::WebUserScriptData::encode): (WebKit::WebUserScriptData::decode): (WebKit::WebUserStyleSheetData::encode): (WebKit::WebUserStyleSheetData::decode): * Shared/WebUserContentControllerDataTypes.h: Added. Add helper types for sending user content over IPC. * UIProcess/API/APIUserScript.cpp: (API::UserScript::generateUniqueURL): (API::UserScript::UserScript): * UIProcess/API/APIUserScript.h: * UIProcess/API/APIUserStyleSheet.cpp: (API::UserStyleSheet::generateUniqueURL): (API::UserStyleSheet::UserStyleSheet): * UIProcess/API/APIUserStyleSheet.h: Add identifiers for tracking across processes. * UIProcess/API/Cocoa/_WKUserStyleSheet.h: * UIProcess/API/Cocoa/_WKUserStyleSheet.mm: (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:userContentWorld:]): (-[_WKUserStyleSheet baseURL]): Add new initializer which takes a baseURL as well as an accessor for the baseURL. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::addUserScript): (WebKit::WebUserContentControllerProxy::removeUserScript): (WebKit::WebUserContentControllerProxy::addUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeUserStyleSheet): Pass identifiers as well as user content. * WebProcess/InjectedBundle/InjectedBundle.cpp: (WebKit::InjectedBundle::addUserScript): (WebKit::InjectedBundle::addUserStyleSheet): Move user content in via move semantics rather than using a unique_ptr. (WebKit::InjectedBundle::removeUserScript): (WebKit::InjectedBundle::removeUserStyleSheet): (WebKit::InjectedBundle::removeUserScripts): (WebKit::InjectedBundle::removeUserStyleSheets): (WebKit::InjectedBundle::removeAllUserContent): Update for new function signatures. * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::WebUserContentController): (WebKit::WebUserContentController::~WebUserContentController): (WebKit::WebUserContentController::addUserContentWorlds): (WebKit::WebUserContentController::removeUserContentWorlds): (WebKit::WebUserContentController::addUserScripts): (WebKit::WebUserContentController::removeUserScript): (WebKit::WebUserContentController::removeAllUserScripts): (WebKit::WebUserContentController::addUserStyleSheets): (WebKit::WebUserContentController::removeUserStyleSheet): (WebKit::WebUserContentController::removeAllUserStyleSheets): (WebKit::WebUserContentController::addUserScriptMessageHandlers): (WebKit::WebUserContentController::removeUserScriptMessageHandler): (WebKit::WebUserContentController::addUserContentExtensions): (WebKit::WebUserContentController::removeUserContentExtension): (WebKit::WebUserContentController::removeAllUserContentExtensions): (WebKit::WebUserContentController::addUserScriptInternal): (WebKit::WebUserContentController::addUserScript): (WebKit::WebUserContentController::removeUserScriptWithURL): (WebKit::WebUserContentController::removeUserScriptInternal): (WebKit::WebUserContentController::removeUserScripts): (WebKit::WebUserContentController::addUserStyleSheetInternal): (WebKit::WebUserContentController::addUserStyleSheet): (WebKit::WebUserContentController::removeUserStyleSheetWithURL): (WebKit::WebUserContentController::removeUserStyleSheetInternal): (WebKit::WebUserContentController::removeUserStyleSheets): (WebKit::WebUserContentController::removeAllUserContent): (WebKit::WebUserContentController::forEachUserScript): (WebKit::WebUserContentController::forEachUserStyleSheet): * WebProcess/UserContent/WebUserContentController.h: * WebProcess/UserContent/WebUserContentController.messages.in: Convert to inheriting from UserContentProvider, rather than containing a UserContentController. This means adding the storage for the user content, which has been simplified to avoid using unique_ptrs. * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::addUserScript): (WebKit::WebPage::addUserStyleSheet): (WebKit::WebPage::removeAllUserContent): Update to call the WebUserContentController, rather than going to the UserContentController, which no longer exists. * WebProcess/WebPage/WebPageGroupProxy.cpp: (WebKit::WebPageGroupProxy::userContentController): * WebProcess/WebPage/WebPageGroupProxy.h: Return the WebUserContentController rather than old UserContentController. Canonical link: https://commits.webkit.org/173593@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198180 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-03-15 00:48:40 +00:00
return;
Add baseURL version of _WKUserStyleSheet forWKWebView. https://bugs.webkit.org/show_bug.cgi?id=211926 rdar://problem/62074675 Reviewed by Devin Rousso. Source/WebCore: Consolidate the paths taken for adding a UserStyleSheet. The m_injectedStyleSheetToSource was missing for page specific style sheets since it was another loop. * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache const): (WebCore::ExtensionStyleSheets::injectPageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::removePageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::detachFromDocument): * dom/ExtensionStyleSheets.h: Source/WebKit: * UIProcess/API/Cocoa/_WKUserStyleSheet.h: * UIProcess/API/Cocoa/_WKUserStyleSheet.mm: (-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:baseURL:level:userContentWorld:]): Added. (-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:level:userContentWorld:]): Clean up WebCore::UserStyleSheet initializer. (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:]): Ditto. (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]): Ditto. (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:userContentWorld:]): Ditto. (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:level:userContentWorld:]): Ditto. Canonical link: https://commits.webkit.org/224820@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261726 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-15 00:33:37 +00:00
addStyleSheet(userStyleSheet);
Add a baseURL parameter to _WKUserStyleSheet https://bugs.webkit.org/show_bug.cgi?id=155219 Reviewed by Tim Horton. Source/WebCore: - Moves to a model for user content where instead of each page having a WebCore::UserContentController object, we have an abstract WebCore::UserContentProvider interface that can be implemented at the WebKit level. For now, legacy WebKit continues to use the old UserContentController, which implements WebCore::UserContentProvider, and WebKit2 implements its own implementation so it can store additional state. * WebCore.xcodeproj/project.pbxproj: Add new files. * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache): Switch to using forEachUserStyleSheet on the UserContentProvider. * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::loadResource): Remove null check now that we always have a UserContentProvider. * loader/EmptyClients.cpp: (WebCore::fillWithEmptyClients): * loader/EmptyClients.h: Add new EmptyClients. * loader/FrameLoader.cpp: (WebCore::FrameLoader::loadResourceSynchronously): Remove null check now that we always have a UserContentProvider. * loader/PingLoader.cpp: (WebCore::processContentExtensionRulesForLoad): Remove null check now that we always have a UserContentProvider. * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::willSendRequestInternal): Remove null check now that we always have a UserContentProvider. * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): Remove null check now that we always have a UserContentProvider. * page/DOMWindow.cpp: (WebCore::DOMWindow::shouldHaveWebKitNamespaceForWorld): Remove null checks now that we always have a UserContentProvider, and userMessageHandlerDescriptors returns a reference. (WebCore::DOMWindow::open): Remove null check now that we always have a UserContentProvider. * page/Frame.cpp: (WebCore::Frame::injectUserScripts): Simplify by lifting document check out of the main loop and using forEachUserScript. * page/Page.cpp: (WebCore::Page::Page): (WebCore::Page::~Page): (WebCore::Page::userContentProvider): (WebCore::Page::setUserContentProvider): (WebCore::Page::setUserContentController): Deleted. * page/Page.h: (WebCore::Page::userContentController): Deleted. * page/PageConfiguration.h: Store the UserContentProvider in a Ref, and require PageConfigurations to provide one. This removes a bunch of null checks and simplifies the code. * page/UserContentController.cpp: (WebCore::UserContentController::~UserContentController): (WebCore::UserContentController::forEachUserScript): (WebCore::UserContentController::forEachUserStyleSheet): (WebCore::UserContentController::addUserScript): (WebCore::UserContentController::removeUserScript): (WebCore::UserContentController::removeUserScripts): (WebCore::UserContentController::addUserStyleSheet): (WebCore::UserContentController::removeUserStyleSheet): (WebCore::UserContentController::removeUserStyleSheets): (WebCore::UserContentController::addUserMessageHandlerDescriptor): (WebCore::UserContentController::removeUserMessageHandlerDescriptor): (WebCore::UserContentController::addUserContentExtension): (WebCore::UserContentController::removeUserContentExtension): (WebCore::UserContentController::removeAllUserContentExtensions): (WebCore::UserContentController::removeAllUserContent): (WebCore::UserContentController::addPage): Deleted. (WebCore::UserContentController::removePage): Deleted. (WebCore::contentExtensionsEnabled): Deleted. (WebCore::UserContentController::processContentExtensionRulesForLoad): Deleted. (WebCore::UserContentController::actionsForResourceLoad): Deleted. * page/UserContentController.h: (WebCore::UserContentController::userScripts): Deleted. (WebCore::UserContentController::userStyleSheets): Deleted. (WebCore::UserContentController::userMessageHandlerDescriptors): Deleted. Add inheritance from UserContentProvider and simplify things by removing unique_ptrs that were holding the member variables. There is usually only one UserContentController so having these in unique_ptrs doesn't make much sense. * page/UserContentProvider.cpp: Added. (WebCore::UserContentProvider::UserContentProvider): (WebCore::UserContentProvider::~UserContentProvider): (WebCore::UserContentProvider::addPage): (WebCore::UserContentProvider::removePage): (WebCore::UserContentProvider::invalidateInjectedStyleSheetCacheInAllFramesInAllPages): (WebCore::contentExtensionsEnabled): (WebCore::UserContentProvider::processContentExtensionRulesForLoad): (WebCore::UserContentProvider::actionsForResourceLoad): * page/UserContentProvider.h: Added. Add abstract class for providing user content and add some helpers on it. * page/UserMessageHandlerDescriptor.h: (WebCore::UserMessageHandlerDescriptor::create): (WebCore::UserMessageHandlerDescriptor::client): (WebCore::UserMessageHandlerDescriptor::invalidateClient): * page/UserMessageHandlersNamespace.cpp: (WebCore::UserMessageHandlersNamespace::handler): Simplify now that userContentProvider() and userMessageHandlerDescriptors() are references. Source/WebKit/mac: * WebView/WebView.mm: (-[WebView _commonInitializationWithFrameName:groupName:]): (-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]): (-[WebView setGroupName:]): Update to account for the name change from UserContentController -> UserContentProvider. Source/WebKit2: - Moves to a model for user content where instead of using a WebCore::UserContentController object, we implement the new WebCore::UserContentProvider interface (on the existing WebUserContentController object). - Uses this to maintain maps of UserStylesSheets and UserScripts along with their identifiers, freeing up the URL, which had been acting as the identifier, to be used as the baseURL which was what it was intended for. - Adds a baseURL property to _WKUserStyleSheet. * WebKit2.xcodeproj/project.pbxproj: Add new files. * Scripts/webkit/messages.py: (headers_for_type): Add support for sending WebUserContentControllerDataTypes. * Shared/WebUserContentControllerDataTypes.cpp: Added. (WebKit::WebUserScriptData::encode): (WebKit::WebUserScriptData::decode): (WebKit::WebUserStyleSheetData::encode): (WebKit::WebUserStyleSheetData::decode): * Shared/WebUserContentControllerDataTypes.h: Added. Add helper types for sending user content over IPC. * UIProcess/API/APIUserScript.cpp: (API::UserScript::generateUniqueURL): (API::UserScript::UserScript): * UIProcess/API/APIUserScript.h: * UIProcess/API/APIUserStyleSheet.cpp: (API::UserStyleSheet::generateUniqueURL): (API::UserStyleSheet::UserStyleSheet): * UIProcess/API/APIUserStyleSheet.h: Add identifiers for tracking across processes. * UIProcess/API/Cocoa/_WKUserStyleSheet.h: * UIProcess/API/Cocoa/_WKUserStyleSheet.mm: (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:userContentWorld:]): (-[_WKUserStyleSheet baseURL]): Add new initializer which takes a baseURL as well as an accessor for the baseURL. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::addUserScript): (WebKit::WebUserContentControllerProxy::removeUserScript): (WebKit::WebUserContentControllerProxy::addUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeUserStyleSheet): Pass identifiers as well as user content. * WebProcess/InjectedBundle/InjectedBundle.cpp: (WebKit::InjectedBundle::addUserScript): (WebKit::InjectedBundle::addUserStyleSheet): Move user content in via move semantics rather than using a unique_ptr. (WebKit::InjectedBundle::removeUserScript): (WebKit::InjectedBundle::removeUserStyleSheet): (WebKit::InjectedBundle::removeUserScripts): (WebKit::InjectedBundle::removeUserStyleSheets): (WebKit::InjectedBundle::removeAllUserContent): Update for new function signatures. * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::WebUserContentController): (WebKit::WebUserContentController::~WebUserContentController): (WebKit::WebUserContentController::addUserContentWorlds): (WebKit::WebUserContentController::removeUserContentWorlds): (WebKit::WebUserContentController::addUserScripts): (WebKit::WebUserContentController::removeUserScript): (WebKit::WebUserContentController::removeAllUserScripts): (WebKit::WebUserContentController::addUserStyleSheets): (WebKit::WebUserContentController::removeUserStyleSheet): (WebKit::WebUserContentController::removeAllUserStyleSheets): (WebKit::WebUserContentController::addUserScriptMessageHandlers): (WebKit::WebUserContentController::removeUserScriptMessageHandler): (WebKit::WebUserContentController::addUserContentExtensions): (WebKit::WebUserContentController::removeUserContentExtension): (WebKit::WebUserContentController::removeAllUserContentExtensions): (WebKit::WebUserContentController::addUserScriptInternal): (WebKit::WebUserContentController::addUserScript): (WebKit::WebUserContentController::removeUserScriptWithURL): (WebKit::WebUserContentController::removeUserScriptInternal): (WebKit::WebUserContentController::removeUserScripts): (WebKit::WebUserContentController::addUserStyleSheetInternal): (WebKit::WebUserContentController::addUserStyleSheet): (WebKit::WebUserContentController::removeUserStyleSheetWithURL): (WebKit::WebUserContentController::removeUserStyleSheetInternal): (WebKit::WebUserContentController::removeUserStyleSheets): (WebKit::WebUserContentController::removeAllUserContent): (WebKit::WebUserContentController::forEachUserScript): (WebKit::WebUserContentController::forEachUserStyleSheet): * WebProcess/UserContent/WebUserContentController.h: * WebProcess/UserContent/WebUserContentController.messages.in: Convert to inheriting from UserContentProvider, rather than containing a UserContentController. This means adding the storage for the user content, which has been simplified to avoid using unique_ptrs. * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::addUserScript): (WebKit::WebPage::addUserStyleSheet): (WebKit::WebPage::removeAllUserContent): Update to call the WebUserContentController, rather than going to the UserContentController, which no longer exists. * WebProcess/WebPage/WebPageGroupProxy.cpp: (WebKit::WebPageGroupProxy::userContentController): * WebProcess/WebPage/WebPageGroupProxy.h: Return the WebUserContentController rather than old UserContentController. Canonical link: https://commits.webkit.org/173593@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198180 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-03-15 00:48:40 +00:00
});
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): Canonical link: https://commits.webkit.org/167594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-23 15:04:16 +00:00
}
Add an SPI to allow UserStyleSheet injection to target a specific WKWebView https://bugs.webkit.org/show_bug.cgi?id=208575 <rdar://problem/59773690> Reviewed by Brady Eidson. Source/WebCore: Add a new Optional<PageIdentifier> member to UserStyleSheet which indicates whether the UserStyleSheet is supposed to be injected for all WKWebViews, or only a specific top-level WKWebView associated with a Page with the give ID. In ExtensionStyleSheets::updateInjectedStyleSheetCache(), UserStyleSheets with a specified pageID are ignored. Instead, we now also consider CSSStyleSheets listed in the new m_pageSpecificStyleSheets which contains page-specific stylesheets to be injected for the associated Document. The new Page::injectUserStyleSheet() method allows the addition of a UserStyleSheet on its documents' ExtensionStyleSheets, and will call this method either for the main frame's Document, or all Documents, depending on the UserStyleSheet's configuration. Finally, these new targeted UserStyleSheets can be removed via Page::removeInjectedUserStyleSheet() and ExtensionStyleSheets::removePageSpecificUserStyleSheet(). * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache const): (WebCore::ExtensionStyleSheets::injectPageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::removePageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::detachFromDocument): * dom/ExtensionStyleSheets.h: * page/Page.cpp: (WebCore::Page::injectUserStyleSheet): (WebCore::Page::removeInjectedUserStyleSheet): * page/Page.h: * page/UserStyleSheet.h: (WebCore::UserStyleSheet::UserStyleSheet): (WebCore::UserStyleSheet::pageID const): Source/WebKit: Since WebCore adds a new Optional<PageIdentifier> member to UserStyleSheet, we now encode that member to be preserved across UI and Web processes. Using this new member, WebUserContentController now determines that a UserStyleSheet meant to target a specific page was added in addUserStyleSheetInternal(), finds the matching WebPage, and calls injectUserStyleSheet() on its backing Page object. Conversely, WebUserContentController::removeUserStyleSheetInternal() will call into Page::removeInjectedUserStyleSheet(). Finally, we offer a new initializer on _WKUserStyleSheet to target a specific WKWebView, and its page's ID will be set on the backing UserStyleSheet. * Shared/WebCoreArgumentCoders.cpp: (IPC::ArgumentCoder<UserStyleSheet>::encode): (IPC::ArgumentCoder<UserStyleSheet>::decode): * UIProcess/API/Cocoa/_WKUserStyleSheet.h: * UIProcess/API/Cocoa/_WKUserStyleSheet.mm: (-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:userContentWorld:]): * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addUserStyleSheetInternal): (WebKit::WebUserContentController::removeUserStyleSheetInternal): Tools: Add new tests for the new SPI which check: 1. that specifying forWKWebView: when initializing a _WKUserStyleSheet will inject the provided CSS source in the specified WKWebView alone, 2. that the same test works with two WKWebViews with a shared WKWebKitConfiguration, 3. that a WKWebView-specific _WKUserStyleSheet can be removed, 4. that a WKWebView-specific _WKUserStyleSheet can be added twice and removed once and be removed as expected, 5. and that a WKWebView-specific _WKUserStyleSheet is automatically removed when navigating to a new page, 6. and that the same test also works with PSON enabled. * TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm: Canonical link: https://commits.webkit.org/221509@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@257870 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-03-04 20:05:38 +00:00
void ExtensionStyleSheets::injectPageSpecificUserStyleSheet(const UserStyleSheet& userStyleSheet)
{
Add baseURL version of _WKUserStyleSheet forWKWebView. https://bugs.webkit.org/show_bug.cgi?id=211926 rdar://problem/62074675 Reviewed by Devin Rousso. Source/WebCore: Consolidate the paths taken for adding a UserStyleSheet. The m_injectedStyleSheetToSource was missing for page specific style sheets since it was another loop. * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache const): (WebCore::ExtensionStyleSheets::injectPageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::removePageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::detachFromDocument): * dom/ExtensionStyleSheets.h: Source/WebKit: * UIProcess/API/Cocoa/_WKUserStyleSheet.h: * UIProcess/API/Cocoa/_WKUserStyleSheet.mm: (-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:baseURL:level:userContentWorld:]): Added. (-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:level:userContentWorld:]): Clean up WebCore::UserStyleSheet initializer. (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:]): Ditto. (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]): Ditto. (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:userContentWorld:]): Ditto. (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:level:userContentWorld:]): Ditto. Canonical link: https://commits.webkit.org/224820@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261726 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-15 00:33:37 +00:00
m_pageSpecificStyleSheets.append(userStyleSheet);
Add an SPI to allow UserStyleSheet injection to target a specific WKWebView https://bugs.webkit.org/show_bug.cgi?id=208575 <rdar://problem/59773690> Reviewed by Brady Eidson. Source/WebCore: Add a new Optional<PageIdentifier> member to UserStyleSheet which indicates whether the UserStyleSheet is supposed to be injected for all WKWebViews, or only a specific top-level WKWebView associated with a Page with the give ID. In ExtensionStyleSheets::updateInjectedStyleSheetCache(), UserStyleSheets with a specified pageID are ignored. Instead, we now also consider CSSStyleSheets listed in the new m_pageSpecificStyleSheets which contains page-specific stylesheets to be injected for the associated Document. The new Page::injectUserStyleSheet() method allows the addition of a UserStyleSheet on its documents' ExtensionStyleSheets, and will call this method either for the main frame's Document, or all Documents, depending on the UserStyleSheet's configuration. Finally, these new targeted UserStyleSheets can be removed via Page::removeInjectedUserStyleSheet() and ExtensionStyleSheets::removePageSpecificUserStyleSheet(). * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache const): (WebCore::ExtensionStyleSheets::injectPageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::removePageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::detachFromDocument): * dom/ExtensionStyleSheets.h: * page/Page.cpp: (WebCore::Page::injectUserStyleSheet): (WebCore::Page::removeInjectedUserStyleSheet): * page/Page.h: * page/UserStyleSheet.h: (WebCore::UserStyleSheet::UserStyleSheet): (WebCore::UserStyleSheet::pageID const): Source/WebKit: Since WebCore adds a new Optional<PageIdentifier> member to UserStyleSheet, we now encode that member to be preserved across UI and Web processes. Using this new member, WebUserContentController now determines that a UserStyleSheet meant to target a specific page was added in addUserStyleSheetInternal(), finds the matching WebPage, and calls injectUserStyleSheet() on its backing Page object. Conversely, WebUserContentController::removeUserStyleSheetInternal() will call into Page::removeInjectedUserStyleSheet(). Finally, we offer a new initializer on _WKUserStyleSheet to target a specific WKWebView, and its page's ID will be set on the backing UserStyleSheet. * Shared/WebCoreArgumentCoders.cpp: (IPC::ArgumentCoder<UserStyleSheet>::encode): (IPC::ArgumentCoder<UserStyleSheet>::decode): * UIProcess/API/Cocoa/_WKUserStyleSheet.h: * UIProcess/API/Cocoa/_WKUserStyleSheet.mm: (-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:userContentWorld:]): * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addUserStyleSheetInternal): (WebKit::WebUserContentController::removeUserStyleSheetInternal): Tools: Add new tests for the new SPI which check: 1. that specifying forWKWebView: when initializing a _WKUserStyleSheet will inject the provided CSS source in the specified WKWebView alone, 2. that the same test works with two WKWebViews with a shared WKWebKitConfiguration, 3. that a WKWebView-specific _WKUserStyleSheet can be removed, 4. that a WKWebView-specific _WKUserStyleSheet can be added twice and removed once and be removed as expected, 5. and that a WKWebView-specific _WKUserStyleSheet is automatically removed when navigating to a new page, 6. and that the same test also works with PSON enabled. * TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm: Canonical link: https://commits.webkit.org/221509@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@257870 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-03-04 20:05:38 +00:00
invalidateInjectedStyleSheetCache();
}
void ExtensionStyleSheets::removePageSpecificUserStyleSheet(const UserStyleSheet& userStyleSheet)
{
Add baseURL version of _WKUserStyleSheet forWKWebView. https://bugs.webkit.org/show_bug.cgi?id=211926 rdar://problem/62074675 Reviewed by Devin Rousso. Source/WebCore: Consolidate the paths taken for adding a UserStyleSheet. The m_injectedStyleSheetToSource was missing for page specific style sheets since it was another loop. * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache const): (WebCore::ExtensionStyleSheets::injectPageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::removePageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::detachFromDocument): * dom/ExtensionStyleSheets.h: Source/WebKit: * UIProcess/API/Cocoa/_WKUserStyleSheet.h: * UIProcess/API/Cocoa/_WKUserStyleSheet.mm: (-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:baseURL:level:userContentWorld:]): Added. (-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:level:userContentWorld:]): Clean up WebCore::UserStyleSheet initializer. (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:]): Ditto. (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]): Ditto. (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:userContentWorld:]): Ditto. (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:level:userContentWorld:]): Ditto. Canonical link: https://commits.webkit.org/224820@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261726 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-15 00:33:37 +00:00
bool removedStyleSheet = m_pageSpecificStyleSheets.removeFirstMatching([&](const auto& styleSheet) {
return styleSheet.url() == userStyleSheet.url();
Add an SPI to allow UserStyleSheet injection to target a specific WKWebView https://bugs.webkit.org/show_bug.cgi?id=208575 <rdar://problem/59773690> Reviewed by Brady Eidson. Source/WebCore: Add a new Optional<PageIdentifier> member to UserStyleSheet which indicates whether the UserStyleSheet is supposed to be injected for all WKWebViews, or only a specific top-level WKWebView associated with a Page with the give ID. In ExtensionStyleSheets::updateInjectedStyleSheetCache(), UserStyleSheets with a specified pageID are ignored. Instead, we now also consider CSSStyleSheets listed in the new m_pageSpecificStyleSheets which contains page-specific stylesheets to be injected for the associated Document. The new Page::injectUserStyleSheet() method allows the addition of a UserStyleSheet on its documents' ExtensionStyleSheets, and will call this method either for the main frame's Document, or all Documents, depending on the UserStyleSheet's configuration. Finally, these new targeted UserStyleSheets can be removed via Page::removeInjectedUserStyleSheet() and ExtensionStyleSheets::removePageSpecificUserStyleSheet(). * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache const): (WebCore::ExtensionStyleSheets::injectPageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::removePageSpecificUserStyleSheet): (WebCore::ExtensionStyleSheets::detachFromDocument): * dom/ExtensionStyleSheets.h: * page/Page.cpp: (WebCore::Page::injectUserStyleSheet): (WebCore::Page::removeInjectedUserStyleSheet): * page/Page.h: * page/UserStyleSheet.h: (WebCore::UserStyleSheet::UserStyleSheet): (WebCore::UserStyleSheet::pageID const): Source/WebKit: Since WebCore adds a new Optional<PageIdentifier> member to UserStyleSheet, we now encode that member to be preserved across UI and Web processes. Using this new member, WebUserContentController now determines that a UserStyleSheet meant to target a specific page was added in addUserStyleSheetInternal(), finds the matching WebPage, and calls injectUserStyleSheet() on its backing Page object. Conversely, WebUserContentController::removeUserStyleSheetInternal() will call into Page::removeInjectedUserStyleSheet(). Finally, we offer a new initializer on _WKUserStyleSheet to target a specific WKWebView, and its page's ID will be set on the backing UserStyleSheet. * Shared/WebCoreArgumentCoders.cpp: (IPC::ArgumentCoder<UserStyleSheet>::encode): (IPC::ArgumentCoder<UserStyleSheet>::decode): * UIProcess/API/Cocoa/_WKUserStyleSheet.h: * UIProcess/API/Cocoa/_WKUserStyleSheet.mm: (-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:userContentWorld:]): * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addUserStyleSheetInternal): (WebKit::WebUserContentController::removeUserStyleSheetInternal): Tools: Add new tests for the new SPI which check: 1. that specifying forWKWebView: when initializing a _WKUserStyleSheet will inject the provided CSS source in the specified WKWebView alone, 2. that the same test works with two WKWebViews with a shared WKWebKitConfiguration, 3. that a WKWebView-specific _WKUserStyleSheet can be removed, 4. that a WKWebView-specific _WKUserStyleSheet can be added twice and removed once and be removed as expected, 5. and that a WKWebView-specific _WKUserStyleSheet is automatically removed when navigating to a new page, 6. and that the same test also works with PSON enabled. * TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm: Canonical link: https://commits.webkit.org/221509@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@257870 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-03-04 20:05:38 +00:00
});
if (removedStyleSheet)
invalidateInjectedStyleSheetCache();
}
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): Canonical link: https://commits.webkit.org/167594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-23 15:04:16 +00:00
void ExtensionStyleSheets::invalidateInjectedStyleSheetCache()
{
m_injectedStyleSheetCacheValid = false;
Style resolver should be updated lazily https://bugs.webkit.org/show_bug.cgi?id=163721 Reviewed by Andreas Kling. Currently when stylesheets change in some way we generally update style resolvers and invalidate style immediately. We should do this lazily to avoid unnecessary work. Also improve naming of the stylesheet invalidation functions and use more optimal functions in some places. * css/CSSComputedStyleDeclaration.cpp: (WebCore::updateStyleIfNeededForNode): * css/CSSStyleSheet.cpp: (WebCore::CSSStyleSheet::didMutateRules): (WebCore::CSSStyleSheet::didMutate): (WebCore::CSSStyleSheet::setDisabled): * css/StyleResolver.cpp: (WebCore::StyleResolver::StyleResolver): Initialize root style font with null font selector. This avoids hitting a CSSFontSelector assert in fast/media/mq-relative-constraints-08.html where media query evaluation requires font information before it is ready. Exposed by increased laziness in this patch. * dom/Document.cpp: (WebCore::Document::setContentLanguage): (WebCore::Document::updateLayoutIgnorePendingStylesheets): (WebCore::Document::isPageBoxVisible): (WebCore::Document::pageSizeAndMarginsInPixels): (WebCore::Document::processHttpEquiv): (WebCore::Document::setSelectedStylesheetSet): (WebCore::Document::didInsertInDocumentShadowRoot): (WebCore::Document::didRemoveInDocumentShadowRoot): * dom/Document.h: (WebCore::Document::inDocumentShadowRoots): Track all shadow roots in the document. This allows us to find and flush style scopes cheaply. * dom/Element.cpp: (WebCore::Element::computedStyle): * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::ExtensionStyleSheets): (WebCore::ExtensionStyleSheets::clearPageUserSheet): (WebCore::ExtensionStyleSheets::updatePageUserSheet): (WebCore::ExtensionStyleSheets::invalidateInjectedStyleSheetCache): (WebCore::ExtensionStyleSheets::addUserStyleSheet): (WebCore::ExtensionStyleSheets::addAuthorStyleSheetForTesting): (WebCore::ExtensionStyleSheets::addDisplayNoneSelector): (WebCore::ExtensionStyleSheets::maybeAddContentExtensionSheet): (WebCore::ExtensionStyleSheets::styleResolverChangedTimerFired): Deleted. Since updates are now done lazily we don't need a special timer for extension stylesheets. * dom/ExtensionStyleSheets.h: * dom/ProcessingInstruction.cpp: (WebCore::ProcessingInstruction::checkStyleSheet): (WebCore::ProcessingInstruction::sheetLoaded): (WebCore::ProcessingInstruction::removedFrom): * dom/ShadowRoot.cpp: (WebCore::ShadowRoot::ShadowRoot): (WebCore::ShadowRoot::insertedInto): (WebCore::ShadowRoot::removedFrom): (WebCore::ShadowRoot::styleScope): * dom/ShadowRoot.h: * html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::setDisabledState): (WebCore::HTMLLinkElement::parseAttribute): (WebCore::HTMLLinkElement::process): (WebCore::HTMLLinkElement::removePendingSheet): * html/HTMLStyleElement.cpp: (WebCore::HTMLStyleElement::parseAttribute): * inspector/InspectorCSSAgent.cpp: (WebCore::InspectorCSSAgent::createInspectorStyleSheetForDocument): (WebCore::InspectorCSSAgent::forcePseudoState): (WebCore::InspectorCSSAgent::resetPseudoStates): * inspector/InspectorPageAgent.cpp: (WebCore::InspectorPageAgent::setEmulatedMedia): * page/Frame.cpp: (WebCore::Frame::setPrinting): * page/FrameView.cpp: (WebCore::FrameView::layout): (WebCore::FrameView::setPagination): (WebCore::FrameView::setViewportSizeForCSSViewportUnits): * page/Page.cpp: (WebCore::Page::setViewMode): (WebCore::Page::setNeedsRecalcStyleInAllFrames): (WebCore::Page::invalidateInjectedStyleSheetCacheInAllFrames): * style/StyleScope.cpp: (WebCore::Style::Scope::setPreferredStylesheetSetName): (WebCore::Style::Scope::setSelectedStylesheetSetName): (WebCore::Style::Scope::removePendingSheet): (WebCore::Style::Scope::removeStyleSheetCandidateNode): (WebCore::Style::Scope::activeStyleSheetsForInspector): (WebCore::Style::Scope::flushPendingUpdate): Also flush descendant shadow roots. (WebCore::Style::Scope::scheduleUpdate): (WebCore::Style::Scope::didChangeActiveStyleSheetCandidates): Make lazy. (WebCore::Style::Scope::didChangeStyleSheetContents): Make lazy. (WebCore::Style::Scope::didChangeStyleSheetEnvironment): Environment changes also affect author shadow roots. (WebCore::Style::Scope::styleSheetsForStyleSheetList): (WebCore::Style::Scope::scheduleActiveSetUpdate): Deleted. (WebCore::Style::Scope::didChangeCandidatesForActiveSet): Deleted. (WebCore::Style::Scope::didChangeContentsOrInterpretation): Deleted. Improved naming of these and split didChangeContentsOrInterpretation into two separate functions. * style/StyleScope.h: (WebCore::Style::Scope::styleSheetsForStyleSheetList): Deleted. (WebCore::Style::Scope::setPreferredStylesheetSetName): Deleted. (WebCore::Style::Scope::setSelectedStylesheetSetName): Deleted. * svg/SVGFontFaceElement.cpp: (WebCore::SVGFontFaceElement::rebuildFontFace): (WebCore::SVGFontFaceElement::removedFrom): * testing/Internals.cpp: (WebCore::Internals::resetToConsistentState): Ensure that cationsStyleSheetOverride really becomes empty. Some tests rely on not having suprise inserted stylesheets. Previously this was racy and the patch affected order of things. (WebCore::Internals::styleChangeType): * xml/XMLTreeViewer.cpp: (WebCore::XMLTreeViewer::transformDocumentToTreeView): * xml/parser/XMLDocumentParser.cpp: (WebCore::XMLDocumentParser::end): * xml/parser/XMLDocumentParserLibxml2.cpp: (WebCore::XMLDocumentParser::doEnd): Canonical link: https://commits.webkit.org/181549@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207669 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-21 13:36:45 +00:00
m_document.styleScope().didChangeStyleSheetEnvironment();
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): Canonical link: https://commits.webkit.org/167594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-23 15:04:16 +00:00
}
void ExtensionStyleSheets::addUserStyleSheet(Ref<StyleSheetContents>&& userSheet)
{
ASSERT(userSheet.get().isUserStyleSheet());
Clean CSS stylesheets should be accessible from JavaScript https://bugs.webkit.org/show_bug.cgi?id=158728 Patch by Youenn Fablet <youenn@apple.com> on 2016-09-05 Reviewed by Darin Adler. Source/WebCore: Covered by updated tests. Making use of the resource response type to evaluate whether to make the CSS stylesheets visible for stylesheet link elements and for stylesheet processing instructions. Ideally, the origin flag should be a boolean. To keep behavior consistent in cors-check-unaware cases, the flag might remain unset. In that case, the behavior remains the same (checking of the stylesheet URL). The origin flag is set to true or false only in case of fetch mode being set to cors using the crossorigin attribute. Updated CSSStyleSheet::create to take a Node reference. Updated callers accordingly. * contentextensions/ContentExtensionStyleSheet.cpp: (WebCore::ContentExtensions::ContentExtensionStyleSheet::ContentExtensionStyleSheet): Updated to pass a Node reference and not pointer. * css/CSSStyleSheet.cpp: (WebCore::CSSStyleSheet::create): Makes origin flag undefined if boolean parameter is not passed. Otherwise origin flag is set according given boolean value. (WebCore::CSSStyleSheet::createInline): Makes origin flag set to true. (WebCore::CSSStyleSheet::CSSStyleSheet): Adding origin flag initialization. (WebCore::CSSStyleSheet::canAccessRules): Returning according the origin flag if set. Returning as before in case the flag is not set. * css/CSSStyleSheet.h: Adding origin clean flag. * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::addUserStyleSheet): (WebCore::ExtensionStyleSheets::addAuthorStyleSheetForTesting): (WebCore::ExtensionStyleSheets::maybeAddContentExtensionSheet): * html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::initializeStyleSheet): Helper routine used in setCSSStyleSheet. Sets origin clean flag if the resource is clean. (WebCore::HTMLLinkElement::setCSSStyleSheet): Making use of initializeStyleSheet. * html/HTMLLinkElement.h: LayoutTests: * http/tests/security/cannot-read-cssrules-expected.txt: * http/tests/security/cannot-read-cssrules-redirect-expected.txt: * http/tests/security/cannot-read-cssrules-redirect.html: * http/tests/security/cannot-read-cssrules.html: * http/tests/security/cross-origin-css-9.html: * http/tests/security/resources/xorigincss1-allow-star.php: Added. Canonical link: https://commits.webkit.org/179771@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205455 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-05 16:58:48 +00:00
m_userStyleSheets.append(CSSStyleSheet::create(WTFMove(userSheet), m_document));
Style resolver should be updated lazily https://bugs.webkit.org/show_bug.cgi?id=163721 Reviewed by Andreas Kling. Currently when stylesheets change in some way we generally update style resolvers and invalidate style immediately. We should do this lazily to avoid unnecessary work. Also improve naming of the stylesheet invalidation functions and use more optimal functions in some places. * css/CSSComputedStyleDeclaration.cpp: (WebCore::updateStyleIfNeededForNode): * css/CSSStyleSheet.cpp: (WebCore::CSSStyleSheet::didMutateRules): (WebCore::CSSStyleSheet::didMutate): (WebCore::CSSStyleSheet::setDisabled): * css/StyleResolver.cpp: (WebCore::StyleResolver::StyleResolver): Initialize root style font with null font selector. This avoids hitting a CSSFontSelector assert in fast/media/mq-relative-constraints-08.html where media query evaluation requires font information before it is ready. Exposed by increased laziness in this patch. * dom/Document.cpp: (WebCore::Document::setContentLanguage): (WebCore::Document::updateLayoutIgnorePendingStylesheets): (WebCore::Document::isPageBoxVisible): (WebCore::Document::pageSizeAndMarginsInPixels): (WebCore::Document::processHttpEquiv): (WebCore::Document::setSelectedStylesheetSet): (WebCore::Document::didInsertInDocumentShadowRoot): (WebCore::Document::didRemoveInDocumentShadowRoot): * dom/Document.h: (WebCore::Document::inDocumentShadowRoots): Track all shadow roots in the document. This allows us to find and flush style scopes cheaply. * dom/Element.cpp: (WebCore::Element::computedStyle): * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::ExtensionStyleSheets): (WebCore::ExtensionStyleSheets::clearPageUserSheet): (WebCore::ExtensionStyleSheets::updatePageUserSheet): (WebCore::ExtensionStyleSheets::invalidateInjectedStyleSheetCache): (WebCore::ExtensionStyleSheets::addUserStyleSheet): (WebCore::ExtensionStyleSheets::addAuthorStyleSheetForTesting): (WebCore::ExtensionStyleSheets::addDisplayNoneSelector): (WebCore::ExtensionStyleSheets::maybeAddContentExtensionSheet): (WebCore::ExtensionStyleSheets::styleResolverChangedTimerFired): Deleted. Since updates are now done lazily we don't need a special timer for extension stylesheets. * dom/ExtensionStyleSheets.h: * dom/ProcessingInstruction.cpp: (WebCore::ProcessingInstruction::checkStyleSheet): (WebCore::ProcessingInstruction::sheetLoaded): (WebCore::ProcessingInstruction::removedFrom): * dom/ShadowRoot.cpp: (WebCore::ShadowRoot::ShadowRoot): (WebCore::ShadowRoot::insertedInto): (WebCore::ShadowRoot::removedFrom): (WebCore::ShadowRoot::styleScope): * dom/ShadowRoot.h: * html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::setDisabledState): (WebCore::HTMLLinkElement::parseAttribute): (WebCore::HTMLLinkElement::process): (WebCore::HTMLLinkElement::removePendingSheet): * html/HTMLStyleElement.cpp: (WebCore::HTMLStyleElement::parseAttribute): * inspector/InspectorCSSAgent.cpp: (WebCore::InspectorCSSAgent::createInspectorStyleSheetForDocument): (WebCore::InspectorCSSAgent::forcePseudoState): (WebCore::InspectorCSSAgent::resetPseudoStates): * inspector/InspectorPageAgent.cpp: (WebCore::InspectorPageAgent::setEmulatedMedia): * page/Frame.cpp: (WebCore::Frame::setPrinting): * page/FrameView.cpp: (WebCore::FrameView::layout): (WebCore::FrameView::setPagination): (WebCore::FrameView::setViewportSizeForCSSViewportUnits): * page/Page.cpp: (WebCore::Page::setViewMode): (WebCore::Page::setNeedsRecalcStyleInAllFrames): (WebCore::Page::invalidateInjectedStyleSheetCacheInAllFrames): * style/StyleScope.cpp: (WebCore::Style::Scope::setPreferredStylesheetSetName): (WebCore::Style::Scope::setSelectedStylesheetSetName): (WebCore::Style::Scope::removePendingSheet): (WebCore::Style::Scope::removeStyleSheetCandidateNode): (WebCore::Style::Scope::activeStyleSheetsForInspector): (WebCore::Style::Scope::flushPendingUpdate): Also flush descendant shadow roots. (WebCore::Style::Scope::scheduleUpdate): (WebCore::Style::Scope::didChangeActiveStyleSheetCandidates): Make lazy. (WebCore::Style::Scope::didChangeStyleSheetContents): Make lazy. (WebCore::Style::Scope::didChangeStyleSheetEnvironment): Environment changes also affect author shadow roots. (WebCore::Style::Scope::styleSheetsForStyleSheetList): (WebCore::Style::Scope::scheduleActiveSetUpdate): Deleted. (WebCore::Style::Scope::didChangeCandidatesForActiveSet): Deleted. (WebCore::Style::Scope::didChangeContentsOrInterpretation): Deleted. Improved naming of these and split didChangeContentsOrInterpretation into two separate functions. * style/StyleScope.h: (WebCore::Style::Scope::styleSheetsForStyleSheetList): Deleted. (WebCore::Style::Scope::setPreferredStylesheetSetName): Deleted. (WebCore::Style::Scope::setSelectedStylesheetSetName): Deleted. * svg/SVGFontFaceElement.cpp: (WebCore::SVGFontFaceElement::rebuildFontFace): (WebCore::SVGFontFaceElement::removedFrom): * testing/Internals.cpp: (WebCore::Internals::resetToConsistentState): Ensure that cationsStyleSheetOverride really becomes empty. Some tests rely on not having suprise inserted stylesheets. Previously this was racy and the patch affected order of things. (WebCore::Internals::styleChangeType): * xml/XMLTreeViewer.cpp: (WebCore::XMLTreeViewer::transformDocumentToTreeView): * xml/parser/XMLDocumentParser.cpp: (WebCore::XMLDocumentParser::end): * xml/parser/XMLDocumentParserLibxml2.cpp: (WebCore::XMLDocumentParser::doEnd): Canonical link: https://commits.webkit.org/181549@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207669 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-21 13:36:45 +00:00
m_document.styleScope().didChangeStyleSheetEnvironment();
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): Canonical link: https://commits.webkit.org/167594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-23 15:04:16 +00:00
}
void ExtensionStyleSheets::addAuthorStyleSheetForTesting(Ref<StyleSheetContents>&& authorSheet)
{
ASSERT(!authorSheet.get().isUserStyleSheet());
Clean CSS stylesheets should be accessible from JavaScript https://bugs.webkit.org/show_bug.cgi?id=158728 Patch by Youenn Fablet <youenn@apple.com> on 2016-09-05 Reviewed by Darin Adler. Source/WebCore: Covered by updated tests. Making use of the resource response type to evaluate whether to make the CSS stylesheets visible for stylesheet link elements and for stylesheet processing instructions. Ideally, the origin flag should be a boolean. To keep behavior consistent in cors-check-unaware cases, the flag might remain unset. In that case, the behavior remains the same (checking of the stylesheet URL). The origin flag is set to true or false only in case of fetch mode being set to cors using the crossorigin attribute. Updated CSSStyleSheet::create to take a Node reference. Updated callers accordingly. * contentextensions/ContentExtensionStyleSheet.cpp: (WebCore::ContentExtensions::ContentExtensionStyleSheet::ContentExtensionStyleSheet): Updated to pass a Node reference and not pointer. * css/CSSStyleSheet.cpp: (WebCore::CSSStyleSheet::create): Makes origin flag undefined if boolean parameter is not passed. Otherwise origin flag is set according given boolean value. (WebCore::CSSStyleSheet::createInline): Makes origin flag set to true. (WebCore::CSSStyleSheet::CSSStyleSheet): Adding origin flag initialization. (WebCore::CSSStyleSheet::canAccessRules): Returning according the origin flag if set. Returning as before in case the flag is not set. * css/CSSStyleSheet.h: Adding origin clean flag. * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::addUserStyleSheet): (WebCore::ExtensionStyleSheets::addAuthorStyleSheetForTesting): (WebCore::ExtensionStyleSheets::maybeAddContentExtensionSheet): * html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::initializeStyleSheet): Helper routine used in setCSSStyleSheet. Sets origin clean flag if the resource is clean. (WebCore::HTMLLinkElement::setCSSStyleSheet): Making use of initializeStyleSheet. * html/HTMLLinkElement.h: LayoutTests: * http/tests/security/cannot-read-cssrules-expected.txt: * http/tests/security/cannot-read-cssrules-redirect-expected.txt: * http/tests/security/cannot-read-cssrules-redirect.html: * http/tests/security/cannot-read-cssrules.html: * http/tests/security/cross-origin-css-9.html: * http/tests/security/resources/xorigincss1-allow-star.php: Added. Canonical link: https://commits.webkit.org/179771@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205455 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-05 16:58:48 +00:00
m_authorStyleSheetsForTesting.append(CSSStyleSheet::create(WTFMove(authorSheet), m_document));
Style resolver should be updated lazily https://bugs.webkit.org/show_bug.cgi?id=163721 Reviewed by Andreas Kling. Currently when stylesheets change in some way we generally update style resolvers and invalidate style immediately. We should do this lazily to avoid unnecessary work. Also improve naming of the stylesheet invalidation functions and use more optimal functions in some places. * css/CSSComputedStyleDeclaration.cpp: (WebCore::updateStyleIfNeededForNode): * css/CSSStyleSheet.cpp: (WebCore::CSSStyleSheet::didMutateRules): (WebCore::CSSStyleSheet::didMutate): (WebCore::CSSStyleSheet::setDisabled): * css/StyleResolver.cpp: (WebCore::StyleResolver::StyleResolver): Initialize root style font with null font selector. This avoids hitting a CSSFontSelector assert in fast/media/mq-relative-constraints-08.html where media query evaluation requires font information before it is ready. Exposed by increased laziness in this patch. * dom/Document.cpp: (WebCore::Document::setContentLanguage): (WebCore::Document::updateLayoutIgnorePendingStylesheets): (WebCore::Document::isPageBoxVisible): (WebCore::Document::pageSizeAndMarginsInPixels): (WebCore::Document::processHttpEquiv): (WebCore::Document::setSelectedStylesheetSet): (WebCore::Document::didInsertInDocumentShadowRoot): (WebCore::Document::didRemoveInDocumentShadowRoot): * dom/Document.h: (WebCore::Document::inDocumentShadowRoots): Track all shadow roots in the document. This allows us to find and flush style scopes cheaply. * dom/Element.cpp: (WebCore::Element::computedStyle): * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::ExtensionStyleSheets): (WebCore::ExtensionStyleSheets::clearPageUserSheet): (WebCore::ExtensionStyleSheets::updatePageUserSheet): (WebCore::ExtensionStyleSheets::invalidateInjectedStyleSheetCache): (WebCore::ExtensionStyleSheets::addUserStyleSheet): (WebCore::ExtensionStyleSheets::addAuthorStyleSheetForTesting): (WebCore::ExtensionStyleSheets::addDisplayNoneSelector): (WebCore::ExtensionStyleSheets::maybeAddContentExtensionSheet): (WebCore::ExtensionStyleSheets::styleResolverChangedTimerFired): Deleted. Since updates are now done lazily we don't need a special timer for extension stylesheets. * dom/ExtensionStyleSheets.h: * dom/ProcessingInstruction.cpp: (WebCore::ProcessingInstruction::checkStyleSheet): (WebCore::ProcessingInstruction::sheetLoaded): (WebCore::ProcessingInstruction::removedFrom): * dom/ShadowRoot.cpp: (WebCore::ShadowRoot::ShadowRoot): (WebCore::ShadowRoot::insertedInto): (WebCore::ShadowRoot::removedFrom): (WebCore::ShadowRoot::styleScope): * dom/ShadowRoot.h: * html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::setDisabledState): (WebCore::HTMLLinkElement::parseAttribute): (WebCore::HTMLLinkElement::process): (WebCore::HTMLLinkElement::removePendingSheet): * html/HTMLStyleElement.cpp: (WebCore::HTMLStyleElement::parseAttribute): * inspector/InspectorCSSAgent.cpp: (WebCore::InspectorCSSAgent::createInspectorStyleSheetForDocument): (WebCore::InspectorCSSAgent::forcePseudoState): (WebCore::InspectorCSSAgent::resetPseudoStates): * inspector/InspectorPageAgent.cpp: (WebCore::InspectorPageAgent::setEmulatedMedia): * page/Frame.cpp: (WebCore::Frame::setPrinting): * page/FrameView.cpp: (WebCore::FrameView::layout): (WebCore::FrameView::setPagination): (WebCore::FrameView::setViewportSizeForCSSViewportUnits): * page/Page.cpp: (WebCore::Page::setViewMode): (WebCore::Page::setNeedsRecalcStyleInAllFrames): (WebCore::Page::invalidateInjectedStyleSheetCacheInAllFrames): * style/StyleScope.cpp: (WebCore::Style::Scope::setPreferredStylesheetSetName): (WebCore::Style::Scope::setSelectedStylesheetSetName): (WebCore::Style::Scope::removePendingSheet): (WebCore::Style::Scope::removeStyleSheetCandidateNode): (WebCore::Style::Scope::activeStyleSheetsForInspector): (WebCore::Style::Scope::flushPendingUpdate): Also flush descendant shadow roots. (WebCore::Style::Scope::scheduleUpdate): (WebCore::Style::Scope::didChangeActiveStyleSheetCandidates): Make lazy. (WebCore::Style::Scope::didChangeStyleSheetContents): Make lazy. (WebCore::Style::Scope::didChangeStyleSheetEnvironment): Environment changes also affect author shadow roots. (WebCore::Style::Scope::styleSheetsForStyleSheetList): (WebCore::Style::Scope::scheduleActiveSetUpdate): Deleted. (WebCore::Style::Scope::didChangeCandidatesForActiveSet): Deleted. (WebCore::Style::Scope::didChangeContentsOrInterpretation): Deleted. Improved naming of these and split didChangeContentsOrInterpretation into two separate functions. * style/StyleScope.h: (WebCore::Style::Scope::styleSheetsForStyleSheetList): Deleted. (WebCore::Style::Scope::setPreferredStylesheetSetName): Deleted. (WebCore::Style::Scope::setSelectedStylesheetSetName): Deleted. * svg/SVGFontFaceElement.cpp: (WebCore::SVGFontFaceElement::rebuildFontFace): (WebCore::SVGFontFaceElement::removedFrom): * testing/Internals.cpp: (WebCore::Internals::resetToConsistentState): Ensure that cationsStyleSheetOverride really becomes empty. Some tests rely on not having suprise inserted stylesheets. Previously this was racy and the patch affected order of things. (WebCore::Internals::styleChangeType): * xml/XMLTreeViewer.cpp: (WebCore::XMLTreeViewer::transformDocumentToTreeView): * xml/parser/XMLDocumentParser.cpp: (WebCore::XMLDocumentParser::end): * xml/parser/XMLDocumentParserLibxml2.cpp: (WebCore::XMLDocumentParser::doEnd): Canonical link: https://commits.webkit.org/181549@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207669 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-21 13:36:45 +00:00
m_document.styleScope().didChangeStyleSheetEnvironment();
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): Canonical link: https://commits.webkit.org/167594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-23 15:04:16 +00:00
}
#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());
}
if (result.iterator->value->addDisplayNoneSelector(selector, selectorID))
Style resolver should be updated lazily https://bugs.webkit.org/show_bug.cgi?id=163721 Reviewed by Andreas Kling. Currently when stylesheets change in some way we generally update style resolvers and invalidate style immediately. We should do this lazily to avoid unnecessary work. Also improve naming of the stylesheet invalidation functions and use more optimal functions in some places. * css/CSSComputedStyleDeclaration.cpp: (WebCore::updateStyleIfNeededForNode): * css/CSSStyleSheet.cpp: (WebCore::CSSStyleSheet::didMutateRules): (WebCore::CSSStyleSheet::didMutate): (WebCore::CSSStyleSheet::setDisabled): * css/StyleResolver.cpp: (WebCore::StyleResolver::StyleResolver): Initialize root style font with null font selector. This avoids hitting a CSSFontSelector assert in fast/media/mq-relative-constraints-08.html where media query evaluation requires font information before it is ready. Exposed by increased laziness in this patch. * dom/Document.cpp: (WebCore::Document::setContentLanguage): (WebCore::Document::updateLayoutIgnorePendingStylesheets): (WebCore::Document::isPageBoxVisible): (WebCore::Document::pageSizeAndMarginsInPixels): (WebCore::Document::processHttpEquiv): (WebCore::Document::setSelectedStylesheetSet): (WebCore::Document::didInsertInDocumentShadowRoot): (WebCore::Document::didRemoveInDocumentShadowRoot): * dom/Document.h: (WebCore::Document::inDocumentShadowRoots): Track all shadow roots in the document. This allows us to find and flush style scopes cheaply. * dom/Element.cpp: (WebCore::Element::computedStyle): * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::ExtensionStyleSheets): (WebCore::ExtensionStyleSheets::clearPageUserSheet): (WebCore::ExtensionStyleSheets::updatePageUserSheet): (WebCore::ExtensionStyleSheets::invalidateInjectedStyleSheetCache): (WebCore::ExtensionStyleSheets::addUserStyleSheet): (WebCore::ExtensionStyleSheets::addAuthorStyleSheetForTesting): (WebCore::ExtensionStyleSheets::addDisplayNoneSelector): (WebCore::ExtensionStyleSheets::maybeAddContentExtensionSheet): (WebCore::ExtensionStyleSheets::styleResolverChangedTimerFired): Deleted. Since updates are now done lazily we don't need a special timer for extension stylesheets. * dom/ExtensionStyleSheets.h: * dom/ProcessingInstruction.cpp: (WebCore::ProcessingInstruction::checkStyleSheet): (WebCore::ProcessingInstruction::sheetLoaded): (WebCore::ProcessingInstruction::removedFrom): * dom/ShadowRoot.cpp: (WebCore::ShadowRoot::ShadowRoot): (WebCore::ShadowRoot::insertedInto): (WebCore::ShadowRoot::removedFrom): (WebCore::ShadowRoot::styleScope): * dom/ShadowRoot.h: * html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::setDisabledState): (WebCore::HTMLLinkElement::parseAttribute): (WebCore::HTMLLinkElement::process): (WebCore::HTMLLinkElement::removePendingSheet): * html/HTMLStyleElement.cpp: (WebCore::HTMLStyleElement::parseAttribute): * inspector/InspectorCSSAgent.cpp: (WebCore::InspectorCSSAgent::createInspectorStyleSheetForDocument): (WebCore::InspectorCSSAgent::forcePseudoState): (WebCore::InspectorCSSAgent::resetPseudoStates): * inspector/InspectorPageAgent.cpp: (WebCore::InspectorPageAgent::setEmulatedMedia): * page/Frame.cpp: (WebCore::Frame::setPrinting): * page/FrameView.cpp: (WebCore::FrameView::layout): (WebCore::FrameView::setPagination): (WebCore::FrameView::setViewportSizeForCSSViewportUnits): * page/Page.cpp: (WebCore::Page::setViewMode): (WebCore::Page::setNeedsRecalcStyleInAllFrames): (WebCore::Page::invalidateInjectedStyleSheetCacheInAllFrames): * style/StyleScope.cpp: (WebCore::Style::Scope::setPreferredStylesheetSetName): (WebCore::Style::Scope::setSelectedStylesheetSetName): (WebCore::Style::Scope::removePendingSheet): (WebCore::Style::Scope::removeStyleSheetCandidateNode): (WebCore::Style::Scope::activeStyleSheetsForInspector): (WebCore::Style::Scope::flushPendingUpdate): Also flush descendant shadow roots. (WebCore::Style::Scope::scheduleUpdate): (WebCore::Style::Scope::didChangeActiveStyleSheetCandidates): Make lazy. (WebCore::Style::Scope::didChangeStyleSheetContents): Make lazy. (WebCore::Style::Scope::didChangeStyleSheetEnvironment): Environment changes also affect author shadow roots. (WebCore::Style::Scope::styleSheetsForStyleSheetList): (WebCore::Style::Scope::scheduleActiveSetUpdate): Deleted. (WebCore::Style::Scope::didChangeCandidatesForActiveSet): Deleted. (WebCore::Style::Scope::didChangeContentsOrInterpretation): Deleted. Improved naming of these and split didChangeContentsOrInterpretation into two separate functions. * style/StyleScope.h: (WebCore::Style::Scope::styleSheetsForStyleSheetList): Deleted. (WebCore::Style::Scope::setPreferredStylesheetSetName): Deleted. (WebCore::Style::Scope::setSelectedStylesheetSetName): Deleted. * svg/SVGFontFaceElement.cpp: (WebCore::SVGFontFaceElement::rebuildFontFace): (WebCore::SVGFontFaceElement::removedFrom): * testing/Internals.cpp: (WebCore::Internals::resetToConsistentState): Ensure that cationsStyleSheetOverride really becomes empty. Some tests rely on not having suprise inserted stylesheets. Previously this was racy and the patch affected order of things. (WebCore::Internals::styleChangeType): * xml/XMLTreeViewer.cpp: (WebCore::XMLTreeViewer::transformDocumentToTreeView): * xml/parser/XMLDocumentParser.cpp: (WebCore::XMLDocumentParser::end): * xml/parser/XMLDocumentParserLibxml2.cpp: (WebCore::XMLDocumentParser::doEnd): Canonical link: https://commits.webkit.org/181549@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207669 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-21 13:36:45 +00:00
m_document.styleScope().didChangeStyleSheetEnvironment();
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): Canonical link: https://commits.webkit.org/167594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-23 15:04:16 +00:00
}
void ExtensionStyleSheets::maybeAddContentExtensionSheet(const String& identifier, StyleSheetContents& sheet)
{
ASSERT(sheet.isUserStyleSheet());
if (m_contentExtensionSheets.contains(identifier))
return;
Clean CSS stylesheets should be accessible from JavaScript https://bugs.webkit.org/show_bug.cgi?id=158728 Patch by Youenn Fablet <youenn@apple.com> on 2016-09-05 Reviewed by Darin Adler. Source/WebCore: Covered by updated tests. Making use of the resource response type to evaluate whether to make the CSS stylesheets visible for stylesheet link elements and for stylesheet processing instructions. Ideally, the origin flag should be a boolean. To keep behavior consistent in cors-check-unaware cases, the flag might remain unset. In that case, the behavior remains the same (checking of the stylesheet URL). The origin flag is set to true or false only in case of fetch mode being set to cors using the crossorigin attribute. Updated CSSStyleSheet::create to take a Node reference. Updated callers accordingly. * contentextensions/ContentExtensionStyleSheet.cpp: (WebCore::ContentExtensions::ContentExtensionStyleSheet::ContentExtensionStyleSheet): Updated to pass a Node reference and not pointer. * css/CSSStyleSheet.cpp: (WebCore::CSSStyleSheet::create): Makes origin flag undefined if boolean parameter is not passed. Otherwise origin flag is set according given boolean value. (WebCore::CSSStyleSheet::createInline): Makes origin flag set to true. (WebCore::CSSStyleSheet::CSSStyleSheet): Adding origin flag initialization. (WebCore::CSSStyleSheet::canAccessRules): Returning according the origin flag if set. Returning as before in case the flag is not set. * css/CSSStyleSheet.h: Adding origin clean flag. * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::addUserStyleSheet): (WebCore::ExtensionStyleSheets::addAuthorStyleSheetForTesting): (WebCore::ExtensionStyleSheets::maybeAddContentExtensionSheet): * html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::initializeStyleSheet): Helper routine used in setCSSStyleSheet. Sets origin clean flag if the resource is clean. (WebCore::HTMLLinkElement::setCSSStyleSheet): Making use of initializeStyleSheet. * html/HTMLLinkElement.h: LayoutTests: * http/tests/security/cannot-read-cssrules-expected.txt: * http/tests/security/cannot-read-cssrules-redirect-expected.txt: * http/tests/security/cannot-read-cssrules-redirect.html: * http/tests/security/cannot-read-cssrules.html: * http/tests/security/cross-origin-css-9.html: * http/tests/security/resources/xorigincss1-allow-star.php: Added. Canonical link: https://commits.webkit.org/179771@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205455 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-05 16:58:48 +00:00
Ref<CSSStyleSheet> cssSheet = CSSStyleSheet::create(sheet, m_document);
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): Canonical link: https://commits.webkit.org/167594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-23 15:04:16 +00:00
m_contentExtensionSheets.set(identifier, &cssSheet.get());
m_userStyleSheets.append(adoptRef(cssSheet.leakRef()));
Style resolver should be updated lazily https://bugs.webkit.org/show_bug.cgi?id=163721 Reviewed by Andreas Kling. Currently when stylesheets change in some way we generally update style resolvers and invalidate style immediately. We should do this lazily to avoid unnecessary work. Also improve naming of the stylesheet invalidation functions and use more optimal functions in some places. * css/CSSComputedStyleDeclaration.cpp: (WebCore::updateStyleIfNeededForNode): * css/CSSStyleSheet.cpp: (WebCore::CSSStyleSheet::didMutateRules): (WebCore::CSSStyleSheet::didMutate): (WebCore::CSSStyleSheet::setDisabled): * css/StyleResolver.cpp: (WebCore::StyleResolver::StyleResolver): Initialize root style font with null font selector. This avoids hitting a CSSFontSelector assert in fast/media/mq-relative-constraints-08.html where media query evaluation requires font information before it is ready. Exposed by increased laziness in this patch. * dom/Document.cpp: (WebCore::Document::setContentLanguage): (WebCore::Document::updateLayoutIgnorePendingStylesheets): (WebCore::Document::isPageBoxVisible): (WebCore::Document::pageSizeAndMarginsInPixels): (WebCore::Document::processHttpEquiv): (WebCore::Document::setSelectedStylesheetSet): (WebCore::Document::didInsertInDocumentShadowRoot): (WebCore::Document::didRemoveInDocumentShadowRoot): * dom/Document.h: (WebCore::Document::inDocumentShadowRoots): Track all shadow roots in the document. This allows us to find and flush style scopes cheaply. * dom/Element.cpp: (WebCore::Element::computedStyle): * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::ExtensionStyleSheets): (WebCore::ExtensionStyleSheets::clearPageUserSheet): (WebCore::ExtensionStyleSheets::updatePageUserSheet): (WebCore::ExtensionStyleSheets::invalidateInjectedStyleSheetCache): (WebCore::ExtensionStyleSheets::addUserStyleSheet): (WebCore::ExtensionStyleSheets::addAuthorStyleSheetForTesting): (WebCore::ExtensionStyleSheets::addDisplayNoneSelector): (WebCore::ExtensionStyleSheets::maybeAddContentExtensionSheet): (WebCore::ExtensionStyleSheets::styleResolverChangedTimerFired): Deleted. Since updates are now done lazily we don't need a special timer for extension stylesheets. * dom/ExtensionStyleSheets.h: * dom/ProcessingInstruction.cpp: (WebCore::ProcessingInstruction::checkStyleSheet): (WebCore::ProcessingInstruction::sheetLoaded): (WebCore::ProcessingInstruction::removedFrom): * dom/ShadowRoot.cpp: (WebCore::ShadowRoot::ShadowRoot): (WebCore::ShadowRoot::insertedInto): (WebCore::ShadowRoot::removedFrom): (WebCore::ShadowRoot::styleScope): * dom/ShadowRoot.h: * html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::setDisabledState): (WebCore::HTMLLinkElement::parseAttribute): (WebCore::HTMLLinkElement::process): (WebCore::HTMLLinkElement::removePendingSheet): * html/HTMLStyleElement.cpp: (WebCore::HTMLStyleElement::parseAttribute): * inspector/InspectorCSSAgent.cpp: (WebCore::InspectorCSSAgent::createInspectorStyleSheetForDocument): (WebCore::InspectorCSSAgent::forcePseudoState): (WebCore::InspectorCSSAgent::resetPseudoStates): * inspector/InspectorPageAgent.cpp: (WebCore::InspectorPageAgent::setEmulatedMedia): * page/Frame.cpp: (WebCore::Frame::setPrinting): * page/FrameView.cpp: (WebCore::FrameView::layout): (WebCore::FrameView::setPagination): (WebCore::FrameView::setViewportSizeForCSSViewportUnits): * page/Page.cpp: (WebCore::Page::setViewMode): (WebCore::Page::setNeedsRecalcStyleInAllFrames): (WebCore::Page::invalidateInjectedStyleSheetCacheInAllFrames): * style/StyleScope.cpp: (WebCore::Style::Scope::setPreferredStylesheetSetName): (WebCore::Style::Scope::setSelectedStylesheetSetName): (WebCore::Style::Scope::removePendingSheet): (WebCore::Style::Scope::removeStyleSheetCandidateNode): (WebCore::Style::Scope::activeStyleSheetsForInspector): (WebCore::Style::Scope::flushPendingUpdate): Also flush descendant shadow roots. (WebCore::Style::Scope::scheduleUpdate): (WebCore::Style::Scope::didChangeActiveStyleSheetCandidates): Make lazy. (WebCore::Style::Scope::didChangeStyleSheetContents): Make lazy. (WebCore::Style::Scope::didChangeStyleSheetEnvironment): Environment changes also affect author shadow roots. (WebCore::Style::Scope::styleSheetsForStyleSheetList): (WebCore::Style::Scope::scheduleActiveSetUpdate): Deleted. (WebCore::Style::Scope::didChangeCandidatesForActiveSet): Deleted. (WebCore::Style::Scope::didChangeContentsOrInterpretation): Deleted. Improved naming of these and split didChangeContentsOrInterpretation into two separate functions. * style/StyleScope.h: (WebCore::Style::Scope::styleSheetsForStyleSheetList): Deleted. (WebCore::Style::Scope::setPreferredStylesheetSetName): Deleted. (WebCore::Style::Scope::setSelectedStylesheetSetName): Deleted. * svg/SVGFontFaceElement.cpp: (WebCore::SVGFontFaceElement::rebuildFontFace): (WebCore::SVGFontFaceElement::removedFrom): * testing/Internals.cpp: (WebCore::Internals::resetToConsistentState): Ensure that cationsStyleSheetOverride really becomes empty. Some tests rely on not having suprise inserted stylesheets. Previously this was racy and the patch affected order of things. (WebCore::Internals::styleChangeType): * xml/XMLTreeViewer.cpp: (WebCore::XMLTreeViewer::transformDocumentToTreeView): * xml/parser/XMLDocumentParser.cpp: (WebCore::XMLDocumentParser::end): * xml/parser/XMLDocumentParserLibxml2.cpp: (WebCore::XMLDocumentParser::doEnd): Canonical link: https://commits.webkit.org/181549@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207669 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-21 13:36:45 +00:00
m_document.styleScope().didChangeStyleSheetEnvironment();
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): Canonical link: https://commits.webkit.org/167594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-23 15:04:16 +00:00
}
Style resolver should be updated lazily https://bugs.webkit.org/show_bug.cgi?id=163721 Reviewed by Andreas Kling. Currently when stylesheets change in some way we generally update style resolvers and invalidate style immediately. We should do this lazily to avoid unnecessary work. Also improve naming of the stylesheet invalidation functions and use more optimal functions in some places. * css/CSSComputedStyleDeclaration.cpp: (WebCore::updateStyleIfNeededForNode): * css/CSSStyleSheet.cpp: (WebCore::CSSStyleSheet::didMutateRules): (WebCore::CSSStyleSheet::didMutate): (WebCore::CSSStyleSheet::setDisabled): * css/StyleResolver.cpp: (WebCore::StyleResolver::StyleResolver): Initialize root style font with null font selector. This avoids hitting a CSSFontSelector assert in fast/media/mq-relative-constraints-08.html where media query evaluation requires font information before it is ready. Exposed by increased laziness in this patch. * dom/Document.cpp: (WebCore::Document::setContentLanguage): (WebCore::Document::updateLayoutIgnorePendingStylesheets): (WebCore::Document::isPageBoxVisible): (WebCore::Document::pageSizeAndMarginsInPixels): (WebCore::Document::processHttpEquiv): (WebCore::Document::setSelectedStylesheetSet): (WebCore::Document::didInsertInDocumentShadowRoot): (WebCore::Document::didRemoveInDocumentShadowRoot): * dom/Document.h: (WebCore::Document::inDocumentShadowRoots): Track all shadow roots in the document. This allows us to find and flush style scopes cheaply. * dom/Element.cpp: (WebCore::Element::computedStyle): * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::ExtensionStyleSheets): (WebCore::ExtensionStyleSheets::clearPageUserSheet): (WebCore::ExtensionStyleSheets::updatePageUserSheet): (WebCore::ExtensionStyleSheets::invalidateInjectedStyleSheetCache): (WebCore::ExtensionStyleSheets::addUserStyleSheet): (WebCore::ExtensionStyleSheets::addAuthorStyleSheetForTesting): (WebCore::ExtensionStyleSheets::addDisplayNoneSelector): (WebCore::ExtensionStyleSheets::maybeAddContentExtensionSheet): (WebCore::ExtensionStyleSheets::styleResolverChangedTimerFired): Deleted. Since updates are now done lazily we don't need a special timer for extension stylesheets. * dom/ExtensionStyleSheets.h: * dom/ProcessingInstruction.cpp: (WebCore::ProcessingInstruction::checkStyleSheet): (WebCore::ProcessingInstruction::sheetLoaded): (WebCore::ProcessingInstruction::removedFrom): * dom/ShadowRoot.cpp: (WebCore::ShadowRoot::ShadowRoot): (WebCore::ShadowRoot::insertedInto): (WebCore::ShadowRoot::removedFrom): (WebCore::ShadowRoot::styleScope): * dom/ShadowRoot.h: * html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::setDisabledState): (WebCore::HTMLLinkElement::parseAttribute): (WebCore::HTMLLinkElement::process): (WebCore::HTMLLinkElement::removePendingSheet): * html/HTMLStyleElement.cpp: (WebCore::HTMLStyleElement::parseAttribute): * inspector/InspectorCSSAgent.cpp: (WebCore::InspectorCSSAgent::createInspectorStyleSheetForDocument): (WebCore::InspectorCSSAgent::forcePseudoState): (WebCore::InspectorCSSAgent::resetPseudoStates): * inspector/InspectorPageAgent.cpp: (WebCore::InspectorPageAgent::setEmulatedMedia): * page/Frame.cpp: (WebCore::Frame::setPrinting): * page/FrameView.cpp: (WebCore::FrameView::layout): (WebCore::FrameView::setPagination): (WebCore::FrameView::setViewportSizeForCSSViewportUnits): * page/Page.cpp: (WebCore::Page::setViewMode): (WebCore::Page::setNeedsRecalcStyleInAllFrames): (WebCore::Page::invalidateInjectedStyleSheetCacheInAllFrames): * style/StyleScope.cpp: (WebCore::Style::Scope::setPreferredStylesheetSetName): (WebCore::Style::Scope::setSelectedStylesheetSetName): (WebCore::Style::Scope::removePendingSheet): (WebCore::Style::Scope::removeStyleSheetCandidateNode): (WebCore::Style::Scope::activeStyleSheetsForInspector): (WebCore::Style::Scope::flushPendingUpdate): Also flush descendant shadow roots. (WebCore::Style::Scope::scheduleUpdate): (WebCore::Style::Scope::didChangeActiveStyleSheetCandidates): Make lazy. (WebCore::Style::Scope::didChangeStyleSheetContents): Make lazy. (WebCore::Style::Scope::didChangeStyleSheetEnvironment): Environment changes also affect author shadow roots. (WebCore::Style::Scope::styleSheetsForStyleSheetList): (WebCore::Style::Scope::scheduleActiveSetUpdate): Deleted. (WebCore::Style::Scope::didChangeCandidatesForActiveSet): Deleted. (WebCore::Style::Scope::didChangeContentsOrInterpretation): Deleted. Improved naming of these and split didChangeContentsOrInterpretation into two separate functions. * style/StyleScope.h: (WebCore::Style::Scope::styleSheetsForStyleSheetList): Deleted. (WebCore::Style::Scope::setPreferredStylesheetSetName): Deleted. (WebCore::Style::Scope::setSelectedStylesheetSetName): Deleted. * svg/SVGFontFaceElement.cpp: (WebCore::SVGFontFaceElement::rebuildFontFace): (WebCore::SVGFontFaceElement::removedFrom): * testing/Internals.cpp: (WebCore::Internals::resetToConsistentState): Ensure that cationsStyleSheetOverride really becomes empty. Some tests rely on not having suprise inserted stylesheets. Previously this was racy and the patch affected order of things. (WebCore::Internals::styleChangeType): * xml/XMLTreeViewer.cpp: (WebCore::XMLTreeViewer::transformDocumentToTreeView): * xml/parser/XMLDocumentParser.cpp: (WebCore::XMLDocumentParser::end): * xml/parser/XMLDocumentParserLibxml2.cpp: (WebCore::XMLDocumentParser::doEnd): Canonical link: https://commits.webkit.org/181549@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207669 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-21 13:36:45 +00:00
#endif // ENABLE(CONTENT_EXTENSIONS)
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): Canonical link: https://commits.webkit.org/167594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-23 15:04:16 +00:00
Web Inspector: unable to edit or view the source of style sheets injected by safari app extensions https://bugs.webkit.org/show_bug.cgi?id=205900 <rdar://problem/57898773> Reviewed by Timothy Hatcher. Remove the restrictions around `CSS.StyleSheetOrigin.User` style sheets, thereby allowing Web Inspector to get the source information that is necessary to show the "resource" in the Sources Tab. Source/WebCore: * dom/ExtensionStyleSheets.h: * dom/ExtensionStyleSheets.cpp: (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache const): (WebCore::ExtensionStyleSheets::contentForInjectedStyleSheet const): Added. Save a copy of the string source of any injected style sheet and provide a way to get it for any given `CSSStyleSheet`. * style/StyleScope.cpp: (WebCore::Style::Scope::activeStyleSheetsForInspector): * style/InspectorCSSOMWrappers.cpp: (WebCore::Style::InspectorCSSOMWrappers::collectDocumentWrappers): Include all types of extension style sheets when collecting active rules and style sheets for Web Inspector to instrument. * inspector/InspectorStyleSheet.cpp: * inspector/InspectorStyleSheet.h: (WebCore::InspectorStyleSheet::buildObjectForRule): (WebCore::InspectorStyleSheet::originalStyleSheetText const): (WebCore::InspectorStyleSheet::resourceStyleSheetText const): (WebCore::InspectorStyleSheet::inlineStyleSheetText const): (WebCore::InspectorStyleSheet::extensionStyleSheetText const): Added. Source/WebInspectorUI: * UserInterface/Models/CSSStyleSheet.js: (WI.CSSStyleSheet.prototype.get displayName): (WI.CSSStyleSheet.prototype.get injected): Added. (WI.CSSStyleSheet.prototype.get anonymous): Added. * UserInterface/Models/DOMNodeStyles.js: (WI.DOMNodeStyles.prototype._parseRulePayload): * UserInterface/Models/CSSRule.js: (WI.CSSRule): (WI.CSSRule.prototype.get editable): (WI.CSSRule.prototype._selectorResolved): Attempt to create a source code location for any style sheet with a source range, not just for the Inspector Style Sheet. * UserInterface/Views/CSSStyleSheetTreeElement.js: (WI.CSSStyleSheetTreeElement): Instead of hardcoding "Inspector Style Sheet", use the associated `WI.CSSStyleSheet`'s info. * UserInterface/Views/FrameTreeElement.js: (WI.FrameTreeElement): (WI.FrameTreeElement.prototype.onattach): (WI.FrameTreeElement.prototype.ondetach): (WI.FrameTreeElement.prototype._styleSheetAdded): (WI.FrameTreeElement.prototype._styleSheetRemoved): Added. Ensure that only non-injected non-anonymous style sheets are shown under frames. * UserInterface/Views/SourcesNavigationSidebarPanel.js: (WI.SourcesNavigationSidebarPanel): (WI.SourcesNavigationSidebarPanel.prototype._compareTreeElements): (WI.SourcesNavigationSidebarPanel.prototype._addResource): (WI.SourcesNavigationSidebarPanel.prototype._addStyleSheet): Added. (WI.SourcesNavigationSidebarPanel.prototype._handleResourceGroupingModeChanged): (WI.SourcesNavigationSidebarPanel.prototype._handleCSSStyleSheetAdded): Added. (WI.SourcesNavigationSidebarPanel.prototype._handleCSSStyleSheetRemoved): Added. Add "Extension Style Sheets", "Extra Style Sheets", and "Anonymous Style Sheets" folders, just like for scripts, with a similar logic as to when style sheets are added to each. * UserInterface/Views/OpenResourceDialog.js: (WI.OpenResourceDialog): (WI.OpenResourceDialog.prototype.representedObjectIsValid): Added. (WI.OpenResourceDialog.prototype._populateResourceTreeOutline): (WI.OpenResourceDialog.prototype._populateResourceTreeOutline.createTreeElement): (WI.OpenResourceDialog.prototype.didDismissDialog): (WI.OpenResourceDialog.prototype.didPresentDialog): (WI.OpenResourceDialog.prototype._removeResource): Added. (WI.OpenResourceDialog.prototype._resourceWasRemoved): Added. (WI.OpenResourceDialog.prototype._scriptAdded): (WI.OpenResourceDialog.prototype._scriptRemoved): Added. (WI.OpenResourceDialog.prototype._handleStyleSheetAdded): Added. (WI.OpenResourceDialog.prototype._handleStyleSheetRemoved): Added. Add any non-injected non-anonymous style sheets when populating the list of resources. Drive-by: remove listings for any resources that are removed from the inspected page. * UserInterface/Views/ResourceTreeElement.js: (WI.ResourceTreeElement.compareResourceTreeElements): (WI.ResourceTreeElement.compareResourceTreeElements.resolvedType): Added. Support comparisons against non-resource tree elements. * Localizations/en.lproj/localizedStrings.js: Canonical link: https://commits.webkit.org/219045@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254186 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-08 05:02:02 +00:00
String ExtensionStyleSheets::contentForInjectedStyleSheet(const RefPtr<CSSStyleSheet>& styleSheet) const
{
return m_injectedStyleSheetToSource.get(styleSheet);
}
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): Canonical link: https://commits.webkit.org/167594@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190169 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-23 15:04:16 +00:00
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();
}
}