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

Side by Side Diff: third_party/WebKit/Source/core/editing/PlainTextRange.cpp

Issue 2926043002: Rename PlainText::end() to PlainText::End() (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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All
3 * rights reserved. 3 * rights reserved.
4 * Copyright (C) 2005 Alexey Proskuryakov. 4 * Copyright (C) 2005 Alexey Proskuryakov.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 for (; !it.AtEnd(); it.Advance()) { 91 for (; !it.AtEnd(); it.Advance()) {
92 int len = it.length(); 92 int len = it.length();
93 93
94 text_run_start_position = it.StartPositionInCurrentContainer(); 94 text_run_start_position = it.StartPositionInCurrentContainer();
95 text_run_end_position = it.EndPositionInCurrentContainer(); 95 text_run_end_position = it.EndPositionInCurrentContainer();
96 96
97 bool found_start = 97 bool found_start =
98 Start() >= doc_text_position && Start() <= doc_text_position + len; 98 Start() >= doc_text_position && Start() <= doc_text_position + len;
99 bool found_end = 99 bool found_end =
100 end() >= doc_text_position && end() <= doc_text_position + len; 100 End() >= doc_text_position && End() <= doc_text_position + len;
101 101
102 // Fix textRunRange->endPosition(), but only if foundStart || foundEnd, 102 // Fix textRunRange->endPosition(), but only if foundStart || foundEnd,
103 // because it is only in those cases that textRunRange is used. 103 // because it is only in those cases that textRunRange is used.
104 if (found_end) { 104 if (found_end) {
105 // FIXME: This is a workaround for the fact that the end of a run 105 // FIXME: This is a workaround for the fact that the end of a run
106 // is often at the wrong position for emitted '\n's or if the 106 // is often at the wrong position for emitted '\n's or if the
107 // layoutObject of the current node is a replaced element. 107 // layoutObject of the current node is a replaced element.
108 if (len == 1 && 108 if (len == 1 &&
109 (it.CharacterAt(0) == '\n' || it.IsInsideAtomicInlineElement())) { 109 (it.CharacterAt(0) == '\n' || it.IsInsideAtomicInlineElement())) {
110 it.Advance(); 110 it.Advance();
(...skipping 19 matching lines...) Expand all
130 } else { 130 } else {
131 if (Start() == doc_text_position) 131 if (Start() == doc_text_position)
132 result_start = text_run_start_position; 132 result_start = text_run_start_position;
133 else 133 else
134 result_start = text_run_end_position; 134 result_start = text_run_end_position;
135 } 135 }
136 } 136 }
137 137
138 if (found_end) { 138 if (found_end) {
139 if (text_run_start_position.ComputeContainerNode()->IsTextNode()) { 139 if (text_run_start_position.ComputeContainerNode()->IsTextNode()) {
140 int offset = end() - doc_text_position; 140 int offset = End() - doc_text_position;
141 result_end = 141 result_end =
142 Position(text_run_start_position.ComputeContainerNode(), 142 Position(text_run_start_position.ComputeContainerNode(),
143 offset + text_run_start_position.OffsetInContainerNode()); 143 offset + text_run_start_position.OffsetInContainerNode());
144 } else { 144 } else {
145 if (end() == doc_text_position) 145 if (End() == doc_text_position)
146 result_end = text_run_start_position; 146 result_end = text_run_start_position;
147 else 147 else
148 result_end = text_run_end_position; 148 result_end = text_run_end_position;
149 } 149 }
150 doc_text_position += len; 150 doc_text_position += len;
151 break; 151 break;
152 } 152 }
153 doc_text_position += len; 153 doc_text_position += len;
154 } 154 }
155 155
156 if (!start_range_found) 156 if (!start_range_found)
157 return EphemeralRange(); 157 return EphemeralRange();
158 158
159 if (length() && end() > doc_text_position) { // end() is out of bounds 159 if (length() && End() > doc_text_position) { // End() is out of bounds
160 result_end = text_run_end_position; 160 result_end = text_run_end_position;
161 } 161 }
162 162
163 return EphemeralRange(result_start.ToOffsetInAnchor(), 163 return EphemeralRange(result_start.ToOffsetInAnchor(),
164 result_end.ToOffsetInAnchor()); 164 result_end.ToOffsetInAnchor());
165 } 165 }
166 166
167 PlainTextRange PlainTextRange::Create(const ContainerNode& scope, 167 PlainTextRange PlainTextRange::Create(const ContainerNode& scope,
168 const EphemeralRange& range) { 168 const EphemeralRange& range) {
169 if (range.IsNull()) 169 if (range.IsNull())
(...skipping 21 matching lines...) Expand all
191 191
192 return PlainTextRange(start, end); 192 return PlainTextRange(start, end);
193 } 193 }
194 194
195 PlainTextRange PlainTextRange::Create(const ContainerNode& scope, 195 PlainTextRange PlainTextRange::Create(const ContainerNode& scope,
196 const Range& range) { 196 const Range& range) {
197 return Create(scope, EphemeralRange(&range)); 197 return Create(scope, EphemeralRange(&range));
198 } 198 }
199 199
200 } // namespace blink 200 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/PlainTextRange.h ('k') | third_party/WebKit/Source/core/exported/WebRange.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698