[Mac] REGRESSION: Auto substitution strips new lines
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Apr 2013 22:46:01 +0000 (22:46 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Apr 2013 22:46:01 +0000 (22:46 +0000)
commit0f3b1f28686f0f2f06d66ac316f9d84391d973e0
tree9f8bd8c8f61cb5e378199365124250b58ec9a5d0
parentc672d79d39c23f5b3000d8cddb23ed8f4aaa4f6b
[Mac] REGRESSION: Auto substitution strips new lines
https://bugs.webkit.org/show_bug.cgi?id=114537

Reviewed by Enrica Casucci.

Source/WebCore:

The bug was caused by SpellingCorrectionCommand's use of InsertTextCommand. This command can't insert
new lines and there's even an assertion for it. Use TypingCommand::insertText instead.

Since TypingCommand::insertText calls appliedEditing on its own, we need to avoid calling that again in
CompositeEditCommand::apply after SpellingCorrectionCommand::doApply. Replaced the check in apply to use
callsAppliedEditingInDoApply instead of isTypingCommand, and added callsAppliedEditingInDoApply to both
TypingCommand and SpellingCorrectionCommand to return true (it returns false by default).

Test: platform/mac/editing/spelling/autocorrection-with-multi-line-text.html

* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::apply): Use TypingCommand::insertText instead of InsertTextCommand
(WebCore::CompositeEditCommand::callsAppliedEditingInDoApply): Added. Returns false.
* editing/CompositeEditCommand.h:
(CompositeEditCommand):
* editing/SpellingCorrectionCommand.cpp:
(WebCore::SpellingCorrectionCommand::doApply):
(WebCore::SpellingCorrectionCommand::callsAppliedEditingInDoApply): Added. Returns true.
* editing/SpellingCorrectionCommand.h:
(SpellingCorrectionCommand):
* editing/TypingCommand.cpp:
(WebCore::TypingCommand::callsAppliedEditingInDoApply): Added. Returns true.
* editing/TypingCommand.h:
(TypingCommand):

Tools:

Add a rule to replace "helloleworld" by "hello\nworld" for testing purpose.

* DumpRenderTree/mac/DumpRenderTree.mm:
(resetDefaultsToConsistentValues):

LayoutTests:

Added a regression test. Unfortunately, we can't setup text substituion in DumpRenderTree
so use NSSpellChecker to exercise the relevant code path.

* platform/mac/editing/spelling/autocorrection-with-multi-line-text-expected.txt: Added.
* platform/mac/editing/spelling/autocorrection-with-multi-line-text.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@148306 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/editing/spelling/autocorrection-with-multi-line-text-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/editing/spelling/autocorrection-with-multi-line-text.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/editing/CompositeEditCommand.cpp
Source/WebCore/editing/CompositeEditCommand.h
Source/WebCore/editing/SpellingCorrectionCommand.cpp
Source/WebCore/editing/SpellingCorrectionCommand.h
Source/WebCore/editing/TypingCommand.cpp
Source/WebCore/editing/TypingCommand.h
Tools/ChangeLog
Tools/DumpRenderTree/mac/DumpRenderTree.mm