Repository navigation
:focus-within pseudo class doesn't get invalidated when frame loses focus - #2259
Conversation
darinadler
left a comment
There was a problem hiding this comment.
I think this is excellent and correct now; of course, @anttijk should still look it over, since he’s the one who spotted it was wrong last time.
There was a problem hiding this comment.
Should we make a function that’s shared for this expression? I know this is not a lot of code, but I think it would be nice to have a named function to emphasize that it’s the same all three times.
|
Have to figure out what’s causing the test failures. |
There was a problem hiding this comment.
Oops, I need to update the flags even when focused element is nullptr here.
|
Sigh... EWS test failures are nothing to do with this patch. Not sure why it thinks this patch caused it. |
…ocus https://bugs.webkit.org/show_bug.cgi?id=242526 Reviewed by Antti Koivisto and Darin Adler. This patch fixes the bug that :focus-within pseudo fails to start applying or stop applying upon frame gaining or losing focus, and makes pseudo class invalidation more precise. A new boolean flag FrameSelection::m_isActive, which mirrors the value of FocusController::isActive() while the frame associated with FrameSelection is focused, is introduced and used in FrameSelection's isFocusedAndActive on behalf of FocusController::isActive(). It's used to compute the value of :focus, :focus-visible, :focus-within and pseudo classes. Most notably, FrameSelection::pageActivationChanged and FrameSelection::setFocused use it to flip the flag with Style::PseudoClassChangeInvalidation. Note that the value of FrameSelection::m_isActive could be stale when the frame associated with FrameSelection is no longer focused. This isn't an issue in practice since it means isFocusedAndActive would always return false in such cases (since m_focused check fails). * LayoutTests/fast/shadow-dom/focus-ring-on-shadow-host-focuswithin-expected.html: Added. * LayoutTests/fast/shadow-dom/focus-ring-on-shadow-host-focuswithin.html: Added. * LayoutTests/fast/shadow-dom/focus-ring-on-shadow-host-sibling-expected.html: Added. * LayoutTests/fast/shadow-dom/focus-ring-on-shadow-host-sibling.html: Added. * LayoutTests/platform/gtk/TestExpectations: * LayoutTests/platform/win/TestExpectations: * Source/WebCore/css/SelectorChecker.cpp: (WebCore::SelectorChecker::checkOne const): Fixed a bug that this was checking hasFocusWithin without isFrameFocused. * Source/WebCore/editing/FrameSelection.cpp: (WebCore::isPageActive): Added. (WebCore::FrameSelection::FrameSelection): Initialize newly introduced m_isActive. (WebCore::FrameSelection::focusedOrActiveStateChanged): Moved the logic to invalidate elements to callers of this function: FrameSelection::pageActivationChanged and FrameSelection::setFocused. (WebCore::invalidateFocusedElementAndShadowIncludingAncestors): Added. (WebCore::FrameSelection::pageActivationChanged): (WebCore::FrameSelection::setFocused): (WebCore::FrameSelection::isFocusedAndActive const): * Source/WebCore/editing/FrameSelection.h: Canonical link: https://commits.webkit.org/252324@main
|
Committed 252324@main (ac8282f): https://commits.webkit.org/252324@main Reviewed commits have been landed. Closing PR #2259 and removing active labels. |
Conflicts: Source/WebCore/loader/FrameLoader.cpp Source/WebCore/page/LocalFrame.cpp Source/WebCore/page/LocalFrame.h Source/WebKit/SourcesGTK.txt Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp Source/WebKit/UIProcess/Inspector/WebPageInspectorController.cpp Source/WebKit/UIProcess/Inspector/WebPageInspectorController.h Source/WebKit/UIProcess/WebFrameProxy.cpp Source/WebKit/UIProcess/WebPageProxy.cpp Source/WebKit/UIProcess/cairo/BackingStoreCairo.cpp Source/WebKit/UIProcess/mac/PageClientImplMac.mm Source/WebKit/WebKit.xcodeproj/project.pbxproj
Conflicts: Source/WebCore/loader/FrameLoader.cpp Source/WebCore/page/LocalFrame.cpp Source/WebCore/page/LocalFrame.h Source/WebKit/SourcesGTK.txt Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp Source/WebKit/UIProcess/Inspector/WebPageInspectorController.cpp Source/WebKit/UIProcess/Inspector/WebPageInspectorController.h Source/WebKit/UIProcess/WebFrameProxy.cpp Source/WebKit/UIProcess/WebPageProxy.cpp Source/WebKit/UIProcess/cairo/BackingStoreCairo.cpp Source/WebKit/UIProcess/mac/PageClientImplMac.mm Source/WebKit/WebKit.xcodeproj/project.pbxproj
ac8282f