Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 5 #ifndef CHROME_COMMON_SPELLCHECK_RESULT_H_ | |
| 6 #define CHROME_COMMON_SPELLCHECK_RESULT_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/string16.h" | |
| 10 #include "ipc/ipc_message_utils.h" | |
| 11 | |
| 12 // This class mirrors WebKit::WebTextCheckingResult which holds a | |
| 13 // misspelled range inside the checked text. It also contains a | |
| 14 // possible replacement of the misspelling if it is available. | |
| 15 // | |
| 16 // Although SpellCheckResult::Type defines various values Chromium | |
| 17 // only uses the |Spelling| type. otehr values are just reflecting the | |
| 18 // enum definition in the original WebKit class. | |
| 19 // | |
| 20 struct SpellCheckResult { | |
|
darin (slow to review)
2012/02/16 04:59:28
Do we care that "spell check result" can express m
| |
| 21 enum Type { | |
| 22 Spelling = 1 << 1, | |
|
darin (slow to review)
2012/02/16 04:59:28
nit: use google c++ style.
| |
| 23 Grammar = 1 << 2, | |
| 24 Link = 1 << 5, | |
| 25 Quote = 1 << 6, | |
| 26 Dash = 1 << 7, | |
| 27 Replacement = 1 << 8, | |
| 28 Correction = 1 << 9, | |
| 29 ShowCorrectionPanel = 1 << 10 | |
| 30 }; | |
| 31 | |
| 32 explicit SpellCheckResult( | |
| 33 Type type = Spelling, | |
| 34 int location = 0, | |
| 35 int length = 0, | |
| 36 const string16& replacement = string16()) | |
| 37 : type_(type), | |
| 38 location_(location), | |
| 39 length_(length), | |
| 40 replacement_(replacement) { | |
| 41 } | |
| 42 | |
| 43 Type type() const { return type_; } | |
| 44 int location() const { return location_; } | |
| 45 int length() const { return length_; } | |
| 46 string16 replacement() const { return replacement_; } | |
| 47 | |
| 48 // Puts these members public to make IPC serialization macros available. | |
| 49 Type type_; | |
|
darin (slow to review)
2012/02/16 04:59:28
nit: I recommend just eliminating the accessor fun
| |
| 50 int location_; | |
| 51 int length_; | |
| 52 string16 replacement_; | |
| 53 }; | |
| 54 | |
| 55 namespace IPC { | |
| 56 | |
| 57 template <> | |
|
darin (slow to review)
2012/02/16 04:59:28
usually, IPC traits go into a separate header file
| |
| 58 struct SimilarTypeTraits<SpellCheckResult::Type> { | |
| 59 typedef int Type; | |
| 60 }; | |
| 61 | |
| 62 template <> | |
| 63 struct ParamTraits<SpellCheckResult> { | |
| 64 typedef SpellCheckResult param_type; | |
| 65 static void Write(Message* m, const param_type& p); | |
| 66 static bool Read(const Message* m, void** iter, param_type* r); | |
| 67 static void Log(const param_type& p, std::string* l); | |
| 68 }; | |
| 69 | |
| 70 } // namespace IPC | |
| 71 | |
| 72 #endif // CHROME_COMMON_SPELLCHECK_RESULT_H_ | |
| OLD | NEW |