Changeset 245238 in webkit


Ignore:
Timestamp:
May 13, 2019, 9:52:05 AM (7 years ago)
Author:
Wenson Hsieh
Message:

[macOS] Font formatting options don't work when composing a message in Yahoo mail
https://bugs.webkit.org/show_bug.cgi?id=197813
<rdar://problem/49382250>

Reviewed by Darin Adler.

Source/WebCore:

The bug happens because on mousedown, the "Aa Font" menu item's event handler hides itself before changing the
font at the text selection. This causes us to clear the selection in FocusController::setFocusedElement.

There is existing logic in clearSelectionIfNeeded that would normally prevent us from clearing the selection due
to the mousePressNode not being able to start a selection. However, since the clickable element in this case is
hidden during mousedown, it is missing a renderer, and we bail from the `mousePressNode->renderer() &&
!mousePressNode->canStartSelection()` check as a result.

This check was orginally added in https://trac.webkit.org/r24334 to avoid clearing the selection when clicking
a button; the intention appears to have been making it so that clicking on something that could not start a
selection (back then, synonymous with -webkit-user-select: ignore;) would not clear the current selection; to
this end, it seems odd to additionally require that the thing being clicked should still have a renderer, so
it seems safe to remove this requirement.

Test: editing/selection/preserve-selection-when-clicking-button.html

  • page/FocusController.cpp:

(WebCore::clearSelectionIfNeeded):

LayoutTests:

Add a new layout test to verify that DOM selection is preserved after clicking a button that hides itself
upon mousedown.

  • editing/selection/preserve-selection-when-clicking-button-expected.txt: Added.
  • editing/selection/preserve-selection-when-clicking-button.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r245235 r245238  
     12019-05-13  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [macOS] Font formatting options don't work when composing a message in Yahoo mail
     4        https://bugs.webkit.org/show_bug.cgi?id=197813
     5        <rdar://problem/49382250>
     6
     7        Reviewed by Darin Adler.
     8
     9        Add a new layout test to verify that DOM selection is preserved after clicking a button that hides itself
     10        upon mousedown.
     11
     12        * editing/selection/preserve-selection-when-clicking-button-expected.txt: Added.
     13        * editing/selection/preserve-selection-when-clicking-button.html: Added.
     14
    1152019-05-13  Sihui Liu  <sihui_liu@apple.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r245236 r245238  
     12019-05-13  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [macOS] Font formatting options don't work when composing a message in Yahoo mail
     4        https://bugs.webkit.org/show_bug.cgi?id=197813
     5        <rdar://problem/49382250>
     6
     7        Reviewed by Darin Adler.
     8
     9        The bug happens because on mousedown, the "Aa Font" menu item's event handler hides itself before changing the
     10        font at the text selection. This causes us to clear the selection in FocusController::setFocusedElement.
     11
     12        There is existing logic in clearSelectionIfNeeded that would normally prevent us from clearing the selection due
     13        to the mousePressNode not being able to start a selection. However, since the clickable element in this case is
     14        hidden during mousedown, it is missing a renderer, and we bail from the `mousePressNode->renderer() &&
     15        !mousePressNode->canStartSelection()` check as a result.
     16
     17        This check was orginally added in https://trac.webkit.org/r24334 to avoid clearing the selection when clicking
     18        a button; the intention appears to have been making it so that clicking on something that could not start a
     19        selection (back then, synonymous with -webkit-user-select: ignore;) would not clear the current selection; to
     20        this end, it seems odd to additionally require that the thing being clicked should still have a renderer, so
     21        it seems safe to remove this requirement.
     22
     23        Test: editing/selection/preserve-selection-when-clicking-button.html
     24
     25        * page/FocusController.cpp:
     26        (WebCore::clearSelectionIfNeeded):
     27
    1282019-05-13  Eric Carlson  <eric.carlson@apple.com>
    229
  • trunk/Source/WebCore/page/FocusController.cpp

    r241932 r245238  
    775775
    776776    if (Node* mousePressNode = newFocusedFrame->eventHandler().mousePressNode()) {
    777         if (mousePressNode->renderer() && !mousePressNode->canStartSelection()) {
     777        if (!mousePressNode->canStartSelection()) {
    778778            // Don't clear the selection for contentEditable elements, but do clear it for input and textarea. See bug 38696.
    779779            auto* root = selection.rootEditableElement();
Note: See TracChangeset for help on using the changeset viewer.