• 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 WEB_HIT_TESTRESULT_H
17 #define WEB_HIT_TESTRESULT_H
18 
19 #include <string>
20 
21 #include "nweb_export.h"
22 
23 namespace OHOS::NWeb {
24 class OHOS_NWEB_EXPORT HitTestResult {
25 public:
HitTestResult()26     HitTestResult() : type_(UNKNOWN_TYPE) {
27     }
28 
29     virtual ~HitTestResult() = default;
30 
31     /**
32      * Default HitTestResult, where the target is unknown.
33      */
34     static const int UNKNOWN_TYPE = 0;
35     /**
36      * This type is no longer used.
37      */
38     static const int ANCHOR_TYPE = 1;
39     /**
40      * HitTestResult for hitting a phone number.
41      */
42     static const int PHONE_TYPE = 2;
43     /**
44      * HitTestResult for hitting a map address.
45      */
46     static const int GEO_TYPE = 3;
47     /**
48      * HitTestResult for hitting an email address.
49      */
50     static const int EMAIL_TYPE = 4;
51     /**
52      * HitTestResult for hitting an HTML::img tag.
53      */
54     static const int IMAGE_TYPE = 5;
55     /**
56      * This type is no longer used.
57      */
58     static const int IMAGE_ANCHOR_TYPE = 6;
59     /**
60      * HitTestResult for hitting a HTML::a tag with src=http.
61      */
62     static const int SRC_ANCHOR_TYPE = 7;
63     /**
64      * HitTestResult for hitting a HTML::a tag with src=http + HTML::img.
65      */
66     static const int SRC_IMAGE_ANCHOR_TYPE = 8;
67     /**
68      * HitTestResult for hitting an edit text area.
69      */
70     static const int EDIT_TEXT_TYPE = 9;
71 
SetType(int type)72     void SetType(int type) {
73         type_ = type;
74     }
75 
SetExtra(std::string extra)76     void SetExtra(std::string extra) {
77         extra_ = extra;
78     }
79 
GetType()80     int GetType() {
81         return type_;
82     }
83 
GetExtra()84     std::string GetExtra() {
85         return extra_;
86     }
87 
88 private:
89     int type_;
90     std::string extra_;
91 };
92 } // namespace OHOS::NWeb
93 
94 #endif  // WEB_HIT_TESTRESULT_H
95