forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1745435 - Make non-draggable & non-editable images easier to sele…
…ct. r=emilio Bug 1550869 made all the non-editable images return a `FrameTarget` with `userFrameEdge=true`. When the user moves the mouse pointer to select an image from its left edge, the mouse pointer needs to reach the right edge of the image in order to complete the selection. This makes it difficult to select an image at the end of a line. This patch restores the behavior to select a non-draggable & non-editable image to it was before bug 1550869. That is, we recognize the image selection when the mouse pointer moves passed the middle point of the image width (`OffsetsForSingleFrame`). Both blink and webkit have the same behavior, but no spec text dictates this behavior, so I mark the wpt test as "tentative". Differential Revision: https://phabricator.services.mozilla.com/D133960
- Loading branch information
Showing
2 changed files
with
52 additions
and
1 deletion.
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
49 changes: 49 additions & 0 deletions
49
testing/web-platform/tests/selection/select-end-of-line-image.tentative.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<meta charset="utf-8"> | ||
<title>Selection: Select the image at the end of the line</title> | ||
<link rel="author" title="Ting-Yu Lin" href="mailto:[email protected]"> | ||
<link rel="author" title="Mozilla" href="https://www.mozilla.org/"> | ||
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1745435"> | ||
|
||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/testdriver.js"></script> | ||
<script src="/resources/testdriver-actions.js"></script> | ||
<script src='/resources/testdriver-vendor.js'></script> | ||
|
||
<style> | ||
img { | ||
inline-size: 100px; | ||
block-size: 20px; | ||
background: orange; | ||
} | ||
</style> | ||
|
||
<body> | ||
You shouldn't see an orange image at the end of this line | ||
<img id="target" src='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"><text>hello</text></svg>'> | ||
</body> | ||
|
||
<script> | ||
promise_test(async function() { | ||
let target = document.getElementById("target"); | ||
let actions = new test_driver.Actions(); | ||
|
||
// Move the pointer from the left edge of the image, to the right for about | ||
// 3/4 width of the image. This should be sufficient to select the image. | ||
await actions.pointerMove(0, 10, {origin: target}) | ||
.pointerDown() | ||
.pointerMove(75, 10, {origin: target}) | ||
.pointerUp() | ||
.send(); | ||
|
||
// Delete the image to verify the image is selected. It's tricky to verify | ||
// it using Range API. | ||
window.getSelection().deleteFromDocument(); | ||
|
||
assert_equals(document.getElementById("target"), null, | ||
"The image should be selected and then deleted.") | ||
}, "Select image at the end of the line."); | ||
</script> | ||
</html> |