[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

rniwa at webkit.org rniwa at webkit.org
Sun Feb 20 22:59:23 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit e3957692b5703383b73a4848999a7fc0817a6902
Author: rniwa at webkit.org <rniwa at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Jan 15 00:16:47 2011 +0000

    2011-01-14  Ryosuke Niwa  <rniwa at webkit.org>
    
            Reviewed by Eric Seidel.
    
            Stop instantiating legacy editing positions in AccessibilityRenderObject.cpp, Element.cpp,
            BreakBlockquoteCommand.cpp, CompositeEditCommand.cpp, and DeleteButtonController.cpp
            https://bugs.webkit.org/show_bug.cgi?id=52481
    
            Removed instantiation of legacy editing positions.
            Calls to Position::Position are replaced by calls to Position's convenience functions.
    
            Also fixed firstPositionInOrBeforeNode and lastPositionInOrAfterNode so that
            they instantiate right positions for text nodes.
    
            * accessibility/AccessibilityRenderObject.cpp:
            (WebCore::AccessibilityRenderObject::setSelectedTextRange):
            * dom/Element.cpp:
            (WebCore::Element::updateFocusAppearance):
            * editing/BreakBlockquoteCommand.cpp:
            (WebCore::BreakBlockquoteCommand::doApply):
            * editing/CompositeEditCommand.cpp:
            (WebCore::CompositeEditCommand::inputText):
            (WebCore::CompositeEditCommand::rebalanceWhitespaceAt):
            (WebCore::CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary):
            (WebCore::CompositeEditCommand::moveParagraphs):
            (WebCore::CompositeEditCommand::breakOutOfEmptyListItem):
            (WebCore::CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph):
            (WebCore::CompositeEditCommand::splitTreeToNode):
            * editing/DeleteButtonController.cpp:
            (WebCore::enclosingDeletableElement):
            * editing/htmlediting.h:
            (WebCore::firstPositionInOrBeforeNode): Instantiates firstPositionInNode instead of
            positionBeforeNode for a text node.
            (WebCore::lastPositionInOrAfterNode): Ditto.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75835 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 11ba9af..06bc01a 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,38 @@
+2011-01-14  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        Stop instantiating legacy editing positions in AccessibilityRenderObject.cpp, Element.cpp,
+        BreakBlockquoteCommand.cpp, CompositeEditCommand.cpp, and DeleteButtonController.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=52481
+
+        Removed instantiation of legacy editing positions.
+        Calls to Position::Position are replaced by calls to Position's convenience functions.
+        
+        Also fixed firstPositionInOrBeforeNode and lastPositionInOrAfterNode so that
+        they instantiate right positions for text nodes.
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::setSelectedTextRange):
+        * dom/Element.cpp:
+        (WebCore::Element::updateFocusAppearance):
+        * editing/BreakBlockquoteCommand.cpp:
+        (WebCore::BreakBlockquoteCommand::doApply):
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::inputText):
+        (WebCore::CompositeEditCommand::rebalanceWhitespaceAt):
+        (WebCore::CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary):
+        (WebCore::CompositeEditCommand::moveParagraphs):
+        (WebCore::CompositeEditCommand::breakOutOfEmptyListItem):
+        (WebCore::CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph):
+        (WebCore::CompositeEditCommand::splitTreeToNode):
+        * editing/DeleteButtonController.cpp:
+        (WebCore::enclosingDeletableElement):
+        * editing/htmlediting.h:
+        (WebCore::firstPositionInOrBeforeNode): Instantiates firstPositionInNode instead of
+        positionBeforeNode for a text node.
+        (WebCore::lastPositionInOrAfterNode): Ditto.
+
 2011-01-14  Helder Correia  <helder at sencha.com>
 
         Reviewed by Simon Fraser.
diff --git a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp b/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
index 7dc6840..8b0c5ca 100644
--- a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
+++ b/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
@@ -2026,8 +2026,8 @@ void AccessibilityRenderObject::setSelectedTextRange(const PlainTextRange& range
     if (!frame)
         return;
     Node* node = m_renderer->node();
-    frame->selection()->setSelection(VisibleSelection(Position(node, range.start),
-        Position(node, range.start + range.length), DOWNSTREAM));
+    frame->selection()->setSelection(VisibleSelection(Position(node, range.start, Position::PositionIsOffsetInAnchor),
+        Position(node, range.start + range.length, Position::PositionIsOffsetInAnchor), DOWNSTREAM));
 }
 
 KURL AccessibilityRenderObject::url() const
diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp
index 6d183ef..c61b95d 100644
--- a/Source/WebCore/dom/Element.cpp
+++ b/Source/WebCore/dom/Element.cpp
@@ -1481,7 +1481,7 @@ void Element::updateFocusAppearance(bool /*restorePreviousSelection*/)
             return;
 
         // FIXME: We should restore the previous selection if there is one.
