[webkit-changes] [WebKit/WebKit] 780bd1: [Remote Inspection] Make it possible to target ::b...
Wenson Hsieh
noreply at github.com
Thu Mar 28 17:25:45 PDT 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 780bd128913de133fa2bcadf4fdd2127be890bcb
https://github.com/WebKit/WebKit/commit/780bd128913de133fa2bcadf4fdd2127be890bcb
Author: Wenson Hsieh <wenson_hsieh at apple.com>
Date: 2024-03-28 (Thu, 28 Mar 2024)
Changed paths:
A LayoutTests/fast/element-targeting/target-pseudo-elements-expected.html
A LayoutTests/fast/element-targeting/target-pseudo-elements.html
M Source/WebCore/Headers.cmake
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
M Source/WebCore/dom/Element.cpp
M Source/WebCore/dom/Element.h
M Source/WebCore/dom/ElementRareData.cpp
M Source/WebCore/dom/ElementRareData.h
A Source/WebCore/dom/VisibilityAdjustment.h
M Source/WebCore/page/ElementTargetingController.cpp
M Source/WebCore/page/ElementTargetingTypes.h
M Source/WebCore/style/StyleAdjuster.cpp
M Source/WebCore/style/StyleAdjuster.h
M Source/WebCore/style/StyleResolver.cpp
M Source/WebCore/style/StyleTreeResolver.cpp
M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
M Source/WebKit/UIProcess/API/APITargetedElementInfo.h
M Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfo.h
M Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfo.mm
Log Message:
-----------
[Remote Inspection] Make it possible to target ::before/::after pseudo elements
https://bugs.webkit.org/show_bug.cgi?id=271791
Reviewed by Megan Gardner.
(...and also incorporates suggestions from Antti).
Add support for targeting `::before` and `::after` pseudo elements, for visibility adjustment. See
below for more details.
* LayoutTests/fast/element-targeting/target-pseudo-elements-expected.html: Added.
* LayoutTests/fast/element-targeting/target-pseudo-elements.html: Added.
Add a new layout test to exercise the change (targeting both `after` and `before` pseudo elements).
* Source/WebCore/Headers.cmake:
Add a new WebCore header that just contains the new `VisibilityAdjustment` enum values.
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::visibilityAdjustment const):
(WebCore::Element::addVisibilityAdjustment):
(WebCore::Element::isVisibilityAdjustmentRoot const): Deleted.
(WebCore::Element::setIsVisibilityAdjustmentRoot): Deleted.
Refactor this code — instead of having a single boolean flag that indicates whether the element is
a visibility adjustment root, turn it into an OptionSet with up to 3 bits (subtree, `::before`
pseudo element and `::after` pseudo element).
* Source/WebCore/dom/Element.h:
* Source/WebCore/dom/ElementRareData.cpp:
* Source/WebCore/dom/ElementRareData.h:
(WebCore::ElementRareData::visibilityAdjustment const):
(WebCore::ElementRareData::addVisibilityAdjustment):
(WebCore::ElementRareData::isVisibilityAdjustmentRoot const): Deleted.
(WebCore::ElementRareData::setIsVisibilityAdjustmentRoot): Deleted.
See above for more details — replace the single `isVisibilityAdjustmentRoot` flag with a new
`OptionSet`.
* Source/WebCore/dom/VisibilityAdjustment.h: Copied from Source/WebCore/page/ElementTargetingTypes.h.
* Source/WebCore/page/ElementTargetingController.cpp:
(WebCore::selectorsForTarget):
(WebCore::targetedElementInfo):
Teach this to emit `::before` and `::after` selectors for pseudo elements.
(WebCore::isTargetCandidate):
Teach this helper function to always consider rendered `::before` and `::after` pseudo elements to
be candidates for target selection, since adjusting visibility for these elements is unlikely to
adversely affect "main content" on the page.
(WebCore::elementToAdjust):
(WebCore::adjustmentToApply):
(WebCore::adjustVisibilityIfNeeded):
Split some of this functionality into multiple helper methods, to make it easier to determine how
an element should be marked for visibility adjustment. In particular, for before and after pseudo
elements, we mark the pseudo host element with `VisibilityAdjustment::{Before|After}Pseudo`, and for
everything else, we mark the element subtree (i.e. the same as what we currently do).
(WebCore::ElementTargetingController::adjustVisibility):
(WebCore::ElementTargetingController::adjustVisibilityInRepeatedlyTargetedRegions):
* Source/WebCore/page/ElementTargetingTypes.h:
* Source/WebCore/style/StyleAdjuster.cpp:
(WebCore::Style::Adjuster::adjust const):
(WebCore::Style::Adjuster::adjustVisibilityForPseudoElement):
Honor `VisibilityAdjustment::{BeforePseudo|AfterPseudo}` on the host element, by marking the
corresponding pseudo element style with visibility adjustment.
* Source/WebCore/style/StyleAdjuster.h:
* Source/WebCore/style/StyleResolver.cpp:
(WebCore::Style::Resolver::styleForPseudoElement):
* Source/WebCore/style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::resolveStartingStyle const):
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/UIProcess/API/APITargetedElementInfo.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfo.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfo.mm:
(-[_WKTargetedElementInfo isPseudoElement]):
Add a new SPI property to surface whether or not the targeted element is a pseudo-element to the
client.
Canonical link: https://commits.webkit.org/276816@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list