Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsGUIEventIPC_h__ |
michael@0 | 7 | #define nsGUIEventIPC_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "ipc/IPCMessageUtils.h" |
michael@0 | 10 | #include "mozilla/GfxMessageUtils.h" |
michael@0 | 11 | #include "mozilla/dom/Touch.h" |
michael@0 | 12 | #include "mozilla/MiscEvents.h" |
michael@0 | 13 | #include "mozilla/MouseEvents.h" |
michael@0 | 14 | #include "mozilla/TextEvents.h" |
michael@0 | 15 | #include "mozilla/TouchEvents.h" |
michael@0 | 16 | |
michael@0 | 17 | namespace IPC |
michael@0 | 18 | { |
michael@0 | 19 | |
michael@0 | 20 | template<> |
michael@0 | 21 | struct ParamTraits<mozilla::BaseEventFlags> |
michael@0 | 22 | { |
michael@0 | 23 | typedef mozilla::BaseEventFlags paramType; |
michael@0 | 24 | |
michael@0 | 25 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 26 | { |
michael@0 | 27 | aMsg->WriteBytes(&aParam, sizeof(aParam)); |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 31 | { |
michael@0 | 32 | const char* outp; |
michael@0 | 33 | if (!aMsg->ReadBytes(aIter, &outp, sizeof(*aResult))) { |
michael@0 | 34 | return false; |
michael@0 | 35 | } |
michael@0 | 36 | *aResult = *reinterpret_cast<const paramType*>(outp); |
michael@0 | 37 | return true; |
michael@0 | 38 | } |
michael@0 | 39 | }; |
michael@0 | 40 | |
michael@0 | 41 | template<> |
michael@0 | 42 | struct ParamTraits<mozilla::WidgetEvent> |
michael@0 | 43 | { |
michael@0 | 44 | typedef mozilla::WidgetEvent paramType; |
michael@0 | 45 | |
michael@0 | 46 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 47 | { |
michael@0 | 48 | WriteParam(aMsg, (uint8_t) aParam.eventStructType); |
michael@0 | 49 | WriteParam(aMsg, aParam.message); |
michael@0 | 50 | WriteParam(aMsg, aParam.refPoint); |
michael@0 | 51 | WriteParam(aMsg, aParam.time); |
michael@0 | 52 | WriteParam(aMsg, aParam.mFlags); |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 56 | { |
michael@0 | 57 | uint8_t eventStructType = 0; |
michael@0 | 58 | bool ret = ReadParam(aMsg, aIter, &eventStructType) && |
michael@0 | 59 | ReadParam(aMsg, aIter, &aResult->message) && |
michael@0 | 60 | ReadParam(aMsg, aIter, &aResult->refPoint) && |
michael@0 | 61 | ReadParam(aMsg, aIter, &aResult->time) && |
michael@0 | 62 | ReadParam(aMsg, aIter, &aResult->mFlags); |
michael@0 | 63 | aResult->eventStructType = static_cast<nsEventStructType>(eventStructType); |
michael@0 | 64 | return ret; |
michael@0 | 65 | } |
michael@0 | 66 | }; |
michael@0 | 67 | |
michael@0 | 68 | template<> |
michael@0 | 69 | struct ParamTraits<mozilla::WidgetGUIEvent> |
michael@0 | 70 | { |
michael@0 | 71 | typedef mozilla::WidgetGUIEvent paramType; |
michael@0 | 72 | |
michael@0 | 73 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 74 | { |
michael@0 | 75 | WriteParam(aMsg, static_cast<mozilla::WidgetEvent>(aParam)); |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 79 | { |
michael@0 | 80 | return ReadParam(aMsg, aIter, static_cast<mozilla::WidgetEvent*>(aResult)); |
michael@0 | 81 | } |
michael@0 | 82 | }; |
michael@0 | 83 | |
michael@0 | 84 | template<> |
michael@0 | 85 | struct ParamTraits<mozilla::WidgetInputEvent> |
michael@0 | 86 | { |
michael@0 | 87 | typedef mozilla::WidgetInputEvent paramType; |
michael@0 | 88 | |
michael@0 | 89 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 90 | { |
michael@0 | 91 | WriteParam(aMsg, static_cast<mozilla::WidgetGUIEvent>(aParam)); |
michael@0 | 92 | WriteParam(aMsg, aParam.modifiers); |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 96 | { |
michael@0 | 97 | return ReadParam(aMsg, aIter, |
michael@0 | 98 | static_cast<mozilla::WidgetGUIEvent*>(aResult)) && |
michael@0 | 99 | ReadParam(aMsg, aIter, &aResult->modifiers); |
michael@0 | 100 | } |
michael@0 | 101 | }; |
michael@0 | 102 | |
michael@0 | 103 | template<> |
michael@0 | 104 | struct ParamTraits<mozilla::WidgetMouseEventBase> |
michael@0 | 105 | { |
michael@0 | 106 | typedef mozilla::WidgetMouseEventBase paramType; |
michael@0 | 107 | |
michael@0 | 108 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 109 | { |
michael@0 | 110 | WriteParam(aMsg, static_cast<mozilla::WidgetInputEvent>(aParam)); |
michael@0 | 111 | WriteParam(aMsg, aParam.button); |
michael@0 | 112 | WriteParam(aMsg, aParam.buttons); |
michael@0 | 113 | WriteParam(aMsg, aParam.pressure); |
michael@0 | 114 | WriteParam(aMsg, aParam.inputSource); |
michael@0 | 115 | } |
michael@0 | 116 | |
michael@0 | 117 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 118 | { |
michael@0 | 119 | return ReadParam(aMsg, aIter, |
michael@0 | 120 | static_cast<mozilla::WidgetInputEvent*>(aResult)) && |
michael@0 | 121 | ReadParam(aMsg, aIter, &aResult->button) && |
michael@0 | 122 | ReadParam(aMsg, aIter, &aResult->buttons) && |
michael@0 | 123 | ReadParam(aMsg, aIter, &aResult->pressure) && |
michael@0 | 124 | ReadParam(aMsg, aIter, &aResult->inputSource); |
michael@0 | 125 | } |
michael@0 | 126 | }; |
michael@0 | 127 | |
michael@0 | 128 | template<> |
michael@0 | 129 | struct ParamTraits<mozilla::WidgetWheelEvent> |
michael@0 | 130 | { |
michael@0 | 131 | typedef mozilla::WidgetWheelEvent paramType; |
michael@0 | 132 | |
michael@0 | 133 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 134 | { |
michael@0 | 135 | WriteParam(aMsg, static_cast<mozilla::WidgetMouseEventBase>(aParam)); |
michael@0 | 136 | WriteParam(aMsg, aParam.deltaX); |
michael@0 | 137 | WriteParam(aMsg, aParam.deltaY); |
michael@0 | 138 | WriteParam(aMsg, aParam.deltaZ); |
michael@0 | 139 | WriteParam(aMsg, aParam.deltaMode); |
michael@0 | 140 | WriteParam(aMsg, aParam.customizedByUserPrefs); |
michael@0 | 141 | WriteParam(aMsg, aParam.isMomentum); |
michael@0 | 142 | WriteParam(aMsg, aParam.isPixelOnlyDevice); |
michael@0 | 143 | WriteParam(aMsg, aParam.lineOrPageDeltaX); |
michael@0 | 144 | WriteParam(aMsg, aParam.lineOrPageDeltaY); |
michael@0 | 145 | WriteParam(aMsg, static_cast<int32_t>(aParam.scrollType)); |
michael@0 | 146 | WriteParam(aMsg, aParam.overflowDeltaX); |
michael@0 | 147 | WriteParam(aMsg, aParam.overflowDeltaY); |
michael@0 | 148 | } |
michael@0 | 149 | |
michael@0 | 150 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 151 | { |
michael@0 | 152 | int32_t scrollType = 0; |
michael@0 | 153 | bool rv = |
michael@0 | 154 | ReadParam(aMsg, aIter, |
michael@0 | 155 | static_cast<mozilla::WidgetMouseEventBase*>(aResult)) && |
michael@0 | 156 | ReadParam(aMsg, aIter, &aResult->deltaX) && |
michael@0 | 157 | ReadParam(aMsg, aIter, &aResult->deltaY) && |
michael@0 | 158 | ReadParam(aMsg, aIter, &aResult->deltaZ) && |
michael@0 | 159 | ReadParam(aMsg, aIter, &aResult->deltaMode) && |
michael@0 | 160 | ReadParam(aMsg, aIter, &aResult->customizedByUserPrefs) && |
michael@0 | 161 | ReadParam(aMsg, aIter, &aResult->isMomentum) && |
michael@0 | 162 | ReadParam(aMsg, aIter, &aResult->isPixelOnlyDevice) && |
michael@0 | 163 | ReadParam(aMsg, aIter, &aResult->lineOrPageDeltaX) && |
michael@0 | 164 | ReadParam(aMsg, aIter, &aResult->lineOrPageDeltaY) && |
michael@0 | 165 | ReadParam(aMsg, aIter, &scrollType) && |
michael@0 | 166 | ReadParam(aMsg, aIter, &aResult->overflowDeltaX) && |
michael@0 | 167 | ReadParam(aMsg, aIter, &aResult->overflowDeltaY); |
michael@0 | 168 | aResult->scrollType = |
michael@0 | 169 | static_cast<mozilla::WidgetWheelEvent::ScrollType>(scrollType); |
michael@0 | 170 | return rv; |
michael@0 | 171 | } |
michael@0 | 172 | }; |
michael@0 | 173 | |
michael@0 | 174 | template<> |
michael@0 | 175 | struct ParamTraits<mozilla::WidgetMouseEvent> |
michael@0 | 176 | { |
michael@0 | 177 | typedef mozilla::WidgetMouseEvent paramType; |
michael@0 | 178 | |
michael@0 | 179 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 180 | { |
michael@0 | 181 | WriteParam(aMsg, static_cast<mozilla::WidgetMouseEventBase>(aParam)); |
michael@0 | 182 | WriteParam(aMsg, aParam.ignoreRootScrollFrame); |
michael@0 | 183 | WriteParam(aMsg, (uint8_t) aParam.reason); |
michael@0 | 184 | WriteParam(aMsg, (uint8_t) aParam.context); |
michael@0 | 185 | WriteParam(aMsg, (uint8_t) aParam.exit); |
michael@0 | 186 | WriteParam(aMsg, aParam.clickCount); |
michael@0 | 187 | } |
michael@0 | 188 | |
michael@0 | 189 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 190 | { |
michael@0 | 191 | bool rv; |
michael@0 | 192 | uint8_t reason = 0, context = 0, exit = 0; |
michael@0 | 193 | rv = ReadParam(aMsg, aIter, |
michael@0 | 194 | static_cast<mozilla::WidgetMouseEventBase*>(aResult)) && |
michael@0 | 195 | ReadParam(aMsg, aIter, &aResult->ignoreRootScrollFrame) && |
michael@0 | 196 | ReadParam(aMsg, aIter, &reason) && |
michael@0 | 197 | ReadParam(aMsg, aIter, &context) && |
michael@0 | 198 | ReadParam(aMsg, aIter, &exit) && |
michael@0 | 199 | ReadParam(aMsg, aIter, &aResult->clickCount); |
michael@0 | 200 | aResult->reason = |
michael@0 | 201 | static_cast<mozilla::WidgetMouseEvent::reasonType>(reason); |
michael@0 | 202 | aResult->context = |
michael@0 | 203 | static_cast<mozilla::WidgetMouseEvent::contextType>(context); |
michael@0 | 204 | aResult->exit = static_cast<mozilla::WidgetMouseEvent::exitType>(exit); |
michael@0 | 205 | return rv; |
michael@0 | 206 | } |
michael@0 | 207 | }; |
michael@0 | 208 | |
michael@0 | 209 | template<> |
michael@0 | 210 | struct ParamTraits<mozilla::WidgetPointerEvent> |
michael@0 | 211 | { |
michael@0 | 212 | typedef mozilla::WidgetPointerEvent paramType; |
michael@0 | 213 | |
michael@0 | 214 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 215 | { |
michael@0 | 216 | WriteParam(aMsg, static_cast<mozilla::WidgetMouseEvent>(aParam)); |
michael@0 | 217 | WriteParam(aMsg, aParam.pointerId); |
michael@0 | 218 | WriteParam(aMsg, aParam.width); |
michael@0 | 219 | WriteParam(aMsg, aParam.height); |
michael@0 | 220 | WriteParam(aMsg, aParam.tiltX); |
michael@0 | 221 | WriteParam(aMsg, aParam.tiltY); |
michael@0 | 222 | WriteParam(aMsg, aParam.isPrimary); |
michael@0 | 223 | } |
michael@0 | 224 | |
michael@0 | 225 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 226 | { |
michael@0 | 227 | bool rv = |
michael@0 | 228 | ReadParam(aMsg, aIter, static_cast<mozilla::WidgetMouseEvent*>(aResult)) && |
michael@0 | 229 | ReadParam(aMsg, aIter, &aResult->pointerId) && |
michael@0 | 230 | ReadParam(aMsg, aIter, &aResult->width) && |
michael@0 | 231 | ReadParam(aMsg, aIter, &aResult->height) && |
michael@0 | 232 | ReadParam(aMsg, aIter, &aResult->tiltX) && |
michael@0 | 233 | ReadParam(aMsg, aIter, &aResult->tiltY) && |
michael@0 | 234 | ReadParam(aMsg, aIter, &aResult->isPrimary); |
michael@0 | 235 | return rv; |
michael@0 | 236 | } |
michael@0 | 237 | }; |
michael@0 | 238 | |
michael@0 | 239 | template<> |
michael@0 | 240 | struct ParamTraits<mozilla::WidgetTouchEvent> |
michael@0 | 241 | { |
michael@0 | 242 | typedef mozilla::WidgetTouchEvent paramType; |
michael@0 | 243 | |
michael@0 | 244 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 245 | { |
michael@0 | 246 | WriteParam(aMsg, static_cast<const mozilla::WidgetInputEvent&>(aParam)); |
michael@0 | 247 | // Sigh, Touch bites us again! We want to be able to do |
michael@0 | 248 | // WriteParam(aMsg, aParam.touches); |
michael@0 | 249 | const nsTArray< nsRefPtr<mozilla::dom::Touch> >& touches = aParam.touches; |
michael@0 | 250 | WriteParam(aMsg, touches.Length()); |
michael@0 | 251 | for (uint32_t i = 0; i < touches.Length(); ++i) { |
michael@0 | 252 | mozilla::dom::Touch* touch = touches[i]; |
michael@0 | 253 | WriteParam(aMsg, touch->mIdentifier); |
michael@0 | 254 | WriteParam(aMsg, touch->mRefPoint); |
michael@0 | 255 | WriteParam(aMsg, touch->mRadius); |
michael@0 | 256 | WriteParam(aMsg, touch->mRotationAngle); |
michael@0 | 257 | WriteParam(aMsg, touch->mForce); |
michael@0 | 258 | } |
michael@0 | 259 | } |
michael@0 | 260 | |
michael@0 | 261 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 262 | { |
michael@0 | 263 | uint32_t numTouches; |
michael@0 | 264 | if (!ReadParam(aMsg, aIter, |
michael@0 | 265 | static_cast<mozilla::WidgetInputEvent*>(aResult)) || |
michael@0 | 266 | !ReadParam(aMsg, aIter, &numTouches)) { |
michael@0 | 267 | return false; |
michael@0 | 268 | } |
michael@0 | 269 | for (uint32_t i = 0; i < numTouches; ++i) { |
michael@0 | 270 | int32_t identifier; |
michael@0 | 271 | mozilla::LayoutDeviceIntPoint refPoint; |
michael@0 | 272 | nsIntPoint radius; |
michael@0 | 273 | float rotationAngle; |
michael@0 | 274 | float force; |
michael@0 | 275 | if (!ReadParam(aMsg, aIter, &identifier) || |
michael@0 | 276 | !ReadParam(aMsg, aIter, &refPoint) || |
michael@0 | 277 | !ReadParam(aMsg, aIter, &radius) || |
michael@0 | 278 | !ReadParam(aMsg, aIter, &rotationAngle) || |
michael@0 | 279 | !ReadParam(aMsg, aIter, &force)) { |
michael@0 | 280 | return false; |
michael@0 | 281 | } |
michael@0 | 282 | aResult->touches.AppendElement( |
michael@0 | 283 | new mozilla::dom::Touch( |
michael@0 | 284 | identifier, mozilla::LayoutDeviceIntPoint::ToUntyped(refPoint), |
michael@0 | 285 | radius, rotationAngle, force)); |
michael@0 | 286 | } |
michael@0 | 287 | return true; |
michael@0 | 288 | } |
michael@0 | 289 | }; |
michael@0 | 290 | |
michael@0 | 291 | template<> |
michael@0 | 292 | struct ParamTraits<mozilla::WidgetKeyboardEvent> |
michael@0 | 293 | { |
michael@0 | 294 | typedef mozilla::WidgetKeyboardEvent paramType; |
michael@0 | 295 | |
michael@0 | 296 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 297 | { |
michael@0 | 298 | WriteParam(aMsg, static_cast<mozilla::WidgetInputEvent>(aParam)); |
michael@0 | 299 | WriteParam(aMsg, static_cast<uint32_t>(aParam.mKeyNameIndex)); |
michael@0 | 300 | WriteParam(aMsg, aParam.mKeyValue); |
michael@0 | 301 | WriteParam(aMsg, aParam.keyCode); |
michael@0 | 302 | WriteParam(aMsg, aParam.charCode); |
michael@0 | 303 | WriteParam(aMsg, aParam.isChar); |
michael@0 | 304 | WriteParam(aMsg, aParam.mIsRepeat); |
michael@0 | 305 | WriteParam(aMsg, aParam.location); |
michael@0 | 306 | WriteParam(aMsg, aParam.mUniqueId); |
michael@0 | 307 | // An OS-specific native event might be attached in |mNativeKeyEvent|, but |
michael@0 | 308 | // that cannot be copied across process boundaries. |
michael@0 | 309 | } |
michael@0 | 310 | |
michael@0 | 311 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 312 | { |
michael@0 | 313 | uint32_t keyNameIndex = 0; |
michael@0 | 314 | if (ReadParam(aMsg, aIter, |
michael@0 | 315 | static_cast<mozilla::WidgetInputEvent*>(aResult)) && |
michael@0 | 316 | ReadParam(aMsg, aIter, &keyNameIndex) && |
michael@0 | 317 | ReadParam(aMsg, aIter, &aResult->mKeyValue) && |
michael@0 | 318 | ReadParam(aMsg, aIter, &aResult->keyCode) && |
michael@0 | 319 | ReadParam(aMsg, aIter, &aResult->charCode) && |
michael@0 | 320 | ReadParam(aMsg, aIter, &aResult->isChar) && |
michael@0 | 321 | ReadParam(aMsg, aIter, &aResult->mIsRepeat) && |
michael@0 | 322 | ReadParam(aMsg, aIter, &aResult->location) && |
michael@0 | 323 | ReadParam(aMsg, aIter, &aResult->mUniqueId)) |
michael@0 | 324 | { |
michael@0 | 325 | aResult->mKeyNameIndex = static_cast<mozilla::KeyNameIndex>(keyNameIndex); |
michael@0 | 326 | aResult->mNativeKeyEvent = nullptr; |
michael@0 | 327 | return true; |
michael@0 | 328 | } |
michael@0 | 329 | return false; |
michael@0 | 330 | } |
michael@0 | 331 | }; |
michael@0 | 332 | |
michael@0 | 333 | template<> |
michael@0 | 334 | struct ParamTraits<mozilla::TextRangeStyle> |
michael@0 | 335 | { |
michael@0 | 336 | typedef mozilla::TextRangeStyle paramType; |
michael@0 | 337 | |
michael@0 | 338 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 339 | { |
michael@0 | 340 | WriteParam(aMsg, aParam.mDefinedStyles); |
michael@0 | 341 | WriteParam(aMsg, aParam.mLineStyle); |
michael@0 | 342 | WriteParam(aMsg, aParam.mIsBoldLine); |
michael@0 | 343 | WriteParam(aMsg, aParam.mForegroundColor); |
michael@0 | 344 | WriteParam(aMsg, aParam.mBackgroundColor); |
michael@0 | 345 | WriteParam(aMsg, aParam.mUnderlineColor); |
michael@0 | 346 | } |
michael@0 | 347 | |
michael@0 | 348 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 349 | { |
michael@0 | 350 | return ReadParam(aMsg, aIter, &aResult->mDefinedStyles) && |
michael@0 | 351 | ReadParam(aMsg, aIter, &aResult->mLineStyle) && |
michael@0 | 352 | ReadParam(aMsg, aIter, &aResult->mIsBoldLine) && |
michael@0 | 353 | ReadParam(aMsg, aIter, &aResult->mForegroundColor) && |
michael@0 | 354 | ReadParam(aMsg, aIter, &aResult->mBackgroundColor) && |
michael@0 | 355 | ReadParam(aMsg, aIter, &aResult->mUnderlineColor); |
michael@0 | 356 | } |
michael@0 | 357 | }; |
michael@0 | 358 | |
michael@0 | 359 | template<> |
michael@0 | 360 | struct ParamTraits<mozilla::TextRange> |
michael@0 | 361 | { |
michael@0 | 362 | typedef mozilla::TextRange paramType; |
michael@0 | 363 | |
michael@0 | 364 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 365 | { |
michael@0 | 366 | WriteParam(aMsg, aParam.mStartOffset); |
michael@0 | 367 | WriteParam(aMsg, aParam.mEndOffset); |
michael@0 | 368 | WriteParam(aMsg, aParam.mRangeType); |
michael@0 | 369 | WriteParam(aMsg, aParam.mRangeStyle); |
michael@0 | 370 | } |
michael@0 | 371 | |
michael@0 | 372 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 373 | { |
michael@0 | 374 | return ReadParam(aMsg, aIter, &aResult->mStartOffset) && |
michael@0 | 375 | ReadParam(aMsg, aIter, &aResult->mEndOffset) && |
michael@0 | 376 | ReadParam(aMsg, aIter, &aResult->mRangeType) && |
michael@0 | 377 | ReadParam(aMsg, aIter, &aResult->mRangeStyle); |
michael@0 | 378 | } |
michael@0 | 379 | }; |
michael@0 | 380 | |
michael@0 | 381 | template<> |
michael@0 | 382 | struct ParamTraits<mozilla::TextRangeArray> |
michael@0 | 383 | { |
michael@0 | 384 | typedef mozilla::TextRangeArray paramType; |
michael@0 | 385 | |
michael@0 | 386 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 387 | { |
michael@0 | 388 | WriteParam(aMsg, aParam.Length()); |
michael@0 | 389 | for (uint32_t index = 0; index < aParam.Length(); index++) { |
michael@0 | 390 | WriteParam(aMsg, aParam[index]); |
michael@0 | 391 | } |
michael@0 | 392 | } |
michael@0 | 393 | |
michael@0 | 394 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 395 | { |
michael@0 | 396 | uint32_t length; |
michael@0 | 397 | if (!ReadParam(aMsg, aIter, &length)) { |
michael@0 | 398 | return false; |
michael@0 | 399 | } |
michael@0 | 400 | for (uint32_t index = 0; index < length; index++) { |
michael@0 | 401 | mozilla::TextRange textRange; |
michael@0 | 402 | if (!ReadParam(aMsg, aIter, &textRange)) { |
michael@0 | 403 | aResult->Clear(); |
michael@0 | 404 | return false; |
michael@0 | 405 | } |
michael@0 | 406 | aResult->AppendElement(textRange); |
michael@0 | 407 | } |
michael@0 | 408 | return true; |
michael@0 | 409 | } |
michael@0 | 410 | }; |
michael@0 | 411 | |
michael@0 | 412 | template<> |
michael@0 | 413 | struct ParamTraits<mozilla::WidgetTextEvent> |
michael@0 | 414 | { |
michael@0 | 415 | typedef mozilla::WidgetTextEvent paramType; |
michael@0 | 416 | |
michael@0 | 417 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 418 | { |
michael@0 | 419 | WriteParam(aMsg, static_cast<mozilla::WidgetGUIEvent>(aParam)); |
michael@0 | 420 | WriteParam(aMsg, aParam.mSeqno); |
michael@0 | 421 | WriteParam(aMsg, aParam.theText); |
michael@0 | 422 | WriteParam(aMsg, aParam.isChar); |
michael@0 | 423 | bool hasRanges = !!aParam.mRanges; |
michael@0 | 424 | WriteParam(aMsg, hasRanges); |
michael@0 | 425 | if (hasRanges) { |
michael@0 | 426 | WriteParam(aMsg, *aParam.mRanges.get()); |
michael@0 | 427 | } |
michael@0 | 428 | } |
michael@0 | 429 | |
michael@0 | 430 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 431 | { |
michael@0 | 432 | bool hasRanges; |
michael@0 | 433 | if (!ReadParam(aMsg, aIter, |
michael@0 | 434 | static_cast<mozilla::WidgetGUIEvent*>(aResult)) || |
michael@0 | 435 | !ReadParam(aMsg, aIter, &aResult->mSeqno) || |
michael@0 | 436 | !ReadParam(aMsg, aIter, &aResult->theText) || |
michael@0 | 437 | !ReadParam(aMsg, aIter, &aResult->isChar) || |
michael@0 | 438 | !ReadParam(aMsg, aIter, &hasRanges)) { |
michael@0 | 439 | return false; |
michael@0 | 440 | } |
michael@0 | 441 | |
michael@0 | 442 | if (!hasRanges) { |
michael@0 | 443 | aResult->mRanges = nullptr; |
michael@0 | 444 | } else { |
michael@0 | 445 | aResult->mRanges = new mozilla::TextRangeArray(); |
michael@0 | 446 | if (!aResult->mRanges) { |
michael@0 | 447 | return false; |
michael@0 | 448 | } |
michael@0 | 449 | if (!ReadParam(aMsg, aIter, aResult->mRanges.get())) { |
michael@0 | 450 | return false; |
michael@0 | 451 | } |
michael@0 | 452 | } |
michael@0 | 453 | return true; |
michael@0 | 454 | } |
michael@0 | 455 | }; |
michael@0 | 456 | |
michael@0 | 457 | template<> |
michael@0 | 458 | struct ParamTraits<mozilla::WidgetCompositionEvent> |
michael@0 | 459 | { |
michael@0 | 460 | typedef mozilla::WidgetCompositionEvent paramType; |
michael@0 | 461 | |
michael@0 | 462 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 463 | { |
michael@0 | 464 | WriteParam(aMsg, static_cast<mozilla::WidgetGUIEvent>(aParam)); |
michael@0 | 465 | WriteParam(aMsg, aParam.mSeqno); |
michael@0 | 466 | WriteParam(aMsg, aParam.data); |
michael@0 | 467 | } |
michael@0 | 468 | |
michael@0 | 469 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 470 | { |
michael@0 | 471 | return ReadParam(aMsg, aIter, |
michael@0 | 472 | static_cast<mozilla::WidgetGUIEvent*>(aResult)) && |
michael@0 | 473 | ReadParam(aMsg, aIter, &aResult->mSeqno) && |
michael@0 | 474 | ReadParam(aMsg, aIter, &aResult->data); |
michael@0 | 475 | } |
michael@0 | 476 | }; |
michael@0 | 477 | |
michael@0 | 478 | template<> |
michael@0 | 479 | struct ParamTraits<mozilla::WidgetQueryContentEvent> |
michael@0 | 480 | { |
michael@0 | 481 | typedef mozilla::WidgetQueryContentEvent paramType; |
michael@0 | 482 | |
michael@0 | 483 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 484 | { |
michael@0 | 485 | WriteParam(aMsg, static_cast<mozilla::WidgetGUIEvent>(aParam)); |
michael@0 | 486 | WriteParam(aMsg, aParam.mSucceeded); |
michael@0 | 487 | WriteParam(aMsg, aParam.mUseNativeLineBreak); |
michael@0 | 488 | WriteParam(aMsg, aParam.mInput.mOffset); |
michael@0 | 489 | WriteParam(aMsg, aParam.mInput.mLength); |
michael@0 | 490 | WriteParam(aMsg, aParam.mReply.mOffset); |
michael@0 | 491 | WriteParam(aMsg, aParam.mReply.mString); |
michael@0 | 492 | WriteParam(aMsg, aParam.mReply.mRect); |
michael@0 | 493 | WriteParam(aMsg, aParam.mReply.mReversed); |
michael@0 | 494 | WriteParam(aMsg, aParam.mReply.mHasSelection); |
michael@0 | 495 | WriteParam(aMsg, aParam.mReply.mWidgetIsHit); |
michael@0 | 496 | } |
michael@0 | 497 | |
michael@0 | 498 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 499 | { |
michael@0 | 500 | aResult->mWasAsync = true; |
michael@0 | 501 | return ReadParam(aMsg, aIter, |
michael@0 | 502 | static_cast<mozilla::WidgetGUIEvent*>(aResult)) && |
michael@0 | 503 | ReadParam(aMsg, aIter, &aResult->mSucceeded) && |
michael@0 | 504 | ReadParam(aMsg, aIter, &aResult->mUseNativeLineBreak) && |
michael@0 | 505 | ReadParam(aMsg, aIter, &aResult->mInput.mOffset) && |
michael@0 | 506 | ReadParam(aMsg, aIter, &aResult->mInput.mLength) && |
michael@0 | 507 | ReadParam(aMsg, aIter, &aResult->mReply.mOffset) && |
michael@0 | 508 | ReadParam(aMsg, aIter, &aResult->mReply.mString) && |
michael@0 | 509 | ReadParam(aMsg, aIter, &aResult->mReply.mRect) && |
michael@0 | 510 | ReadParam(aMsg, aIter, &aResult->mReply.mReversed) && |
michael@0 | 511 | ReadParam(aMsg, aIter, &aResult->mReply.mHasSelection) && |
michael@0 | 512 | ReadParam(aMsg, aIter, &aResult->mReply.mWidgetIsHit); |
michael@0 | 513 | } |
michael@0 | 514 | }; |
michael@0 | 515 | |
michael@0 | 516 | template<> |
michael@0 | 517 | struct ParamTraits<mozilla::WidgetSelectionEvent> |
michael@0 | 518 | { |
michael@0 | 519 | typedef mozilla::WidgetSelectionEvent paramType; |
michael@0 | 520 | |
michael@0 | 521 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 522 | { |
michael@0 | 523 | WriteParam(aMsg, static_cast<mozilla::WidgetGUIEvent>(aParam)); |
michael@0 | 524 | WriteParam(aMsg, aParam.mSeqno); |
michael@0 | 525 | WriteParam(aMsg, aParam.mOffset); |
michael@0 | 526 | WriteParam(aMsg, aParam.mLength); |
michael@0 | 527 | WriteParam(aMsg, aParam.mReversed); |
michael@0 | 528 | WriteParam(aMsg, aParam.mExpandToClusterBoundary); |
michael@0 | 529 | WriteParam(aMsg, aParam.mSucceeded); |
michael@0 | 530 | WriteParam(aMsg, aParam.mUseNativeLineBreak); |
michael@0 | 531 | } |
michael@0 | 532 | |
michael@0 | 533 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 534 | { |
michael@0 | 535 | return ReadParam(aMsg, aIter, |
michael@0 | 536 | static_cast<mozilla::WidgetGUIEvent*>(aResult)) && |
michael@0 | 537 | ReadParam(aMsg, aIter, &aResult->mSeqno) && |
michael@0 | 538 | ReadParam(aMsg, aIter, &aResult->mOffset) && |
michael@0 | 539 | ReadParam(aMsg, aIter, &aResult->mLength) && |
michael@0 | 540 | ReadParam(aMsg, aIter, &aResult->mReversed) && |
michael@0 | 541 | ReadParam(aMsg, aIter, &aResult->mExpandToClusterBoundary) && |
michael@0 | 542 | ReadParam(aMsg, aIter, &aResult->mSucceeded) && |
michael@0 | 543 | ReadParam(aMsg, aIter, &aResult->mUseNativeLineBreak); |
michael@0 | 544 | } |
michael@0 | 545 | }; |
michael@0 | 546 | |
michael@0 | 547 | template<> |
michael@0 | 548 | struct ParamTraits<nsIMEUpdatePreference> |
michael@0 | 549 | { |
michael@0 | 550 | typedef nsIMEUpdatePreference paramType; |
michael@0 | 551 | |
michael@0 | 552 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 553 | { |
michael@0 | 554 | WriteParam(aMsg, aParam.mWantUpdates); |
michael@0 | 555 | } |
michael@0 | 556 | |
michael@0 | 557 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 558 | { |
michael@0 | 559 | return ReadParam(aMsg, aIter, &aResult->mWantUpdates); |
michael@0 | 560 | } |
michael@0 | 561 | }; |
michael@0 | 562 | |
michael@0 | 563 | template<> |
michael@0 | 564 | struct ParamTraits<mozilla::WidgetPluginEvent> |
michael@0 | 565 | { |
michael@0 | 566 | typedef mozilla::WidgetPluginEvent paramType; |
michael@0 | 567 | |
michael@0 | 568 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 569 | { |
michael@0 | 570 | WriteParam(aMsg, static_cast<mozilla::WidgetGUIEvent>(aParam)); |
michael@0 | 571 | WriteParam(aMsg, aParam.retargetToFocusedDocument); |
michael@0 | 572 | } |
michael@0 | 573 | |
michael@0 | 574 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 575 | { |
michael@0 | 576 | return ReadParam(aMsg, aIter, |
michael@0 | 577 | static_cast<mozilla::WidgetGUIEvent*>(aResult)) && |
michael@0 | 578 | ReadParam(aMsg, aIter, &aResult->retargetToFocusedDocument); |
michael@0 | 579 | } |
michael@0 | 580 | }; |
michael@0 | 581 | |
michael@0 | 582 | } // namespace IPC |
michael@0 | 583 | |
michael@0 | 584 | #endif // nsGUIEventIPC_h__ |
michael@0 | 585 |