Reviewed by Brady
authorsullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Oct 2006 03:53:05 +0000 (03:53 +0000)
committersullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Oct 2006 03:53:05 +0000 (03:53 +0000)
        - minor cleanup to make future patches clearer

        * bridge/mac/FrameMac.mm:
        (WebCore::FrameMac::advanceToNextMisspelling):
        renamed misspelling to misspellingNSRange for clarity; changed > 0 test to == 0 test
        with "continue" to better match structure of similar code in markMisspellings; a few
        other style tweaks.

        (WebCore::FrameMac::markMisspellings):
        renamed misspelling to misspellingNSRange for clarity; removed unnecessary braces around
        a block just after a break and outdented accordingly.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@17466 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/bridge/mac/FrameMac.mm

index 9557f5be65e5d8b156110d7a850a8b424bc789e5..0b90d1c63f06c88f158b74a951ca0e273a99c155 100644 (file)
@@ -1,3 +1,19 @@
+2006-10-30  John Sullivan  <sullivan@apple.com>
+
+        Reviewed by Brady
+        
+        - minor cleanup to make future patches clearer
+
+        * bridge/mac/FrameMac.mm:
+        (WebCore::FrameMac::advanceToNextMisspelling):
+        renamed misspelling to misspellingNSRange for clarity; changed > 0 test to == 0 test
+        with "continue" to better match structure of similar code in markMisspellings; a few
+        other style tweaks.
+        
+        (WebCore::FrameMac::markMisspellings):
+        renamed misspelling to misspellingNSRange for clarity; removed unnecessary braces around
+        a block just after a break and outdented accordingly.
+
 2006-10-30  John Sullivan  <sullivan@apple.com>
 
         Reviewed by Geoff Garen
index c8c64cc0795acf949b600596ada47fd488d4bb35..4c8913f3ed9c46f4390c48b0b85677bae262f989 100644 (file)
@@ -635,44 +635,43 @@ void FrameMac::advanceToNextMisspelling(bool startBeforeSelection)
             int len = it.length();
             if (len > 1 || !DeprecatedChar(chars[0]).isSpace()) {
                 NSString *chunk = [[NSString alloc] initWithCharactersNoCopy:const_cast<UChar*>(chars) length:len freeWhenDone:NO];
-                NSRange misspelling = [checker checkSpellingOfString:chunk startingAt:0 language:nil wrap:NO inSpellDocumentWithTag:editor()->client()->spellCheckerDocumentTag() wordCount:NULL];
+                NSRange misspellingNSRange = [checker checkSpellingOfString:chunk startingAt:0 language:nil wrap:NO inSpellDocumentWithTag:editor()->client()->spellCheckerDocumentTag() wordCount:NULL];
                 [chunk release];
-                if (misspelling.length > 0) {
-                    // Build up result range and string.  Note the misspelling may span many text nodes,
-                    // but the CharIterator insulates us from this complexity
-                    RefPtr<Range> misspellingRange(rangeOfContents(document()));
-                    CharacterIterator chars(it.range().get());
-                    chars.advance(misspelling.location);
-                    misspellingRange->setStart(chars.range()->startContainer(exception), chars.range()->startOffset(exception), exception);
-                    DeprecatedString result = chars.string(misspelling.length);
-                    misspellingRange->setEnd(chars.range()->startContainer(exception), chars.range()->startOffset(exception), exception);
-
-                    selectionController()->setSelection(Selection(misspellingRange.get(), DOWNSTREAM));
-                    revealSelection();
-                    // Mark misspelling in document.
-                    document()->addMarker(misspellingRange.get(), DocumentMarker::Spelling);
-                    [checker updateSpellingPanelWithMisspelledWord:result];
-                    return;
+                if (misspellingNSRange.length == 0) {
+                    it.advance();
+                    continue;
                 }
+
+                // Build up result range and string.  Note the misspelling may span many text nodes,
+                // but the CharIterator insulates us from this complexity
+                RefPtr<Range> misspellingRange(rangeOfContents(document()));
+                CharacterIterator chars(it.range().get());
+                chars.advance(misspellingNSRange.location);
+                misspellingRange->setStart(chars.range()->startContainer(exception), chars.range()->startOffset(exception), exception);
+                DeprecatedString result = chars.string(misspellingNSRange.length);
+                misspellingRange->setEnd(chars.range()->startContainer(exception), chars.range()->startOffset(exception), exception);
+                selectionController()->setSelection(Selection(misspellingRange.get(), DOWNSTREAM));
+                revealSelection();
+                // Mark misspelling in document.
+                document()->addMarker(misspellingRange.get(), DocumentMarker::Spelling);
+                
+                [checker updateSpellingPanelWithMisspelledWord:result];
+                return;
             }
-        
-            it.advance();
         }
