Changeset 272983 in webkit


Ignore:
Timestamp:
Feb 16, 2021 9:54:15 PM (17 months ago)
Author:
Manuel Rego Casasnovas
Message:

[selectors] :focus-visible parsing and experimental flag
https://bugs.webkit.org/show_bug.cgi?id=221895

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Update expectations as now :focus-visible is a valid selector.

  • web-platform-tests/css/selectors/focus-in-focus-event-001-expected.txt:
  • web-platform-tests/css/selectors/focus-in-focusin-event-001-expected.txt:
  • web-platform-tests/css/selectors/focus-visible-001-expected.txt:
  • web-platform-tests/css/selectors/focus-visible-002-expected.txt:
  • web-platform-tests/css/selectors/focus-visible-003-expected.txt:
  • web-platform-tests/css/selectors/focus-visible-004-expected.txt:
  • web-platform-tests/css/selectors/focus-visible-005-expected.txt:
  • web-platform-tests/css/selectors/focus-visible-006-expected.txt:
  • web-platform-tests/css/selectors/focus-visible-007-expected.txt:
  • web-platform-tests/css/selectors/focus-visible-009-expected.txt:
  • web-platform-tests/css/selectors/focus-visible-010-expected.txt:
  • web-platform-tests/css/selectors/focus-visible-012-expected.txt:
  • web-platform-tests/css/selectors/focus-visible-015-expected.txt:
  • web-platform-tests/css/selectors/focus-visible-016-expected.txt:
  • web-platform-tests/css/selectors/focus-visible-017-expected.txt:
  • web-platform-tests/css/selectors/focus-visible-018-expected.txt:
  • web-platform-tests/css/selectors/parsing/parse-focus-visible-expected.txt:

Source/WebCore:

Add parsing for :focus-visible pseudo class, it'll only be enabled if the experimental feature flag is enabled.

Test: imported/w3c/web-platform-tests/css/selectors/parsing/parse-focus-visible.html

  • css/CSSSelector.cpp:

(WebCore::CSSSelector::selectorText const):

  • css/CSSSelector.h:
  • css/SelectorChecker.cpp:

(WebCore::SelectorChecker::checkOne const):

  • css/SelectorCheckerTestFunctions.h:

(WebCore::matchesFocusVisiblePseudoClass):

  • css/SelectorPseudoClassAndCompatibilityElementMap.in:
  • css/parser/CSSParserContext.cpp:

(WebCore::CSSParserContext::CSSParserContext):
(WebCore::operator==):

  • css/parser/CSSParserContext.h:
  • css/parser/CSSSelectorParser.cpp:

(WebCore::isUserActionPseudoClass):
(WebCore::CSSSelectorParser::consumePseudo):

  • cssjit/SelectorCompiler.cpp:

(WebCore::SelectorCompiler::JSC_DEFINE_JIT_OPERATION):
(WebCore::SelectorCompiler::addPseudoClassType):

Source/WTF:

  • Scripts/Preferences/WebPreferencesExperimental.yaml: Add experimental feature flag.

LayoutTests:

  • platform/ios/TestExpectations: Skip test that timeouts in iOS platform.
  • platform/mac/imported/w3c/web-platform-tests/css/selectors/focus-visible-009-expected.txt:

Slightly different rebaseline due to default outline color on Mac.

