1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "ohos_adapter/bridge/ark_imf_text_config_adapter_impl.h" 17 18 #include "ohos_adapter/bridge/ark_imf_cursor_info_adapter_impl.h" 19 #include "ohos_adapter/bridge/ark_imf_input_attribute_adapter_impl.h" 20 #include "ohos_adapter/bridge/ark_imf_selection_range_adapter_impl.h" 21 22 #include "base/bridge/ark_web_bridge_macros.h" 23 24 namespace OHOS::ArkWeb { 25 ArkIMFTextConfigAdapterImpl(std::shared_ptr<OHOS::NWeb::IMFTextConfigAdapter> ref)26ArkIMFTextConfigAdapterImpl::ArkIMFTextConfigAdapterImpl(std::shared_ptr<OHOS::NWeb::IMFTextConfigAdapter> ref) 27 : real_(ref) 28 {} 29 GetInputAttribute()30ArkWebRefPtr<ArkIMFInputAttributeAdapter> ArkIMFTextConfigAdapterImpl::GetInputAttribute() 31 { 32 std::shared_ptr<NWeb::IMFInputAttributeAdapter> attribute = real_->GetInputAttribute(); 33 if (CHECK_SHARED_PTR_IS_NULL(attribute)) { 34 return nullptr; 35 } 36 return new ArkIMFInputAttributeAdapterImpl(attribute); 37 } 38 GetCursorInfo()39ArkWebRefPtr<ArkIMFCursorInfoAdapter> ArkIMFTextConfigAdapterImpl::GetCursorInfo() 40 { 41 std::shared_ptr<NWeb::IMFCursorInfoAdapter> cursorInfo = real_->GetCursorInfo(); 42 if (CHECK_SHARED_PTR_IS_NULL(cursorInfo)) { 43 return nullptr; 44 } 45 return new ArkIMFCursorInfoAdapterImpl(cursorInfo); 46 } 47 GetSelectionRange()48ArkWebRefPtr<ArkIMFSelectionRangeAdapter> ArkIMFTextConfigAdapterImpl::GetSelectionRange() 49 { 50 std::shared_ptr<NWeb::IMFSelectionRangeAdapter> range = real_->GetSelectionRange(); 51 if (CHECK_SHARED_PTR_IS_NULL(range)) { 52 return nullptr; 53 } 54 return new ArkIMFSelectionRangeAdapterImpl(range); 55 } 56 GetWindowId()57uint32_t ArkIMFTextConfigAdapterImpl::GetWindowId() 58 { 59 return real_->GetWindowId(); 60 } 61 GetPositionY()62double ArkIMFTextConfigAdapterImpl::GetPositionY() 63 { 64 return real_->GetPositionY(); 65 } 66 GetHeight()67double ArkIMFTextConfigAdapterImpl::GetHeight() 68 { 69 return real_->GetHeight(); 70 } 71 } // namespace OHOS::ArkWeb 72