Changeset 21212 in webkit


Ignore:
Timestamp:
May 1, 2007 3:20:46 PM (17 years ago)
Author:
justing
Message:

LayoutTests:

Reviewed by darin


<rdar://problem/5002441>
Pressing space key does nothing above quoted content or a signature

Demonstrates the bug:

  • editing/inserting/5002441-expected.checksum: Added.
  • editing/inserting/5002441-expected.png: Added.
  • editing/inserting/5002441-expected.txt: Added.
  • editing/inserting/5002441.html: Added.


Fixed. Spaces passed to execCommand("InsertText", ...)
are no longer collapsed:

  • editing/inserting/editable-html-element-expected.checksum:
  • editing/inserting/editable-html-element-expected.png:
  • editing/inserting/editable-html-element-expected.txt:
  • editing/pasteboard/4989774-expected.checksum:
  • editing/pasteboard/4989774-expected.png:
  • editing/pasteboard/4989774-expected.txt:
  • editing/selection/4983858-expected.checksum:
  • editing/selection/4983858-expected.png:
  • editing/selection/4983858-expected.txt:

WebCore:

Reviewed by darin

<rdar://problem/5002441>
Pressing space key does nothing above quoted content or a signature


Inserting a space under these circumstances inserts a single
text node containing a regular space and then does a layout.
That space isn't rendered (which is correct). Whitespace
rebalancing is supposed to correct it but failed. It replaces
the space with a non-breaking space, but that change doesn't
dirty line boxes (9441) and so the space isn't rendered.


This workaround turns all incoming spaces into non-breaking
spaces before they're inserted (they're rebalanced after
insertion and turned back into regular spaces if possible).

  • editing/InsertTextCommand.cpp: (WebCore::InsertTextCommand::prepareForTextInsertion): Removed an old irrelevant FIXME. (WebCore::InsertTextCommand::input): Turn incoming spaces into non breaking spaces before inserting them.
