diff --git a/content/browser/renderer_host/page_impl.cc b/content/browser/renderer_host/page_impl.cc index fc4c3a4a853d5f9d73b79b0eac9a4304742928e3..257bceae606ebc71bf05235a2d89944910eebb94 100644 --- a/content/browser/renderer_host/page_impl.cc +++ b/content/browser/renderer_host/page_impl.cc @@ -258,4 +258,11 @@ void PageImpl::UpdateEncoding(const std::string& encoding_name) { base::GetCanonicalEncodingNameByAliasName(encoding_name); } +#if BUILDFLAG(IS_OHOS) +void PageImpl::NotifyVirtualKeyboardOverlayRect( + const gfx::Rect& keyboard_rect){ + GetMainDocument().GetAssociatedLocalFrame()->NotifyVirtualKeyboardOverlayRect( + keyboard_rect); +} +#endif } // namespace content diff --git a/content/browser/renderer_host/page_impl.h b/content/browser/renderer_host/page_impl.h index 6e145db0d205b3bdc3d90c6bd828d61e53031f61..8a444c9670fb4997f18b0b7c6644126253c3ff57 100644 --- a/content/browser/renderer_host/page_impl.h +++ b/content/browser/renderer_host/page_impl.h @@ -47,7 +47,9 @@ class CONTENT_EXPORT PageImpl : public Page { void WriteIntoTrace(perfetto::TracedValue context) override; base::WeakPtr GetWeakPtr() override; bool IsPageScaleFactorOne() override; - +#if BUILDFLAG(IS_OHOS) + void NotifyVirtualKeyboardOverlayRect(const gfx::Rect& keyboard_rect); +#endif void UpdateManifestUrl(const GURL& manifest_url); RenderFrameHostImpl& GetMainDocument() const; diff --git a/ohos_nweb/include/nweb.h b/ohos_nweb/include/nweb.h index 83a11aade2277ce2c77d6e305bbf9da682e74e52..1dec8c978e72ddebff590bae53b7bf25a5704c74 100644 --- a/ohos_nweb/include/nweb.h +++ b/ohos_nweb/include/nweb.h @@ -782,6 +782,16 @@ class OHOS_NWEB_EXPORT NWeb : public std::enable_shared_from_this { * Set enable lower the frame rate. */ virtual void SetEnableLowerFrameRate(bool enabled) const = 0; + + /** + * Set the property values for width, height, and keyboard height. + */ + virtual void SetVirtualKeyBoardArg(int32_t width, int32_t height, double keyboard) = 0; + + /** + * Set the virtual keyboard to override the web status. + */ + virtual bool ShouldVirtualKeyboardOverlay() = 0; }; } // namespace OHOS::NWeb diff --git a/ohos_nweb/src/cef_delegate/nweb_delegate.cc b/ohos_nweb/src/cef_delegate/nweb_delegate.cc index 0c0bbce229d70110f5518d89b9e4c8bbe9e8cfc8..f409fbd3776feecef1c8350ef2d75b657ae8ad31 100644 --- a/ohos_nweb/src/cef_delegate/nweb_delegate.cc +++ b/ohos_nweb/src/cef_delegate/nweb_delegate.cc @@ -1889,6 +1889,19 @@ void NWebDelegate::SetShouldFrameSubmissionBeforeDraw(bool should) { } } +void NWebDelegate::SetVirtualKeyBoardArg(int32_t width, int32_t height, double keyboard) { + if (GetBrowser().get()) { + GetBrowser()->GetHost()->SetVirtualKeyBoardArg(width, height, keyboard); + } +} + +bool NWebDelegate::ShouldVirtualKeyboardOverlay() { + if (GetBrowser().get()) { + return GetBrowser()->GetHost()->ShouldVirtualKeyboardOverlay(); + } + return false; +} + void NWebDelegate::SetAudioResumeInterval(int32_t resumeInterval) { if (GetBrowser() == nullptr || GetBrowser()->GetHost() == nullptr) { LOG(ERROR) << "SetAudioResumeInterval can not get browser"; diff --git a/ohos_nweb/src/cef_delegate/nweb_delegate.h b/ohos_nweb/src/cef_delegate/nweb_delegate.h index 5346e2ea808eb96d8cc88568e23f9b0dad9bb7f6..0796aa5534dbefe3bbf2e95af0f70a8e5efb051a 100644 --- a/ohos_nweb/src/cef_delegate/nweb_delegate.h +++ b/ohos_nweb/src/cef_delegate/nweb_delegate.h @@ -212,6 +212,10 @@ class NWebDelegate : public NWebDelegateInterface, public virtual CefRefCount { void PrefetchPage( std::string& url, std::map additionalHttpHeaders) override; + void SetVirtualKeyBoardArg(int32_t width, int32_t height, double keyboard) override; + bool ShouldVirtualKeyboardOverlay() override; + + #if defined (OHOS_NWEB_EX) void SetForceEnableZoom(bool forceEnableZoom) override; bool GetForceEnableZoom() override; diff --git a/ohos_nweb/src/nweb_delegate_interface.h b/ohos_nweb/src/nweb_delegate_interface.h index f77ac2981e18315156e308b39c451a2f21988910..a181153efff5415d01932e0b4f46bbf06c47b7c1 100644 --- a/ohos_nweb/src/nweb_delegate_interface.h +++ b/ohos_nweb/src/nweb_delegate_interface.h @@ -237,6 +237,8 @@ class NWebDelegateInterface virtual void NotifyPopupWindowResult(bool result) = 0; virtual void SetWindowId(uint32_t window_id); virtual void SetToken(void* token) = 0; + virtual void SetVirtualKeyBoardArg(int32_t width, int32_t height, double keyboard) = 0; + virtual bool ShouldVirtualKeyboardOverlay() = 0; }; } // namespace OHOS::NWeb diff --git a/ohos_nweb/src/nweb_impl.cc b/ohos_nweb/src/nweb_impl.cc index 8b7e84d6446ff4f8a59d80a09d32f2f8e7ee71b0..b2cc2a4e80c5660f5bc04d9fa6ba543a955552be 100644 --- a/ohos_nweb/src/nweb_impl.cc +++ b/ohos_nweb/src/nweb_impl.cc @@ -713,6 +713,22 @@ void NWebImpl::SetToken(void* token) { nweb_delegate_->SetToken(token); } +void NWebImpl::SetVirtualKeyBoardArg(int32_t width, int32_t height, double keyboard) { + if (nweb_delegate_ == nullptr) { + WVLOG_E("SetVirtualKeyBoardArg nweb delegate is null"); + return; + } + nweb_delegate_->SetVirtualKeyBoardArg(width, height, keyboard); +} + +bool NWebImpl::ShouldVirtualKeyboardOverlay() { + if (nweb_delegate_ == nullptr) { + WVLOG_E("ShouldVirtualKeyboardOverlay nweb delegate is null"); + return false; + } + return nweb_delegate_->ShouldVirtualKeyboardOverlay(); +} + void NWebImpl::SetNestedScrollMode(const NestedScrollMode& nestedScrollMode) {} const std::shared_ptr NWebImpl::GetPreference() const { diff --git a/ohos_nweb/src/nweb_impl.h b/ohos_nweb/src/nweb_impl.h index f370a4c1aa622cfccc6e5900f5b30559cea4bd68..e90641b97822ca998e281cd3e54a27cc34f651f6 100644 --- a/ohos_nweb/src/nweb_impl.h +++ b/ohos_nweb/src/nweb_impl.h @@ -164,6 +164,8 @@ class NWebImpl : public NWeb { void SetWindowId(uint32_t window_id) override; void SetToken(void* token) override; void SetNestedScrollMode(const NestedScrollMode& nestedScrollMode) override; + void SetVirtualKeyBoardArg(int32_t width, int32_t height, double keyboard) override; + bool ShouldVirtualKeyboardOverlay() override; // For NWebEx static NWebImpl* FromID(int32_t nweb_id);