Changeset 274305 in webkit


Ignore:
Timestamp:
Mar 11, 2021 3:55:40 PM (17 months ago)
Author:
Wenson Hsieh
Message:

[macOS] Selecting text via mouse drag in image documents shouldn't trigger click events
https://bugs.webkit.org/show_bug.cgi?id=223075

Reviewed by Tim Horton.

Improve image overlay support in image documents, by setting -webkit-user-select: text; on the image overlay
container and cursor: text; on each of the text children. Additionally, make it so that text selection in
image overlays doesn't trigger a click event, so that attempting to select text doesn't trigger click events.

  • html/HTMLElement.cpp:

(WebCore::HTMLElement::updateWithImageExtractionResult):

  • page/EventHandler.cpp:

(WebCore::EventHandler::updateSelectionForMouseDrag):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r274301 r274305  
     12021-03-11  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [macOS] Selecting text via mouse drag in image documents shouldn't trigger click events
     4        https://bugs.webkit.org/show_bug.cgi?id=223075
     5
     6        Reviewed by Tim Horton.
     7
     8        Improve image overlay support in image documents, by setting `-webkit-user-select: text;` on the image overlay
     9        container and `cursor: text;` on each of the text children. Additionally, make it so that text selection in
     10        image overlays doesn't trigger a click event, so that attempting to select text doesn't trigger click events.
     11
     12        * html/HTMLElement.cpp:
     13        (WebCore::HTMLElement::updateWithImageExtractionResult):
     14        * page/EventHandler.cpp:
     15        (WebCore::EventHandler::updateSelectionForMouseDrag):
     16
    1172021-03-11  Aditya Keerthi  <akeerthi@apple.com>
    218
  • trunk/Source/WebCore/html/HTMLElement.cpp

    r274215 r274305  
    12811281    auto container = HTMLDivElement::create(document());
    12821282    container->setIdAttribute(imageOverlayElementIdentifier());
     1283    if (document().isImageDocument())
     1284        container->setInlineStyleProperty(CSSPropertyWebkitUserSelect, CSSValueText);
    12831285    shadowRoot->appendChild(container);
    12841286
     
    13131315            "scale("_s, scale.width(), ", "_s, scale.height(), ") "_s
    13141316        ));
     1317
     1318        if (document().isImageDocument())
     1319            child->setInlineStyleProperty(CSSPropertyCursor, CSSValueText);
    13151320    }
    13161321
  • trunk/Source/WebCore/page/EventHandler.cpp

    r274215 r274305  
    10001000    m_frame.selection().setSelectionByMouseIfDifferent(newSelection, m_frame.selection().granularity(),
    10011001        FrameSelection::EndPointsAdjustmentMode::AdjustAtBidiBoundary);
     1002
     1003    if (newSelection.start().containerNode() && HTMLElement::isImageOverlayText(*newSelection.start().containerNode())
     1004        && newSelection.end().containerNode() && HTMLElement::isImageOverlayText(*newSelection.end().containerNode()))
     1005        invalidateClick();
    10021006}
    10031007#endif // ENABLE(DRAG_SUPPORT)
Note: See TracChangeset for help on using the changeset viewer.