diff --git a/ohos_nweb/src/cef_delegate/nweb_delegate.cc b/ohos_nweb/src/cef_delegate/nweb_delegate.cc index 318715fe41ce76e705eb6641849fa7a36ceb27a8..828af732800aa9d584a2e1812f0c8d6b3160aa85 100644 --- a/ohos_nweb/src/cef_delegate/nweb_delegate.cc +++ b/ohos_nweb/src/cef_delegate/nweb_delegate.cc @@ -1482,6 +1482,13 @@ void NWebDelegate::InitialScale(float scale) const { } } +void NWebDelegate::PutOptimizeParserBudgetEnabled(bool enable) const { + 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 e4df07143b89142f653fc665fb37c4286cc7f259..252461126730feba996cd40f900bacec705a85dd 100644 --- a/ohos_nweb/src/cef_delegate/nweb_delegate.h +++ b/ohos_nweb/src/cef_delegate/nweb_delegate.h @@ -142,6 +142,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 de79ac6ae7ec6acd559042be82a6d91dd6e2e8ca..5c4ac69702b423428466e19404ff02605a2ef54b 100644 --- a/ohos_nweb/src/nweb_delegate_interface.h +++ b/ohos_nweb/src/nweb_delegate_interface.h @@ -196,6 +196,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 010a7cdd2e1add3df7ebce7f3d874fd8e08da6a1..a942f6353a6cd3941c55658425f15a21140cbd81 100644 --- a/ohos_nweb/src/nweb_impl.cc +++ b/ohos_nweb/src/nweb_impl.cc @@ -1310,6 +1310,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 b6437ccf3a4e55b2f7ea71b8272afee53d3074d6..e7ff164969ff7cc8b95cb5cb04f231f0df04128d 100644 --- a/ohos_nweb/src/nweb_impl.h +++ b/ohos_nweb/src/nweb_impl.h @@ -93,6 +93,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;