Diff
Modified: trunk/LayoutTests/ChangeLog (260366 => 260367)
--- trunk/LayoutTests/ChangeLog 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/LayoutTests/ChangeLog 2020-04-20 15:53:48 UTC (rev 260367)
@@ -1,3 +1,32 @@
+2020-04-20 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Oversized caret and selection rects in text fields on ganji.com and netflix.com/login
+ https://bugs.webkit.org/show_bug.cgi?id=210622
+ <rdar://problem/45945636>
+
+ Reviewed by Darin Adler.
+
+ Rebaseline existing tests, and add a new test to verify that caret and selection rects do not extend to match
+ the line height in empty and non-empty editable elements, in both horizontal and vertical writing modes.
+
+ * editing/selection/ios/absolute-selection-after-scroll-expected.txt:
+ * editing/selection/ios/absolute-selection-after-scroll.html:
+ * editing/selection/ios/change-selection-after-tapping-focused-element-expected.txt:
+ * editing/selection/ios/change-selection-after-tapping-focused-element.html:
+ * editing/selection/ios/fixed-selection-after-scroll-expected.txt:
+ * editing/selection/ios/fixed-selection-after-scroll.html:
+ * editing/selection/ios/selection-after-changing-text-with-callout-menu-expected.txt:
+ * editing/selection/ios/selection-after-changing-text-with-callout-menu.html:
+ * editing/selection/ios/selection-handles-after-touch-end-expected.txt:
+ * editing/selection/ios/update-selection-after-overflow-scroll-expected.txt:
+ * editing/selection/ios/update-selection-after-overflow-scroll.html:
+ * editing/selection/selection-and-caret-do-not-extend-to-line-height-expected.txt: Added.
+ * editing/selection/selection-and-caret-do-not-extend-to-line-height.html: Added.
+ * fast/repaint/focus-ring-repaint-expected.txt:
+ * platform/ios/editing/selection/ios/selection-handles-after-touch-end-expected.txt: Removed.
+
+ Delete this redundant test expectation.
+
2020-04-20 Youenn Fablet <you...@apple.com>
Safari doesn't apply frameRate limit when request stream from Camera
Modified: trunk/LayoutTests/editing/selection/ios/absolute-selection-after-scroll-expected.txt (260366 => 260367)
--- trunk/LayoutTests/editing/selection/ios/absolute-selection-after-scroll-expected.txt 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/LayoutTests/editing/selection/ios/absolute-selection-after-scroll-expected.txt 2020-04-20 15:53:48 UTC (rev 260367)
@@ -1,13 +1,13 @@
PASS initialSelectionRects.length is 1
PASS initialSelectionRects[0].left is 0
-PASS initialSelectionRects[0].top is 0
+PASS initialSelectionRects[0].top is 2
PASS initialSelectionRects[0].width is 309
-PASS initialSelectionRects[0].height is 114
+PASS initialSelectionRects[0].height is 112
PASS finalSelectionRects.length is 1
PASS finalSelectionRects[0].left is 0
-PASS finalSelectionRects[0].top is 0
+PASS finalSelectionRects[0].top is 2
PASS finalSelectionRects[0].width is 309
-PASS finalSelectionRects[0].height is 114
+PASS finalSelectionRects[0].height is 112
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/editing/selection/ios/absolute-selection-after-scroll.html (260366 => 260367)
--- trunk/LayoutTests/editing/selection/ios/absolute-selection-after-scroll.html 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/LayoutTests/editing/selection/ios/absolute-selection-after-scroll.html 2020-04-20 15:53:48 UTC (rev 260367)
@@ -51,9 +51,9 @@
initialSelectionRects = rects;
shouldBe("initialSelectionRects.length", "1");
shouldBe("initialSelectionRects[0].left", "0");
- shouldBe("initialSelectionRects[0].top", "0");
+ shouldBe("initialSelectionRects[0].top", "2");
shouldBe("initialSelectionRects[0].width", "309");
- shouldBe("initialSelectionRects[0].height", "114");
+ shouldBe("initialSelectionRects[0].height", "112");
document.scrollingElement.scrollTop += 5000;
return UIHelper.getUISelectionRects();
})
@@ -61,9 +61,9 @@
finalSelectionRects = rects;
shouldBe("finalSelectionRects.length", "1");
shouldBe("finalSelectionRects[0].left", "0");
- shouldBe("finalSelectionRects[0].top", "0");
+ shouldBe("finalSelectionRects[0].top", "2");
shouldBe("finalSelectionRects[0].width", "309");
- shouldBe("finalSelectionRects[0].height", "114");
+ shouldBe("finalSelectionRects[0].height", "112");
finishJSTest();
});
}
Modified: trunk/LayoutTests/editing/selection/ios/change-selection-after-tapping-focused-element-expected.txt (260366 => 260367)
--- trunk/LayoutTests/editing/selection/ios/change-selection-after-tapping-focused-element-expected.txt 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/LayoutTests/editing/selection/ios/change-selection-after-tapping-focused-element-expected.txt 2020-04-20 15:53:48 UTC (rev 260367)
@@ -5,9 +5,9 @@
PASS selectionRects.length is 1
PASS selectionRects[0].left is 2
-PASS selectionRects[0].top is 2
+PASS selectionRects[0].top is 4
PASS selectionRects[0].width is 309
-PASS selectionRects[0].height is 114
+PASS selectionRects[0].height is 112
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/editing/selection/ios/change-selection-after-tapping-focused-element.html (260366 => 260367)
--- trunk/LayoutTests/editing/selection/ios/change-selection-after-tapping-focused-element.html 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/LayoutTests/editing/selection/ios/change-selection-after-tapping-focused-element.html 2020-04-20 15:53:48 UTC (rev 260367)
@@ -54,9 +54,9 @@
window.selectionRects = selectionRects;
shouldBe("selectionRects.length", "1");
shouldBe("selectionRects[0].left", "2");
- shouldBe("selectionRects[0].top", "2");
+ shouldBe("selectionRects[0].top", "4");
shouldBe("selectionRects[0].width", "309");
- shouldBe("selectionRects[0].height", "114");
+ shouldBe("selectionRects[0].height", "112");
finishJSTest();
});
Modified: trunk/LayoutTests/editing/selection/ios/fixed-selection-after-scroll-expected.txt (260366 => 260367)
--- trunk/LayoutTests/editing/selection/ios/fixed-selection-after-scroll-expected.txt 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/LayoutTests/editing/selection/ios/fixed-selection-after-scroll-expected.txt 2020-04-20 15:53:48 UTC (rev 260367)
@@ -1,13 +1,13 @@
PASS initialSelectionRects.length is 1
PASS initialSelectionRects[0].left is 0
-PASS initialSelectionRects[0].top is 0
+PASS initialSelectionRects[0].top is 2
PASS initialSelectionRects[0].width is 309
-PASS initialSelectionRects[0].height is 114
+PASS initialSelectionRects[0].height is 112
PASS finalSelectionRects.length is 1
PASS finalSelectionRects[0].left is 0
-PASS finalSelectionRects[0].top is 5000
+PASS finalSelectionRects[0].top is 5002
PASS finalSelectionRects[0].width is 309
-PASS finalSelectionRects[0].height is 114
+PASS finalSelectionRects[0].height is 112
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/editing/selection/ios/fixed-selection-after-scroll.html (260366 => 260367)
--- trunk/LayoutTests/editing/selection/ios/fixed-selection-after-scroll.html 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/LayoutTests/editing/selection/ios/fixed-selection-after-scroll.html 2020-04-20 15:53:48 UTC (rev 260367)
@@ -51,9 +51,9 @@
initialSelectionRects = rects;
shouldBe("initialSelectionRects.length", "1");
shouldBe("initialSelectionRects[0].left", "0");
- shouldBe("initialSelectionRects[0].top", "0");
+ shouldBe("initialSelectionRects[0].top", "2");
shouldBe("initialSelectionRects[0].width", "309");
- shouldBe("initialSelectionRects[0].height", "114");
+ shouldBe("initialSelectionRects[0].height", "112");
document.scrollingElement.scrollTop += 5000;
return UIHelper.getUISelectionRects();
})
@@ -61,9 +61,9 @@
finalSelectionRects = rects;
shouldBe("finalSelectionRects.length", "1");
shouldBe("finalSelectionRects[0].left", "0");
- shouldBe("finalSelectionRects[0].top", "5000");
+ shouldBe("finalSelectionRects[0].top", "5002");
shouldBe("finalSelectionRects[0].width", "309");
- shouldBe("finalSelectionRects[0].height", "114");
+ shouldBe("finalSelectionRects[0].height", "112");
finishJSTest();
});
}
Modified: trunk/LayoutTests/editing/selection/ios/selection-after-changing-text-with-callout-menu-expected.txt (260366 => 260367)
--- trunk/LayoutTests/editing/selection/ios/selection-after-changing-text-with-callout-menu-expected.txt 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/LayoutTests/editing/selection/ios/selection-after-changing-text-with-callout-menu-expected.txt 2020-04-20 15:53:48 UTC (rev 260367)
@@ -3,10 +3,10 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-PASS selectionRects[0].top is 101
+PASS selectionRects[0].top is 102
PASS selectionRects[0].width is 320
PASS selectionRects[0].left is 1
-PASS selectionRects[0].height is 29
+PASS selectionRects[0].height is 28
PASS selectionRects[1].top is 130
PASS selectionRects[1].width is 172
PASS selectionRects[1].left is 1
Modified: trunk/LayoutTests/editing/selection/ios/selection-after-changing-text-with-callout-menu.html (260366 => 260367)
--- trunk/LayoutTests/editing/selection/ios/selection-after-changing-text-with-callout-menu.html 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/LayoutTests/editing/selection/ios/selection-after-changing-text-with-callout-menu.html 2020-04-20 15:53:48 UTC (rev 260367)
@@ -53,10 +53,10 @@
dismissingMenu = await UIHelper.isDismissingMenu();
showingMenu = await UIHelper.isShowingMenu();
- shouldBe("selectionRects[0].top", "101");
+ shouldBe("selectionRects[0].top", "102");
shouldBe("selectionRects[0].width", "320");
shouldBe("selectionRects[0].left", "1");
- shouldBe("selectionRects[0].height", "29");
+ shouldBe("selectionRects[0].height", "28");
shouldBe("selectionRects[1].top", "130");
shouldBe("selectionRects[1].width", "172");
shouldBe("selectionRects[1].left", "1");
Modified: trunk/LayoutTests/editing/selection/ios/selection-handles-after-touch-end-expected.txt (260366 => 260367)
--- trunk/LayoutTests/editing/selection/ios/selection-handles-after-touch-end-expected.txt 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/LayoutTests/editing/selection/ios/selection-handles-after-touch-end-expected.txt 2020-04-20 15:53:48 UTC (rev 260367)
@@ -1,11 +1,11 @@
WK
Selection rects before touchend:
-{ left = 0, top = 0, width = 250, height = 170 }
+{ left = 0, top = 3, width = 250, height = 167 }
Selection start handle before touchend: { left = 0, top = 0, width = 0, height = 0 }
Selection end handle before touchend: { left = 0, top = 0, width = 0, height = 0 }
Selection rects after touchend:
-{ left = 0, top = 0, width = 250, height = 170 }
-Selection start handle after touchend: { left = 0, top = 0, width = 2, height = 170 }
-Selection end handle after touchend: { left = 249, top = 0, width = 2, height = 170 }
+{ left = 0, top = 3, width = 250, height = 167 }
+Selection start handle after touchend: { left = 0, top = 3, width = 2, height = 167 }
+Selection end handle after touchend: { left = 249, top = 3, width = 2, height = 167 }
Modified: trunk/LayoutTests/editing/selection/ios/update-selection-after-overflow-scroll-expected.txt (260366 => 260367)
--- trunk/LayoutTests/editing/selection/ios/update-selection-after-overflow-scroll-expected.txt 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/LayoutTests/editing/selection/ios/update-selection-after-overflow-scroll-expected.txt 2020-04-20 15:53:48 UTC (rev 260367)
@@ -2,18 +2,18 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-PASS selectionRectsBefore[0].top is 108
+PASS selectionRectsBefore[0].top is 109
PASS selectionRectsBefore[0].width is 320
PASS selectionRectsBefore[0].left is 0
-PASS selectionRectsBefore[0].height is 29
+PASS selectionRectsBefore[0].height is 28
PASS selectionRectsBefore[1].top is 137
PASS selectionRectsBefore[1].width is 172
PASS selectionRectsBefore[1].left is 0
PASS selectionRectsBefore[1].height is 30
-PASS selectionRectsAfter[0].top is 58
+PASS selectionRectsAfter[0].top is 59
PASS selectionRectsAfter[0].width is 320
PASS selectionRectsAfter[0].left is 0
-PASS selectionRectsAfter[0].height is 29
+PASS selectionRectsAfter[0].height is 28
PASS selectionRectsAfter[1].top is 87
PASS selectionRectsAfter[1].width is 172
PASS selectionRectsAfter[1].left is 0
Modified: trunk/LayoutTests/editing/selection/ios/update-selection-after-overflow-scroll.html (260366 => 260367)
--- trunk/LayoutTests/editing/selection/ios/update-selection-after-overflow-scroll.html 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/LayoutTests/editing/selection/ios/update-selection-after-overflow-scroll.html 2020-04-20 15:53:48 UTC (rev 260367)
@@ -66,19 +66,19 @@
await UIHelper.immediateScrollElementAtContentPointToOffset(150, 100, 0, 50);
selectionRectsAfter = await waitForSelectionRectsToChange(selectionRectsBefore);
- shouldBe("selectionRectsBefore[0].top", "108");
+ shouldBe("selectionRectsBefore[0].top", "109");
shouldBe("selectionRectsBefore[0].width", "320");
shouldBe("selectionRectsBefore[0].left", "0");
- shouldBe("selectionRectsBefore[0].height", "29");
+ shouldBe("selectionRectsBefore[0].height", "28");
shouldBe("selectionRectsBefore[1].top", "137");
shouldBe("selectionRectsBefore[1].width", "172");
shouldBe("selectionRectsBefore[1].left", "0");
shouldBe("selectionRectsBefore[1].height", "30");
- shouldBe("selectionRectsAfter[0].top", "58");
+ shouldBe("selectionRectsAfter[0].top", "59");
shouldBe("selectionRectsAfter[0].width", "320");
shouldBe("selectionRectsAfter[0].left", "0");
- shouldBe("selectionRectsAfter[0].height", "29");
+ shouldBe("selectionRectsAfter[0].height", "28");
shouldBe("selectionRectsAfter[1].top", "87");
shouldBe("selectionRectsAfter[1].width", "172");
shouldBe("selectionRectsAfter[1].left", "0");
Added: trunk/LayoutTests/editing/selection/selection-and-caret-do-not-extend-to-line-height-expected.txt (0 => 260367)
--- trunk/LayoutTests/editing/selection/selection-and-caret-do-not-extend-to-line-height-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/selection/selection-and-caret-do-not-extend-to-line-height-expected.txt 2020-04-20 15:53:48 UTC (rev 260367)
@@ -0,0 +1,18 @@
+This test verifies that caret and selection heights do not extend to match line height (or part of line height). To run the test manually, focus each of the editable elements and make sure that the caret roughly matches the font size in each editable element. Then select text in each of the elements with text and verify that the selection height also matches the font size.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Logical selection height in #horizontal did not extend to line height.
+PASS Logical selection height in #vertical did not extend to line height.
+PASS Logical caret height in #horizontal did not extend to line height.
+PASS Logical caret height in #horizontal-empty did not extend to line height.
+PASS Logical caret height in #vertical did not extend to line height.
+PASS Logical caret height in #vertical-empty did not extend to line height.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Foo
+
+Bar
+
Added: trunk/LayoutTests/editing/selection/selection-and-caret-do-not-extend-to-line-height.html (0 => 260367)
--- trunk/LayoutTests/editing/selection/selection-and-caret-do-not-extend-to-line-height.html (rev 0)
+++ trunk/LayoutTests/editing/selection/selection-and-caret-do-not-extend-to-line-height.html 2020-04-20 15:53:48 UTC (rev 260367)
@@ -0,0 +1,77 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<style>
+#horizontal, #horizontal-empty, #vertical, #vertical-empty {
+ font-size: 20px;
+ line-height: 100px;
+ outline: none;
+}
+
+#horizontal {
+ border: 1px solid tomato;
+}
+
+#horizontal-empty {
+ border: 1px solid lightblue;
+}
+
+#vertical {
+ border: 1px solid orange;
+}
+
+#vertical-empty {
+ margin-top: 1em;
+ height: 44px;
+ border: 1px solid cyan;
+}
+</style>
+</head>
+<body>
+<p id="horizontal" contenteditable>Foo</p>
+<p id="horizontal-empty" contenteditable></p>
+<div id="vertical" style="writing-mode: vertical-lr;" contenteditable>Bar</div>
+<div id="vertical-empty" style="writing-mode: vertical-lr;" contenteditable></div>
+<script>
+function logicalHeightOfRect(element, rect) {
+ return getComputedStyle(element).writingMode.startsWith("vertical") ? rect.width : rect.height;
+}
+
+function testLogicalHeightOfSelection(elementID) {
+ const element = document.getElementById(elementID);
+ element.focus();
+ document.execCommand("SelectAll");
+
+ const height = logicalHeightOfRect(element, internals.selectionBounds());
+ if (height < 25)
+ testPassed(`Logical selection height in #${elementID} did not extend to line height.`);
+ else
+ testFailed(`Logical selection height in #${elementID} was too tall (observed: ${height}).`);
+ element.blur();
+}
+
+function testLogicalHeightOfCaret(elementID) {
+ const element = document.getElementById(elementID);
+ element.focus();
+
+ const height = logicalHeightOfRect(element, internals.absoluteCaretBounds());
+ if (height < 25)
+ testPassed(`Logical caret height in #${elementID} did not extend to line height.`);
+ else
+ testFailed(`Logical caret height in #${elementID} was too tall (observed: ${height}).`);
+ element.blur();
+}
+
+description("This test verifies that caret and selection heights do not extend to match line height (or part of line height). To run the test manually, focus each of the editable elements and make sure that the caret roughly matches the font size in each editable element. Then select text in each of the elements with text and verify that the selection height also matches the font size.");
+if (window.testRunner) {
+ testLogicalHeightOfSelection("horizontal");
+ testLogicalHeightOfSelection("vertical");
+ testLogicalHeightOfCaret("horizontal");
+ testLogicalHeightOfCaret("horizontal-empty");
+ testLogicalHeightOfCaret("vertical");
+ testLogicalHeightOfCaret("vertical-empty");
+}
+</script>
+</body>
+</html>
Modified: trunk/LayoutTests/fast/repaint/focus-ring-repaint-expected.txt (260366 => 260367)
--- trunk/LayoutTests/fast/repaint/focus-ring-repaint-expected.txt 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/LayoutTests/fast/repaint/focus-ring-repaint-expected.txt 2020-04-20 15:53:48 UTC (rev 260367)
@@ -10,8 +10,8 @@
(rect 5 457 103 67)
(rect 5 457 106 70)
(rect 5 542 106 70)
- (rect 15 32 36 70)
- (rect 18 35 30 64)
+ (rect 15 62 36 40)
+ (rect 18 65 30 34)
(rect 5 89 56 10)
(rect 5 35 56 64)
(rect 5 117 36 60)
Modified: trunk/Source/WebCore/ChangeLog (260366 => 260367)
--- trunk/Source/WebCore/ChangeLog 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/Source/WebCore/ChangeLog 2020-04-20 15:53:48 UTC (rev 260367)
@@ -1,3 +1,60 @@
+2020-04-20 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Oversized caret and selection rects in text fields on ganji.com and netflix.com/login
+ https://bugs.webkit.org/show_bug.cgi?id=210622
+ <rdar://problem/45945636>
+
+ Reviewed by Darin Adler.
+
+ Currently, selection and caret rects in text fields on some web pages can be excessively tall. This patch makes
+ a small adjustment to allow the top of the caret or selection rect to snap to the top of the inline box instead
+ of being at the end of the previous line, in the case where there is no previous inline box.
+
+ In the case where we compute the caret rect for an empty renderer (i.e. no children), we make an additional
+ tweak so that the caret rect's height is based on the computed font height instead of line height, and then we
+ ensure that the caret is (logically) vertically centered.
+
+ See below for more details.
+
+ Test: editing/selection/selection-and-caret-do-not-extend-to-line-height.html
+
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::RenderBlockFlow::positionForPointWithInlineChildren):
+
+ Specify ForHitTesting::Yes when asking for selectionTop().
+
+ * rendering/RenderBoxModelObject.cpp:
+ (WebCore::RenderBoxModelObject::localCaretRectForEmptyElement):
+
+ Use FontMetric's height when computing the height of the caret rect, and then center it vertically in the
+ renderer.
+
+ * rendering/RenderReplaced.cpp:
+ (WebCore::RenderReplaced::positionForPoint):
+
+ Specify ForHitTesting::Yes when asking for selectionTop(). See below for more information.
+
+ * rendering/RenderTextLineBoxes.cpp:
+ (WebCore::RenderTextLineBoxes::positionForPoint const):
+ * rendering/RootInlineBox.cpp:
+ (WebCore::RootInlineBox::selectionTop const):
+
+ When computing selectionTop(), we currently fall back to using the top of the containing RenderBlockFlow
+ (`blockFlow().borderAndPaddingBefore()`) in the case where there is no previous root box. However, this can lead
+ to selection and caret rects being taller than expected; instead, we can use the max of the `selectionTop`
+ (that is, the top of the line box, adjusted for annotations) and the top of the RenderBlockFlow. This has the
+ effect of allowing the caret and selection to visually snap to the top of a run of text, provided there is not
+ already a line of text that precedes it. Taking the maximum of the two values ensures that we don't
+ unintentionally make the selection or caret rects even larger, if the line top is above the top of the block.
+
+ Note that we also avoid shrinking the selection and caret rects when hit-testing renderers for positions and
+ ranges. This allows users to still click and drag to select text in the extra line-height area above a piece of
+ text, even if the selection is only painted over the text (and not in the region containing the line-height).
+ This behavior was established in the fix for webkit.org/b/14911, and is covered by the layout test
+ `editing/selection/inline-closest-leaf-child.html`.
+
+ * rendering/RootInlineBox.h:
+
2020-04-20 Darin Adler <da...@apple.com>
Use #import instead of #include in Objective-C and don't use #pragma once
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (260366 => 260367)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2020-04-20 15:53:48 UTC (rev 260367)
@@ -3537,7 +3537,7 @@
if (closestBox) {
if (moveCaretToBoundary) {
- LayoutUnit firstRootBoxWithChildrenTop = std::min(firstRootBoxWithChildren->selectionTop(), LayoutUnit(firstRootBoxWithChildren->logicalTop()));
+ LayoutUnit firstRootBoxWithChildrenTop = std::min(firstRootBoxWithChildren->selectionTop(RootInlineBox::ForHitTesting::Yes), LayoutUnit(firstRootBoxWithChildren->logicalTop()));
if (pointInLogicalContents.y() < firstRootBoxWithChildrenTop
|| (blocksAreFlipped && pointInLogicalContents.y() == firstRootBoxWithChildrenTop)) {
InlineBox* box = firstRootBoxWithChildren->firstLeafDescendant();
Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (260366 => 260367)
--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2020-04-20 15:53:48 UTC (rev 260367)
@@ -2597,7 +2597,6 @@
// constructed and this kludge is not called any more. So only the caret size
// of an empty :first-line'd block is wrong. I think we can live with that.
const RenderStyle& currentStyle = firstLineStyle();
- LayoutUnit height = lineHeight(true, currentStyle.isHorizontalWritingMode() ? HorizontalLine : VerticalLine);
enum CaretAlignment { alignLeft, alignRight, alignCenter };
@@ -2649,8 +2648,9 @@
}
x = std::min(x, std::max<LayoutUnit>(maxX - caretWidth, 0));
- LayoutUnit y = paddingTop() + borderTop();
-
+ auto lineHeight = this->lineHeight(true, currentStyle.isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes);
+ auto height = std::min(lineHeight, LayoutUnit { currentStyle.fontMetrics().height() });
+ auto y = paddingTop() + borderTop() + (lineHeight > height ? (lineHeight - height) / 2 : LayoutUnit { });
return currentStyle.isHorizontalWritingMode() ? LayoutRect(x, y, caretWidth, height) : LayoutRect(y, x, height, caretWidth);
}
Modified: trunk/Source/WebCore/rendering/RenderReplaced.cpp (260366 => 260367)
--- trunk/Source/WebCore/rendering/RenderReplaced.cpp 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/Source/WebCore/rendering/RenderReplaced.cpp 2020-04-20 15:53:48 UTC (rev 260367)
@@ -620,7 +620,7 @@
InlineBox* box = inlineBoxWrapper();
const RootInlineBox* rootBox = box ? &box->root() : 0;
- LayoutUnit top = rootBox ? rootBox->selectionTop() : logicalTop();
+ LayoutUnit top = rootBox ? rootBox->selectionTop(RootInlineBox::ForHitTesting::Yes) : logicalTop();
LayoutUnit bottom = rootBox ? rootBox->selectionBottom() : logicalBottom();
LayoutUnit blockDirectionPosition = isHorizontalWritingMode() ? point.y() + y() : point.x() + x();
Modified: trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp (260366 => 260367)
--- trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp 2020-04-20 15:53:48 UTC (rev 260367)
@@ -312,7 +312,7 @@
box = box->nextTextBox();
auto& rootBox = box->root();
- LayoutUnit top = std::min(rootBox.selectionTop(), rootBox.lineTop());
+ LayoutUnit top = std::min(rootBox.selectionTop(RootInlineBox::ForHitTesting::Yes), rootBox.lineTop());
if (pointBlockDirection > top || (!blocksAreFlipped && pointBlockDirection == top)) {
LayoutUnit bottom = rootBox.selectionBottom();
if (rootBox.nextRootBox())
Modified: trunk/Source/WebCore/rendering/RootInlineBox.cpp (260366 => 260367)
--- trunk/Source/WebCore/rendering/RootInlineBox.cpp 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/Source/WebCore/rendering/RootInlineBox.cpp 2020-04-20 15:53:48 UTC (rev 260367)
@@ -568,7 +568,7 @@
return nullptr;
}
-LayoutUnit RootInlineBox::selectionTop() const
+LayoutUnit RootInlineBox::selectionTop(ForHitTesting forHitTesting) const
{
LayoutUnit selectionTop = m_lineTop;
@@ -609,7 +609,14 @@
}
#endif
- LayoutUnit prevBottom = prevRootBox() ? prevRootBox()->selectionBottom() : blockFlow().borderAndPaddingBefore();
+ LayoutUnit prevBottom;
+ if (auto* previousBox = prevRootBox())
+ prevBottom = previousBox->selectionBottom();
+ else {
+ auto borderAndPaddingBefore = blockFlow().borderAndPaddingBefore();
+ prevBottom = forHitTesting == ForHitTesting::Yes ? borderAndPaddingBefore : std::max(borderAndPaddingBefore, selectionTop);
+ }
+
if (prevBottom < selectionTop && blockFlow().containsFloats()) {
// This line has actually been moved further down, probably from a large line-height, but possibly because the
// line was forced to clear floats. If so, let's check the offsets, and only be willing to use the previous
Modified: trunk/Source/WebCore/rendering/RootInlineBox.h (260366 => 260367)
--- trunk/Source/WebCore/rendering/RootInlineBox.h 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/Source/WebCore/rendering/RootInlineBox.h 2020-04-20 15:53:48 UTC (rev 260367)
@@ -72,7 +72,8 @@
void setContainingFragment(RenderFragmentContainer&);
void clearContainingFragment();
- LayoutUnit selectionTop() const;
+ enum class ForHitTesting : bool { No, Yes };
+ LayoutUnit selectionTop(ForHitTesting = ForHitTesting::No) const;
LayoutUnit selectionBottom() const;
LayoutUnit selectionHeight() const { return std::max<LayoutUnit>(0, selectionBottom() - selectionTop()); }
Modified: trunk/Tools/ChangeLog (260366 => 260367)
--- trunk/Tools/ChangeLog 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/Tools/ChangeLog 2020-04-20 15:53:48 UTC (rev 260367)
@@ -1,3 +1,20 @@
+2020-04-20 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Oversized caret and selection rects in text fields on ganji.com and netflix.com/login
+ https://bugs.webkit.org/show_bug.cgi?id=210622
+ <rdar://problem/45945636>
+
+ Reviewed by Darin Adler.
+
+ Rebaseline some expected selection and caret rects in some iOS API tests.
+
+ * TestWebKitAPI/Tests/ios/AccessibilityTestsIOS.mm:
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm:
+ (TEST):
+ * TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm:
+ (TestWebKitAPI::TEST):
+
2020-04-20 Darin Adler <da...@apple.com>
Use #import instead of #include in Objective-C and don't use #pragma once
Modified: trunk/Tools/TestWebKitAPI/Tests/ios/AccessibilityTestsIOS.mm (260366 => 260367)
--- trunk/Tools/TestWebKitAPI/Tests/ios/AccessibilityTestsIOS.mm 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/AccessibilityTestsIOS.mm 2020-04-20 15:53:48 UTC (rev 260367)
@@ -93,13 +93,13 @@
NSArray<NSValue *> *rects = [webView rectsAtSelectionOffset:0 withText:@"abcdefghijklmnopqrstuvwxyz"];
#if PLATFORM(MACCATALYST)
- checkCGRectValueAtIndex(rects, CGRectMake(8, 8, 304, 116), 0);
+ checkCGRectValueAtIndex(rects, CGRectMake(8, 10, 304, 114), 0);
checkCGRectValueAtIndex(rects, CGRectMake(8, 124, 304, 116), 1);
checkCGRectValueAtIndex(rects, CGRectMake(8, 240, 304, 116), 2);
checkCGRectValueAtIndex(rects, CGRectMake(8, 356, 304, 116), 3);
checkCGRectValueAtIndex(rects, CGRectMake(8, 472, 145, 116), 4);
#else
- checkCGRectValueAtIndex(rects, CGRectMake(8, 8, 304, 114), 0);
+ checkCGRectValueAtIndex(rects, CGRectMake(8, 10, 304, 112), 0);
checkCGRectValueAtIndex(rects, CGRectMake(8, 122, 304, 117), 1);
checkCGRectValueAtIndex(rects, CGRectMake(8, 239, 304, 117), 2);
checkCGRectValueAtIndex(rects, CGRectMake(8, 356, 304, 117), 3);
Modified: trunk/Tools/TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm (260366 => 260367)
--- trunk/Tools/TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm 2020-04-20 15:53:48 UTC (rev 260367)
@@ -77,8 +77,8 @@
[webView _executeEditCommand:@"MoveToEndOfLine" argument:nil completion:nil];
auto autocorrectionRects = retainPtr([webView autocorrectionRectsForString:@"Wulk"]);
- checkCGRectIsEqualToCGRectWithLogging(CGRectMake(8, 8, 36, 21), [autocorrectionRects firstRect]);
- checkCGRectIsEqualToCGRectWithLogging(CGRectMake(8, 8, 36, 21), [autocorrectionRects lastRect]);
+ checkCGRectIsEqualToCGRectWithLogging(CGRectMake(8, 9, 36, 20), [autocorrectionRects firstRect]);
+ checkCGRectIsEqualToCGRectWithLogging(CGRectMake(8, 9, 36, 20), [autocorrectionRects lastRect]);
auto contentView = [webView textInputContentView];
UIFont *fontBeforeScaling = [contentView fontForCaretSelection];
Modified: trunk/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm (260366 => 260367)
--- trunk/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm 2020-04-20 15:32:36 UTC (rev 260366)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm 2020-04-20 15:53:48 UTC (rev 260367)
@@ -361,7 +361,7 @@
EXPECT_TRUE([observedEventNames containsObject:@"dragenter"]);
EXPECT_TRUE([observedEventNames containsObject:@"dragover"]);
EXPECT_TRUE([observedEventNames containsObject:@"drop"]);
- checkCGRectIsEqualToCGRectWithLogging(CGRectMake(960, 201, 2, 227), [simulator finalSelectionStartRect]);
+ checkCGRectIsEqualToCGRectWithLogging(CGRectMake(960, 205, 2, 223), [simulator finalSelectionStartRect]);
checkRichTextTypePrecedesPlainTextType(simulator.get());
EXPECT_TRUE([simulator lastKnownDropProposal].precise);
@@ -989,7 +989,7 @@
[simulator setExternalItemProviders:@[ simulatedItemProvider.get() ]];
[simulator runFrom:CGPointMake(300, 400) to:CGPointMake(100, 300)];
EXPECT_WK_STREQ(textPayload.UTF8String, [webView stringByEvaluatingJavaScript:@"editor.textContent"].UTF8String);
- checkCGRectIsEqualToCGRectWithLogging(CGRectMake(1935, 201, 2, 227), [simulator finalSelectionStartRect]);
+ checkCGRectIsEqualToCGRectWithLogging(CGRectMake(1935, 205, 2, 223), [simulator finalSelectionStartRect]);
}
TEST(DragAndDropTests, ExternalSourceJPEGOnly)