From d4b948525dcac3c1d931ab9d3f1172236740be11 Mon Sep 17 00:00:00 2001 From: "yupeng74@huawei.com" Date: Mon, 16 Sep 2024 14:49:23 +0800 Subject: [PATCH] =?UTF-8?q?revert=20=E7=AA=97=E5=8F=A3=E6=8B=96=E6=8B=BD?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yupeng74@huawei.com --- ohos_nweb/BUILD.gn | 2 - ohos_nweb/src/nweb__resize_helper.cc | 102 --------------------------- ohos_nweb/src/nweb_impl.cc | 47 ------------ ohos_nweb/src/nweb_impl.h | 4 -- ohos_nweb/src/nweb_resize_helper.h | 54 -------------- 5 files changed, 209 deletions(-) delete mode 100644 ohos_nweb/src/nweb__resize_helper.cc delete mode 100644 ohos_nweb/src/nweb_resize_helper.h diff --git a/ohos_nweb/BUILD.gn b/ohos_nweb/BUILD.gn index d9dfab86e6..09a9e3478d 100644 --- a/ohos_nweb/BUILD.gn +++ b/ohos_nweb/BUILD.gn @@ -168,8 +168,6 @@ component("cef_nweb") { "src/sysevent/event_reporter.h", "src/sysevent/oh_web_performance_timing.cc", "src/sysevent/oh_web_performance_timing.h", - "src/nweb__resize_helper.cc", - "src/nweb__resize_helper.h", ] #ifdef OHOS_SCHEME_HANDLER diff --git a/ohos_nweb/src/nweb__resize_helper.cc b/ohos_nweb/src/nweb__resize_helper.cc deleted file mode 100644 index 55dfea54be..0000000000 --- a/ohos_nweb/src/nweb__resize_helper.cc +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "nweb_resize_helper.h" - -namespace OHOS::NWeb { - -NWebResizeHelper& NWebResizeHelper::GetInstance() { - static NWebResizeHelper instance; - return instance; -} - -void NWebResizeHelper::SetResizeStartTimeStamp() { - auto time = std::chrono::high_resolution_clock::now().time_since_epoch(); - resize_start_timestamp_ = std::chrono::duration_cast(time).count(); -} - -void NWebResizeHelper::CaculateResizeTime() { - auto time = std::chrono::high_resolution_clock::now().time_since_epoch(); - int64_t complete_time = std::chrono::duration_cast(time).count(); - resize_time_ = complete_time - resize_start_timestamp_; -} - -int64_t NWebResizeHelper::GetResizeStartTimeStamp() { - return resize_start_timestamp_; -} - -int64_t NWebResizeHelper::GetResizeTime() { - return resize_time_; -} - -void NWebResizeHelper::RefreshStartTimeStamp() { - resize_start_timestamp_ = 0; -} - -int64_t NWebResizeHelper::GetResizeAdjustValue(uint32_t target_length, - int64_t resize_pre_length, - bool isHeight) { - int64_t result = 0; - if (isHeight) { - if (resize_last_height_ == 0) { - resize_start_timestamp_ = 0; - return target_length; - } - result = target_length + (target_length - resize_last_height_) + resize_pre_length; - if (result < 0) { - result = target_length; - } - if (result < resize_last_height_) { - result = resize_last_height_; - } - }else { - if (resize_last_width_ == 0) { - resize_start_timestamp_ = 0; - return target_length; - } - result = target_length + (target_length - resize_last_width_) + resize_pre_length; - if (result < 0) { - result = target_length; - } - if (result < resize_last_width_) { - result = resize_last_width_; - } - } - return result; -} - -void NWebResizeHelper::RefreshParam() { - resize_start_timestamp_ = 0; - resize_time_ = 0L; - resize_last_height_ = 0L; - resize_last_width_ = 0L; -} - -void NWebResizeHelper::SetDragResizeStart(bool is_start) { - is_drag_resize_start_ = is_start; -} - -bool NWebResizeHelper::IsDragResizeStart() { - return is_drag_resize_start_; -} - -void NWebResizeHelper::SetResizeHeightAndWidth(int64_t height, int64_t width) { - LOG(DEBUG) << "===== set resize last size"; - resize_last_height_ = height; - resize_last_width_ = width; - LOG(DEBUG) << "====== resize_last_width_ ======= " << resize_last_width_ << "=== resize_last_height_ ===" << resize_last_height_; -} - -} diff --git a/ohos_nweb/src/nweb_impl.cc b/ohos_nweb/src/nweb_impl.cc index b542b54e29..8edcd14e5a 100644 --- a/ohos_nweb/src/nweb_impl.cc +++ b/ohos_nweb/src/nweb_impl.cc @@ -45,8 +45,6 @@ #include "nweb_hit_test_result_impl.h" #include "ohos_adapter_helper.h" #include "res_sched_client_adapter.h" -#include "nweb_resize_helper.h" -#include "third_party/ohos_ndk/includes/ohos_adapter/ohos_adapter_helper.h" #include "components/web_cache/browser/web_cache_manager.h" #include "ui/base/clipboard/ohos/clipboard_ohos.h" @@ -159,7 +157,6 @@ namespace { uint32_t g_nweb_count = 0; const uint32_t kSurfaceMaxWidth = 7680; const uint32_t kSurfaceMaxHeight = 7680; -const int SOC_PERF_WEB_DRAG_RESIZE_ID = 10073; #if defined(OHOS_MEDIA_POLICY) const int32_t kMaxResumeInterval = 60; #endif // defined(OHOS_MEDIA_POLICY) @@ -929,50 +926,6 @@ void NWebImpl::ResizeVisibleViewport(uint32_t width, uint32_t height, bool isKey #endif } -void NWebImpl::DragResize(uint32_t width, uint32_t height, uint32_t pre_height, uint32_t pre_width) { - LOG(DEBUG) << "===== start drag resize ====="; - bool drag_bigger_height = false; - bool drag_bigger_width = false; - if (input_handler_ == nullptr || output_handler_ == nullptr) { - return; - } - OHOS::NWeb::NWebResizeHelper::GetInstance().SetDragResizeStart(true); - if (pre_height > 0) { - drag_bigger_height = true; - } - if (pre_width > 0) { - drag_bigger_width = true; - } - if (drag_bigger_height) { - height = OHOS::NWeb::NWebResizeHelper::GetInstance().GetResizeAdjustValue(height, - pre_height, - true); - } - if (drag_bigger_width) { - width = OHOS::NWeb::NWebResizeHelper::GetInstance().GetResizeAdjustValue(width, - pre_width, - false); - } - OHOS::NWeb::NWebResizeHelper::GetInstance().SetResizeHeightAndWidth(height, width); - if (width > kSurfaceMaxWidth || height > kSurfaceMaxHeight) { - if (draw_mode_ == 0) { - OHOS::NWeb::NWebResizeHelper::GetInstance().RefreshParam(); - WVLOG_E("size too large in surface mode (%{public}u , %{public}u)", width, height); - return; - }; - } - if (nweb_delegate_ == nullptr) { - WVLOG_E("resize failed, nweb delegate is nullptr, nweb_id = %{public}u", nweb_id_); - return; - } - OHOS::NWeb::OhosAdapterHelper::GetInstance() - .CreateSocPerfClientAdapter() - ->ApplySocPerfConfigByIdEx(SOC_PERF_WEB_DRAG_RESIZE_ID, true); - nweb_delegate_->SetDrawMode(draw_mode_); - nweb_delegate_->Resize(width, height, false); - output_handler_->Resize(width, height); -} - void NWebImpl::SetDrawRect(int x, int y, int width, int height) { if (nweb_delegate_) { nweb_delegate_->SetDrawRect(x, y, width, height); diff --git a/ohos_nweb/src/nweb_impl.h b/ohos_nweb/src/nweb_impl.h index d1fbe955b2..8d53ba44e9 100644 --- a/ohos_nweb/src/nweb_impl.h +++ b/ohos_nweb/src/nweb_impl.h @@ -344,10 +344,6 @@ class NWebImpl : public NWeb { #endif std::string GetLastJavascriptProxyCallingFrameUrl() override; - void DragResize(uint32_t width, - uint32_t height, - uint32_t pre_height, - uint32_t pre_width) override; #if defined(OHOS_INPUT_EVENTS) void SetVirtualKeyBoardArg(int32_t width, int32_t height, double keyboard) override; diff --git a/ohos_nweb/src/nweb_resize_helper.h b/ohos_nweb/src/nweb_resize_helper.h deleted file mode 100644 index c0963b3979..0000000000 --- a/ohos_nweb/src/nweb_resize_helper.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef NWEB_RESIZE_HELPER_H -#define NWEB_RESIZE_HELPER_H - -#include -#include -#include "base/logging.h" -#include - -namespace OHOS::NWeb { -class NWebResizeHelper { - public: - static NWebResizeHelper& GetInstance(); - void SetResizeStartTimeStamp(); - void CaculateResizeTime(); - int64_t GetResizeStartTimeStamp(); - int64_t GetResizeTime(); - void RefreshStartTimeStamp(); - void RefreshParam(); - int64_t GetResizeAdjustValue(uint32_t target_length, - int64_t resize_pre_length, - bool isHeight); - void SetResizeHeightAndWidth(int64_t height, int64_t width); - void SetDragResizeStart(bool is_start); - bool IsDragResizeStart(); - -private: - int64_t resize_start_timestamp_ = 0; - int64_t resize_time_ = 0L; - int64_t resize_last_height_ = 0L; - int64_t resize_last_width_ = 0L; - bool is_drag_resize_start_ = false; - -private: - NWebResizeHelper() = default; - ~NWebResizeHelper() = default; -}; -} // namespace OHOS::NWeb - -#endif // NWEB_RESIZE_HELPER_H_ -- Gitee