Title: [285609] trunk
Revision
285609
Author
[email protected]
Date
2021-11-10 16:03:06 -0800 (Wed, 10 Nov 2021)

Log Message

Refactor some image overlay logic to work with built-in media controls
https://bugs.webkit.org/show_bug.cgi?id=232899
rdar://83173597

Reviewed by Antoine Quint and Tim Horton.

Source/WebCore:

Make various minor adjustments to allow built-in modern media controls to play well with image overlay content.
See below for more details.

* Modules/mediacontrols/MediaControlsHost.cpp:
(WebCore::MediaControlsHost::mediaControlsContainerClassName):
* Modules/mediacontrols/MediaControlsHost.h:

Add a helper function to grab the "media-controls-container" class name, which is used for the `div` element
containing built-in modern media controls. This is used below to identify existing media control container
elements when determining where to inject the image overlay root container.

* Modules/mediacontrols/MediaControlsHost.idl:
* Modules/modern-media-controls/controls/controls-bar.css:
(.controls-bar):

Z-order the media controls bar (which contains all interactible media control elements) above any image overlay
content that may coexist in the same shadow root.

* Modules/modern-media-controls/controls/media-controls.css:
(:host):

Remove `-webkit-user-select: none;` here. This was added to prevent the iOS magnifier UI from showing up when
long pressing inside a video element; we can achieve the same effect without applying this property over the
entire host element by instead changing selection logic in WebKit2.

(.media-controls):

Push the `-webkit-user-select: none;` property down into the media control children, instead of on
`.media-controls` itself.

(.media-controls > *):
* Modules/modern-media-controls/media/media-controller.js:
(MediaController):

Change this to ask for `mediaControlsContainerClassName` from the host, instead of hard-coding it to
"media-controls-container". From code inspection, there does not seem to be any codepath that passes in an
undefined `host`, except for the modern media controls layout tests (which still pass after this adjustment).

* html/HTMLElement.cpp:
(WebCore::HTMLElement::isImageOverlayText):
(WebCore::HTMLElement::removeImageOverlaySoonIfNeeded):

Adjust these helper methods to work in the case where the image overlay container is hosted underneath the media
controls container.

(WebCore::HTMLElement::updateWithTextRecognitionResult):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::seekWithTolerance):
(WebCore::HTMLMediaElement::playInternal):

If needed, remove the image overlay when seeking or playing media.

Source/WebKit:

See WebCore/ChangeLog for more details.

* Shared/ios/InteractionInformationAtPosition.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(canAttemptTextRecognitionForNonImageElements):

Add a new WebKitAdditions integration point.

(-[WKContentView imageAnalysisGestureDidBegin:]):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::selectionPositionInformation):

Adjust for the changes to the built-in media controls stylesheet by adding logic to prevent the magnifier from
showing up when long pressing (or long pressing inside) video elements on iOS.

LayoutTests:

Adjust a modern media controls test, such that it no longer verifies that the `-webkit-user-select` CSS property
is none on an audio element; in lieu of this, we add a new layout test in `editing/selection` to verify that
long pressing over the timestamp of an audio element does not trigger text selection.

* editing/selection/ios/do-not-allow-text-selection-in-audio-element-expected.txt: Added.
* editing/selection/ios/do-not-allow-text-selection-in-audio-element.html: Added.
* media/modern-media-controls/audio/audio-controls-styles-expected.txt:
* media/modern-media-controls/audio/audio-controls-styles.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (285608 => 285609)


--- trunk/LayoutTests/ChangeLog	2021-11-10 22:49:56 UTC (rev 285608)
+++ trunk/LayoutTests/ChangeLog	2021-11-11 00:03:06 UTC (rev 285609)
@@ -1,3 +1,20 @@
+2021-11-10  Wenson Hsieh  <[email protected]>
+
+        Refactor some image overlay logic to work with built-in media controls
+        https://bugs.webkit.org/show_bug.cgi?id=232899
+        rdar://83173597
+
+        Reviewed by Antoine Quint and Tim Horton.
+
+        Adjust a modern media controls test, such that it no longer verifies that the `-webkit-user-select` CSS property
+        is none on an audio element; in lieu of this, we add a new layout test in `editing/selection` to verify that
+        long pressing over the timestamp of an audio element does not trigger text selection.
+
+        * editing/selection/ios/do-not-allow-text-selection-in-audio-element-expected.txt: Added.
+        * editing/selection/ios/do-not-allow-text-selection-in-audio-element.html: Added.
+        * media/modern-media-controls/audio/audio-controls-styles-expected.txt:
+        * media/modern-media-controls/audio/audio-controls-styles.html:
+
 2021-11-10  Antoine Quint  <[email protected]>
 
         The cssText property for a computed style should return an empty string