-        VisibleSelection newSelection = VisibleSelection(Position(this, 0), DOWNSTREAM);
+        VisibleSelection newSelection = VisibleSelection(firstPositionInNode(this), DOWNSTREAM);
         
         if (frame->selection()->shouldChangeSelection(newSelection)) {
             frame->selection()->setSelection(newSelection);
diff --git a/Source/WebCore/editing/BreakBlockquoteCommand.cpp b/Source/WebCore/editing/BreakBlockquoteCommand.cpp
index 63956e5..ae409c6 100644
--- a/Source/WebCore/editing/BreakBlockquoteCommand.cpp
+++ b/Source/WebCore/editing/BreakBlockquoteCommand.cpp
@@ -82,7 +82,7 @@ void BreakBlockquoteCommand::doApply()
     // Instead, insert the break before the blockquote, unless the position is as the end of the the quoted content.
     if (isFirstVisiblePositionInNode(visiblePos, topBlockquote) && !isLastVisPosInNode) {
         insertNodeBefore(breakNode.get(), topBlockquote);
-        setEndingSelection(VisibleSelection(Position(breakNode.get(), 0), DOWNSTREAM));
+        setEndingSelection(VisibleSelection(positionBeforeNode(breakNode.get()), DOWNSTREAM));
         rebalanceWhitespace();   
         return;
     }
@@ -92,7 +92,7 @@ void BreakBlockquoteCommand::doApply()
 
     // If we're inserting the break at the end of the quoted content, we don't need to break the quote.
     if (isLastVisPosInNode) {
-        setEndingSelection(VisibleSelection(Position(breakNode.get(), 0), DOWNSTREAM));
+        setEndingSelection(VisibleSelection(positionBeforeNode(breakNode.get()), DOWNSTREAM));
         rebalanceWhitespace();
         return;
     }
@@ -125,7 +125,7 @@ void BreakBlockquoteCommand::doApply()
     
     // If there's nothing inside topBlockquote to move, we're finished.
     if (!startNode->isDescendantOf(topBlockquote)) {
-        setEndingSelection(VisibleSelection(VisiblePosition(Position(startNode, 0))));
+        setEndingSelection(VisibleSelection(VisiblePosition(firstPositionInOrBeforeNode(startNode))));
         return;
     }
     
@@ -198,7 +198,7 @@ void BreakBlockquoteCommand::doApply()
     addBlockPlaceholderIfNeeded(clonedBlockquote.get());
     
     // Put the selection right before the break.
-    setEndingSelection(VisibleSelection(Position(breakNode.get(), 0), DOWNSTREAM));
+    setEndingSelection(VisibleSelection(positionBeforeNode(breakNode.get()), DOWNSTREAM));
     rebalanceWhitespace();
 }
 
