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

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

Issue 2938923004: Get rid of redundant block scope from ComputeInlineBoxPositionForTextNode() (Closed)
Patch Set: 2017-06-15T18:24:45 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 d4355c86858b648cfbc2d8743d4387c817b425bb..1cb2230373de5150956fa9bf386e7360ae30f8af 100644
--- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
+++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
@@ -839,41 +839,37 @@ static InlineBoxPosition ComputeInlineBoxPositionForTextNode(
int caret_offset,
TextAffinity affinity,
TextDirection primary_direction) {
- // TODO(yosin): We should move this code fragment to another function to
- // remove the scope.
InlineBox* inline_box = nullptr;
- {
- LayoutText* text_layout_object = ToLayoutText(layout_object);
-
- InlineTextBox* candidate = nullptr;
+ LayoutText* text_layout_object = ToLayoutText(layout_object);
- for (InlineTextBox* box : InlineTextBoxesOf(*text_layout_object)) {
- int caret_min_offset = box->CaretMinOffset();
- int caret_max_offset = box->CaretMaxOffset();
+ InlineTextBox* candidate = nullptr;
- if (caret_offset < caret_min_offset || caret_offset > caret_max_offset ||
- (caret_offset == caret_max_offset && box->IsLineBreak()))
- continue;
+ 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)
- return InlineBoxPosition(box, caret_offset);
+ if (caret_offset < caret_min_offset || caret_offset > caret_max_offset ||
+ (caret_offset == caret_max_offset && box->IsLineBreak()))
+ continue;
- if (IsCaretAtEdgeOfInlineTextBox(caret_offset, *box, affinity)) {
- inline_box = box;
- break;
- }
+ if (caret_offset > caret_min_offset && caret_offset < caret_max_offset)
+ return InlineBoxPosition(box, caret_offset);
- 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 (IsCaretAtEdgeOfInlineTextBox(caret_offset, *box, affinity)) {
+ inline_box = box;
+ break;
}
- if (!inline_box)
- inline_box = candidate;
+
+ 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();
« 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