spellcheck_result.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_SPELLCHECK_COMMON_SPELLCHECK_RESULT_H_
  5. #define COMPONENTS_SPELLCHECK_COMMON_SPELLCHECK_RESULT_H_
  6. #include <stdint.h>
  7. #include <string>
  8. #include <vector>
  9. // This class mirrors blink::WebTextCheckingResult which holds a
  10. // misspelled range inside the checked text. It also contains a
  11. // possible replacement of the misspelling if it is available.
  12. struct SpellCheckResult {
  13. enum Decoration {
  14. // Red underline for misspelled words.
  15. SPELLING,
  16. // Gray underline for correctly spelled words that are incorrectly used in
  17. // their context.
  18. GRAMMAR,
  19. LAST = GRAMMAR,
  20. };
  21. explicit SpellCheckResult(
  22. Decoration d = SPELLING,
  23. int loc = 0,
  24. int len = 0,
  25. const std::vector<std::u16string>& rep = std::vector<std::u16string>());
  26. explicit SpellCheckResult(Decoration d,
  27. int loc,
  28. int len,
  29. const std::u16string& rep);
  30. ~SpellCheckResult();
  31. SpellCheckResult(const SpellCheckResult&);
  32. Decoration decoration;
  33. // The zero-based index where the misspelling starts. For spell check results
  34. // returned by the local spell check infrastructure, this is measured by
  35. // the code point count, i.e. each surrogate pair, such as emojis, will count
  36. // for 2 positions. For results returned by enhanced (server side) spell
  37. // check, positions are based on "logical" characters, i.e. emojis and their
  38. // modifiers count for 1.
  39. int location;
  40. // The length of the misspelled word. The same code point / logical character
  41. // count distinction as for `location` applies.
  42. int length;
  43. std::vector<std::u16string> replacements;
  44. bool spelling_service_used = false;
  45. };
  46. #endif // COMPONENTS_SPELLCHECK_COMMON_SPELLCHECK_RESULT_H_