| 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 return nextCandidateAlgorithm<EditingStrategy>(position); | 348 return nextCandidateAlgorithm<EditingStrategy>(position); |
| 349 } | 349 } |
| 350 | 350 |
| 351 PositionInComposedTree nextCandidate(const PositionInComposedTree& position) | 351 PositionInComposedTree nextCandidate(const PositionInComposedTree& position) |
| 352 { | 352 { |
| 353 return nextCandidateAlgorithm<EditingInComposedTreeStrategy>(position); | 353 return nextCandidateAlgorithm<EditingInComposedTreeStrategy>(position); |
| 354 } | 354 } |
| 355 | 355 |
| 356 Position nextVisuallyDistinctCandidate(const Position& position) | 356 Position nextVisuallyDistinctCandidate(const Position& position) |
| 357 { | 357 { |
| 358 // TODO(changseok): Use PositionIterator instead. |
| 358 Position p = position; | 359 Position p = position; |
| 359 Position downstreamStart = p.downstream(); | 360 Position downstreamStart = p.downstream(); |
| 360 while (!p.atEndOfTree()) { | 361 while (!p.atEndOfTree()) { |
| 361 p = p.next(Character); | 362 p = p.next(Character); |
| 362 if (p.isCandidate() && p.downstream() != downstreamStart) | 363 if (p.isCandidate() && p.downstream() != downstreamStart) |
| 363 return p; | 364 return p; |
| 365 if (auto* node = p.containerNode()) { |
| 366 if (!node->layoutObject()) |
| 367 p = lastPositionInOrAfterNode(node); |
| 368 } |
| 364 } | 369 } |
| 365 return Position(); | 370 return Position(); |
| 366 } | 371 } |
| 367 | 372 |
| 368 template <typename Strategy> | 373 template <typename Strategy> |
| 369 typename Strategy::PositionType previousCandidateAlgorithm(const typename Strate
gy::PositionType& position) | 374 typename Strategy::PositionType previousCandidateAlgorithm(const typename Strate
gy::PositionType& position) |
| 370 { | 375 { |
| 371 using PositionType = typename Strategy::PositionType; | 376 using PositionType = typename Strategy::PositionType; |
| 372 PositionIteratorAlgorithm<Strategy> p(position); | 377 PositionIteratorAlgorithm<Strategy> p(position); |
| 373 while (!p.atStart()) { | 378 while (!p.atStart()) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 384 } | 389 } |
| 385 | 390 |
| 386 PositionInComposedTree previousCandidate(const PositionInComposedTree& position) | 391 PositionInComposedTree previousCandidate(const PositionInComposedTree& position) |
| 387 { | 392 { |
| 388 return previousCandidateAlgorithm<EditingInComposedTreeStrategy>(position); | 393 return previousCandidateAlgorithm<EditingInComposedTreeStrategy>(position); |
| 389 } | 394 } |
| 390 | 395 |
| 391 template <typename PositionType> | 396 template <typename PositionType> |
| 392 PositionType previousVisuallyDistinctCandidateAlgorithm(const PositionType& posi
tion) | 397 PositionType previousVisuallyDistinctCandidateAlgorithm(const PositionType& posi
tion) |
| 393 { | 398 { |
| 399 // TODO(changseok): Use PositionIterator instead. |
| 394 PositionType p = position; | 400 PositionType p = position; |
| 395 PositionType downstreamStart = p.downstream(); | 401 PositionType downstreamStart = p.downstream(); |
| 396 while (!p.atStartOfTree()) { | 402 while (!p.atStartOfTree()) { |
| 397 p = p.previous(Character); | 403 p = p.previous(Character); |
| 398 if (p.isCandidate() && p.downstream() != downstreamStart) | 404 if (p.isCandidate() && p.downstream() != downstreamStart) |
| 399 return p; | 405 return p; |
| 406 if (auto* node = p.containerNode()) { |
| 407 if (!node->layoutObject()) |
| 408 p = PositionType::firstPositionInOrBeforeNode(node); |
| 409 } |
| 400 } | 410 } |
| 401 return PositionType(); | 411 return PositionType(); |
| 402 } | 412 } |
| 403 | 413 |
| 404 Position previousVisuallyDistinctCandidate(const Position& position) | 414 Position previousVisuallyDistinctCandidate(const Position& position) |
| 405 { | 415 { |
| 406 return previousVisuallyDistinctCandidateAlgorithm<Position>(position); | 416 return previousVisuallyDistinctCandidateAlgorithm<Position>(position); |
| 407 } | 417 } |
| 408 | 418 |
| 409 PositionInComposedTree previousVisuallyDistinctCandidate(const PositionInCompose
dTree& position) | 419 PositionInComposedTree previousVisuallyDistinctCandidate(const PositionInCompose
dTree& position) |
| (...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1348 // if the selection starts just before a paragraph break, skip over it | 1358 // if the selection starts just before a paragraph break, skip over it |
| 1349 if (isEndOfParagraph(visiblePosition)) | 1359 if (isEndOfParagraph(visiblePosition)) |
| 1350 return visiblePosition.next().deepEquivalent().downstream(); | 1360 return visiblePosition.next().deepEquivalent().downstream(); |
| 1351 | 1361 |
| 1352 // otherwise, make sure to be at the start of the first selected node, | 1362 // otherwise, make sure to be at the start of the first selected node, |
| 1353 // instead of possibly at the end of the last node before the selection | 1363 // instead of possibly at the end of the last node before the selection |
| 1354 return visiblePosition.deepEquivalent().downstream(); | 1364 return visiblePosition.deepEquivalent().downstream(); |
| 1355 } | 1365 } |
| 1356 | 1366 |
| 1357 } // namespace blink | 1367 } // namespace blink |
| OLD | NEW |