Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: ab72fddbb6e18544ccccd8cfbd38e1e44ef4b5c6
https://github.com/WebKit/WebKit/commit/ab72fddbb6e18544ccccd8cfbd38e1e44ef4b5c6
Author: Kiet Ho <[email protected]>
Date: 2026-10-13 (Tue, 13 Oct 2026)
Changed paths:
M Source/WebCore/editing/Editor.cpp
M Source/WebCore/editing/FrameSelection.cpp
M Source/WebCore/editing/ReplaceSelectionCommand.cpp
M Source/WebCore/editing/cocoa/EditingHTMLConverter.mm
M Source/WebCore/html/HTMLSelectElement.cpp
M Source/WebCore/html/SearchInputType.cpp
M Source/WebCore/html/shadow/DateTimeFieldElement.cpp
M Source/WebCore/page/FrameSnapshotting.cpp
M Source/WebCore/page/LocalFrameView.cpp
M Source/WebCore/rendering/BackgroundPainter.cpp
M Source/WebCore/rendering/InlineBoxPainter.cpp
M Source/WebCore/rendering/RenderBox.cpp
M Source/WebCore/rendering/RenderElement.cpp
M Source/WebCore/rendering/RenderLayerBacking.cpp
M Source/WebCore/rendering/RenderLayerCompositor.cpp
M Source/WebCore/rendering/RenderListBox.cpp
M Source/WebCore/rendering/RenderMenuList.cpp
M Source/WebCore/rendering/RenderReplaced.cpp
M Source/WebCore/rendering/RenderTableCell.cpp
M Source/WebCore/rendering/RenderTreeAsText.cpp
M Source/WebCore/rendering/StyledMarkedText.cpp
M Source/WebCore/rendering/TextPaintStyle.cpp
M Source/WebCore/rendering/cocoa/RenderThemeCocoa.mm
M Source/WebCore/rendering/ios/RenderThemeIOS.mm
M Source/WebCore/style/StyleChangedAnimatableProperties.cpp
M Source/WebCore/style/StyleColorResolver.h
M Source/WebCore/style/StyleDifference.cpp
M Source/WebCore/style/computed/StyleComputedStyle+GettersInlines.h
M Source/WebCore/style/computed/StyleComputedStyle.cpp
M Source/WebCore/style/computed/StyleComputedStyle.h
M Source/WebCore/style/computed/StyleComputedStyleBase+SettersInlines.h
M Source/WebCore/style/computed/StyleComputedStyleBase.h
M Source/WebCore/style/computed/data/StyleBackgroundData.cpp
M Source/WebCore/style/computed/data/StyleNonInheritedRareData.cpp
M Source/WebCore/style/computed/data/StyleNonInheritedRareData.h
M Source/WebCore/testing/Internals.cpp
M Source/WebCore/testing/Internals.h
M Source/WebCore/testing/Internals.idl
M Source/WebKitLegacy/mac/WebView/WebFrame.mm
Log Message:
-----------
Allow overriding background color in ComputedStyle
rdar://188884144
https://bugs.webkit.org/show_bug.cgi?id=325909
Reviewed by Simon Fraser.
This patch adds the ability to override the existing background color in
ComputedStyle. This allows the used background color (for rendering) to be
different from the original background color.
How it works:
- The overriden background color is stored in NonInheritedRareData
and can be set/clear using ComputedStyleBase::setOverridenBackgroundColor
- In rendering code, use ComputedStyle::usedBackgroundColor to get the
background color for rendering. This will return the overriden color if set,
otherwise it returns the original color.
- ComputedStyle also provides a number of methods to get the resolved
used background color (e.g usedBackgroundColorResolvingCurrentColor,
visitedDependentUsedBackgroundColor).
- Rendering code that uses the background color are switched to
usedBackgroundColor. Any other places (like style and animation)
uses the original background color.
- In layout tests, window.internals.usedBackgroundColor can be used to
test the used background color.
Note that this does not allow overriding the _visited_ background color.
Tested by existing test suite.
* Source/WebCore/editing/Editor.cpp:
(WebCore::Editor::fontAttributesAtSelectionStart):
* Source/WebCore/editing/FrameSelection.cpp:
(WebCore::CaretBase::computeCaretColor):
* Source/WebCore/editing/ReplaceSelectionCommand.cpp:
(WebCore::collectStylesToRemove):
* Source/WebCore/editing/cocoa/EditingHTMLConverter.mm:
(WebCore::updateAttributes):
* Source/WebCore/html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::menuListDefaultEventHandler):
* Source/WebCore/html/SearchInputType.cpp:
(WebCore::SearchInputType::menuStyle const):
* Source/WebCore/html/shadow/DateTimeFieldElement.cpp:
(WebCore::DateTimeFieldElement::resolveCustomStyle):
* Source/WebCore/page/FrameSnapshotting.cpp:
(WebCore::estimatedBackgroundColorForRange):
* Source/WebCore/page/LocalFrameView.cpp:
(WebCore::LocalFrameView::fixedContainerEdges const):
(WebCore::LocalFrameView::documentBackgroundColor const):
* Source/WebCore/rendering/BackgroundPainter.cpp:
(WebCore::BackgroundPainter::paintBackground const):
(WebCore::BackgroundPainter::paintRootBoxFillLayers const):
(WebCore::BackgroundPainter::paintBoxShadow const):
(WebCore::BackgroundPainter::boxShadowShouldBeAppliedToBackground):
* Source/WebCore/rendering/InlineBoxPainter.cpp:
(WebCore::InlineBoxPainter::paintDecorations):
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::getBackgroundPaintedExtent const):
(WebCore::RenderBox::backgroundIsKnownToBeOpaqueInRect const):
(WebCore::RenderBox::backgroundHasOpaqueTopLayer const):
* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::selectionBackgroundColor const):
* Source/WebCore/rendering/RenderLayerBacking.cpp:
(WebCore::canDirectlyCompositeBackgroundBackgroundImage):
(WebCore::RenderLayerBacking::rendererBackgroundColor const):
* Source/WebCore/rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::rootOrBodyStyleChanged):
* Source/WebCore/rendering/RenderListBox.cpp:
(WebCore::RenderListBox::paintItemBackground):
* Source/WebCore/rendering/RenderMenuList.cpp:
(WebCore::RenderMenuList::getItemBackgroundColor const):
* Source/WebCore/rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::calculateHighlightColor const):
* Source/WebCore/rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::paintBackgroundsBehindCell):
* Source/WebCore/rendering/RenderTreeAsText.cpp:
(WebCore::RenderTreeAsText::writeRenderObject):
* Source/WebCore/rendering/StyledMarkedText.cpp:
(WebCore::computeStyleForPseudoElementStyle):
* Source/WebCore/rendering/TextPaintStyle.cpp:
(WebCore::adjustColorForPunchedOutBackground):
* Source/WebCore/rendering/cocoa/RenderThemeCocoa.mm:
(WebCore::RenderThemeCocoa::paintFileUploadIconDecorations):
(WebCore::paintTextAreaOrTextField):
* Source/WebCore/rendering/ios/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::isControlStyled const):
(WebCore::RenderThemeIOS::adjustButtonLikeControlStyle const):
* Source/WebCore/style/StyleChangedAnimatableProperties.cpp:
(WebCore::Style::conservativelyCollectChangedAnimatableProperties):
* Source/WebCore/style/StyleColorResolver.h:
* Source/WebCore/style/StyleDifference.cpp:
* Source/WebCore/style/computed/StyleComputedStyle+GettersInlines.h:
(WebCore::Style::ComputedStyle::hasBackground const):
* Source/WebCore/style/computed/StyleComputedStyle.cpp:
(WebCore::Style::ComputedStyle::borderAndBackgroundEqual const):
(WebCore::Style::ComputedStyle::usedBackgroundColor const):
(WebCore::Style::ComputedStyle::usedBackgroundColorResolvingCurrentColor const):
(WebCore::Style::ComputedStyle::usedBackgroundColorResolvingCurrentColorApplyingColorFilter
const):
(WebCore::Style::ComputedStyle::visitedDependentUsedBackgroundColor const):
(WebCore::Style::ComputedStyle::visitedDependentUsedBackgroundColorApplyingColorFilter
const):
* Source/WebCore/style/computed/StyleComputedStyle.h:
* Source/WebCore/style/computed/StyleComputedStyleBase+SettersInlines.h:
(WebCore::Style::ComputedStyleBase::setOverrideBackgroundColor):
* Source/WebCore/style/computed/StyleComputedStyleBase.h:
* Source/WebCore/style/computed/data/StyleBackgroundData.cpp:
(WebCore::Style::BackgroundData::containsCurrentColor const):
(WebCore::Style::BackgroundData::backgroundContainsCurrentColor const):
* Source/WebCore/style/computed/data/StyleNonInheritedRareData.cpp:
(WebCore::Style::NonInheritedRareData::NonInheritedRareData):
(WebCore::Style::NonInheritedRareData::operator== const):
(WebCore::Style::NonInheritedRareData::dumpDifferences const):
* Source/WebCore/style/computed/data/StyleNonInheritedRareData.h:
* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::usedBackgroundColor):
* Source/WebCore/testing/Internals.h:
* Source/WebCore/testing/Internals.idl:
* Source/WebKitLegacy/mac/WebView/WebFrame.mm:
(-[WebFrame _bodyBackgroundColor]):
Canonical link: https://commits.webkit.org/323548@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications