Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fix caret move by line when padding-top is set
Fix caret move by line when padding-top is set https://bugs.webkit.org/show_bug.cgi?id=248413 rdar://problem/102991672 Reviewed by Ryosuke Niwa. This patch is to align WebKit behavior with Gecko / Firefox and Blink / Chromium. Partial Merge - https://chromium.googlesource.com/chromium/blink/+/87805d6f9313997171b970d847e141a18b95dcf7 Moving carets by line, either forward or backward, could be prevented because the large part of the relevant code path for that case (previousLinePosition(), nextLinePosition(), etc.) uses int and IntPoint. This patch fixes all relevant functions to use LayoutUnit and LayoutPoint in VisibleUnits. * Source/WebCore/editing/VisibleUnits.cpp: (absoluteLineDirectionPointToLocalPointInBlock): Modify "IntPoint" and "int" to "LayoutPoint" and "LayoutUnit" (previousLinePosition): Ditto (nextLinePosition): Ditto (previousParagraphPosition): Ditto (nextParagraphPosition): Ditto * Source/WebCore/editing/VisibleUnits.h: Introduce 'LayoutUnit' class and use it in similar functions as our changes in .cpp file * LayoutTests/editing/selection/move-with-padding-top.html: Add Test Case * LayoutTests/editing/selection/move-with-padding-top-expected.txt: Add Test Case Expectation Canonical link: https://commits.webkit.org/259906@main
- Loading branch information
1 parent
47f7b57
commit 7e9c271
Showing
4 changed files
with
60 additions
and
12 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
LayoutTests/editing/selection/move-with-padding-top-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,5 @@ | ||
|
||
PASS padding-top=0 | ||
PASS padding-top=4pt | ||
PASS padding-top=4.8pt | ||
|
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,42 @@ | ||
<!DOCTYPE html> | ||
<style> | ||
html, body { | ||
margin: 0; | ||
} | ||
#container { | ||
width:300px; | ||
} | ||
</style> | ||
<script src="../../resources/testharness.js"></script> | ||
<script src="../../resources/testharnessreport.js"></script> | ||
<div id="container" contenteditable="true"> | ||
<p><span style="font-size:24px">Caret navigation using up arrow key does not work</span></p> | ||
</div> | ||
<script> | ||
var p = document.getElementsByTagName("p")[0]; | ||
var selection = window.getSelection(); | ||
|
||
testMoveByLineWithPaddingTop("0"); | ||
testMoveByLineWithPaddingTop("4pt"); | ||
testMoveByLineWithPaddingTop("4.8pt"); | ||
|
||
function testMoveByLineWithPaddingTop(paddingTop) { | ||
test(function () { | ||
p.style.paddingTop = paddingTop; | ||
var textNode = document.getElementsByTagName("span")[0].firstChild; | ||
selection.collapse(textNode, 1); // avoid line-top not to be bothered by affinity | ||
var beforeRect = selection.getRangeAt(0).getClientRects()[0]; | ||
|
||
selection.modify("move", "forward", "line"); | ||
var forwardRect = selection.getRangeAt(0).getClientRects()[0]; | ||
assert_greater_than(forwardRect.top, beforeRect.top, "move forward by line"); | ||
|
||
selection.modify("move", "backward", "line"); | ||
var backwardRect = selection.getRangeAt(0).getClientRects()[0]; | ||
assert_equals(backwardRect.top, beforeRect.top, "move backward by line"); | ||
}, "padding-top=" + paddingTop); | ||
} | ||
|
||
if (window.testRunner) | ||
container.style.display = "none"; | ||
</script> |
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