| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
| 3 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved. | 3 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 if (prevIsInSameEditableElement && !nextIsInSameEditableElement) | 606 if (prevIsInSameEditableElement && !nextIsInSameEditableElement) |
| 607 return prev; | 607 return prev; |
| 608 | 608 |
| 609 if (nextIsInSameEditableElement && !prevIsInSameEditableElement) | 609 if (nextIsInSameEditableElement && !prevIsInSameEditableElement) |
| 610 return next; | 610 return next; |
| 611 | 611 |
| 612 if (!nextIsInSameEditableElement && !prevIsInSameEditableElement) | 612 if (!nextIsInSameEditableElement && !prevIsInSameEditableElement) |
| 613 return Position(); | 613 return Position(); |
| 614 | 614 |
| 615 // The new position should be in the same block flow element. Favor that. | 615 // The new position should be in the same block flow element. Favor that. |
| 616 Node* originalBlock = node ? node->enclosingBlockFlowElement() : 0; | 616 Node* originalBlock = node ? enclosingBlockFlowElement(*node) : 0; |
| 617 bool nextIsOutsideOriginalBlock = !nextNode->isDescendantOf(originalBlock) &
& nextNode != originalBlock; | 617 bool nextIsOutsideOriginalBlock = !nextNode->isDescendantOf(originalBlock) &
& nextNode != originalBlock; |
| 618 bool prevIsOutsideOriginalBlock = !prevNode->isDescendantOf(originalBlock) &
& prevNode != originalBlock; | 618 bool prevIsOutsideOriginalBlock = !prevNode->isDescendantOf(originalBlock) &
& prevNode != originalBlock; |
| 619 if (nextIsOutsideOriginalBlock && !prevIsOutsideOriginalBlock) | 619 if (nextIsOutsideOriginalBlock && !prevIsOutsideOriginalBlock) |
| 620 return prev; | 620 return prev; |
| 621 | 621 |
| 622 return next; | 622 return next; |
| 623 } | 623 } |
| 624 | 624 |
| 625 UChar32 VisiblePosition::characterAfter() const | 625 UChar32 VisiblePosition::characterAfter() const |
| 626 { | 626 { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 bool setEnd(Range *r, const VisiblePosition &visiblePosition) | 751 bool setEnd(Range *r, const VisiblePosition &visiblePosition) |
| 752 { | 752 { |
| 753 if (!r) | 753 if (!r) |
| 754 return false; | 754 return false; |
| 755 Position p = visiblePosition.deepEquivalent().parentAnchoredEquivalent(); | 755 Position p = visiblePosition.deepEquivalent().parentAnchoredEquivalent(); |
| 756 TrackExceptionState exceptionState; | 756 TrackExceptionState exceptionState; |
| 757 r->setEnd(p.containerNode(), p.offsetInContainerNode(), exceptionState); | 757 r->setEnd(p.containerNode(), p.offsetInContainerNode(), exceptionState); |
| 758 return !exceptionState.hadException(); | 758 return !exceptionState.hadException(); |
| 759 } | 759 } |
| 760 | 760 |
| 761 Element* enclosingBlockFlowElement(const VisiblePosition &visiblePosition) | 761 Element* enclosingBlockFlowElement(const VisiblePosition& visiblePosition) |
| 762 { | 762 { |
| 763 if (visiblePosition.isNull()) | 763 if (visiblePosition.isNull()) |
| 764 return NULL; | 764 return 0; |
| 765 | 765 |
| 766 return visiblePosition.deepEquivalent().deprecatedNode()->enclosingBlockFlow
Element(); | 766 return enclosingBlockFlowElement(*visiblePosition.deepEquivalent().deprecate
dNode()); |
| 767 } | 767 } |
| 768 | 768 |
| 769 bool isFirstVisiblePositionInNode(const VisiblePosition &visiblePosition, const
Node *node) | 769 bool isFirstVisiblePositionInNode(const VisiblePosition &visiblePosition, const
Node *node) |
| 770 { | 770 { |
| 771 if (visiblePosition.isNull()) | 771 if (visiblePosition.isNull()) |
| 772 return false; | 772 return false; |
| 773 | 773 |
| 774 if (!visiblePosition.deepEquivalent().containerNode()->isDescendantOf(node)) | 774 if (!visiblePosition.deepEquivalent().containerNode()->isDescendantOf(node)) |
| 775 return false; | 775 return false; |
| 776 | 776 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 804 if (vpos) | 804 if (vpos) |
| 805 vpos->showTreeForThis(); | 805 vpos->showTreeForThis(); |
| 806 } | 806 } |
| 807 | 807 |
| 808 void showTree(const blink::VisiblePosition& vpos) | 808 void showTree(const blink::VisiblePosition& vpos) |
| 809 { | 809 { |
| 810 vpos.showTreeForThis(); | 810 vpos.showTreeForThis(); |
| 811 } | 811 } |
| 812 | 812 |
| 813 #endif | 813 #endif |
| OLD | NEW |