// Copyright (c) 2011 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. #include "ppapi/cpp/dev/ime_input_event_dev.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" #include "ppapi/cpp/var.h" namespace pp { namespace { template <> const char* interface_name() { return PPB_IME_INPUT_EVENT_DEV_INTERFACE; } } // namespace // IMEInputEvent_Dev ------------------------------------------------------- IMEInputEvent_Dev::IMEInputEvent_Dev() : InputEvent() { } IMEInputEvent_Dev::IMEInputEvent_Dev(const InputEvent& event) : InputEvent() { // Type check the input event before setting it. if (!has_interface()) return; if (get_interface()->IsIMEInputEvent( event.pp_resource())) { Module::Get()->core()->AddRefResource(event.pp_resource()); PassRefFromConstructor(event.pp_resource()); } } Var IMEInputEvent_Dev::GetText() const { if (!has_interface()) return Var(); return Var(Var::PassRef(), get_interface()->GetText(pp_resource())); } uint32_t IMEInputEvent_Dev::GetSegmentNumber() const { if (!has_interface()) return 0; return get_interface()->GetSegmentNumber( pp_resource()); } uint32_t IMEInputEvent_Dev::GetSegmentOffset(uint32_t index) const { if (!has_interface()) return 0; return get_interface()->GetSegmentOffset(pp_resource(), index); } int32_t IMEInputEvent_Dev::GetTargetSegment() const { if (!has_interface()) return 0; return get_interface()->GetTargetSegment( pp_resource()); } std::pair IMEInputEvent_Dev::GetSelection() const { std::pair range(0, 0); if (!has_interface()) return range; get_interface()->GetSelection(pp_resource(), &range.first, &range.second); return range; } } // namespace pp