From c94eff71fb30f3b6ba13ed61c8c5f61c8f0ec996 Mon Sep 17 00:00:00 2001 From: hexu28huawei Date: Tue, 26 Aug 2025 16:21:27 +0800 Subject: [PATCH] fix web drag effect values Signed-off-by: hexu28huawei --- ohos_interface/include/ohos_nweb/nweb.h | 3 +++ .../include/ohos_nweb/nweb_drag_data.h | 17 +++++++++++++++++ .../bridge/webcore/ark_web_drag_data_impl.cpp | 5 +++++ .../bridge/webcore/ark_web_drag_data_impl.h | 5 +++++ .../webcore/ark_web_drag_event_wrapper.cpp | 15 +++++++++++++++ .../bridge/webcore/ark_web_drag_event_wrapper.h | 8 ++++++++ .../webview/ark_web_drag_data_wrapper.cpp | 4 ++++ .../bridge/webview/ark_web_drag_data_wrapper.h | 10 ++++++++++ .../bridge/webview/ark_web_drag_event_impl.cpp | 15 +++++++++++++++ .../bridge/webview/ark_web_drag_event_impl.h | 6 ++++++ .../ohos_nweb/include/ark_web_drag_data.h | 6 ++++++ .../ohos_nweb/include/ark_web_drag_event.h | 9 +++++++++ 12 files changed, 103 insertions(+) diff --git a/ohos_interface/include/ohos_nweb/nweb.h b/ohos_interface/include/ohos_nweb/nweb.h index 98291b7e5..125e5771b 100644 --- a/ohos_interface/include/ohos_nweb/nweb.h +++ b/ohos_interface/include/ohos_nweb/nweb.h @@ -149,6 +149,9 @@ public: virtual double GetX() = 0; virtual double GetY() = 0; virtual DragAction GetAction() = 0; + virtual OHOS::NWeb::NWebDragData::DragOperation GetDragOperation() const = 0; + virtual OHOS::NWeb::NWebDragData::DragOperationsMask GetAllowedDragOperation() const = 0; + virtual bool IsDragOpValid() const = 0; }; enum class BlurReason : int32_t { diff --git a/ohos_interface/include/ohos_nweb/nweb_drag_data.h b/ohos_interface/include/ohos_nweb/nweb_drag_data.h index 3271deac8..ad002b72a 100644 --- a/ohos_interface/include/ohos_nweb/nweb_drag_data.h +++ b/ohos_interface/include/ohos_nweb/nweb_drag_data.h @@ -40,6 +40,17 @@ public: DRAG_OPERATION_DELETE = 32, DRAG_OPERATION_EVERY = UINT_MAX }; + + // Mask of the allowed drag-and-drop operations. + // These constants match their equivalents in NSDragOperation and + // should not be renumbered. + enum class DragOperationsMask { + DRAG_ALLOW_NONE = 0, + DRAG_ALLOW_COPY = 1, + DRAG_ALLOW_LINK = 2, + DRAG_ALLOW_MOVE = 16, + DRAG_ALLOW_EVERY = UINT_MAX + }; NWebDragData() = default; virtual ~NWebDragData() = default; @@ -92,6 +103,12 @@ public: virtual bool IsDragNewStyle() { return false; } + + // get allowed drag operation mask for current drag. + virtual DragOperationsMask GetAllowedDragOperation() const = 0; + + // set allowed drag operation for current drag. + virtual void SetAllowedDragOperation(DragOperationsMask allowed_op) = 0; }; } // namespace OHOS::NWeb diff --git a/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_drag_data_impl.cpp b/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_drag_data_impl.cpp index 44395af9b..8142aedd7 100644 --- a/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_drag_data_impl.cpp +++ b/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_drag_data_impl.cpp @@ -103,4 +103,9 @@ bool ArkWebDragDataImpl::IsDragNewStyle() return nweb_drag_data_->IsDragNewStyle(); } +int ArkWebDragDataImpl::GetAllowedDragOperation() +{ + return static_cast(nweb_drag_data_->GetAllowedDragOperation()); +} + } // namespace OHOS::ArkWeb diff --git a/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_drag_data_impl.h b/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_drag_data_impl.h index 5f5ffd085..5c2aeba0d 100644 --- a/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_drag_data_impl.h +++ b/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_drag_data_impl.h @@ -109,6 +109,11 @@ public: */ bool IsDragNewStyle() override; + /** + * @brief get allowed drag operation mask for current drag. + */ + int GetAllowedDragOperation() override; + private: std::shared_ptr nweb_drag_data_; }; diff --git a/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_drag_event_wrapper.cpp b/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_drag_event_wrapper.cpp index 247dace9b..68f6f649a 100644 --- a/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_drag_event_wrapper.cpp +++ b/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_drag_event_wrapper.cpp @@ -38,4 +38,19 @@ ArkWebDragAction ArkWebDragEventWrapper::GetAction() return static_cast(ark_web_drag_event_->GetAction()); } +ArkWebDragOperation ArkWebDragEventWrapper::GetDragOperation() const +{ + return static_cast(ark_web_drag_event_->GetDragOperation()); +} + +ArkWebDragOperationsMask ArkWebDragEventWrapper::GetAllowedDragOperation() const +{ + return static_cast(ark_web_drag_event_->GetAllowedDragOperation()); +} + +bool ArkWebDragEventWrapper::IsDragOpValid() const +{ + return ark_web_drag_event_->IsDragOpValid(); +} + } // namespace OHOS::ArkWeb diff --git a/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_drag_event_wrapper.h b/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_drag_event_wrapper.h index c217907ad..051686265 100644 --- a/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_drag_event_wrapper.h +++ b/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_drag_event_wrapper.h @@ -25,6 +25,8 @@ namespace OHOS::ArkWeb { using ArkWebDragAction = OHOS::NWeb::DragAction; +using ArkWebDragOperation = OHOS::NWeb::NWebDragData::DragOperation; +using ArkWebDragOperationsMask = OHOS::NWeb::NWebDragData::DragOperationsMask; class ArkWebDragEventWrapper : public OHOS::NWeb::NWebDragEvent { public: @@ -37,6 +39,12 @@ public: ArkWebDragAction GetAction() override; + ArkWebDragOperation GetDragOperation() const override; + + ArkWebDragOperationsMask GetAllowedDragOperation() const override; + + bool IsDragOpValid() const override; + private: ArkWebRefPtr ark_web_drag_event_; }; diff --git a/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_drag_data_wrapper.cpp b/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_drag_data_wrapper.cpp index 63ac35853..f776f51f1 100644 --- a/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_drag_data_wrapper.cpp +++ b/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_drag_data_wrapper.cpp @@ -148,4 +148,8 @@ bool ArkWebDragDataWrapper::IsDragNewStyle() return ark_web_drag_data_->IsDragNewStyle(); } +OHOS::NWeb::NWebDragData::DragOperationsMask ArkWebDragDataWrapper::GetAllowedDragOperation() const +{ + return static_cast(ark_web_drag_data_->GetAllowedDragOperation()); +} } // namespace OHOS::ArkWeb diff --git a/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_drag_data_wrapper.h b/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_drag_data_wrapper.h index cd81eb134..ae3498dc2 100644 --- a/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_drag_data_wrapper.h +++ b/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_drag_data_wrapper.h @@ -107,6 +107,16 @@ public: */ bool IsDragNewStyle() override; + /** + * @brief get allowed drag operation mask for current drag. + */ + OHOS::NWeb::NWebDragData::DragOperationsMask GetAllowedDragOperation() const override; + + /** + * @brief set allowed drag operation mask. + */ + void SetAllowedDragOperation(DragOperationsMask allowed_op) override {} + private: ArkWebRefPtr ark_web_drag_data_; }; diff --git a/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_drag_event_impl.cpp b/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_drag_event_impl.cpp index d6e3cec9a..76bc9f04e 100644 --- a/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_drag_event_impl.cpp +++ b/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_drag_event_impl.cpp @@ -38,4 +38,19 @@ int ArkWebDragEventImpl::GetAction() return static_cast(nweb_drag_event_->GetAction()); } +int ArkWebDragEventImpl::GetDragOperation() +{ + return static_cast(nweb_drag_event_->GetDragOperation()); +} + +int ArkWebDragEventImpl::GetAllowedDragOperation() +{ + return static_cast(nweb_drag_event_->GetAllowedDragOperation()); +} + +bool ArkWebDragEventImpl::IsDragOpValid() +{ + return nweb_drag_event_->IsDragOpValid(); +} + } // namespace OHOS::ArkWeb diff --git a/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_drag_event_impl.h b/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_drag_event_impl.h index e1d13996f..918f4f828 100644 --- a/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_drag_event_impl.h +++ b/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_drag_event_impl.h @@ -35,6 +35,12 @@ public: int GetAction() override; + int GetDragOperation() override; + + int GetAllowedDragOperation() override; + + bool IsDragOpValid() override; + private: std::shared_ptr nweb_drag_event_; }; diff --git a/ohos_interface/ohos_glue/ohos_nweb/include/ark_web_drag_data.h b/ohos_interface/ohos_glue/ohos_nweb/include/ark_web_drag_data.h index b6a8ce48b..225b293a1 100644 --- a/ohos_interface/ohos_glue/ohos_nweb/include/ark_web_drag_data.h +++ b/ohos_interface/ohos_glue/ohos_nweb/include/ark_web_drag_data.h @@ -121,6 +121,12 @@ public: */ /*--ark web()--*/ virtual bool IsDragNewStyle() = 0; + + /** + * @Description: get allowed drag operation mask. + */ + /*--ark web()--*/ + virtual int GetAllowedDragOperation() = 0; }; } // namespace OHOS::ArkWeb diff --git a/ohos_interface/ohos_glue/ohos_nweb/include/ark_web_drag_event.h b/ohos_interface/ohos_glue/ohos_nweb/include/ark_web_drag_event.h index c87854849..9a6fb25cb 100644 --- a/ohos_interface/ohos_glue/ohos_nweb/include/ark_web_drag_event.h +++ b/ohos_interface/ohos_glue/ohos_nweb/include/ark_web_drag_event.h @@ -32,6 +32,15 @@ public: /*--ark web()--*/ virtual int GetAction() = 0; + + /*--ark web()--*/ + virtual int GetDragOperation() = 0; + + /*--ark web()--*/ + virtual int GetAllowedDragOperation() = 0; + + /*--ark web()--*/ + virtual bool IsDragOpValid() = 0; }; } // namespace OHOS::ArkWeb -- Gitee