Location:
trunk
Files:
4 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r21211 r21212  
     12007-05-01  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by darin
     4       
     5        <rdar://problem/5002441>
     6        Pressing space key does nothing above quoted content or a signature
     7
     8        Demonstrates the bug:
     9        * editing/inserting/5002441-expected.checksum: Added.
     10        * editing/inserting/5002441-expected.png: Added.
     11        * editing/inserting/5002441-expected.txt: Added.
     12        * editing/inserting/5002441.html: Added.
     13       
     14        Fixed.  Spaces passed to execCommand("InsertText", ...)
     15        are no longer collapsed:
     16        * editing/inserting/editable-html-element-expected.checksum:
     17        * editing/inserting/editable-html-element-expected.png:
     18        * editing/inserting/editable-html-element-expected.txt:
     19        * editing/pasteboard/4989774-expected.checksum:
     20        * editing/pasteboard/4989774-expected.png:
     21        * editing/pasteboard/4989774-expected.txt:
     22        * editing/selection/4983858-expected.checksum:
     23        * editing/selection/4983858-expected.png:
     24        * editing/selection/4983858-expected.txt:
     25
    1262007-05-01  Darin Adler  <darin@apple.com>
    227
  • trunk/LayoutTests/editing/inserting/editable-html-element-expected.checksum

    r14195 r21212  
    1 d53960e87b7f062db7c195bd7a7a7f9a
     11186e4514352fbbb37f6518c9093f1c3
  • trunk/LayoutTests/editing/inserting/editable-html-element-expected.txt

    r20950 r21212  
    1818    RenderBody {BODY} at (8,8) size 784x584
    1919      RenderBlock (anonymous) at (0,0) size 784x54
    20         RenderText {#text} at (0,0) size 783x54
    21           text run at (0,0) width 714: "This tests to make sure that when the enclosing block is the body element, and when the html element is editable, "
    22           text run at (714,0) width 69: "inserting a "
     20        RenderText {#text} at (0,0) size 784x54
     21          text run at (0,0) width 783: "This tests to make sure that when the enclosing block is the body element, and when the html element is editable,  inserting a"
     22          text run at (783,0) width 1: " "
    2323          text run at (0,18) width 755: "paragraph separator doesn't split the body (inserting a paragraph separator usually splits/clones the enclosing block flow "
    2424          text run at (0,36) width 58: "element)."
  • trunk/LayoutTests/editing/pasteboard/4989774-expected.checksum

    r20963 r21212  
    1 6c03d26dbbfba19f07b9a4e4a1c322d0
     1be6fd52ad002752178c046831f449f1c
  • trunk/LayoutTests/editing/pasteboard/4989774-expected.txt

    r19648 r21212  
    88      RenderImage {IMG} at (152,0) size 76x103
    99      RenderBR {BR} at (228,103) size 0x0
    10       RenderText {#text} at (0,103) size 784x36
    11         text run at (0,103) width 629: "This tests for a bug where an images pasted on the same line would appear on different lines. "
    12         text run at (629,103) width 153: "You should see several"
    13         text run at (782,103) width 2: " "
    14         text run at (0,121) width 307: "pictures above all in the same line/paragraph."
     10      RenderText {#text} at (0,103) size 739x36
     11        text run at (0,103) width 739: "This tests for a bug where an images pasted on the same line would appear on different lines.  You should see "
     12        text run at (0,121) width 358: "several pictures above all in the same line/paragraph."
    1513      RenderText {#text} at (0,0) size 0x0
    1614      RenderText {#text} at (0,0) size 0x0
  • trunk/LayoutTests/editing/selection/4983858-expected.checksum

    r20275 r21212  
    1 27a07777535624367be11a3a86abf096
     128b7b7fc983f2d802da039a49859f928
  • trunk/LayoutTests/editing/selection/4983858-expected.txt

    r19542 r21212  
    55    RenderBody {BODY} at (8,8) size 784x584
    66      RenderBlock (anonymous) at (0,0) size 784x36
    7         RenderText {#text} at (0,0) size 772x36
    8           text run at (0,0) width 570: "This tests for a bug where selecting a word would select the line break and word before it. "
    9           text run at (570,0) width 135: "Only the word in the "
    10           text run at (705,0) width 67: "paragraph "
     7        RenderText {#text} at (0,0) size 780x36
     8          text run at (0,0) width 780: "This tests for a bug where selecting a word would select the line break and word before it.  Only the word in the  paragraph "
    119          text run at (0,18) width 162: "below should be selected:"
    1210      RenderBlock {DIV} at (0,36) size 784x18
  • trunk/WebCore/ChangeLog

    r21211 r21212  
     12007-05-01  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by darin
     4
     5        <rdar://problem/5002441>
     6        Pressing space key does nothing above quoted content or a signature
     7       
     8        Inserting a space under these circumstances inserts a single
     9        text node containing a regular space and then does a layout.
     10        That space isn't rendered (which is correct).  Whitespace
     11        rebalancing is supposed to correct it but failed.  It replaces
     12        the space with a non-breaking space, but that change doesn't
     13        dirty line boxes (9441) and so the space isn't rendered.
     14       
     15        This workaround turns all incoming spaces into non-breaking
     16        spaces before they're inserted (they're rebalanced after
     17        insertion and turned back into regular spaces if possible).
     18
     19        * editing/InsertTextCommand.cpp:
     20        (WebCore::InsertTextCommand::prepareForTextInsertion): Removed
     21        an old irrelevant FIXME.
     22        (WebCore::InsertTextCommand::input): Turn incoming spaces into
     23        non breaking spaces before inserting them.
     24       
    1252007-05-01  Darin Adler  <darin@apple.com>
    226
  • trunk/WebCore/editing/InsertTextCommand.cpp

    r20960 r21212  
    2727#include "InsertTextCommand.h"
    2828
     29#include "CharacterNames.h"
    2930#include "CSSMutableStyleDeclaration.h"
    3031#include "CSSComputedStyleDeclaration.h"
     
    6465    // Prepare for text input by looking at the specified position.
    6566    // It may be necessary to insert a text node to receive characters.
    66     // FIXME: What is the rootEditable() check about?  Seems like it
    67     // assumes that the content before (or after) pos.node() is editable
    68     // (i.e. pos is at an editable/non-editable boundary).  That seems
    69     // like a bad assumption.
    7067    if (!pos.node()->isTextNode()) {
    7168        RefPtr<Node> textNode = document()->createEditingTextNode("");
    72 
    7369        insertNodeAt(textNode.get(), pos);
    74        
    7570        return Position(textNode.get(), 0);
    7671    }
     
    8580}
    8681
    87 void InsertTextCommand::input(const String &text, bool selectInsertedText)
     82void InsertTextCommand::input(const String& originalText, bool selectInsertedText)
    8883{
     84    String text = originalText;
     85   
    8986    ASSERT(text.find('\n') == -1);
    9087
    9188    if (endingSelection().isNone())
    9289        return;
     90       
     91    if (RenderObject* renderer = endingSelection().start().node()->renderer())
     92        if (renderer->style()->collapseWhiteSpace())
     93            // Turn all spaces into non breaking spaces, to make sure that they are treated
     94            // literally, and aren't collapsed after insertion. They will be rebalanced
     95            // (turned into a sequence of regular and non breaking spaces) below.
     96            text.replace(' ', noBreakSpace);
    9397   
    9498    // Delete the current selection.
     
    128132        rebalanceWhitespaceAt(endPosition);
    129133        // Rebalancing on both sides isn't necessary if we've inserted a space.
    130         if (text != " ")
     134        if (originalText != " ")
    131135            rebalanceWhitespaceAt(startPosition);
    132136           
Note: See TracChangeset for help on using the changeset viewer.