Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[Live Text] Use iBeam cursor when hovering over selectable text insid…
…e image links https://bugs.webkit.org/show_bug.cgi?id=228700 rdar://81210248 Reviewed by Tim Horton. Source/WebCore: Make a couple of small adjustments to allow the cursor to change to an I-beam when hovering over selectable Live Text inside images in links, but only in the case where the computed cursor type is Auto. Currently, this always results in a Hand cursor type because of the link ancestor, despite the injected Live Text being selectable. Test: fast/images/text-recognition/mac/cursor-types-for-recognized-text.html * html/HTMLElement.cpp: (WebCore::HTMLElement::updateWithTextRecognitionResult): Drive-by fix an adjacent bug, wherein we try to check whether the image element has `user-select: none;` before the style has been resolved, which results in injecting selectable Live Text even when the page has explicitly disabled text selection on the image element. Instead, move this code to right after we update layout after ensuring the UA shadow DOM structure for Live Text, so that the bool flag is meaningful. * page/EventHandler.cpp: (WebCore::EventHandler::selectCursor): LayoutTests: Add a layout test that hovers over Live Text in several different image elements, and checks their respective cursor types. * fast/images/text-recognition/mac/cursor-types-for-recognized-text-expected.txt: Added. * fast/images/text-recognition/mac/cursor-types-for-recognized-text.html: Added. Canonical link: https://commits.webkit.org/240175@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280548 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
6 changed files
with
135 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
Testing <img id="inside-link"> | ||
PASS cursor is "IBeam" | ||
|
||
Testing <img id="cursor-zoom-in"> | ||
PASS cursor is "ZoomIn" | ||
|
||
Testing <img id="user-select-none-in-link"> | ||
PASS cursor is "Hand" | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<head> | ||
<script src="../../../../resources/js-test.js"></script> | ||
<style> | ||
img { | ||
width: 100px; | ||
height: 100px; | ||
box-sizing: border-box; | ||
border: 1px solid black; | ||
display: block; | ||
} | ||
|
||
a { | ||
display: block; | ||
} | ||
|
||
#cursor-zoom-in { | ||
top: 100px; | ||
cursor: zoom-in; | ||
} | ||
|
||
#user-select-none-in-link { | ||
top: 200px; | ||
-webkit-user-select: none; | ||
} | ||
</style> | ||
<script> | ||
addEventListener("load", () => { | ||
document.querySelectorAll("img").forEach(image => { | ||
internals.installImageOverlay(image, [ | ||
{ | ||
topLeft : new DOMPointReadOnly(0, 0.3), | ||
topRight : new DOMPointReadOnly(1, 0.3), | ||
bottomRight : new DOMPointReadOnly(1, 0.7), | ||
bottomLeft : new DOMPointReadOnly(0, 0.7), | ||
children: [{ | ||
text : "Hello", | ||
topLeft : new DOMPointReadOnly(0, 0.3), | ||
topRight : new DOMPointReadOnly(1, 0.3), | ||
bottomRight : new DOMPointReadOnly(1, 0.7), | ||
bottomLeft : new DOMPointReadOnly(0, 0.7), | ||
}], | ||
} | ||
]); | ||
}); | ||
|
||
function testImage(imageID, expectedResult) { | ||
let image = document.getElementById(imageID); | ||
let rect = image.getBoundingClientRect(); | ||
eventSender.mouseMoveTo(rect.left + rect.width / 2, rect.top + rect.height / 2); | ||
cursor = internals.getCurrentCursorInfo().match(/type=(\w+)\s/).pop(); | ||
debug(`\nTesting <img id="${imageID}">`); | ||
shouldBeEqualToString("cursor", expectedResult); | ||
} | ||
|
||
testImage("inside-link", "IBeam"); | ||
testImage("cursor-zoom-in", "ZoomIn"); | ||
testImage("user-select-none-in-link", "Hand"); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<a href="#"> | ||
<img id="inside-link" src="../../resources/green-400x400.png"></img> | ||
</a> | ||
<img id="cursor-zoom-in" src="../../resources/green-400x400.png"></img> | ||
<a href="#"> | ||
<img id="user-select-none-in-link" src="../../resources/green-400x400.png"></img> | ||
</a> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters