Changeset 207578 in webkit


Ignore:
Timestamp:
Oct 19, 2016 4:49:43 PM (8 years ago)
Author:
joone.hur@intel.com
Message:

Add a plain space instead of   between text nodes
https://bugs.webkit.org/show_bug.cgi?id=123163

Reviewed by Ryosuke Niwa.

When we rebalance white spaces,   can be added as space
under some conditions. This patch adds a condition that the next
sibling text node should not exist.

Source/WebCore:

No new tests, updated existing test.

  • editing/CompositeEditCommand.cpp:

(WebCore::CompositeEditCommand::rebalanceWhitespaceOnTextSubstring):

  • editing/htmlediting.cpp:

(WebCore::stringWithRebalancedWhitespace):

  • editing/htmlediting.h:

LayoutTests:

  • accessibility/mac/find-and-replace-match-capitalization-expected.txt:
  • accessibility/mac/find-and-replace-match-capitalization.html:
  • accessibility/mac/select-text/select-text-135575-expected.txt:
  • accessibility/mac/select-text/select-text-7-expected.txt:
  • accessibility/mac/select-text/select-text-8-expected.txt:
  • accessibility/mac/select-text/select-text-9-expected.txt:
  • editing/mac/spelling/autocorrection-blockquote-crash-expected.txt:
  • editing/pasteboard/paste-text-003-expected.txt:
  • platform/gtk/editing/execCommand/paste-1-expected.txt:
  • platform/gtk/editing/pasteboard/paste-2-expected.txt:
  • platform/gtk/editing/pasteboard/unrendered-br-expected.txt:
  • platform/mac/editing/execCommand/paste-1-expected.txt:
  • platform/mac/editing/pasteboard/paste-2-expected.txt:
  • platform/mac/editing/pasteboard/unrendered-br-expected.txt:
