Commit 19d5de99 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Refactor ContainerNode::GetUpperLeftCorner

This patch reorganizes the branches in the above mentioned function
to make the branching logic more clearer. It also contains some other
minor cleanup.

Bug: 
Change-Id: Iabe6c4fa4f6b2681dcb6b0c2cbc41f4a3382dcfa
Reviewed-on: https://chromium-review.googlesource.com/775892Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517339}
parent aeee4f66
......@@ -988,6 +988,7 @@ bool ContainerNode::GetUpperLeftCorner(FloatPoint& point) const {
return false;
// FIXME: What is this code really trying to do?
// TODO(xiaochengh): Rename |o| to |runner|.
LayoutObject* o = GetLayoutObject();
if (!o->IsInline() || o->IsAtomicInlineLevel()) {
point = o->LocalToAbsolute(FloatPoint(), kUseTransforms);
......@@ -996,7 +997,7 @@ bool ContainerNode::GetUpperLeftCorner(FloatPoint& point) const {
// Find the next text/image child, to get a position.
while (o) {
LayoutObject* p = o;
const LayoutObject* const previous = o;
if (LayoutObject* o_first_child = o->SlowFirstChild()) {
o = o_first_child;
} else if (o->NextSibling()) {
......@@ -1019,27 +1020,31 @@ bool ContainerNode::GetUpperLeftCorner(FloatPoint& point) const {
return true;
}
DCHECK(CanUseInlineBox(*o));
if (p->GetNode() && p->GetNode() == this && o->IsText() && !o->IsBR() &&
!ToLayoutText(o)->HasTextBoxes()) {
// Do nothing - skip unrendered whitespace that is a child or next sibling
// of the anchor.
// FIXME: This fails to skip a whitespace sibling when there was also a
// whitespace child (because p has moved).
} else if ((o->IsText() && !o->IsBR()) || o->IsAtomicInlineLevel()) {
if (o->IsText() && !o->IsBR()) {
if (previous->GetNode() == this && !ToLayoutText(o)->HasTextBoxes()) {
// Do nothing - skip unrendered whitespace that is a child or next
// sibling of the anchor.
// FIXME: This fails to skip a whitespace sibling when there was also a
// whitespace child (because |previous| has moved).
continue;
}
// TODO(xiaochengh): Move the code below to LayoutText.
DCHECK(CanUseInlineBox(*o));
point = FloatPoint();
if (o->IsText()) {
if (ToLayoutText(o)->FirstTextBox())
point.Move(
ToLayoutText(o)->LinesBoundingBox().X(),
ToLayoutText(o)->FirstTextBox()->Root().LineTop().ToFloat());
point = o->LocalToAbsolute(point, kUseTransforms);
} else {
DCHECK(o->IsBox());
LayoutBox* box = ToLayoutBox(o);
point.MoveBy(box->Location());
point = o->Container()->LocalToAbsolute(point, kUseTransforms);
if (ToLayoutText(o)->FirstTextBox()) {
point.Move(ToLayoutText(o)->LinesBoundingBox().X(),
ToLayoutText(o)->FirstTextBox()->Root().LineTop().ToFloat());
}
point = o->LocalToAbsolute(point, kUseTransforms);
return true;
}
if (o->IsAtomicInlineLevel()) {
point = FloatPoint();
DCHECK(o->IsBox());
LayoutBox* box = ToLayoutBox(o);
point.MoveBy(box->Location());
point = o->Container()->LocalToAbsolute(point, kUseTransforms);
return true;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment