Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 30bf5b4225da3bad951b7998771245472a486218
https://github.com/WebKit/WebKit/commit/30bf5b4225da3bad951b7998771245472a486218
Author: Antti Koivisto <[email protected]>
Date: 2026-06-08 (Mon, 08 Jun 2026)
Changed paths:
M Source/WebCore/Headers.cmake
M Source/WebCore/SaferCPPExpectations/UncheckedCallArgsCheckerExpectations
M Source/WebCore/SaferCPPExpectations/UncheckedLocalVarsCheckerExpectations
M Source/WebCore/SaferCPPExpectations/UncountedCallArgsCheckerExpectations
M Source/WebCore/SaferCPPExpectations/UncountedLocalVarsCheckerExpectations
M Source/WebCore/Scripts/generate-unified-sources.sh
M Source/WebCore/Sources.txt
M Source/WebCore/UnifiedSources-output.xcfilelist
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
M Source/WebCore/css/CSSPositionTryDescriptors.cpp
M Source/WebCore/css/CSSStyleSheet.cpp
M Source/WebCore/css/DOMCSSRegisterCustomProperty.cpp
M Source/WebCore/css/StyleSheetList.cpp
M Source/WebCore/dom/Document.cpp
M Source/WebCore/dom/Document.h
M Source/WebCore/dom/Element.cpp
M Source/WebCore/dom/ExtensionStyleSheets.cpp
M Source/WebCore/dom/ProcessingInstruction.cpp
M Source/WebCore/dom/ScriptableDocumentParser.cpp
M Source/WebCore/dom/ViewTransition.cpp
M Source/WebCore/inspector/agents/InspectorCSSAgent.cpp
M Source/WebCore/page/LocalDOMWindow.cpp
M Source/WebCore/page/LocalFrame.cpp
M Source/WebCore/page/LocalFrameView.cpp
M Source/WebCore/page/LocalFrameViewLayoutContext.cpp
M Source/WebCore/page/MemoryRelease.cpp
M Source/WebCore/page/Page.cpp
M Source/WebCore/page/PrintContext.cpp
M Source/WebCore/rendering/RenderView.cpp
M Source/WebCore/style/AnchorPositionEvaluator.cpp
M Source/WebCore/style/RuleSetBuilder.cpp
M Source/WebCore/style/StyleCustomPropertyRegistry.cpp
M Source/WebCore/style/StyleCustomPropertyRegistry.h
A Source/WebCore/style/StyleDocumentScope.cpp
A Source/WebCore/style/StyleDocumentScope.h
M Source/WebCore/style/StyleExtractor.cpp
M Source/WebCore/style/StyleScope.cpp
M Source/WebCore/style/StyleScope.h
M Source/WebCore/style/StyleScopeRuleSets.cpp
M Source/WebCore/style/StyleTreeResolver.cpp
M Source/WebCore/svg/SVGFontFaceElement.cpp
M Source/WebCore/testing/Internals.cpp
M Source/WebCore/xml/parser/XMLDocumentParser.cpp
M Source/WebKitLegacy/mac/WebView/WebHTMLView.mm
Log Message:
-----------
Split Style::DocumentScope out of Style::Scope
https://bugs.webkit.org/show_bug.cgi?id=316527
rdar://178989814
Reviewed by Alan Baradlay.
Style::Scope is used both for the document tree scope and for each shadow
tree scope, but much of its state and logic only ever applies to the
document scope. Add Style::DocumentScope, a subclass of Scope in its own
StyleDocumentScope.h / StyleDocumentScope.cpp, that owns the document-level
state so shadow tree scopes no longer carry or expose it.
The base Scope keeps the per-tree-scope machinery: stylesheet collection,
pending updates, resolver creation and sharing, and the custom property and
counter style registries. DocumentScope holds the document-only members and
the methods that operate on them: the shared shadow tree resolver cache, the
dynamic view transitions style, the match result cache, anchor positioning
and layout dependency state, dynamic media query evaluation, and the
preferred stylesheet set name.
There is no virtual dispatch. Document::styleScope() returns DocumentScope&,
so every document-only call site already has the static type, while
ShadowRoot::styleScope() keeps returning Scope&. The few base methods that
still branch on scope kind (resolver(), scheduleUpdate()) use
dynamicDowncast<DocumentScope>, enabled by SPECIALIZE_TYPE_TRAITS whose
predicate is the absence of a shadow root. Base methods that need document
state (createOrFindSharedShadowTreeResolver,
unshareShadowTreeResolverBeforeMutation)
reach it through documentScope(); the two classes are mutual friends so this
needs no extra accessors.
This is intended to be free of behavior changes.
* Source/WebCore/Headers.cmake:
* Source/WebCore/Scripts/generate-unified-sources.sh:
* Source/WebCore/SaferCPPExpectations/UncheckedCallArgsCheckerExpectations:
* Source/WebCore/SaferCPPExpectations/UncheckedLocalVarsCheckerExpectations:
* Source/WebCore/SaferCPPExpectations/UncountedCallArgsCheckerExpectations:
* Source/WebCore/SaferCPPExpectations/UncountedLocalVarsCheckerExpectations:
* Source/WebCore/Sources.txt:
* Source/WebCore/UnifiedSources-output.xcfilelist:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/css/CSSPositionTryDescriptors.cpp:
(WebCore::CSSPositionTryDescriptors::setPropertyInternal):
* Source/WebCore/css/CSSStyleSheet.cpp:
* Source/WebCore/css/DOMCSSRegisterCustomProperty.cpp:
* Source/WebCore/css/StyleSheetList.cpp:
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::usesStyleBasedEditability const):
* Source/WebCore/dom/Document.h:
(WebCore::Document::styleScope):
(WebCore::Document::styleScope const):
* Source/WebCore/dom/Element.cpp:
* Source/WebCore/dom/ExtensionStyleSheets.cpp:
* Source/WebCore/dom/ProcessingInstruction.cpp:
* Source/WebCore/dom/ScriptableDocumentParser.cpp:
* Source/WebCore/dom/ViewTransition.cpp:
* Source/WebCore/inspector/agents/InspectorCSSAgent.cpp:
* Source/WebCore/page/LocalDOMWindow.cpp:
* Source/WebCore/page/LocalFrame.cpp:
* Source/WebCore/page/LocalFrameView.cpp:
* Source/WebCore/page/LocalFrameViewLayoutContext.cpp:
(WebCore::LocalFrameViewLayoutContext::layout):
(WebCore::LocalFrameViewLayoutContext::interleavedLayout):
* Source/WebCore/page/MemoryRelease.cpp:
* Source/WebCore/page/Page.cpp:
* Source/WebCore/page/PrintContext.cpp:
* Source/WebCore/rendering/RenderView.cpp:
* Source/WebCore/style/AnchorPositionEvaluator.cpp:
* Source/WebCore/style/RuleSetBuilder.cpp:
* Source/WebCore/style/StyleCustomPropertyRegistry.cpp:
(WebCore::Style::CustomPropertyRegistry::registerFromAPI):
* Source/WebCore/style/StyleCustomPropertyRegistry.h:
* Source/WebCore/style/StyleDocumentScope.cpp: Added.
(WebCore::Style::DocumentScope::DocumentScope):
(WebCore::Style::DocumentScope::createDocumentResolver):
(WebCore::Style::DocumentScope::clearViewTransitionStyles):
(WebCore::Style::DocumentScope::releaseMemory):
(WebCore::Style::DocumentScope::setPreferredStylesheetSetName):
(WebCore::Style::DocumentScope::mediaQueryViewportStateForDocument):
(WebCore::Style::DocumentScope::evaluateMediaQueriesForViewportChange):
(WebCore::Style::DocumentScope::evaluateMediaQueriesForAccessibilitySettingsChange):
(WebCore::Style::DocumentScope::evaluateMediaQueriesForAppearanceChange):
(WebCore::Style::DocumentScope::collectResolverScopes):
(WebCore::Style::DocumentScope::evaluateMediaQueries):
(WebCore::Style::DocumentScope::didChangeStyleSheetEnvironment):
(WebCore::Style::DocumentScope::didChangeExtensionStyleSheets):
(WebCore::Style::DocumentScope::invalidateForLayoutDependencies):
(WebCore::Style::DocumentScope::invalidateForContainerDependencies):
(WebCore::Style::DocumentScope::invalidateForAnchorDependencies):
(WebCore::Style::DocumentScope::invalidateForPositionTryFallbacks):
(WebCore::Style::DocumentScope::matchResultCache):
(WebCore::Style::DocumentScope::updateAnchorPositioningStateAfterStyleResolution):
(WebCore::Style::DocumentScope::lastSuccessfulPositionOptionIndexFor):
(WebCore::Style::DocumentScope::setLastSuccessfulPositionOptionIndexMap):
(WebCore::Style::DocumentScope::forgetLastSuccessfulPositionOptionIndex):
* Source/WebCore/style/StyleDocumentScope.h: Added.
(isType):
* Source/WebCore/style/StyleExtractor.cpp:
* Source/WebCore/style/StyleScope.cpp:
(WebCore::Style::Scope::resolver):
(WebCore::Style::Scope::createOrFindSharedShadowTreeResolver):
(WebCore::Style::Scope::unshareShadowTreeResolverBeforeMutation):
(WebCore::Style::Scope::releaseMemory):
(WebCore::Style::Scope::establishPreferredStylesheetSetName):
(WebCore::Style::Scope::collectActiveStyleSheets):
(WebCore::Style::Scope::scheduleUpdate):
(WebCore::Style::Scope::documentScope):
(WebCore::Style::Scope::createDocumentResolver): Deleted.
(WebCore::Style::Scope::clearViewTransitionStyles): Deleted.
(WebCore::Style::Scope::setPreferredStylesheetSetName): Deleted.
(WebCore::Style::Scope::mediaQueryViewportStateForDocument): Deleted.
(WebCore::Style::Scope::evaluateMediaQueriesForViewportChange): Deleted.
(WebCore::Style::Scope::evaluateMediaQueriesForAccessibilitySettingsChange):
Deleted.
(WebCore::Style::Scope::evaluateMediaQueriesForAppearanceChange): Deleted.
(WebCore::Style::Scope::collectResolverScopes): Deleted.
(WebCore::Style::Scope::evaluateMediaQueries): Deleted.
(WebCore::Style::Scope::didChangeStyleSheetEnvironment): Deleted.
(WebCore::Style::Scope::didChangeExtensionStyleSheets): Deleted.
(WebCore::Style::Scope::invalidateForLayoutDependencies): Deleted.
(WebCore::Style::Scope::invalidateForContainerDependencies): Deleted.
(WebCore::Style::Scope::invalidateForAnchorDependencies): Deleted.
(WebCore::Style::Scope::invalidateForPositionTryFallbacks): Deleted.
(WebCore::Style::Scope::matchResultCache): Deleted.
(WebCore::Style::Scope::updateAnchorPositioningStateAfterStyleResolution):
Deleted.
(WebCore::Style::Scope::lastSuccessfulPositionOptionIndexFor): Deleted.
(WebCore::Style::Scope::setLastSuccessfulPositionOptionIndexMap): Deleted.
(WebCore::Style::Scope::forgetLastSuccessfulPositionOptionIndex): Deleted.
* Source/WebCore/style/StyleScope.h:
* Source/WebCore/style/StyleScopeRuleSets.cpp:
* Source/WebCore/style/StyleTreeResolver.cpp:
* Source/WebCore/svg/SVGFontFaceElement.cpp:
* Source/WebCore/testing/Internals.cpp:
* Source/WebCore/xml/parser/XMLDocumentParser.cpp:
* Source/WebKitLegacy/mac/WebView/WebHTMLView.mm:
Canonical link: https://commits.webkit.org/314735@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications