Changeset 202470 in webkit


Ignore:
Timestamp:
Jun 25, 2016 9:34:23 PM (8 years ago)
Author:
benjamin@webkit.org
Message:

The active state of elements can break when focus changes
https://bugs.webkit.org/show_bug.cgi?id=159112

Patch by Benjamin Poulain <bpoulain@apple.com> on 2016-06-25
Reviewed by Antti Koivisto.

Source/WebCore:

The pseudo class :active was behaving weirdly when used
with label elements with an associated form element.
The form element would get the :active state on the first click
then no longer get the state until the focus changes.

What was happenning is setFocusedElement() was clearing active
for some unknown reason. When you really do that on an active element,
you end up in an inconsistent state where no invalidation works.

The two tests illustrates 2 ways this breaks.

The test "pseudo-active-on-labeled-element-not-canceled-by-focus" clicks
several time on a lable element. The first time, the input element gets
the focus. The second time, it already has the focus, setFocusedElement()
clears :active before finding the focusable element and end up clearing
the active state on a target in the active chain.

The test "pseudo-active-with-programmatic-focus.html" shows how to invalidate
arbitrary elements using JavaScript. This can cause severely broken active
chains where invalidation never cleans some ancestors.

Tests: fast/css/pseudo-active-on-labeled-element-not-canceled-by-focus.html

fast/css/pseudo-active-with-programmatic-focus.html

  • dom/Document.cpp:

(WebCore::Document::setFocusedElement): Deleted.

  • page/EventHandler.cpp:

(WebCore::EventHandler::handleMouseDoubleClickEvent):
This is WebKit1 specific. The double click event was dispatching
the mouseUp and Click with after doing an Active hit test.
This causes us to have :active state in and after mouseUp in WebKit1.

LayoutTests:

  • fast/css/pseudo-active-on-labeled-element-not-canceled-by-focus-expected.txt: Added.
  • fast/css/pseudo-active-on-labeled-element-not-canceled-by-focus.html: Added.
  • fast/css/pseudo-active-with-programmatic-focus-expected.txt: Added.
  • fast/css/pseudo-active-with-programmatic-focus.html: Added.
Location:
trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202466 r202470  
     12016-06-25  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        The active state of elements can break when focus changes
     4        https://bugs.webkit.org/show_bug.cgi?id=159112
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * fast/css/pseudo-active-on-labeled-element-not-canceled-by-focus-expected.txt: Added.
     9        * fast/css/pseudo-active-on-labeled-element-not-canceled-by-focus.html: Added.
     10        * fast/css/pseudo-active-with-programmatic-focus-expected.txt: Added.
     11        * fast/css/pseudo-active-with-programmatic-focus.html: Added.
     12
    1132016-06-24  Jer Noble  <jer.noble@apple.com>
    214
  • trunk/LayoutTests/platform/ios-simulator/TestExpectations

    r202447 r202470  
    14361436fast/css/object-fit/object-fit-input-image.html [ ImageOnlyFailure ]
    14371437fast/css/outline-auto-empty-rects.html [ Failure ]
     1438fast/css/pseudo-active-on-labeled-element-not-canceled-by-focus.html [ Failure ]
     1439fast/css/pseudo-active-with-programmatic-focus.html [ Failure ]
    14381440fast/css/pseudo-first-line-border-width.html [ Failure ]
    14391441fast/css/read-only-read-write-input-basics.html [ ImageOnlyFailure ]
  • trunk/Source/WebCore/ChangeLog

    r202466 r202470  
     12016-06-25  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        The active state of elements can break when focus changes
     4        https://bugs.webkit.org/show_bug.cgi?id=159112
     5
     6        Reviewed by Antti Koivisto.
     7
     8        The pseudo class :active was behaving weirdly when used
     9        with label elements with an associated form element.
     10        The form element would get the :active state on the first click
     11        then no longer get the state until the focus changes.
     12
     13        What was happenning is setFocusedElement() was clearing active
     14        for some unknown reason. When you really do that on an active element,
     15        you end up in an inconsistent state where no invalidation works.
     16
     17        The two tests illustrates 2 ways this breaks.
     18
     19        The test "pseudo-active-on-labeled-element-not-canceled-by-focus" clicks
     20        several time on a lable element. The first time, the input element gets
     21        the focus. The second time, it already has the focus, setFocusedElement()
     22        clears :active before finding the focusable element and end up clearing
     23        the active state on a target in the active chain.
     24
     25        The test "pseudo-active-with-programmatic-focus.html" shows how to invalidate
     26        arbitrary elements using JavaScript. This can cause severely broken active
     27        chains where invalidation never cleans some ancestors.
     28
     29        Tests: fast/css/pseudo-active-on-labeled-element-not-canceled-by-focus.html
     30               fast/css/pseudo-active-with-programmatic-focus.html
     31
     32        * dom/Document.cpp:
     33        (WebCore::Document::setFocusedElement): Deleted.
     34
     35        * page/EventHandler.cpp:
     36        (WebCore::EventHandler::handleMouseDoubleClickEvent):
     37        This is WebKit1 specific. The double click event was dispatching
     38        the mouseUp and Click with after doing an Active hit test.
     39        This causes us to have :active state in and after mouseUp in WebKit1.
     40
    1412016-06-24  Jer Noble  <jer.noble@apple.com>
    242
  • trunk/Source/WebCore/dom/Document.cpp

    r202399 r202470  
    37783778    // Remove focus from the existing focus node (if any)
    37793779    if (oldFocusedElement) {
    3780         if (oldFocusedElement->active())
    3781             oldFocusedElement->setActive(false);
    3782 
    37833780        oldFocusedElement->setFocus(false);
    37843781        setFocusNavigationStartingNode(nullptr);
  • trunk/Source/WebCore/page/EventHandler.cpp

    r202242 r202470  
    17531753    setLastKnownMousePosition(platformMouseEvent);
    17541754
    1755     HitTestRequest request(HitTestRequest::Active | HitTestRequest::DisallowUserAgentShadowContent);
     1755    HitTestRequest request(HitTestRequest::Release | HitTestRequest::DisallowUserAgentShadowContent);
    17561756    MouseEventWithHitTestResults mouseEvent = prepareMouseEvent(request, platformMouseEvent);
    17571757    Frame* subframe = subframeForHitTestResult(mouseEvent);
Note: See TracChangeset for help on using the changeset viewer.