Ignore contiguous composition event.
[framework/web/webkit-efl.git] / Source / WebKit2 / Shared / WebHitTestResult.h
1 /*
2  * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 #ifndef WebHitTestResult_h
21 #define WebHitTestResult_h
22
23 #include "APIObject.h"
24 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
25 #include <WebCore/Color.h>
26 #endif
27 #include <WebCore/HitTestResult.h>
28 #include <WebCore/KURL.h>
29 #include <wtf/Forward.h>
30 #include <wtf/PassRefPtr.h>
31 #include <wtf/RefPtr.h>
32 #include <wtf/text/WTFString.h>
33
34 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
35 #include "DataReference.h"
36 #endif
37
38 namespace CoreIPC {
39 class ArgumentDecoder;
40 class ArgumentEncoder;
41 }
42
43 namespace WebKit {
44
45 class WebFrame;
46
47 class WebHitTestResult : public APIObject {
48 public:
49     static const Type APIType = TypeHitTestResult;
50
51 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
52     enum HitTestResultContext{
53         HitTestResultContextDocument = 1 << 1,
54         HitTestResultContextLink = 1 << 2,
55         HitTestResultContextImage = 1 << 3,
56         HitTestResultContextMedia = 1 << 4,
57         HitTestResultContextSelection = 1 << 5,
58         HitTestResultContextEditable = 1 << 6,
59         HitTestResultContextText = 1 << 7,
60 #if ENABLE(TIZEN_DRAG_SUPPORT)
61         HitTestResultDragSupport = 1 << 8
62 #endif
63     };
64
65     enum HitTestMode {
66         HitTestModeDefault = 1 << 1,
67         HitTestModeNodeData = 1 << 2,
68         HitTestModeImageData = 1 << 3,
69         HitTestModeAll = HitTestModeDefault | HitTestModeNodeData | HitTestModeImageData
70     };
71 #endif
72
73     struct Data {
74         String absoluteImageURL;
75         String absolutePDFURL;
76         String absoluteLinkURL;
77         String absoluteMediaURL;
78         String linkLabel;
79         String linkTitle;
80         bool isContentEditable;
81
82 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
83         unsigned int context;
84         unsigned int hitTestMode;
85
86 #if ENABLE(TIZEN_DRAG_SUPPORT)
87         bool isDragSupport;
88 #endif
89
90 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
91         WebCore::IntRect focusedRect;
92         WebCore::Color focusedColor;
93 #endif
94
95         struct NodeData {
96             String tagName;
97             String nodeValue;
98             typedef HashMap<String, String> AttributeMap;
99             AttributeMap attributeMap;
100         };
101         NodeData nodeData;
102
103         struct ImageData {
104             Vector<uint8_t> data;
105             String fileNameExtension;
106         } ;
107         ImageData imageData;
108 #endif
109
110         Data()
111         {
112         }
113
114         explicit Data(const WebCore::HitTestResult& hitTestResult)
115             : absoluteImageURL(hitTestResult.absoluteImageURL().string())
116             , absolutePDFURL(hitTestResult.absolutePDFURL().string())
117             , absoluteLinkURL(hitTestResult.absoluteLinkURL().string())
118             , absoluteMediaURL(hitTestResult.absoluteMediaURL().string())
119             , linkLabel(hitTestResult.textContent())
120             , linkTitle(hitTestResult.titleDisplayString())
121             , isContentEditable(hitTestResult.isContentEditable())
122 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
123             , context(HitTestResultContextDocument)
124             , hitTestMode(HitTestModeDefault)
125 #if ENABLE(TIZEN_DRAG_SUPPORT)
126             , isDragSupport(hitTestResult.isDragSupport())
127 #endif
128 #endif
129         {
130         }
131
132         void encode(CoreIPC::ArgumentEncoder*) const;
133         static bool decode(CoreIPC::ArgumentDecoder*, WebHitTestResult::Data&);
134     };
135
136     static PassRefPtr<WebHitTestResult> create(const WebHitTestResult::Data&);
137
138     String absoluteImageURL() const { return m_data.absoluteImageURL; }
139     String absolutePDFURL() const { return m_data.absolutePDFURL; }
140     String absoluteLinkURL() const { return m_data.absoluteLinkURL; }
141     String absoluteMediaURL() const { return m_data.absoluteMediaURL; }
142
143     String linkLabel() const { return m_data.linkLabel; }
144     String linkTitle() const { return m_data.linkTitle; }
145
146     bool isContentEditable() const { return m_data.isContentEditable; }
147 #if ENABLE(TIZEN_DRAG_SUPPORT)
148     bool isDragSupport() const { return m_data.isDragSupport; }
149 #endif
150
151 private:
152     explicit WebHitTestResult(const WebHitTestResult::Data& hitTestResultData)
153         : m_data(hitTestResultData)
154     {
155     }
156
157     virtual Type type() const { return APIType; }
158
159     Data m_data;
160 };
161
162 } // namespace WebKit
163
164 #endif // WebHitTestResult_h