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 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 for (Node* n = node; n && n->parentNode(); n = n->parentNode()) { | 673 for (Node* n = node; n && n->parentNode(); n = n->parentNode()) { |
674 if (n->hasTagName(liTag) || (isListElement(n->parentNode()) && n != root
)) | 674 if (n->hasTagName(liTag) || (isListElement(n->parentNode()) && n != root
)) |
675 return n; | 675 return n; |
676 if (n == root || isTableCell(n)) | 676 if (n == root || isTableCell(n)) |
677 return 0; | 677 return 0; |
678 } | 678 } |
679 | 679 |
680 return 0; | 680 return 0; |
681 } | 681 } |
682 | 682 |
683 static HTMLElement* embeddedSublist(Node* listItem) | |
684 { | |
685 // Check the DOM so that we'll find collapsed sublists without renderers. | |
686 for (Node* n = listItem->firstChild(); n; n = n->nextSibling()) { | |
687 if (isListElement(n)) | |
688 return toHTMLElement(n); | |
689 } | |
690 | |
691 return 0; | |
692 } | |
693 | |
694 static Node* appendedSublist(Node* listItem) | |
695 { | |
696 // Check the DOM so that we'll find collapsed sublists without renderers. | |
697 for (Node* n = listItem->nextSibling(); n; n = n->nextSibling()) { | |
698 if (isListElement(n)) | |
699 return toHTMLElement(n); | |
700 if (isListItem(listItem)) | |
701 return 0; | |
702 } | |
703 | |
704 return 0; | |
705 } | |
706 | |
707 // FIXME: This method should not need to call isStartOfParagraph/isEndOfParagrap
h | 683 // FIXME: This method should not need to call isStartOfParagraph/isEndOfParagrap
h |
708 Node* enclosingEmptyListItem(const VisiblePosition& visiblePos) | 684 Node* enclosingEmptyListItem(const VisiblePosition& visiblePos) |
709 { | 685 { |
710 // Check that position is on a line by itself inside a list item | 686 // Check that position is on a line by itself inside a list item |
711 Node* listChildNode = enclosingListChild(visiblePos.deepEquivalent().depreca
tedNode()); | 687 Node* listChildNode = enclosingListChild(visiblePos.deepEquivalent().depreca
tedNode()); |
712 if (!listChildNode || !isStartOfParagraph(visiblePos) || !isEndOfParagraph(v
isiblePos)) | 688 if (!listChildNode || !isStartOfParagraph(visiblePos) || !isEndOfParagraph(v
isiblePos)) |
713 return 0; | 689 return 0; |
714 | 690 |
715 VisiblePosition firstInListChild(firstPositionInOrBeforeNode(listChildNode))
; | 691 VisiblePosition firstInListChild(firstPositionInOrBeforeNode(listChildNode))
; |
716 VisiblePosition lastInListChild(lastPositionInOrAfterNode(listChildNode)); | 692 VisiblePosition lastInListChild(lastPositionInOrAfterNode(listChildNode)); |
717 | 693 |
718 if (firstInListChild != visiblePos || lastInListChild != visiblePos) | 694 if (firstInListChild != visiblePos || lastInListChild != visiblePos) |
719 return 0; | 695 return 0; |
720 | 696 |
721 if (embeddedSublist(listChildNode) || appendedSublist(listChildNode)) | |
722 return 0; | |
723 | |
724 return listChildNode; | 697 return listChildNode; |
725 } | 698 } |
726 | 699 |
727 HTMLElement* outermostEnclosingList(Node* node, Node* rootList) | 700 HTMLElement* outermostEnclosingList(Node* node, Node* rootList) |
728 { | 701 { |
729 HTMLElement* list = enclosingList(node); | 702 HTMLElement* list = enclosingList(node); |
730 if (!list) | 703 if (!list) |
731 return 0; | 704 return 0; |
732 | 705 |
733 while (HTMLElement* nextList = enclosingList(list)) { | 706 while (HTMLElement* nextList = enclosingList(list)) { |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 // if the selection starts just before a paragraph break, skip over it | 1133 // if the selection starts just before a paragraph break, skip over it |
1161 if (isEndOfParagraph(visiblePosition)) | 1134 if (isEndOfParagraph(visiblePosition)) |
1162 return visiblePosition.next().deepEquivalent().downstream(); | 1135 return visiblePosition.next().deepEquivalent().downstream(); |
1163 | 1136 |
1164 // otherwise, make sure to be at the start of the first selected node, | 1137 // otherwise, make sure to be at the start of the first selected node, |
1165 // instead of possibly at the end of the last node before the selection | 1138 // instead of possibly at the end of the last node before the selection |
1166 return visiblePosition.deepEquivalent().downstream(); | 1139 return visiblePosition.deepEquivalent().downstream(); |
1167 } | 1140 } |
1168 | 1141 |
1169 } // namespace WebCore | 1142 } // namespace WebCore |
OLD | NEW |