spellcheck_mojom_traits.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2017 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_MOJOM_TRAITS_H_
  5. #define COMPONENTS_SPELLCHECK_COMMON_SPELLCHECK_MOJOM_TRAITS_H_
  6. #include "components/spellcheck/common/spellcheck.mojom-shared.h"
  7. #include "components/spellcheck/common/spellcheck_result.h"
  8. namespace mojo {
  9. template <>
  10. struct EnumTraits<spellcheck::mojom::Decoration, SpellCheckResult::Decoration> {
  11. static spellcheck::mojom::Decoration ToMojom(SpellCheckResult::Decoration);
  12. static bool FromMojom(spellcheck::mojom::Decoration,
  13. SpellCheckResult::Decoration*);
  14. };
  15. template <>
  16. struct StructTraits<spellcheck::mojom::SpellCheckResultDataView,
  17. SpellCheckResult> {
  18. static SpellCheckResult::Decoration decoration(
  19. const SpellCheckResult& result) {
  20. return result.decoration;
  21. }
  22. static int32_t location(const SpellCheckResult& result) {
  23. return result.location;
  24. }
  25. static int32_t length(const SpellCheckResult& result) {
  26. return result.length;
  27. }
  28. static const std::vector<std::u16string>& replacements(
  29. const SpellCheckResult& result) {
  30. return result.replacements;
  31. }
  32. static bool Read(spellcheck::mojom::SpellCheckResultDataView,
  33. SpellCheckResult*);
  34. };
  35. } // namespace mojo
  36. #endif // COMPONENTS_SPELLCHECK_COMMON_SPELLCHECK_MOJOM_TRAITS_H_