Changeset 282740 in webkit
- Timestamp:
- Sep 19, 2021, 5:10:37 PM (4 years ago)
- Location:
- trunk/Source
- Files:
-
- 7 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/html/HTMLVideoElement.h (modified) (1 diff)
-
WebCore/page/EventHandler.cpp (modified) (5 diffs)
-
WebCore/page/EventHandler.h (modified) (1 diff)
-
WebCore/rendering/RenderVideo.h (modified) (1 diff)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/WebProcess/WebCoreSupport/ShareableBitmapUtilities.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r282738 r282740 1 2021-09-19 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Teach `WebKit::createShareableBitmap` to snapshot video elements 4 https://bugs.webkit.org/show_bug.cgi?id=230468 5 6 Reviewed by Tim Horton. 7 8 Now that `createShareableBitmap` may return images for video elements, we need to ensure that we explicitly 9 avoid allowing Live Text in video elements, since doing so will (1) break built-in platform media controls, 10 which also share the same shadow root, and (2) lead to confusing results when playing or seeking in videos, 11 since the recognized text falls out of sync with the video frame. 12 13 * html/HTMLVideoElement.h: 14 * page/EventHandler.cpp: 15 (WebCore::EventHandler::textRecognitionCandidateElement const): 16 17 For the above reasons, we refactor logic to check if the currently hovered node is a candidate for text 18 recognition, such that the video element check is consolidated all in one place. 19 20 (WebCore::EventHandler::updateMouseEventTargetNode): 21 (WebCore::EventHandler::textRecognitionHoverTimerFired): 22 * page/EventHandler.h: 23 * rendering/RenderVideo.h: 24 1 25 2021-09-19 Alan Bujtas <zalan@apple.com> 2 26 -
trunk/Source/WebCore/html/HTMLVideoElement.h
r278277 r282740 78 78 void paintCurrentFrameInContext(GraphicsContext&, const FloatRect&); 79 79 80 RefPtr<NativeImage> nativeImageForCurrentTime();80 WEBCORE_EXPORT RefPtr<NativeImage> nativeImageForCurrentTime(); 81 81 82 82 WEBCORE_EXPORT bool shouldDisplayPosterImage() const; -
trunk/Source/WebCore/page/EventHandler.cpp
r282480 r282740 64 64 #include "HTMLInputElement.h" 65 65 #include "HTMLNames.h" 66 #include "HTMLVideoElement.h" 66 67 #include "HitTestRequest.h" 67 68 #include "HitTestResult.h" … … 84 85 #include "Range.h" 85 86 #include "RenderFrameSet.h" 87 #include "RenderImage.h" 86 88 #include "RenderLayer.h" 87 89 #include "RenderLayerScrollableArea.h" … … 2513 2515 } 2514 2516 2517 RefPtr<Element> EventHandler::textRecognitionCandidateElement() const 2518 { 2519 RefPtr shadowHost = m_elementUnderMouse ? m_elementUnderMouse->shadowHost() : nullptr; 2520 if (!shadowHost) 2521 return nullptr; 2522 2523 auto renderer = shadowHost->renderer(); 2524 if (!is<RenderImage>(renderer)) 2525 return nullptr; 2526 2527 if (is<HTMLVideoElement>(*shadowHost)) 2528 return nullptr; 2529 2530 return shadowHost; 2531 } 2532 2515 2533 void EventHandler::updateMouseEventTargetNode(const AtomString& eventType, Node* targetNode, const PlatformMouseEvent& platformMouseEvent, FireMouseOverOut fireMouseOverOut) 2516 2534 { … … 2532 2550 #if ENABLE(IMAGE_ANALYSIS) 2533 2551 if (m_frame.settings().preferInlineTextSelectionInImages()) { 2534 if (! m_elementUnderMouse || !is<RenderImage>(m_elementUnderMouse->renderer()))2552 if (!textRecognitionCandidateElement()) 2535 2553 m_textRecognitionHoverTimer.stop(); 2536 2554 else if (!platformMouseEvent.movementDelta().isZero()) … … 3411 3429 void EventHandler::textRecognitionHoverTimerFired() 3412 3430 { 3413 if (!m_elementUnderMouse || !is<RenderImage>(m_elementUnderMouse->renderer())) 3431 auto element = this->textRecognitionCandidateElement(); 3432 if (!element) 3414 3433 return; 3415 3434 3416 3435 if (auto* page = m_frame.page()) 3417 page->chrome().client().requestTextRecognition(* m_elementUnderMouse);3436 page->chrome().client().requestTextRecognition(*element); 3418 3437 } 3419 3438 -
trunk/Source/WebCore/page/EventHandler.h
r281247 r282740 364 364 #endif 365 365 366 RefPtr<Element> textRecognitionCandidateElement() const; 367 366 368 bool eventActivatedView(const PlatformMouseEvent&) const; 367 369 bool updateSelectionForMouseDownDispatchingSelectStart(Node*, const VisibleSelection&, TextGranularity); -
trunk/Source/WebCore/rendering/RenderVideo.h
r269407 r282740 39 39 virtual ~RenderVideo(); 40 40 41 HTMLVideoElement& videoElement() const;41 WEBCORE_EXPORT HTMLVideoElement& videoElement() const; 42 42 43 43 WEBCORE_EXPORT IntRect videoBox() const; -
trunk/Source/WebKit/ChangeLog
r282712 r282740 1 2021-09-19 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Teach `WebKit::createShareableBitmap` to snapshot video elements 4 https://bugs.webkit.org/show_bug.cgi?id=230468 5 6 Reviewed by Tim Horton. 7 8 `createShareableBitmap` currently only returns a non-null image bitmap for image renderers that have cached 9 images; notably, this omits video elements. For use in future patches, we should allow this helper function to 10 handle video elements by snapshotting the current frame of the video. 11 12 * WebProcess/WebCoreSupport/ShareableBitmapUtilities.cpp: 13 (WebKit::createShareableBitmap): 14 1 15 2021-09-17 Alex Christensen <achristensen@webkit.org> 2 16 -
trunk/Source/WebKit/WebProcess/WebCoreSupport/ShareableBitmapUtilities.cpp
r280271 r282740 37 37 #include <WebCore/PlatformScreen.h> 38 38 #include <WebCore/RenderImage.h> 39 #include <WebCore/RenderVideo.h> 39 40 40 41 namespace WebKit { … … 71 72 } 72 73 74 if (is<RenderVideo>(renderImage)) { 75 auto& renderVideo = downcast<RenderVideo>(renderImage); 76 Ref video = renderVideo.videoElement(); 77 auto image = video->nativeImageForCurrentTime(); 78 if (!image) 79 return { }; 80 81 auto imageSize = image->size(); 82 if (imageSize.isEmpty() || imageSize.width() <= 1 || imageSize.height() <= 1) 83 return { }; 84 85 auto bitmap = ShareableBitmap::createShareable(imageSize, { WTFMove(colorSpaceForBitmap) }); 86 if (!bitmap) 87 return { }; 88 89 auto context = bitmap->createGraphicsContext(); 90 if (!context) 91 return { }; 92 93 context->drawNativeImage(*image, imageSize, FloatRect { { }, imageSize }, FloatRect { { }, imageSize }); 94 return bitmap; 95 } 96 73 97 auto* cachedImage = renderImage.cachedImage(); 74 98 if (!cachedImage || cachedImage->errorOccurred())
Note:
See TracChangeset
for help on using the changeset viewer.