-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Incorrect caret position in empty elements with a vertical writing mode
https://bugs.webkit.org/show_bug.cgi?id=248322 rdar://102652127 Reviewed by Tim Nguyen. Caret rect computation for empty elements does not fully account for vertical writing mode. Fix by consistently using logical values. * LayoutTests/editing/selection/caret-in-empty-block-vertical-horizontal-rtl-text-indent-padding-expected.txt: Added. * LayoutTests/editing/selection/caret-in-empty-block-vertical-horizontal-rtl-text-indent-padding.html: Added. * LayoutTests/editing/selection/caret-in-empty-block-vertical-rl-rtl-expected.txt: Added. * LayoutTests/editing/selection/caret-in-empty-block-vertical-rl-rtl.html: Added. * LayoutTests/editing/selection/caret-in-empty-inline-vertical-rl-rtl-expected.txt: Added. * LayoutTests/editing/selection/caret-in-empty-inline-vertical-rl-rtl.html: Added. * Source/WebCore/rendering/CaretRectComputation.cpp: (WebCore::computeCaretRectForEmptyElement): (WebCore::computeCaretRectForBlock): (WebCore::computeCaretRectForInline): * Source/WebCore/rendering/RenderBoxModelObject.h: * Source/WebCore/rendering/RenderBoxModelObjectInlines.h: (WebCore::RenderBoxModelObject::borderAndPaddingLogicalHeight const): (WebCore::RenderBoxModelObject::borderAndPaddingLogicalLeft const): (WebCore::RenderBoxModelObject::borderAndPaddingLogicalRight const): (WebCore::RenderBoxModelObject::borderAndPaddingEnd const): Canonical link: https://commits.webkit.org/270707@main
- Loading branch information
Showing
9 changed files
with
190 additions
and
8 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...g/selection/caret-in-empty-block-vertical-horizontal-rtl-text-indent-padding-expected.txt
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,11 @@ | ||
This test verifies that an empty block contenteditable element with indented text and padding, and right-to-left text direction, gets a valid caret rect. | ||
|
||
|
||
PASS caretRect.left is correct. | ||
PASS caretRect.top is correct. | ||
PASS caretRect.width is correct. | ||
PASS caretRect.height is correct. | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
49 changes: 49 additions & 0 deletions
49
...s/editing/selection/caret-in-empty-block-vertical-horizontal-rtl-text-indent-padding.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> | ||
<head> | ||
<script src="../../resources/js-test.js" type="text/javascript"></script> | ||
<style> | ||
|
||
.hidden { | ||
display: none; | ||
} | ||
|
||
#text, #emptyBlock { | ||
border: 1px solid black; | ||
inline-size: 100px; | ||
text-indent: 20px; | ||
padding: 10px 20px 30px 40px; | ||
direction: rtl; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<p>This test verifies that an empty block contenteditable element with indented text and padding, and right-to-left text direction, gets a valid caret rect.</p> | ||
<div id="text" contenteditable>Some text.</div> | ||
<div id="emptyBlock" contenteditable></div><br> | ||
<div id="console"></div> | ||
</body> | ||
<script> | ||
var text = document.getElementById("text"); | ||
var emptyBlock = document.getElementById("emptyBlock"); | ||
|
||
if (window.internals) { | ||
emptyBlock.classList.toggle("hidden"); | ||
getSelection().collapse(text, 0); | ||
var textCaretRect = internals.absoluteCaretBounds(); | ||
|
||
text.classList.toggle("hidden"); | ||
emptyBlock.classList.toggle("hidden"); | ||
|
||
getSelection().collapse(emptyBlock, 0); | ||
var emptyBlockCaretRect = internals.absoluteCaretBounds(); | ||
|
||
['left', 'top', 'width', 'height'].forEach((property) => { | ||
if (Math.abs(emptyBlockCaretRect[property] - textCaretRect[property]) <= 1) | ||
testPassed(`caretRect.${property} is correct.`); | ||
else | ||
testFailed(`caretRect.${property} is incorrect.`); | ||
}); | ||
} | ||
</script> | ||
</html> |
11 changes: 11 additions & 0 deletions
11
LayoutTests/editing/selection/caret-in-empty-block-vertical-rl-rtl-expected.txt
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,11 @@ | ||
This test verifies that an empty block contenteditable element with a vertical writing mode, and right-to-left text direction, gets a valid caret rect. | ||
|
||
|
||
PASS caretRect.left is correct. | ||
PASS caretRect.top is correct. | ||
PASS caretRect.width is correct. | ||
PASS caretRect.height is correct. | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
48 changes: 48 additions & 0 deletions
48
LayoutTests/editing/selection/caret-in-empty-block-vertical-rl-rtl.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,48 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="../../resources/js-test.js" type="text/javascript"></script> | ||
<style> | ||
|
||
.hidden { | ||
display: none; | ||
} | ||
|
||
#text, #emptyBlock { | ||
border: 1px solid black; | ||
inline-size: 100px; | ||
writing-mode: vertical-rl; | ||
direction: rtl; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<p>This test verifies that an empty block contenteditable element with a vertical writing mode, and right-to-left text direction, gets a valid caret rect.</p> | ||
<div id="text" contenteditable>Some text.</div> | ||
<div id="emptyBlock" contenteditable></div><br> | ||
<div id="console"></div> | ||
</body> | ||
<script> | ||
var text = document.getElementById("text"); | ||
var emptyBlock = document.getElementById("emptyBlock"); | ||
|
||
if (window.internals) { | ||
emptyBlock.classList.toggle("hidden"); | ||
getSelection().collapse(text, 0); | ||
var textCaretRect = internals.absoluteCaretBounds(); | ||
|
||
text.classList.toggle("hidden"); | ||
emptyBlock.classList.toggle("hidden"); | ||
|
||
getSelection().collapse(emptyBlock, 0); | ||
var emptyBlockCaretRect = internals.absoluteCaretBounds(); | ||
|
||
['left', 'top', 'width', 'height'].forEach((property) => { | ||
if (Math.abs(emptyBlockCaretRect[property] - textCaretRect[property]) <= 1) | ||
testPassed(`caretRect.${property} is correct.`); | ||
else | ||
testFailed(`caretRect.${property} is incorrect.`); | ||
}); | ||
} | ||
</script> | ||
</html> |
11 changes: 11 additions & 0 deletions
11
LayoutTests/editing/selection/caret-in-empty-inline-vertical-rl-rtl-expected.txt
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,11 @@ | ||
This test verifies that an empty inline contenteditable element with a vertical writing mode, and right-to-left text direction, gets a valid caret rect. | ||
|
||
|
||
PASS caretRect.left is correct. | ||
PASS caretRect.top is correct. | ||
PASS caretRect.width is correct. | ||
PASS caretRect.height is correct. | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
48 changes: 48 additions & 0 deletions
48
LayoutTests/editing/selection/caret-in-empty-inline-vertical-rl-rtl.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,48 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="../../resources/js-test.js" type="text/javascript"></script> | ||
<style> | ||
|
||
.hidden { | ||
display: none; | ||
} | ||
|
||
#text, #emptyInline { | ||
border: 1px solid black; | ||
inline-size: 100px; | ||
writing-mode: vertical-rl; | ||
direction: rtl; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<p>This test verifies that an empty inline contenteditable element with a vertical writing mode, and right-to-left text direction, gets a valid caret rect.</p> | ||
<div id="text" contenteditable>Some text.</div> | ||
<div id="emptyInline" contenteditable></div><br> | ||
<div id="console"></div> | ||
</body> | ||
<script> | ||
var text = document.getElementById("text"); | ||
var emptyInline = document.getElementById("emptyInline"); | ||
|
||
if (window.internals) { | ||
emptyInline.classList.toggle("hidden"); | ||
getSelection().collapse(text, 0); | ||
var textCaretRect = internals.absoluteCaretBounds(); | ||
|
||
text.classList.toggle("hidden"); | ||
emptyInline.classList.toggle("hidden"); | ||
|
||
getSelection().collapse(emptyInline, 0); | ||
var emptyInlineCaretRect = internals.absoluteCaretBounds(); | ||
|
||
['left', 'top', 'width', 'height'].forEach((property) => { | ||
if (Math.abs(emptyInlineCaretRect[property] - textCaretRect[property]) <= 1) | ||
testPassed(`caretRect.${property} is correct.`); | ||
else | ||
testFailed(`caretRect.${property} is incorrect.`); | ||
}); | ||
} | ||
</script> | ||
</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