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 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 Position nextPositionOf(const Position& position, PositionMoveType moveType) | 633 Position nextPositionOf(const Position& position, PositionMoveType moveType) |
634 { | 634 { |
635 return nextPositionOfAlgorithm<EditingStrategy>(position, moveType); | 635 return nextPositionOfAlgorithm<EditingStrategy>(position, moveType); |
636 } | 636 } |
637 | 637 |
638 PositionInComposedTree nextPositionOf(const PositionInComposedTree& position, Po
sitionMoveType moveType) | 638 PositionInComposedTree nextPositionOf(const PositionInComposedTree& position, Po
sitionMoveType moveType) |
639 { | 639 { |
640 return nextPositionOfAlgorithm<EditingInComposedTreeStrategy>(position, move
Type); | 640 return nextPositionOfAlgorithm<EditingInComposedTreeStrategy>(position, move
Type); |
641 } | 641 } |
642 | 642 |
643 // FIXME: The method name, comment, and code say three different things here! | 643 bool isEnclosingBlock(const Node* node) |
644 // Whether or not content before and after this node will collapse onto the same
line as it. | |
645 bool isBlock(const Node* node) | |
646 { | 644 { |
647 return node && node->layoutObject() && !node->layoutObject()->isInline() &&
!node->layoutObject()->isRubyText(); | 645 return node && node->layoutObject() && !node->layoutObject()->isInline() &&
!node->layoutObject()->isRubyText(); |
648 } | 646 } |
649 | 647 |
650 bool isInline(const Node* node) | 648 bool isInline(const Node* node) |
651 { | 649 { |
652 return node && node->layoutObject() && node->layoutObject()->isInline(); | 650 return node && node->layoutObject() && node->layoutObject()->isInline(); |
653 } | 651 } |
654 | 652 |
655 // FIXME: Deploy this in all of the places where enclosingBlockFlow/enclosingBlo
ckFlowOrTableElement are used. | 653 // FIXME: Deploy this in all of the places where enclosingBlockFlow/enclosingBlo
ckFlowOrTableElement are used. |
656 // FIXME: Pass a position to this function. The enclosing block of [table, x] fo
r example, should be the | 654 // FIXME: Pass a position to this function. The enclosing block of [table, x] fo
r example, should be the |
657 // block that contains the table and not the table, and this function should be
the only one responsible for | 655 // block that contains the table and not the table, and this function should be
the only one responsible for |
658 // knowing about these kinds of special cases. | 656 // knowing about these kinds of special cases. |
659 Element* enclosingBlock(Node* node, EditingBoundaryCrossingRule rule) | 657 Element* enclosingBlock(Node* node, EditingBoundaryCrossingRule rule) |
660 { | 658 { |
661 Node* enclosingNode = enclosingNodeOfType(firstPositionInOrBeforeNode(node),
isBlock, rule); | 659 Node* enclosingNode = enclosingNodeOfType(firstPositionInOrBeforeNode(node),
isEnclosingBlock, rule); |
662 return enclosingNode && enclosingNode->isElementNode() ? toElement(enclosing
Node) : 0; | 660 return enclosingNode && enclosingNode->isElementNode() ? toElement(enclosing
Node) : nullptr; |
663 } | 661 } |
664 | 662 |
665 Element* enclosingBlockFlowElement(Node& node) | 663 Element* enclosingBlockFlowElement(Node& node) |
666 { | 664 { |
667 if (isBlockFlowElement(node)) | 665 if (isBlockFlowElement(node)) |
668 return &toElement(node); | 666 return &toElement(node); |
669 | 667 |
670 for (Node* n = node.parentNode(); n; n = n->parentNode()) { | 668 for (Node* n = node.parentNode(); n; n = n->parentNode()) { |
671 if (isBlockFlowElement(*n) || isHTMLBodyElement(*n)) | 669 if (isBlockFlowElement(*n) || isHTMLBodyElement(*n)) |
672 return toElement(n); | 670 return toElement(n); |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1593 // if the selection starts just before a paragraph break, skip over it | 1591 // if the selection starts just before a paragraph break, skip over it |
1594 if (isEndOfParagraph(visiblePosition)) | 1592 if (isEndOfParagraph(visiblePosition)) |
1595 return mostForwardCaretPosition(visiblePosition.next().deepEquivalent())
; | 1593 return mostForwardCaretPosition(visiblePosition.next().deepEquivalent())
; |
1596 | 1594 |
1597 // otherwise, make sure to be at the start of the first selected node, | 1595 // otherwise, make sure to be at the start of the first selected node, |
1598 // instead of possibly at the end of the last node before the selection | 1596 // instead of possibly at the end of the last node before the selection |
1599 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); | 1597 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); |
1600 } | 1598 } |
1601 | 1599 |
1602 } // namespace blink | 1600 } // namespace blink |
OLD | NEW |