From b536ef722e8af704866a4da945fba39f20904391 Mon Sep 17 00:00:00 2001 From: taozhuowei Date: Thu, 19 Dec 2024 08:45:07 +0000 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E6=AE=B5=E6=B8=B2=E6=9F=93=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: taozhuowei --- ohos_nweb/src/cef_delegate/nweb_delegate.cc | 7 +++++++ ohos_nweb/src/cef_delegate/nweb_delegate.h | 1 + ohos_nweb/src/nweb_delegate_interface.h | 1 + ohos_nweb/src/nweb_impl.cc | 8 ++++++++ ohos_nweb/src/nweb_impl.h | 1 + 5 files changed, 18 insertions(+) diff --git a/ohos_nweb/src/cef_delegate/nweb_delegate.cc b/ohos_nweb/src/cef_delegate/nweb_delegate.cc index f130beefa5..b1b4ac94a5 100644 --- a/ohos_nweb/src/cef_delegate/nweb_delegate.cc +++ b/ohos_nweb/src/cef_delegate/nweb_delegate.cc @@ -1456,6 +1456,13 @@ void NWebDelegate::InitialScale(float scale) const { } } +void NWebDelegate::PutOptimizeParserBudgetEnabled(bool enable) { + LOG(DEBUG) << "NWebDelegate::PutOptimizeParserBudgetEnabled"; + if (GetBrowser().get()) { + GetBrowser()->GetHost()->SetOptimizeParserBudgetEnabled(enable); + } +} + void NWebDelegate::OnPause() { LOG(INFO) << "NWebDelegate::OnPause, nweb_id = " << nweb_id_; TRACE_EVENT1("base", "NWebDelegate::OnPause", "nweb id = ", nweb_id_); diff --git a/ohos_nweb/src/cef_delegate/nweb_delegate.h b/ohos_nweb/src/cef_delegate/nweb_delegate.h index cd559955c1..58522a4e07 100644 --- a/ohos_nweb/src/cef_delegate/nweb_delegate.h +++ b/ohos_nweb/src/cef_delegate/nweb_delegate.h @@ -143,6 +143,7 @@ class NWebDelegate : public NWebDelegateInterface, public virtual CefRefCount { void ExecuteJavaScript(const std::string& code) const override; void PutBackgroundColor(int color) const override; void InitialScale(float scale) const override; + void PutOptimizeParserBudgetEnabled(bool enable) const override; void OnPause() override; void OnContinue() override; void WebComponentsBlur() override; diff --git a/ohos_nweb/src/nweb_delegate_interface.h b/ohos_nweb/src/nweb_delegate_interface.h index 3d0103e02a..cf4e327de0 100644 --- a/ohos_nweb/src/nweb_delegate_interface.h +++ b/ohos_nweb/src/nweb_delegate_interface.h @@ -193,6 +193,7 @@ class NWebDelegateInterface virtual void ExecuteJavaScript(const std::string& code) const = 0; virtual void PutBackgroundColor(int color) const = 0; virtual void InitialScale(float scale) const = 0; + virtual void PutOptimizeParserBudgetEnabled(bool enable) const = 0; virtual void OnPause() = 0; virtual void OnContinue() = 0; virtual void WebComponentsBlur() = 0; diff --git a/ohos_nweb/src/nweb_impl.cc b/ohos_nweb/src/nweb_impl.cc index 5ae1f5b3ef..c25938e2d6 100644 --- a/ohos_nweb/src/nweb_impl.cc +++ b/ohos_nweb/src/nweb_impl.cc @@ -1295,6 +1295,14 @@ void NWebImpl::InitialScale(float scale) { nweb_delegate_->InitialScale(scale); } +void NWebImpl::PutOptimizeParserBudgetEnabled(bool enable) +{ + if (nweb_delegate_ == nullptr) { + return; + } + nweb_delegate_->PutOptimizeParserBudgetEnabled(true); +} + void NWebImpl::OnPause() { if (!GetWebOptimizationValue()) { LOG(DEBUG) << "WebOptimization disabled."; diff --git a/ohos_nweb/src/nweb_impl.h b/ohos_nweb/src/nweb_impl.h index 5f2fbc3148..ca89c93ee6 100644 --- a/ohos_nweb/src/nweb_impl.h +++ b/ohos_nweb/src/nweb_impl.h @@ -84,6 +84,7 @@ class NWebImpl : public NWeb { void ExecuteJavaScript(const std::string& code) override; void PutBackgroundColor(int color) override; void InitialScale(float scale) override; + void PutOptimizeParserBudgetEnabled(bool enable) override; void OnPause() override; void OnContinue() override; void WebComponentsBlur() override; -- Gitee