(Web Engine) Moved Devel Headers into sub-folder to improve SAM score
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / web-engine / web-engine-hit-test.h
1 #ifndef DALI_WEB_ENGINE_HIT_TEST_H
2 #define DALI_WEB_ENGINE_HIT_TEST_H
3
4 /*
5  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/devel-api/common/bitwise-enum.h>
23 #include <dali/public-api/images/pixel-data.h>
24 #include <dali/public-api/object/property-map.h>
25 #include <string>
26
27 namespace Dali
28 {
29 /**
30  * @brief A class WebEngineHitTest for hit test of web engine.
31  */
32 class WebEngineHitTest
33 {
34 public:
35   /**
36    * @brief Enumeration for mode of hit test.
37    */
38   enum class HitTestMode
39   {
40     DEFAULT    = 1 << 1,                           ///< link data.
41     NODE_DATA  = 1 << 2,                           ///< extra node data(tag name, node value, attribute infomation, etc).
42     IMAGE_DATA = 1 << 3,                           ///< extra image data(image data, image data length, image file name exteionsion, etc).
43     ALL        = DEFAULT | NODE_DATA | IMAGE_DATA, ///< all data.
44   };
45
46   /**
47    * @brief Enumeration for context of hit test result.
48    */
49   enum class ResultContext
50   {
51     DOCUMENT  = 1 << 1, ///< anywhere in the document.
52     LINK      = 1 << 2, ///< a hyperlink element.
53     IMAGE     = 1 << 3, ///< an image element.
54     MEDIA     = 1 << 4, ///< a video or audio element.
55     SELECTION = 1 << 5, ///< the area is selected.
56     EDITABLE  = 1 << 6, ///< the area is editable
57     TEXT      = 1 << 7, ///< the area is text
58   };
59
60   /**
61    * @brief Constructor.
62    */
63   WebEngineHitTest() = default;
64
65   /**
66    * @brief Destructor.
67    */
68   virtual ~WebEngineHitTest() = default;
69
70   /**
71    * @brief Get the context of the hit test.
72    *
73    * @return a bitmask of the hit test context.
74    */
75   virtual ResultContext GetResultContext() const = 0;
76
77   /**
78    * @brief Get the link uri string of the hit test.
79    *
80    * @return the URI of the link element in the coordinates of the hit test
81    */
82   virtual std::string GetLinkUri() const = 0;
83
84   /**
85    * @brief Get the link title of the hit test.
86    *
87    * @return the title of the link element in the coordinates of the hit test
88    */
89   virtual std::string GetLinkTitle() const = 0;
90
91   /**
92    * @brief Get the link label of the hit test.
93    *
94    * @return the label of the link element in the coordinates of the hit test
95    */
96   virtual std::string GetLinkLabel() const = 0;
97
98   /**
99    * @brief Get the image uri of the hit test.
100    *
101    * @return the URI of the image element in the coordinates of the hit test
102    */
103   virtual std::string GetImageUri() const = 0;
104
105   /**
106    * @brief Get the media uri of the hit test.
107    *
108    * @return the URI of the media element in the coordinates of the hit test
109    */
110   virtual std::string GetMediaUri() const = 0;
111
112   /**
113    * @brief Get the tag name of hit element of the hit test.
114    *
115    * @return the tag name of the hit element in the coordinates of the hit test
116    */
117   virtual std::string GetTagName() const = 0;
118
119   /**
120    * @brief Get the node value of hit element of the hit test.
121    *
122    * @return the node value of the hit element in the coordinates of the hit test
123    */
124   virtual std::string GetNodeValue() const = 0;
125
126   /**
127    * @brief Get the attribute data of hit element of the hit test.
128    *
129    * @return the attribute data of the hit element in the coordinates of the hit test
130    */
131   virtual Dali::Property::Map GetAttributes() const = 0;
132
133   /**
134    * @brief Get the image file name extension of hit element of the hit test.
135    *
136    * @return the image fiile name extension of the hit element in the coordinates of the hit test
137    */
138   virtual std::string GetImageFileNameExtension() const = 0;
139
140   /**
141    * @brief Get the image buffer of hit element of the hit test.
142    *
143    * @return the image buffer of the hit element in the coordinates of the hit test
144    */
145   virtual Dali::PixelData GetImageBuffer() = 0;
146 };
147
148 // specialization has to be done in the same namespace
149 template<>
150 struct EnableBitMaskOperators<WebEngineHitTest::HitTestMode>
151 {
152   static const bool ENABLE = true;
153 };
154
155 template<>
156 struct EnableBitMaskOperators<WebEngineHitTest::ResultContext>
157 {
158   static const bool ENABLE = true;
159 };
160
161 } // namespace Dali
162
163 #endif // DALI_WEB_ENGINE_HIT_TEST_H