Commit e8fba76f authored by morrita@google.com's avatar morrita@google.com

2010-10-26 MORITA Hajime <morrita@google.com>

        Reviewed by Kent Tamura.

        Refactoring: Spellchecking related static functions could form a class
        https://bugs.webkit.org/show_bug.cgi?id=48287

        Extracted spellcheck related static functions to TextCheckingHelper class,
        which has EditorClient and Range as its member.

        No new tests. Just a refactoring.

        * CMakeLists.txt:
        * GNUmakefile.am:
        * WebCore.gypi:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * editing/Editor.cpp:
        (WebCore::Editor::advanceToNextMisspelling):
        (WebCore::Editor::isSelectionUngrammatical):
        (WebCore::Editor::guessesForUngrammaticalSelection):
        (WebCore::Editor::guessesForMisspelledOrUngrammaticalSelection):
        (WebCore::Editor::markMisspellingsAfterTypingToPosition):
        (WebCore::Editor::markMisspellingsOrBadGrammar):
        (WebCore::Editor::markMisspellings):
        (WebCore::Editor::markBadGrammar):
        (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
        (WebCore::Editor::changeBackToReplacedString):
        * editing/Editor.h:
        * editing/TextCheckingHelper.cpp: Added.
        (WebCore::TextCheckingHelper::TextCheckingHelper):
        (WebCore::TextCheckingHelper::~TextCheckingHelper):
        (WebCore::TextCheckingHelper::paragraphAlignedRange):
        (WebCore::TextCheckingHelper::findFirstMisspelling):
        (WebCore::TextCheckingHelper::findFirstMisspellingOrBadGrammar):
        (WebCore::TextCheckingHelper::findFirstGrammarDetail):
        (WebCore::TextCheckingHelper::findFirstBadGrammar):
        (WebCore::TextCheckingHelper::isUngrammatical):
        (WebCore::TextCheckingHelper::guessesForMisspelledOrUngrammaticalRange):
        (WebCore::TextCheckingHelper::markAllMisspellings):
        (WebCore::TextCheckingHelper::markAllBadGrammar):
        * editing/TextCheckingHelper.h: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70847 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d01e25a5
......@@ -924,6 +924,7 @@ SET(WebCore_SOURCES
editing/SplitElementCommand.cpp
editing/SplitTextNodeCommand.cpp
editing/SplitTextNodeContainingElementCommand.cpp
editing/TextCheckingHelper.cpp
editing/TextIterator.cpp
editing/TypingCommand.cpp
editing/UnlinkCommand.cpp
......
2010-10-26 MORITA Hajime <morrita@google.com>
Reviewed by Kent Tamura.
Refactoring: Spellchecking related static functions could form a class
https://bugs.webkit.org/show_bug.cgi?id=48287
Extracted spellcheck related static functions to TextCheckingHelper class,
which has EditorClient and Range as its member.
No new tests. Just a refactoring.
* CMakeLists.txt:
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* editing/Editor.cpp:
(WebCore::Editor::advanceToNextMisspelling):
(WebCore::Editor::isSelectionUngrammatical):
(WebCore::Editor::guessesForUngrammaticalSelection):
(WebCore::Editor::guessesForMisspelledOrUngrammaticalSelection):
(WebCore::Editor::markMisspellingsAfterTypingToPosition):
(WebCore::Editor::markMisspellingsOrBadGrammar):
(WebCore::Editor::markMisspellings):
(WebCore::Editor::markBadGrammar):
(WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
(WebCore::Editor::changeBackToReplacedString):
* editing/Editor.h:
* editing/TextCheckingHelper.cpp: Added.
(WebCore::TextCheckingHelper::TextCheckingHelper):
(WebCore::TextCheckingHelper::~TextCheckingHelper):
(WebCore::TextCheckingHelper::paragraphAlignedRange):
(WebCore::TextCheckingHelper::findFirstMisspelling):
(WebCore::TextCheckingHelper::findFirstMisspellingOrBadGrammar):
(WebCore::TextCheckingHelper::findFirstGrammarDetail):
(WebCore::TextCheckingHelper::findFirstBadGrammar):
(WebCore::TextCheckingHelper::isUngrammatical):
(WebCore::TextCheckingHelper::guessesForMisspelledOrUngrammaticalRange):
(WebCore::TextCheckingHelper::markAllMisspellings):
(WebCore::TextCheckingHelper::markAllBadGrammar):
* editing/TextCheckingHelper.h: Added.
2010-10-28 Adam Barth <abarth@webkit.org>
Reviewed by Eric Seidel, Peter Kasting, and Darin Fisher.
......@@ -1352,6 +1352,8 @@ webcore_sources += \
WebCore/editing/SplitTextNodeContainingElementCommand.cpp \
WebCore/editing/SplitTextNodeContainingElementCommand.h \
WebCore/editing/TextAffinity.h \
WebCore/editing/TextCheckingHelper.cpp \
WebCore/editing/TextCheckingHelper.h \
WebCore/editing/TextGranularity.h \
WebCore/editing/TextIterator.cpp \
WebCore/editing/TextIterator.h \
......
......@@ -1434,6 +1434,8 @@
'editing/SplitTextNodeContainingElementCommand.cpp',
'editing/SplitTextNodeContainingElementCommand.h',
'editing/TextAffinity.h',
'editing/TextCheckingHelper.cpp',
'editing/TextCheckingHelper.h',
'editing/TextGranularity.h',
'editing/TextIterator.cpp',
'editing/TextIterator.h',
......
......@@ -814,6 +814,7 @@ SOURCES += \
editing/SplitElementCommand.cpp \
editing/SplitTextNodeCommand.cpp \
editing/SplitTextNodeContainingElementCommand.cpp \
editing/TextCheckingHelper.cpp \
editing/TextIterator.cpp \
editing/TypingCommand.cpp \
editing/UnlinkCommand.cpp \
......
......@@ -47883,6 +47883,62 @@
RelativePath="..\editing\TextAffinity.h"
>
</File>
<File
RelativePath="..\editing\TextCheckingHelper.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug_Internal|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug_Cairo|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release_Cairo|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug_All|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\editing\TextCheckingHelper.h"
>
</File>
<File
RelativePath="..\editing\TextGranularity.h"
>
......@@ -3054,6 +3054,8 @@
A7D3C5240B576B4B002CA450 /* PasteboardHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D3C5230B576B4B002CA450 /* PasteboardHelper.h */; settings = {ATTRIBUTES = (Private, ); }; };
A7D6B3490F61104500B79FD1 /* WorkerScriptLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D6B3470F61104500B79FD1 /* WorkerScriptLoader.h */; };
A7D6B34A0F61104500B79FD1 /* WorkerScriptLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7D6B3480F61104500B79FD1 /* WorkerScriptLoader.cpp */; };
A7DBF8DD1276919C006B6008 /* TextCheckingHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7DBF8DB1276919C006B6008 /* TextCheckingHelper.cpp */; };
A7DBF8DE1276919C006B6008 /* TextCheckingHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = A7DBF8DC1276919C006B6008 /* TextCheckingHelper.h */; };
A7F338A311C0EFCA00A320A7 /* ShadowElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7F338A111C0EFCA00A320A7 /* ShadowElement.cpp */; };
A7F338A411C0EFCA00A320A7 /* ShadowElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A7F338A211C0EFCA00A320A7 /* ShadowElement.h */; };
A809F1470B73793A002E4D7F /* RenderSVGGradientStop.h in Headers */ = {isa = PBXBuildFile; fileRef = A809F1450B73793A002E4D7F /* RenderSVGGradientStop.h */; };
......@@ -9125,6 +9127,8 @@
A7D3C5230B576B4B002CA450 /* PasteboardHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PasteboardHelper.h; sourceTree = "<group>"; };
A7D6B3470F61104500B79FD1 /* WorkerScriptLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WorkerScriptLoader.h; path = workers/WorkerScriptLoader.h; sourceTree = "<group>"; };
A7D6B3480F61104500B79FD1 /* WorkerScriptLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WorkerScriptLoader.cpp; path = workers/WorkerScriptLoader.cpp; sourceTree = "<group>"; };
A7DBF8DB1276919C006B6008 /* TextCheckingHelper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextCheckingHelper.cpp; sourceTree = "<group>"; };
A7DBF8DC1276919C006B6008 /* TextCheckingHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextCheckingHelper.h; sourceTree = "<group>"; };
A7F338A111C0EFCA00A320A7 /* ShadowElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShadowElement.cpp; sourceTree = "<group>"; };
A7F338A211C0EFCA00A320A7 /* ShadowElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShadowElement.h; sourceTree = "<group>"; };
A809F1450B73793A002E4D7F /* RenderSVGGradientStop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGGradientStop.h; sourceTree = "<group>"; };
......@@ -14516,6 +14520,8 @@
93309DC7099E64910056E581 /* SplitTextNodeContainingElementCommand.h */,
93309DC8099E64910056E581 /* TextAffinity.h */,
93309DC9099E64910056E581 /* TextGranularity.h */,
A7DBF8DB1276919C006B6008 /* TextCheckingHelper.cpp */,
A7DBF8DC1276919C006B6008 /* TextCheckingHelper.h */,
93309DCC099E64910056E581 /* TextIterator.cpp */,
93309DCD099E64910056E581 /* TextIterator.h */,
93309DCA099E64910056E581 /* TypingCommand.cpp */,
......@@ -20940,6 +20946,7 @@
B2C3DA340D006C1D00EF6F26 /* TextBoundaries.h in Headers */,
B2C3DA360D006C1D00EF6F26 /* TextBreakIterator.h in Headers */,
B2C3DA380D006C1D00EF6F26 /* TextBreakIteratorInternalICU.h in Headers */,
A7DBF8DE1276919C006B6008 /* TextCheckingHelper.h in Headers */,
B2C3DA3A0D006C1D00EF6F26 /* TextCodec.h in Headers */,
B2C3DA3C0D006C1D00EF6F26 /* TextCodecICU.h in Headers */,
B2C3DA3E0D006C1D00EF6F26 /* TextCodecLatin1.h in Headers */,
......@@ -23548,6 +23555,7 @@
B2AFFC970D00A5DF0030074D /* TextBoundaries.mm in Sources */,
B2C3DA370D006C1D00EF6F26 /* TextBreakIteratorICU.cpp in Sources */,
B2AFFC980D00A5DF0030074D /* TextBreakIteratorInternalICUMac.mm in Sources */,
A7DBF8DD1276919C006B6008 /* TextCheckingHelper.cpp in Sources */,
B2C3DA390D006C1D00EF6F26 /* TextCodec.cpp in Sources */,
B2C3DA3B0D006C1D00EF6F26 /* TextCodecICU.cpp in Sources */,
B2C3DA3D0D006C1D00EF6F26 /* TextCodecLatin1.cpp in Sources */,
This diff is collapsed.
......@@ -404,6 +404,7 @@ private:
void replaceSelectionWithText(const String&, bool selectReplacement, bool smartReplace);
void writeSelectionToPasteboard(Pasteboard*);
void revealSelectionAfterEditingOperation();
void markMisspellingsOrBadGrammar(const VisibleSelection&, bool checkSpelling, RefPtr<Range>& firstMisspellingRange);
void selectComposition();
void confirmComposition(const String&, bool preserveSelection);
......
This diff is collapsed.
/*
* Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef TextCheckingHelper_h
#define TextCheckingHelper_h
#include "EditorClient.h"
namespace WebCore {
class Range;
class TextCheckingHelper : public Noncopyable {
public:
TextCheckingHelper(EditorClient*, PassRefPtr<Range>);
~TextCheckingHelper();
String findFirstMisspelling(int& firstMisspellingOffset, bool markAll, RefPtr<Range>& firstMisspellingRange);
String findFirstMisspellingOrBadGrammar(bool checkGrammar, bool& outIsSpelling, int& outFirstFoundOffset, GrammarDetail& outGrammarDetail);
String findFirstBadGrammar(GrammarDetail& outGrammarDetail, int& outGrammarPhraseOffset, bool markAll);
int findFirstGrammarDetail(const Vector<GrammarDetail>& grammarDetails, int badGrammarPhraseLocation, int badGrammarPhraseLength, int startOffset, int endOffset, bool markAll);
void markAllMisspellings(RefPtr<Range>& firstMisspellingRange);
void markAllBadGrammar();
bool isUngrammatical(Vector<String>& guessesVector) const;
Vector<String> guessesForMisspelledOrUngrammaticalRange(bool checkGrammar, bool& misspelled, bool& ungrammatical) const;
PassRefPtr<Range> paragraphAlignedRange(int& offsetIntoParagraphAlignedRange, String& paragraphString) const;
private:
EditorClient* m_client;
RefPtr<Range> m_range;
};
} // namespace WebCore
#endif // TextCheckingHelper_h
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment