- Revision
- 274396
- Author
- [email protected]
- Date
- 2021-03-13 22:51:31 -0800 (Sat, 13 Mar 2021)
Log Message
[iOS] Selecting the first word in an image overlay may select text in the previous line
https://bugs.webkit.org/show_bug.cgi?id=223153
Reviewed by Tim Horton.
Source/WebCore:
Add a (collapsible) newline at the start of each line of text in an image overlay, so that
`wordRangeFromPosition` will not include content from the previous line when selecting the first word in a
line inside an image overlay.
Test: fast/images/image-extraction/ios/select-word-in-image-overlay.html
* html/HTMLElement.cpp:
(WebCore::HTMLElement::updateWithImageExtractionResult):
LayoutTests:
Add a layout test to verify the behavior change.
* fast/images/image-extraction/ios/select-word-in-image-overlay-expected.txt: Added.
* fast/images/image-extraction/ios/select-word-in-image-overlay.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (274395 => 274396)
--- trunk/LayoutTests/ChangeLog 2021-03-14 03:32:31 UTC (rev 274395)
+++ trunk/LayoutTests/ChangeLog 2021-03-14 06:51:31 UTC (rev 274396)
@@ -1,5 +1,17 @@
2021-03-13 Wenson Hsieh <[email protected]>
+ [iOS] Selecting the first word in an image overlay may select text in the previous line
+ https://bugs.webkit.org/show_bug.cgi?id=223153
+
+ Reviewed by Tim Horton.
+
+ Add a layout test to verify the behavior change.
+
+ * fast/images/image-extraction/ios/select-word-in-image-overlay-expected.txt: Added.
+ * fast/images/image-extraction/ios/select-word-in-image-overlay.html: Added.
+
+2021-03-13 Wenson Hsieh <[email protected]>
+
Add support for accessibility image overlays in layout tests
https://bugs.webkit.org/show_bug.cgi?id=223146
Added: trunk/LayoutTests/fast/images/image-extraction/ios/select-word-in-image-overlay-expected.txt (0 => 274396)
--- trunk/LayoutTests/fast/images/image-extraction/ios/select-word-in-image-overlay-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/images/image-extraction/ios/select-word-in-image-overlay-expected.txt 2021-03-14 06:51:31 UTC (rev 274396)
@@ -0,0 +1,5 @@
+PASS selectionRects.length is 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/images/image-extraction/ios/select-word-in-image-overlay.html (0 => 274396)
--- trunk/LayoutTests/fast/images/image-extraction/ios/select-word-in-image-overlay.html (rev 0)
+++ trunk/LayoutTests/fast/images/image-extraction/ios/select-word-in-image-overlay.html 2021-03-14 06:51:31 UTC (rev 274396)
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+<style>
+img {
+ position: absolute;
+ top: 0;
+ left: 0;
+}
+</style>
+</head>
+<body>
+<img src=""
+<script>
+jsTestIsAsync = true;
+addEventListener("load", async () => {
+ let image = document.querySelector("img");
+ internals.installImageOverlay(image, [
+ {
+ text : "hello",
+ topLeft : new DOMPointReadOnly(0, 0),
+ topRight : new DOMPointReadOnly(1, 0),
+ bottomRight : new DOMPointReadOnly(1, 0.5),
+ bottomLeft : new DOMPointReadOnly(0, 0.5),
+ },
+ {
+ text : "world",
+ topLeft : new DOMPointReadOnly(0, 0.5),
+ topRight : new DOMPointReadOnly(1, 0.5),
+ bottomRight : new DOMPointReadOnly(1, 1),
+ bottomLeft : new DOMPointReadOnly(0, 1),
+ },
+ ]);
+ await UIHelper.longPressAtPoint(200, 300);
+ selectionRects = await UIHelper.waitForSelectionToAppear();
+ shouldBe("selectionRects.length", "1");
+ finishJSTest();
+});
+</script>
+</body>
+</html>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (274395 => 274396)
--- trunk/Source/WebCore/ChangeLog 2021-03-14 03:32:31 UTC (rev 274395)
+++ trunk/Source/WebCore/ChangeLog 2021-03-14 06:51:31 UTC (rev 274396)
@@ -1,5 +1,21 @@
2021-03-13 Wenson Hsieh <[email protected]>
+ [iOS] Selecting the first word in an image overlay may select text in the previous line
+ https://bugs.webkit.org/show_bug.cgi?id=223153
+
+ Reviewed by Tim Horton.
+
+ Add a (collapsible) newline at the start of each line of text in an image overlay, so that
+ `wordRangeFromPosition` will not include content from the previous line when selecting the first word in a
+ line inside an image overlay.
+
+ Test: fast/images/image-extraction/ios/select-word-in-image-overlay.html
+
+ * html/HTMLElement.cpp:
+ (WebCore::HTMLElement::updateWithImageExtractionResult):
+
+2021-03-13 Wenson Hsieh <[email protected]>
+
Add support for accessibility image overlays in layout tests
https://bugs.webkit.org/show_bug.cgi?id=223146
Modified: trunk/Source/WebCore/html/HTMLElement.cpp (274395 => 274396)
--- trunk/Source/WebCore/html/HTMLElement.cpp 2021-03-14 03:32:31 UTC (rev 274395)
+++ trunk/Source/WebCore/html/HTMLElement.cpp 2021-03-14 06:51:31 UTC (rev 274396)
@@ -1290,7 +1290,7 @@
child->classList().add(imageOverlayTextClass);
container->appendChild(child);
- child->appendChild(Text::create(document(), data.text));
+ child->appendChild(Text::create(document(), makeString('\n', data.text)));
child->appendChild(HTMLBRElement::create(document()));
IntSize originalSize { child->offsetWidth(), child->offsetHeight() };