Changeset 81328 in webkit
- Timestamp:
- Mar 16, 2011 11:31:00 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r81324 r81328 1 2011-03-16 Naoki Takano <takano.naoki@gmail.com> 2 3 Reviewed by Ryosuke Niwa. 4 5 Textarea maxlength doesn't account for newlines 6 https://bugs.webkit.org/show_bug.cgi?id=54443 7 8 * fast/forms/script-tests/textarea-maxlength.js: 9 (createFocusedTextAreaWithMaxLength3): Added two tests to make sure consecutive insertbreaks 10 work correctly for textarea maxlength. 11 * fast/forms/textarea-maxlength-expected.txt: Added two test results. 12 1 13 2011-03-16 Alice Liu <alice.liu@apple.com> 2 14 -
trunk/LayoutTests/fast/forms/script-tests/textarea-maxlength.js
r48903 r81328 89 89 shouldBe('textArea.value', '"A\\nB"'); 90 90 91 // Confirms correct count for close linebreaks inputs. 92 createFocusedTextAreaWithMaxLength3(); 93 textArea.innerHTML = 'a\n\n'; 94 document.execCommand('insertLineBreak'); 95 shouldBe('textArea.value', '"a\\n\\n"'); 96 97 // Confirms correct count for open consecutive linebreaks inputs. 98 createFocusedTextAreaWithMaxLength3(); 99 document.execCommand('insertLineBreak'); 100 document.execCommand('insertLineBreak'); 101 document.execCommand('insertLineBreak'); 102 document.execCommand('insertLineBreak'); 103 shouldBe('textArea.value', '"\\n\\n\\n"'); 104 91 105 // According to the HTML5 specification, maxLength is code-point length. 92 106 // However WebKit handles it as grapheme length. -
trunk/LayoutTests/fast/forms/textarea-maxlength-expected.txt
r48903 r81328 22 22 PASS textArea.value is "abcde" 23 23 PASS textArea.value is "A\nB" 24 PASS textArea.value is "a\n\n" 25 PASS textArea.value is "\n\n\n" 24 26 PASS textArea.value is "AB" + fancyX 25 27 PASS textArea.value.length is 5 -
trunk/Source/WebCore/ChangeLog
r81326 r81328 1 2011-03-16 Naoki Takano <takano.naoki@gmail.com> 2 3 Reviewed by Ryosuke Niwa. 4 5 Textarea maxlength doesn't account for newlines 6 https://bugs.webkit.org/show_bug.cgi?id=54443 7 8 When a user presses a return key, TypingCommand::insertLineBreak() is called. 9 So before append a new line, check if we can add the new line. 10 11 * editing/TypingCommand.cpp: 12 (WebCore::canAppendNewLineFeed): Implement new helper function to check if we can add new line. 13 (WebCore::TypingCommand::insertLineBreak): Added check logic before adding the new line. 14 (WebCore::TypingCommand::insertParagraphSeparator): Added check logic before adding the new line. 15 1 16 2011-03-16 Adam Barth <abarth@webkit.org> 2 17 -
trunk/Source/WebCore/editing/TypingCommand.cpp
r81165 r81328 48 48 using namespace HTMLNames; 49 49 50 static bool canAppendNewLineFeed(const VisibleSelection& selection) 51 { 52 ExceptionCode ec = 0; 53 RefPtr<BeforeTextInsertedEvent> event = BeforeTextInsertedEvent::create(String("\n")); 54 selection.rootEditableElement()->dispatchEvent(event, ec); 55 return event->text().length(); 56 } 57 50 58 TypingCommand::TypingCommand(Document *document, ETypingCommand commandType, const String &textToInsert, TypingCommandOptions options, TextGranularity granularity, TextCompositionType compositionType) 51 59 : CompositeEditCommand(document) … … 404 412 void TypingCommand::insertLineBreak() 405 413 { 414 if (!canAppendNewLineFeed(endingSelection())) 415 return; 416 406 417 applyCommandToComposite(InsertLineBreakCommand::create(document())); 407 418 typingAddedToOpenCommand(InsertLineBreak); … … 410 421 void TypingCommand::insertParagraphSeparator() 411 422 { 423 if (!canAppendNewLineFeed(endingSelection())) 424 return; 425 412 426 applyCommandToComposite(InsertParagraphSeparatorCommand::create(document())); 413 427 typingAddedToOpenCommand(InsertParagraphSeparator);
Note: See TracChangeset
for help on using the changeset viewer.