Changeset 86520 in webkit


Ignore:
Timestamp:
May 15, 2011 7:46:12 PM (13 years ago)
Author:
morrita@google.com
Message:

2011-05-13 MORITA Hajime <morrita@google.com>

Reviewed by Ryosuke Niwa.

Refactoring: Editor::TextCheckingOptions should be replaced with TextCheckingType
https://bugs.webkit.org/show_bug.cgi?id=57088

Removed Editor::TextCheckingOptions and replaced it with TextCheckingTypeMask
No new tests, no behavior change.

  • editing/Editor.cpp: (WebCore::Editor::replaceSelectionWithFragment): (WebCore::Editor::markMisspellingsAfterTypingToWord): (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges): (WebCore::Editor::markMisspellingsAndBadGrammar): (WebCore::Editor::resolveTextCheckingTypeMask):
  • editing/Editor.h:
  • platform/text/TextChecking.h: Added TextCheckingTypeShowCorrectionPanel
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r86507 r86520  
     12011-05-13  MORITA Hajime  <morrita@google.com>
     2
     3        Reviewed by Ryosuke Niwa.
     4
     5        Refactoring: Editor::TextCheckingOptions should be replaced with TextCheckingType
     6        https://bugs.webkit.org/show_bug.cgi?id=57088
     7
     8        Removed Editor::TextCheckingOptions and replaced it with TextCheckingTypeMask
     9        No new tests, no behavior change.
     10
     11        * editing/Editor.cpp:
     12        (WebCore::Editor::replaceSelectionWithFragment):
     13        (WebCore::Editor::markMisspellingsAfterTypingToWord):
     14        (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
     15        (WebCore::Editor::markMisspellingsAndBadGrammar):
     16        (WebCore::Editor::resolveTextCheckingTypeMask):
     17        * editing/Editor.h:
     18        * platform/text/TextChecking.h: Added TextCheckingTypeShowCorrectionPanel
     19
    1202011-05-15  Ilya Tikhonovsky  <loislo@chromium.org>
    221
  • trunk/Source/WebCore/editing/Editor.cpp

    r86325 r86520  
    419419    Node* nodeToCheck = m_frame->selection()->rootEditableElement();
    420420    if (m_spellChecker->canCheckAsynchronously(nodeToCheck))
    421         m_spellChecker->requestCheckingFor(textCheckingTypeMaskFor(MarkSpelling | MarkGrammar), nodeToCheck);
     421        m_spellChecker->requestCheckingFor(resolveTextCheckingTypeMask(TextCheckingTypeSpelling | TextCheckingTypeGrammar), nodeToCheck);
    422422}
    423423
     
    19741974    m_spellingCorrector->applyPendingCorrection(selectionAfterTyping);
    19751975
    1976     TextCheckingOptions textCheckingOptions = 0;
     1976    TextCheckingTypeMask textCheckingOptions = 0;
     1977
    19771978    if (isContinuousSpellCheckingEnabled())
    1978         textCheckingOptions |= MarkSpelling;
     1979        textCheckingOptions |= TextCheckingTypeSpelling;
    19791980
    19801981#if USE(AUTOMATIC_TEXT_REPLACEMENT)
     
    19841985            || isAutomaticDashSubstitutionEnabled()
    19851986            || isAutomaticTextReplacementEnabled()
    1986             || ((textCheckingOptions & MarkSpelling) && isAutomaticSpellingCorrectionEnabled())))
    1987         textCheckingOptions |= PerformReplacement;
     1987            || ((textCheckingOptions & TextCheckingTypeSpelling) && isAutomaticSpellingCorrectionEnabled())))
     1988        textCheckingOptions |= TextCheckingTypeReplacement;
    19881989#endif
    1989     if (!textCheckingOptions & (MarkSpelling | PerformReplacement))
     1990    if (!textCheckingOptions & (TextCheckingTypeSpelling | TextCheckingTypeReplacement))
    19901991        return;
    19911992
    19921993    if (isGrammarCheckingEnabled())
    1993         textCheckingOptions |= MarkGrammar;
     1994        textCheckingOptions |= TextCheckingTypeGrammar;
    19941995
    19951996    VisibleSelection adjacentWords = VisibleSelection(startOfWord(wordStart, LeftWordIfOnBoundary), endOfWord(wordStart, RightWordIfOnBoundary));
    1996     if (textCheckingOptions & MarkGrammar) {
     1997    if (textCheckingOptions & TextCheckingTypeGrammar) {
    19971998        VisibleSelection selectedSentence = VisibleSelection(startOfSentence(wordStart), endOfSentence(wordStart));
    19981999        markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, adjacentWords.toNormalizedRange().get(), selectedSentence.toNormalizedRange().get());
     
    21092110}
    21102111
    2111 void Editor::markAllMisspellingsAndBadGrammarInRanges(TextCheckingOptions textCheckingOptions, Range* spellingRange, Range* grammarRange)
     2112void Editor::markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask textCheckingOptions, Range* spellingRange, Range* grammarRange)
    21122113{
    21132114#if USE(UNIFIED_TEXT_CHECKING)
     
    21152116    ASSERT(!m_spellingCorrector->hasPendingCorrection());
    21162117
    2117     bool shouldMarkSpelling = textCheckingOptions & MarkSpelling;
    2118     bool shouldMarkGrammar = textCheckingOptions & MarkGrammar;
    2119     bool shouldPerformReplacement = textCheckingOptions & PerformReplacement;
    2120     bool shouldShowCorrectionPanel = textCheckingOptions & ShowCorrectionPanel;
    2121     bool shouldCheckForCorrection = shouldShowCorrectionPanel || (textCheckingOptions & CheckForCorrection);
     2118    bool shouldMarkSpelling = textCheckingOptions & TextCheckingTypeSpelling;
     2119    bool shouldMarkGrammar = textCheckingOptions & TextCheckingTypeGrammar;
     2120    bool shouldPerformReplacement = textCheckingOptions & TextCheckingTypeReplacement;
     2121    bool shouldShowCorrectionPanel = textCheckingOptions & TextCheckingTypeShowCorrectionPanel;
     2122    bool shouldCheckForCorrection = shouldShowCorrectionPanel || (textCheckingOptions & TextCheckingTypeCorrection);
    21222123
    21232124    // This function is called with selections already expanded to word boundaries.
     
    21662167    if (shouldMarkGrammar)
    21672168        textChecker()->checkTextOfParagraph(grammarParagraph.textCharacters(), grammarParagraph.textLength(),
    2168                                             textCheckingTypeMaskFor(textCheckingOptions), results);
     2169                                            resolveTextCheckingTypeMask(textCheckingOptions), results);
    21692170    else
    21702171        textChecker()->checkTextOfParagraph(spellingParagraph.textCharacters(), spellingParagraph.textLength(),
    2171                                             textCheckingTypeMaskFor(textCheckingOptions), results);
     2172                                            resolveTextCheckingTypeMask(textCheckingOptions), results);
    21722173       
    21732174
     
    23362337    if (!isContinuousSpellCheckingEnabled())
    23372338        return;
    2338     TextCheckingOptions textCheckingOptions = MarkSpelling | CheckForCorrection;
     2339    TextCheckingTypeMask textCheckingOptions = TextCheckingTypeSpelling | TextCheckingTypeCorrection;
    23392340    if (markGrammar && isGrammarCheckingEnabled())
    2340         textCheckingOptions |= MarkGrammar;
     2341        textCheckingOptions |= TextCheckingTypeGrammar;
    23412342    markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, spellingSelection.toNormalizedRange().get(), grammarSelection.toNormalizedRange().get());
    23422343#else
     
    32273228}       
    32283229
    3229 TextCheckingTypeMask Editor::textCheckingTypeMaskFor(TextCheckingOptions textCheckingOptions)
    3230 {
    3231     bool shouldMarkSpelling = textCheckingOptions & MarkSpelling;
    3232     bool shouldMarkGrammar = textCheckingOptions & MarkGrammar;
    3233     bool shouldShowCorrectionPanel = textCheckingOptions & ShowCorrectionPanel;
    3234     bool shouldCheckForCorrection = shouldShowCorrectionPanel || (textCheckingOptions & CheckForCorrection);
     3230TextCheckingTypeMask Editor::resolveTextCheckingTypeMask(TextCheckingTypeMask textCheckingOptions)
     3231{
     3232    bool shouldMarkSpelling = textCheckingOptions & TextCheckingTypeSpelling;
     3233    bool shouldMarkGrammar = textCheckingOptions & TextCheckingTypeGrammar;
     3234    bool shouldShowCorrectionPanel = textCheckingOptions & TextCheckingTypeShowCorrectionPanel;
     3235    bool shouldCheckForCorrection = shouldShowCorrectionPanel || (textCheckingOptions & TextCheckingTypeCorrection);
    32353236
    32363237    TextCheckingTypeMask checkingTypes = 0;
     
    32433244
    32443245#if USE(AUTOMATIC_TEXT_REPLACEMENT)
    3245     bool shouldPerformReplacement = textCheckingOptions & PerformReplacement;
     3246    bool shouldPerformReplacement = textCheckingOptions & TextCheckingTypeReplacement;
    32463247    if (shouldPerformReplacement) {
    32473248        if (isAutomaticLinkDetectionEnabled())
  • trunk/Source/WebCore/editing/Editor.h

    r86295 r86520  
    224224    void markMisspellingsAndBadGrammar(const VisibleSelection& spellingSelection, bool markGrammar, const VisibleSelection& grammarSelection);
    225225
    226     enum TextCheckingOptionFlags {
    227         MarkSpelling = 1 << 0,
    228         MarkGrammar = 1 << 1,
    229         PerformReplacement = 1 << 2,
    230         ShowCorrectionPanel = 1 << 3,
    231         CheckForCorrection = 1 << 4,
    232     };
    233     typedef unsigned TextCheckingOptions;
    234 
    235226#if USE(AUTOMATIC_TEXT_REPLACEMENT)
    236227    void uppercaseWord();
     
    252243#endif
    253244
    254     void markAllMisspellingsAndBadGrammarInRanges(TextCheckingOptions, Range* spellingRange, Range* grammarRange);
     245    void markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask, Range* spellingRange, Range* grammarRange);
    255246    void changeBackToReplacedString(const String& replacedString);
    256247
     
    415406    void revealSelectionAfterEditingOperation();
    416407    void markMisspellingsOrBadGrammar(const VisibleSelection&, bool checkSpelling, RefPtr<Range>& firstMisspellingRange);
    417     TextCheckingTypeMask textCheckingTypeMaskFor(TextCheckingOptions);
     408    TextCheckingTypeMask resolveTextCheckingTypeMask(TextCheckingTypeMask);
    418409
    419410    void selectComposition();
  • trunk/Source/WebCore/platform/text/TextChecking.h

    r85036 r86520  
    4848    TextCheckingTypeDash        = 1 << 7,
    4949    TextCheckingTypeReplacement = 1 << 8,
    50     TextCheckingTypeCorrection  = 1 << 9
     50    TextCheckingTypeCorrection  = 1 << 9,
     51    TextCheckingTypeShowCorrectionPanel = 1 << 10
    5152};
    5253
Note: See TracChangeset for help on using the changeset viewer.