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 2932283002: Introduce IsCaretAtEdgeOfInlineTextBox() to simplify ComputeInlineBoxPosition() (Closed)
Patch Set: 2017-06-12T15:57:21 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 10d7bb2428cb8dcae515df30e6b47cfe308179ee..00d6b6ac4c461c5d98b4ea6929b006a89f2440d0 100644
--- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
+++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
@@ -817,16 +817,20 @@ static InlineBoxPosition ComputeInlineBoxPositionTemplate(
if (caret_offset > caret_min_offset && caret_offset < caret_max_offset)
return InlineBoxPosition(box, caret_offset);
- if (((caret_offset == caret_max_offset) ^
- (affinity == TextAffinity::kDownstream)) ||
- ((caret_offset == caret_min_offset) ^
- (affinity == TextAffinity::kUpstream)) ||
- (caret_offset == caret_max_offset && box->NextLeafChild() &&
- box->NextLeafChild()->IsLineBreak())) {
+ if (caret_offset == caret_min_offset) {
Xiaocheng 2017/06/12 18:35:12 I think it's better to use a wrapper function that
yosin_UTC9 2017/06/13 07:41:07 You're right. Move the condition to another functi
+ if (affinity == TextAffinity::kDownstream) {
+ inline_box = box;
+ break;
+ }
+ candidate = box;
+ continue;
+ }
+ DCHECK_EQ(caret_offset, caret_max_offset);
+ if (affinity == TextAffinity::kUpstream ||
+ (box->NextLeafChild() && box->NextLeafChild()->IsLineBreak())) {
inline_box = box;
break;
}
-
candidate = box;
}
if (candidate && candidate == text_layout_object->LastTextBox() &&
« 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