Skip to content

Commit

Permalink
[LayoutNG] Fix 1px failure in WebFrameTest
Browse files Browse the repository at this point in the history
Unit tests WebFrameTest.MoveRangeSelectionExtent and MoveRangeSelectionExtentCannotCollapse currently fail with LayoutNG on Mac due to a 1px rounding difference when calculating caret rects (InlineTextBox::PositionForOffset() vs. NGPhysicalTextFragment::InlinePositionForOffset()).

As the legacy caret rect rounding process is already very artificial, it's not worthy recovering exactly the same process in NG. Hence, this patch simply tweaks hit test coordinates in the unit tests to make them pass with LayoutNG.

Bug: 591099
Change-Id: Ia0eb2ecdde0eb593ac72e010822e780720b930da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1612118
Commit-Queue: Emil A Eklund <eae@chromium.org>
Reviewed-by: Koji Ishii <kojii@chromium.org>
Reviewed-by: Emil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659853}
  • Loading branch information
xiaochengh authored and Commit Bot committed May 15, 2019
1 parent dcf9f6e commit e190216
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion third_party/blink/renderer/core/exported/web_frame_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5426,7 +5426,9 @@ static WebPoint BottomRightMinusOne(const WebRect& rect) {
// selection bounds, selectRange() will select the *next* element. That's
// strictly correct, as hit-testing checks the pixel to the lower-right of
// the input coordinate, but it's a wart on the API.
return WebPoint(rect.x + rect.width - 1, rect.y + rect.height - 1);
if (rect.width > 0)
return WebPoint(rect.x + rect.width - 1, rect.y + rect.height - 1);
return WebPoint(rect.x + rect.width, rect.y + rect.height - 1);
}

static WebRect ElementBounds(WebLocalFrame* frame, const WebString& id) {
Expand Down

0 comments on commit e190216

Please sign in to comment.