Added: trunk/LayoutTests/editing/selection/ios/do-not-allow-text-selection-in-audio-element-expected.txt (0 => 285609)


--- trunk/LayoutTests/editing/selection/ios/do-not-allow-text-selection-in-audio-element-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/ios/do-not-allow-text-selection-in-audio-element-expected.txt	2021-11-11 00:03:06 UTC (rev 285609)
@@ -0,0 +1,10 @@
+This test verifies that long pressing the timestamp in an audio element does not start a text selection. To manually run the test, long press the audio element below and verify that no text is selected.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS rects.length is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/editing/selection/ios/do-not-allow-text-selection-in-audio-element.html (0 => 285609)


--- trunk/LayoutTests/editing/selection/ios/do-not-allow-text-selection-in-audio-element.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/ios/do-not-allow-text-selection-in-audio-element.html	2021-11-11 00:03:06 UTC (rev 285609)
@@ -0,0 +1,34 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<head>
+<script src=""
+<script src=""
+<script>
+jsTestIsAsync = true;
+description("This test verifies that long pressing the timestamp in an audio element does not start a text selection. To manually run the test, long press the audio element below and verify that no text is selected.");
+addEventListener("load", async () => {
+    if (!window.internals)
+        return;
+
+    const audioElement = document.querySelector("audio");
+    let timeLabel;
+    for (let label of Array.from(internals.shadowRoot(audioElement).querySelectorAll("div.time-label"))) {
+        if (getComputedStyle(label).display !== "none")
+            timeLabel = label;
+    }
+
+    const targetX = (audioElement.offsetLeft + timeLabel.offsetLeft) + timeLabel.offsetWidth / 2;
+    const targetY = (audioElement.offsetTop + timeLabel.offsetTop) + timeLabel.offsetHeight / 2;
+    await UIHelper.longPressAtPoint(targetX, targetY);
+    rects = await UIHelper.getUISelectionViewRects();
+
+    shouldBe("rects.length", "0");
+    finishJSTest();
+});
+</script>
+</head>
+<body>
+<audio controls src=""
+</body>
+</html>
\ No newline at end of file

Modified: trunk/LayoutTests/media/modern-media-controls/audio/audio-controls-styles-expected.txt (285608 => 285609)


--- trunk/LayoutTests/media/modern-media-controls/audio/audio-controls-styles-expected.txt	2021-11-10 22:49:56 UTC (rev 285608)
+++ trunk/LayoutTests/media/modern-media-controls/audio/audio-controls-styles-expected.txt	2021-11-11 00:03:06 UTC (rev 285609)
@@ -3,7 +3,6 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS getComputedStyle(audio).WebkitUserSelect is "none"
 PASS getComputedStyle(audio).WebkitTouchCallout is "none"
 
 PASS successfullyParsed is true

Modified: trunk/LayoutTests/media/modern-media-controls/audio/audio-controls-styles.html (285608 => 285609)


--- trunk/LayoutTests/media/modern-media-controls/audio/audio-controls-styles.html	2021-11-10 22:49:56 UTC (rev 285608)
+++ trunk/LayoutTests/media/modern-media-controls/audio/audio-controls-styles.html	2021-11-11 00:03:06 UTC (rev 285609)
@@ -8,7 +8,6 @@
 const audio = document.body.appendChild(document.createElement("audio"));
 audio.controls = true;
 
-shouldBeEqualToString("getComputedStyle(audio).WebkitUserSelect", "none");
 shouldBeEqualToString("getComputedStyle(audio).WebkitTouchCallout", "none");
 
 debug("");

Modified: trunk/Source/WebCore/ChangeLog (285608 => 285609)


