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

Side by Side Diff: Source/core/editing/htmlediting.cpp

Issue 1189543002: Do not traverse nodes not having a layout object while searching editable visible position. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Split out the test Created 5 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 | « Source/core/dom/PositionIterator.cpp ('k') | 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 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 return PositionType(); 223 return PositionType();
224 } 224 }
225 225
226 Position nextCandidate(const Position& position) 226 Position nextCandidate(const Position& position)
227 { 227 {
228 return nextCandidateAlgorithm<EditingStrategy>(position); 228 return nextCandidateAlgorithm<EditingStrategy>(position);
229 } 229 }
230 230
231 Position nextVisuallyDistinctCandidate(const Position& position) 231 Position nextVisuallyDistinctCandidate(const Position& position)
232 { 232 {
233 // FIXME: Use PositionIterator instead.
leviw_travelin_and_unemployed 2015/06/25 00:15:20 We use TODO(name) syntax in Blink now.
changseok 2015/06/25 03:49:39 Done.
233 Position p = position; 234 Position p = position;
234 Position downstreamStart = p.downstream(); 235 Position downstreamStart = p.downstream();
235 while (!p.atEndOfTree()) { 236 while (!p.atEndOfTree()) {
236 p = p.next(Character); 237 p = p.next(Character);
237 if (p.isCandidate() && p.downstream() != downstreamStart) 238 if (p.isCandidate() && p.downstream() != downstreamStart)
238 return p; 239 return p;
240 if (auto* node = p.containerNode()) {
241 if (!node->layoutObject())
242 p = lastPositionInOrAfterNode(node);
243 }
239 } 244 }
240 return Position(); 245 return Position();
241 } 246 }
242 247
243 template <typename Strategy> 248 template <typename Strategy>
244 typename Strategy::PositionType previousCandidateAlgorithm(const typename Strate gy::PositionType& position) 249 typename Strategy::PositionType previousCandidateAlgorithm(const typename Strate gy::PositionType& position)
245 { 250 {
246 using PositionType = typename Strategy::PositionType; 251 using PositionType = typename Strategy::PositionType;
247 typename Strategy::PositionIteratorType p(position); 252 typename Strategy::PositionIteratorType p(position);
248 while (!p.atStart()) { 253 while (!p.atStart()) {
249 p.decrement(); 254 p.decrement();
250 if (p.isCandidate()) 255 if (p.isCandidate())
251 return p; 256 return p;
252 } 257 }
253 return PositionType(); 258 return PositionType();
254 } 259 }
255 260
256 Position previousCandidate(const Position& position) 261 Position previousCandidate(const Position& position)
257 { 262 {
258 return previousCandidateAlgorithm<EditingStrategy>(position); 263 return previousCandidateAlgorithm<EditingStrategy>(position);
259 } 264 }
260 265
261 template <typename PositionType> 266 template <typename PositionType>
262 PositionType previousVisuallyDistinctCandidateAlgorithm(const PositionType& posi tion) 267 PositionType previousVisuallyDistinctCandidateAlgorithm(const PositionType& posi tion)
263 { 268 {
269 // FIXME: Use PositionIterator instead.
264 PositionType p = position; 270 PositionType p = position;
265 PositionType downstreamStart = p.downstream(); 271 PositionType downstreamStart = p.downstream();
266 while (!p.atStartOfTree()) { 272 while (!p.atStartOfTree()) {
267 p = p.previous(Character); 273 p = p.previous(Character);
268 if (p.isCandidate() && p.downstream() != downstreamStart) 274 if (p.isCandidate() && p.downstream() != downstreamStart)
269 return p; 275 return p;
276 if (auto* node = p.containerNode()) {
277 if (!node->layoutObject())
278 p = firstPositionInOrBeforeNode(node);
279 }
270 } 280 }
271 return PositionType(); 281 return PositionType();
272 } 282 }
273 283
274 Position previousVisuallyDistinctCandidate(const Position& position) 284 Position previousVisuallyDistinctCandidate(const Position& position)
275 { 285 {
276 return previousVisuallyDistinctCandidateAlgorithm<Position>(position); 286 return previousVisuallyDistinctCandidateAlgorithm<Position>(position);
277 } 287 }
278 288
279 VisiblePosition firstEditableVisiblePositionAfterPositionInRoot(const Position& position, ContainerNode* highestRoot) 289 VisiblePosition firstEditableVisiblePositionAfterPositionInRoot(const Position& position, ContainerNode* highestRoot)
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 // if the selection starts just before a paragraph break, skip over it 1218 // if the selection starts just before a paragraph break, skip over it
1209 if (isEndOfParagraph(visiblePosition)) 1219 if (isEndOfParagraph(visiblePosition))
1210 return visiblePosition.next().deepEquivalent().downstream(); 1220 return visiblePosition.next().deepEquivalent().downstream();
1211 1221
1212 // otherwise, make sure to be at the start of the first selected node, 1222 // otherwise, make sure to be at the start of the first selected node,
1213 // instead of possibly at the end of the last node before the selection 1223 // instead of possibly at the end of the last node before the selection
1214 return visiblePosition.deepEquivalent().downstream(); 1224 return visiblePosition.deepEquivalent().downstream();
1215 } 1225 }
1216 1226
1217 } // namespace blink 1227 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/PositionIterator.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698