New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Live Text text selection in image goes offscreen in Mail #13865
Conversation
EWS run on previous version of this PR (hash e5915a7) |
@@ -280,6 +280,9 @@ static Elements updateSubtree(HTMLElement& element, const TextRecognitionResult& | |||
#endif // ENABLE(MODERN_MEDIA_CONTROLS) | |||
|
|||
if (RefPtr shadowRoot = element.shadowRoot()) { | |||
if (auto* renderer = dynamicDowncast<RenderImage>(element.renderer())) | |||
renderer->setHasImageOverlay(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm basically just co-opting "hasImageOverlay" to mean "has shadow content", since that's what it effectively means, and I figured this was preferable to introducing a new method / member variable to RenderImage
Is it possible to write a test for this? |
I tried to, but I wasn't sure how to artificially get it into the same state as Mail such that the RenderImage constructor is called before |
oh maybe I can replicate it if I use < attachment> |
Yeah, makes sense β |
EWS run on previous version of this PR (hash 2e8b50a) |
EWS run on previous version of this PR (hash 19fd020) |
LayoutTests/fast/images/text-recognition/image-overlay-with-attachment-element.html
Outdated
Show resolved
Hide resolved
LayoutTests/fast/images/text-recognition/image-overlay-with-attachment-element.html
Outdated
Show resolved
Hide resolved
EWS run on current version of this PR (hash 14221b0) |
https://bugs.webkit.org/show_bug.cgi?id=256772 rdar://108597859 Reviewed by Wenson Hsieh. In `ImageOverlay::updateWithTextRecognitionResult`, the `sizeBeforeTransform` is empty in the case of selecting text in an image in Mail. This is because the renderer returned by `textContainer->renderBoxModelObject()` is `nullptr`, so `sizeBeforeTransform` is never set. This renderer is null because it is never created, because `shouldCreateRenderer` returns `false`, ultimately because `RenderImage::hasShadowContent` returns `false`. This method returns `false` because `m_hasImageOverlay` is `false`. In the constructor of `RenderImage`, `m_hasImageOverlay` is initialized to the result of `ImageOverlay::hasOverlay`. _This_ method returns `false` because the shadow root has no element who's id is that of `imageOverlayElementIdentifier`. `updateSubtree` in `ImageOverlay` is what is responsible for setting the id of the root shadow element to `imageOverlayElementIdentifier`. In the case of Safari, `updateSubtree` is called first, and then the constructor of `RenderImage` is called, which ensures that the renderer is ultimately created. However, in Mail, the `RenderImage` constructor is called first, and so at that time there's no `imageOverlayElementIdentifier` element, which leads to the renderer never being created. This PR fixes this by ensuring that `RenderImage::hasShadowContent` returns `true` if the element has a shadow root in `updateSubtree`, by setting `RenderImage::setHasImageOverlay`. * LayoutTests/fast/images/text-recognition/image-overlay-with-attachment-element-expected.txt: Added. * LayoutTests/fast/images/text-recognition/image-overlay-with-attachment-element.html: Added. * Source/WebCore/dom/ImageOverlay.cpp: (WebCore::ImageOverlay::updateSubtree): Canonical link: https://commits.webkit.org/264156@main
14221b0
to
9477772
Compare
Committed 264156@main (9477772): https://commits.webkit.org/264156@main Reviewed commits have been landed. Closing PR #13865 and removing active labels. |
9477772
14221b0