--- trunk/Source/WebCore/ChangeLog	2021-11-10 22:49:56 UTC (rev 285608)
+++ trunk/Source/WebCore/ChangeLog	2021-11-11 00:03:06 UTC (rev 285609)
@@ -1,3 +1,63 @@
+2021-11-10  Wenson Hsieh  <[email protected]>
+
+        Refactor some image overlay logic to work with built-in media controls
+        https://bugs.webkit.org/show_bug.cgi?id=232899
+        rdar://83173597
+
+        Reviewed by Antoine Quint and Tim Horton.
+
+        Make various minor adjustments to allow built-in modern media controls to play well with image overlay content.
+        See below for more details.
+
+        * Modules/mediacontrols/MediaControlsHost.cpp:
+        (WebCore::MediaControlsHost::mediaControlsContainerClassName):
+        * Modules/mediacontrols/MediaControlsHost.h:
+
+        Add a helper function to grab the "media-controls-container" class name, which is used for the `div` element
+        containing built-in modern media controls. This is used below to identify existing media control container
+        elements when determining where to inject the image overlay root container.
+
+        * Modules/mediacontrols/MediaControlsHost.idl:
+        * Modules/modern-media-controls/controls/controls-bar.css:
+        (.controls-bar):
+
+        Z-order the media controls bar (which contains all interactible media control elements) above any image overlay
+        content that may coexist in the same shadow root.
+
+        * Modules/modern-media-controls/controls/media-controls.css:
+        (:host):
+
+        Remove `-webkit-user-select: none;` here. This was added to prevent the iOS magnifier UI from showing up when
+        long pressing inside a video element; we can achieve the same effect without applying this property over the
+        entire host element by instead changing selection logic in WebKit2.
+
+        (.media-controls):
+
+        Push the `-webkit-user-select: none;` property down into the media control children, instead of on
+        `.media-controls` itself.
+
+        (.media-controls > *):
+        * Modules/modern-media-controls/media/media-controller.js:
+        (MediaController):
+
+        Change this to ask for `mediaControlsContainerClassName` from the host, instead of hard-coding it to
+        "media-controls-container". From code inspection, there does not seem to be any codepath that passes in an
+        undefined `host`, except for the modern media controls layout tests (which still pass after this adjustment).
+
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::isImageOverlayText):
+        (WebCore::HTMLElement::removeImageOverlaySoonIfNeeded):
+
+        Adjust these helper methods to work in the case where the image overlay container is hosted underneath the media
+        controls container.
+
+        (WebCore::HTMLElement::updateWithTextRecognitionResult):
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::seekWithTolerance):
+        (WebCore::HTMLMediaElement::playInternal):
+
+        If needed, remove the image overlay when seeking or playing media.
+
 2021-11-10  Antoine Quint  <[email protected]>
 
         The cssText property for a computed style should return an empty string

Modified: trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp (285608 => 285609)


--- trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp	2021-11-10 22:49:56 UTC (rev 285608)
+++ trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp	2021-11-11 00:03:06 UTC (rev 285609)
@@ -133,6 +133,12 @@
 #endif
 }
 
+const AtomString& MediaControlsHost::mediaControlsContainerClassName() const
+{
+    static MainThreadNeverDestroyed<const AtomString> className("media-controls-container", AtomString::ConstructFromLiteral);
+    return className;
+}
+
 Vector<RefPtr<TextTrack>> MediaControlsHost::sortedTrackListForMenu(TextTrackList& trackList)
 {
     if (!m_mediaElement)

Modified: trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.h (285608 => 285609)


--- trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.h	2021-11-10 22:49:56 UTC (rev 285608)
+++ trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.h	2021-11-11 00:03:06 UTC (rev 285609)
@@ -55,6 +55,7 @@
     static const AtomString& forcedOnlyKeyword();
 
     String layoutTraitsClassName() const;
+    const AtomString& mediaControlsContainerClassName() const;
 
     double brightness() const { return 1; }
     void setBrightness(double) { }

Modified: trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.idl (285608 => 285609)


--- trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.idl	2021-11-10 22:49:56 UTC (rev 285608)
+++ trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.idl	2021-11-11 00:03:06 UTC (rev 285609)
@@ -35,6 +35,7 @@
     LegacyNoInterfaceObject,
 ] interface MediaControlsHost {
     readonly attribute DOMString layoutTraitsClassName;
+    readonly attribute DOMString mediaControlsContainerClassName;
     attribute double brightness;
 
     sequence<TextTrack> sortedTrackListForMenu(TextTrackList trackList);

Modified: trunk/Source/WebCore/Modules/modern-media-controls/controls/controls-bar.css (285608 => 285609)


--- trunk/Source/WebCore/Modules/modern-media-controls/controls/controls-bar.css	2021-11-10 22:49:56 UTC (rev 285608)
+++ trunk/Source/WebCore/Modules/modern-media-controls/controls/controls-bar.css	2021-11-11 00:03:06 UTC (rev 285609)
@@ -28,4 +28,5 @@
     cursor: default;
     direction: ltr;
     will-change: z-index;
+    z-index: 1;
 }