diff --git a/Source/WebCore/editing/CompositeEditCommand.cpp b/Source/WebCore/editing/CompositeEditCommand.cpp
index 748777d..9e1dfca 100644
--- a/Source/WebCore/editing/CompositeEditCommand.cpp
+++ b/Source/WebCore/editing/CompositeEditCommand.cpp
@@ -301,7 +301,7 @@ void CompositeEditCommand::inputText(const String& text, bool selectInsertedText
 {
     unsigned offset = 0;
     unsigned length = text.length();
-    RefPtr<Range> startRange = Range::create(document(), Position(document()->documentElement(), 0), endingSelection().start());
+    RefPtr<Range> startRange = Range::create(document(), firstPositionInNode(document()->documentElement()), endingSelection().start());
     unsigned startIndex = TextIterator::rangeLength(startRange.get());
     size_t newline;
     do {
@@ -398,17 +398,17 @@ static inline bool isWhitespace(UChar c)
 // FIXME: Doesn't go into text nodes that contribute adjacent text (siblings, cousins, etc).
 void CompositeEditCommand::rebalanceWhitespaceAt(const Position& position)
 {
-    Node* node = position.node();
-    if (!node || !node->isTextNode())
+    Node* node = position.containerNode();
+    if (position.anchorType() != Position::PositionIsOffsetInAnchor || !node || !node->isTextNode())
         return;
     Text* textNode = static_cast<Text*>(node);
-    
+
     if (textNode->length() == 0)
         return;
     RenderObject* renderer = textNode->renderer();
     if (renderer && !renderer->style()->collapseWhiteSpace())
         return;
-        
+
     String text = textNode->data();
     ASSERT(!text.isEmpty());
 
@@ -432,8 +432,8 @@ void CompositeEditCommand::rebalanceWhitespaceAt(const Position& position)
     int length = downstream - upstream + 1;
     ASSERT(length > 0);
     
-    VisiblePosition visibleUpstreamPos(Position(position.node(), upstream));
-    VisiblePosition visibleDownstreamPos(Position(position.node(), downstream + 1));
+    VisiblePosition visibleUpstreamPos(Position(position.containerNode(), upstream, Position::PositionIsOffsetInAnchor));
+    VisiblePosition visibleDownstreamPos(Position(position.containerNode(), downstream + 1, Position::PositionIsOffsetInAnchor));
     
     String string = text.substring(upstream, length);
     String rebalancedString = stringWithRebalancedWhitespace(string,
@@ -715,10 +715,10 @@ PassRefPtr<Node> CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessar
     }
 
     RefPtr<Node> newBlock = insertNewDefaultParagraphElementAt(upstreamStart);
-    
+
     bool endWasBr = visibleParagraphEnd.deepEquivalent().node()->hasTagName(brTag);
 
-    moveParagraphs(visibleParagraphStart, visibleParagraphEnd, VisiblePosition(Position(newBlock.get(), 0)));
+    moveParagraphs(visibleParagraphStart, visibleParagraphEnd, VisiblePosition(firstPositionInNode(newBlock.get())));
 
     if (newBlock->lastChild() && newBlock->lastChild()->hasTagName(brTag) && !endWasBr)
         removeNode(newBlock->lastChild());
@@ -973,10 +973,10 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
         // Need an updateLayout here in case inserting the br has split a text node.
         updateLayout();
     }
-        
-    RefPtr<Range> startToDestinationRange(Range::create(document(), Position(document(), 0), rangeCompliantEquivalent(destination.deepEquivalent())));
+
+    RefPtr<Range> startToDestinationRange(Range::create(document(), firstPositionInNode(document()->documentElement()), rangeCompliantEquivalent(destination.deepEquivalent())));
     destinationIndex = TextIterator::rangeLength(startToDestinationRange.get(), true);
-    
+
     setEndingSelection(destination);
     ASSERT(endingSelection().isCaretOrRange());
     applyCommandToComposite(ReplaceSelectionCommand::create(document(), fragment, true, false, !preserveStyle, false, true));
@@ -1055,7 +1055,7 @@ bool CompositeEditCommand::breakOutOfEmptyListItem()
     }
 
     appendBlockPlaceholder(newBlock);
-    setEndingSelection(VisibleSelection(Position(newBlock.get(), 0), DOWNSTREAM));
+    setEndingSelection(VisibleSelection(firstPositionInNode(newBlock.get()), DOWNSTREAM));
 
     style->prepareToApplyAt(endingSelection().start());
     if (!style->isEmpty())
@@ -1088,7 +1088,7 @@ bool CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph()
     // We want to replace this quoted paragraph with an unquoted one, so insert a br
     // to hold the caret before the highest blockquote.
     insertNodeBefore(br, highestBlockquote);
-    VisiblePosition atBR(Position(br.get(), 0));
+    VisiblePosition atBR(positionBeforeNode(br.get()));
     // If the br we inserted collapsed, for example foo<br><blockquote>...</blockquote>, insert
     // a second one.
     if (!isStartOfParagraph(atBR))
@@ -1191,8 +1191,8 @@ PassRefPtr<Node> CompositeEditCommand::splitTreeToNode(Node* start, Node* end, b
     for (node = start; node && node->parentNode() != end; node = node->parentNode()) {
         if (!node->parentNode()->isElementNode())
             break;
-        VisiblePosition positionInParent(Position(node->parentNode(), 0), DOWNSTREAM);
-        VisiblePosition positionInNode(Position(node, 0), DOWNSTREAM);
+        VisiblePosition positionInParent(firstPositionInNode(node->parentNode()), DOWNSTREAM);
+        VisiblePosition positionInNode(firstPositionInOrBeforeNode(node.get()), DOWNSTREAM);
         if (positionInParent != positionInNode)
             applyCommandToComposite(SplitElementCommand::create(static_cast<Element*>(node->parentNode()), node));
     }
diff --git a/Source/WebCore/editing/DeleteButtonController.cpp b/Source/WebCore/editing/DeleteButtonController.cpp
index 028edc8..61e3190 100644
--- a/Source/WebCore/editing/DeleteButtonController.cpp
+++ b/Source/WebCore/editing/DeleteButtonController.cpp
@@ -159,7 +159,7 @@ static HTMLElement* enclosingDeletableElement(const VisibleSelection& selection)
     if (!container->isContentEditable())
         return 0;
 
-    Node* element = enclosingNodeOfType(Position(container, 0), &isDeletableElement);
+    Node* element = enclosingNodeOfType(firstPositionInNode(container), &isDeletableElement);
     if (!element)
         return 0;
 
diff --git a/Source/WebCore/editing/htmlediting.h b/Source/WebCore/editing/htmlediting.h
index cec69de..1f6b986 100644
--- a/Source/WebCore/editing/htmlediting.h
+++ b/Source/WebCore/editing/htmlediting.h
@@ -117,12 +117,12 @@ Position positionOutsideContainingSpecialElement(const Position&, Node** contain
 
 inline Position firstPositionInOrBeforeNode(Node* node)
 {
-    return canHaveChildrenForEditing(node) ? firstPositionInNode(node) : positionBeforeNode(node);
+    return editingIgnoresContent(node) ? positionBeforeNode(node) : firstPositionInNode(node);
 }
 
 inline Position lastPositionInOrAfterNode(Node* node)
 {
-    return canHaveChildrenForEditing(node) ? lastPositionInNode(node) : positionAfterNode(node);
+    return editingIgnoresContent(node) ? positionAfterNode(node) : lastPositionInNode(node);
 }
 
 // Position creation functions are inline to prevent ref-churn.

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list