From fcd53ccbc29e86532658f8ca04050f7734e5e941 Mon Sep 17 00:00:00 2001 From: zhufenghao Date: Sun, 8 Oct 2023 15:28:31 +0800 Subject: [PATCH] =?UTF-8?q?web=E5=86=85=E6=A0=B8=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=B5=8C=E5=A5=97=E6=BB=9A=E5=8A=A8=E4=BA=8B=E4=BB=B6=E4=B8=8A?= =?UTF-8?q?=E6=8A=A5=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhufenghao --- ohos_nweb/include/nweb.h | 16 ++++++++++++++-- ohos_nweb/include/nweb_handler.h | 6 +++++- .../src/cef_delegate/nweb_render_handler.cc | 9 +++++++++ ohos_nweb/src/cef_delegate/nweb_render_handler.h | 6 ++++++ ohos_nweb/src/nweb_impl.cc | 2 ++ ohos_nweb/src/nweb_impl.h | 1 + 6 files changed, 37 insertions(+), 3 deletions(-) diff --git a/ohos_nweb/include/nweb.h b/ohos_nweb/include/nweb.h index 7ab882ed1c..759f0bc7c4 100644 --- a/ohos_nweb/include/nweb.h +++ b/ohos_nweb/include/nweb.h @@ -20,17 +20,17 @@ #include #include #include -#include "nweb_export.h" #include "nweb_download_callback.h" #include "nweb_drag_data.h" +#include "nweb_export.h" #include "nweb_find_callback.h" #include "nweb_history_list.h" +#include "nweb_hit_testresult.h" #include "nweb_javascript_result_callback.h" #include "nweb_preference.h" #include "nweb_release_surface_callback.h" #include "nweb_value_callback.h" -#include "nweb_hit_testresult.h" #include "nweb_web_message.h" namespace OHOS::NWeb { @@ -125,6 +125,13 @@ struct OHOS_NWEB_EXPORT NWebDOHConfig { std::string doh_config = ""; }; +enum class NestedScrollMode : int32_t { + SELF_ONLY = 0, + SELF_FIRST = 1, + PARENT_FIRST = 2, + PARALLEL = 3, +}; + using WebState = std::shared_ptr>; using SetKeepScreenOn = std::function; @@ -765,6 +772,11 @@ class OHOS_NWEB_EXPORT NWeb : public std::enable_shared_from_this { * Set the token. */ virtual void SetToken(void* token) = 0; + + /** + * Set the nested scroll mode. + */ + virtual void SetNestedScrollMode(const NestedScrollMode& nestedScrollMode) = 0; }; } // namespace OHOS::NWeb diff --git a/ohos_nweb/include/nweb_handler.h b/ohos_nweb/include/nweb_handler.h index cd301d1770..eda861f06d 100755 --- a/ohos_nweb/include/nweb_handler.h +++ b/ohos_nweb/include/nweb_handler.h @@ -557,7 +557,7 @@ public: * @param playing Whether the audio is playing or not. */ virtual void OnAudioStateChanged(bool playing) {} - + /** * @brief Called when the first content rendering of web page. * @param navigationStartTick Absolute navigation start time, as TimeTicks. @@ -601,6 +601,10 @@ public: * screen capture permission. */ virtual void OnScreenCaptureRequest(std::shared_ptr request) {} + + virtual void OnOverScrollFlingVelocity(float xVelocity, float yVelocity, bool isFling) {} + + virtual void OnOverScrollFlingEnd() {} }; } // namespace OHOS::NWeb diff --git a/ohos_nweb/src/cef_delegate/nweb_render_handler.cc b/ohos_nweb/src/cef_delegate/nweb_render_handler.cc index fcee780d82..ddf9f5c414 100755 --- a/ohos_nweb/src/cef_delegate/nweb_render_handler.cc +++ b/ohos_nweb/src/cef_delegate/nweb_render_handler.cc @@ -448,4 +448,13 @@ void NWebRenderHandler::OnOverscroll(CefRefPtr browser, void NWebRenderHandler::SetIrregularDragBackground(bool is_irregular_background) { is_irregular_drag_background_ = is_irregular_background; } + +void NWebRenderHandler::OnOverScrollFlingVelocity(CefRefPtr browser, + const float x, + const float y, + bool is_fling) { +} + +void NWebRenderHandler::OnOverScrollFlingEnd(CefRefPtr browser) { +} } // namespace OHOS::NWeb diff --git a/ohos_nweb/src/cef_delegate/nweb_render_handler.h b/ohos_nweb/src/cef_delegate/nweb_render_handler.h index 84b632a734..551baad219 100755 --- a/ohos_nweb/src/cef_delegate/nweb_render_handler.h +++ b/ohos_nweb/src/cef_delegate/nweb_render_handler.h @@ -121,6 +121,12 @@ class NWebRenderHandler : public CefRenderHandler { void OnOverscroll(CefRefPtr browser, const float x, const float y) override; + + void OnOverScrollFlingVelocity(CefRefPtr browser, + const float x, + const float y, + bool is_fling) override; + void OnOverScrollFlingEnd(CefRefPtr browser) override; /* CefRenderHandler method end */ std::shared_ptr GetTouchHandleState( diff --git a/ohos_nweb/src/nweb_impl.cc b/ohos_nweb/src/nweb_impl.cc index 4e6e9c5892..be0561b434 100644 --- a/ohos_nweb/src/nweb_impl.cc +++ b/ohos_nweb/src/nweb_impl.cc @@ -705,6 +705,8 @@ void NWebImpl::SetToken(void* token) { nweb_delegate_->SetToken(token); } +void NWebImpl::SetNestedScrollMode(const NestedScrollMode& nestedScrollMode) {} + const std::shared_ptr NWebImpl::GetPreference() const { if (nweb_delegate_ == nullptr) { return nullptr; diff --git a/ohos_nweb/src/nweb_impl.h b/ohos_nweb/src/nweb_impl.h index dc25d182bd..c67c69e2a0 100644 --- a/ohos_nweb/src/nweb_impl.h +++ b/ohos_nweb/src/nweb_impl.h @@ -162,6 +162,7 @@ class NWebImpl : public NWeb { void OnWebviewShow() const override; void SetWindowId(uint32_t window_id) override; void SetToken(void* token) override; + void SetNestedScrollMode(const NestedScrollMode& nestedScrollMode) override; // For NWebEx static NWebImpl* FromID(int32_t nweb_id); -- Gitee