Title: [122176] trunk
Revision
122176
Author
[email protected]
Date
2012-07-09 18:25:09 -0700 (Mon, 09 Jul 2012)

Log Message

Editing: Autocorrection in blockquotes causes text to break out of quote
https://bugs.webkit.org/show_bug.cgi?id=90487
<rdar://problem/11769020>

Patch by Alice Cheng <[email protected]> on 2012-07-09
Reviewed by Enrica Casucci.

Source/WebCore:

Test: platform/mac/editing/spelling/autocorrection-blockquote-crash.html

SpellingCorrectionCommand uses ReplaceSelectionCommand to replace the misspelled word with the auto-corrected word. Specifically, ReplaceSelectionCommand does a smart copy, where it breaks out of blockquotes. Thus, the fix is to substitute ReplaceSelectionCommand with InserTextCommand.

* editing/SpellingCorrectionCommand.cpp:
(WebCore::SpellingCorrectionCommand::doApply):

LayoutTests:

* platform/mac/editing/spelling/autocorrection-blockquote-crash-expected.txt:
* platform/mac/editing/spelling/autocorrection-blockquote-crash.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (122175 => 122176)


--- trunk/LayoutTests/ChangeLog	2012-07-10 01:06:52 UTC (rev 122175)
+++ trunk/LayoutTests/ChangeLog	2012-07-10 01:25:09 UTC (rev 122176)
@@ -1,3 +1,14 @@
+2012-07-09  Alice Cheng  <[email protected]>
+
+        Editing: Autocorrection in blockquotes causes text to break out of quote
+        https://bugs.webkit.org/show_bug.cgi?id=90487
+        <rdar://problem/11769020> 
+
+        Reviewed by Enrica Casucci.
+
+        * platform/mac/editing/spelling/autocorrection-blockquote-crash-expected.txt:
+        * platform/mac/editing/spelling/autocorrection-blockquote-crash.html:
+
 2012-07-09  Yongjun Zhang  <[email protected]>
 
         Consider closing unused localStorage database after a timeout.

Modified: trunk/LayoutTests/platform/mac/editing/spelling/autocorrection-blockquote-crash-expected.txt (122175 => 122176)


--- trunk/LayoutTests/platform/mac/editing/spelling/autocorrection-blockquote-crash-expected.txt	2012-07-10 01:06:52 UTC (rev 122175)
+++ trunk/LayoutTests/platform/mac/editing/spelling/autocorrection-blockquote-crash-expected.txt	2012-07-10 01:25:09 UTC (rev 122176)
@@ -1,13 +1,13 @@
-This test checks that markers are correct when auto correcting in the blockquote. If you type "n" and " ", there should be blue dots under information, but is off by one. 
-Note, this test can fail due to user specific spell checking data. If the user has previously dismissed 'notational' as the correct spelling of 'notationl' several times, the spell checker will not provide 'information' as a suggestion anymore. To fix this, remove all files in ~/Library/Spelling.
+This test checks that markers are correct when auto correcting in the blockquote. If you type "n" and " ", there should be blue dots under the word: "information". This test also makes sure that the replacement does not cause breaking out of blockquotes. 
+Note, this test can fail due to user specific spell checking data. If the user has previously dismissed 'information' as the correct spelling of 'infomation' several times, the spell checker will not provide 'information' as a suggestion anymore. To fix this, remove all files in ~/Library/Spelling. and kill AppleSpell.service
 
-PASS internals.hasAutocorrectedMarker(document, 0, 1) is true
+PASS internals.hasAutocorrectedMarker(document, 5, 11) is true
 PASS successfullyParsed is true
 
 TEST COMPLETE
 
 would this 
-testinformation 
+test information 
 make a difference?
 
 

Modified: trunk/LayoutTests/platform/mac/editing/spelling/autocorrection-blockquote-crash.html (122175 => 122176)


--- trunk/LayoutTests/platform/mac/editing/spelling/autocorrection-blockquote-crash.html	2012-07-10 01:06:52 UTC (rev 122175)
+++ trunk/LayoutTests/platform/mac/editing/spelling/autocorrection-blockquote-crash.html	2012-07-10 01:25:09 UTC (rev 122176)
@@ -4,7 +4,7 @@
     <script src=""
 </head>
 <body>
