Skip to content

Commit

Permalink
Stop checking InlineTextBox in HasRenderedNonAnonymousDescendantsWith…
Browse files Browse the repository at this point in the history
…Height

HasRenderedNonAnonymousDescendantsWithHeight is a subroutine called
during position canonicalization to detect caret positions in empty
blocks. Its current dependency on legacy inline structure blocks the
NG conversion of canonicalization.

This patch changes the above mentioned function to decouple it from
legacy InlineTextBox, to make editing work better with LayoutNG.

Although the function still relies on InlineBox after the patch
(via LayoutInline::LinesBoundingBox), at least we get an NG version of
canonicalization that works in most cases, i.e., when there are text
nodes. In other words, this patch allows us to run canonicalization in
the NG world in most cases.

Note: there is no need to enable layout_ng bot in this patch because
the bot doesn't have LayoutNGPaintFragments enabled, and hence, the patch
has no effect there.

Bug: 771398
Change-Id: Idbd595b0a2776dd843840a1ab903f5de7d9d5d59
Reviewed-on: https://chromium-review.googlesource.com/729040
Reviewed-by: Yoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#510387}
  • Loading branch information
xiaochengh authored and Commit Bot committed Oct 20, 2017
1 parent 5818fa1 commit 83f1a4e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions third_party/WebKit/Source/core/editing/VisibleUnits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,13 +770,15 @@ static LayoutUnit BoundingBoxLogicalHeight(LayoutObject* o,
// TODO(crbug.com/766448): Change parameter type to |const LayoutObject*|.
bool HasRenderedNonAnonymousDescendantsWithHeight(LayoutObject* layout_object) {
LayoutObject* stop = layout_object->NextInPreOrderAfterChildren();
// TODO(editing-dev): Avoid single-character parameter names.
for (LayoutObject* o = layout_object->SlowFirstChild(); o && o != stop;
o = o->NextInPreOrder()) {
if (o->NonPseudoNode()) {
if ((o->IsText() &&
BoundingBoxLogicalHeight(o, ToLayoutText(o)->LinesBoundingBox())) ||
if ((o->IsText() && ToLayoutText(o)->HasNonCollapsedText()) ||
(o->IsBox() && ToLayoutBox(o)->PixelSnappedLogicalHeight()) ||
(o->IsLayoutInline() && IsEmptyInline(LineLayoutItem(o)) &&
// TODO(crbug.com/771398): Find alternative ways to check whether an
// empty LayoutInline is rendered, without checking InlineBox.
BoundingBoxLogicalHeight(o, ToLayoutInline(o)->LinesBoundingBox())))
return true;
}
Expand Down

0 comments on commit 83f1a4e

Please sign in to comment.