| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_COMMON_MAC_ATTRIBUTED_STRING_CODER_H_ | 5 #ifndef CONTENT_COMMON_MAC_ATTRIBUTED_STRING_CODER_H_ |
| 6 #define CONTENT_COMMON_MAC_ATTRIBUTED_STRING_CODER_H_ | 6 #define CONTENT_COMMON_MAC_ATTRIBUTED_STRING_CODER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 FontDescriptor font_descriptor_; | 57 FontDescriptor font_descriptor_; |
| 58 gfx::Range effective_range_; | 58 gfx::Range effective_range_; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 // A class that contains the pertinent information from an NSAttributedString, | 61 // A class that contains the pertinent information from an NSAttributedString, |
| 62 // which can be serialized over IPC. | 62 // which can be serialized over IPC. |
| 63 class EncodedString { | 63 class EncodedString { |
| 64 public: | 64 public: |
| 65 explicit EncodedString(string16 string); | 65 explicit EncodedString(base::string16 string); |
| 66 EncodedString(); | 66 EncodedString(); |
| 67 ~EncodedString(); | 67 ~EncodedString(); |
| 68 | 68 |
| 69 // Accessors: | 69 // Accessors: |
| 70 string16 string() const { return string_; } | 70 base::string16 string() const { return string_; } |
| 71 const std::vector<FontAttribute>& attributes() const { | 71 const std::vector<FontAttribute>& attributes() const { |
| 72 return attributes_; | 72 return attributes_; |
| 73 } | 73 } |
| 74 std::vector<FontAttribute>* attributes() { return &attributes_; } | 74 std::vector<FontAttribute>* attributes() { return &attributes_; } |
| 75 | 75 |
| 76 private: | 76 private: |
| 77 // The plain-text string. | 77 // The plain-text string. |
| 78 string16 string_; | 78 base::string16 string_; |
| 79 // The set of attributes that style |string_|. | 79 // The set of attributes that style |string_|. |
| 80 std::vector<FontAttribute> attributes_; | 80 std::vector<FontAttribute> attributes_; |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 // Takes an NSAttributedString, extracts the pertinent attributes, and returns | 83 // Takes an NSAttributedString, extracts the pertinent attributes, and returns |
| 84 // an object that represents it. Caller owns the result. | 84 // an object that represents it. Caller owns the result. |
| 85 static const EncodedString* Encode(NSAttributedString* str); | 85 static const EncodedString* Encode(NSAttributedString* str); |
| 86 | 86 |
| 87 // Returns an autoreleased NSAttributedString from an encoded representation. | 87 // Returns an autoreleased NSAttributedString from an encoded representation. |
| 88 static NSAttributedString* Decode(const EncodedString* str); | 88 static NSAttributedString* Decode(const EncodedString* str); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 109 struct ParamTraits<mac::AttributedStringCoder::FontAttribute> { | 109 struct ParamTraits<mac::AttributedStringCoder::FontAttribute> { |
| 110 typedef mac::AttributedStringCoder::FontAttribute param_type; | 110 typedef mac::AttributedStringCoder::FontAttribute param_type; |
| 111 static void Write(Message* m, const param_type& p); | 111 static void Write(Message* m, const param_type& p); |
| 112 static bool Read(const Message* m, PickleIterator* iter, param_type* r); | 112 static bool Read(const Message* m, PickleIterator* iter, param_type* r); |
| 113 static void Log(const param_type& p, std::string* l); | 113 static void Log(const param_type& p, std::string* l); |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 } // namespace IPC | 116 } // namespace IPC |
| 117 | 117 |
| 118 #endif // CONTENT_COMMON_MAC_ATTRIBUTED_STRING_CODER_H_ | 118 #endif // CONTENT_COMMON_MAC_ATTRIBUTED_STRING_CODER_H_ |
| OLD | NEW |