Title: [102120] trunk/Source/WebCore
Revision
102120
Author
[email protected]
Date
2011-12-06 03:38:16 -0800 (Tue, 06 Dec 2011)

Log Message

Unreviewed, rolling out r102111.
http://trac.webkit.org/changeset/102111
https://bugs.webkit.org/show_bug.cgi?id=73902

Breaks compilation (Requested by vsevik on #webkit).

Patch by Sheriff Bot <[email protected]> on 2011-12-06

* editing/Editor.cpp:
(WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
* editing/Editor.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (102119 => 102120)


--- trunk/Source/WebCore/ChangeLog	2011-12-06 11:30:45 UTC (rev 102119)
+++ trunk/Source/WebCore/ChangeLog	2011-12-06 11:38:16 UTC (rev 102120)
@@ -1,3 +1,15 @@
+2011-12-06  Sheriff Bot  <[email protected]>
+
+        Unreviewed, rolling out r102111.
+        http://trac.webkit.org/changeset/102111
+        https://bugs.webkit.org/show_bug.cgi?id=73902
+
+        Breaks compilation (Requested by vsevik on #webkit).
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
+        * editing/Editor.h:
+
 2011-12-06  Hajime Morrita  <[email protected]>
 
         [Refactoring] Accessing Node::m_document should be minimized.

Modified: trunk/Source/WebCore/editing/Editor.cpp (102119 => 102120)


--- trunk/Source/WebCore/editing/Editor.cpp	2011-12-06 11:30:45 UTC (rev 102119)
+++ trunk/Source/WebCore/editing/Editor.cpp	2011-12-06 11:38:16 UTC (rev 102120)
@@ -1994,10 +1994,14 @@
     // There shouldn't be pending autocorrection at this moment.
     ASSERT(!m_spellingCorrector->hasPendingCorrection());
 
+    bool shouldMarkSpelling = textCheckingOptions & TextCheckingTypeSpelling;
     bool shouldMarkGrammar = textCheckingOptions & TextCheckingTypeGrammar;
+    bool shouldPerformReplacement = textCheckingOptions & TextCheckingTypeReplacement;
     bool shouldShowCorrectionPanel = textCheckingOptions & TextCheckingTypeShowCorrectionPanel;
+    bool shouldCheckForCorrection = shouldShowCorrectionPanel || (textCheckingOptions & TextCheckingTypeCorrection);
 
     // This function is called with selections already expanded to word boundaries.
+    ExceptionCode ec = 0;
     if (!client() || !spellingRange || (shouldMarkGrammar && !grammarRange))
         return;
 
@@ -2009,12 +2013,36 @@
     if (!isSpellCheckingEnabledFor(editableNode))
         return;
 
+    // Expand the range to encompass entire paragraphs, since text checking needs that much context.
+    int selectionOffset = 0;
+    int ambiguousBoundaryOffset = -1;
+    bool selectionChanged = false;
+    bool restoreSelectionAfterChange = false;
+    bool adjustSelectionForParagraphBoundaries = false;
+
     TextCheckingParagraph spellingParagraph(spellingRange);
     TextCheckingParagraph grammarParagraph(shouldMarkGrammar ? grammarRange : 0);
 
     if (shouldMarkGrammar ? (spellingParagraph.isRangeEmpty() && grammarParagraph.isEmpty()) : spellingParagraph.isEmpty())
         return;
 
+    if (shouldPerformReplacement || shouldMarkSpelling || shouldCheckForCorrection) {
+        if (m_frame->selection()->selectionType() == VisibleSelection::CaretSelection) {
+            // Attempt to save the caret position so we can restore it later if needed
+            Position caretPosition = m_frame->selection()->end();
+            int offset = spellingParagraph.offsetTo(caretPosition, ec);
+            if (!ec) {
+                selectionOffset = offset;
+                restoreSelectionAfterChange = true;
+                if (selectionOffset > 0 && (selectionOffset > spellingParagraph.textLength() || spellingParagraph.textCharAt(selectionOffset - 1) == newlineCharacter))
+                    adjustSelectionForParagraphBoundaries = true;
+                if (selectionOffset > 0 && selectionOffset <= spellingParagraph.textLength() && isAmbiguousBoundaryCharacter(spellingParagraph.textCharAt(selectionOffset - 1)))
+                    ambiguousBoundaryOffset = selectionOffset - 1;
+            }
+        }
+    }
+
+
     bool asynchronous = m_frame && m_frame->settings() && m_frame->settings()->asynchronousSpellCheckingEnabled() && !shouldShowCorrectionPanel;
     if (asynchronous) {
         if (shouldMarkGrammar)
@@ -2031,38 +2059,8 @@
     else
         checkTextOfParagraph(textChecker(), spellingParagraph.textCharacters(), spellingParagraph.textLength(), 
                                             resolveTextCheckingTypeMask(textCheckingOptions), results);
+        
 
-    markAndReplaceFor(textCheckingOptions, results, spellingParagraph, grammarParagraph);
-}
-
-void Editor::markAndReplaceFor(TextCheckingTypeMask textCheckingOptions, const Vector<TextCheckingResult>& results, const TextCheckingParagraph& spellingParagraph, const TextCheckingParagraph& grammarParagraph)
-{
-    bool shouldMarkSpelling = textCheckingOptions & TextCheckingTypeSpelling;
-    bool shouldMarkGrammar = textCheckingOptions & TextCheckingTypeGrammar;
-    bool shouldPerformReplacement = textCheckingOptions & TextCheckingTypeReplacement;
-    bool shouldShowCorrectionPanel = textCheckingOptions & TextCheckingTypeShowCorrectionPanel;
-    bool shouldCheckForCorrection = shouldShowCorrectionPanel || (textCheckingOptions & TextCheckingTypeCorrection);
-
-    // Expand the range to encompass entire paragraphs, since text checking needs that much context.
-    int selectionOffset = 0;
-    int ambiguousBoundaryOffset = -1;
-    bool selectionChanged = false;
-    bool restoreSelectionAfterChange = false;
-    bool adjustSelectionForParagraphBoundaries = false;
-
-    if (shouldPerformReplacement || shouldMarkSpelling || shouldCheckForCorrection) {
-        if (m_frame->selection()->selectionType() == VisibleSelection::CaretSelection) {
-            // Attempt to save the caret position so we can restore it later if needed
-            Position caretPosition = m_frame->selection()->end();
-            selectionOffset = spellingParagraph.offsetTo(caretPosition, ASSERT_NO_EXCEPTION);
-            restoreSelectionAfterChange = true;
-            if (selectionOffset > 0 && (selectionOffset > spellingParagraph.textLength() || spellingParagraph.textCharAt(selectionOffset - 1) == newlineCharacter))
-                adjustSelectionForParagraphBoundaries = true;
-            if (selectionOffset > 0 && selectionOffset <= spellingParagraph.textLength() && isAmbiguousBoundaryCharacter(spellingParagraph.textCharAt(selectionOffset - 1)))
-                ambiguousBoundaryOffset = selectionOffset - 1;
-        }
-    }
-
     // If this checking is only for showing correction panel, we shouldn't bother to mark misspellings.
     if (shouldShowCorrectionPanel)
         shouldMarkSpelling = false;
@@ -2086,7 +2084,7 @@
             RefPtr<Range> misspellingRange = spellingParagraph.subrange(resultLocation, resultLength);
             if (!m_spellingCorrector->isSpellingMarkerAllowed(misspellingRange))
                 continue;
-            misspellingRange->startContainer()->document()->markers()->addMarker(misspellingRange.get(), DocumentMarker::Spelling);
+            misspellingRange->startContainer(ec)->document()->markers()->addMarker(misspellingRange.get(), DocumentMarker::Spelling);
         } else if (shouldMarkGrammar && result->type == TextCheckingTypeGrammar && grammarParagraph.checkingRangeCovers(resultLocation, resultLength)) {
             ASSERT(resultLength > 0 && resultLocation >= 0);
             for (unsigned j = 0; j < result->details.size(); j++) {
@@ -2094,7 +2092,7 @@
                 ASSERT(detail->length > 0 && detail->location >= 0);
                 if (grammarParagraph.checkingRangeCovers(resultLocation + detail->location, detail->length)) {
                     RefPtr<Range> badGrammarRange = grammarParagraph.subrange(resultLocation + detail->location, detail->length);
-                    badGrammarRange->startContainer()->document()->markers()->addMarker(badGrammarRange.get(), DocumentMarker::Grammar, detail->userDescription);
+                    grammarRange->startContainer(ec)->document()->markers()->addMarker(badGrammarRange.get(), DocumentMarker::Grammar, detail->userDescription);
                 }
             }
         } else if (resultLocation + resultLength <= spellingRangeEndOffset && resultLocation + resultLength >= spellingParagraph.checkingStart()
@@ -2180,11 +2178,10 @@
     }
 
     if (selectionChanged) {
-        TextCheckingParagraph extendedParagraph(spellingParagraph);
         // Restore the caret position if we have made any replacements
-        extendedParagraph.expandRangeToNextEnd();
-        if (restoreSelectionAfterChange && selectionOffset >= 0 && selectionOffset <= extendedParagraph.rangeLength()) {
-            RefPtr<Range> selectionRange = extendedParagraph.subrange(0, selectionOffset);
+        spellingParagraph.expandRangeToNextEnd();
+        if (restoreSelectionAfterChange && selectionOffset >= 0 && selectionOffset <= spellingParagraph.rangeLength()) {
+            RefPtr<Range> selectionRange = spellingParagraph.subrange(0, selectionOffset);
             m_frame->selection()->moveTo(selectionRange->endPosition(), DOWNSTREAM);
             if (adjustSelectionForParagraphBoundaries)
                 m_frame->selection()->modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity);

Modified: trunk/Source/WebCore/editing/Editor.h (102119 => 102120)


--- trunk/Source/WebCore/editing/Editor.h	2011-12-06 11:30:45 UTC (rev 102119)
+++ trunk/Source/WebCore/editing/Editor.h	2011-12-06 11:38:16 UTC (rev 102120)
@@ -62,8 +62,6 @@
 class SpellChecker;
 class Text;
 class TextCheckerClient;
-class TextCheckingParagraph;
-class TextCheckingResult;
 class TextEvent;
 
 struct CompositionUnderline {
@@ -405,7 +403,6 @@
     void writeSelectionToPasteboard(Pasteboard*);
     void revealSelectionAfterEditingOperation();
     void markMisspellingsOrBadGrammar(const VisibleSelection&, bool checkSpelling, RefPtr<Range>& firstMisspellingRange);
-    void markAndReplaceFor(TextCheckingTypeMask, const Vector<TextCheckingResult>&, const TextCheckingParagraph& spellingParagraph, const TextCheckingParagraph& grammarParagraph);
     TextCheckingTypeMask resolveTextCheckingTypeMask(TextCheckingTypeMask);
 
     void selectComposition();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to