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

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: Updated patch Created 5 years, 4 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 if (enclosingCell) 327 if (enclosingCell)
328 return enclosingCell; 328 return enclosingCell;
329 329
330 return editableRootForPosition(p); 330 return editableRootForPosition(p);
331 } 331 }
332 332
333 template <typename Strategy> 333 template <typename Strategy>
334 PositionAlgorithm<Strategy> nextCandidateAlgorithm(const PositionAlgorithm<Strat egy>& position) 334 PositionAlgorithm<Strategy> nextCandidateAlgorithm(const PositionAlgorithm<Strat egy>& position)
335 { 335 {
336 PositionIteratorAlgorithm<Strategy> p(position); 336 PositionIteratorAlgorithm<Strategy> p(position);
337
338 p.increment();
337 while (!p.atEnd()) { 339 while (!p.atEnd()) {
338 p.increment();
339 PositionAlgorithm<Strategy> candidate = p.computePosition(); 340 PositionAlgorithm<Strategy> candidate = p.computePosition();
340 if (candidate.isCandidate()) 341 if (candidate.isCandidate())
341 return candidate; 342 return candidate;
343
344 p.increment();
342 } 345 }
346
343 return PositionAlgorithm<Strategy>(); 347 return PositionAlgorithm<Strategy>();
344 } 348 }
345 349
346 Position nextCandidate(const Position& position) 350 Position nextCandidate(const Position& position)
347 { 351 {
348 return nextCandidateAlgorithm<EditingStrategy>(position); 352 return nextCandidateAlgorithm<EditingStrategy>(position);
349 } 353 }
350 354
351 PositionInComposedTree nextCandidate(const PositionInComposedTree& position) 355 PositionInComposedTree nextCandidate(const PositionInComposedTree& position)
352 { 356 {
353 return nextCandidateAlgorithm<EditingInComposedTreeStrategy>(position); 357 return nextCandidateAlgorithm<EditingInComposedTreeStrategy>(position);
354 } 358 }
355 359
356 // |nextVisuallyDistinctCandidate| is similar to |nextCandidate| except 360 // |nextVisuallyDistinctCandidate| is similar to |nextCandidate| except
357 // for returning position which |downstream()| not equal to initial position's 361 // for returning position which |downstream()| not equal to initial position's
358 // |downstream()|. 362 // |downstream()|.
359 Position nextVisuallyDistinctCandidate(const Position& position) 363 Position nextVisuallyDistinctCandidate(const Position& position)
360 { 364 {
361 if (position.isNull()) 365 if (position.isNull())
362 return position; 366 return Position();
367
363 PositionIterator p(position); 368 PositionIterator p(position);
364 Position downstreamStart = position.downstream(); 369 Position downstreamStart = position.downstream();
370
371 p.increment();
365 while (!p.atEnd()) { 372 while (!p.atEnd()) {
366 p.increment();
367 Position candidate = p.computePosition(); 373 Position candidate = p.computePosition();
368 if (candidate.isCandidate() && candidate.downstream() != downstreamStart ) 374 if (candidate.isCandidate() && candidate.downstream() != downstreamStart )
369 return candidate; 375 return candidate;
376
377 p.increment();
370 } 378 }
379
371 return Position(); 380 return Position();
372 } 381 }
373 382
374 template <typename Strategy> 383 template <typename Strategy>
375 PositionAlgorithm<Strategy> previousCandidateAlgorithm(const PositionAlgorithm<S trategy>& position) 384 PositionAlgorithm<Strategy> previousCandidateAlgorithm(const PositionAlgorithm<S trategy>& position)
376 { 385 {
377 PositionIteratorAlgorithm<Strategy> p(position); 386 PositionIteratorAlgorithm<Strategy> p(position);
387
388 p.decrement();
378 while (!p.atStart()) { 389 while (!p.atStart()) {
379 p.decrement();
380 PositionAlgorithm<Strategy> candidate = p.computePosition(); 390 PositionAlgorithm<Strategy> candidate = p.computePosition();
381 if (candidate.isCandidate()) 391 if (candidate.isCandidate())
382 return candidate; 392 return candidate;
393
394 p.decrement();
383 } 395 }
396
384 return PositionAlgorithm<Strategy>(); 397 return PositionAlgorithm<Strategy>();
385 } 398 }
386 399
387 Position previousCandidate(const Position& position) 400 Position previousCandidate(const Position& position)
388 { 401 {
389 return previousCandidateAlgorithm<EditingStrategy>(position); 402 return previousCandidateAlgorithm<EditingStrategy>(position);
390 } 403 }
391 404
392 PositionInComposedTree previousCandidate(const PositionInComposedTree& position) 405 PositionInComposedTree previousCandidate(const PositionInComposedTree& position)
393 { 406 {
394 return previousCandidateAlgorithm<EditingInComposedTreeStrategy>(position); 407 return previousCandidateAlgorithm<EditingInComposedTreeStrategy>(position);
395 } 408 }
396 409
397 // |previousVisuallyDistinctCandidate| is similar to |previousCandidate| except 410 // |previousVisuallyDistinctCandidate| is similar to |previousCandidate| except
398 // for returning position which |downstream()| not equal to initial position's 411 // for returning position which |downstream()| not equal to initial position's
399 // |downstream()|. 412 // |downstream()|.
400 template <typename Strategy> 413 template <typename Strategy>
401 PositionAlgorithm<Strategy> previousVisuallyDistinctCandidateAlgorithm(const Pos itionAlgorithm<Strategy>& position) 414 PositionAlgorithm<Strategy> previousVisuallyDistinctCandidateAlgorithm(const Pos itionAlgorithm<Strategy>& position)
402 { 415 {
403 if (position.isNull()) 416 if (position.isNull())
404 return position; 417 return PositionAlgorithm<Strategy>();
418
405 PositionIteratorAlgorithm<Strategy> p(position); 419 PositionIteratorAlgorithm<Strategy> p(position);
406 PositionAlgorithm<Strategy> downstreamStart = position.downstream(); 420 PositionAlgorithm<Strategy> downstreamStart = position.downstream();
421
422 p.decrement();
407 while (!p.atStart()) { 423 while (!p.atStart()) {
408 p.decrement();
409 PositionAlgorithm<Strategy> candidate = p.computePosition(); 424 PositionAlgorithm<Strategy> candidate = p.computePosition();
410 if (candidate.isCandidate() && candidate.downstream() != downstreamStart ) 425 if (candidate.isCandidate() && candidate.downstream() != downstreamStart )
411 return candidate; 426 return candidate;
427
428 p.decrement();
412 } 429 }
430
413 return PositionAlgorithm<Strategy>(); 431 return PositionAlgorithm<Strategy>();
414 } 432 }
415 433
416 Position previousVisuallyDistinctCandidate(const Position& position) 434 Position previousVisuallyDistinctCandidate(const Position& position)
417 { 435 {
418 return previousVisuallyDistinctCandidateAlgorithm<EditingStrategy>(position) ; 436 return previousVisuallyDistinctCandidateAlgorithm<EditingStrategy>(position) ;
419 } 437 }
420 438
421 PositionInComposedTree previousVisuallyDistinctCandidate(const PositionInCompose dTree& position) 439 PositionInComposedTree previousVisuallyDistinctCandidate(const PositionInCompose dTree& position)
422 { 440 {
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 // if the selection starts just before a paragraph break, skip over it 1432 // if the selection starts just before a paragraph break, skip over it
1415 if (isEndOfParagraph(visiblePosition)) 1433 if (isEndOfParagraph(visiblePosition))
1416 return visiblePosition.next().deepEquivalent().downstream(); 1434 return visiblePosition.next().deepEquivalent().downstream();
1417 1435
1418 // otherwise, make sure to be at the start of the first selected node, 1436 // otherwise, make sure to be at the start of the first selected node,
1419 // instead of possibly at the end of the last node before the selection 1437 // instead of possibly at the end of the last node before the selection
1420 return visiblePosition.deepEquivalent().downstream(); 1438 return visiblePosition.deepEquivalent().downstream();
1421 } 1439 }
1422 1440
1423 } // namespace blink 1441 } // 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