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

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

Issue 2933513002: Avoid to reuse local variable in ComputeInlineBoxPosition() (Closed)
Patch Set: 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 fc81732adfaf8acc405ae4f963d6ee809e21ae40..000acbf96ae153a730363db9635cf71ef7737633 100644
--- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
+++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
@@ -773,17 +773,20 @@ static InlineBoxPosition ComputeInlineBoxPositionTemplate(
// but surrounded by non-editable positions. It acts to negate the
// logic at the beginning of
// |LayoutObject::createPositionWithAffinity()|.
- PositionTemplate<Strategy> equivalent =
+ const PositionTemplate<Strategy>& downstream_equivalent =
DownstreamIgnoringEditingBoundaries(position);
- if (equivalent == position) {
- equivalent = UpstreamIgnoringEditingBoundaries(position);
- if (equivalent == position ||
- DownstreamIgnoringEditingBoundaries(equivalent) == position)
- return InlineBoxPosition(inline_box, caret_offset);
+ 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(inline_box, caret_offset);
- return ComputeInlineBoxPosition(equivalent, TextAffinity::kUpstream,
- primary_direction);
+ return ComputeInlineBoxPosition(
+ upstream_equivalent, TextAffinity::kUpstream, primary_direction);
}
if (layout_object->IsBox()) {
inline_box = ToLayoutBox(layout_object)->InlineBoxWrapper();
« 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