⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 121303 in webkit


Ignore:
Timestamp:
Jun 26, 2012, 5:00:52 PM (14 years ago)
Author:
rniwa@webkit.org
Message:

Stop calling node() and deprecatedEditingOffset() in comparePositions
https://bugs.webkit.org/show_bug.cgi?id=54535

Reviewed by Enrica Casucci.

Source/WebCore:

Replaced deprecatedNode() and deprecatedEditingOffset() by containerNode() and computeOffsetInContainerNode()
in comparePositions().

In addition, fixed a bunch of bugs in DeleteSelectionCommand::handleSpecialCaseBRDelete revealed by this change:

  • Use node after position instead of deprecated node in determinig whether start and end positions at a br.
  • Don't set m_startsAtEmptyLine true when BR is wrapped in a block element. The only reason this code had worked

was positions like (div, offset, 0) and (br, before) in <div><br> were treated differently, which we no longer do.

  • editing/DeleteSelectionCommand.cpp:

(WebCore::DeleteSelectionCommand::handleSpecialCaseBRDelete):

  • editing/htmlediting.cpp:

(WebCore::comparePositions):

LayoutTests:

Rebaselined existing tests. There are no user-visible changes.

  • editing/inseting/font-size-clears-from-typing-style-expected.txt: No longer keeps div's around