Modified: trunk/Source/WebCore/Modules/modern-media-controls/controls/media-controls.css (285608 => 285609)


--- trunk/Source/WebCore/Modules/modern-media-controls/controls/media-controls.css	2021-11-10 22:49:56 UTC (rev 285608)
+++ trunk/Source/WebCore/Modules/modern-media-controls/controls/media-controls.css	2021-11-11 00:03:06 UTC (rev 285609)
@@ -24,8 +24,7 @@
  */
 
 :host {
-    /* We always want to prevent iOS dialogs and the magnifier UI to be shown. */
-    -webkit-user-select: none !important;
+    /* We always want to avoid showing the context menu on iOS. */
     -webkit-touch-callout: none !important;
 }
 
@@ -82,7 +81,6 @@
 .media-controls {
     height: 100%;
     font-family: -apple-system;
-    -webkit-user-select: none;
     white-space: nowrap;
     text-align: initial;
     transform-origin: 0 0;
@@ -93,6 +91,8 @@
 }
 
 .media-controls > * {
+    /* We always want to avoid showing the text selection magnifier on iOS. */
+    -webkit-user-select: none;
     transition: opacity 0.1s linear;
 }
 
@@ -126,4 +126,4 @@
 @media (inverted-colors) {
     :host { filter: invert(100%); } /* WebKit native audio and video. */
     picture { filter: none; } /* Don't invert the control buttons. */
-}
\ No newline at end of file
+}

Modified: trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js (285608 => 285609)


--- trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js	2021-11-10 22:49:56 UTC (rev 285608)
+++ trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js	2021-11-11 00:03:06 UTC (rev 285609)
@@ -37,12 +37,12 @@
         this.hasPlayed = false;
 
         this.container = shadowRoot.appendChild(document.createElement("div"));
-        this.container.className = "media-controls-container";
 
         this._updateControlsIfNeeded();
         this._usesLTRUserInterfaceLayoutDirection = false;
 
         if (host) {
+            this.container.className = host.mediaControlsContainerClassName;
             host.controlsDependOnPageScaleFactor = this.layoutTraits.controlsDependOnPageScaleFactor();
             this.container.insertBefore(host.textTrackContainer, this.controls.element);
             if (host.isInMediaDocument)

Modified: trunk/Source/WebCore/html/HTMLElement.cpp (285608 => 285609)


--- trunk/Source/WebCore/html/HTMLElement.cpp	2021-11-10 22:49:56 UTC (rev 285608)
+++ trunk/Source/WebCore/html/HTMLElement.cpp	2021-11-11 00:03:06 UTC (rev 285609)
@@ -53,6 +53,7 @@
 #include "HTMLFieldSetElement.h"
 #include "HTMLFormElement.h"
 #include "HTMLInputElement.h"
+#include "HTMLMediaElement.h"
 #include "HTMLNames.h"
 #include "HTMLOptGroupElement.h"
 #include "HTMLOptionElement.h"
@@ -61,6 +62,7 @@
 #include "HTMLStyleElement.h"
 #include "HTMLTextAreaElement.h"
 #include "HTMLTextFormControlElement.h"
+#include "MediaControlsHost.h"
 #include "NodeTraversal.h"
 #include "RenderElement.h"
 #include "RenderImage.h"
@@ -1250,6 +1252,9 @@
     setAttributeWithoutSynchronization(enterkeyhintAttr, value);
 }
 
