Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 9477772ce229c822b9fffd49ea9889569cd9496f
      
https://github.com/WebKit/WebKit/commit/9477772ce229c822b9fffd49ea9889569cd9496f
  Author: Richard Robinson <[email protected]>
  Date:   2023-05-17 (Wed, 17 May 2023)

  Changed paths:
    A 
LayoutTests/fast/images/text-recognition/image-overlay-with-attachment-element-expected.txt
    A 
LayoutTests/fast/images/text-recognition/image-overlay-with-attachment-element.html
    M Source/WebCore/dom/ImageOverlay.cpp

  Log Message:
  -----------
  Live Text text selection in image goes offscreen in Mail
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


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to