Changeset 286021 in webkit
- Timestamp:
- Nov 18, 2021, 12:48:15 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/images/text-recognition/mac/text-recognition-candidates-expected.txt (added)
-
LayoutTests/fast/images/text-recognition/mac/text-recognition-candidates.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/page/EventHandler.cpp (modified) (3 diffs)
-
Source/WebCore/page/EventHandler.h (modified) (2 diffs)
-
Source/WebCore/testing/Internals.cpp (modified) (2 diffs)
-
Source/WebCore/testing/Internals.h (modified) (1 diff)
-
Source/WebCore/testing/Internals.idl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r286011 r286021 1 2021-11-18 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [macOS] [Live Text] Avoid analyzing images in editable content 4 https://bugs.webkit.org/show_bug.cgi?id=233317 5 6 Reviewed by Megan Gardner. 7 8 Add a layout test to exercise the change. 9 10 * fast/images/text-recognition/mac/text-recognition-candidates-expected.txt: Added. 11 * fast/images/text-recognition/mac/text-recognition-candidates.html: Added. 12 1 13 2021-11-18 Yoshiaki Jitsukawa <yoshiaki.jitsukawa@sony.com> 2 14 -
trunk/Source/WebCore/ChangeLog
r286019 r286021 1 2021-11-18 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [macOS] [Live Text] Avoid analyzing images in editable content 4 https://bugs.webkit.org/show_bug.cgi?id=233317 5 6 Reviewed by Megan Gardner. 7 8 Make macOS Live Text behavior consistent with iOS, and avoid automatically triggering text recognition (Live 9 Text) when hovering over images in editable content. In addition to platform consistency, this also allows us to 10 avoid handling both image service controls and image overlay content inside editable image elements in Mail 11 compose. 12 13 Test: fast/images/text-recognition/mac/text-recognition-candidates.html 14 15 * page/EventHandler.cpp: 16 (WebCore::EventHandler::textRecognitionCandidateElement const): 17 18 Add the editability check here and return null. 19 20 * page/EventHandler.h: 21 22 Drive-by code cleanup -- move `textRecognitionCandidateElement` behind the `ENABLE(IMAGE_ANALYSIS)` compile-time 23 flag, since it's only used from image analysis code. 24 25 * testing/Internals.cpp: 26 (WebCore::Internals::textRecognitionCandidate const): 27 28 Add an internal testing hook to query the current text recognition candidate element (i.e. a suitable image that 29 is being hovered, or otherwise null). 30 31 * testing/Internals.h: 32 * testing/Internals.idl: 33 1 34 2021-11-18 Antoine Quint <graouts@webkit.org> 2 35 -
trunk/Source/WebCore/page/EventHandler.cpp
r285655 r286021 2525 2525 } 2526 2526 2527 #if ENABLE(IMAGE_ANALYSIS) 2528 2527 2529 RefPtr<Element> EventHandler::textRecognitionCandidateElement() const 2528 2530 { … … 2536 2538 return nullptr; 2537 2539 2540 if (candidateElement->hasEditableStyle()) 2541 return nullptr; 2542 2538 2543 auto renderer = candidateElement->renderer(); 2539 2544 if (!is<RenderImage>(renderer)) … … 2552 2557 return candidateElement; 2553 2558 } 2559 2560 #endif // ENABLE(IMAGE_ANALYSIS) 2554 2561 2555 2562 void EventHandler::updateMouseEventTargetNode(const AtomString& eventType, Node* targetNode, const PlatformMouseEvent& platformMouseEvent, FireMouseOverOut fireMouseOverOut) -
trunk/Source/WebCore/page/EventHandler.h
r285367 r286021 355 355 WEBCORE_EXPORT void invalidateClick(); 356 356 357 #if ENABLE(IMAGE_ANALYSIS) 358 WEBCORE_EXPORT RefPtr<Element> textRecognitionCandidateElement() const; 359 #endif 360 357 361 static bool scrollableAreaCanHandleEvent(const PlatformWheelEvent&, ScrollableArea&); 358 362 … … 362 366 static const Seconds TextDragDelay; 363 367 #endif 364 365 RefPtr<Element> textRecognitionCandidateElement() const;366 368 367 369 bool eventActivatedView(const PlatformMouseEvent&) const; -
trunk/Source/WebCore/testing/Internals.cpp
r286012 r286021 5776 5776 } 5777 5777 5778 #endif // ENABLE(IMAGE_ANALYSIS)5779 5780 5778 void Internals::requestTextRecognition(Element& element, RefPtr<VoidCallback>&& callback) 5781 5779 { … … 5786 5784 } 5787 5785 5788 #if ENABLE(IMAGE_ANALYSIS)5789 5786 page->chrome().client().requestTextRecognition(element, { }, [callback = WTFMove(callback)] (auto&&) { 5790 5787 if (callback) 5791 5788 callback->handleEvent(); 5792 5789 }); 5793 #else 5794 UNUSED_PARAM(element); 5795 if (callback) 5796 callback->handleEvent(); 5797 #endif 5798 } 5790 } 5791 5792 RefPtr<Element> Internals::textRecognitionCandidate() const 5793 { 5794 if (RefPtr frame = contextDocument()->frame()) 5795 return frame->eventHandler().textRecognitionCandidateElement(); 5796 5797 return nullptr; 5798 } 5799 5800 #endif // ENABLE(IMAGE_ANALYSIS) 5799 5801 5800 5802 void Internals::installImageOverlay(Element& element, Vector<ImageOverlayLine>&& lines) -
trunk/Source/WebCore/testing/Internals.h
r285984 r286021 920 920 }; 921 921 void installImageOverlay(Element&, Vector<ImageOverlayLine>&&); 922 923 #if ENABLE(IMAGE_ANALYSIS) 922 924 void requestTextRecognition(Element&, RefPtr<VoidCallback>&&); 925 RefPtr<Element> textRecognitionCandidate() const; 926 #endif 923 927 924 928 bool isSystemPreviewLink(Element&) const; -
trunk/Source/WebCore/testing/Internals.idl
r285610 r286021 940 940 boolean isSystemPreviewImage(Element element); 941 941 942 undefined requestTextRecognition(Element element, VoidCallback callback); 942 [Conditional=IMAGE_ANALYSIS] readonly attribute Element? textRecognitionCandidate; 943 [Conditional=IMAGE_ANALYSIS] undefined requestTextRecognition(Element element, VoidCallback callback); 943 944 undefined installImageOverlay(Element element, sequence<ImageOverlayLine> lines); 944 945
Note:
See TracChangeset
for help on using the changeset viewer.