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

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

Issue 2943623002: Reduce indentation in ComputeInlineBoxPositionTemplate() (Closed)
Patch Set: 2017-06-16T14:52:49 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..5b77ae5f7b1e8d04c6ebaab66a6f535b9583ab43 100644
--- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
+++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
@@ -791,46 +791,44 @@ static InlineBoxPosition ComputeInlineBoxPositionTemplate(
DCHECK(layout_object) << position;
- if (!layout_object->IsText()) {
- if (CanHaveChildrenForEditing(anchor_node) &&
- layout_object->IsLayoutBlockFlow() &&
- HasRenderedNonAnonymousDescendantsWithHeight(layout_object)) {
- // Try a visually equivalent position with possibly opposite
- // editability. This helps in case |this| is in an editable block
- // but surrounded by non-editable positions. It acts to negate the
- // logic at the beginning of
- // |LayoutObject::createPositionWithAffinity()|.
- const PositionTemplate<Strategy>& downstream_equivalent =
- DownstreamIgnoringEditingBoundaries(position);
- if (downstream_equivalent != position) {
- return ComputeInlineBoxPosition(
- downstream_equivalent, TextAffinity::kUpstream, primary_direction);
- }
- const PositionTemplate<Strategy>& upstream_equivalent =
- UpstreamIgnoringEditingBoundaries(position);
- if (upstream_equivalent == position ||
- DownstreamIgnoringEditingBoundaries(upstream_equivalent) == position)
- return InlineBoxPosition();
-
+ if (layout_object->IsText()) {
+ return ComputeInlineBoxPositionForTextNode(layout_object, caret_offset,
+ affinity, primary_direction);
+ }
+ if (CanHaveChildrenForEditing(anchor_node) &&
+ layout_object->IsLayoutBlockFlow() &&
+ HasRenderedNonAnonymousDescendantsWithHeight(layout_object)) {
+ // Try a visually equivalent position with possibly opposite
+ // editability. This helps in case |this| is in an editable block
+ // but surrounded by non-editable positions. It acts to negate the
+ // logic at the beginning of
+ // |LayoutObject::createPositionWithAffinity()|.
+ const PositionTemplate<Strategy>& downstream_equivalent =
+ DownstreamIgnoringEditingBoundaries(position);
+ if (downstream_equivalent != position) {
return ComputeInlineBoxPosition(
- upstream_equivalent, TextAffinity::kUpstream, primary_direction);
+ downstream_equivalent, TextAffinity::kUpstream, primary_direction);
}
- if (!layout_object->IsBox())
- return InlineBoxPosition();
- InlineBox* const inline_box =
- ToLayoutBox(layout_object)->InlineBoxWrapper();
- if (!inline_box)
+ const PositionTemplate<Strategy>& upstream_equivalent =
+ UpstreamIgnoringEditingBoundaries(position);
+ if (upstream_equivalent == position ||
+ DownstreamIgnoringEditingBoundaries(upstream_equivalent) == position)
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);
- }
- return ComputeInlineBoxPositionForTextNode(layout_object, caret_offset,
- affinity, primary_direction);
+ return ComputeInlineBoxPosition(upstream_equivalent,
+ TextAffinity::kUpstream, primary_direction);
+ }
+ 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 make |ComputeInlineBoxPositionForTextNode()| to take
« 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