Changeset 48234 in webkit
- Timestamp:
- Sep 9, 2009, 4:25:47 PM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 1 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r48233 r48234 1 1 2009-07-30 Eric Seidel <eric@webkit.org> 2 3 Reviewed by Adam Barth. 4 5 Rename positionBeforeNode to positionInParentBeforeNode 6 and positionAfterNode to positionInParentAfterNode 7 in preparation for adding a positionBeforeNode 8 which returns a neighbor-anchored position. 9 https://bugs.webkit.org/show_bug.cgi?id=25494 10 11 No functional changes, thus no tests. 12 13 * dom/PositionConstructors.h: 14 (WebCore::positionInParentBeforeNode): 15 (WebCore::positionInParentAfterNode): 16 * dom/PositionIterator.cpp: 17 (WebCore::PositionIterator::operator Position): 18 * editing/ApplyStyleCommand.cpp: 19 (WebCore::ApplyStyleCommand::applyInlineStyle): 20 * editing/CompositeEditCommand.cpp: 21 (WebCore::CompositeEditCommand::positionOutsideTabSpan): 22 (WebCore::CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph): 23 (WebCore::CompositeEditCommand::positionAvoidingSpecialElementBoundary): 24 * editing/CreateLinkCommand.cpp: 25 (WebCore::CreateLinkCommand::doApply): 26 * editing/DeleteButtonController.cpp: 27 (WebCore::DeleteButtonController::deleteTarget): 28 * editing/DeleteSelectionCommand.cpp: 29 (WebCore::DeleteSelectionCommand::initializeStartEnd): 30 (WebCore::updatePositionForNodeRemoval): 31 * editing/InsertLineBreakCommand.cpp: 32 (WebCore::InsertLineBreakCommand::doApply): 33 * editing/InsertListCommand.cpp: 34 (WebCore::InsertListCommand::doApply): 35 * editing/InsertParagraphSeparatorCommand.cpp: 36 (WebCore::InsertParagraphSeparatorCommand::doApply): 37 * editing/InsertTextCommand.cpp: 38 (WebCore::InsertTextCommand::input): 39 * editing/ReplaceSelectionCommand.cpp: 40 (WebCore::ReplaceSelectionCommand::positionAtStartOfInsertedContent): 41 (WebCore::ReplaceSelectionCommand::doApply): 42 * editing/VisibleSelection.cpp: 43 (WebCore::VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries): 44 * editing/htmlediting.cpp: 45 (WebCore::firstEditablePositionAfterPositionInRoot): 46 (WebCore::lastEditablePositionBeforePositionInRoot): 47 (WebCore::rangeCompliantEquivalent): 48 (WebCore::positionBeforeContainingSpecialElement): 49 (WebCore::positionAfterContainingSpecialElement): 50 (WebCore::positionBeforeTabSpan): 51 52 2009-04-30 Eric Seidel <eric@webkit.org> 2 53 3 54 Reviewed by Adam Barth. -
trunk/WebCore/dom/Position.h
r48233 r48234 194 194 // If we ever add a PassPosition we can make these non-inline. 195 195 196 inline Position position BeforeNode(const Node* node)196 inline Position positionInParentBeforeNode(const Node* node) 197 197 { 198 198 // FIXME: This should ASSERT(node->parentNode()) … … 203 203 } 204 204 205 inline Position position AfterNode(const Node* node)205 inline Position positionInParentAfterNode(const Node* node) 206 206 { 207 207 ASSERT(node->parentNode()); -
trunk/WebCore/dom/PositionIterator.cpp
r44374 r48234 39 39 if (m_nodeAfterPositionInAnchor) { 40 40 ASSERT(m_nodeAfterPositionInAnchor->parentNode() == m_anchorNode); 41 return position BeforeNode(m_nodeAfterPositionInAnchor);41 return positionInParentBeforeNode(m_nodeAfterPositionInAnchor); 42 42 } 43 43 if (m_anchorNode->hasChildNodes()) -
trunk/WebCore/editing/ApplyStyleCommand.cpp
r47644 r48234 909 909 // Avoid removing the dir attribute and the unicode-bidi and direction properties from the unsplit ancestors. 910 910 if (startUnsplitAncestor && nodeFullySelected(startUnsplitAncestor, removeStart, end)) 911 embeddingRemoveStart = position AfterNode(startUnsplitAncestor);911 embeddingRemoveStart = positionInParentAfterNode(startUnsplitAncestor); 912 912 if (endUnsplitAncestor && nodeFullySelected(endUnsplitAncestor, removeStart, end)) 913 embeddingRemoveEnd = position BeforeNode(endUnsplitAncestor).downstream();913 embeddingRemoveEnd = positionInParentBeforeNode(endUnsplitAncestor).downstream(); 914 914 } 915 915 … … 961 961 ASSERT(ancestorUnicodeBidi->isPrimitiveValue()); 962 962 if (static_cast<CSSPrimitiveValue*>(ancestorUnicodeBidi.get())->getIdent() == CSSValueEmbed) { 963 embeddingApplyStart = position AfterNode(n);963 embeddingApplyStart = positionInParentAfterNode(n); 964 964 break; 965 965 } … … 975 975 ASSERT(ancestorUnicodeBidi->isPrimitiveValue()); 976 976 if (static_cast<CSSPrimitiveValue*>(ancestorUnicodeBidi.get())->getIdent() == CSSValueEmbed) { 977 embeddingApplyEnd = position BeforeNode(n);977 embeddingApplyEnd = positionInParentBeforeNode(n); 978 978 break; 979 979 } -
trunk/WebCore/editing/CompositeEditCommand.cpp
r47987 r48234 344 344 345 345 if (pos.deprecatedEditingOffset() <= caretMinOffset(pos.node())) 346 return position BeforeNode(tabSpan);346 return positionInParentBeforeNode(tabSpan); 347 347 348 348 if (pos.deprecatedEditingOffset() >= caretMaxOffset(pos.node())) 349 return position AfterNode(tabSpan);349 return positionInParentAfterNode(tabSpan); 350 350 351 351 splitTextNodeContainingElement(static_cast<Text *>(pos.node()), pos.deprecatedEditingOffset()); 352 return position BeforeNode(tabSpan);352 return positionInParentBeforeNode(tabSpan); 353 353 } 354 354 … … 987 987 988 988 if (caretPos.node()->hasTagName(brTag)) { 989 Position beforeBR(position BeforeNode(caretPos.node()));989 Position beforeBR(positionInParentBeforeNode(caretPos.node())); 990 990 removeNode(caretPos.node()); 991 991 prune(beforeBR.node()); … … 1040 1040 return original; 1041 1041 1042 result = position AfterNode(enclosingAnchor);1042 result = positionInParentAfterNode(enclosingAnchor); 1043 1043 } 1044 1044 // If visually just before an anchor, insert *outside* the anchor unless it's the first … … 1054 1054 return original; 1055 1055 1056 result = position BeforeNode(enclosingAnchor);1056 result = positionInParentBeforeNode(enclosingAnchor); 1057 1057 } 1058 1058 } -
trunk/WebCore/editing/CreateLinkCommand.cpp
r47688 r48234 54 54 RefPtr<Text> textNode = Text::create(document(), m_url); 55 55 appendNode(textNode.get(), anchorElement.get()); 56 setEndingSelection(VisibleSelection(position BeforeNode(anchorElement.get()), positionAfterNode(anchorElement.get()), DOWNSTREAM));56 setEndingSelection(VisibleSelection(positionInParentBeforeNode(anchorElement.get()), positionInParentAfterNode(anchorElement.get()), DOWNSTREAM)); 57 57 } 58 58 } -
trunk/WebCore/editing/DeleteButtonController.cpp
r47367 r48234 351 351 // within the target, we unconditionally update the selection to be 352 352 // a caret where the target had been. 353 Position pos = position BeforeNode(element.get());353 Position pos = positionInParentBeforeNode(element.get()); 354 354 applyCommand(RemoveNodeCommand::create(element.release())); 355 355 m_frame->selection()->setSelection(VisiblePosition(pos)); -
trunk/WebCore/editing/DeleteSelectionCommand.cpp
r46914 r48234 138 138 if (VisiblePosition(start) != m_selectionToDelete.visibleStart() || VisiblePosition(end) != m_selectionToDelete.visibleEnd()) 139 139 break; 140 140 141 141 // If we're going to expand to include the startSpecialContainer, it must be fully selected. 142 143 if (startSpecialContainer && !endSpecialContainer && comparePositions(positionAfterNode(startSpecialContainer), end) > -1) 142 if (startSpecialContainer && !endSpecialContainer && comparePositions(positionInParentAfterNode(startSpecialContainer), end) > -1) 144 143 break; 145 144 146 145 // If we're going to expand to include the endSpecialContainer, it must be fully selected. 147 if (endSpecialContainer && !startSpecialContainer && comparePositions(start, position BeforeNode(endSpecialContainer)) > -1)146 if (endSpecialContainer && !startSpecialContainer && comparePositions(start, positionInParentBeforeNode(endSpecialContainer)) > -1) 148 147 break; 149 148 150 149 if (startSpecialContainer && startSpecialContainer->isDescendantOf(endSpecialContainer)) 151 150 // Don't adjust the end yet, it is the end of a special element that contains the start … … 318 317 position = Position(position.node(), position.deprecatedEditingOffset() - 1); 319 318 if (position.node() == node || position.node()->isDescendantOf(node)) 320 position = position BeforeNode(node);319 position = positionInParentBeforeNode(node); 321 320 } 322 321 -
trunk/WebCore/editing/IndentOutdentCommand.cpp
r47578 r48234 174 174 175 175 // If the node isn't br or the parent node is empty, then don't remove. 176 if (!br->hasTagName(brTag) || isVisiblyAdjacent(position BeforeNode(parentNode), positionAfterNode(parentNode)))176 if (!br->hasTagName(brTag) || isVisiblyAdjacent(positionInParentBeforeNode(parentNode), positionInParentAfterNode(parentNode))) 177 177 return; 178 178 -
trunk/WebCore/editing/InsertLineBreakCommand.cpp
r43035 r48234 126 126 insertNodeBefore(nodeToInsert->cloneNode(false).get(), nodeToInsert.get()); 127 127 128 setEndingSelection(VisibleSelection(position AfterNode(nodeToInsert.get()), DOWNSTREAM));128 setEndingSelection(VisibleSelection(positionInParentAfterNode(nodeToInsert.get()), DOWNSTREAM)); 129 129 // If we're inserting after all of the rendered text in a text node, or into a non-text node, 130 130 // a simple insertion is sufficient. 131 131 } else if (pos.deprecatedEditingOffset() >= caretMaxOffset(pos.node()) || !pos.node()->isTextNode()) { 132 132 insertNodeAt(nodeToInsert.get(), pos); 133 setEndingSelection(VisibleSelection(position AfterNode(nodeToInsert.get()), DOWNSTREAM));133 setEndingSelection(VisibleSelection(positionInParentAfterNode(nodeToInsert.get()), DOWNSTREAM)); 134 134 } else { 135 135 // Split a text node … … 145 145 updateLayout(); 146 146 if (!endingPosition.isRenderedCharacter()) { 147 Position positionBeforeTextNode(position BeforeNode(textNode));147 Position positionBeforeTextNode(positionInParentBeforeNode(textNode)); 148 148 // Clear out all whitespace and insert one non-breaking space 149 149 deleteInsignificantTextDownstream(endingPosition); -
trunk/WebCore/editing/InsertListCommand.cpp
r44375 r48234 252 252 Node* listChild = enclosingListChild(insertionPos.node()); 253 253 if (listChild && listChild->hasTagName(liTag)) 254 insertionPos = position BeforeNode(listChild);254 insertionPos = positionInParentBeforeNode(listChild); 255 255 256 256 insertNodeAt(listElement, insertionPos); -
trunk/WebCore/editing/InsertParagraphSeparatorCommand.cpp
r46914 r48234 235 235 RefPtr<Element> br = createBreakElement(document()); 236 236 insertNodeAt(br.get(), insertionPosition); 237 insertionPosition = position AfterNode(br.get());237 insertionPosition = positionInParentAfterNode(br.get()); 238 238 } 239 239 -
trunk/WebCore/editing/InsertTextCommand.cpp
r45016 r48234 146 146 // It is possible for the node that contains startPosition to contain only unrendered whitespace, 147 147 // and so deleteInsignificantText could remove it. Save the position before the node in case that happens. 148 Position positionBeforeStartNode(position BeforeNode(startPosition.node()));148 Position positionBeforeStartNode(positionInParentBeforeNode(startPosition.node())); 149 149 deleteInsignificantText(startPosition.upstream(), startPosition.downstream()); 150 150 if (!startPosition.node()->inDocument()) -
trunk/WebCore/editing/ReplaceSelectionCommand.cpp
r46914 r48234 529 529 { 530 530 // Return the inserted content's first VisiblePosition. 531 return VisiblePosition(nextCandidate(position BeforeNode(m_firstNodeInserted.get())));531 return VisiblePosition(nextCandidate(positionInParentBeforeNode(m_firstNodeInserted.get()))); 532 532 } 533 533 … … 795 795 ASSERT(br->hasTagName(brTag)); 796 796 // Insert content between the two blockquotes, but remove the br (since it was just a placeholder). 797 insertionPos = position BeforeNode(br);797 insertionPos = positionInParentBeforeNode(br); 798 798 removeNode(br); 799 799 } … … 818 818 VisiblePosition visibleInsertionPos(insertionPos); 819 819 if (isEndOfBlock(visibleInsertionPos) && !(isStartOfBlock(visibleInsertionPos) && fragment.hasInterchangeNewlineAtEnd())) 820 insertionPos = position AfterNode(startBlock);820 insertionPos = positionInParentAfterNode(startBlock); 821 821 else if (isStartOfBlock(visibleInsertionPos)) 822 insertionPos = position BeforeNode(startBlock);822 insertionPos = positionInParentBeforeNode(startBlock); 823 823 } 824 824 -
trunk/WebCore/editing/VisibleSelection.cpp
r44491 r48234 512 512 Node* root = editableRootForPosition(p); 513 513 shadowAncestor = root ? root->shadowAncestorNode() : 0; 514 p = isAtomicNode(p.node()) ? position BeforeNode(p.node()) : previousVisuallyDistinctCandidate(p);514 p = isAtomicNode(p.node()) ? positionInParentBeforeNode(p.node()) : previousVisuallyDistinctCandidate(p); 515 515 if (p.isNull() && (shadowAncestor != root)) 516 516 p = lastDeepEditingPositionForNode(shadowAncestor); … … 541 541 Node* root = editableRootForPosition(p); 542 542 shadowAncestor = root ? root->shadowAncestorNode() : 0; 543 p = isAtomicNode(p.node()) ? position AfterNode(p.node()) : nextVisuallyDistinctCandidate(p);543 p = isAtomicNode(p.node()) ? positionInParentAfterNode(p.node()) : nextVisuallyDistinctCandidate(p); 544 544 if (p.isNull() && (shadowAncestor != root)) 545 545 p = Position(shadowAncestor, 0); -
trunk/WebCore/editing/htmlediting.cpp
r48233 r48234 281 281 282 282 while (p.node() && !isEditablePosition(p) && p.node()->isDescendantOf(highestRoot)) 283 p = isAtomicNode(p.node()) ? position AfterNode(p.node()) : nextVisuallyDistinctCandidate(p);283 p = isAtomicNode(p.node()) ? positionInParentAfterNode(p.node()) : nextVisuallyDistinctCandidate(p); 284 284 285 285 if (p.node() && !p.node()->isDescendantOf(highestRoot)) … … 302 302 303 303 while (p.node() && !isEditablePosition(p) && p.node()->isDescendantOf(highestRoot)) 304 p = isAtomicNode(p.node()) ? position BeforeNode(p.node()) : previousVisuallyDistinctCandidate(p);304 p = isAtomicNode(p.node()) ? positionInParentBeforeNode(p.node()) : previousVisuallyDistinctCandidate(p); 305 305 306 306 if (p.node() && !p.node()->isDescendantOf(highestRoot)) … … 340 340 if (pos.deprecatedEditingOffset() <= 0) { 341 341 if (node->parentNode() && (editingIgnoresContent(node) || isTableElement(node))) 342 return position BeforeNode(node);342 return positionInParentBeforeNode(node); 343 343 return Position(node, 0); 344 344 } … … 350 350 if (pos.deprecatedEditingOffset() > maxCompliantOffset) { 351 351 if (node->parentNode()) 352 return position AfterNode(node);352 return positionInParentAfterNode(node); 353 353 354 354 // there is no other option at this point than to … … 360 360 if ((pos.deprecatedEditingOffset() < maxCompliantOffset) && editingIgnoresContent(node)) { 361 361 ASSERT_NOT_REACHED(); 362 return node->parentNode() ? position BeforeNode(node) : Position(node, 0);362 return node->parentNode() ? positionInParentBeforeNode(node) : Position(node, 0); 363 363 } 364 364 365 365 if (pos.deprecatedEditingOffset() == maxCompliantOffset && (editingIgnoresContent(node) || isTableElement(node))) 366 return position AfterNode(node);366 return positionInParentAfterNode(node); 367 367 368 368 return Position(pos); … … 526 526 if (!n) 527 527 return pos; 528 Position result = position BeforeNode(n);528 Position result = positionInParentBeforeNode(n); 529 529 if (result.isNull() || result.node()->rootEditableElement() != pos.node()->rootEditableElement()) 530 530 return pos; … … 544 544 if (!n) 545 545 return pos; 546 Position result = position AfterNode(n);546 Position result = positionInParentAfterNode(n); 547 547 if (result.isNull() || result.node()->rootEditableElement() != pos.node()->rootEditableElement()) 548 548 return pos; … … 586 586 return VisiblePosition(node, 0, DOWNSTREAM); 587 587 ASSERT(node->parentNode()); 588 return position BeforeNode(node);588 return positionInParentBeforeNode(node); 589 589 } 590 590 … … 596 596 return VisiblePosition(node, node->childNodeCount(), DOWNSTREAM); 597 597 ASSERT(node->parentNode()); 598 return position AfterNode(node);598 return positionInParentAfterNode(node); 599 599 } 600 600 … … 811 811 && firstList->isContentEditable() && secondList->isContentEditable()// both lists are editable 812 812 && firstList->rootEditableElement() == secondList->rootEditableElement()// don't cross editing boundaries 813 && isVisiblyAdjacent(position AfterNode(firstList), positionBeforeNode(secondList));813 && isVisiblyAdjacent(positionInParentAfterNode(firstList), positionInParentBeforeNode(secondList)); 814 814 // Make sure there is no visible content between this li and the previous list 815 815 } … … 901 901 return pos; 902 902 903 return position BeforeNode(node);903 return positionInParentBeforeNode(node); 904 904 } 905 905
Note:
See TracChangeset
for help on using the changeset viewer.