Diff
Modified: trunk/LayoutTests/ChangeLog (148305 => 148306)
--- trunk/LayoutTests/ChangeLog 2013-04-12 22:04:38 UTC (rev 148305)
+++ trunk/LayoutTests/ChangeLog 2013-04-12 22:46:01 UTC (rev 148306)
@@ -1,3 +1,16 @@
+2013-04-12 Ryosuke Niwa <rn...@webkit.org>
+
+ [Mac] REGRESSION: Auto substitution strips new lines
+ https://bugs.webkit.org/show_bug.cgi?id=114537
+
+ Reviewed by Enrica Casucci.
+
+ 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.
+
2013-04-12 Commit Queue <rn...@webkit.org>
Unreviewed, rolling out r147942, r148026, and r148092.
Added: trunk/LayoutTests/platform/mac/editing/spelling/autocorrection-with-multi-line-text-expected.txt (0 => 148306)
--- trunk/LayoutTests/platform/mac/editing/spelling/autocorrection-with-multi-line-text-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac/editing/spelling/autocorrection-with-multi-line-text-expected.txt 2013-04-12 22:46:01 UTC (rev 148306)
@@ -0,0 +1,10 @@
+This tests auto-substitution with a multi-line text works.
+To manually test, open Language & Text system preference and setup "helloleworld" to be replaced by
+"helloworld" (copy paste it) and reload this page. You should see hello and world in two distinct lines.
+| "hello"
+| <div>
+| "world"
+| <br>
+| <div>
+| <#selection-caret>
+| <br>
Added: trunk/LayoutTests/platform/mac/editing/spelling/autocorrection-with-multi-line-text.html (0 => 148306)
--- trunk/LayoutTests/platform/mac/editing/spelling/autocorrection-with-multi-line-text.html (rev 0)
+++ trunk/LayoutTests/platform/mac/editing/spelling/autocorrection-with-multi-line-text.html 2013-04-12 22:46:01 UTC (rev 148306)
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p id="description">This tests auto-substitution with a multi-line text works.
+To manually test, open Language & Text system preference and setup "helloleworld" to be replaced by
+"hello<br>world" (copy paste it) and reload this page. You should see hello and world in two distinct lines.</p>
+<div id="editor" contenteditable></div>
+<script src=""
+<script>
+
+var editor = document.getElementById('editor');
+document.getElementById('description');
+editor.focus();
+document.execCommand('InsertText', false, 'h');
+document.execCommand('InsertText', false, 'e');
+document.execCommand('InsertText', false, 'l');
+document.execCommand('InsertText', false, 'l');
+document.execCommand('InsertText', false, 'o');
+document.execCommand('InsertText', false, 'l');
+document.execCommand('InsertText', false, 'f');
+document.execCommand('InsertText', false, 'w');
+document.execCommand('InsertText', false, 'o');
+document.execCommand('InsertText', false, 'r');
+document.execCommand('InsertText', false, 'l');
+document.execCommand('InsertText', false, 'd');
+document.execCommand('InsertParagraph');
+
+Markup.description(document.getElementById('description').textContent);
+Markup.dump('editor');
+
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (148305 => 148306)
--- trunk/Source/WebCore/ChangeLog 2013-04-12 22:04:38 UTC (rev 148305)
+++ trunk/Source/WebCore/ChangeLog 2013-04-12 22:46:01 UTC (rev 148306)
@@ -1,3 +1,35 @@
+2013-04-12 Ryosuke Niwa <rn...@webkit.org>
+
+ [Mac] REGRESSION: Auto substitution strips new lines
+ https://bugs.webkit.org/show_bug.cgi?id=114537
+
+ Reviewed by Enrica Casucci.
+
+ 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):
+
2013-04-12 Brendan Long <b.l...@cablelabs.com>
Refactor TextTrack and TextTrackList to make it easier to add audio and video tracks
Modified: trunk/Source/WebCore/editing/CompositeEditCommand.cpp (148305 => 148306)
--- trunk/Source/WebCore/editing/CompositeEditCommand.cpp 2013-04-12 22:04:38 UTC (rev 148305)
+++ trunk/Source/WebCore/editing/CompositeEditCommand.cpp 2013-04-12 22:46:01 UTC (rev 148306)
@@ -216,7 +216,7 @@
// Only need to call appliedEditing for top-level commands,
// and TypingCommands do it on their own (see TypingCommand::typingAddedToOpenCommand).
- if (!isTypingCommand())
+ if (!callsAppliedEditingInDoApply())
frame->editor()->appliedEditing(this);
setShouldRetainAutocorrectionIndicator(false);
}
@@ -246,6 +246,11 @@
return false;
}
+bool CompositeEditCommand::callsAppliedEditingInDoApply() const
+{
+ return false;
+}
+
bool CompositeEditCommand::shouldRetainAutocorrectionIndicator() const
{
return false;
Modified: trunk/Source/WebCore/editing/CompositeEditCommand.h (148305 => 148306)
--- trunk/Source/WebCore/editing/CompositeEditCommand.h 2013-04-12 22:04:38 UTC (rev 148305)
+++ trunk/Source/WebCore/editing/CompositeEditCommand.h 2013-04-12 22:46:01 UTC (rev 148306)
@@ -82,6 +82,7 @@
virtual bool isCreateLinkCommand() const;
virtual bool isTypingCommand() const;
+ virtual bool callsAppliedEditingInDoApply() const;
virtual bool isDictationCommand() const { return false; }
virtual bool preservesTypingStyle() const;
virtual bool shouldRetainAutocorrectionIndicator() const;
Modified: trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp (148305 => 148306)
--- trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp 2013-04-12 22:04:38 UTC (rev 148305)
+++ trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp 2013-04-12 22:46:01 UTC (rev 148306)
@@ -30,9 +30,9 @@
#include "Document.h"
#include "DocumentFragment.h"
#include "Frame.h"
-#include "InsertTextCommand.h"
#include "SetSelectionCommand.h"
#include "TextIterator.h"
+#include "TypingCommand.h"
#include "markup.h"
namespace WebCore {
@@ -101,7 +101,7 @@
#if USE(AUTOCORRECTION_PANEL)
applyCommandToComposite(SpellingCorrectionRecordUndoCommand::create(document(), m_corrected, m_correction));
#endif
- applyCommandToComposite(InsertTextCommand::create(document(), m_correction));
+ TypingCommand::insertText(document(), m_correction, TypingCommand::PreventSpellChecking);
}
bool SpellingCorrectionCommand::shouldRetainAutocorrectionIndicator() const
@@ -109,4 +109,9 @@
return true;
}
+bool SpellingCorrectionCommand::callsAppliedEditingInDoApply() const
+{
+ return true;
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/editing/SpellingCorrectionCommand.h (148305 => 148306)
--- trunk/Source/WebCore/editing/SpellingCorrectionCommand.h 2013-04-12 22:04:38 UTC (rev 148305)
+++ trunk/Source/WebCore/editing/SpellingCorrectionCommand.h 2013-04-12 22:46:01 UTC (rev 148306)
@@ -41,6 +41,7 @@
SpellingCorrectionCommand(PassRefPtr<Range> rangeToBeCorrected, const String& correction);
virtual void doApply();
virtual bool shouldRetainAutocorrectionIndicator() const;
+ virtual bool callsAppliedEditingInDoApply() const;
RefPtr<Range> m_rangeToBeCorrected;
VisibleSelection m_selectionToBeCorrected;
Modified: trunk/Source/WebCore/editing/TypingCommand.cpp (148305 => 148306)
--- trunk/Source/WebCore/editing/TypingCommand.cpp 2013-04-12 22:04:38 UTC (rev 148305)
+++ trunk/Source/WebCore/editing/TypingCommand.cpp 2013-04-12 22:46:01 UTC (rev 148306)
@@ -645,4 +645,9 @@
return true;
}
+bool TypingCommand::callsAppliedEditingInDoApply() const
+{
+ return true;
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/editing/TypingCommand.h (148305 => 148306)
--- trunk/Source/WebCore/editing/TypingCommand.h 2013-04-12 22:04:38 UTC (rev 148305)
+++ trunk/Source/WebCore/editing/TypingCommand.h 2013-04-12 22:46:01 UTC (rev 148306)
@@ -100,6 +100,7 @@
virtual void doApply();
virtual EditAction editingAction() const;
virtual bool isTypingCommand() const;
+ virtual bool callsAppliedEditingInDoApply() const;
virtual bool preservesTypingStyle() const { return m_preservesTypingStyle; }
virtual bool shouldRetainAutocorrectionIndicator() const
{
Modified: trunk/Tools/ChangeLog (148305 => 148306)
--- trunk/Tools/ChangeLog 2013-04-12 22:04:38 UTC (rev 148305)
+++ trunk/Tools/ChangeLog 2013-04-12 22:46:01 UTC (rev 148306)
@@ -1,3 +1,15 @@
+2013-04-12 Ryosuke Niwa <rn...@webkit.org>
+
+ [Mac] REGRESSION: Auto substitution strips new lines
+ https://bugs.webkit.org/show_bug.cgi?id=114537
+
+ Reviewed by Enrica Casucci.
+
+ Add a rule to replace "helloleworld" by "hello\nworld" for testing purpose.
+
+ * DumpRenderTree/mac/DumpRenderTree.mm:
+ (resetDefaultsToConsistentValues):
+
2013-04-09 Roger Fong <roger_f...@apple.com>
Re-enable WinEWS tests.
Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (148305 => 148306)
--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2013-04-12 22:04:38 UTC (rev 148305)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2013-04-12 22:46:01 UTC (rev 148306)
@@ -606,7 +606,7 @@
@"message", @"mesage",
@"would", @"wouldn",
@"welcome", @"wellcome",
- @"uppercase", @"upper case",
+ @"hello\nworld", @"hellolfworld",
nil] forKey:@"NSTestCorrectionDictionary"];
#endif