+        
         if (it.atEnd()) {
-            if (wrapped || !startedWithSelection) {
-                break;      // finished the second range, or we did the whole doc with the first range
-            } else {
-                // we've gone from the selection to the end of doc, now wrap around
-                wrapped = YES;
-                searchRange->setStart(topNode, 0, exception);
-                // going until the end of the very first chunk we tested is far enough
-                searchRange->setEnd(searchEndAfterWrapNode, searchEndAfterWrapOffset, exception);
-                it = WordAwareIterator(searchRange.get());
-            }
+            if (wrapped || !startedWithSelection)
+                return;      // finished the second range, or we did the whole doc with the first range
+
+            // we've gone from the selection to the end of doc, now wrap around
+            wrapped = YES;
+            searchRange->setStart(topNode, 0, exception);
+            // going until the end of the very first chunk we tested is far enough
+            searchRange->setEnd(searchEndAfterWrapNode, searchEndAfterWrapOffset, exception);
+            it = WordAwareIterator(searchRange.get());
         }   
     }
-    
-    return;
 }
 
 bool FrameMac::wheelEvent(NSEvent *event)
@@ -2481,22 +2480,22 @@ void FrameMac::markMisspellings(const Selection& selection)
             int startIndex = 0;
             // Loop over the chunk to find each misspelling in it.
             while (startIndex < len) {
-                NSRange misspelling = [checker checkSpellingOfString:chunk startingAt:startIndex language:nil wrap:NO inSpellDocumentWithTag:editor()->client()->spellCheckerDocumentTag() wordCount:NULL];
-                if (misspelling.length == 0)
+                NSRange misspellingNSRange = [checker checkSpellingOfString:chunk startingAt:startIndex language:nil wrap:NO inSpellDocumentWithTag:editor()->client()->spellCheckerDocumentTag() wordCount:NULL];
+                if (misspellingNSRange.length == 0)
                     break;
-                else {
-                    // Build up result range and string.  Note the misspelling may span many text nodes,
-                    // but the CharIterator insulates us from this complexity
-                    RefPtr<Range> misspellingRange(rangeOfContents(document()));
-                    CharacterIterator chars(it.range().get());
-                    chars.advance(misspelling.location);
-                    misspellingRange->setStart(chars.range()->startContainer(exception), chars.range()->startOffset(exception), exception);
-                    chars.advance(misspelling.length);
-                    misspellingRange->setEnd(chars.range()->startContainer(exception), chars.range()->startOffset(exception), exception);
-                    // Mark misspelling in document.
-                    document()->addMarker(misspellingRange.get(), DocumentMarker::Spelling);
-                    startIndex = misspelling.location + misspelling.length;
-                }
+
+                // Build up result range and string.  Note the misspelling may span many text nodes,
+                // but the CharIterator insulates us from this complexity
+                RefPtr<Range> misspellingRange(rangeOfContents(document()));
+                CharacterIterator chars(it.range().get());
+                chars.advance(misspellingNSRange.location);
+                misspellingRange->setStart(chars.range()->startContainer(exception), chars.range()->startOffset(exception), exception);
+                chars.advance(misspellingNSRange.length);
+                misspellingRange->setEnd(chars.range()->startContainer(exception), chars.range()->startOffset(exception), exception);
+                // Mark misspelling in document.
+                document()->addMarker(misspellingRange.get(), DocumentMarker::Spelling);
+                
+                startIndex = misspellingNSRange.location + misspellingNSRange.length;
             }
             [chunk release];
         }