1 #ifndef DALI_WEB_ENGINE_HIT_TEST_H
2 #define DALI_WEB_ENGINE_HIT_TEST_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
30 * @brief A class WebEngineHitTest for hit test of web engine.
32 class WebEngineHitTest
36 * @brief Enumeration for mode of hit test.
38 enum class HitTestMode
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.
47 * @brief Enumeration for context of hit test result.
49 enum class ResultContext
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
63 WebEngineHitTest() = default;
68 virtual ~WebEngineHitTest() = default;
71 * @brief Get the context of the hit test.
73 * @return a bitmask of the hit test context.
75 virtual ResultContext GetResultContext() const = 0;
78 * @brief Get the link uri string of the hit test.
80 * @return the URI of the link element in the coordinates of the hit test
82 virtual std::string GetLinkUri() const = 0;
85 * @brief Get the link title of the hit test.
87 * @return the title of the link element in the coordinates of the hit test
89 virtual std::string GetLinkTitle() const = 0;
92 * @brief Get the link label of the hit test.
94 * @return the label of the link element in the coordinates of the hit test
96 virtual std::string GetLinkLabel() const = 0;
99 * @brief Get the image uri of the hit test.
101 * @return the URI of the image element in the coordinates of the hit test
103 virtual std::string GetImageUri() const = 0;
106 * @brief Get the media uri of the hit test.
108 * @return the URI of the media element in the coordinates of the hit test
110 virtual std::string GetMediaUri() const = 0;
113 * @brief Get the tag name of hit element of the hit test.
115 * @return the tag name of the hit element in the coordinates of the hit test
117 virtual std::string GetTagName() const = 0;
120 * @brief Get the node value of hit element of the hit test.
122 * @return the node value of the hit element in the coordinates of the hit test
124 virtual std::string GetNodeValue() const = 0;
127 * @brief Get the attribute data of hit element of the hit test.
129 * @return the attribute data of the hit element in the coordinates of the hit test
131 virtual Dali::Property::Map GetAttributes() const = 0;
134 * @brief Get the image file name extension of hit element of the hit test.
136 * @return the image fiile name extension of the hit element in the coordinates of the hit test
138 virtual std::string GetImageFileNameExtension() const = 0;
141 * @brief Get the image buffer of hit element of the hit test.
143 * @return the image buffer of the hit element in the coordinates of the hit test
145 virtual Dali::PixelData GetImageBuffer() = 0;
148 // specialization has to be done in the same namespace
150 struct EnableBitMaskOperators<WebEngineHitTest::HitTestMode>
152 static const bool ENABLE = true;
156 struct EnableBitMaskOperators<WebEngineHitTest::ResultContext>
158 static const bool ENABLE = true;
163 #endif // DALI_WEB_ENGINE_HIT_TEST_H