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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 return false; | 427 return false; |
428 } | 428 } |
429 | 429 |
430 static Node* firstInSpecialElement(const Position& pos) | 430 static Node* firstInSpecialElement(const Position& pos) |
431 { | 431 { |
432 Node* rootEditableElement = pos.containerNode()->rootEditableElement(); | 432 Node* rootEditableElement = pos.containerNode()->rootEditableElement(); |
433 for (Node* n = pos.deprecatedNode(); n && n->rootEditableElement() == rootEd
itableElement; n = n->parentNode()) | 433 for (Node* n = pos.deprecatedNode(); n && n->rootEditableElement() == rootEd
itableElement; n = n->parentNode()) |
434 if (isSpecialElement(n)) { | 434 if (isSpecialElement(n)) { |
435 VisiblePosition vPos = VisiblePosition(pos, DOWNSTREAM); | 435 VisiblePosition vPos = VisiblePosition(pos, DOWNSTREAM); |
436 VisiblePosition firstInElement = VisiblePosition(firstPositionInOrBe
foreNode(n), DOWNSTREAM); | 436 VisiblePosition firstInElement = VisiblePosition(firstPositionInOrBe
foreNode(n), DOWNSTREAM); |
437 if (isTableElement(n) && vPos == firstInElement.next()) | 437 if (isRenderedTable(n) && vPos == firstInElement.next()) |
438 return n; | 438 return n; |
439 if (vPos == firstInElement) | 439 if (vPos == firstInElement) |
440 return n; | 440 return n; |
441 } | 441 } |
442 return 0; | 442 return 0; |
443 } | 443 } |
444 | 444 |
445 static Node* lastInSpecialElement(const Position& pos) | 445 static Node* lastInSpecialElement(const Position& pos) |
446 { | 446 { |
447 Node* rootEditableElement = pos.containerNode()->rootEditableElement(); | 447 Node* rootEditableElement = pos.containerNode()->rootEditableElement(); |
448 for (Node* n = pos.deprecatedNode(); n && n->rootEditableElement() == rootEd
itableElement; n = n->parentNode()) | 448 for (Node* n = pos.deprecatedNode(); n && n->rootEditableElement() == rootEd
itableElement; n = n->parentNode()) |
449 if (isSpecialElement(n)) { | 449 if (isSpecialElement(n)) { |
450 VisiblePosition vPos = VisiblePosition(pos, DOWNSTREAM); | 450 VisiblePosition vPos = VisiblePosition(pos, DOWNSTREAM); |
451 VisiblePosition lastInElement = VisiblePosition(lastPositionInOrAfte
rNode(n), DOWNSTREAM); | 451 VisiblePosition lastInElement = VisiblePosition(lastPositionInOrAfte
rNode(n), DOWNSTREAM); |
452 if (isTableElement(n) && vPos == lastInElement.previous()) | 452 if (isRenderedTable(n) && vPos == lastInElement.previous()) |
453 return n; | 453 return n; |
454 if (vPos == lastInElement) | 454 if (vPos == lastInElement) |
455 return n; | 455 return n; |
456 } | 456 } |
457 return 0; | 457 return 0; |
458 } | 458 } |
459 | 459 |
460 Position positionBeforeContainingSpecialElement(const Position& pos, Node** cont
ainingSpecialElement) | 460 Position positionBeforeContainingSpecialElement(const Position& pos, Node** cont
ainingSpecialElement) |
461 { | 461 { |
462 Node* n = firstInSpecialElement(pos); | 462 Node* n = firstInSpecialElement(pos); |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 if (!firstList || !secondList || !firstList->isHTMLElement() || !secondList-
>isHTMLElement()) | 745 if (!firstList || !secondList || !firstList->isHTMLElement() || !secondList-
>isHTMLElement()) |
746 return false; | 746 return false; |
747 | 747 |
748 return firstList->hasTagName(secondList->tagQName()) // make sure the list t
ypes match (ol vs. ul) | 748 return firstList->hasTagName(secondList->tagQName()) // make sure the list t
ypes match (ol vs. ul) |
749 && firstList->rendererIsEditable() && secondList->rendererIsEditable() // bo
th lists are editable | 749 && firstList->rendererIsEditable() && secondList->rendererIsEditable() // bo
th lists are editable |
750 && firstList->rootEditableElement() == secondList->rootEditableElement() //
don't cross editing boundaries | 750 && firstList->rootEditableElement() == secondList->rootEditableElement() //
don't cross editing boundaries |
751 && isVisiblyAdjacent(positionInParentAfterNode(firstList), positionInParentB
eforeNode(secondList)); | 751 && isVisiblyAdjacent(positionInParentAfterNode(firstList), positionInParentB
eforeNode(secondList)); |
752 // Make sure there is no visible content between this li and the previous li
st | 752 // Make sure there is no visible content between this li and the previous li
st |
753 } | 753 } |
754 | 754 |
755 // FIXME: do not require renderer, so that this can be used within fragments, or
rename to isRenderedTable() | 755 bool isRenderedTable(const Node* n) |
756 bool isTableElement(Node* n) | |
757 { | 756 { |
758 if (!n || !n->isElementNode()) | 757 if (!n || !n->isElementNode()) |
759 return false; | 758 return false; |
760 | 759 |
761 RenderObject* renderer = n->renderer(); | 760 RenderObject* renderer = n->renderer(); |
762 return (renderer && (renderer->style()->display() == TABLE || renderer->styl
e()->display() == INLINE_TABLE)); | 761 return (renderer && renderer->isTable()); |
763 } | 762 } |
764 | 763 |
765 bool isTableCell(const Node* node) | 764 bool isTableCell(const Node* node) |
766 { | 765 { |
767 RenderObject* r = node->renderer(); | 766 RenderObject* r = node->renderer(); |
768 if (!r) | 767 if (!r) |
769 return node->hasTagName(tdTag) || node->hasTagName(thTag); | 768 return node->hasTagName(tdTag) || node->hasTagName(thTag); |
770 | 769 |
771 return r->isTableCell(); | 770 return r->isTableCell(); |
772 } | 771 } |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 // if the selection starts just before a paragraph break, skip over it | 1153 // if the selection starts just before a paragraph break, skip over it |
1155 if (isEndOfParagraph(visiblePosition)) | 1154 if (isEndOfParagraph(visiblePosition)) |
1156 return visiblePosition.next().deepEquivalent().downstream(); | 1155 return visiblePosition.next().deepEquivalent().downstream(); |
1157 | 1156 |
1158 // otherwise, make sure to be at the start of the first selected node, | 1157 // otherwise, make sure to be at the start of the first selected node, |
1159 // instead of possibly at the end of the last node before the selection | 1158 // instead of possibly at the end of the last node before the selection |
1160 return visiblePosition.deepEquivalent().downstream(); | 1159 return visiblePosition.deepEquivalent().downstream(); |
1161 } | 1160 } |
1162 | 1161 |
1163 } // namespace WebCore | 1162 } // namespace WebCore |
OLD | NEW |