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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 int caret_min_offset = box->CaretMinOffset(); 810 int caret_min_offset = box->CaretMinOffset();
811 int caret_max_offset = box->CaretMaxOffset(); 811 int caret_max_offset = box->CaretMaxOffset();
812 812
813 if (caret_offset < caret_min_offset || caret_offset > caret_max_offset || 813 if (caret_offset < caret_min_offset || caret_offset > caret_max_offset ||
814 (caret_offset == caret_max_offset && box->IsLineBreak())) 814 (caret_offset == caret_max_offset && box->IsLineBreak()))
815 continue; 815 continue;
816 816
817 if (caret_offset > caret_min_offset && caret_offset < caret_max_offset) 817 if (caret_offset > caret_min_offset && caret_offset < caret_max_offset)
818 return InlineBoxPosition(box, caret_offset); 818 return InlineBoxPosition(box, caret_offset);
819 819
820 if (((caret_offset == caret_max_offset) ^ 820 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
821 (affinity == TextAffinity::kDownstream)) || 821 if (affinity == TextAffinity::kDownstream) {
822 ((caret_offset == caret_min_offset) ^ 822 inline_box = box;
823 (affinity == TextAffinity::kUpstream)) || 823 break;
824 (caret_offset == caret_max_offset && box->NextLeafChild() && 824 }
825 box->NextLeafChild()->IsLineBreak())) { 825 candidate = box;
826 continue;
827 }
828 DCHECK_EQ(caret_offset, caret_max_offset);
829 if (affinity == TextAffinity::kUpstream ||
830 (box->NextLeafChild() && box->NextLeafChild()->IsLineBreak())) {
826 inline_box = box; 831 inline_box = box;
827 break; 832 break;
828 } 833 }
829
830 candidate = box; 834 candidate = box;
831 } 835 }
832 if (candidate && candidate == text_layout_object->LastTextBox() && 836 if (candidate && candidate == text_layout_object->LastTextBox() &&
833 affinity == TextAffinity::kDownstream) { 837 affinity == TextAffinity::kDownstream) {
834 inline_box = SearchAheadForBetterMatch(text_layout_object); 838 inline_box = SearchAheadForBetterMatch(text_layout_object);
835 if (inline_box) 839 if (inline_box)
836 caret_offset = inline_box->CaretMinOffset(); 840 caret_offset = inline_box->CaretMinOffset();
837 } 841 }
838 if (!inline_box) 842 if (!inline_box)
839 inline_box = candidate; 843 inline_box = candidate;
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
2062 2066
2063 IntRect ComputeTextRect(const EphemeralRangeInFlatTree& range) { 2067 IntRect ComputeTextRect(const EphemeralRangeInFlatTree& range) {
2064 return EnclosingIntRect(ComputeTextRectTemplate(range)); 2068 return EnclosingIntRect(ComputeTextRectTemplate(range));
2065 } 2069 }
2066 2070
2067 FloatRect ComputeTextFloatRect(const EphemeralRange& range) { 2071 FloatRect ComputeTextFloatRect(const EphemeralRange& range) {
2068 return ComputeTextRectTemplate(range); 2072 return ComputeTextRectTemplate(range);
2069 } 2073 }
2070 2074
2071 } // namespace blink 2075 } // namespace blink
OLDNEW
« 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