-<p id="description">This test checks that markers are correct when auto correcting in the blockquote. If you type "n" and " ", there should be blue dots under information, but is off by one. <br> Note, this test can fail due to user specific spell checking data. If the user has previously dismissed 'notational' as the correct spelling of 'notationl' several times, the spell checker will not provide 'information' as a suggestion anymore. To fix this, remove all files in ~/Library/Spelling.</p>
+    <p id="description">This test checks that markers are correct when auto correcting in the blockquote. If you type "n" and " ", there should be blue dots under the word: "information". This test also makes sure that the replacement does not cause breaking out of blockquotes. <br> Note, this test can fail due to user specific spell checking data. If the user has previously dismissed 'information' as the correct spelling of 'infomation' several times, the spell checker will not provide 'information' as a suggestion anymore. To fix this, remove all files in ~/Library/Spelling. and kill AppleSpell.service</p>
 <div id="console"></div>
 
 <div id = "test" contentEditable="true" spellCheck="true"><blockquote type="cite"><font style = "font-family:Arial"><br> would this <b id = "bold"><br></b><b><br></b>make a difference?<span><br></span><span><br></span></font></blockquote></div>
@@ -17,7 +17,7 @@
     eventSender.keyDown(' ');
     
     if(window.internals)
-        shouldBeTrue('internals.hasAutocorrectedMarker(document, 0, 1)');
+        shouldBeTrue('internals.hasAutocorrectedMarker(document, 5, 11)');
 </script>
 <script src=""
 </body>

Modified: trunk/Source/WebCore/ChangeLog (122175 => 122176)


--- trunk/Source/WebCore/ChangeLog	2012-07-10 01:06:52 UTC (rev 122175)
+++ trunk/Source/WebCore/ChangeLog	2012-07-10 01:25:09 UTC (rev 122176)
@@ -1,3 +1,18 @@
+2012-07-09  Alice Cheng  <[email protected]>
+
+        Editing: Autocorrection in blockquotes causes text to break out of quote
+        https://bugs.webkit.org/show_bug.cgi?id=90487
+        <rdar://problem/11769020> 
+
+        Reviewed by Enrica Casucci.
+
+        Test: platform/mac/editing/spelling/autocorrection-blockquote-crash.html
+
+        SpellingCorrectionCommand uses ReplaceSelectionCommand to replace the misspelled word with the auto-corrected word. Specifically, ReplaceSelectionCommand does a smart copy, where it breaks out of blockquotes. Thus, the fix is to substitute ReplaceSelectionCommand with InserTextCommand.
+
+        * editing/SpellingCorrectionCommand.cpp:
+        (WebCore::SpellingCorrectionCommand::doApply):
+
 2012-07-09  No'am Rosenthal  <[email protected]>
 
         Shared code that is guarded with ENABLE(WEBGL) should be guarded with USE()

Modified: trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp (122175 => 122176)


--- trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp	2012-07-10 01:06:52 UTC (rev 122175)
+++ trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp	2012-07-10 01:25:09 UTC (rev 122176)
@@ -30,7 +30,7 @@
 #include "Document.h"
 #include "DocumentFragment.h"
 #include "Frame.h"
-#include "ReplaceSelectionCommand.h"
+#include "InsertTextCommand.h"
 #include "SetSelectionCommand.h"
 #include "TextIterator.h"
 #include "markup.h"
@@ -97,15 +97,11 @@
     if (!document()->frame()->selection()->shouldChangeSelection(m_selectionToBeCorrected))
         return;
 
-    RefPtr<DocumentFragment> fragment = createFragmentFromText(m_rangeToBeCorrected.get(), m_correction);
-    if (!fragment)
-        return;
-
     applyCommandToComposite(SetSelectionCommand::create(m_selectionToBeCorrected, FrameSelection::SpellCorrectionTriggered | FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle));
 #if USE(AUTOCORRECTION_PANEL)
     applyCommandToComposite(SpellingCorrectionRecordUndoCommand::create(document(), m_corrected, m_correction));
 #endif
-    applyCommandToComposite(ReplaceSelectionCommand::create(document(), fragment, ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting, EditActionPaste));
+    applyCommandToComposite(InsertTextCommand::create(document(), m_correction));
 }
 
 bool SpellingCorrectionCommand::shouldRetainAutocorrectionIndicator() const
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to