Chromium Code Reviews| Index: chrome/common/spellcheck_result.h |
| diff --git a/chrome/common/spellcheck_result.h b/chrome/common/spellcheck_result.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4a03f6772ea742beb059fef2ead0835ddeb84f64 |
| --- /dev/null |
| +++ b/chrome/common/spellcheck_result.h |
| @@ -0,0 +1,72 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_COMMON_SPELLCHECK_RESULT_H_ |
| +#define CHROME_COMMON_SPELLCHECK_RESULT_H_ |
| +#pragma once |
| + |
| +#include "base/string16.h" |
| +#include "ipc/ipc_message_utils.h" |
| + |
| +// This class mirrors WebKit::WebTextCheckingResult which holds a |
| +// misspelled range inside the checked text. It also contains a |
| +// possible replacement of the misspelling if it is available. |
| +// |
| +// Although SpellCheckResult::Type defines various values Chromium |
| +// only uses the |Spelling| type. otehr values are just reflecting the |
| +// enum definition in the original WebKit class. |
| +// |
| +struct SpellCheckResult { |
|
darin (slow to review)
2012/02/16 04:59:28
Do we care that "spell check result" can express m
|
| + enum Type { |
| + Spelling = 1 << 1, |
|
darin (slow to review)
2012/02/16 04:59:28
nit: use google c++ style.
|
| + Grammar = 1 << 2, |
| + Link = 1 << 5, |
| + Quote = 1 << 6, |
| + Dash = 1 << 7, |
| + Replacement = 1 << 8, |
| + Correction = 1 << 9, |
| + ShowCorrectionPanel = 1 << 10 |
| + }; |
| + |
| + explicit SpellCheckResult( |
| + Type type = Spelling, |
| + int location = 0, |
| + int length = 0, |
| + const string16& replacement = string16()) |
| + : type_(type), |
| + location_(location), |
| + length_(length), |
| + replacement_(replacement) { |
| + } |
| + |
| + Type type() const { return type_; } |
| + int location() const { return location_; } |
| + int length() const { return length_; } |
| + string16 replacement() const { return replacement_; } |
| + |
| + // Puts these members public to make IPC serialization macros available. |
| + Type type_; |
|
darin (slow to review)
2012/02/16 04:59:28
nit: I recommend just eliminating the accessor fun
|
| + int location_; |
| + int length_; |
| + string16 replacement_; |
| +}; |
| + |
| +namespace IPC { |
| + |
| +template <> |
|
darin (slow to review)
2012/02/16 04:59:28
usually, IPC traits go into a separate header file
|
| +struct SimilarTypeTraits<SpellCheckResult::Type> { |
| + typedef int Type; |
| +}; |
| + |
| +template <> |
| +struct ParamTraits<SpellCheckResult> { |
| + typedef SpellCheckResult param_type; |
| + static void Write(Message* m, const param_type& p); |
| + static bool Read(const Message* m, void** iter, param_type* r); |
| + static void Log(const param_type& p, std::string* l); |
| +}; |
| + |
| +} // namespace IPC |
| + |
| +#endif // CHROME_COMMON_SPELLCHECK_RESULT_H_ |