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

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

Issue 2934223002: Utilize ComputeInlineBoxPosition in early-return style (Closed)
Patch Set: 2017-06-15T11:32:36 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 5def96008bcf39ce3f192892caeeb93e0db0ea4e..cd66924d14ea243eaf3f0c0ff8f48b5b5a17ce57 100644
--- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
+++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
@@ -774,7 +774,6 @@ static InlineBoxPosition ComputeInlineBoxPositionTemplate(
const PositionTemplate<Strategy>& position,
TextAffinity affinity,
TextDirection primary_direction) {
- InlineBox* inline_box = nullptr;
int caret_offset = position.ComputeEditingOffset();
Node* const anchor_node = position.AnchorNode();
LayoutObject* layout_object =
@@ -785,7 +784,6 @@ static InlineBoxPosition ComputeInlineBoxPositionTemplate(
DCHECK(layout_object) << position;
if (!layout_object->IsText()) {
- inline_box = 0;
if (CanHaveChildrenForEditing(anchor_node) &&
layout_object->IsLayoutBlockFlow() &&
HasRenderedNonAnonymousDescendantsWithHeight(layout_object)) {
@@ -809,15 +807,24 @@ static InlineBoxPosition ComputeInlineBoxPositionTemplate(
return ComputeInlineBoxPosition(
upstream_equivalent, TextAffinity::kUpstream, primary_direction);
}
- if (layout_object->IsBox()) {
- inline_box = ToLayoutBox(layout_object)->InlineBoxWrapper();
- if (!inline_box)
- return InlineBoxPosition();
- if ((caret_offset > inline_box->CaretMinOffset() &&
- caret_offset < inline_box->CaretMaxOffset()))
- return InlineBoxPosition(inline_box, caret_offset);
- }
- } else {
+ if (!layout_object->IsBox())
+ return InlineBoxPosition();
+ InlineBox* const inline_box =
+ ToLayoutBox(layout_object)->InlineBoxWrapper();
+ if (!inline_box)
+ return InlineBoxPosition();
+ if ((caret_offset > inline_box->CaretMinOffset() &&
+ caret_offset < inline_box->CaretMaxOffset()))
+ return InlineBoxPosition(inline_box, caret_offset);
+ return AdjustInlineBoxPositionForTextDirection(
+ inline_box, caret_offset, layout_object->Style()->GetUnicodeBidi(),
+ 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;
« 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