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 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 // |enclosingBlockFlowOrTableElement()| are used. | 654 // |enclosingBlockFlowOrTableElement()| are used. |
655 // TODO(yosin) Callers of |Node| version of |enclosingBlock()| should use | 655 // TODO(yosin) Callers of |Node| version of |enclosingBlock()| should use |
656 // |Position| version The enclosing block of [table, x] for example, should be | 656 // |Position| version The enclosing block of [table, x] for example, should be |
657 // the block that contains the table and not the table, and this function should | 657 // the block that contains the table and not the table, and this function should |
658 // be the only one responsible for knowing about these kinds of special cases. | 658 // be the only one responsible for knowing about these kinds of special cases. |
659 Element* enclosingBlock(Node* node, EditingBoundaryCrossingRule rule) | 659 Element* enclosingBlock(Node* node, EditingBoundaryCrossingRule rule) |
660 { | 660 { |
661 return enclosingBlock(firstPositionInOrBeforeNode(node), rule); | 661 return enclosingBlock(firstPositionInOrBeforeNode(node), rule); |
662 } | 662 } |
663 | 663 |
664 Element* enclosingBlock(const Position& position, EditingBoundaryCrossingRule ru
le) | 664 template <typename Strategy> |
| 665 Element* enclosingBlockAlgorithm(const PositionAlgorithm<Strategy>& position, Ed
itingBoundaryCrossingRule rule) |
665 { | 666 { |
666 Node* enclosingNode = enclosingNodeOfType(position, isEnclosingBlock, rule); | 667 Node* enclosingNode = enclosingNodeOfType(position, isEnclosingBlock, rule); |
667 return enclosingNode && enclosingNode->isElementNode() ? toElement(enclosing
Node) : nullptr; | 668 return enclosingNode && enclosingNode->isElementNode() ? toElement(enclosing
Node) : nullptr; |
668 } | 669 } |
669 | 670 |
| 671 Element* enclosingBlock(const Position& position, EditingBoundaryCrossingRule ru
le) |
| 672 { |
| 673 return enclosingBlockAlgorithm<EditingStrategy>(position, rule); |
| 674 } |
| 675 |
| 676 Element* enclosingBlock(const PositionInComposedTree& position, EditingBoundaryC
rossingRule rule) |
| 677 { |
| 678 return enclosingBlockAlgorithm<EditingInComposedTreeStrategy>(position, rule
); |
| 679 } |
| 680 |
670 Element* enclosingBlockFlowElement(Node& node) | 681 Element* enclosingBlockFlowElement(Node& node) |
671 { | 682 { |
672 if (isBlockFlowElement(node)) | 683 if (isBlockFlowElement(node)) |
673 return &toElement(node); | 684 return &toElement(node); |
674 | 685 |
675 for (Node* n = node.parentNode(); n; n = n->parentNode()) { | 686 for (Node* n = node.parentNode(); n; n = n->parentNode()) { |
676 if (isBlockFlowElement(*n) || isHTMLBodyElement(*n)) | 687 if (isBlockFlowElement(*n) || isHTMLBodyElement(*n)) |
677 return toElement(n); | 688 return toElement(n); |
678 } | 689 } |
679 return 0; | 690 return 0; |
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 // if the selection starts just before a paragraph break, skip over it | 1609 // if the selection starts just before a paragraph break, skip over it |
1599 if (isEndOfParagraph(visiblePosition)) | 1610 if (isEndOfParagraph(visiblePosition)) |
1600 return mostForwardCaretPosition(visiblePosition.next().deepEquivalent())
; | 1611 return mostForwardCaretPosition(visiblePosition.next().deepEquivalent())
; |
1601 | 1612 |
1602 // otherwise, make sure to be at the start of the first selected node, | 1613 // otherwise, make sure to be at the start of the first selected node, |
1603 // instead of possibly at the end of the last node before the selection | 1614 // instead of possibly at the end of the last node before the selection |
1604 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); | 1615 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); |
1605 } | 1616 } |
1606 | 1617 |
1607 } // namespace blink | 1618 } // namespace blink |
OLD | NEW |