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 #include <string> | 5 #include <string> |
6 #include <utility> | 6 #include <utility> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ppapi/c/dev/ppb_console_dev.h" | 9 #include "ppapi/c/dev/ppb_console_dev.h" |
10 #include "ppapi/c/dev/ppb_cursor_control_dev.h" | 10 #include "ppapi/c/dev/ppb_cursor_control_dev.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 caret_pos_(std::string::npos), | 141 caret_pos_(std::string::npos), |
142 anchor_pos_(std::string::npos) { | 142 anchor_pos_(std::string::npos) { |
143 pp::FontDescription_Dev desc; | 143 pp::FontDescription_Dev desc; |
144 desc.set_family(PP_FONTFAMILY_SANSSERIF); | 144 desc.set_family(PP_FONTFAMILY_SANSSERIF); |
145 desc.set_size(font_size_); | 145 desc.set_size(font_size_); |
146 font_ = pp::Font_Dev(instance_, desc); | 146 font_ = pp::Font_Dev(instance_, desc); |
147 } | 147 } |
148 | 148 |
149 // Paint on the specified ImageData. | 149 // Paint on the specified ImageData. |
150 void PaintOn(pp::ImageData* image, pp::Rect clip) { | 150 void PaintOn(pp::ImageData* image, pp::Rect clip) { |
151 clip = clip.Intersect(area_); | 151 clip.Intersect(area_); |
152 FillRect(image, clip, kTextfieldBgColor); | 152 FillRect(image, clip, kTextfieldBgColor); |
153 | 153 |
154 if (caret_pos_ != std::string::npos) { | 154 if (caret_pos_ != std::string::npos) { |
155 int offset = area_.x(); | 155 int offset = area_.x(); |
156 // selection (for the case without composition text) | 156 // selection (for the case without composition text) |
157 if (composition_.empty() && HasSelection()) { | 157 if (composition_.empty() && HasSelection()) { |
158 int left_x = font_.MeasureSimpleText( | 158 int left_x = font_.MeasureSimpleText( |
159 utf8_text_.substr(0, SelectionLeft())); | 159 utf8_text_.substr(0, SelectionLeft())); |
160 int right_x = font_.MeasureSimpleText( | 160 int right_x = font_.MeasureSimpleText( |
161 utf8_text_.substr(0, SelectionRight())); | 161 utf8_text_.substr(0, SelectionRight())); |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 } | 727 } |
728 }; | 728 }; |
729 | 729 |
730 namespace pp { | 730 namespace pp { |
731 | 731 |
732 Module* CreateModule() { | 732 Module* CreateModule() { |
733 return new MyModule(); | 733 return new MyModule(); |
734 } | 734 } |
735 | 735 |
736 } // namespace pp | 736 } // namespace pp |
OLD | NEW |