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

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

Issue 2941213002: Get rid of forward declaration of ComputeInlineBoxPositionForTextNode() (Closed)
Patch Set: 2017-06-16T14:34:05 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..6eb6d29cea23161f0d14d6e838e7bc460d9500a7 100644
--- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
+++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
@@ -770,12 +770,49 @@ static bool IsCaretAtEdgeOfInlineTextBox(int caret_offset,
return box.NextLeafChild() && box.NextLeafChild()->IsLineBreak();
}
-// TODO(yosin): We have a forward declaration here to reduce patch size. We'll
-// replace this with an implementation once review finished.
-static InlineBoxPosition ComputeInlineBoxPositionForTextNode(LayoutObject*,
- int caret_offset,
- TextAffinity,
- TextDirection);
+static InlineBoxPosition ComputeInlineBoxPositionForTextNode(
+ LayoutObject* layout_object,
+ int caret_offset,
+ TextAffinity affinity,
+ TextDirection primary_direction) {
+ InlineBox* inline_box = nullptr;
+ LayoutText* text_layout_object = ToLayoutText(layout_object);
+
+ InlineTextBox* candidate = nullptr;
+
+ for (InlineTextBox* box : InlineTextBoxesOf(*text_layout_object)) {
+ int caret_min_offset = box->CaretMinOffset();
+ int caret_max_offset = box->CaretMaxOffset();
+
+ if (caret_offset < caret_min_offset || caret_offset > caret_max_offset ||
+ (caret_offset == caret_max_offset && box->IsLineBreak()))
+ continue;
+
+ if (caret_offset > caret_min_offset && caret_offset < caret_max_offset)
+ return InlineBoxPosition(box, caret_offset);
+
+ if (IsCaretAtEdgeOfInlineTextBox(caret_offset, *box, affinity)) {
+ inline_box = box;
+ break;
+ }
+
+ candidate = box;
+ }
+ if (candidate && candidate == text_layout_object->LastTextBox() &&
+ affinity == TextAffinity::kDownstream) {
+ inline_box = SearchAheadForBetterMatch(text_layout_object);
+ if (inline_box)
+ caret_offset = inline_box->CaretMinOffset();
+ }
+ if (!inline_box)
+ inline_box = candidate;
+
+ if (!inline_box)
+ return InlineBoxPosition();
+ return AdjustInlineBoxPositionForTextDirection(
+ inline_box, caret_offset, layout_object->Style()->GetUnicodeBidi(),
+ primary_direction);
+}
template <typename Strategy>
static InlineBoxPosition ComputeInlineBoxPositionTemplate(
@@ -833,52 +870,6 @@ static InlineBoxPosition ComputeInlineBoxPositionTemplate(
affinity, primary_direction);
}
-// TODO(yosin): We should make |ComputeInlineBoxPositionForTextNode()| to take
-// |const LayoutText&|.
-static InlineBoxPosition ComputeInlineBoxPositionForTextNode(
- LayoutObject* layout_object,
- int caret_offset,
- TextAffinity affinity,
- TextDirection primary_direction) {
- InlineBox* inline_box = nullptr;
- LayoutText* text_layout_object = ToLayoutText(layout_object);
-
- InlineTextBox* candidate = nullptr;
-
- for (InlineTextBox* box : InlineTextBoxesOf(*text_layout_object)) {
- int caret_min_offset = box->CaretMinOffset();
- int caret_max_offset = box->CaretMaxOffset();
-
- if (caret_offset < caret_min_offset || caret_offset > caret_max_offset ||
- (caret_offset == caret_max_offset && box->IsLineBreak()))
- continue;
-
- if (caret_offset > caret_min_offset && caret_offset < caret_max_offset)
- return InlineBoxPosition(box, caret_offset);
-
- if (IsCaretAtEdgeOfInlineTextBox(caret_offset, *box, affinity)) {
- inline_box = box;
- break;
- }
-
- candidate = box;
- }
- if (candidate && candidate == text_layout_object->LastTextBox() &&
- affinity == TextAffinity::kDownstream) {
- inline_box = SearchAheadForBetterMatch(text_layout_object);
- if (inline_box)
- caret_offset = inline_box->CaretMinOffset();
- }
- if (!inline_box)
- inline_box = candidate;
-
- if (!inline_box)
- return InlineBoxPosition();
- return AdjustInlineBoxPositionForTextDirection(
- inline_box, caret_offset, layout_object->Style()->GetUnicodeBidi(),
- primary_direction);
-}
-
static InlineBoxPosition AdjustInlineBoxPositionForTextDirection(
InlineBox* inline_box,
int caret_offset,
« 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