Changeset 80317 in webkit


Ignore:
Timestamp:
Mar 3, 2011 8:58:20 PM (13 years ago)
Author:
rniwa@webkit.org
Message:

2011-03-03 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Kent Tamura.

Stop calling deprecatedNode and deprecatedEditingOffset in InsertTextCommand
https://bugs.webkit.org/show_bug.cgi?id=55352

Stopped calling deprecatedNode and deprecatedEditingOffset in the following functions:

  • editing/CompositeEditCommand.cpp: (WebCore::CompositeEditCommand::positionOutsideTabSpan): Takes care of all types of positions and no longer calls deprecated functions.
  • editing/InsertTextCommand.cpp: (WebCore::InsertTextCommand::positionInsideTextNode): Ditto; renamed from prepareForTextInsertion. Check if the text node inside a tab span before checking if the container node is a text node because the position before or after a text node can still be inside a tab span. (WebCore::InsertTextCommand::input): No longer calls deprecated functions.
  • editing/InsertTextCommand.h:
  • editing/ModifySelectionListLevel.cpp: (WebCore::getStartEndListChildren): Call anchorNode() instead of deprecatedNode() because the start or the end of selection could be an immediate child of a list node (e.g. br inside ul)
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r80315 r80317  
     12011-03-03  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Kent Tamura.
     4
     5        Stop calling deprecatedNode and deprecatedEditingOffset in InsertTextCommand
     6        https://bugs.webkit.org/show_bug.cgi?id=55352
     7
     8        Stopped calling deprecatedNode and deprecatedEditingOffset in the following functions:
     9
     10        * editing/CompositeEditCommand.cpp:
     11        (WebCore::CompositeEditCommand::positionOutsideTabSpan): Takes care of all types of positions and
     12        no longer calls deprecated functions.
     13        * editing/InsertTextCommand.cpp:
     14        (WebCore::InsertTextCommand::positionInsideTextNode): Ditto; renamed from prepareForTextInsertion.
     15        Check if the text node inside a tab span before checking if the container node is a text node
     16        because the position before or after a text node can still be inside a tab span.
     17        (WebCore::InsertTextCommand::input): No longer calls deprecated functions.
     18        * editing/InsertTextCommand.h:
     19        * editing/ModifySelectionListLevel.cpp:
     20        (WebCore::getStartEndListChildren): Call anchorNode() instead of deprecatedNode() because the start
     21        or the end of selection could be an immediate child of a list node (e.g. br inside ul)
     22
    1232011-03-03  Hans Wennborg  <hans@chromium.org>
    224
  • trunk/Source/WebCore/editing/CompositeEditCommand.cpp

    r79536 r80317  
    343343Position CompositeEditCommand::positionOutsideTabSpan(const Position& pos)
    344344{
    345     if (!isTabSpanTextNode(pos.deprecatedNode()))
     345    if (!isTabSpanTextNode(pos.anchorNode()))
    346346        return pos;
    347    
    348     Node* tabSpan = tabSpanNode(pos.deprecatedNode());
    349    
    350     if (pos.deprecatedEditingOffset() <= caretMinOffset(pos.deprecatedNode()))
     347
     348    if (pos.anchorType() == Position::PositionIsAfterAnchor)
     349        return positionInParentAfterNode(pos.anchorNode());
     350    if (pos.anchorType() == Position::PositionIsBeforeAnchor)
     351        return positionInParentBeforeNode(pos.anchorNode());
     352
     353    Node* tabSpan = tabSpanNode(pos.containerNode());
     354
     355    if (pos.offsetInContainerNode() <= caretMinOffset(pos.containerNode()))
    351356        return positionInParentBeforeNode(tabSpan);
    352        
    353     if (pos.deprecatedEditingOffset() >= caretMaxOffset(pos.deprecatedNode()))
     357
     358    if (pos.offsetInContainerNode() >= caretMaxOffset(pos.containerNode()))
    354359        return positionInParentAfterNode(tabSpan);
    355360
    356     splitTextNodeContainingElement(static_cast<Text *>(pos.deprecatedNode()), pos.deprecatedEditingOffset());
     361    splitTextNodeContainingElement(static_cast<Text *>(pos.containerNode()), pos.offsetInContainerNode());
    357362    return positionInParentBeforeNode(tabSpan);
    358363}
  • trunk/Source/WebCore/editing/InsertTextCommand.cpp

    r79976 r80317  
    4848}
    4949
    50 Position InsertTextCommand::prepareForTextInsertion(const Position& p)
     50Position InsertTextCommand::positionInsideTextNode(const Position& p)
    5151{
    5252    Position pos = p;
     53    if (isTabSpanTextNode(pos.anchorNode())) {
     54        RefPtr<Node> textNode = document()->createEditingTextNode("");
     55        insertNodeAtTabSpanPosition(textNode.get(), pos);
     56        return firstPositionInNode(textNode.get());
     57    }
     58
    5359    // Prepare for text input by looking at the specified position.
    5460    // It may be necessary to insert a text node to receive characters.
    55     if (!pos.deprecatedNode()->isTextNode()) {
     61    if (!pos.containerNode()->isTextNode()) {
    5662        RefPtr<Node> textNode = document()->createEditingTextNode("");
    5763        insertNodeAt(textNode.get(), pos);
    58         return firstPositionInNode(textNode.get());
    59     }
    60 
    61     if (isTabSpanTextNode(pos.deprecatedNode())) {
    62         RefPtr<Node> textNode = document()->createEditingTextNode("");
    63         insertNodeAtTabSpanPosition(textNode.get(), pos);
    6464        return firstPositionInNode(textNode.get());
    6565    }
     
    142142    // It is possible for the node that contains startPosition to contain only unrendered whitespace,
    143143    // and so deleteInsignificantText could remove it.  Save the position before the node in case that happens.
    144     Position positionBeforeStartNode(positionInParentBeforeNode(startPosition.deprecatedNode()));
     144    Position positionBeforeStartNode(positionInParentBeforeNode(startPosition.containerNode()));
    145145    deleteInsignificantText(startPosition.upstream(), startPosition.downstream());
    146146    if (!startPosition.anchorNode()->inDocument())
     
    160160    } else {
    161161        // Make sure the document is set up to receive text
    162         startPosition = prepareForTextInsertion(startPosition);
     162        startPosition = positionInsideTextNode(startPosition);
     163        ASSERT(startPosition.anchorType() == Position::PositionIsOffsetInAnchor);
     164        ASSERT(startPosition.containerNode());
     165        ASSERT(startPosition.containerNode()->isTextNode());
    163166        if (placeholder.isNotNull())
    164167            removePlaceholderAt(placeholder);
    165         Text* textNode = static_cast<Text*>(startPosition.deprecatedNode());
    166         int offset = startPosition.deprecatedEditingOffset();
     168        Text* textNode = static_cast<Text*>(startPosition.containerNode());
     169        const unsigned offset = startPosition.offsetInContainerNode();
    167170
    168171        insertTextIntoNode(textNode, offset, text);
     
    178181            ASSERT(whitespaceRebalance == RebalanceAllWhitespaces);
    179182            if (canRebalance(startPosition) && canRebalance(endPosition))
    180                 rebalanceWhitespaceOnTextSubstring(textNode, startPosition.deprecatedEditingOffset(), endPosition.deprecatedEditingOffset());
     183                rebalanceWhitespaceOnTextSubstring(textNode, startPosition.offsetInContainerNode(), endPosition.offsetInContainerNode());
    181184        }
    182185    }
  • trunk/Source/WebCore/editing/InsertTextCommand.h

    r76482 r80317  
    5454    virtual bool isInsertTextCommand() const;
    5555
    56     Position prepareForTextInsertion(const Position&);
     56    Position positionInsideTextNode(const Position&);
    5757    Position insertTab(const Position&);
    5858   
  • trunk/Source/WebCore/editing/ModifySelectionListLevel.cpp

    r79196 r80317  
    5353
    5454    // start must be in a list child
    55     Node* startListChild = enclosingListChild(selection.start().deprecatedNode());
     55    Node* startListChild = enclosingListChild(selection.start().anchorNode());
    5656    if (!startListChild)
    5757        return false;
    58        
     58
    5959    // end must be in a list child
    60     Node* endListChild = selection.isRange() ? enclosingListChild(selection.end().deprecatedNode()) : startListChild;
     60    Node* endListChild = selection.isRange() ? enclosingListChild(selection.end().anchorNode()) : startListChild;
    6161    if (!endListChild)
    6262        return false;
Note: See TracChangeset for help on using the changeset viewer.