Ignore contiguous composition event.
[framework/web/webkit-efl.git] / Source / WebKit2 / Shared / EditorState.cpp
1 /*
2  * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #include "config.h"
27 #include "EditorState.h"
28
29 #include "Arguments.h"
30 #include "WebCoreArgumentCoders.h"
31
32 namespace WebKit {
33
34 void EditorState::encode(CoreIPC::ArgumentEncoder* encoder) const
35 {
36     encoder->encode(shouldIgnoreCompositionSelectionChange);
37     encoder->encode(selectionIsNone);
38     encoder->encode(selectionIsRange);
39     encoder->encode(isContentEditable);
40     encoder->encode(isContentRichlyEditable);
41     encoder->encode(isInPasswordField);
42     encoder->encode(hasComposition);
43
44 #if ENABLE(TIZEN_ISF_PORT)
45     encoder->encode(isTapEventHandling);
46     encoder->encode(inputMethodContextID);
47     encoder->encode(inputMethodHints);
48     encoder->encode(surroundingText);
49     encoder->encode(cursorPosition);
50 #endif
51
52 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
53     encoder->encode(editorRect);
54     encoder->encode(updateEditorRectOnly);
55 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
56     encoder->encode(underlineState);
57     encoder->encode(italicState);
58     encoder->encode(boldState);
59     encoder->encode(bgColor);
60     encoder->encode(color);
61     encoder->encode(fontSize);
62 #endif
63 #endif
64
65 #if PLATFORM(QT)
66     encoder->encode(cursorPosition);
67     encoder->encode(anchorPosition);
68     encoder->encode(editorRect);
69     encoder->encode(cursorRect);
70     encoder->encode(compositionRect);
71     encoder->encode(inputMethodHints);
72     encoder->encode(selectedText);
73     encoder->encode(surroundingText);
74 #endif
75 }
76
77 bool EditorState::decode(CoreIPC::ArgumentDecoder* decoder, EditorState& result)
78 {
79     if (!decoder->decode(result.shouldIgnoreCompositionSelectionChange))
80         return false;
81
82     if (!decoder->decode(result.selectionIsNone))
83         return false;
84
85     if (!decoder->decode(result.selectionIsRange))
86         return false;
87
88     if (!decoder->decode(result.isContentEditable))
89         return false;
90
91     if (!decoder->decode(result.isContentRichlyEditable))
92         return false;
93
94     if (!decoder->decode(result.isInPasswordField))
95         return false;
96
97     if (!decoder->decode(result.hasComposition))
98         return false;
99
100 #if ENABLE(TIZEN_ISF_PORT)
101     if (!decoder->decode(result.isTapEventHandling))
102         return false;
103
104     if (!decoder->decode(result.inputMethodContextID))
105         return false;
106
107     if (!decoder->decode(result.inputMethodHints))
108         return false;
109
110     if (!decoder->decode(result.surroundingText))
111         return false;
112
113     if (!decoder->decode(result.cursorPosition))
114         return false;
115 #endif
116
117 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
118     if (!decoder->decode(result.editorRect))
119         return false;
120
121     if (!decoder->decode(result.updateEditorRectOnly))
122         return false;
123
124 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
125     if (!decoder->decode(result.underlineState))
126         return false;
127
128     if (!decoder->decode(result.italicState))
129         return false;
130
131     if (!decoder->decode(result.boldState))
132         return false;
133
134     if (!decoder->decode(result.bgColor))
135         return false;
136
137     if (!decoder->decode(result.color))
138         return false;
139
140     if (!decoder->decode(result.fontSize))
141         return false;
142 #endif
143 #endif
144
145 #if PLATFORM(QT)
146     if (!decoder->decode(result.cursorPosition))
147         return false;
148
149     if (!decoder->decode(result.anchorPosition))
150         return false;
151
152     if (!decoder->decode(result.editorRect))
153         return false;
154
155     if (!decoder->decode(result.cursorRect))
156         return false;
157
158     if (!decoder->decode(result.compositionRect))
159         return false;
160
161     if (!decoder->decode(result.inputMethodHints))
162         return false;
163
164     if (!decoder->decode(result.selectedText))
165         return false;
166
167     if (!decoder->decode(result.surroundingText))
168         return false;
169 #endif
170
171     return true;
172 }
173
174 }