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 * | 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 Node* previousNode = previousLeafWithSameEditability(node, editableType); | 94 Node* previousNode = previousLeafWithSameEditability(node, editableType); |
95 | 95 |
96 while (previousNode && (!previousNode->layoutObject() || inSameLine(VisibleP
osition(firstPositionInOrBeforeNode(previousNode)), visiblePosition))) | 96 while (previousNode && (!previousNode->layoutObject() || inSameLine(VisibleP
osition(firstPositionInOrBeforeNode(previousNode)), visiblePosition))) |
97 previousNode = previousLeafWithSameEditability(previousNode, editableTyp
e); | 97 previousNode = previousLeafWithSameEditability(previousNode, editableTyp
e); |
98 | 98 |
99 while (previousNode && !previousNode->isShadowRoot()) { | 99 while (previousNode && !previousNode->isShadowRoot()) { |
100 if (highestEditableRoot(firstPositionInOrBeforeNode(previousNode), edita
bleType) != highestRoot) | 100 if (highestEditableRoot(firstPositionInOrBeforeNode(previousNode), edita
bleType) != highestRoot) |
101 break; | 101 break; |
102 | 102 |
103 Position pos = isHTMLBRElement(*previousNode) ? positionBeforeNode(previ
ousNode) : | 103 Position pos = isHTMLBRElement(*previousNode) ? positionBeforeNode(previ
ousNode) : |
104 createLegacyEditingPosition(previousNode, caretMaxOffset(previousNod
e)); | 104 Position::editingPositionOf(previousNode, caretMaxOffset(previousNod
e)); |
105 | 105 |
106 if (pos.isCandidate()) | 106 if (pos.isCandidate()) |
107 return pos; | 107 return pos; |
108 | 108 |
109 previousNode = previousLeafWithSameEditability(previousNode, editableTyp
e); | 109 previousNode = previousLeafWithSameEditability(previousNode, editableTyp
e); |
110 } | 110 } |
111 return Position(); | 111 return Position(); |
112 } | 112 } |
113 | 113 |
114 static Position nextRootInlineBoxCandidatePosition(Node* node, const VisiblePosi
tion& visiblePosition, EditableType editableType) | 114 static Position nextRootInlineBoxCandidatePosition(Node* node, const VisiblePosi
tion& visiblePosition, EditableType editableType) |
115 { | 115 { |
116 ContainerNode* highestRoot = highestEditableRoot(visiblePosition.deepEquival
ent(), editableType); | 116 ContainerNode* highestRoot = highestEditableRoot(visiblePosition.deepEquival
ent(), editableType); |
117 Node* nextNode = nextLeafWithSameEditability(node, editableType); | 117 Node* nextNode = nextLeafWithSameEditability(node, editableType); |
118 while (nextNode && (!nextNode->layoutObject() || inSameLine(VisiblePosition(
firstPositionInOrBeforeNode(nextNode)), visiblePosition))) | 118 while (nextNode && (!nextNode->layoutObject() || inSameLine(VisiblePosition(
firstPositionInOrBeforeNode(nextNode)), visiblePosition))) |
119 nextNode = nextLeafWithSameEditability(nextNode, ContentIsEditable); | 119 nextNode = nextLeafWithSameEditability(nextNode, ContentIsEditable); |
120 | 120 |
121 while (nextNode && !nextNode->isShadowRoot()) { | 121 while (nextNode && !nextNode->isShadowRoot()) { |
122 if (highestEditableRoot(firstPositionInOrBeforeNode(nextNode), editableT
ype) != highestRoot) | 122 if (highestEditableRoot(firstPositionInOrBeforeNode(nextNode), editableT
ype) != highestRoot) |
123 break; | 123 break; |
124 | 124 |
125 Position pos; | 125 Position pos; |
126 pos = createLegacyEditingPosition(nextNode, caretMinOffset(nextNode)); | 126 pos = Position::editingPositionOf(nextNode, caretMinOffset(nextNode)); |
127 | 127 |
128 if (pos.isCandidate()) | 128 if (pos.isCandidate()) |
129 return pos; | 129 return pos; |
130 | 130 |
131 nextNode = nextLeafWithSameEditability(nextNode, editableType); | 131 nextNode = nextLeafWithSameEditability(nextNode, editableType); |
132 } | 132 } |
133 return Position(); | 133 return Position(); |
134 } | 134 } |
135 | 135 |
136 class CachedLogicallyOrderedLeafBoxes { | 136 class CachedLogicallyOrderedLeafBoxes { |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 typedef unsigned (*BoundarySearchFunction)(const UChar*, unsigned length, unsign
ed offset, BoundarySearchContextAvailability, bool& needMoreContext); | 457 typedef unsigned (*BoundarySearchFunction)(const UChar*, unsigned length, unsign
ed offset, BoundarySearchContextAvailability, bool& needMoreContext); |
458 | 458 |
459 static VisiblePosition previousBoundary(const VisiblePosition& c, BoundarySearch
Function searchFunction) | 459 static VisiblePosition previousBoundary(const VisiblePosition& c, BoundarySearch
Function searchFunction) |
460 { | 460 { |
461 Position pos = c.deepEquivalent(); | 461 Position pos = c.deepEquivalent(); |
462 Node* boundary = pos.parentEditingBoundary(); | 462 Node* boundary = pos.parentEditingBoundary(); |
463 if (!boundary) | 463 if (!boundary) |
464 return VisiblePosition(); | 464 return VisiblePosition(); |
465 | 465 |
466 Document& d = boundary->document(); | 466 Document& d = boundary->document(); |
467 Position start = createLegacyEditingPosition(boundary, 0).parentAnchoredEqui
valent(); | 467 Position start = Position::editingPositionOf(boundary, 0).parentAnchoredEqui
valent(); |
468 Position end = pos.parentAnchoredEquivalent(); | 468 Position end = pos.parentAnchoredEquivalent(); |
469 | 469 |
470 Vector<UChar, 1024> string; | 470 Vector<UChar, 1024> string; |
471 unsigned suffixLength = 0; | 471 unsigned suffixLength = 0; |
472 | 472 |
473 TrackExceptionState exceptionState; | 473 TrackExceptionState exceptionState; |
474 if (requiresContextForWordBoundary(c.characterBefore())) { | 474 if (requiresContextForWordBoundary(c.characterBefore())) { |
475 RefPtrWillBeRawPtr<Range> forwardsScanRange(d.createRange()); | 475 RefPtrWillBeRawPtr<Range> forwardsScanRange(d.createRange()); |
476 forwardsScanRange->setEndAfter(boundary, exceptionState); | 476 forwardsScanRange->setEndAfter(boundary, exceptionState); |
477 forwardsScanRange->setStart(end.anchorNode(), end.offsetInContainerNode(
), exceptionState); | 477 forwardsScanRange->setStart(end.anchorNode(), end.offsetInContainerNode(
), exceptionState); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 int length = characters.size(); | 555 int length = characters.size(); |
556 int i = startOfLastWordBoundaryContext(characters.data(), length); | 556 int i = startOfLastWordBoundaryContext(characters.data(), length); |
557 string.prepend(characters.data() + i, length - i); | 557 string.prepend(characters.data() + i, length - i); |
558 prefixLength += length - i; | 558 prefixLength += length - i; |
559 if (i > 0) | 559 if (i > 0) |
560 break; | 560 break; |
561 backwardsIterator.advance(); | 561 backwardsIterator.advance(); |
562 } | 562 } |
563 } | 563 } |
564 | 564 |
565 Position searchStart = createLegacyEditingPosition(start.anchorNode(), start
.offsetInContainerNode()); | 565 Position searchStart = Position::editingPositionOf(start.anchorNode(), start
.offsetInContainerNode()); |
566 RangeBoundaryPoint searchEndPoint(boundary); | 566 RangeBoundaryPoint searchEndPoint(boundary); |
567 searchEndPoint.setToEndOfNode(*boundary); | 567 searchEndPoint.setToEndOfNode(*boundary); |
568 Position searchEnd = searchEndPoint.toPosition(); | 568 Position searchEnd = searchEndPoint.toPosition(); |
569 TextIterator it(searchStart, searchEnd, TextIteratorEmitsCharactersBetweenAl
lVisiblePositions); | 569 TextIterator it(searchStart, searchEnd, TextIteratorEmitsCharactersBetweenAl
lVisiblePositions); |
570 const unsigned invalidOffset = static_cast<unsigned>(-1); | 570 const unsigned invalidOffset = static_cast<unsigned>(-1); |
571 unsigned next = invalidOffset; | 571 unsigned next = invalidOffset; |
572 bool needMoreContext = false; | 572 bool needMoreContext = false; |
573 while (!it.atEnd()) { | 573 while (!it.atEnd()) { |
574 // Keep asking the iterator for chunks until the search function | 574 // Keep asking the iterator for chunks until the search function |
575 // returns an end value not equal to the length of the string passed to
it. | 575 // returns an end value not equal to the length of the string passed to
it. |
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1595 | 1595 |
1596 if (previousRenderedEditable(position1.anchorNode()) == position2.anchorNode
() | 1596 if (previousRenderedEditable(position1.anchorNode()) == position2.anchorNode
() |
1597 && !renderedOffset1 && renderedOffset2 == caretMaxOffset(position2.ancho
rNode())) { | 1597 && !renderedOffset1 && renderedOffset2 == caretMaxOffset(position2.ancho
rNode())) { |
1598 return false; | 1598 return false; |
1599 } | 1599 } |
1600 | 1600 |
1601 return true; | 1601 return true; |
1602 } | 1602 } |
1603 | 1603 |
1604 } | 1604 } |
OLD | NEW |