• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef NWEB_DRAG_DATA_H
17 #define NWEB_DRAG_DATA_H
18 
19 #include <memory>
20 #include <string>
21 #include "nweb_export.h"
22 
23 namespace OHOS::NWeb {
24 class OHOS_NWEB_EXPORT NWebDragData {
25 public:
26 ///
27 // "Verb" of a drag-and-drop operation as negotiated between the source and
28 // destination. These constants match their equivalents in WebCore's
29 // DragActions.h and should not be renumbered.
30 ///
31     enum class DragOperation : unsigned char {
32         DRAG_OPERATION_NONE = 0,
33         DRAG_OPERATION_COPY = 1,
34         DRAG_OPERATION_LINK = 2,
35         DRAG_OPERATION_GENERIC = 4,
36         DRAG_OPERATION_PRIVATE = 8,
37         DRAG_OPERATION_MOVE = 16,
38         DRAG_OPERATION_DELETE = 32,
39         DRAG_OPERATION_EVERY = UINT_MAX
40     };
41     NWebDragData() = default;
42     virtual ~NWebDragData() = default;
43 
44     // get the link URL that is being dragged.
45     virtual std::string GetLinkURL() = 0;
46 
47     // get the plain text that is being dragged.
48     virtual std::string GetFragmentText() = 0;
49 
50     // get the text/html fragment that is being dragged.
51     virtual std::string GetFragmentHtml() = 0;
52 
53     // get the image representation of drag data.
54     virtual bool GetPixelMapSetting(const void** data, size_t& len, int& width, int& height) = 0;
55 
56     // set the text/html fragment that is being dragged.
57     virtual bool SetFragmentHtml(std::string& html) = 0;
58 
59     // set the image representation of drag data.
60     virtual bool SetPixelMapSetting(const void* data, size_t len, int width, int height) = 0;
61 
62     // set the link URL that is being dragged.
63     virtual bool SetLinkURL(std::string& url) = 0;
64 
65     // set the plain text that is being dragged.
66     virtual bool SetFragmentText(std::string& Text) = 0;
67 
68     // get the title associated with the link that is being dragged.
69     virtual std::string GetLinkTitle() = 0;
70 
71     // set the title associated with the link that is being dragged.
72     virtual bool SetLinkTitle(std::string& title) = 0;
73 
74     // get the positon of the drag point.
75     virtual void GetDragStartPosition(int& x, int& y) = 0;
76 
77     // is single iamge that is being dragged.
78     virtual bool IsSingleImageContent() = 0;
79 };
80 }
81 #endif
82