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 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 bool isEnclosingBlock(const Node* node) | 643 bool isEnclosingBlock(const Node* node) |
644 { | 644 { |
645 return node && node->layoutObject() && !node->layoutObject()->isInline() &&
!node->layoutObject()->isRubyText(); | 645 return node && node->layoutObject() && !node->layoutObject()->isInline() &&
!node->layoutObject()->isRubyText(); |
646 } | 646 } |
647 | 647 |
648 bool isInline(const Node* node) | 648 bool isInline(const Node* node) |
649 { | 649 { |
650 return node && node->layoutObject() && node->layoutObject()->isInline(); | 650 return node && node->layoutObject() && node->layoutObject()->isInline(); |
651 } | 651 } |
652 | 652 |
653 // FIXME: Deploy this in all of the places where enclosingBlockFlow/enclosingBlo
ckFlowOrTableElement are used. | 653 // TODO(yosin) Deploy this in all of the places where |enclosingBlockFlow()| and |
654 // FIXME: Pass a position to this function. The enclosing block of [table, x] fo
r example, should be the | 654 // |enclosingBlockFlowOrTableElement()| are used. |
655 // block that contains the table and not the table, and this function should be
the only one responsible for | 655 // TODO(yosin) Callers of |Node| version of |enclosingBlock()| should use |
656 // knowing about these kinds of special cases. | 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 |
| 658 // be the only one responsible for knowing about these kinds of special cases. |
657 Element* enclosingBlock(Node* node, EditingBoundaryCrossingRule rule) | 659 Element* enclosingBlock(Node* node, EditingBoundaryCrossingRule rule) |
658 { | 660 { |
659 Node* enclosingNode = enclosingNodeOfType(firstPositionInOrBeforeNode(node),
isEnclosingBlock, rule); | 661 return enclosingBlock(firstPositionInOrBeforeNode(node), rule); |
| 662 } |
| 663 |
| 664 Element* enclosingBlock(const Position& position, EditingBoundaryCrossingRule ru
le) |
| 665 { |
| 666 Node* enclosingNode = enclosingNodeOfType(position, isEnclosingBlock, rule); |
660 return enclosingNode && enclosingNode->isElementNode() ? toElement(enclosing
Node) : nullptr; | 667 return enclosingNode && enclosingNode->isElementNode() ? toElement(enclosing
Node) : nullptr; |
661 } | 668 } |
662 | 669 |
663 Element* enclosingBlockFlowElement(Node& node) | 670 Element* enclosingBlockFlowElement(Node& node) |
664 { | 671 { |
665 if (isBlockFlowElement(node)) | 672 if (isBlockFlowElement(node)) |
666 return &toElement(node); | 673 return &toElement(node); |
667 | 674 |
668 for (Node* n = node.parentNode(); n; n = n->parentNode()) { | 675 for (Node* n = node.parentNode(); n; n = n->parentNode()) { |
669 if (isBlockFlowElement(*n) || isHTMLBodyElement(*n)) | 676 if (isBlockFlowElement(*n) || isHTMLBodyElement(*n)) |
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1591 // if the selection starts just before a paragraph break, skip over it | 1598 // if the selection starts just before a paragraph break, skip over it |
1592 if (isEndOfParagraph(visiblePosition)) | 1599 if (isEndOfParagraph(visiblePosition)) |
1593 return mostForwardCaretPosition(visiblePosition.next().deepEquivalent())
; | 1600 return mostForwardCaretPosition(visiblePosition.next().deepEquivalent())
; |
1594 | 1601 |
1595 // otherwise, make sure to be at the start of the first selected node, | 1602 // otherwise, make sure to be at the start of the first selected node, |
1596 // instead of possibly at the end of the last node before the selection | 1603 // instead of possibly at the end of the last node before the selection |
1597 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); | 1604 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); |
1598 } | 1605 } |
1599 | 1606 |
1600 } // namespace blink | 1607 } // namespace blink |
OLD | NEW |