Changeset 141471 in webkit


Ignore:
Timestamp:
Jan 31, 2013 12:58:51 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Tools: [Chromium] Add two-word misspelling to mock spellchecker
https://bugs.webkit.org/show_bug.cgi?id=108498

Patch by Rouslan Solomakhin <rouslan@chromium.org> on 2013-01-31
Reviewed by Tony Chang.

Some layout tests verify spellcheck behavior when multiple words are
marked as a single misspelling. This change adds a two-word misspelling
'upper case' to the mock spellchecker used by layout tests.

  • DumpRenderTree/chromium/TestRunner/src/MockSpellCheck.cpp:

(MockSpellCheck::spellCheckWord): Modified to handle spaces in misspellings.
(MockSpellCheck::initializeIfNeeded): Modified to use a vector instead of a hash table.

  • DumpRenderTree/chromium/TestRunner/src/MockSpellCheck.h:

(MockSpellCheck): Changed misspellings container from hash table to vector.

LayoutTests: [Chromium] Expect spellcheck to work for exactly-selected multi-word misspellings
https://bugs.webkit.org/show_bug.cgi?id=108498

Patch by Rouslan Solomakhin <rouslan@chromium.org> on 2013-01-31
Reviewed by Tony Chang.

  • platform/chromium/TestExpectations: Update spellcheck tests expectations.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r141469 r141471  
     12013-01-31  Rouslan Solomakhin  <rouslan@chromium.org>
     2
     3        [Chromium] Expect spellcheck to work for exactly-selected multi-word misspellings
     4        https://bugs.webkit.org/show_bug.cgi?id=108498
     5
     6        Reviewed by Tony Chang.
     7
     8        * platform/chromium/TestExpectations: Update spellcheck tests expectations.
     9
    1102013-01-31  Jessie Berlin  <jberlin@apple.com>
    211
  • trunk/LayoutTests/platform/chromium/TestExpectations

    r141456 r141471  
    43584358
    43594359# Spellchecker behavior tests.
    4360 webkit.org/b/108370 editing/spelling/spelling-double-clicked-word.html [ Skip ]
    4361 webkit.org/b/108370 editing/spelling/spelling-double-clicked-word-with-underscores.html [ Skip ]
    4362 webkit.org/b/108370 editing/spelling/spelling-exactly-selected-multiple-words.html [ Skip ]
    4363 webkit.org/b/108370 editing/spelling/spelling-exactly-selected-word.html [ Skip ]
    4364 webkit.org/b/108370 editing/spelling/spelling-multiword-selection.html [ Skip ]
    4365 webkit.org/b/108370 editing/spelling/spelling-should-select-multiple-words.html [ Skip ]
    4366 webkit.org/b/108370 editing/spelling/spelling-should-select-single-word.html [ Skip ]
    4367 webkit.org/b/108370 editing/spelling/spelling-subword-selection.html [ Skip ]
    4368 webkit.org/b/108370 editing/spelling/spelling-with-punctuation-selection.html [ Skip ]
    4369 webkit.org/b/108370 editing/spelling/spelling-with-underscore-selection.html [ Skip ]
    4370 webkit.org/b/108370 editing/spelling/spelling-with-whitespace-selection.html [ Skip ]
     4360webkit.org/b/108370 editing/spelling/spelling-double-clicked-word.html [ Failure ]
     4361webkit.org/b/108370 editing/spelling/spelling-double-clicked-word-with-underscores.html [ Failure ]
     4362webkit.org/b/108370 editing/spelling/spelling-should-select-multiple-words.html [ Failure ]
     4363webkit.org/b/108370 editing/spelling/spelling-with-punctuation-selection.html [ Failure ]
     4364webkit.org/b/108370 editing/spelling/spelling-with-underscore-selection.html [ Failure ]
     4365webkit.org/b/108370 editing/spelling/spelling-with-whitespace-selection.html [ Failure ]
    43714366
    43724367webkit.org/b/108424 media/video-error-does-not-exist.html [ Failure Crash ]
  • trunk/Tools/ChangeLog

    r141467 r141471  
     12013-01-31  Rouslan Solomakhin  <rouslan@chromium.org>
     2
     3        [Chromium] Add two-word misspelling to mock spellchecker
     4        https://bugs.webkit.org/show_bug.cgi?id=108498
     5
     6        Reviewed by Tony Chang.
     7
     8        Some layout tests verify spellcheck behavior when multiple words are
     9        marked as a single misspelling. This change adds a two-word misspelling
     10        'upper case' to the mock spellchecker used by layout tests.
     11
     12        * DumpRenderTree/chromium/TestRunner/src/MockSpellCheck.cpp:
     13        (MockSpellCheck::spellCheckWord): Modified to handle spaces in misspellings.
     14        (MockSpellCheck::initializeIfNeeded):  Modified to use a vector instead of a hash table.
     15        * DumpRenderTree/chromium/TestRunner/src/MockSpellCheck.h:
     16        (MockSpellCheck): Changed misspellings container from hash table to vector.
     17
    1182013-01-31  Simon Hausmann  <simon.hausmann@digia.com>
    219
  • trunk/Tools/DumpRenderTree/chromium/TestRunner/src/MockSpellCheck.cpp

    r140396 r141471  
    5959    // Convert to a String because we store String instances in
    6060    // m_misspelledWords and WebString has no find().
    61     WTF::String stringText(text.data(), text.length());
     61    String stringText(text.data(), text.length());
    6262    int skippedLength = 0;
    6363
     
    7070        // If the given string doesn't include any ASCII characters, we can treat the
    7171        // string as valid one.
    72         // Unfortunately, This implementation splits a contraction, i.e. "isn't" is
    73         // split into two pieces "isn" and "t". This is OK because webkit tests
    74         // don't have misspelled contractions.
    7572        int wordOffset = stringText.find(isASCIIAlpha);
    7673        if (wordOffset == -1)
    7774            return true;
    78         int wordEnd = stringText.find(isNotASCIIAlpha, wordOffset);
    79         int wordLength = wordEnd == -1 ? static_cast<int>(stringText.length()) - wordOffset : wordEnd - wordOffset;
     75        int maxWordLength = static_cast<int>(stringText.length()) - wordOffset;
     76        int wordLength;
     77        String word;
    8078
    8179        // Look up our misspelled-word table to check if the extracted word is a
     
    8482        // (See the comment in MockSpellCheck::initializeIfNeeded() why we use a
    8583        // misspelled-word table.)
    86         WTF::String word = stringText.substring(wordOffset, wordLength);
    87         if (m_misspelledWords.contains(word)) {
    88             *misspelledOffset = wordOffset + skippedLength;
    89             *misspelledLength = wordLength;
     84        for (int i = 0; i < m_misspelledWords.size(); ++i) {
     85            wordLength = static_cast<int>(m_misspelledWords.at(i).length()) > maxWordLength ? maxWordLength : static_cast<int>(m_misspelledWords.at(i).length());
     86            word = stringText.substring(wordOffset, wordLength);
     87            if (word == m_misspelledWords.at(i) && (static_cast<int>(stringText.length()) == wordOffset + wordLength || isNotASCIIAlpha(stringText[wordOffset + wordLength]))) {
     88                *misspelledOffset = wordOffset + skippedLength;
     89                *misspelledLength = wordLength;
     90                break;
     91            }
     92        }
     93
     94        if (*misspelledLength > 0)
    9095            break;
    91         }
     96
     97        int wordEnd = stringText.find(isNotASCIIAlpha, wordOffset);
     98        wordLength = wordEnd == -1 ? static_cast<int>(stringText.length()) - wordOffset : wordEnd - wordOffset;
    9299
    93100        ASSERT(0 < wordOffset + wordLength);
     
    152159        "qwertyuiopasd",
    153160        "qwertyuiopasdf",
     161        "upper case",
    154162        "wellcome"
    155163    };
     
    157165    m_misspelledWords.clear();
    158166    for (size_t i = 0; i < arraysize(misspelledWords); ++i)
    159         m_misspelledWords.add(WTF::String::fromUTF8(misspelledWords[i]), false);
     167        m_misspelledWords.append(String::fromUTF8(misspelledWords[i]));
    160168
    161169    // Mark as initialized to prevent this object from being initialized twice
  • trunk/Tools/DumpRenderTree/chromium/TestRunner/src/MockSpellCheck.h

    r140621 r141471  
    3434#include "Platform/chromium/public/WebString.h"
    3535#include "Platform/chromium/public/WebVector.h"
    36 #include <wtf/HashMap.h>
    37 #include <wtf/text/StringHash.h>
     36#include <wtf/Vector.h>
    3837#include <wtf/text/WTFString.h>
    3938
     
    7271
    7372    // A table that consists of misspelled words.
    74     HashMap<WTF::String, bool> m_misspelledWords;
     73    Vector<String> m_misspelledWords;
    7574
    7675    // A flag representing whether or not this object is initialized.
Note: See TracChangeset for help on using the changeset viewer.