diff --git a/ohos_interface/include/ohos_nweb/nweb.h b/ohos_interface/include/ohos_nweb/nweb.h index 98291b7e59bc647251b42f30237d420f3df5fa21..125e5771b184255920058e6e23292e991062ea54 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 3271deac88b32dfd8a6df60520d76ca4e1a3dc5c..ad002b72a34c026234346873f77e75480952006f 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 44395af9b73ad9d743b27a7f99b1683ae20bc607..8142aedd7d89ceca6f7e19f9ad19fdcacd7b14c1 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 5f5ffd0853bdb8b998e576dfbad396fb977b890f..5c2aeba0db6329f847e906ba4be2e42662768eb0 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 247dace9beb79c10d9febf9571bae659b11c58d0..68f6f649a56760b9574c16965e2d091dd1f5ece6 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 c217907adbdbebca7d3534ae5d957d8e3250073c..051686265c151be5ea3e688209af4e9732fdc3a5 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 63ac35853f84cd4c4e1c33a2e154a67acedcbe02..f776f51f156a9bd6c258bbfe6b79f733708f0574 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 cd81eb1348a5f020c137cf8be67551d68e13dcb1..ae3498dc218aa1734e1951be298a5597fd16afe4 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 d6e3cec9a5d64a2ff31abe072e05e3e0c02c5aca..76bc9f04e9029a4a3340d78ae03ff17f796d8f50 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 e1d13996fed60f3e6dc5c2e0af2d394c8d800650..918f4f828a395fe2cfce3061e1d0cdb189f0457a 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 b6a8ce48bd8039af2aed64260071599d2303b0b3..225b293a19d881a878628cd45b6b5c0766c31fd1 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 c87854849b9d475d7bdfbfe24796efb8c8780548..9a6fb25cb411f14f7e620f866e2ddc675f8f69da 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