Title: [278531] trunk/Source/WebKit
Revision
278531
Author
[email protected]
Date
2021-06-05 20:21:13 -0700 (Sat, 05 Jun 2021)

Log Message

[macOS] Dictionary lookup highlights in image overlays should include background content
https://bugs.webkit.org/show_bug.cgi?id=226686

Reviewed by Tim Horton.

Make a few minor adjustments to text indicator options on macOS when triggering Look Up.

* WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
(WebKit::WebPage::dictionaryPopupInfoForRange):
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::performImmediateActionHitTestAtLocation):

Add both `PaintAllContent` and `PaintBackgrounds` options when creating text indicators, in the case where the
indicated range is inside an image overlay.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (278530 => 278531)


--- trunk/Source/WebKit/ChangeLog	2021-06-06 01:18:09 UTC (rev 278530)
+++ trunk/Source/WebKit/ChangeLog	2021-06-06 03:21:13 UTC (rev 278531)
@@ -1,5 +1,22 @@
 2021-06-05  Wenson Hsieh  <[email protected]>
 
+        [macOS] Dictionary lookup highlights in image overlays should include background content
+        https://bugs.webkit.org/show_bug.cgi?id=226686
+
+        Reviewed by Tim Horton.
+
+        Make a few minor adjustments to text indicator options on macOS when triggering Look Up.
+
+        * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
+        (WebKit::WebPage::dictionaryPopupInfoForRange):
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::performImmediateActionHitTestAtLocation):
+
+        Add both `PaintAllContent` and `PaintBackgrounds` options when creating text indicators, in the case where the
+        indicated range is inside an image overlay.
+
+2021-06-05  Wenson Hsieh  <[email protected]>
+
         [macOS] Move DataDetectors softlinking in DataDetectorsSPI.h out into a separate PAL header
         https://bugs.webkit.org/show_bug.cgi?id=226669
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm (278530 => 278531)


--- trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm	2021-06-06 01:18:09 UTC (rev 278530)
+++ trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm	2021-06-06 03:21:13 UTC (rev 278531)
@@ -200,6 +200,9 @@
 #endif // PLATFORM(MAC)
 
     OptionSet<TextIndicatorOption> indicatorOptions { TextIndicatorOption::UseBoundingRectAndPaintAllContentForComplexRanges };
+    if (HTMLElement::isInsideImageOverlay(range))
+        indicatorOptions.add({ TextIndicatorOption::PaintAllContent, TextIndicatorOption::PaintBackgrounds });
+
     if (presentationTransition == TextIndicatorPresentationTransition::BounceAndCrossfade)
         indicatorOptions.add(TextIndicatorOption::IncludeSnapshotWithSelectionHighlight);
     

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (278530 => 278531)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2021-06-06 01:18:09 UTC (rev 278530)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2021-06-06 03:21:13 UTC (rev 278531)
@@ -877,10 +877,18 @@
 
     auto selectionRange = corePage()->focusController().focusedOrMainFrame().selection().selection().firstRange();
 
+    auto indicatorOptions = [&](const SimpleRange& range) {
+        OptionSet<TextIndicatorOption> options { TextIndicatorOption::UseBoundingRectAndPaintAllContentForComplexRanges };
+        if (HTMLElement::isInsideImageOverlay(range))
+            options.add({ TextIndicatorOption::PaintAllContent, TextIndicatorOption::PaintBackgrounds });
+        return options;
+    };
+
     URL absoluteLinkURL = hitTestResult.absoluteLinkURL();
-    Element* URLElement = hitTestResult.URLElement();
-    if (!absoluteLinkURL.isEmpty() && URLElement)
-        immediateActionResult.linkTextIndicator = TextIndicator::createWithRange(makeRangeSelectingNodeContents(*URLElement), { TextIndicatorOption::UseBoundingRectAndPaintAllContentForComplexRanges }, TextIndicatorPresentationTransition::FadeIn);
+    if (auto urlElement = makeRefPtr(hitTestResult.URLElement()); !absoluteLinkURL.isEmpty() && urlElement) {
+        auto elementRange = makeRangeSelectingNodeContents(*urlElement);
+        immediateActionResult.linkTextIndicator = TextIndicator::createWithRange(elementRange, indicatorOptions(elementRange), TextIndicatorPresentationTransition::FadeIn);
+    }
 
     if (auto lookupResult = lookupTextAtLocation(locationInViewCoordinates)) {
         auto [lookupRange, options] = WTFMove(*lookupResult);
@@ -908,7 +916,7 @@
         pageOverlayDidOverrideDataDetectors = true;
         immediateActionResult.detectedDataActionContext = actionContext->context.get();
         immediateActionResult.detectedDataBoundingBox = view->contentsToWindow(enclosingIntRect(unitedBoundingBoxes(RenderObject::absoluteTextQuads(actionContext->range))));
-        immediateActionResult.detectedDataTextIndicator = TextIndicator::createWithRange(actionContext->range, { TextIndicatorOption::UseBoundingRectAndPaintAllContentForComplexRanges }, TextIndicatorPresentationTransition::FadeIn);
+        immediateActionResult.detectedDataTextIndicator = TextIndicator::createWithRange(actionContext->range, indicatorOptions(actionContext->range), TextIndicatorPresentationTransition::FadeIn);
         immediateActionResult.detectedDataOriginatingPageOverlay = overlay->pageOverlayID();
         break;
     }
@@ -918,8 +926,7 @@
         if (auto result = DataDetection::detectItemAroundHitTestResult(hitTestResult)) {
             immediateActionResult.detectedDataActionContext = WTFMove(result->actionContext);
             immediateActionResult.detectedDataBoundingBox = result->boundingBox;
-            immediateActionResult.detectedDataTextIndicator = TextIndicator::createWithRange(result->range,
-                { TextIndicatorOption::UseBoundingRectAndPaintAllContentForComplexRanges }, TextIndicatorPresentationTransition::FadeIn);
+            immediateActionResult.detectedDataTextIndicator = TextIndicator::createWithRange(result->range, indicatorOptions(result->range), TextIndicatorPresentationTransition::FadeIn);
         }
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to