Location:
trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r207575 r207578  
     12016-10-19  Joone Hur  <joone.hur@intel.com>
     2
     3        Add a plain space instead of &nbsp; between text nodes
     4        https://bugs.webkit.org/show_bug.cgi?id=123163
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        When we rebalance white spaces, &nbsp; can be added as space
     9        under some conditions. This patch adds a condition that the next
     10        sibling text node should not exist.
     11
     12        * accessibility/mac/find-and-replace-match-capitalization-expected.txt:
     13        * accessibility/mac/find-and-replace-match-capitalization.html:
     14        * accessibility/mac/select-text/select-text-135575-expected.txt:
     15        * accessibility/mac/select-text/select-text-7-expected.txt:
     16        * accessibility/mac/select-text/select-text-8-expected.txt:
     17        * accessibility/mac/select-text/select-text-9-expected.txt:
     18        * editing/mac/spelling/autocorrection-blockquote-crash-expected.txt:
     19        * editing/pasteboard/paste-text-003-expected.txt:
     20        * platform/gtk/editing/execCommand/paste-1-expected.txt:
     21        * platform/gtk/editing/pasteboard/paste-2-expected.txt:
     22        * platform/gtk/editing/pasteboard/unrendered-br-expected.txt:
     23        * platform/mac/editing/execCommand/paste-1-expected.txt:
     24        * platform/mac/editing/pasteboard/paste-2-expected.txt:
     25        * platform/mac/editing/pasteboard/unrendered-br-expected.txt:
     26
    1272016-10-19  Sam Weinig  <sam@webkit.org>
    228
  • trunk/LayoutTests/accessibility/mac/find-and-replace-match-capitalization-expected.txt

    r187799 r207578  
    1 The Test test TEST.
     1The Test test TEST.
    22
    33This tests that find and replace will match the capitalization of the replaced word.
     
    66
    77
    8 PASS document.getElementById('text').innerHTML is 'The&nbsp;Test&nbsp;jumped high.'
    9 PASS document.getElementById('text').innerHTML is 'The&nbsp;Test&nbsp;test&nbsp;high.'
    10 PASS document.getElementById('text').innerHTML is 'The&nbsp;Test&nbsp;test&nbsp;TEST.'
     8PASS document.getElementById('text').innerHTML is 'The Test&nbsp;jumped high.'
     9PASS document.getElementById('text').innerHTML is 'The Test test&nbsp;high.'
     10PASS document.getElementById('text').innerHTML is 'The Test test TEST.'
    1111PASS successfullyParsed is true
    1212
  • trunk/LayoutTests/accessibility/mac/find-and-replace-match-capitalization.html

    r187799 r207578  
    2121        // 'Man' is capitalized, so the replaced text should end up capitalized.
    2222        var result = text.selectTextWithCriteria("AXSelectTextAmbiguityResolutionClosestToSelection", "man", "test");
    23         shouldBe("document.getElementById('text').innerHTML", "'The&nbsp;Test&nbsp;jumped high.'");
     23        shouldBe("document.getElementById('text').innerHTML", "'The Test&nbsp;jumped high.'");
    2424
    2525        // 'jumped' is not capitalized so the text should not be capitalized.
    2626        result = text.selectTextWithCriteria("AXSelectTextAmbiguityResolutionClosestToSelection", "jumped", "Test");
    27         shouldBe("document.getElementById('text').innerHTML", "'The&nbsp;Test&nbsp;test&nbsp;high.'");
     27        shouldBe("document.getElementById('text').innerHTML", "'The Test test&nbsp;high.'");
    2828
    2929        // The replacement text was all caps, so don't change based on the existing text.
    3030        result = text.selectTextWithCriteria("AXSelectTextAmbiguityResolutionClosestToSelection", "high", "TEST");
    31         shouldBe("document.getElementById('text').innerHTML", "'The&nbsp;Test&nbsp;test&nbsp;TEST.'");
     31        shouldBe("document.getElementById('text').innerHTML", "'The Test test TEST.'");
    3232
    3333    }
  • trunk/LayoutTests/accessibility/mac/select-text/select-text-135575-expected.txt

    r187799 r207578  
    11The quick brown fox jumps over the lazy dog.
    22
    3 TEXT2: THE quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
     3TEXT2: THE quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
    44
    55This tests the ability to select and replace text with respect to selection.
  • trunk/LayoutTests/accessibility/mac/select-text/select-text-7-expected.txt

    r187799 r207578  
    1 The slow brown fox jumps over the lazy dog.
     1The slow brown fox jumps over the lazy dog.
    22
    33TEXT2: The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
  • trunk/LayoutTests/accessibility/mac/select-text/select-text-8-expected.txt

    r187799 r207578  
    1 The quick brown cat jumps over the lazy dog.
     1The quick brown cat jumps over the lazy dog.
    22
    33TEXT2: The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
  • trunk/LayoutTests/accessibility/mac/select-text/select-text-9-expected.txt

    r187799 r207578  
    1 The quick Brown fox jumps over the lazy dog.
     1The quick Brown fox jumps over the lazy dog.
    22
    33TEXT2: The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
  • trunk/LayoutTests/editing/mac/spelling/autocorrection-blockquote-crash-expected.txt

    r187932 r207578  
    99
    1010would this
    11 test notational 
     11test notational 
    1212make a difference?
    1313
  • trunk/LayoutTests/editing/pasteboard/paste-text-003-expected.txt

    r130411 r207578  
    107107This test copies and pastes "is a tide in the affairs of men,\nWhich taken at the flood leads on to fortune.\nOmitted" twice.
    108108
    109 There is a tide in the affairs of men,
     109There is a tide in the affairs of men,
    110110Which taken at the flood leads on to fortune.
    111111Omittedis a tide in the affairs of men,
     
    114114Is bound in shallows and in miseries.
    115115execCopyCommand: <div id="test" class="editing">There is a tide in the affairs of men, <div class="editing">Which taken at the flood leads on to fortune. <div class="editing">Omitted, all the voyage of their life, <div class="editing">Is bound in shallows and in miseries. </div> </div> </div> </div>
    116 execPasteCommand: <div id="test" class="editing">There&nbsp;is a tide in the affairs of men,<div class="editing">Which taken at the flood leads on to fortune.</div><div class="editing"><div class="editing">Omitted, all the voyage of their life, <div class="editing">Is bound in shallows and in miseries. </div> </div> </div> </div>
    117 execPasteCommand: <div id="test" class="editing">There&nbsp;is a tide in the affairs of men,<div class="editing">Which taken at the flood leads on to fortune.</div><div class="editing"><div class="editing">Omittedis a tide in the affairs of men,</div><div class="editing">Which taken at the flood leads on to fortune.</div><div class="editing">Omitted, all the voyage of their life, <div class="editing">Is bound in shallows and in miseries. </div> </div> </div> </div>
     116execPasteCommand: <div id="test" class="editing">There is a tide in the affairs of men,<div class="editing">Which taken at the flood leads on to fortune.</div><div class="editing"><div class="editing">Omitted, all the voyage of their life, <div class="editing">Is bound in shallows and in miseries. </div> </div> </div> </div>
     117execPasteCommand: <div id="test" class="editing">There is a tide in the affairs of men,<div class="editing">Which taken at the flood leads on to fortune.</div><div class="editing"><div class="editing">Omittedis a tide in the affairs of men,</div><div class="editing">Which taken at the flood leads on to fortune.</div><div class="editing">Omitted, all the voyage of their life, <div class="editing">Is bound in shallows and in miseries. </div> </div> </div> </div>
  • trunk/LayoutTests/platform/gtk/editing/execCommand/paste-1-expected.txt

    r159017 r207578  
    1111EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
    1212EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 8 of #text > BODY > HTML > #document to 8 of #text > BODY > HTML > #document givenAction:WebViewInsertActionPasted
    13 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 8 of #text > BODY > HTML > #document to 8 of #text > BODY > HTML > #document toDOMRange:range from 11 of #text > BODY > HTML > #document to 11 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     13EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
     14EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 7 of #text > BODY > HTML > #document to 7 of #text > BODY > HTML > #document toDOMRange:range from 11 of #text > BODY > HTML > #document to 11 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    1415EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1516EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
  • trunk/LayoutTests/platform/gtk/editing/pasteboard/paste-2-expected.txt

    r159017 r207578  
    1111EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
    1212EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 8 of #text > BODY > HTML > #document to 8 of #text > BODY > HTML > #document givenAction:WebViewInsertActionPasted
    13 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 8 of #text > BODY > HTML > #document to 8 of #text > BODY > HTML > #document toDOMRange:range from 11 of #text > BODY > HTML > #document to 11 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     13EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
     14EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 7 of #text > BODY > HTML > #document to 7 of #text > BODY > HTML > #document toDOMRange:range from 11 of #text > BODY > HTML > #document to 11 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    1415EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1516EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
  • trunk/LayoutTests/platform/gtk/editing/pasteboard/unrendered-br-expected.txt

    r148801 r207578  
    33EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    44EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    5 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 6 of #text > DIV > BODY > HTML > #document to 6 of #text > DIV > BODY > HTML > #document toDOMRange:range from 17 of #text > DIV > DIV > BODY > HTML > #document to 17 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     5EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
     6EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 5 of #text > DIV > BODY > HTML > #document to 5 of #text > DIV > BODY > HTML > #document toDOMRange:range from 17 of #text > DIV > DIV > BODY > HTML > #document to 17 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    67EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    78EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
  • trunk/LayoutTests/platform/mac/editing/execCommand/paste-1-expected.txt

    r177774 r207578  
    1111EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
    1212EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 8 of #text > BODY > HTML > #document to 8 of #text > BODY > HTML > #document givenAction:WebViewInsertActionPasted
    13 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 8 of #text > BODY > HTML > #document to 8 of #text > BODY > HTML > #document toDOMRange:range from 11 of #text > BODY > HTML > #document to 11 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     13EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
     14EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 7 of #text > BODY > HTML > #document to 7 of #text > BODY > HTML > #document toDOMRange:range from 11 of #text > BODY > HTML > #document to 11 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    1415EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1516EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
  • trunk/LayoutTests/platform/mac/editing/pasteboard/paste-2-expected.txt

    r177774 r207578  
    1111EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
    1212EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 8 of #text > BODY > HTML > #document to 8 of #text > BODY > HTML > #document givenAction:WebViewInsertActionPasted
    13 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 8 of #text > BODY > HTML > #document to 8 of #text > BODY > HTML > #document toDOMRange:range from 11 of #text > BODY > HTML > #document to 11 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     13EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
     14EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 7 of #text > BODY > HTML > #document to 7 of #text > BODY > HTML > #document toDOMRange:range from 11 of #text > BODY > HTML > #document to 11 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    1415EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1516EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
  • trunk/LayoutTests/platform/mac/editing/pasteboard/unrendered-br-expected.txt

    r177774 r207578  
    33EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    44EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    5 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 6 of #text > DIV > BODY > HTML > #document to 6 of #text > DIV > BODY > HTML > #document toDOMRange:range from 17 of #text > DIV > DIV > BODY > HTML > #document to 17 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     5EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
     6EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 5 of #text > DIV > BODY > HTML > #document to 5 of #text > DIV > BODY > HTML > #document toDOMRange:range from 17 of #text > DIV > DIV > BODY > HTML > #document to 17 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    67EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    78EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
  • trunk/Source/WebCore/ChangeLog

    r207575 r207578  
     12016-10-19  Joone Hur  <joone.hur@intel.com>
     2
     3        Add a plain space instead of &nbsp; between text nodes
     4        https://bugs.webkit.org/show_bug.cgi?id=123163
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        When we rebalance white spaces, &nbsp; can be added as space
     9        under some conditions. This patch adds a condition that the next
     10        sibling text node should not exist.
     11
     12        No new tests, updated existing test.
     13
     14        * editing/CompositeEditCommand.cpp:
     15        (WebCore::CompositeEditCommand::rebalanceWhitespaceOnTextSubstring):
     16        * editing/htmlediting.cpp:
     17        (WebCore::stringWithRebalancedWhitespace):
     18        * editing/htmlediting.h:
     19
    1202016-10-19  Sam Weinig  <sam@webkit.org>
    221
  • trunk/Source/WebCore/editing/CompositeEditCommand.cpp

    r206979 r207578  
    895895    VisiblePosition visibleUpstreamPos(Position(textNode, upstream));
    896896    VisiblePosition visibleDownstreamPos(Position(textNode, downstream));
    897    
     897
     898    Node* nextSibling = textNode->nextSibling();
    898899    String string = text.substring(upstream, length);
    899900    String rebalancedString = stringWithRebalancedWhitespace(string,
    900901    // FIXME: Because of the problem mentioned at the top of this function, we must also use nbsps at the start/end of the string because
    901902    // this function doesn't get all surrounding whitespace, just the whitespace in the current text node.
    902                                                              isStartOfParagraph(visibleUpstreamPos) || upstream == 0,
    903                                                              isEndOfParagraph(visibleDownstreamPos) || (unsigned)downstream == text.length());
     903        isStartOfParagraph(visibleUpstreamPos) || !upstream,
     904        (isEndOfParagraph(visibleDownstreamPos) || (unsigned)downstream == text.length())
     905        && !(nextSibling && nextSibling->isTextNode() && downcast<Text>(nextSibling)->data().at(0) != ' '));
    904906   
    905907    if (string != rebalancedString)
  • trunk/Source/WebCore/editing/htmlediting.cpp

    r203324 r207578  
    398398}
    399399
    400 String stringWithRebalancedWhitespace(const String& string, bool startIsStartOfParagraph, bool endIsEndOfParagraph)
     400String stringWithRebalancedWhitespace(const String& string, bool startIsStartOfParagraph, bool shouldEmitNonBreakingSpaceBeforeEnd)
    401401{
    402402    StringBuilder rebalancedString;
     
    411411        }
    412412        LChar selectedWhitespaceCharacter;
    413         if (previousCharacterWasSpace || (!i && startIsStartOfParagraph) || (i == length - 1 && endIsEndOfParagraph)) {
     413        // We need to ensure there is no next sibling text node. See https://bugs.webkit.org/show_bug.cgi?id=123163
     414        if (previousCharacterWasSpace || (!i && startIsStartOfParagraph) || (i == length - 1 && shouldEmitNonBreakingSpaceBeforeEnd)) {
    414415            selectedWhitespaceCharacter = noBreakSpace;
    415416            previousCharacterWasSpace = false;
  • trunk/Source/WebCore/editing/htmlediting.h

    r202454 r207578  
    193193bool isAmbiguousBoundaryCharacter(UChar);
    194194
    195 String stringWithRebalancedWhitespace(const String&, bool startIsStartOfParagraph, bool endIsEndOfParagraph);
     195String stringWithRebalancedWhitespace(const String&, bool startIsStartOfParagraph, bool shouldEmitNonBreakingSpaceBeforeEnd);
    196196const String& nonBreakingSpaceString();
    197197
Note: See TracChangeset for help on using the changeset viewer.