diff --git a/ohos_nweb/src/cef_delegate/nweb_delegate.cc b/ohos_nweb/src/cef_delegate/nweb_delegate.cc index f130beefa55b787cb14d11b4db70a0732335052f..b1b4ac94a5a5336a7c8d004ef7c1261d60c940a8 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 cd559955c1537a62624e182b4fdd0aa0d79740c3..58522a4e070e5cb51e51d7a644988711c3d1da41 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 3d0103e02acaee98b6afa348a60327c418301920..cf4e327de01d2e3af5fae5bea07376f22af078e8 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 5ae1f5b3effb8c5d77e95b44bfbb8e9f27d7d763..c25938e2d6e76e84fa0ddd054d2c306fbeff7403 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 5f2fbc3148c19d7479ad52256ddacc68655f55a3..ca89c93ee664316f23269c7c5ca0084776327df7 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;