| 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 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 | 534 |
| 535 // When neither upstream or downstream gets us to a candidate (upstream/down
stream won't leave | 535 // When neither upstream or downstream gets us to a candidate (upstream/down
stream won't leave |
| 536 // blocks or enter new ones), we search forward and backward until we find o
ne. | 536 // blocks or enter new ones), we search forward and backward until we find o
ne. |
| 537 Position next = canonicalizeCandidate(nextCandidate(position)); | 537 Position next = canonicalizeCandidate(nextCandidate(position)); |
| 538 Position prev = canonicalizeCandidate(previousCandidate(position)); | 538 Position prev = canonicalizeCandidate(previousCandidate(position)); |
| 539 Node* nextNode = next.deprecatedNode(); | 539 Node* nextNode = next.deprecatedNode(); |
| 540 Node* prevNode = prev.deprecatedNode(); | 540 Node* prevNode = prev.deprecatedNode(); |
| 541 | 541 |
| 542 // The new position must be in the same editable element. Enforce that first
. | 542 // The new position must be in the same editable element. Enforce that first
. |
| 543 // Unless the descent is from a non-editable html element to an editable bod
y. | 543 // Unless the descent is from a non-editable html element to an editable bod
y. |
| 544 if (node && isHTMLHtmlElement(node) && !node->rendererIsEditable() && node->
document()->body() && node->document()->body()->rendererIsEditable()) | 544 if (node && isHTMLHtmlElement(node) && !node->rendererIsEditable() && node->
document().body() && node->document().body()->rendererIsEditable()) |
| 545 return next.isNotNull() ? next : prev; | 545 return next.isNotNull() ? next : prev; |
| 546 | 546 |
| 547 Node* editingRoot = editableRootForPosition(position); | 547 Node* editingRoot = editableRootForPosition(position); |
| 548 | 548 |
| 549 // If the html element is editable, descending into its body will look like
a descent | 549 // If the html element is editable, descending into its body will look like
a descent |
| 550 // from non-editable to editable content since rootEditableElement() always
stops at the body. | 550 // from non-editable to editable content since rootEditableElement() always
stops at the body. |
| 551 if ((editingRoot && isHTMLHtmlElement(editingRoot)) || position.deprecatedNo
de()->isDocumentNode()) | 551 if ((editingRoot && isHTMLHtmlElement(editingRoot)) || position.deprecatedNo
de()->isDocumentNode()) |
| 552 return next.isNotNull() ? next : prev; | 552 return next.isNotNull() ? next : prev; |
| 553 | 553 |
| 554 bool prevIsInSameEditableElement = prevNode && editableRootForPosition(prev)
== editingRoot; | 554 bool prevIsInSameEditableElement = prevNode && editableRootForPosition(prev)
== editingRoot; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 PassRefPtr<Range> makeRange(const VisiblePosition &start, const VisiblePosition
&end) | 673 PassRefPtr<Range> makeRange(const VisiblePosition &start, const VisiblePosition
&end) |
| 674 { | 674 { |
| 675 if (start.isNull() || end.isNull()) | 675 if (start.isNull() || end.isNull()) |
| 676 return 0; | 676 return 0; |
| 677 | 677 |
| 678 Position s = start.deepEquivalent().parentAnchoredEquivalent(); | 678 Position s = start.deepEquivalent().parentAnchoredEquivalent(); |
| 679 Position e = end.deepEquivalent().parentAnchoredEquivalent(); | 679 Position e = end.deepEquivalent().parentAnchoredEquivalent(); |
| 680 if (s.isNull() || e.isNull()) | 680 if (s.isNull() || e.isNull()) |
| 681 return 0; | 681 return 0; |
| 682 | 682 |
| 683 return Range::create(s.containerNode()->document(), s.containerNode(), s.off
setInContainerNode(), e.containerNode(), e.offsetInContainerNode()); | 683 return Range::create(&s.containerNode()->document(), s.containerNode(), s.of
fsetInContainerNode(), e.containerNode(), e.offsetInContainerNode()); |
| 684 } | 684 } |
| 685 | 685 |
| 686 VisiblePosition startVisiblePosition(const Range *r, EAffinity affinity) | 686 VisiblePosition startVisiblePosition(const Range *r, EAffinity affinity) |
| 687 { | 687 { |
| 688 return VisiblePosition(r->startPosition(), affinity); | 688 return VisiblePosition(r->startPosition(), affinity); |
| 689 } | 689 } |
| 690 | 690 |
| 691 VisiblePosition endVisiblePosition(const Range *r, EAffinity affinity) | 691 VisiblePosition endVisiblePosition(const Range *r, EAffinity affinity) |
| 692 { | 692 { |
| 693 return VisiblePosition(r->endPosition(), affinity); | 693 return VisiblePosition(r->endPosition(), affinity); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 if (vpos) | 754 if (vpos) |
| 755 vpos->showTreeForThis(); | 755 vpos->showTreeForThis(); |
| 756 } | 756 } |
| 757 | 757 |
| 758 void showTree(const WebCore::VisiblePosition& vpos) | 758 void showTree(const WebCore::VisiblePosition& vpos) |
| 759 { | 759 { |
| 760 vpos.showTreeForThis(); | 760 vpos.showTreeForThis(); |
| 761 } | 761 } |
| 762 | 762 |
| 763 #endif | 763 #endif |
| OLD | NEW |