OLD | NEW |
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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 } | 353 } |
354 | 354 |
355 PositionInComposedTree nextCandidate(const PositionInComposedTree& position) | 355 PositionInComposedTree nextCandidate(const PositionInComposedTree& position) |
356 { | 356 { |
357 return nextCandidateAlgorithm<EditingInComposedTreeStrategy>(position); | 357 return nextCandidateAlgorithm<EditingInComposedTreeStrategy>(position); |
358 } | 358 } |
359 | 359 |
360 // |nextVisuallyDistinctCandidate| is similar to |nextCandidate| except | 360 // |nextVisuallyDistinctCandidate| is similar to |nextCandidate| except |
361 // for returning position which |downstream()| not equal to initial position's | 361 // for returning position which |downstream()| not equal to initial position's |
362 // |downstream()|. | 362 // |downstream()|. |
363 Position nextVisuallyDistinctCandidate(const Position& position) | 363 template <typename Strategy> |
| 364 static PositionAlgorithm<Strategy> nextVisuallyDistinctCandidateAlgorithm(const
PositionAlgorithm<Strategy>& position) |
364 { | 365 { |
365 if (position.isNull()) | 366 if (position.isNull()) |
366 return Position(); | 367 return PositionAlgorithm<Strategy>(); |
367 | 368 |
368 PositionIterator p(position); | 369 PositionIteratorAlgorithm<Strategy> p(position); |
369 Position downstreamStart = mostForwardCaretPosition(position); | 370 const PositionAlgorithm<Strategy> downstreamStart = mostForwardCaretPosition
(position); |
370 | 371 |
371 p.increment(); | 372 p.increment(); |
372 while (!p.atEnd()) { | 373 while (!p.atEnd()) { |
373 Position candidate = p.computePosition(); | 374 PositionAlgorithm<Strategy> candidate = p.computePosition(); |
374 if (isVisuallyEquivalentCandidate(candidate) && mostForwardCaretPosition
(candidate) != downstreamStart) | 375 if (isVisuallyEquivalentCandidate(candidate) && mostForwardCaretPosition
(candidate) != downstreamStart) |
375 return candidate; | 376 return candidate; |
376 | 377 |
377 p.increment(); | 378 p.increment(); |
378 } | 379 } |
379 | 380 |
380 return Position(); | 381 return PositionAlgorithm<Strategy>(); |
| 382 } |
| 383 |
| 384 Position nextVisuallyDistinctCandidate(const Position& position) |
| 385 { |
| 386 return nextVisuallyDistinctCandidateAlgorithm<EditingStrategy>(position); |
| 387 } |
| 388 |
| 389 PositionInComposedTree nextVisuallyDistinctCandidate(const PositionInComposedTre
e& position) |
| 390 { |
| 391 return nextVisuallyDistinctCandidateAlgorithm<EditingInComposedTreeStrategy>
(position); |
381 } | 392 } |
382 | 393 |
383 template <typename Strategy> | 394 template <typename Strategy> |
384 PositionAlgorithm<Strategy> previousCandidateAlgorithm(const PositionAlgorithm<S
trategy>& position) | 395 PositionAlgorithm<Strategy> previousCandidateAlgorithm(const PositionAlgorithm<S
trategy>& position) |
385 { | 396 { |
386 PositionIteratorAlgorithm<Strategy> p(position); | 397 PositionIteratorAlgorithm<Strategy> p(position); |
387 | 398 |
388 p.decrement(); | 399 p.decrement(); |
389 while (!p.atStart()) { | 400 while (!p.atStart()) { |
390 PositionAlgorithm<Strategy> candidate = p.computePosition(); | 401 PositionAlgorithm<Strategy> candidate = p.computePosition(); |
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1555 // if the selection starts just before a paragraph break, skip over it | 1566 // if the selection starts just before a paragraph break, skip over it |
1556 if (isEndOfParagraph(visiblePosition)) | 1567 if (isEndOfParagraph(visiblePosition)) |
1557 return mostForwardCaretPosition(visiblePosition.next().deepEquivalent())
; | 1568 return mostForwardCaretPosition(visiblePosition.next().deepEquivalent())
; |
1558 | 1569 |
1559 // otherwise, make sure to be at the start of the first selected node, | 1570 // otherwise, make sure to be at the start of the first selected node, |
1560 // instead of possibly at the end of the last node before the selection | 1571 // instead of possibly at the end of the last node before the selection |
1561 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); | 1572 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); |
1562 } | 1573 } |
1563 | 1574 |
1564 } // namespace blink | 1575 } // namespace blink |
OLD | NEW |