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

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

Issue 2939953005: Refactor EndOfLineAlgorithm() (Closed)
Patch Set: 2017-06-16T11:14:30 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/VisibleUnitsLine.cpp
diff --git a/third_party/WebKit/Source/core/editing/VisibleUnitsLine.cpp b/third_party/WebKit/Source/core/editing/VisibleUnitsLine.cpp
index 4e0da7b8bca4b8bed3208ebaf42b26e0d28fe8f0..376baa48381e1f77c64b9a0d610e6ec40eb1a471 100644
--- a/third_party/WebKit/Source/core/editing/VisibleUnitsLine.cpp
+++ b/third_party/WebKit/Source/core/editing/VisibleUnitsLine.cpp
@@ -394,7 +394,7 @@ static VisiblePositionTemplate<Strategy> EndOfLineAlgorithm(
DCHECK(current_position.IsValid()) << current_position;
// TODO(yosin) this is the current behavior that might need to be fixed.
// Please refer to https://bugs.webkit.org/show_bug.cgi?id=49107 for detail.
- VisiblePositionTemplate<Strategy> vis_pos =
+ const VisiblePositionTemplate<Strategy>& candidate_position =
EndPositionForLine(current_position, kUseInlineBoxOrdering);
// Make sure the end of line is at the same line as the given input
@@ -405,15 +405,17 @@ static VisiblePositionTemplate<Strategy> EndOfLineAlgorithm(
// line instead. This fix is to account for the discrepancy between lines
// with "webkit-line-break:after-white-space" style versus lines without
// that style, which would break before a space by default.
- if (!InSameLine(current_position, vis_pos)) {
- vis_pos = PreviousPositionOf(current_position);
- if (vis_pos.IsNull())
- return VisiblePositionTemplate<Strategy>();
- vis_pos = EndPositionForLine(vis_pos, kUseInlineBoxOrdering);
+ if (InSameLine(current_position, candidate_position)) {
+ return HonorEditingBoundaryAtOrAfter(candidate_position,
+ current_position.DeepEquivalent());
}
-
- return HonorEditingBoundaryAtOrAfter(vis_pos,
- current_position.DeepEquivalent());
+ const VisiblePositionTemplate<Strategy>& adjusted_position =
+ PreviousPositionOf(current_position);
+ if (adjusted_position.IsNull())
+ return VisiblePositionTemplate<Strategy>();
+ return HonorEditingBoundaryAtOrAfter(
+ EndPositionForLine(adjusted_position, kUseInlineBoxOrdering),
+ current_position.DeepEquivalent());
}
// TODO(yosin) Rename this function to reflect the fact it ignores bidi levels.
« 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