when merging paragraphs.

  • platform/mac/editing/deleting/delete-br-002-expected.txt:
  • platform/mac/editing/deleting/delete-br-004-expected.txt:
  • platform/mac/editing/deleting/delete-br-005-expected.txt:
  • platform/mac/editing/deleting/delete-br-006-expected.txt:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r121299 r121303  
     12012-06-26  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Stop calling node() and deprecatedEditingOffset() in comparePositions
     4        https://bugs.webkit.org/show_bug.cgi?id=54535
     5
     6        Reviewed by Enrica Casucci.
     7
     8        Rebaselined existing tests. There are no user-visible changes.
     9
     10        * editing/inseting/font-size-clears-from-typing-style-expected.txt: No longer keeps div's around
     11        when merging paragraphs.
     12        * platform/mac/editing/deleting/delete-br-002-expected.txt:
     13        * platform/mac/editing/deleting/delete-br-004-expected.txt:
     14        * platform/mac/editing/deleting/delete-br-005-expected.txt:
     15        * platform/mac/editing/deleting/delete-br-006-expected.txt:
     16
    1172012-06-26  Alice Cheng  <alice_cheng@apple.com>
    218
  • trunk/LayoutTests/editing/inserting/font-size-clears-from-typing-style-expected.txt

    r121298 r121303  
    11Tests that we don't serialize redundant font-size in typingStyle. There should be no span or style attribute around A or B below.See https://bugs.webkit.org/show_bug.cgi?id=26279.
    2 | <div>
    3 |   id="wrapper"
    4 |   "B<#selection-caret>A"
     2| "B<#selection-caret>A"
     3| <br>
  • trunk/LayoutTests/platform/mac/editing/deleting/delete-br-002-expected.txt

    r93134 r121303  
    2525EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    2626EDITING DELEGATE: shouldDeleteDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document
     27EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document toDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 2 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    2728EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    2829EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
  • trunk/LayoutTests/platform/mac/editing/deleting/delete-br-004-expected.txt

    r93134 r121303  
    2626EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    2727EDITING DELEGATE: shouldDeleteDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 4 of SPAN > DIV > BODY > HTML > #document
     28EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > SPAN > DIV > BODY > HTML > #document to 9 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    2829EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    2930EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    4344          RenderText {#text} at (14,70) size 92x28
    4445            text run at (14,70) width 92: "years ago"
    45         RenderText {#text} at (0,0) size 0x0
    4646caret: position 0 of child 3 {#text} of child 1 {SPAN} of child 1 {DIV} of body
  • trunk/LayoutTests/platform/mac/editing/deleting/delete-br-005-expected.txt

    r93134 r121303  
    2626EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    2727EDITING DELEGATE: shouldDeleteDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 4 of SPAN > DIV > BODY > HTML > #document
     28EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > SPAN > DIV > BODY > HTML > #document to 9 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    2829EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    2930EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
    3031EDITING DELEGATE: shouldDeleteDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document
     32EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > SPAN > DIV > BODY > HTML > #document to 9 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 2 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    3133EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    3234EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    4547          RenderText {#text} at (14,42) size 92x28
    4648            text run at (14,42) width 92: "years ago"
    47         RenderText {#text} at (0,0) size 0x0
    4849caret: position 0 of child 2 {#text} of child 1 {SPAN} of child 1 {DIV} of body
  • trunk/LayoutTests/platform/mac/editing/deleting/delete-br-006-expected.txt

    r93134 r121303  
    2626EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    2727EDITING DELEGATE: shouldDeleteDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 4 of SPAN > DIV > BODY > HTML > #document
     28EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > SPAN > DIV > BODY > HTML > #document to 9 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    2829EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    2930EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
    3031EDITING DELEGATE: shouldDeleteDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document
     32EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > SPAN > DIV > BODY > HTML > #document to 9 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 2 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    3133EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    3234EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    4850          RenderText {#text} at (218,14) size 92x28
    4951            text run at (218,14) width 92: "years ago"
    50         RenderText {#text} at (0,0) size 0x0
    5152caret: position 23 of child 0 {#text} of child 1 {SPAN} of child 1 {DIV} of body
  • trunk/Source/WebCore/ChangeLog

    r121300 r121303  
     12012-06-26  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Stop calling node() and deprecatedEditingOffset() in comparePositions
     4        https://bugs.webkit.org/show_bug.cgi?id=54535
     5
     6        Reviewed by Enrica Casucci.
     7
     8        Replaced deprecatedNode() and deprecatedEditingOffset() by containerNode() and computeOffsetInContainerNode()
     9        in comparePositions().
     10       
     11        In addition, fixed a bunch of bugs in DeleteSelectionCommand::handleSpecialCaseBRDelete revealed by this change:
     12        - Use node after position instead of deprecated node in determinig whether start and end positions at a br.
     13        - Don't set m_startsAtEmptyLine true when BR is wrapped in a block element. The only reason this code had worked
     14        was positions like (div, offset, 0) and (br, before) in <div><br> were treated differently, which we no longer do.
     15
     16        * editing/DeleteSelectionCommand.cpp:
     17        (WebCore::DeleteSelectionCommand::handleSpecialCaseBRDelete):
     18        * editing/htmlediting.cpp:
     19        (WebCore::comparePositions):
     20
    1212012-06-26  Christophe Dumez  <christophe.dumez@intel.com>
    222
  • trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp

    r116798 r121303  
    298298bool DeleteSelectionCommand::handleSpecialCaseBRDelete()
    299299{
     300    Node* nodeAfterUpstreamStart = m_upstreamStart.computeNodeAfterPosition();
     301    Node* nodeAfterDownstreamStart = m_downstreamStart.computeNodeAfterPosition();
     302    // Upstream end will appear before BR due to canonicalization
     303    Node* nodeAfterUpstreamEnd = m_upstreamEnd.computeNodeAfterPosition();
     304
     305    if (!nodeAfterUpstreamStart || !nodeAfterDownstreamStart)
     306        return false;
     307
    300308    // Check for special-case where the selection contains only a BR on a line by itself after another BR.
    301     bool upstreamStartIsBR = m_upstreamStart.deprecatedNode()->hasTagName(brTag);
    302     bool downstreamStartIsBR = m_downstreamStart.deprecatedNode()->hasTagName(brTag);
    303     bool isBROnLineByItself = upstreamStartIsBR && downstreamStartIsBR && m_downstreamStart.deprecatedNode() == m_upstreamEnd.deprecatedNode();
     309    bool upstreamStartIsBR = nodeAfterUpstreamStart->hasTagName(brTag);
     310    bool downstreamStartIsBR = nodeAfterDownstreamStart->hasTagName(brTag);
     311    bool isBROnLineByItself = upstreamStartIsBR && downstreamStartIsBR && nodeAfterDownstreamStart == nodeAfterUpstreamEnd;
    304312    if (isBROnLineByItself) {
    305         removeNode(m_downstreamStart.deprecatedNode());
     313        removeNode(nodeAfterDownstreamStart);
    306314        return true;
    307315    }
    308316
    309     // Not a special-case delete per se, but we can detect that the merging of content between blocks
    310     // should not be done.
    311     if (upstreamStartIsBR && downstreamStartIsBR) {
     317    // FIXME: This code doesn't belong in here.
     318    // We detect the case where the start is an empty line consisting of BR not wrapped in a block element.
     319    if (upstreamStartIsBR && downstreamStartIsBR && !(isStartOfBlock(positionBeforeNode(nodeAfterUpstreamStart)) && isEndOfBlock(positionAfterNode(nodeAfterUpstreamStart)))) {
    312320        m_startsAtEmptyLine = true;
    313321        m_endingPosition = m_downstreamEnd;
  • trunk/Source/WebCore/editing/htmlediting.cpp

    r120991 r121303  
    7979        return 0;
    8080
    81     Node* nodeA = commonScope->ancestorInThisScope(a.deprecatedNode());
     81    Node* nodeA = commonScope->ancestorInThisScope(a.containerNode());
    8282    ASSERT(nodeA);
    83     bool hasDescendentA = nodeA != a.deprecatedNode();
    84     int offsetA = hasDescendentA ? 0 : a.deprecatedEditingOffset();
    85 
    86     Node* nodeB = commonScope->ancestorInThisScope(b.deprecatedNode());
     83    bool hasDescendentA = nodeA != a.containerNode();
     84    int offsetA = hasDescendentA ? 0 : a.computeOffsetInContainerNode();
     85
     86    Node* nodeB = commonScope->ancestorInThisScope(b.containerNode());
    8787    ASSERT(nodeB);
    88     bool hasDescendentB = nodeB != b.deprecatedNode();
    89     int offsetB = hasDescendentB ? 0 : b.deprecatedEditingOffset();
     88    bool hasDescendentB = nodeB != b.containerNode();
     89    int offsetB = hasDescendentB ? 0 : b.computeOffsetInContainerNode();
    9090
    9191    int bias = 0;
Note: See TracChangeset for help on using the changeset viewer.