Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement focus fixup rule
https://bugs.webkit.org/show_bug.cgi?id=237273

Reviewed by Tim Nguyen.

Implement step 15 of update the rendering between 14. servicing resize observers and 16. updating intersection observations:
whatwg/html#8392

* LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/layout-dependent-focus-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-display-none-001-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-within-display-none-001-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/inert/dynamic-inert-on-focused-element-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-shadowhost-display-none-expected.txt:
* Source/WebCore/page/Page.cpp:
(WebCore::Page::updateRendering):
(WebCore::operator<<):
* Source/WebCore/page/Page.h:

Canonical link: https://commits.webkit.org/260067@main
  • Loading branch information
rniwa committed Feb 9, 2023
1 parent 2fbadf6 commit 71bc534
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 27 deletions.
@@ -1,3 +1,3 @@

FAIL Verify that onblur is called on hidden input assert_unreached: Event listener for 'blur' not called Reached unreachable code
PASS Verify that onblur is called on hidden input

@@ -1,5 +1,5 @@


FAIL Test ':focus' after 'display:none' on input assert_false: Check input doesn't match ':focus' after getting 'display: none' expected false got true
FAIL Test ':focus' after 'display:none' on input's parent assert_false: Check input doesn't match ':focus' after parent got 'display: none' expected false got true
PASS Test ':focus' after 'display:none' on input
PASS Test ':focus' after 'display:none' on input's parent

@@ -1,5 +1,5 @@


FAIL Test ':focus-within' after 'display:none' on input assert_false: Check input doesn't match ':focus-within' after getting 'display: none' expected false got true
FAIL Test ':focus-within' after 'display:none' on input's parent assert_false: Check input doesn't match ':focus-within' after parent got 'display: none' expected false got true
PASS Test ':focus-within' after 'display:none' on input
PASS Test ':focus-within' after 'display:none' on input's parent

@@ -1,22 +1,10 @@

FAIL <input> that gets 'inert' attribute assert_equals: The element stops being focused expected Element node <body><div id="log"></div>

<div class="test-wrapper" dat... but got Element node <input class="becomes-inert check-focus" inert=""></input>
FAIL <input> whose parent gets 'inert' attribute assert_equals: The element stops being focused expected Element node <body><div id="log"></div>

<div class="test-wrapper" dat... but got Element node <input class="check-focus"></input>
FAIL <button> that gets 'inert' attribute assert_equals: The element stops being focused expected Element node <body><div id="log"></div>

<div class="test-wrapper" dat... but got Element node <button class="becomes-inert check-focus" inert="">foo</b...
FAIL <div> that gets 'inert' attribute assert_equals: The element stops being focused expected Element node <body><div id="log"></div>

<div class="test-wrapper" dat... but got Element node <div class="becomes-inert check-focus" tabindex="-1" iner...
FAIL <div> whose parent gets 'inert' attribute assert_equals: The element stops being focused expected Element node <body><div id="log"></div>

<div class="test-wrapper" dat... but got Element node <div class="check-focus" tabindex="-1">bar</div>
FAIL <div> whose grandparent gets 'inert' attribute assert_equals: The element stops being focused expected Element node <body><div id="log"></div>

<div class="test-wrapper" dat... but got Element node <span class="check-focus" tabindex="-1">baz</span>
PASS <input> that gets 'inert' attribute
PASS <input> whose parent gets 'inert' attribute
PASS <button> that gets 'inert' attribute
PASS <div> that gets 'inert' attribute
PASS <div> whose parent gets 'inert' attribute
PASS <div> whose grandparent gets 'inert' attribute


foo
Expand Down
@@ -1,6 +1,4 @@

Harness Error (TIMEOUT), message = null

TIMEOUT when shadow host itself is focused, it should match display:none, lose focus then becomes display:block again. Test timed out
NOTRUN when shadow host with delegatesFocus=true has focused element inside the shadow, it should also match display:none, then lose focus and become display:block again.
PASS when shadow host itself is focused, it should match display:none, lose focus then becomes display:block again.
PASS when shadow host with delegatesFocus=true has focused element inside the shadow, it should also match display:none, then lose focus and become display:block again.

8 changes: 8 additions & 0 deletions Source/WebCore/page/Page.cpp
Expand Up @@ -1734,6 +1734,13 @@ void Page::updateRendering()
document.updateResizeObservations(*this);
});

runProcessingStep(RenderingUpdateStep::FocusFixup, [&] (Document& document) {
if (RefPtr focusedElement = document.focusedElement()) {
if (!focusedElement->isFocusable())
document.setFocusedElement(nullptr);
}
});

runProcessingStep(RenderingUpdateStep::IntersectionObservations, [] (Document& document) {
document.updateIntersectionObservations();
});
Expand Down Expand Up @@ -3956,6 +3963,7 @@ WTF::TextStream& operator<<(WTF::TextStream& ts, RenderingUpdateStep step)
case RenderingUpdateStep::VideoFrameCallbacks: ts << "VideoFrameCallbacks"; break;
case RenderingUpdateStep::PrepareCanvasesForDisplay: ts << "PrepareCanvasesForDisplay"; break;
case RenderingUpdateStep::CaretAnimation: ts << "CaretAnimation"; break;
case RenderingUpdateStep::FocusFixup: ts << "FocusFixup"; break;
}
return ts;
}
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/page/Page.h
Expand Up @@ -236,6 +236,7 @@ enum class RenderingUpdateStep : uint32_t {
VideoFrameCallbacks = 1 << 15,
PrepareCanvasesForDisplay = 1 << 16,
CaretAnimation = 1 << 17,
FocusFixup = 1 << 18,
};

enum LookalikeCharacterSanitizationTrigger : uint8_t {
Expand Down

0 comments on commit 71bc534

Please sign in to comment.