OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2009 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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 } | 463 } |
464 | 464 |
465 template <typename Strategy> | 465 template <typename Strategy> |
466 static ContainerNode* nonShadowBoundaryParentNode(Node* node) | 466 static ContainerNode* nonShadowBoundaryParentNode(Node* node) |
467 { | 467 { |
468 ContainerNode* parent = Strategy::parent(*node); | 468 ContainerNode* parent = Strategy::parent(*node); |
469 return parent && !parent->isShadowRoot() ? parent : nullptr; | 469 return parent && !parent->isShadowRoot() ? parent : nullptr; |
470 } | 470 } |
471 | 471 |
472 template <typename Strategy> | 472 template <typename Strategy> |
473 Node* PositionAlgorithm<Strategy>::parentEditingBoundary() const | 473 static Node* parentEditingBoundaryAlgorithm(const PositionAlgorithm<Strategy>& p
osition) |
474 { | 474 { |
475 if (!m_anchorNode) | 475 Node* const anchorNode = position.anchorNode(); |
476 return 0; | 476 if (!anchorNode) |
| 477 return nullptr; |
477 | 478 |
478 Node* documentElement = m_anchorNode->document().documentElement(); | 479 Node* documentElement = anchorNode->document().documentElement(); |
479 if (!documentElement) | 480 if (!documentElement) |
480 return 0; | 481 return nullptr; |
481 | 482 |
482 Node* boundary = computeContainerNode(); | 483 Node* boundary = position.computeContainerNode(); |
483 while (boundary != documentElement && nonShadowBoundaryParentNode<Strategy>(
boundary) && m_anchorNode->hasEditableStyle() == Strategy::parent(*boundary)->ha
sEditableStyle()) | 484 while (boundary != documentElement && nonShadowBoundaryParentNode<Strategy>(
boundary) && anchorNode->hasEditableStyle() == Strategy::parent(*boundary)->hasE
ditableStyle()) |
484 boundary = nonShadowBoundaryParentNode<Strategy>(boundary); | 485 boundary = nonShadowBoundaryParentNode<Strategy>(boundary); |
485 | 486 |
486 return boundary; | 487 return boundary; |
487 } | 488 } |
488 | 489 |
| 490 Node* parentEditingBoundary(const Position& position) |
| 491 { |
| 492 return parentEditingBoundaryAlgorithm<EditingStrategy>(position); |
| 493 } |
| 494 |
| 495 Node* parentEditingBoundary(const PositionInComposedTree& position) |
| 496 { |
| 497 return parentEditingBoundaryAlgorithm<EditingInComposedTreeStrategy>(positio
n); |
| 498 } |
489 | 499 |
490 template <typename Strategy> | 500 template <typename Strategy> |
491 bool PositionAlgorithm<Strategy>::atStartOfTree() const | 501 bool PositionAlgorithm<Strategy>::atStartOfTree() const |
492 { | 502 { |
493 if (isNull()) | 503 if (isNull()) |
494 return true; | 504 return true; |
495 return !Strategy::parent(*anchorNode()) && m_offset == 0; | 505 return !Strategy::parent(*anchorNode()) && m_offset == 0; |
496 } | 506 } |
497 | 507 |
498 template <typename Strategy> | 508 template <typename Strategy> |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1349 | 1359 |
1350 void showTree(const blink::Position* pos) | 1360 void showTree(const blink::Position* pos) |
1351 { | 1361 { |
1352 if (pos) | 1362 if (pos) |
1353 pos->showTreeForThis(); | 1363 pos->showTreeForThis(); |
1354 else | 1364 else |
1355 fprintf(stderr, "Cannot showTree for (nil)\n"); | 1365 fprintf(stderr, "Cannot showTree for (nil)\n"); |
1356 } | 1366 } |
1357 | 1367 |
1358 #endif | 1368 #endif |
OLD | NEW |