Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/ppb_text_input_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_text_input_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextInputType.h" | 8 #include "ui/base/ime/text_input_type.h" |
| 9 #include "ui/gfx/rect.h" | |
| 9 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 10 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 10 | 11 |
| 11 namespace webkit { | 12 namespace webkit { |
| 12 namespace ppapi { | 13 namespace ppapi { |
| 13 | 14 |
| 14 PPB_TextInput_Impl::PPB_TextInput_Impl(PluginInstance* instance) | 15 PPB_TextInput_Impl::PPB_TextInput_Impl(PluginInstance* instance) |
| 15 : instance_(instance) { | 16 : instance_(instance) { |
| 16 } | 17 } |
| 17 | 18 |
| 18 ::ppapi::thunk::PPB_TextInput_FunctionAPI* | 19 ::ppapi::thunk::PPB_TextInput_FunctionAPI* |
| 19 PPB_TextInput_Impl::AsPPB_TextInput_FunctionAPI() { | 20 PPB_TextInput_Impl::AsPPB_TextInput_FunctionAPI() { |
| 20 return this; | 21 return this; |
| 21 } | 22 } |
| 22 | 23 |
| 23 COMPILE_ASSERT(int(WebKit::WebTextInputTypeNone) == \ | 24 // Check PP_TextInput_Type and ui::TextInputType are kept in sync. |
| 25 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_NONE) == \ | |
| 24 int(PP_TEXTINPUT_TYPE_NONE), mismatching_enums); | 26 int(PP_TEXTINPUT_TYPE_NONE), mismatching_enums); |
| 25 COMPILE_ASSERT(int(WebKit::WebTextInputTypeText) == \ | 27 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_TEXT) == \ |
| 26 int(PP_TEXTINPUT_TYPE_TEXT), mismatching_enums); | 28 int(PP_TEXTINPUT_TYPE_TEXT), mismatching_enums); |
| 27 COMPILE_ASSERT(int(WebKit::WebTextInputTypePassword) == \ | 29 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_PASSWORD) == \ |
| 28 int(PP_TEXTINPUT_TYPE_PASSWORD), mismatching_enums); | 30 int(PP_TEXTINPUT_TYPE_PASSWORD), mismatching_enums); |
| 29 COMPILE_ASSERT(int(WebKit::WebTextInputTypeSearch) == \ | 31 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_SEARCH) == \ |
| 30 int(PP_TEXTINPUT_TYPE_SEARCH), mismatching_enums); | 32 int(PP_TEXTINPUT_TYPE_SEARCH), mismatching_enums); |
| 31 COMPILE_ASSERT(int(WebKit::WebTextInputTypeEmail) == \ | 33 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_EMAIL) == \ |
| 32 int(PP_TEXTINPUT_TYPE_EMAIL), mismatching_enums); | 34 int(PP_TEXTINPUT_TYPE_EMAIL), mismatching_enums); |
| 33 COMPILE_ASSERT(int(WebKit::WebTextInputTypeNumber) == \ | 35 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_NUMBER) == \ |
| 34 int(PP_TEXTINPUT_TYPE_NUMBER), mismatching_enums); | 36 int(PP_TEXTINPUT_TYPE_NUMBER), mismatching_enums); |
| 35 COMPILE_ASSERT(int(WebKit::WebTextInputTypeTelephone) == \ | 37 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_TELEPHONE) == \ |
| 36 int(PP_TEXTINPUT_TYPE_TELEPHONE), mismatching_enums); | 38 int(PP_TEXTINPUT_TYPE_TELEPHONE), mismatching_enums); |
| 37 COMPILE_ASSERT(int(WebKit::WebTextInputTypeURL) == \ | 39 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_URL) == \ |
| 38 int(PP_TEXTINPUT_TYPE_URL), mismatching_enums); | 40 int(PP_TEXTINPUT_TYPE_URL), mismatching_enums); |
| 39 | 41 |
| 40 void PPB_TextInput_Impl::SetTextInputType(PP_Instance instance, | 42 void PPB_TextInput_Impl::SetTextInputType(PP_Instance instance, |
| 41 PP_TextInput_Type type) { | 43 PP_TextInput_Type type) { |
| 42 // TODO(kinaba) the implementation is split to another CL for reviewing. | 44 int itype = type; |
| 43 NOTIMPLEMENTED(); | 45 if (itype<0 || itype>ui::TEXT_INPUT_TYPE_URL) |
|
brettw
2011/10/03 16:46:01
Can you add spaces around the < and > here?
kinaba
2011/10/05 04:43:19
Done.
| |
| 46 itype = ui::TEXT_INPUT_TYPE_NONE; | |
| 47 instance_->SetTextInputType(static_cast<ui::TextInputType>(itype)); | |
| 44 } | 48 } |
| 45 | 49 |
| 46 void PPB_TextInput_Impl::UpdateCaretPosition(PP_Instance instance, | 50 void PPB_TextInput_Impl::UpdateCaretPosition(PP_Instance instance, |
| 47 const PP_Rect& caret, | 51 const PP_Rect& caret, |
| 48 const PP_Rect& bounding_box) { | 52 const PP_Rect& bounding_box) { |
| 49 // TODO(kinaba) the implementation is split to another CL for reviewing. | 53 instance_->UpdateCaretPosition( |
| 50 NOTIMPLEMENTED(); | 54 gfx::Rect(caret.point.x, caret.point.y, |
| 55 caret.size.width, caret.size.height), | |
| 56 gfx::Rect(bounding_box.point.x, bounding_box.point.y, | |
| 57 bounding_box.size.width, bounding_box.size.height)); | |
| 51 } | 58 } |
| 52 | 59 |
| 53 void PPB_TextInput_Impl::CancelCompositionText(PP_Instance instance) { | 60 void PPB_TextInput_Impl::CancelCompositionText(PP_Instance instance) { |
| 54 // TODO(kinaba) the implementation is split to another CL for reviewing. | 61 instance_->delegate()->PluginRequestedCancelComposition(instance_); |
| 55 NOTIMPLEMENTED(); | |
| 56 } | 62 } |
| 57 | 63 |
| 58 } // namespace ppapi | 64 } // namespace ppapi |
| 59 } // namespace webkit | 65 } // namespace webkit |
| OLD | NEW |