Changeset 87008 in webkit


Ignore:
Timestamp:
May 20, 2011 6:15:40 PM (13 years ago)
Author:
ap@apple.com
Message:

2011-05-20 Alexey Proskuryakov <ap@apple.com>

Reviewed by Kent Tamura.

Special characters can be inserted in text field having reached maxlength
https://bugs.webkit.org/show_bug.cgi?id=19479
<rdar://problem/7828739>

  • platform/mac/editing/input/maxlength-expected.txt: Added.
  • platform/mac/editing/input/maxlength.html: Added.
  • fast/forms/input-number-commit-valid-only-expected.txt:
  • fast/forms/script-tests/input-number-commit-valid-only.js: The user can make a number field empty by deleting its content, so there is no reason why execCommand shouldn't be able to make it empty.

2011-05-20 Alexey Proskuryakov <ap@apple.com>

Reviewed by Kent Tamura.

Special characters can be inserted in text field having reached maxlength
https://bugs.webkit.org/show_bug.cgi?id=19479
<rdar://problem/7828739>

Test: platform/mac/editing/input/maxlength.html

  • editing/CompositeEditCommand.cpp: (WebCore::CompositeEditCommand::insertTextIntoNode): (WebCore::CompositeEditCommand::replaceTextInNode): Avoid hitting an assertion below, now that we can get here with empty text.
  • editing/TypingCommand.cpp: (WebCore::TypingCommand::insertText): There is still work to do even if beforetextinput removed all text from the event. At the very least, we should delete the current selection.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r87007 r87008  
     12011-05-20  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Reviewed by Kent Tamura.
     4
     5        Special characters can be inserted in text field having reached maxlength
     6        https://bugs.webkit.org/show_bug.cgi?id=19479
     7        <rdar://problem/7828739>
     8
     9        * platform/mac/editing/input/maxlength-expected.txt: Added.
     10        * platform/mac/editing/input/maxlength.html: Added.
     11
     12        * fast/forms/input-number-commit-valid-only-expected.txt:
     13        * fast/forms/script-tests/input-number-commit-valid-only.js:
     14        The user can make a number field empty by deleting its content, so there is no reason why
     15        execCommand shouldn't be able to make it empty.
     16
    1172011-05-20  Andy Estes  <aestes@apple.com>
    218
  • trunk/LayoutTests/fast/forms/input-number-commit-valid-only-expected.txt

    r67164 r87008  
    66PASS input.value is "512"
    77PASS input.value is "512"
    8 PASS input.value is "512"
     8PASS input.value is ""
    99PASS successfullyParsed is true
    1010
  • trunk/LayoutTests/fast/forms/script-tests/input-number-commit-valid-only.js

    r67164 r87008  
    2020document.execCommand('InsertText', false, '');
    2121input.blur();
    22 shouldBe('input.value', '"512"');
     22shouldBe('input.value', '""');
    2323
    2424var successfullyParsed = true;
  • trunk/Source/WebCore/ChangeLog

    r87007 r87008  
     12011-05-20  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Reviewed by Kent Tamura.
     4
     5        Special characters can be inserted in text field having reached maxlength
     6        https://bugs.webkit.org/show_bug.cgi?id=19479
     7        <rdar://problem/7828739>
     8
     9        Test: platform/mac/editing/input/maxlength.html
     10
     11        * editing/CompositeEditCommand.cpp:
     12        (WebCore::CompositeEditCommand::insertTextIntoNode):
     13        (WebCore::CompositeEditCommand::replaceTextInNode):
     14        Avoid hitting an assertion below, now that we can get here with empty text.
     15
     16        * editing/TypingCommand.cpp: (WebCore::TypingCommand::insertText): There is still work to do
     17        even if beforetextinput removed all text from the event. At the very least, we should delete
     18        the current selection.
     19
    1202011-05-20  Andy Estes  <aestes@apple.com>
    221
  • trunk/Source/WebCore/editing/CompositeEditCommand.cpp

    r86854 r87008  
    322322void CompositeEditCommand::insertTextIntoNode(PassRefPtr<Text> node, unsigned offset, const String& text)
    323323{
    324     applyCommandToComposite(InsertIntoTextNodeCommand::create(node, offset, text));
     324    if (!text.isEmpty())
     325        applyCommandToComposite(InsertIntoTextNodeCommand::create(node, offset, text));
    325326}
    326327
     
    333334{
    334335    applyCommandToComposite(DeleteFromTextNodeCommand::create(node.get(), offset, count));
    335     applyCommandToComposite(InsertIntoTextNodeCommand::create(node, offset, replacementText));
     336    if (!replacementText.isEmpty())
     337        applyCommandToComposite(InsertIntoTextNodeCommand::create(node, offset, replacementText));
    336338}
    337339
  • trunk/Source/WebCore/editing/TypingCommand.cpp

    r85864 r87008  
    183183    }
    184184   
    185     if (newText.isEmpty())
    186         return;
    187    
    188185    // Set the starting and ending selection appropriately if we are using a selection
    189186    // that is different from the current selection.  In the future, we should change EditCommand
Note: See TracChangeset for help on using the changeset viewer.