Changeset 75835 in webkit
- Timestamp:
- Jan 14, 2011 4:16:47 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r75833 r75835 1 2011-01-14 Ryosuke Niwa <rniwa@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Stop instantiating legacy editing positions in AccessibilityRenderObject.cpp, Element.cpp, 6 BreakBlockquoteCommand.cpp, CompositeEditCommand.cpp, and DeleteButtonController.cpp 7 https://bugs.webkit.org/show_bug.cgi?id=52481 8 9 Removed instantiation of legacy editing positions. 10 Calls to Position::Position are replaced by calls to Position's convenience functions. 11 12 Also fixed firstPositionInOrBeforeNode and lastPositionInOrAfterNode so that 13 they instantiate right positions for text nodes. 14 15 * accessibility/AccessibilityRenderObject.cpp: 16 (WebCore::AccessibilityRenderObject::setSelectedTextRange): 17 * dom/Element.cpp: 18 (WebCore::Element::updateFocusAppearance): 19 * editing/BreakBlockquoteCommand.cpp: 20 (WebCore::BreakBlockquoteCommand::doApply): 21 * editing/CompositeEditCommand.cpp: 22 (WebCore::CompositeEditCommand::inputText): 23 (WebCore::CompositeEditCommand::rebalanceWhitespaceAt): 24 (WebCore::CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary): 25 (WebCore::CompositeEditCommand::moveParagraphs): 26 (WebCore::CompositeEditCommand::breakOutOfEmptyListItem): 27 (WebCore::CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph): 28 (WebCore::CompositeEditCommand::splitTreeToNode): 29 * editing/DeleteButtonController.cpp: 30 (WebCore::enclosingDeletableElement): 31 * editing/htmlediting.h: 32 (WebCore::firstPositionInOrBeforeNode): Instantiates firstPositionInNode instead of 33 positionBeforeNode for a text node. 34 (WebCore::lastPositionInOrAfterNode): Ditto. 35 1 36 2011-01-14 Helder Correia <helder@sencha.com> 2 37 -
trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
r75179 r75835 2027 2027 return; 2028 2028 Node* node = m_renderer->node(); 2029 frame->selection()->setSelection(VisibleSelection(Position(node, range.start ),2030 Position(node, range.start + range.length ), DOWNSTREAM));2029 frame->selection()->setSelection(VisibleSelection(Position(node, range.start, Position::PositionIsOffsetInAnchor), 2030 Position(node, range.start + range.length, Position::PositionIsOffsetInAnchor), DOWNSTREAM)); 2031 2031 } 2032 2032 -
trunk/Source/WebCore/dom/Element.cpp
r75277 r75835 1482 1482 1483 1483 // FIXME: We should restore the previous selection if there is one. 1484 VisibleSelection newSelection = VisibleSelection( Position(this, 0), DOWNSTREAM);1484 VisibleSelection newSelection = VisibleSelection(firstPositionInNode(this), DOWNSTREAM); 1485 1485 1486 1486 if (frame->selection()->shouldChangeSelection(newSelection)) { -
trunk/Source/WebCore/editing/BreakBlockquoteCommand.cpp
r69868 r75835 83 83 if (isFirstVisiblePositionInNode(visiblePos, topBlockquote) && !isLastVisPosInNode) { 84 84 insertNodeBefore(breakNode.get(), topBlockquote); 85 setEndingSelection(VisibleSelection( Position(breakNode.get(), 0), DOWNSTREAM));85 setEndingSelection(VisibleSelection(positionBeforeNode(breakNode.get()), DOWNSTREAM)); 86 86 rebalanceWhitespace(); 87 87 return; … … 93 93 // If we're inserting the break at the end of the quoted content, we don't need to break the quote. 94 94 if (isLastVisPosInNode) { 95 setEndingSelection(VisibleSelection( Position(breakNode.get(), 0), DOWNSTREAM));95 setEndingSelection(VisibleSelection(positionBeforeNode(breakNode.get()), DOWNSTREAM)); 96 96 rebalanceWhitespace(); 97 97 return; … … 126 126 // If there's nothing inside topBlockquote to move, we're finished. 127 127 if (!startNode->isDescendantOf(topBlockquote)) { 128 setEndingSelection(VisibleSelection(VisiblePosition( Position(startNode, 0))));128 setEndingSelection(VisibleSelection(VisiblePosition(firstPositionInOrBeforeNode(startNode)))); 129 129 return; 130 130 } … … 199 199 200 200 // Put the selection right before the break. 201 setEndingSelection(VisibleSelection( Position(breakNode.get(), 0), DOWNSTREAM));201 setEndingSelection(VisibleSelection(positionBeforeNode(breakNode.get()), DOWNSTREAM)); 202 202 rebalanceWhitespace(); 203 203 } -
trunk/Source/WebCore/editing/CompositeEditCommand.cpp
r74214 r75835 302 302 unsigned offset = 0; 303 303 unsigned length = text.length(); 304 RefPtr<Range> startRange = Range::create(document(), Position(document()->documentElement(), 0), endingSelection().start());304 RefPtr<Range> startRange = Range::create(document(), firstPositionInNode(document()->documentElement()), endingSelection().start()); 305 305 unsigned startIndex = TextIterator::rangeLength(startRange.get()); 306 306 size_t newline; … … 399 399 void CompositeEditCommand::rebalanceWhitespaceAt(const Position& position) 400 400 { 401 Node* node = position. node();402 if ( !node || !node->isTextNode())401 Node* node = position.containerNode(); 402 if (position.anchorType() != Position::PositionIsOffsetInAnchor || !node || !node->isTextNode()) 403 403 return; 404 404 Text* textNode = static_cast<Text*>(node); 405 405 406 406 if (textNode->length() == 0) 407 407 return; … … 409 409 if (renderer && !renderer->style()->collapseWhiteSpace()) 410 410 return; 411 411 412 412 String text = textNode->data(); 413 413 ASSERT(!text.isEmpty()); … … 433 433 ASSERT(length > 0); 434 434 435 VisiblePosition visibleUpstreamPos(Position(position. node(), upstream));436 VisiblePosition visibleDownstreamPos(Position(position. node(), downstream + 1));435 VisiblePosition visibleUpstreamPos(Position(position.containerNode(), upstream, Position::PositionIsOffsetInAnchor)); 436 VisiblePosition visibleDownstreamPos(Position(position.containerNode(), downstream + 1, Position::PositionIsOffsetInAnchor)); 437 437 438 438 String string = text.substring(upstream, length); … … 716 716 717 717 RefPtr<Node> newBlock = insertNewDefaultParagraphElementAt(upstreamStart); 718 718 719 719 bool endWasBr = visibleParagraphEnd.deepEquivalent().node()->hasTagName(brTag); 720 720 721 moveParagraphs(visibleParagraphStart, visibleParagraphEnd, VisiblePosition( Position(newBlock.get(), 0)));721 moveParagraphs(visibleParagraphStart, visibleParagraphEnd, VisiblePosition(firstPositionInNode(newBlock.get()))); 722 722 723 723 if (newBlock->lastChild() && newBlock->lastChild()->hasTagName(brTag) && !endWasBr) … … 974 974 updateLayout(); 975 975 } 976 977 RefPtr<Range> startToDestinationRange(Range::create(document(), Position(document(), 0), rangeCompliantEquivalent(destination.deepEquivalent())));976 977 RefPtr<Range> startToDestinationRange(Range::create(document(), firstPositionInNode(document()->documentElement()), rangeCompliantEquivalent(destination.deepEquivalent()))); 978 978 destinationIndex = TextIterator::rangeLength(startToDestinationRange.get(), true); 979 979 980 980 setEndingSelection(destination); 981 981 ASSERT(endingSelection().isCaretOrRange()); … … 1056 1056 1057 1057 appendBlockPlaceholder(newBlock); 1058 setEndingSelection(VisibleSelection( Position(newBlock.get(), 0), DOWNSTREAM));1058 setEndingSelection(VisibleSelection(firstPositionInNode(newBlock.get()), DOWNSTREAM)); 1059 1059 1060 1060 style->prepareToApplyAt(endingSelection().start()); … … 1089 1089 // to hold the caret before the highest blockquote. 1090 1090 insertNodeBefore(br, highestBlockquote); 1091 VisiblePosition atBR( Position(br.get(), 0));1091 VisiblePosition atBR(positionBeforeNode(br.get())); 1092 1092 // If the br we inserted collapsed, for example foo<br><blockquote>...</blockquote>, insert 1093 1093 // a second one. … … 1192 1192 if (!node->parentNode()->isElementNode()) 1193 1193 break; 1194 VisiblePosition positionInParent( Position(node->parentNode(), 0), DOWNSTREAM);1195 VisiblePosition positionInNode( Position(node, 0), DOWNSTREAM);1194 VisiblePosition positionInParent(firstPositionInNode(node->parentNode()), DOWNSTREAM); 1195 VisiblePosition positionInNode(firstPositionInOrBeforeNode(node.get()), DOWNSTREAM); 1196 1196 if (positionInParent != positionInNode) 1197 1197 applyCommandToComposite(SplitElementCommand::create(static_cast<Element*>(node->parentNode()), node)); -
trunk/Source/WebCore/editing/DeleteButtonController.cpp
r69868 r75835 160 160 return 0; 161 161 162 Node* element = enclosingNodeOfType( Position(container, 0), &isDeletableElement);162 Node* element = enclosingNodeOfType(firstPositionInNode(container), &isDeletableElement); 163 163 if (!element) 164 164 return 0; -
trunk/Source/WebCore/editing/htmlediting.h
r75672 r75835 118 118 inline Position firstPositionInOrBeforeNode(Node* node) 119 119 { 120 return canHaveChildrenForEditing(node) ? firstPositionInNode(node) : positionBeforeNode(node);120 return editingIgnoresContent(node) ? positionBeforeNode(node) : firstPositionInNode(node); 121 121 } 122 122 123 123 inline Position lastPositionInOrAfterNode(Node* node) 124 124 { 125 return canHaveChildrenForEditing(node) ? lastPositionInNode(node) : positionAfterNode(node);125 return editingIgnoresContent(node) ? positionAfterNode(node) : lastPositionInNode(node); 126 126 } 127 127
Note: See TracChangeset
for help on using the changeset viewer.