Changeset 97696 in webkit
- Timestamp:
- Oct 17, 2011 6:38:49 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r97669 r97696 652 652 editing/ReplaceSelectionCommand.cpp 653 653 editing/SetNodeAttributeCommand.cpp 654 editing/SetSelectionCommand.cpp 654 655 editing/SmartReplace.cpp 655 656 editing/SpellChecker.cpp 656 657 editing/SpellingCorrectionController.cpp 658 editing/SpellingCorrectionCommand.cpp 657 659 editing/SplitElementCommand.cpp 658 660 editing/SplitTextNodeCommand.cpp -
trunk/Source/WebCore/ChangeLog
r97695 r97696 1 2011-10-17 Shinya Kawanaka <shinyak@google.com> 2 3 Unified spell-checking and legacy spell checking should be easy to switch 4 https://bugs.webkit.org/show_bug.cgi?id=69242 5 6 Reviewed by Hajime Morita. 7 8 WebCore has two different code paths for spell-checking: 9 1) checkTextOfParagraph() for Snow Leopard or later 10 2) checkSpellingOfString() for checkGrammarOfString() for other platforms. 11 12 This patch introduces a flag to change code paths dynamically. 13 This patch also includes build fix for QT, GTK, and Windows platforms. 14 15 No new tests because this patch does not change a behavior. 16 17 * CMakeLists.txt: 18 * GNUmakefile.list.am: 19 * WebCore.pro: 20 * WebCore.vcproj/WebCore.vcproj: 21 * accessibility/AccessibilityObject.cpp: 22 (WebCore::AccessibilityObject::hasMisspelling): 23 Changed static if-USE(UNIFIED_TEXT_CHECKING) statement to dynamic 24 condition branch to achieve easy code path change. 25 * accessibility/mac/WebAccessibilityObjectWrapper.mm: ditto. 26 (AXAttributeStringSetSpelling): 27 * editing/EditingAllInOne.cpp: 28 * editing/Editor.cpp: 29 (WebCore::Editor::advanceToNextMisspelling): ditto. 30 (WebCore::Editor::guessesForMisspelledOrUngrammaticalSelection): ditto. 31 (WebCore::Editor::markMisspellingsAfterTypingToWord): ditto. 32 (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges): ditto. 33 (WebCore::Editor::changeBackToReplacedString): ditto. 34 (WebCore::Editor::markMisspellingsAndBadGrammar): ditto. 35 (WebCore::Editor::unifiedTextCheckerEnabled): 36 Utility method to check using unified text checking or not. 37 * editing/Editor.h: 38 * editing/TextCheckingHelper.cpp: 39 (WebCore::TextCheckingHelper::findFirstMisspellingOrBadGrammar): 40 Same as WebCore::AccessibilityObject::hasMisspelling. 41 (WebCore::TextCheckingHelper::guessesForMisspelledOrUngrammaticalRange): ditto. 42 (WebCore::TextCheckingHelper::unifiedTextCheckerEnabled): 43 Utility method to check using unified text checking or not. 44 (WebCore::unifiedTextCheckerEnabled): ditto. 45 * editing/TextCheckingHelper.h: 46 * page/Settings.cpp: 47 (WebCore::Settings::Settings): 48 Includes a flag to change the code path. 49 * page/Settings.h: 50 (WebCore::Settings::setUnifiedTextCheckerEnabled): 51 Sets a flag to change the code path. 52 (WebCore::Settings::unifiedTextCheckerEnabled): 53 A flag to change the code path. 54 1 55 2011-10-17 Julien Chaffraix <jchaffraix@webkit.org> 2 56 -
trunk/Source/WebCore/GNUmakefile.list.am
r97669 r97696 1438 1438 Source/WebCore/editing/SetNodeAttributeCommand.cpp \ 1439 1439 Source/WebCore/editing/SetNodeAttributeCommand.h \ 1440 Source/WebCore/editing/SetSelectionCommand.cpp \ 1441 Source/WebCore/editing/SetSelectionCommand.h \ 1440 1442 Source/WebCore/editing/SmartReplace.cpp \ 1441 1443 Source/WebCore/editing/SmartReplace.h \ … … 1445 1447 Source/WebCore/editing/SpellingCorrectionController.cpp \ 1446 1448 Source/WebCore/editing/SpellingCorrectionController.h \ 1449 Source/WebCore/editing/SpellingCorrectionCommand.cpp \ 1447 1450 Source/WebCore/editing/SpellingCorrectionCommand.h \ 1448 1451 Source/WebCore/editing/SplitElementCommand.cpp \ -
trunk/Source/WebCore/WebCore.pro
r97669 r97696 616 616 editing/ReplaceSelectionCommand.cpp \ 617 617 editing/SetNodeAttributeCommand.cpp \ 618 editing/SetSelectionCommand.cpp \ 618 619 editing/SmartReplaceICU.cpp \ 619 620 editing/SpellChecker.cpp \ 621 editing/SpellingCorrectionCommand.cpp \ 620 622 editing/SpellingCorrectionController.cpp \ 621 623 editing/SplitElementCommand.cpp \ … … 1647 1649 editing/SetNodeAttributeCommand.h \ 1648 1650 editing/SmartReplace.h \ 1651 editing/SpellingCorrectionCommand.h \ 1649 1652 editing/SpellingCorrectionController.h \ 1650 1653 editing/SplitElementCommand.h \ -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r97669 r97696 52617 52617 </FileConfiguration> 52618 52618 </File> 52619 <File 52620 RelativePath="..\editing\SetSelectionCommand.cpp" 52621 > 52622 <FileConfiguration 52623 Name="Debug|Win32" 52624 ExcludedFromBuild="true" 52625 > 52626 <Tool 52627 Name="VCCLCompilerTool" 52628 /> 52629 </FileConfiguration> 52630 <FileConfiguration 52631 Name="Release|Win32" 52632 ExcludedFromBuild="true" 52633 > 52634 <Tool 52635 Name="VCCLCompilerTool" 52636 /> 52637 </FileConfiguration> 52638 <FileConfiguration 52639 Name="Debug_Cairo_CFLite|Win32" 52640 ExcludedFromBuild="true" 52641 > 52642 <Tool 52643 Name="VCCLCompilerTool" 52644 /> 52645 </FileConfiguration> 52646 <FileConfiguration 52647 Name="Release_Cairo_CFLite|Win32" 52648 ExcludedFromBuild="true" 52649 > 52650 <Tool 52651 Name="VCCLCompilerTool" 52652 /> 52653 </FileConfiguration> 52654 <FileConfiguration 52655 Name="Debug_All|Win32" 52656 ExcludedFromBuild="true" 52657 > 52658 <Tool 52659 Name="VCCLCompilerTool" 52660 /> 52661 </FileConfiguration> 52662 <FileConfiguration 52663 Name="Production|Win32" 52664 ExcludedFromBuild="true" 52665 > 52666 <Tool 52667 Name="VCCLCompilerTool" 52668 /> 52669 </FileConfiguration> 52670 </File> 52671 <File 52672 RelativePath="..\editing\SetSelectionCommand.h" 52673 > 52674 </File> 52619 52675 <File 52620 52676 RelativePath="..\editing\SmartReplace.h" … … 52729 52785 > 52730 52786 </File> 52787 <File 52788 RelativePath="..\editing\SpellingCorrectionCommand.cpp" 52789 > 52790 <FileConfiguration 52791 Name="Debug|Win32" 52792 ExcludedFromBuild="true" 52793 > 52794 <Tool 52795 Name="VCCLCompilerTool" 52796 /> 52797 </FileConfiguration> 52798 <FileConfiguration 52799 Name="Release|Win32" 52800 ExcludedFromBuild="true" 52801 > 52802 <Tool 52803 Name="VCCLCompilerTool" 52804 /> 52805 </FileConfiguration> 52806 <FileConfiguration 52807 Name="Debug_Cairo_CFLite|Win32" 52808 ExcludedFromBuild="true" 52809 > 52810 <Tool 52811 Name="VCCLCompilerTool" 52812 /> 52813 </FileConfiguration> 52814 <FileConfiguration 52815 Name="Release_Cairo_CFLite|Win32" 52816 ExcludedFromBuild="true" 52817 > 52818 <Tool 52819 Name="VCCLCompilerTool" 52820 /> 52821 </FileConfiguration> 52822 <FileConfiguration 52823 Name="Debug_All|Win32" 52824 ExcludedFromBuild="true" 52825 > 52826 <Tool 52827 Name="VCCLCompilerTool" 52828 /> 52829 </FileConfiguration> 52830 <FileConfiguration 52831 Name="Release_LTCG|Win32" 52832 ExcludedFromBuild="true" 52833 > 52834 <Tool 52835 Name="VCCLCompilerTool" 52836 /> 52837 </FileConfiguration> 52838 </File> 52839 <File 52840 RelativePath="..\editing\SpellingCorrectionCommand.h" 52841 > 52842 </File> 52731 52843 <File 52732 52844 RelativePath="..\editing\SpellingCorrectionController.cpp" -
trunk/Source/WebCore/accessibility/AccessibilityObject.cpp
r97669 r97696 51 51 #include "RenderWidget.h" 52 52 #include "RenderedPosition.h" 53 #include "Settings.h" 53 54 #include "TextCheckerClient.h" 54 55 #include "TextCheckingHelper.h" … … 290 291 int charsLength = stringValue().length(); 291 292 bool isMisspelled = false; 292 293 #if USE(UNIFIED_TEXT_CHECKING) 294 Vector<TextCheckingResult> results; 295 checkTextOfParagraph(textChecker, chars, charsLength, TextCheckingTypeSpelling, results); 296 if (!results.isEmpty()) 297 isMisspelled = true; 298 #else 293 294 if (unifiedTextCheckerEnabled(frame)) { 295 Vector<TextCheckingResult> results; 296 checkTextOfParagraph(textChecker, chars, charsLength, TextCheckingTypeSpelling, results); 297 if (!results.isEmpty()) 298 isMisspelled = true; 299 return isMisspelled; 300 } 301 299 302 int misspellingLength = 0; 300 303 int misspellingLocation = -1; … … 302 305 if (misspellingLength || misspellingLocation != -1) 303 306 isMisspelled = true; 304 #endif305 307 306 308 return isMisspelled; -
trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapper.mm
r97669 r97696 691 691 static void AXAttributeStringSetSpelling(NSMutableAttributedString* attrString, Node* node, const UChar* chars, int charLength, NSRange range) 692 692 { 693 #if USE(UNIFIED_TEXT_CHECKING) 694 // Check the spelling directly since document->markersForNode() does not store the misspelled marking when the cursor is in a word. 695 TextCheckerClient* checker = node->document()->frame()->editor()->textChecker(); 696 697 // checkTextOfParagraph is the only spelling/grammar checker implemented in WK1 and WK2 698 Vector<TextCheckingResult> results; 699 checkTextOfParagraph(checker, chars, charLength, TextCheckingTypeSpelling, results); 700 701 size_t size = results.size(); 702 NSNumber* trueValue = [NSNumber numberWithBool:YES]; 703 for (unsigned i = 0; i < size; i++) { 704 const TextCheckingResult& result = results[i]; 705 AXAttributeStringSetNumber(attrString, NSAccessibilityMisspelledTextAttribute, trueValue, NSMakeRange(result.location + range.location, result.length)); 706 } 707 #else 693 if (unifiedTextCheckerEnabled(node->document()->frame())) { 694 // Check the spelling directly since document->markersForNode() does not store the misspelled marking when the cursor is in a word. 695 TextCheckerClient* checker = node->document()->frame()->editor()->textChecker(); 696 697 // checkTextOfParagraph is the only spelling/grammar checker implemented in WK1 and WK2 698 Vector<TextCheckingResult> results; 699 checkTextOfParagraph(checker, chars, charLength, TextCheckingTypeSpelling, results); 700 701 size_t size = results.size(); 702 NSNumber* trueValue = [NSNumber numberWithBool:YES]; 703 for (unsigned i = 0; i < size; i++) { 704 const TextCheckingResult& result = results[i]; 705 AXAttributeStringSetNumber(attrString, NSAccessibilityMisspelledTextAttribute, trueValue, NSMakeRange(result.location + range.location, result.length)); 706 } 707 return; 708 } 709 708 710 int currentPosition = 0; 709 711 while (charLength > 0) { … … 722 724 currentPosition += (misspellingLocation + misspellingLength); 723 725 } 724 #endif725 726 } 726 727 -
trunk/Source/WebCore/editing/EditingAllInOne.cpp
r92286 r97696 62 62 #include <ReplaceSelectionCommand.cpp> 63 63 #include <SetNodeAttributeCommand.cpp> 64 #include <SetSelectionCommand.cpp> 64 65 #include <SmartReplace.cpp> 65 66 #include <SmartReplaceCF.cpp> 67 #include <SpellingCorrectionCommand.cpp> 66 68 #include <SpellingCorrectionController.cpp> 67 69 #include <SpellChecker.cpp> -
trunk/Source/WebCore/editing/Editor.cpp
r97585 r97696 1629 1629 String misspelledWord; 1630 1630 1631 #if USE(UNIFIED_TEXT_CHECKING)1632 grammarSearchRange = spellingSearchRange->cloneRange(ec);1633 1631 bool isSpelling = true; 1634 1632 int foundOffset = 0; 1635 String foundItem = TextCheckingHelper(client(), spellingSearchRange).findFirstMisspellingOrBadGrammar(isGrammarCheckingEnabled(), isSpelling, foundOffset, grammarDetail); 1636 if (isSpelling) { 1637 misspelledWord = foundItem; 1638 misspellingOffset = foundOffset; 1639 } else { 1640 badGrammarPhrase = foundItem; 1641 grammarPhraseOffset = foundOffset; 1642 } 1643 #else 1633 String foundItem; 1644 1634 RefPtr<Range> firstMisspellingRange; 1645 misspelledWord = TextCheckingHelper(client(), spellingSearchRange).findFirstMisspelling(misspellingOffset, false, firstMisspellingRange); 1646 1647 #if USE(GRAMMAR_CHECKING) 1648 // Search for bad grammar that occurs prior to the next misspelled word (if any) 1649 grammarSearchRange = spellingSearchRange->cloneRange(ec); 1650 if (!misspelledWord.isEmpty()) { 1651 // Stop looking at start of next misspelled word 1652 CharacterIterator chars(grammarSearchRange.get()); 1653 chars.advance(misspellingOffset); 1654 grammarSearchRange->setEnd(chars.range()->startContainer(ec), chars.range()->startOffset(ec), ec); 1655 } 1656 1657 if (isGrammarCheckingEnabled()) 1658 badGrammarPhrase = TextCheckingHelper(client(), grammarSearchRange).findFirstBadGrammar(grammarDetail, grammarPhraseOffset, false); 1659 #endif 1660 #endif 1661 1662 // If we found neither bad grammar nor a misspelled word, wrap and try again (but don't bother if we started at the beginning of the 1663 // block rather than at a selection). 1664 if (startedWithSelection && !misspelledWord && !badGrammarPhrase) { 1665 spellingSearchRange->setStart(topNode, 0, ec); 1666 // going until the end of the very first chunk we tested is far enough 1667 spellingSearchRange->setEnd(searchEndNodeAfterWrap, searchEndOffsetAfterWrap, ec); 1668 1669 #if USE(UNIFIED_TEXT_CHECKING) 1635 if (unifiedTextCheckerEnabled()) { 1670 1636 grammarSearchRange = spellingSearchRange->cloneRange(ec); 1671 1637 foundItem = TextCheckingHelper(client(), spellingSearchRange).findFirstMisspellingOrBadGrammar(isGrammarCheckingEnabled(), isSpelling, foundOffset, grammarDetail); … … 1677 1643 grammarPhraseOffset = foundOffset; 1678 1644 } 1679 #else 1645 } else { 1680 1646 misspelledWord = TextCheckingHelper(client(), spellingSearchRange).findFirstMisspelling(misspellingOffset, false, firstMisspellingRange); 1681 1647 … … 1688 1654 grammarSearchRange->setEnd(chars.range()->startContainer(ec), chars.range()->startOffset(ec), ec); 1689 1655 } 1690 1656 1691 1657 if (isGrammarCheckingEnabled()) 1692 1658 badGrammarPhrase = TextCheckingHelper(client(), grammarSearchRange).findFirstBadGrammar(grammarDetail, grammarPhraseOffset, false); 1693 1659 #endif 1660 } 1661 1662 // If we found neither bad grammar nor a misspelled word, wrap and try again (but don't bother if we started at the beginning of the 1663 // block rather than at a selection). 1664 if (startedWithSelection && !misspelledWord && !badGrammarPhrase) { 1665 spellingSearchRange->setStart(topNode, 0, ec); 1666 // going until the end of the very first chunk we tested is far enough 1667 spellingSearchRange->setEnd(searchEndNodeAfterWrap, searchEndOffsetAfterWrap, ec); 1668 1669 if (unifiedTextCheckerEnabled()) { 1670 grammarSearchRange = spellingSearchRange->cloneRange(ec); 1671 foundItem = TextCheckingHelper(client(), spellingSearchRange).findFirstMisspellingOrBadGrammar(isGrammarCheckingEnabled(), isSpelling, foundOffset, grammarDetail); 1672 if (isSpelling) { 1673 misspelledWord = foundItem; 1674 misspellingOffset = foundOffset; 1675 } else { 1676 badGrammarPhrase = foundItem; 1677 grammarPhraseOffset = foundOffset; 1678 } 1679 } else { 1680 misspelledWord = TextCheckingHelper(client(), spellingSearchRange).findFirstMisspelling(misspellingOffset, false, firstMisspellingRange); 1681 1682 #if USE(GRAMMAR_CHECKING) 1683 grammarSearchRange = spellingSearchRange->cloneRange(ec); 1684 if (!misspelledWord.isEmpty()) { 1685 // Stop looking at start of next misspelled word 1686 CharacterIterator chars(grammarSearchRange.get()); 1687 chars.advance(misspellingOffset); 1688 grammarSearchRange->setEnd(chars.range()->startContainer(ec), chars.range()->startOffset(ec), ec); 1689 } 1690 1691 if (isGrammarCheckingEnabled()) 1692 badGrammarPhrase = TextCheckingHelper(client(), grammarSearchRange).findFirstBadGrammar(grammarDetail, grammarPhraseOffset, false); 1694 1693 #endif 1694 } 1695 1695 } 1696 1696 … … 1792 1792 Vector<String> Editor::guessesForMisspelledOrUngrammaticalSelection(bool& misspelled, bool& ungrammatical) 1793 1793 { 1794 #if USE(UNIFIED_TEXT_CHECKING) 1795 RefPtr<Range> range = frame()->selection()->toNormalizedRange(); 1796 if (!range) 1797 return Vector<String>(); 1798 return TextCheckingHelper(client(), range).guessesForMisspelledOrUngrammaticalRange(isGrammarCheckingEnabled(), misspelled, ungrammatical); 1799 #else 1794 if (unifiedTextCheckerEnabled()) { 1795 RefPtr<Range> range = frame()->selection()->toNormalizedRange(); 1796 if (!range) 1797 return Vector<String>(); 1798 return TextCheckingHelper(client(), range).guessesForMisspelledOrUngrammaticalRange(isGrammarCheckingEnabled(), misspelled, ungrammatical); 1799 } 1800 1800 1801 misspelled = isSelectionMisspelled(); 1801 1802 if (misspelled) { … … 1809 1810 ungrammatical = false; 1810 1811 return Vector<String>(); 1811 #endif1812 1812 } 1813 1813 … … 1851 1851 void Editor::markMisspellingsAfterTypingToWord(const VisiblePosition &wordStart, const VisibleSelection& selectionAfterTyping, bool doReplacement) 1852 1852 { 1853 #if USE(UNIFIED_TEXT_CHECKING) 1854 m_spellingCorrector->applyPendingCorrection(selectionAfterTyping);1855 1856 TextCheckingTypeMask textCheckingOptions = 0;1857 1858 if (isContinuousSpellCheckingEnabled())1859 textCheckingOptions |= TextCheckingTypeSpelling;1853 if (unifiedTextCheckerEnabled()) { 1854 m_spellingCorrector->applyPendingCorrection(selectionAfterTyping); 1855 1856 TextCheckingTypeMask textCheckingOptions = 0; 1857 1858 if (isContinuousSpellCheckingEnabled()) 1859 textCheckingOptions |= TextCheckingTypeSpelling; 1860 1860 1861 1861 #if USE(AUTOMATIC_TEXT_REPLACEMENT) 1862 if (doReplacement1863 && (isAutomaticQuoteSubstitutionEnabled()1864 || isAutomaticLinkDetectionEnabled()1865 || isAutomaticDashSubstitutionEnabled()1866 || isAutomaticTextReplacementEnabled()1867 || ((textCheckingOptions & TextCheckingTypeSpelling) && isAutomaticSpellingCorrectionEnabled())))1868 textCheckingOptions |= TextCheckingTypeReplacement;1862 if (doReplacement 1863 && (isAutomaticQuoteSubstitutionEnabled() 1864 || isAutomaticLinkDetectionEnabled() 1865 || isAutomaticDashSubstitutionEnabled() 1866 || isAutomaticTextReplacementEnabled() 1867 || ((textCheckingOptions & TextCheckingTypeSpelling) && isAutomaticSpellingCorrectionEnabled()))) 1868 textCheckingOptions |= TextCheckingTypeReplacement; 1869 1869 #endif 1870 if (!textCheckingOptions & (TextCheckingTypeSpelling | TextCheckingTypeReplacement)) 1871 return; 1872 1873 if (isGrammarCheckingEnabled()) 1874 textCheckingOptions |= TextCheckingTypeGrammar; 1875 1876 VisibleSelection adjacentWords = VisibleSelection(startOfWord(wordStart, LeftWordIfOnBoundary), endOfWord(wordStart, RightWordIfOnBoundary)); 1877 if (textCheckingOptions & TextCheckingTypeGrammar) { 1878 VisibleSelection selectedSentence = VisibleSelection(startOfSentence(wordStart), endOfSentence(wordStart)); 1879 markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, adjacentWords.toNormalizedRange().get(), selectedSentence.toNormalizedRange().get()); 1880 } else { 1881 markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, adjacentWords.toNormalizedRange().get(), adjacentWords.toNormalizedRange().get()); 1882 } 1883 1884 #else 1885 UNUSED_PARAM(selectionAfterTyping); 1886 UNUSED_PARAM(doReplacement); 1870 if (!(textCheckingOptions & (TextCheckingTypeSpelling | TextCheckingTypeReplacement))) 1871 return; 1872 1873 if (isGrammarCheckingEnabled()) 1874 textCheckingOptions |= TextCheckingTypeGrammar; 1875 1876 VisibleSelection adjacentWords = VisibleSelection(startOfWord(wordStart, LeftWordIfOnBoundary), endOfWord(wordStart, RightWordIfOnBoundary)); 1877 if (textCheckingOptions & TextCheckingTypeGrammar) { 1878 VisibleSelection selectedSentence = VisibleSelection(startOfSentence(wordStart), endOfSentence(wordStart)); 1879 markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, adjacentWords.toNormalizedRange().get(), selectedSentence.toNormalizedRange().get()); 1880 } else 1881 markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, adjacentWords.toNormalizedRange().get(), adjacentWords.toNormalizedRange().get()); 1882 return; 1883 } 1887 1884 1888 1885 if (!isContinuousSpellCheckingEnabled()) … … 1924 1921 // Check grammar of entire sentence 1925 1922 markBadGrammar(VisibleSelection(startOfSentence(wordStart), endOfSentence(wordStart))); 1926 #endif1927 1923 } 1928 1924 … … 1992 1988 void Editor::markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask textCheckingOptions, Range* spellingRange, Range* grammarRange) 1993 1989 { 1994 #if USE(UNIFIED_TEXT_CHECKING) 1990 ASSERT(unifiedTextCheckerEnabled()); 1991 1995 1992 // There shouldn't be pending autocorrection at this moment. 1996 1993 ASSERT(!m_spellingCorrector->hasPendingCorrection()); … … 2183 2180 } 2184 2181 } 2185 #else2186 ASSERT_NOT_REACHED();2187 UNUSED_PARAM(textCheckingOptions);2188 UNUSED_PARAM(spellingRange);2189 UNUSED_PARAM(grammarRange);2190 #endif // USE(UNIFIED_TEXT_CHECKING)2191 2182 } 2192 2183 2193 2184 void Editor::changeBackToReplacedString(const String& replacedString) 2194 2185 { 2195 #if USE(UNIFIED_TEXT_CHECKING) 2186 ASSERT(unifiedTextCheckerEnabled()); 2187 2196 2188 if (replacedString.isEmpty()) 2197 2189 return; … … 2207 2199 changedRange->startContainer()->document()->markers()->addMarker(changedRange.get(), DocumentMarker::Replacement, String()); 2208 2200 m_spellingCorrector->markReversed(changedRange.get()); 2209 #else2210 ASSERT_NOT_REACHED();2211 UNUSED_PARAM(replacedString);2212 #endif // USE(UNIFIED_TEXT_CHECKING)2213 2201 } 2214 2202 … … 2216 2204 void Editor::markMisspellingsAndBadGrammar(const VisibleSelection& spellingSelection, bool markGrammar, const VisibleSelection& grammarSelection) 2217 2205 { 2218 #if USE(UNIFIED_TEXT_CHECKING) 2219 if (!isContinuousSpellCheckingEnabled()) 2220 return; 2221 TextCheckingTypeMask textCheckingOptions = TextCheckingTypeSpelling | TextCheckingTypeCorrection; 2222 if (markGrammar && isGrammarCheckingEnabled()) 2223 textCheckingOptions |= TextCheckingTypeGrammar; 2224 markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, spellingSelection.toNormalizedRange().get(), grammarSelection.toNormalizedRange().get()); 2225 #else 2206 if (unifiedTextCheckerEnabled()) { 2207 if (!isContinuousSpellCheckingEnabled()) 2208 return; 2209 TextCheckingTypeMask textCheckingOptions = TextCheckingTypeSpelling | TextCheckingTypeCorrection; 2210 if (markGrammar && isGrammarCheckingEnabled()) 2211 textCheckingOptions |= TextCheckingTypeGrammar; 2212 markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, spellingSelection.toNormalizedRange().get(), grammarSelection.toNormalizedRange().get()); 2213 return; 2214 } 2215 2226 2216 RefPtr<Range> firstMisspellingRange; 2227 2217 markMisspellings(spellingSelection, firstMisspellingRange); 2228 2218 if (markGrammar) 2229 2219 markBadGrammar(grammarSelection); 2230 #endif2231 2220 } 2232 2221 … … 3081 3070 } 3082 3071 3072 bool Editor::unifiedTextCheckerEnabled() const 3073 { 3074 return WebCore::unifiedTextCheckerEnabled(m_frame); 3075 } 3076 3083 3077 } // namespace WebCore -
trunk/Source/WebCore/editing/Editor.h
r97585 r97696 418 418 419 419 Node* findEventTargetFromSelection() const; 420 421 bool unifiedTextCheckerEnabled() const; 420 422 }; 421 423 -
trunk/Source/WebCore/editing/TextCheckingHelper.cpp
r96568 r97696 30 30 #include "Document.h" 31 31 #include "DocumentMarkerController.h" 32 #include "Frame.h" 32 33 #include "Range.h" 34 #include "Settings.h" 33 35 #include "TextCheckerClient.h" 34 36 #include "TextIterator.h" … … 226 228 String TextCheckingHelper::findFirstMisspellingOrBadGrammar(bool checkGrammar, bool& outIsSpelling, int& outFirstFoundOffset, GrammarDetail& outGrammarDetail) 227 229 { 228 #if USE(UNIFIED_TEXT_CHECKING) 230 if (!unifiedTextCheckerEnabled()) 231 return ""; 232 229 233 String firstFoundItem; 230 234 String misspelledWord; … … 345 349 } 346 350 return firstFoundItem; 347 #else348 ASSERT_NOT_REACHED();349 UNUSED_PARAM(checkGrammar);350 UNUSED_PARAM(outIsSpelling);351 UNUSED_PARAM(outFirstFoundOffset);352 UNUSED_PARAM(outGrammarDetail);353 return "";354 #endif // USE(UNIFIED_TEXT_CHECKING)355 351 } 356 352 … … 511 507 Vector<String> TextCheckingHelper::guessesForMisspelledOrUngrammaticalRange(bool checkGrammar, bool& misspelled, bool& ungrammatical) const 512 508 { 513 #if USE(UNIFIED_TEXT_CHECKING) 509 if (!unifiedTextCheckerEnabled()) 510 return Vector<String>(); 511 514 512 Vector<String> guesses; 515 513 ExceptionCode ec; … … 563 561 } 564 562 return guesses; 565 #else566 ASSERT_NOT_REACHED();567 UNUSED_PARAM(checkGrammar);568 UNUSED_PARAM(misspelled);569 UNUSED_PARAM(ungrammatical);570 return Vector<String>();571 #endif // USE(UNIFIED_TEXT_CHECKING)572 563 } 573 564 … … 589 580 int ignoredOffset; 590 581 findFirstBadGrammar(ignoredGrammarDetail, ignoredOffset, true); 582 } 583 584 bool TextCheckingHelper::unifiedTextCheckerEnabled() const 585 { 586 if (!m_range) 587 return false; 588 589 Document* doc = m_range->ownerDocument(); 590 if (!doc) 591 return false; 592 593 return WebCore::unifiedTextCheckerEnabled(doc->frame()); 591 594 } 592 595 … … 608 611 } 609 612 610 } 613 bool unifiedTextCheckerEnabled(const Frame* frame) 614 { 615 if (!frame) 616 return false; 617 618 const Settings* settings = frame->settings(); 619 if (!settings) 620 return false; 621 622 return settings->unifiedTextCheckerEnabled(); 623 } 624 625 } -
trunk/Source/WebCore/editing/TextCheckingHelper.h
r96571 r97696 91 91 EditorClient* m_client; 92 92 RefPtr<Range> m_range; 93 94 bool unifiedTextCheckerEnabled() const; 93 95 }; 94 96 … … 96 98 TextCheckingTypeMask checkingTypes, Vector<TextCheckingResult>& results); 97 99 100 bool unifiedTextCheckerEnabled(const Frame*); 101 98 102 } // namespace WebCore 99 103 -
trunk/Source/WebCore/page/Settings.cpp
r97574 r97696 197 197 #endif 198 198 , m_asynchronousSpellCheckingEnabled(false) 199 #if USE(UNIFIED_TEXT_CHECKING) 200 , m_unifiedTextCheckerEnabled(true) 201 #else 202 , m_unifiedTextCheckerEnabled(false) 203 #endif 199 204 , m_memoryInfoEnabled(false) 200 205 , m_interactiveFormValidation(false) -
trunk/Source/WebCore/page/Settings.h
r97574 r97696 381 381 void setAsynchronousSpellCheckingEnabled(bool flag) { m_asynchronousSpellCheckingEnabled = flag; } 382 382 bool asynchronousSpellCheckingEnabled() const { return m_asynchronousSpellCheckingEnabled; } 383 384 void setUnifiedTextCheckerEnabled(bool flag) { m_unifiedTextCheckerEnabled = flag; } 385 bool unifiedTextCheckerEnabled() const { return m_unifiedTextCheckerEnabled; } 383 386 384 387 void setMemoryInfoEnabled(bool flag) { m_memoryInfoEnabled = flag; } … … 569 572 #endif 570 573 bool m_asynchronousSpellCheckingEnabled: 1; 574 bool m_unifiedTextCheckerEnabled: 1; 571 575 bool m_memoryInfoEnabled: 1; 572 576 bool m_interactiveFormValidation: 1;
Note: See TracChangeset
for help on using the changeset viewer.