Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Unified Diff: third_party/WebKit/Source/core/editing/VisibleUnits.cpp

Issue 2938373002: Introduce CanNotContinueOnNextLine() for DoesContinueOnNextLine() (Closed)
Patch Set: 2017-06-16T16:18:00 Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/VisibleUnits.cpp
diff --git a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
index 0fe37bfec988ce5ee355ab3af0f81238c6e28496..71815bb387ce08a9c1acb68047ee275797e335c2 100644
--- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
+++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
@@ -1433,6 +1433,18 @@ static PositionTemplate<Strategy> MostBackwardCaretPosition(
return last_visible.DeprecatedComputePosition();
}
+// Returns true if |box| at |text_offset| can not continue on next line.
+static bool CanNotContinueOnNextLine(const LayoutText& text_layout_object,
+ InlineBox* box,
+ unsigned text_offset) {
+ InlineTextBox* const last_text_box = text_layout_object.LastTextBox();
+ if (box == last_text_box)
+ return true;
+ return LineLayoutAPIShim::LayoutObjectFrom(box->GetLineLayoutItem()) ==
+ text_layout_object &&
+ ToInlineTextBox(box)->Start() >= text_offset;
+}
+
// The text continues on the next line only if the last text box is not on this
// line and none of the boxes on this line have a larger start offset.
static bool DoesContinueOnNextLine(const LayoutText& text_layout_object,
@@ -1442,21 +1454,13 @@ static bool DoesContinueOnNextLine(const LayoutText& text_layout_object,
DCHECK_NE(box, last_text_box);
for (InlineBox* runner = box->NextLeafChild(); runner;
runner = runner->NextLeafChild()) {
- if (runner == last_text_box)
- return false;
- if (LineLayoutAPIShim::LayoutObjectFrom(runner->GetLineLayoutItem()) ==
- text_layout_object &&
- ToInlineTextBox(runner)->Start() >= text_offset)
+ if (CanNotContinueOnNextLine(text_layout_object, runner, text_offset))
return false;
}
for (InlineBox* runner = box->PrevLeafChild(); runner;
runner = runner->PrevLeafChild()) {
- if (runner == last_text_box)
- return false;
- if (LineLayoutAPIShim::LayoutObjectFrom(runner->GetLineLayoutItem()) ==
- text_layout_object &&
- ToInlineTextBox(runner)->Start() >= text_offset)
+ if (CanNotContinueOnNextLine(text_layout_object, runner, text_offset))
return false;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698