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

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: Fix a loop issue caused by document-fragment 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 return nextCandidateAlgorithm<EditingStrategy>(position); 243 return nextCandidateAlgorithm<EditingStrategy>(position);
244 } 244 }
245 245
246 PositionInComposedTree nextCandidate(const PositionInComposedTree& position) 246 PositionInComposedTree nextCandidate(const PositionInComposedTree& position)
247 { 247 {
248 return nextCandidateAlgorithm<EditingInComposedTreeStrategy>(position); 248 return nextCandidateAlgorithm<EditingInComposedTreeStrategy>(position);
249 } 249 }
250 250
251 Position nextVisuallyDistinctCandidate(const Position& position) 251 Position nextVisuallyDistinctCandidate(const Position& position)
252 { 252 {
253 // TODO(changseok): Use PositionIterator instead.
253 Position p = position; 254 Position p = position;
254 Position downstreamStart = p.downstream(); 255 Position downstreamStart = p.downstream();
255 while (!p.atEndOfTree()) { 256 while (!p.atEndOfTree()) {
256 p = p.next(Character); 257 p = p.next(Character);
257 if (p.isCandidate() && p.downstream() != downstreamStart) 258 if (p.isCandidate() && p.downstream() != downstreamStart)
258 return p; 259 return p;
260 if (auto* node = p.containerNode()) {
261 if (!node->isDocumentFragment() && !node->layoutObject())
leviw_travelin_and_unemployed 2015/06/29 20:17:56 Can you help me understand why this is needed?
changseok 2015/06/30 05:50:58 I'm not sure if I correctly understand the root ca
yosin_UTC9 2015/07/01 01:50:12 Bottom line: You don't need to check |!node->isDoc
262 p = lastPositionInOrAfterNode(node);
263 }
259 } 264 }
260 return Position(); 265 return Position();
261 } 266 }
262 267
263 template <typename Strategy> 268 template <typename Strategy>
264 typename Strategy::PositionType previousCandidateAlgorithm(const typename Strate gy::PositionType& position) 269 typename Strategy::PositionType previousCandidateAlgorithm(const typename Strate gy::PositionType& position)
265 { 270 {
266 using PositionType = typename Strategy::PositionType; 271 using PositionType = typename Strategy::PositionType;
267 typename Strategy::PositionIteratorType p(position); 272 typename Strategy::PositionIteratorType p(position);
268 while (!p.atStart()) { 273 while (!p.atStart()) {
(...skipping 10 matching lines...) Expand all
279 } 284 }
280 285
281 PositionInComposedTree previousCandidate(const PositionInComposedTree& position) 286 PositionInComposedTree previousCandidate(const PositionInComposedTree& position)
282 { 287 {
283 return previousCandidateAlgorithm<EditingInComposedTreeStrategy>(position); 288 return previousCandidateAlgorithm<EditingInComposedTreeStrategy>(position);
284 } 289 }
285 290
286 template <typename PositionType> 291 template <typename PositionType>
287 PositionType previousVisuallyDistinctCandidateAlgorithm(const PositionType& posi tion) 292 PositionType previousVisuallyDistinctCandidateAlgorithm(const PositionType& posi tion)
288 { 293 {
294 // TODO(changseok): Use PositionIterator instead.
289 PositionType p = position; 295 PositionType p = position;
290 PositionType downstreamStart = p.downstream(); 296 PositionType downstreamStart = p.downstream();
291 while (!p.atStartOfTree()) { 297 while (!p.atStartOfTree()) {
292 p = p.previous(Character); 298 p = p.previous(Character);
293 if (p.isCandidate() && p.downstream() != downstreamStart) 299 if (p.isCandidate() && p.downstream() != downstreamStart)
294 return p; 300 return p;
301 if (auto* node = p.containerNode()) {
302 if (!node->isDocumentFragment() && !node->layoutObject())
303 p = PositionType::firstPositionInOrBeforeNode(node);
304 }
295 } 305 }
296 return PositionType(); 306 return PositionType();
297 } 307 }
298 308
299 Position previousVisuallyDistinctCandidate(const Position& position) 309 Position previousVisuallyDistinctCandidate(const Position& position)
300 { 310 {
301 return previousVisuallyDistinctCandidateAlgorithm<Position>(position); 311 return previousVisuallyDistinctCandidateAlgorithm<Position>(position);
302 } 312 }
303 313
304 PositionInComposedTree previousVisuallyDistinctCandidate(const PositionInCompose dTree& position) 314 PositionInComposedTree previousVisuallyDistinctCandidate(const PositionInCompose dTree& position)
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 // if the selection starts just before a paragraph break, skip over it 1253 // if the selection starts just before a paragraph break, skip over it
1244 if (isEndOfParagraph(visiblePosition)) 1254 if (isEndOfParagraph(visiblePosition))
1245 return visiblePosition.next().deepEquivalent().downstream(); 1255 return visiblePosition.next().deepEquivalent().downstream();
1246 1256
1247 // otherwise, make sure to be at the start of the first selected node, 1257 // otherwise, make sure to be at the start of the first selected node,
1248 // instead of possibly at the end of the last node before the selection 1258 // instead of possibly at the end of the last node before the selection
1249 return visiblePosition.deepEquivalent().downstream(); 1259 return visiblePosition.deepEquivalent().downstream();
1250 } 1260 }
1251 1261
1252 } // namespace blink 1262 } // 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