Ignore contiguous composition event.
[framework/web/webkit-efl.git] / Source / WebKit2 / Shared / WebHitTestResult.cpp
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 #include "config.h"
21 #include "WebHitTestResult.h"
22
23 #include "WebCoreArgumentCoders.h"
24
25 #include <WebCore/KURL.h>
26 #include <wtf/text/WTFString.h>
27
28 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
29 #include <wtf/text/StringHash.h>
30 #endif
31
32 using namespace WebCore;
33
34 namespace WebKit {
35
36 PassRefPtr<WebHitTestResult> WebHitTestResult::create(const WebHitTestResult::Data& hitTestResultData)
37 {
38     return adoptRef(new WebHitTestResult(hitTestResultData));
39 }
40
41 void WebHitTestResult::Data::encode(CoreIPC::ArgumentEncoder* encoder) const
42 {
43     encoder->encode(absoluteImageURL);
44     encoder->encode(absolutePDFURL);
45     encoder->encode(absoluteLinkURL);
46     encoder->encode(absoluteMediaURL);
47     encoder->encode(linkLabel);
48     encoder->encode(linkTitle);
49     encoder->encode(isContentEditable);
50
51 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
52     encoder->encode(context);
53     encoder->encode(hitTestMode);
54 #if ENABLE(TIZEN_DRAG_SUPPORT)
55     encoder->encode(isDragSupport);
56 #endif
57 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
58     encoder->encode(focusedRect);
59     encoder->encode(focusedColor);
60 #endif
61
62     if (hitTestMode & HitTestModeNodeData) {
63         encoder->encode(nodeData.tagName);
64         encoder->encode(nodeData.nodeValue);
65         encoder->encode(nodeData.attributeMap);
66     }
67
68     if ((hitTestMode & HitTestModeImageData) && (context & HitTestResultContextImage)) {
69         encoder->encode(CoreIPC::DataReference(imageData.data));
70         encoder->encode(imageData.fileNameExtension);
71     }
72 #endif
73 }
74
75 bool WebHitTestResult::Data::decode(CoreIPC::ArgumentDecoder* decoder, WebHitTestResult::Data& hitTestResultData)
76 {
77     if (!decoder->decode(hitTestResultData.absoluteImageURL)
78         || !decoder->decode(hitTestResultData.absolutePDFURL)
79         || !decoder->decode(hitTestResultData.absoluteLinkURL)
80         || !decoder->decode(hitTestResultData.absoluteMediaURL)
81         || !decoder->decode(hitTestResultData.linkLabel)
82         || !decoder->decode(hitTestResultData.linkTitle)
83         || !decoder->decode(hitTestResultData.isContentEditable))
84         return false;
85
86 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
87     if (!decoder->decode(hitTestResultData.context))
88         return false;
89
90     if (!decoder->decode(hitTestResultData.hitTestMode))
91         return false;
92
93 #if ENABLE(TIZEN_DRAG_SUPPORT)
94     if (!decoder->decode(hitTestResultData.isDragSupport))
95         return false;
96 #endif
97
98 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
99     if (!decoder->decode(hitTestResultData.focusedRect))
100         return false;
101
102     if (!decoder->decode(hitTestResultData.focusedColor))
103         return false;
104 #endif
105
106     if (hitTestResultData.hitTestMode & HitTestModeNodeData) {
107         if (!decoder->decode(hitTestResultData.nodeData.tagName))
108             return false;
109
110         if (!decoder->decode(hitTestResultData.nodeData.nodeValue))
111             return false;
112
113         if (!decoder->decode(hitTestResultData.nodeData.attributeMap))
114             return false;
115     }
116
117     if ((hitTestResultData.hitTestMode & HitTestModeImageData) && (hitTestResultData.context & HitTestResultContextImage)) {
118         CoreIPC::DataReference data;
119         if (!decoder->decode(data))
120             return false;
121         hitTestResultData.imageData.data.append(data.data(), data.size());
122
123         if (!decoder->decode(hitTestResultData.imageData.fileNameExtension))
124             return false;
125     }
126 #endif
127
128     return true;
129 }
130
131 } // WebKit