+// FIXME: We should move all of this image overlay-specific logic out into a separate helper file (possibly as standalone functions)
+// to better compartmentalize this code.
+
 static const AtomString& imageOverlayElementIdentifier()
 {
     static MainThreadNeverDestroyed<const AtomString> identifier("image-overlay", AtomString::ConstructFromLiteral);
@@ -1323,10 +1328,8 @@
     if (!host)
         return false;
 
-    for (auto& child : childrenOfType<HTMLDivElement>(*host->userAgentShadowRoot())) {
-        if (child.getIdAttribute() == imageOverlayElementIdentifier())
-            return node.isDescendantOf(child);
-    }
+    if (RefPtr overlay = static_cast<TreeScope&>(*host->userAgentShadowRoot()).getElementById(imageOverlayElementIdentifier()))
+        return node.isDescendantOf(*overlay);
 
     return false;
 }
@@ -1345,17 +1348,9 @@
         if (!shadowRoot)
             return;
 
-        RefPtr<HTMLDivElement> containerToRemove;
-        for (auto& child : childrenOfType<HTMLDivElement>(*shadowRoot)) {
-            if (child.getIdAttribute() == imageOverlayElementIdentifier()) {
-                containerToRemove = &child;
-                break;
-            }
-        }
+        if (RefPtr overlay = static_cast<TreeScope&>(*shadowRoot).getElementById(imageOverlayElementIdentifier()))
+            overlay->remove();
 
-        if (containerToRemove)
-            containerToRemove->remove();
-
 #if ENABLE(IMAGE_ANALYSIS)
         if (auto page = protectedThis->document().page())
             page->resetTextRecognitionResult(*protectedThis);
@@ -1395,15 +1390,35 @@
 
     bool hadExistingTextRecognitionElements = false;
     TextRecognitionElements textRecognitionElements;