Location:
trunk
Files:
1 added
32 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r272981 r272983  
     12021-02-16  Manuel Rego Casasnovas  <rego@igalia.com>
     2
     3        [selectors] :focus-visible parsing and experimental flag
     4        https://bugs.webkit.org/show_bug.cgi?id=221895
     5
     6        Reviewed by Darin Adler.
     7
     8        * platform/ios/TestExpectations: Skip test that timeouts in iOS platform.
     9        * platform/mac/imported/w3c/web-platform-tests/css/selectors/focus-visible-009-expected.txt:
     10        Slightly different rebaseline due to default outline color on Mac.
     11
    1122021-02-16  Jonathan Bedard  <JonWBedard@gmail.com>
    213
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r272911 r272983  
     12021-02-16  Manuel Rego Casasnovas  <rego@igalia.com>
     2
     3        [selectors] :focus-visible parsing and experimental flag
     4        https://bugs.webkit.org/show_bug.cgi?id=221895
     5
     6        Reviewed by Darin Adler.
     7
     8        Update expectations as now :focus-visible is a valid selector.
     9
     10        * web-platform-tests/css/selectors/focus-in-focus-event-001-expected.txt:
     11        * web-platform-tests/css/selectors/focus-in-focusin-event-001-expected.txt:
     12        * web-platform-tests/css/selectors/focus-visible-001-expected.txt:
     13        * web-platform-tests/css/selectors/focus-visible-002-expected.txt:
     14        * web-platform-tests/css/selectors/focus-visible-003-expected.txt:
     15        * web-platform-tests/css/selectors/focus-visible-004-expected.txt:
     16        * web-platform-tests/css/selectors/focus-visible-005-expected.txt:
     17        * web-platform-tests/css/selectors/focus-visible-006-expected.txt:
     18        * web-platform-tests/css/selectors/focus-visible-007-expected.txt:
     19        * web-platform-tests/css/selectors/focus-visible-009-expected.txt:
     20        * web-platform-tests/css/selectors/focus-visible-010-expected.txt:
     21        * web-platform-tests/css/selectors/focus-visible-012-expected.txt:
     22        * web-platform-tests/css/selectors/focus-visible-015-expected.txt:
     23        * web-platform-tests/css/selectors/focus-visible-016-expected.txt:
     24        * web-platform-tests/css/selectors/focus-visible-017-expected.txt:
     25        * web-platform-tests/css/selectors/focus-visible-018-expected.txt:
     26        * web-platform-tests/css/selectors/parsing/parse-focus-visible-expected.txt:
     27
    1282021-02-16  Youenn Fablet  <youenn@apple.com>
    229
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-in-focus-event-001-expected.txt

    r271395 r272983  
    22
    33PASS Checks that ':focus' pseudo-class matches inside 'focus' event handler
    4 FAIL Checks that ':focus-visible' pseudo-class matches inside 'focus' event handler assert_unreached: ':focus-visible'  is an invalid selector. SyntaxError: SyntaxError: The string did not match the expected pattern. Reached unreachable code
     4FAIL Checks that ':focus-visible' pseudo-class matches inside 'focus' event handler assert_unreached: ':focus-visible'  is an invalid selector. SyntaxError: Error: assert_equals: ':focus-visible' matches event.target expected null but got Element node <input type="text"></input> Reached unreachable code
    55PASS Checks that ':focus-within' pseudo-class matches inside 'focus' event handler
    66
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-in-focusin-event-001-expected.txt

    r271395 r272983  
    22
    33PASS Checks that ':focus' pseudo-class matches inside 'focusin' event handler
    4 FAIL Checks that ':focus-visible' pseudo-class matches inside 'focusin' event handler assert_unreached: ':focus-visible'  is an invalid selector. SyntaxError: SyntaxError: The string did not match the expected pattern. Reached unreachable code
     4FAIL Checks that ':focus-visible' pseudo-class matches inside 'focusin' event handler assert_unreached: ':focus-visible'  is an invalid selector. SyntaxError: Error: assert_equals: ':focus-visible' matches event.target expected null but got Element node <input type="text"></input> Reached unreachable code
    55PASS Checks that ':focus-within' pseudo-class matches inside 'focusin' event handler
    66
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-001-expected.txt

    r271395 r272983  
    66Focus me.
    77
    8 FAIL Keyboard focus should match :focus-visible assert_equals: outlineColor for DIV#el should be green expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
     8FAIL Keyboard focus should match :focus-visible assert_equals: outlineColor for DIV#el should be green expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
    99
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-002-expected.txt

    r272847 r272983  
    1919
    2020
    21 FAIL Focus element INPUT#input1 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input1 should be green expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
    22 FAIL Focus element INPUT#input2 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input2 should be green expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
    23 FAIL Focus element INPUT#input3 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input3 should be green expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
    24 FAIL Focus element INPUT#input4 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input4 should be green expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
    25 FAIL Focus element INPUT#input5 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input5 should be green expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
    26 FAIL Focus element INPUT#input6 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input6 should be green expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
    27 FAIL Focus element INPUT#input7 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input7 should be green expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
    28 FAIL Focus element INPUT#input8 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input8 should be green expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
    29 FAIL Focus element INPUT#input9 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input9 should be green expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
    30 FAIL Focus element INPUT#input10 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input10 should be green expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
    31 FAIL Focus element INPUT#input11 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input11 should be green expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
    32 FAIL Focus element INPUT#input12 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input12 should be green expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
    33 FAIL Focus element INPUT#input13 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input13 should be green expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
    34 FAIL Focus element TEXTAREA#input14 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for TEXTAREA#input14 should be green expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
     21FAIL Focus element INPUT#input1 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input1 should be green expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
     22FAIL Focus element INPUT#input2 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input2 should be green expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
     23FAIL Focus element INPUT#input3 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input3 should be green expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
     24FAIL Focus element INPUT#input4 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input4 should be green expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
     25FAIL Focus element INPUT#input5 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input5 should be green expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
     26FAIL Focus element INPUT#input6 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input6 should be green expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
     27FAIL Focus element INPUT#input7 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input7 should be green expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
     28FAIL Focus element INPUT#input8 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input8 should be green expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
     29FAIL Focus element INPUT#input9 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input9 should be green expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
     30FAIL Focus element INPUT#input10 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input10 should be green expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
     31FAIL Focus element INPUT#input11 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input11 should be green expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
     32FAIL Focus element INPUT#input12 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input12 should be green expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
     33FAIL Focus element INPUT#input13 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for INPUT#input13 should be green expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
     34FAIL Focus element TEXTAREA#input14 via mouse should match :focus-visible as it supports keyboard input assert_equals: outlineColor for TEXTAREA#input14 should be green expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
    3535
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-003-expected.txt

    r271395 r272983  
    1818 Focus me.
    1919
    20 FAIL Focus element SPAN#el-1 via mouse should NOT match :focus-visible as it does NOT support keyboard input assert_equals: backgroundColor for SPAN#el-1 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
    21 FAIL Focus element SPAN#el-2 via mouse should NOT match :focus-visible as it does NOT support keyboard input assert_equals: backgroundColor for SPAN#el-2 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
    22 FAIL Focus element SPAN#el-3 via mouse should NOT match :focus-visible as it does NOT support keyboard input assert_equals: backgroundColor for SPAN#el-3 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
    23 FAIL Focus element BUTTON#el-4 via mouse should NOT match :focus-visible as it does NOT support keyboard input assert_equals: backgroundColor for BUTTON#el-4 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
    24 FAIL Focus element INPUT#el-5 via mouse should NOT match :focus-visible as it does NOT support keyboard input assert_equals: backgroundColor for INPUT#el-5 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
    25 FAIL Focus element INPUT#el-6 via mouse should NOT match :focus-visible as it does NOT support keyboard input assert_equals: backgroundColor for INPUT#el-6 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
    26 FAIL Focus element INPUT#el-7 via mouse should NOT match :focus-visible as it does NOT support keyboard input assert_equals: backgroundColor for INPUT#el-7 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
    27 FAIL Focus element INPUT#el-8 via mouse should NOT match :focus-visible as it does NOT support keyboard input assert_equals: backgroundColor for INPUT#el-8 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
    28 FAIL Focus element INPUT#el-9 via mouse should NOT match :focus-visible as it does NOT support keyboard input assert_equals: backgroundColor for INPUT#el-9 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
    29 FAIL Focus element INPUT#el-10 via mouse should NOT match :focus-visible as it does NOT support keyboard input assert_equals: backgroundColor for INPUT#el-10 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
    30 FAIL Focus element INPUT#el-12 via mouse should NOT match :focus-visible as it does NOT support keyboard input assert_equals: backgroundColor for INPUT#el-12 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
    31 FAIL Focus element INPUT#el-13 via mouse should NOT match :focus-visible as it does NOT support keyboard input assert_equals: backgroundColor for INPUT#el-13 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
     20PASS Focus element SPAN#el-1 via mouse should NOT match :focus-visible as it does NOT support keyboard input
     21PASS Focus element SPAN#el-2 via mouse should NOT match :focus-visible as it does NOT support keyboard input
     22PASS Focus element SPAN#el-3 via mouse should NOT match :focus-visible as it does NOT support keyboard input
     23PASS Focus element BUTTON#el-4 via mouse should NOT match :focus-visible as it does NOT support keyboard input
     24PASS Focus element INPUT#el-5 via mouse should NOT match :focus-visible as it does NOT support keyboard input
     25PASS Focus element INPUT#el-6 via mouse should NOT match :focus-visible as it does NOT support keyboard input
     26PASS Focus element INPUT#el-7 via mouse should NOT match :focus-visible as it does NOT support keyboard input
     27PASS Focus element INPUT#el-8 via mouse should NOT match :focus-visible as it does NOT support keyboard input
     28PASS Focus element INPUT#el-9 via mouse should NOT match :focus-visible as it does NOT support keyboard input
     29PASS Focus element INPUT#el-10 via mouse should NOT match :focus-visible as it does NOT support keyboard input
     30PASS Focus element INPUT#el-12 via mouse should NOT match :focus-visible as it does NOT support keyboard input
     31PASS Focus element INPUT#el-13 via mouse should NOT match :focus-visible as it does NOT support keyboard input
    3232
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-004-expected.txt

    r271395 r272983  
    1616 Focus me.
    1717
    18 FAIL Focus element SPAN#el-1 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none" assert_equals: backgroundColor for SPAN#el-1 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
    19 FAIL Focus element SPAN#el-2 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none" assert_equals: backgroundColor for SPAN#el-2 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
    20 FAIL Focus element SPAN#el-3 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none" assert_equals: backgroundColor for SPAN#el-3 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
    21 FAIL Focus element BUTTON#el-4 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none" assert_equals: backgroundColor for BUTTON#el-4 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
    22 FAIL Focus element INPUT#el-5 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none" assert_equals: backgroundColor for INPUT#el-5 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
    23 FAIL Focus element INPUT#el-6 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none" assert_equals: backgroundColor for INPUT#el-6 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
    24 FAIL Focus element INPUT#el-7 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none" assert_equals: backgroundColor for INPUT#el-7 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
    25 FAIL Focus element INPUT#el-8 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none" assert_equals: backgroundColor for INPUT#el-8 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
    26 FAIL Focus element INPUT#el-10 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none" assert_equals: backgroundColor for INPUT#el-10 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
    27 FAIL Focus element INPUT#el-11 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none" assert_equals: backgroundColor for INPUT#el-11 should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
     18PASS Focus element SPAN#el-1 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"
     19PASS Focus element SPAN#el-2 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"
     20PASS Focus element SPAN#el-3 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"
     21PASS Focus element BUTTON#el-4 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"
     22PASS Focus element INPUT#el-5 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"
     23PASS Focus element INPUT#el-6 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"
     24PASS Focus element INPUT#el-7 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"
     25PASS Focus element INPUT#el-8 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"
     26PASS Focus element INPUT#el-10 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"
     27PASS Focus element INPUT#el-11 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"
    2828
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-005-expected.txt

    r271395 r272983  
    77I will be focused programmatically.
    88
    9 FAIL Programmatic focus after click should not match :focus-visible assert_equals: backgroundColor for DIV#el should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
     9PASS Programmatic focus after click should not match :focus-visible
    1010
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-006-expected.txt

    r271395 r272983  
    66Focus me
    77
    8 FAIL Focus should always match :focus-visible on content editable divs assert_equals: outlineColor for SPAN#el should be green expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
     8FAIL Focus should always match :focus-visible on content editable divs assert_equals: outlineColor for SPAN#el should be green expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
    99
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-007-expected.txt

    r272007 r272983  
    77Click me.
    88
    9 FAIL Using keyboard while element is focused should trigger :focus-visible; using mouse without moving focus should not cancel it; moving focus using mouse should cancel it. assert_equals: expected "rgb(0, 255, 0)" but got "rgba(0, 0, 0, 0)"
     9FAIL Using keyboard while element is focused should trigger :focus-visible; using mouse without moving focus should not cancel it; moving focus using mouse should cancel it. assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
    1010
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-009-expected.txt

    r271395 r272983  
    44I will be focused automatically.
    55
    6 FAIL Autofocus should match :focus-visible assert_equals: outlineColor for BUTTON#button should be green expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
     6FAIL Autofocus should match :focus-visible assert_equals: outlineColor for BUTTON#button should be green expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
    77
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-010-expected.txt

    r271395 r272983  
    44I will be focused automatically.
    55
    6 FAIL Programmatic focus on page load should match :focus-visible assert_equals: outlineColor for DIV#el should be green expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
     6FAIL Programmatic focus on page load should match :focus-visible assert_equals: outlineColor for DIV#el should be green expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
    77
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-012-expected.txt

    r271395 r272983  
    77Click me, then use a keyboard shortcut.
    88
    9 FAIL Keyboard focus should match :focus-visible assert_equals: outlineColor for DIV#el should be green expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
     9PASS Keyboard focus should match :focus-visible
    1010
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-015-expected.txt

    r271395 r272983  
    22Target
    33
    4 FAIL :focus-visible does not match after script focus move assert_equals: backgroundColor for DIV#initial should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
     4PASS :focus-visible does not match after script focus move
    55
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-016-expected.txt

    r271395 r272983  
    22
    33
    4 FAIL :focus-visible always match on text inputs assert_equals: backgroundColor for DIV#initial should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
     4FAIL :focus-visible always match on text inputs assert_equals: backgroundColor for INPUT#target should be lime expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
    55
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-017-expected.txt

    r272007 r272983  
    11This test checks that by default, if using JavaScript to focus an element triggers :focus-visible matching, then the element should show a focus ring with outline-style: auto.
    22
    3 Your user-agent does not support :focus-visible pseudo-class, please SKIP this test.
    4 
     3If the element below that says "Target" show a focus ring with outline-style: auto, then the test result is SUCCESS.
    54Target
    65
    7 FAIL ":focus-visible" should be a valid selector The string did not match the expected pattern.
     6PASS ":focus-visible" should be a valid selector
    87PASS By default initial programatic focus matches ':focus-visible', so the element shows a focus ring with 'outline-style: auto'
    98
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-018-expected.txt

    r272007 r272983  
    11This test checks that by default, using the mouse to focus a generic element does not show a focus ring (because it does not trigger :focus-visible matching).
    22
    3 Your user-agent does not support :focus-visible pseudo-class, please SKIP this test.
    4 
     3Click on the element below that says "Click me."
     4If the element does not have a focus ring, then the test result is SUCCESS.
    55Click me.
    66
    7 FAIL ":focus-visible" should be a valid selector The string did not match the expected pattern.
     7PASS ":focus-visible" should be a valid selector
    88FAIL Mouse focus does not show a focus ring by default assert_equals: outline-style for DIV#target should be none expected "none" but got "auto"
    99
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/parsing/parse-focus-visible-expected.txt

    r271395 r272983  
    11
    2 FAIL ":focus-visible" should be a valid selector The string did not match the expected pattern.
    3 FAIL "a:focus-visible" should be a valid selector The string did not match the expected pattern.
    4 FAIL ":focus:not(:focus-visible)" should be a valid selector The string did not match the expected pattern.
     2PASS ":focus-visible" should be a valid selector
     3PASS "a:focus-visible" should be a valid selector
     4PASS ":focus:not(:focus-visible)" should be a valid selector
    55
  • trunk/LayoutTests/platform/ios/TestExpectations

    r272720 r272983  
    33953395webkit.org/b/209734 imported/w3c/web-platform-tests/css/selectors/focus-visible-007.html [ Skip ]
    33963396webkit.org/b/209734 imported/w3c/web-platform-tests/css/selectors/focus-visible-009.html [ Skip ]
     3397webkit.org/b/209734 imported/w3c/web-platform-tests/css/selectors/focus-visible-012.html [ Skip ]
    33973398webkit.org/b/209734 imported/w3c/web-platform-tests/css/selectors/focus-visible-013.html [ Skip ]
    33983399webkit.org/b/209734 imported/w3c/web-platform-tests/css/selectors/hover-002.html [ Skip ]
  • trunk/LayoutTests/platform/mac/imported/w3c/web-platform-tests/css/selectors/focus-visible-009-expected.txt

    r272982 r272983  
    44I will be focused automatically.
    55
    6 FAIL Autofocus should match :focus-visible assert_equals: outlineColor for BUTTON#button should be green expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
     6FAIL Autofocus should match :focus-visible assert_equals: outlineColor for BUTTON#button should be green expected "rgb(0, 128, 0)" but got "rgba(0, 0, 0, 0.847)"
    77
  • trunk/Source/WTF/ChangeLog

    r272922 r272983  
     12021-02-16  Manuel Rego Casasnovas  <rego@igalia.com>
     2
     3        [selectors] :focus-visible parsing and experimental flag
     4        https://bugs.webkit.org/show_bug.cgi?id=221895
     5
     6        Reviewed by Darin Adler.
     7
     8        * Scripts/Preferences/WebPreferencesExperimental.yaml: Add experimental feature flag.
     9
    1102021-02-16  Yusuke Suzuki  <ysuzuki@apple.com>
    211
  • trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml

    r272858 r272983  
    283283      default: true
    284284
     285FocusVisibleEnabled:
     286  type: bool
     287  humanReadableName: ":focus-visible pseudo-class"
     288  humanReadableDescription: "Enable the focus-indicated pseudo-class :focus-visible"
     289  defaultValue:
     290    WebKitLegacy:
     291      default: false
     292    WebKit:
     293      default: false
     294    WebCore:
     295      default: false
     296
    285297# FIXME: This is on by default in WebKit2. Perhaps we should consider turning it on for WebKitLegacy as well.
    286298GenericCueAPIEnabled:
  • trunk/Source/WebCore/ChangeLog

    r272982 r272983  
     12021-02-16  Manuel Rego Casasnovas  <rego@igalia.com>
     2
     3        [selectors] :focus-visible parsing and experimental flag
     4        https://bugs.webkit.org/show_bug.cgi?id=221895
     5
     6        Reviewed by Darin Adler.
     7
     8        Add parsing for :focus-visible pseudo class, it'll only be enabled if the experimental feature flag is enabled.
     9
     10        Test: imported/w3c/web-platform-tests/css/selectors/parsing/parse-focus-visible.html
     11
     12        * css/CSSSelector.cpp:
     13        (WebCore::CSSSelector::selectorText const):
     14        * css/CSSSelector.h:
     15        * css/SelectorChecker.cpp:
     16        (WebCore::SelectorChecker::checkOne const):
     17        * css/SelectorCheckerTestFunctions.h:
     18        (WebCore::matchesFocusVisiblePseudoClass):
     19        * css/SelectorPseudoClassAndCompatibilityElementMap.in:
     20        * css/parser/CSSParserContext.cpp:
     21        (WebCore::CSSParserContext::CSSParserContext):
     22        (WebCore::operator==):
     23        * css/parser/CSSParserContext.h:
     24        * css/parser/CSSSelectorParser.cpp:
     25        (WebCore::isUserActionPseudoClass):
     26        (WebCore::CSSSelectorParser::consumePseudo):
     27        * cssjit/SelectorCompiler.cpp:
     28        (WebCore::SelectorCompiler::JSC_DEFINE_JIT_OPERATION):
     29        (WebCore::SelectorCompiler::addPseudoClassType):
     30
    1312021-02-16  Tyler Wilcock  <twilco.o@protonmail.com>
    232
  • trunk/Source/WebCore/css/CSSSelector.cpp

    r270784 r272983  
    505505                builder.appendLiteral(":focus");
    506506                break;
     507            case CSSSelector::PseudoClassFocusVisible:
     508                builder.appendLiteral(":focus-visible");
     509                break;
    507510            case CSSSelector::PseudoClassFocusWithin:
    508511                builder.appendLiteral(":focus-within");
  • trunk/Source/WebCore/css/CSSSelector.h

    r262695 r272983  
    115115            PseudoClassDrag,
    116116            PseudoClassFocus,
     117            PseudoClassFocusVisible,
    117118            PseudoClassFocusWithin,
    118119            PseudoClassActive,
  • trunk/Source/WebCore/css/SelectorChecker.cpp

    r271451 r272983  
    959959        case CSSSelector::PseudoClassFocus:
    960960            return matchesFocusPseudoClass(element);
     961        case CSSSelector::PseudoClassFocusVisible:
     962            return matchesFocusVisiblePseudoClass(element);
    961963        case CSSSelector::PseudoClassFocusWithin:
    962964            return element.hasFocusWithin();
  • trunk/Source/WebCore/css/SelectorCheckerTestFunctions.h

    r267783 r272983  
    473473}
    474474
     475ALWAYS_INLINE bool matchesFocusVisiblePseudoClass(const Element& element)
     476{
     477    return InspectorInstrumentation::forcePseudoState(element, CSSSelector::PseudoClassFocusVisible);
     478}
     479
    475480} // namespace WebCore
  • trunk/Source/WebCore/css/SelectorPseudoClassAndCompatibilityElementMap.in

    r262695 r272983  
    3030first-of-type
    3131focus
     32focus-visible
    3233focus-within
    3334#if ENABLE(ATTACHMENT_ELEMENT)
  • trunk/Source/WebCore/css/parser/CSSParserContext.cpp

    r272870 r272983  
    8484#endif
    8585    , useLegacyBackgroundSizeShorthandBehavior { document.settings().useLegacyBackgroundSizeShorthandBehavior() }
     86    , focusVisibleEnabled { document.settings().focusVisibleEnabled() }
    8687#if ENABLE(ATTACHMENT_ELEMENT)
    8788    , attachmentEnabled { RuntimeEnabledFeatures::sharedFeatures().attachmentElementEnabled() }
     
    116117#endif
    117118        && a.useLegacyBackgroundSizeShorthandBehavior == b.useLegacyBackgroundSizeShorthandBehavior
     119        && a.focusVisibleEnabled == b.focusVisibleEnabled
    118120#if ENABLE(ATTACHMENT_ELEMENT)
    119121        && a.attachmentEnabled == b.attachmentEnabled
  • trunk/Source/WebCore/css/parser/CSSParserContext.h

    r272870 r272983  
    7474#endif
    7575    bool useLegacyBackgroundSizeShorthandBehavior { false };
     76    bool focusVisibleEnabled { false };
    7677
    7778    // RuntimeEnabledFeatures.
  • trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp

    r270955 r272983  
    277277    case CSSSelector::PseudoClassFocus:
    278278    case CSSSelector::PseudoClassActive:
     279    case CSSSelector::PseudoClassFocusVisible:
    279280    case CSSSelector::PseudoClassFocusWithin:
    280281        return true;
     
    581582        if (selector->match() == CSSSelector::PseudoClass) {
    582583            if (m_context.mode != UASheetMode && selector->pseudoClassType() == CSSSelector::PseudoClassDirectFocus)
     584                return nullptr;
     585            if (!m_context.focusVisibleEnabled && selector->pseudoClassType() == CSSSelector::PseudoClassFocusVisible)
    583586                return nullptr;
    584587#if ENABLE(ATTACHMENT_ELEMENT)
  • trunk/Source/WebCore/cssjit/SelectorCompiler.cpp

    r270967 r272983  
    8686static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(operationMatchesDirectFocusPseudoClass, bool, (const Element&));
    8787static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(operationMatchesFocusPseudoClass, bool, (const Element&));
     88static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(operationMatchesFocusVisiblePseudoClass, bool, (const Element&));
    8889static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(operationIsMediaDocument, bool, (const Element&));
    8990static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(operationIsInRange, bool, (const Element&));
     
    632633}
    633634
     635JSC_DEFINE_JIT_OPERATION(operationMatchesFocusVisiblePseudoClass, bool, (const Element& element))
     636{
     637    return matchesFocusVisiblePseudoClass(element);
     638}
     639
    634640JSC_DEFINE_JIT_OPERATION(operationIsMediaDocument, bool, (const Element& element))
    635641{
     
    779785    case CSSSelector::PseudoClassFocus:
    780786        fragment.unoptimizedPseudoClasses.append(JSC::FunctionPtr<JSC::OperationPtrTag>(operationMatchesFocusPseudoClass));
     787        return FunctionType::SimpleSelectorChecker;
     788    case CSSSelector::PseudoClassFocusVisible:
     789        fragment.unoptimizedPseudoClasses.append(JSC::FunctionPtr<JSC::OperationPtrTag>(operationMatchesFocusVisiblePseudoClass));
    781790        return FunctionType::SimpleSelectorChecker;
    782791    case CSSSelector::PseudoClassFullPageMedia:
Note: See TracChangeset for help on using the changeset viewer.