-
-    if (hasImageOverlay()) {
-        for (auto& child : childrenOfType<HTMLDivElement>(*userAgentShadowRoot())) {
-            if (child.getIdAttribute() == imageOverlayElementIdentifier()) {
-                textRecognitionElements.root = &child;
-                hadExistingTextRecognitionElements = true;
-                break;
+    RefPtr<HTMLElement> mediaControlsContainer;
+    if (RefPtr shadowRoot = this->shadowRoot()) {
+#if ENABLE(MODERN_MEDIA_CONTROLS)
+        if (is<HTMLMediaElement>(*this)) {
+            if (RefPtr controlsHost = downcast<HTMLMediaElement>(*this).mediaControlsHost()) {
+                auto& containerClass = controlsHost->mediaControlsContainerClassName();
+                for (auto& child : childrenOfType<HTMLDivElement>(*shadowRoot)) {
+                    if (child.hasClass() && child.classNames().contains(containerClass)) {
+                        mediaControlsContainer = &child;
+                        break;
+                    }
+                }
             }
         }
+#endif
+        if (hasImageOverlay()) {
+            RefPtr<ContainerNode> containerForImageOverlay;
+            if (mediaControlsContainer)
+                containerForImageOverlay = mediaControlsContainer;
+            else
+                containerForImageOverlay = shadowRoot;
+            for (auto& child : childrenOfType<HTMLDivElement>(*containerForImageOverlay)) {
+                if (child.getIdAttribute() == imageOverlayElementIdentifier()) {
+                    textRecognitionElements.root = &child;
+                    hadExistingTextRecognitionElements = true;
+                    continue;
+                }
+            }
+        }
     }
 
     if (textRecognitionElements.root) {
@@ -1457,7 +1472,11 @@
         rootContainer->setIdAttribute(imageOverlayElementIdentifier());
         if (document().isImageDocument())
             rootContainer->setInlineStyleProperty(CSSPropertyWebkitUserSelect, CSSValueText);
-        shadowRoot->appendChild(rootContainer);
+
+        if (mediaControlsContainer)
+            mediaControlsContainer->appendChild(rootContainer);
+        else
+            shadowRoot->appendChild(rootContainer);
         textRecognitionElements.root = rootContainer.copyRef();
         textRecognitionElements.lines.reserveInitialCapacity(result.lines.size());
         for (auto& line : result.lines) {

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (285608 => 285609)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2021-11-10 22:49:56 UTC (rev 285608)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2021-11-11 00:03:06 UTC (rev 285609)
@@ -3139,6 +3139,8 @@
 
     if (processingUserGestureForMedia())
         mediaSession().removeBehaviorRestriction(MediaElementSession::RequireUserGestureToControlControlsManager);
+
+    removeImageOverlaySoonIfNeeded();
 }
 
 void HTMLMediaElement::seekTask()
@@ -3731,6 +3733,8 @@
 
     m_autoplaying = false;
     updatePlayState();
+
+    removeImageOverlaySoonIfNeeded();
 }
 
 void HTMLMediaElement::pause()

Modified: trunk/Source/WebKit/ChangeLog (285608 => 285609)


--- trunk/Source/WebKit/ChangeLog	2021-11-10 22:49:56 UTC (rev 285608)
+++ trunk/Source/WebKit/ChangeLog	2021-11-11 00:03:06 UTC (rev 285609)
@@ -1,3 +1,26 @@
+2021-11-10  Wenson Hsieh  <[email protected]>
+
+        Refactor some image overlay logic to work with built-in media controls
+        https://bugs.webkit.org/show_bug.cgi?id=232899
+        rdar://83173597
+
+        Reviewed by Antoine Quint and Tim Horton.
+
+        See WebCore/ChangeLog for more details.
+
+        * Shared/ios/InteractionInformationAtPosition.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (canAttemptTextRecognitionForNonImageElements):
+
+        Add a new WebKitAdditions integration point.
+
+        (-[WKContentView imageAnalysisGestureDidBegin:]):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::selectionPositionInformation):
+
+        Adjust for the changes to the built-in media controls stylesheet by adding logic to prevent the magnifier from
+        showing up when long pressing (or long pressing inside) video elements on iOS.
+
 2021-11-10  Per Arne Vollan <[email protected]>
 
         [macOS][GPUP] Remove access to sysctl properties

Modified: trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.h (285608 => 285609)


--- trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.h	2021-11-10 22:49:56 UTC (rev 285608)
+++ trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.h	2021-11-11 00:03:06 UTC (rev 285609)
@@ -59,6 +59,7 @@
         UnselectableDueToFocusableElement,
         UnselectableDueToLargeElementBounds,
         UnselectableDueToUserSelectNone,
+        UnselectableDueToMediaControls,
     };
     Selectability selectability { Selectability::Selectable };
 
@@ -132,7 +133,8 @@
         WebKit::InteractionInformationAtPosition::Selectability::Selectable,
         WebKit::InteractionInformationAtPosition::Selectability::UnselectableDueToFocusableElement,
         WebKit::InteractionInformationAtPosition::Selectability::UnselectableDueToLargeElementBounds,
-        WebKit::InteractionInformationAtPosition::Selectability::UnselectableDueToUserSelectNone
+        WebKit::InteractionInformationAtPosition::Selectability::UnselectableDueToUserSelectNone,
+        WebKit::InteractionInformationAtPosition::Selectability::UnselectableDueToMediaControls
     >;
 };
 

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (285608 => 285609)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-11-10 22:49:56 UTC (rev 285608)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-11-11 00:03:06 UTC (rev 285609)
@@ -226,6 +226,19 @@
 
 #endif // ENABLE(IMAGE_ANALYSIS)
 
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WKContentViewInteractionAdditions.mm>
+#else
+
+#if ENABLE(IMAGE_ANALYSIS)
+static bool canAttemptTextRecognitionForNonImageElements(const WebKit::InteractionInformationAtPosition& information, const WebKit::WebPreferences&)
+{
+    return false;
+}
+#endif // ENABLE(IMAGE_ANALYSIS)
+
+#endif
+
 namespace WebKit {
 using namespace WebCore;
 using namespace WebKit;
@@ -10187,7 +10200,7 @@
             return;
 
         bool shouldAnalyzeImageAtLocation = ([&] {
-            if (!information.isImage)
+            if (!information.isImage && !canAttemptTextRecognitionForNonImageElements(information, strongSelf->_page->preferences()))
                 return false;
 
             if (!information.image)

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (285608 => 285609)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2021-11-10 22:49:56 UTC (rev 285608)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2021-11-11 00:03:06 UTC (rev 285609)
@@ -2940,6 +2940,9 @@
                 // FIXME: Is this heuristic still needed, now that block selection has been removed?
                 return InteractionInformationAtPosition::Selectability::UnselectableDueToLargeElementBounds;
             }
+
+            if (hostVideoElementIgnoringImageOverlay(*hitNode))
+                return InteractionInformationAtPosition::Selectability::UnselectableDueToMediaControls;
         }
 
         return InteractionInformationAtPosition::Selectability::Selectable;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to