/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef mozilla_layers_LayersMessageUtils #define mozilla_layers_LayersMessageUtils #include #include #include "FrameMetrics.h" #include "VsyncSource.h" #include "chrome/common/ipc_message_utils.h" #include "ipc/EnumSerializer.h" #include "ipc/IPCMessageUtils.h" #include "mozilla/MotionPathUtils.h" #include "mozilla/ServoBindings.h" #include "mozilla/ipc/ByteBuf.h" #include "mozilla/layers/APZInputBridge.h" #include "mozilla/layers/AsyncDragMetrics.h" #include "mozilla/layers/CompositorOptions.h" #include "mozilla/layers/CompositorTypes.h" #include "mozilla/layers/FocusTarget.h" #include "mozilla/layers/GeckoContentControllerTypes.h" #include "mozilla/layers/KeyboardMap.h" #include "mozilla/layers/LayersTypes.h" #include "mozilla/layers/MatrixMessage.h" #include "mozilla/layers/OverlayInfo.h" #include "mozilla/layers/RepaintRequest.h" #include "mozilla/layers/ScrollbarData.h" #include "nsSize.h" #include "mozilla/layers/DoubleTapToZoom.h" // For ParamTraits, could be moved to cpp file #include "ipc/nsGUIEventIPC.h" #include "mozilla/GfxMessageUtils.h" #include "mozilla/ipc/ByteBufUtils.h" #ifdef _MSC_VER # pragma warning(disable : 4800) #endif namespace IPC { template <> struct ParamTraits : public PlainOldDataSerializer {}; template struct ParamTraits> : public PlainOldDataSerializer> {}; template <> struct ParamTraits : public PlainOldDataSerializer {}; template <> struct ParamTraits { typedef mozilla::VsyncEvent paramType; static void Write(MessageWriter* writer, const paramType& param) { WriteParam(writer, param.mId); WriteParam(writer, param.mTime); WriteParam(writer, param.mOutputTime); } static bool Read(MessageReader* reader, paramType* result) { return ReadParam(reader, &result->mId) && ReadParam(reader, &result->mTime) && ReadParam(reader, &result->mOutputTime); } }; template <> struct ParamTraits { typedef mozilla::layers::MatrixMessage paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mMatrix); WriteParam(aWriter, aParam.mTopLevelViewportVisibleRectInBrowserCoords); WriteParam(aWriter, aParam.mLayersId); } static bool Read(MessageReader* aReader, paramType* aResult) { return ReadParam(aReader, &aResult->mMatrix) && ReadParam(aReader, &aResult->mTopLevelViewportVisibleRectInBrowserCoords) && ReadParam(aReader, &aResult->mLayersId); } }; template <> struct ParamTraits : public PlainOldDataSerializer {}; template <> struct ParamTraits : public ContiguousEnumSerializer {}; template <> struct ParamTraits : public ContiguousEnumSerializer< mozilla::layers::LayersBackend, mozilla::layers::LayersBackend::LAYERS_NONE, mozilla::layers::LayersBackend::LAYERS_LAST> {}; template <> struct ParamTraits : public ContiguousEnumSerializer< mozilla::layers::WebRenderBackend, mozilla::layers::WebRenderBackend::HARDWARE, mozilla::layers::WebRenderBackend::LAST> {}; template <> struct ParamTraits : public ContiguousEnumSerializer< mozilla::layers::WebRenderCompositor, mozilla::layers::WebRenderCompositor::DRAW, mozilla::layers::WebRenderCompositor::LAST> {}; template <> struct ParamTraits : public ContiguousEnumSerializer {}; template <> struct ParamTraits : public ContiguousEnumSerializerInclusive< mozilla::layers::ScaleMode, mozilla::layers::ScaleMode::SCALE_NONE, mozilla::layers::kHighestScaleMode> {}; template <> struct ParamTraits : public ContiguousEnumSerializerInclusive< mozilla::StyleScrollSnapStrictness, mozilla::StyleScrollSnapStrictness::None, mozilla::StyleScrollSnapStrictness::Proximity> {}; template <> struct ParamTraits : public BitFlagsEnumSerializer {}; template <> struct ParamTraits : public BitFlagsEnumSerializer< mozilla::layers::DiagnosticTypes, mozilla::layers::DiagnosticTypes::ALL_BITS> {}; template <> struct ParamTraits : public ContiguousEnumSerializerInclusive< mozilla::layers::ScrollDirection, mozilla::layers::ScrollDirection::eVertical, mozilla::layers::kHighestScrollDirection> {}; template <> struct ParamTraits : public ContiguousEnumSerializerInclusive< mozilla::layers::FrameMetrics::ScrollOffsetUpdateType, mozilla::layers::FrameMetrics::ScrollOffsetUpdateType::eNone, mozilla::layers::FrameMetrics::sHighestScrollOffsetUpdateType> {}; template <> struct ParamTraits : public ContiguousEnumSerializerInclusive< mozilla::layers::RepaintRequest::ScrollOffsetUpdateType, mozilla::layers::RepaintRequest::ScrollOffsetUpdateType::eNone, mozilla::layers::RepaintRequest::sHighestScrollOffsetUpdateType> {}; template <> struct ParamTraits : public ContiguousEnumSerializerInclusive< mozilla::layers::OverscrollBehavior, mozilla::layers::OverscrollBehavior::Auto, mozilla::layers::kHighestOverscrollBehavior> {}; template <> struct ParamTraits { typedef mozilla::layers::LayerHandle paramType; static void Write(MessageWriter* writer, const paramType& param) { WriteParam(writer, param.mHandle); } static bool Read(MessageReader* reader, paramType* result) { return ReadParam(reader, &result->mHandle); } }; template <> struct ParamTraits { typedef mozilla::layers::CompositableHandle paramType; static void Write(MessageWriter* writer, const paramType& param) { WriteParam(writer, param.mHandle); } static bool Read(MessageReader* reader, paramType* result) { return ReadParam(reader, &result->mHandle); } }; template <> struct ParamTraits : public ContiguousEnumSerializerInclusive< mozilla::layers::CompositableHandleOwner, mozilla::layers::CompositableHandleOwner::WebRenderBridge, mozilla::layers::CompositableHandleOwner::ImageBridge> {}; template <> struct ParamTraits { typedef mozilla::layers::RemoteTextureId paramType; static void Write(MessageWriter* writer, const paramType& param) { WriteParam(writer, param.mId); } static bool Read(MessageReader* reader, paramType* result) { return ReadParam(reader, &result->mId); } }; template <> struct ParamTraits { typedef mozilla::layers::RemoteTextureOwnerId paramType; static void Write(MessageWriter* writer, const paramType& param) { WriteParam(writer, param.mId); } static bool Read(MessageReader* reader, paramType* result) { return ReadParam(reader, &result->mId); } }; template <> struct ParamTraits : BitfieldHelper { typedef mozilla::layers::FrameMetrics paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mScrollId); WriteParam(aWriter, aParam.mPresShellResolution); WriteParam(aWriter, aParam.mCompositionBounds); WriteParam(aWriter, aParam.mCompositionBoundsWidthIgnoringScrollbars); WriteParam(aWriter, aParam.mDisplayPort); WriteParam(aWriter, aParam.mScrollableRect); WriteParam(aWriter, aParam.mCumulativeResolution); WriteParam(aWriter, aParam.mDevPixelsPerCSSPixel); WriteParam(aWriter, aParam.mScrollOffset); WriteParam(aWriter, aParam.mZoom); WriteParam(aWriter, aParam.mScrollGeneration); WriteParam(aWriter, aParam.mBoundingCompositionSize); WriteParam(aWriter, aParam.mPresShellId); WriteParam(aWriter, aParam.mLayoutViewport); WriteParam(aWriter, aParam.mTransformToAncestorScale); WriteParam(aWriter, aParam.mPaintRequestTime); WriteParam(aWriter, aParam.mVisualDestination); WriteParam(aWriter, aParam.mVisualScrollUpdateType); WriteParam(aWriter, aParam.mFixedLayerMargins); WriteParam(aWriter, aParam.mCompositionSizeWithoutDynamicToolbar); WriteParam(aWriter, aParam.mIsRootContent); WriteParam(aWriter, aParam.mIsScrollInfoLayer); WriteParam(aWriter, aParam.mHasNonZeroDisplayPortMargins); WriteParam(aWriter, aParam.mMinimalDisplayPort); } static bool Read(MessageReader* aReader, paramType* aResult) { return ( ReadParam(aReader, &aResult->mScrollId) && ReadParam(aReader, &aResult->mPresShellResolution) && ReadParam(aReader, &aResult->mCompositionBounds) && ReadParam(aReader, &aResult->mCompositionBoundsWidthIgnoringScrollbars) && ReadParam(aReader, &aResult->mDisplayPort) && ReadParam(aReader, &aResult->mScrollableRect) && ReadParam(aReader, &aResult->mCumulativeResolution) && ReadParam(aReader, &aResult->mDevPixelsPerCSSPixel) && ReadParam(aReader, &aResult->mScrollOffset) && ReadParam(aReader, &aResult->mZoom) && ReadParam(aReader, &aResult->mScrollGeneration) && ReadParam(aReader, &aResult->mBoundingCompositionSize) && ReadParam(aReader, &aResult->mPresShellId) && ReadParam(aReader, &aResult->mLayoutViewport) && ReadParam(aReader, &aResult->mTransformToAncestorScale) && ReadParam(aReader, &aResult->mPaintRequestTime) && ReadParam(aReader, &aResult->mVisualDestination) && ReadParam(aReader, &aResult->mVisualScrollUpdateType) && ReadParam(aReader, &aResult->mFixedLayerMargins) && ReadParam(aReader, &aResult->mCompositionSizeWithoutDynamicToolbar) && ReadBoolForBitfield(aReader, aResult, ¶mType::SetIsRootContent) && ReadBoolForBitfield(aReader, aResult, ¶mType::SetIsScrollInfoLayer) && ReadBoolForBitfield(aReader, aResult, ¶mType::SetHasNonZeroDisplayPortMargins) && ReadBoolForBitfield(aReader, aResult, ¶mType::SetMinimalDisplayPort)); } }; template <> struct ParamTraits : public ContiguousEnumSerializerInclusive< mozilla::APZScrollAnimationType, mozilla::APZScrollAnimationType::No, mozilla::APZScrollAnimationType::TriggeredByUserInput> {}; template <> struct ParamTraits { typedef mozilla::ScrollSnapTargetIds paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mIdsOnX); WriteParam(aWriter, aParam.mIdsOnY); } static bool Read(MessageReader* aReader, paramType* aResult) { return ReadParam(aReader, &aResult->mIdsOnX) && ReadParam(aReader, &aResult->mIdsOnY); } }; template <> struct ParamTraits : BitfieldHelper { typedef mozilla::layers::RepaintRequest paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mScrollId); WriteParam(aWriter, aParam.mPresShellResolution); WriteParam(aWriter, aParam.mCompositionBounds); WriteParam(aWriter, aParam.mCumulativeResolution); WriteParam(aWriter, aParam.mDevPixelsPerCSSPixel); WriteParam(aWriter, aParam.mScrollOffset); WriteParam(aWriter, aParam.mZoom); WriteParam(aWriter, aParam.mScrollGeneration); WriteParam(aWriter, aParam.mScrollGenerationOnApz); WriteParam(aWriter, aParam.mDisplayPortMargins); WriteParam(aWriter, aParam.mPresShellId); WriteParam(aWriter, aParam.mLayoutViewport); WriteParam(aWriter, aParam.mTransformToAncestorScale); WriteParam(aWriter, aParam.mPaintRequestTime); WriteParam(aWriter, aParam.mScrollUpdateType); WriteParam(aWriter, aParam.mScrollAnimationType); WriteParam(aWriter, aParam.mLastSnapTargetIds); WriteParam(aWriter, aParam.mIsRootContent); WriteParam(aWriter, aParam.mIsScrollInfoLayer); WriteParam(aWriter, aParam.mIsInScrollingGesture); } static bool Read(MessageReader* aReader, paramType* aResult) { return ( ReadParam(aReader, &aResult->mScrollId) && ReadParam(aReader, &aResult->mPresShellResolution) && ReadParam(aReader, &aResult->mCompositionBounds) && ReadParam(aReader, &aResult->mCumulativeResolution) && ReadParam(aReader, &aResult->mDevPixelsPerCSSPixel) && ReadParam(aReader, &aResult->mScrollOffset) && ReadParam(aReader, &aResult->mZoom) && ReadParam(aReader, &aResult->mScrollGeneration) && ReadParam(aReader, &aResult->mScrollGenerationOnApz) && ReadParam(aReader, &aResult->mDisplayPortMargins) && ReadParam(aReader, &aResult->mPresShellId) && ReadParam(aReader, &aResult->mLayoutViewport) && ReadParam(aReader, &aResult->mTransformToAncestorScale) && ReadParam(aReader, &aResult->mPaintRequestTime) && ReadParam(aReader, &aResult->mScrollUpdateType) && ReadParam(aReader, &aResult->mScrollAnimationType) && ReadParam(aReader, &aResult->mLastSnapTargetIds) && ReadBoolForBitfield(aReader, aResult, ¶mType::SetIsRootContent) && ReadBoolForBitfield(aReader, aResult, ¶mType::SetIsScrollInfoLayer) && ReadBoolForBitfield(aReader, aResult, ¶mType::SetIsInScrollingGesture)); } }; template <> struct ParamTraits { typedef nsSize paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.width); WriteParam(aWriter, aParam.height); } static bool Read(MessageReader* aReader, paramType* aResult) { return ReadParam(aReader, &aResult->width) && ReadParam(aReader, &aResult->height); } }; template <> struct ParamTraits : public ContiguousEnumSerializerInclusive< mozilla::StyleScrollSnapStop, mozilla::StyleScrollSnapStop::Normal, mozilla::StyleScrollSnapStop::Always> {}; template <> struct ParamTraits : public PlainOldDataSerializer {}; template <> struct ParamTraits { typedef mozilla::layers::ScrollSnapInfo::SnapTarget paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mSnapPositionX); WriteParam(aWriter, aParam.mSnapPositionY); WriteParam(aWriter, aParam.mSnapArea); WriteParam(aWriter, aParam.mScrollSnapStop); WriteParam(aWriter, aParam.mTargetId); } static bool Read(MessageReader* aReader, paramType* aResult) { return ReadParam(aReader, &aResult->mSnapPositionX) && ReadParam(aReader, &aResult->mSnapPositionY) && ReadParam(aReader, &aResult->mSnapArea) && ReadParam(aReader, &aResult->mScrollSnapStop) && ReadParam(aReader, &aResult->mTargetId); } }; template <> struct ParamTraits { typedef mozilla::layers::ScrollSnapInfo::ScrollSnapRange paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mStart); WriteParam(aWriter, aParam.mEnd); WriteParam(aWriter, aParam.mTargetId); } static bool Read(MessageReader* aReader, paramType* aResult) { return ReadParam(aReader, &aResult->mStart) && ReadParam(aReader, &aResult->mEnd) && ReadParam(aReader, &aResult->mTargetId); } }; template <> struct ParamTraits { typedef mozilla::layers::ScrollSnapInfo paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mScrollSnapStrictnessX); WriteParam(aWriter, aParam.mScrollSnapStrictnessY); WriteParam(aWriter, aParam.mSnapTargets); WriteParam(aWriter, aParam.mXRangeWiderThanSnapport); WriteParam(aWriter, aParam.mYRangeWiderThanSnapport); WriteParam(aWriter, aParam.mSnapportSize); } static bool Read(MessageReader* aReader, paramType* aResult) { return (ReadParam(aReader, &aResult->mScrollSnapStrictnessX) && ReadParam(aReader, &aResult->mScrollSnapStrictnessY) && ReadParam(aReader, &aResult->mSnapTargets) && ReadParam(aReader, &aResult->mXRangeWiderThanSnapport) && ReadParam(aReader, &aResult->mYRangeWiderThanSnapport) && ReadParam(aReader, &aResult->mSnapportSize)); } }; template <> struct ParamTraits { // Not using PlainOldDataSerializer so we get enum validation // for the members. typedef mozilla::layers::OverscrollBehaviorInfo paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mBehaviorX); WriteParam(aWriter, aParam.mBehaviorY); } static bool Read(MessageReader* aReader, paramType* aResult) { return (ReadParam(aReader, &aResult->mBehaviorX) && ReadParam(aReader, &aResult->mBehaviorY)); } }; template struct ParamTraits> : PlainOldDataSerializer> {}; template <> struct ParamTraits : public ContiguousEnumSerializerInclusive< mozilla::ScrollUpdateType, mozilla::ScrollUpdateType::Absolute, mozilla::ScrollUpdateType::PureRelative> {}; template <> struct ParamTraits : public ContiguousEnumSerializerInclusive {}; template <> struct ParamTraits : public ContiguousEnumSerializerInclusive< mozilla::ScrollOrigin, mozilla::ScrollOrigin::None, mozilla::ScrollOrigin::Scrollbars> {}; template <> struct ParamTraits : public ContiguousEnumSerializerInclusive< mozilla::ScrollTriggeredByScript, mozilla::ScrollTriggeredByScript::No, mozilla::ScrollTriggeredByScript::Yes> {}; template <> struct ParamTraits { typedef mozilla::ScrollPositionUpdate paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mScrollGeneration); WriteParam(aWriter, aParam.mType); WriteParam(aWriter, aParam.mScrollMode); WriteParam(aWriter, aParam.mScrollOrigin); WriteParam(aWriter, aParam.mDestination); WriteParam(aWriter, aParam.mSource); WriteParam(aWriter, aParam.mDelta); WriteParam(aWriter, aParam.mTriggeredByScript); WriteParam(aWriter, aParam.mSnapTargetIds); } static bool Read(MessageReader* aReader, paramType* aResult) { return ReadParam(aReader, &aResult->mScrollGeneration) && ReadParam(aReader, &aResult->mType) && ReadParam(aReader, &aResult->mScrollMode) && ReadParam(aReader, &aResult->mScrollOrigin) && ReadParam(aReader, &aResult->mDestination) && ReadParam(aReader, &aResult->mSource) && ReadParam(aReader, &aResult->mDelta) && ReadParam(aReader, &aResult->mTriggeredByScript) && ReadParam(aReader, &aResult->mSnapTargetIds); } }; template <> struct ParamTraits : BitfieldHelper { typedef mozilla::layers::ScrollMetadata paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mMetrics); WriteParam(aWriter, aParam.mSnapInfo); WriteParam(aWriter, aParam.mScrollParentId); WriteParam(aWriter, aParam.mBackgroundColor); WriteParam(aWriter, aParam.GetContentDescription()); WriteParam(aWriter, aParam.mLineScrollAmount); WriteParam(aWriter, aParam.mPageScrollAmount); WriteParam(aWriter, aParam.mHasScrollgrab); WriteParam(aWriter, aParam.mIsLayersIdRoot); WriteParam(aWriter, aParam.mIsAutoDirRootContentRTL); WriteParam(aWriter, aParam.mForceDisableApz); WriteParam(aWriter, aParam.mResolutionUpdated); WriteParam(aWriter, aParam.mIsRDMTouchSimulationActive); WriteParam(aWriter, aParam.mDidContentGetPainted); WriteParam(aWriter, aParam.mForceMousewheelAutodir); WriteParam(aWriter, aParam.mForceMousewheelAutodirHonourRoot); WriteParam(aWriter, aParam.mIsPaginatedPresentation); WriteParam(aWriter, aParam.mDisregardedDirection); WriteParam(aWriter, aParam.mOverscrollBehavior); WriteParam(aWriter, aParam.mScrollUpdates); } static bool ReadContentDescription(MessageReader* aReader, paramType* aResult) { nsCString str; if (!ReadParam(aReader, &str)) { return false; } aResult->SetContentDescription(str); return true; } static bool Read(MessageReader* aReader, paramType* aResult) { return (ReadParam(aReader, &aResult->mMetrics) && ReadParam(aReader, &aResult->mSnapInfo) && ReadParam(aReader, &aResult->mScrollParentId) && ReadParam(aReader, &aResult->mBackgroundColor) && ReadContentDescription(aReader, aResult) && ReadParam(aReader, &aResult->mLineScrollAmount) && ReadParam(aReader, &aResult->mPageScrollAmount) && ReadBoolForBitfield(aReader, aResult, ¶mType::SetHasScrollgrab) && ReadBoolForBitfield(aReader, aResult, ¶mType::SetIsLayersIdRoot) && ReadBoolForBitfield(aReader, aResult, ¶mType::SetIsAutoDirRootContentRTL) && ReadBoolForBitfield(aReader, aResult, ¶mType::SetForceDisableApz) && ReadBoolForBitfield(aReader, aResult, ¶mType::SetResolutionUpdated) && ReadBoolForBitfield(aReader, aResult, ¶mType::SetIsRDMTouchSimulationActive)) && ReadBoolForBitfield(aReader, aResult, ¶mType::SetDidContentGetPainted) && ReadBoolForBitfield(aReader, aResult, ¶mType::SetForceMousewheelAutodir) && ReadBoolForBitfield( aReader, aResult, ¶mType::SetForceMousewheelAutodirHonourRoot) && ReadBoolForBitfield(aReader, aResult, ¶mType::SetIsPaginatedPresentation) && ReadParam(aReader, &aResult->mDisregardedDirection) && ReadParam(aReader, &aResult->mOverscrollBehavior) && ReadParam(aReader, &aResult->mScrollUpdates); } }; template <> struct ParamTraits { typedef mozilla::layers::TextureFactoryIdentifier paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mParentBackend); WriteParam(aWriter, aParam.mWebRenderBackend); WriteParam(aWriter, aParam.mWebRenderCompositor); WriteParam(aWriter, aParam.mParentProcessType); WriteParam(aWriter, aParam.mMaxTextureSize); WriteParam(aWriter, aParam.mCompositorUseANGLE); WriteParam(aWriter, aParam.mCompositorUseDComp); WriteParam(aWriter, aParam.mUseCompositorWnd); WriteParam(aWriter, aParam.mSupportsTextureBlitting); WriteParam(aWriter, aParam.mSupportsPartialUploads); WriteParam(aWriter, aParam.mSupportsComponentAlpha); WriteParam(aWriter, aParam.mSyncHandle); } static bool Read(MessageReader* aReader, paramType* aResult) { bool result = ReadParam(aReader, &aResult->mParentBackend) && ReadParam(aReader, &aResult->mWebRenderBackend) && ReadParam(aReader, &aResult->mWebRenderCompositor) && ReadParam(aReader, &aResult->mParentProcessType) && ReadParam(aReader, &aResult->mMaxTextureSize) && ReadParam(aReader, &aResult->mCompositorUseANGLE) && ReadParam(aReader, &aResult->mCompositorUseDComp) && ReadParam(aReader, &aResult->mUseCompositorWnd) && ReadParam(aReader, &aResult->mSupportsTextureBlitting) && ReadParam(aReader, &aResult->mSupportsPartialUploads) && ReadParam(aReader, &aResult->mSupportsComponentAlpha) && ReadParam(aReader, &aResult->mSyncHandle); return result; } }; template <> struct ParamTraits { typedef mozilla::layers::TextureInfo paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mCompositableType); WriteParam(aWriter, aParam.mTextureFlags); } static bool Read(MessageReader* aReader, paramType* aResult) { return ReadParam(aReader, &aResult->mCompositableType) && ReadParam(aReader, &aResult->mTextureFlags); } }; template <> struct ParamTraits : public ContiguousEnumSerializer< mozilla::layers::CompositableType, mozilla::layers::CompositableType::UNKNOWN, mozilla::layers::CompositableType::COUNT> {}; template <> struct ParamTraits { typedef mozilla::layers::ScrollableLayerGuid paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mLayersId); WriteParam(aWriter, aParam.mPresShellId); WriteParam(aWriter, aParam.mScrollId); } static bool Read(MessageReader* aReader, paramType* aResult) { return (ReadParam(aReader, &aResult->mLayersId) && ReadParam(aReader, &aResult->mPresShellId) && ReadParam(aReader, &aResult->mScrollId)); } }; template <> struct ParamTraits : public ContiguousEnumSerializer {}; template <> struct ParamTraits : public ContiguousEnumSerializer< mozilla::layers::APZHandledPlace, mozilla::layers::APZHandledPlace::Unhandled, mozilla::layers::APZHandledPlace::Last> {}; template <> struct ParamTraits { typedef mozilla::layers::ScrollDirections paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.serialize()); } static bool Read(MessageReader* aReader, paramType* aResult) { uint8_t value; if (!ReadParam(aReader, &value)) { return false; } aResult->deserialize(value); return true; } }; template <> struct ParamTraits { typedef mozilla::layers::APZHandledResult paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mPlace); WriteParam(aWriter, aParam.mScrollableDirections); WriteParam(aWriter, aParam.mOverscrollDirections); } static bool Read(MessageReader* aReader, paramType* aResult) { return (ReadParam(aReader, &aResult->mPlace) && ReadParam(aReader, &aResult->mScrollableDirections) && ReadParam(aReader, &aResult->mOverscrollDirections)); } }; template <> struct ParamTraits { typedef mozilla::layers::APZEventResult paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.GetStatus()); WriteParam(aWriter, aParam.GetHandledResult()); WriteParam(aWriter, aParam.mTargetGuid); WriteParam(aWriter, aParam.mInputBlockId); } static bool Read(MessageReader* aReader, paramType* aResult) { nsEventStatus status; if (!ReadParam(aReader, &status)) { return false; } aResult->UpdateStatus(status); mozilla::Maybe handledResult; if (!ReadParam(aReader, &handledResult)) { return false; } aResult->UpdateHandledResult(handledResult); return (ReadParam(aReader, &aResult->mTargetGuid) && ReadParam(aReader, &aResult->mInputBlockId)); } }; template <> struct ParamTraits { typedef mozilla::layers::ZoomConstraints paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mAllowZoom); WriteParam(aWriter, aParam.mAllowDoubleTapZoom); WriteParam(aWriter, aParam.mMinZoom); WriteParam(aWriter, aParam.mMaxZoom); } static bool Read(MessageReader* aReader, paramType* aResult) { return (ReadParam(aReader, &aResult->mAllowZoom) && ReadParam(aReader, &aResult->mAllowDoubleTapZoom) && ReadParam(aReader, &aResult->mMinZoom) && ReadParam(aReader, &aResult->mMaxZoom)); } }; template <> struct ParamTraits { typedef mozilla::layers::FocusTarget::ScrollTargets paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mHorizontal); WriteParam(aWriter, aParam.mVertical); } static bool Read(MessageReader* aReader, paramType* aResult) { return ReadParam(aReader, &aResult->mHorizontal) && ReadParam(aReader, &aResult->mVertical); } }; template <> struct ParamTraits : public EmptyStructSerializer< mozilla::layers::FocusTarget::NoFocusTarget> {}; template <> struct ParamTraits { typedef mozilla::layers::FocusTarget paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mSequenceNumber); WriteParam(aWriter, aParam.mFocusHasKeyEventListeners); WriteParam(aWriter, aParam.mData); } static bool Read(MessageReader* aReader, paramType* aResult) { if (!ReadParam(aReader, &aResult->mSequenceNumber) || !ReadParam(aReader, &aResult->mFocusHasKeyEventListeners) || !ReadParam(aReader, &aResult->mData)) { return false; } return true; } }; template <> struct ParamTraits< mozilla::layers::KeyboardScrollAction::KeyboardScrollActionType> : public ContiguousEnumSerializerInclusive< mozilla::layers::KeyboardScrollAction::KeyboardScrollActionType, mozilla::layers::KeyboardScrollAction::KeyboardScrollActionType:: eScrollCharacter, mozilla::layers::KeyboardScrollAction:: sHighestKeyboardScrollActionType> {}; template <> struct ParamTraits { typedef mozilla::layers::KeyboardScrollAction paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mType); WriteParam(aWriter, aParam.mForward); } static bool Read(MessageReader* aReader, paramType* aResult) { return ReadParam(aReader, &aResult->mType) && ReadParam(aReader, &aResult->mForward); } }; template <> struct ParamTraits { typedef mozilla::layers::KeyboardShortcut paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mAction); WriteParam(aWriter, aParam.mKeyCode); WriteParam(aWriter, aParam.mCharCode); WriteParam(aWriter, aParam.mModifiers); WriteParam(aWriter, aParam.mModifiersMask); WriteParam(aWriter, aParam.mEventType); WriteParam(aWriter, aParam.mDispatchToContent); } static bool Read(MessageReader* aReader, paramType* aResult) { return ReadParam(aReader, &aResult->mAction) && ReadParam(aReader, &aResult->mKeyCode) && ReadParam(aReader, &aResult->mCharCode) && ReadParam(aReader, &aResult->mModifiers) && ReadParam(aReader, &aResult->mModifiersMask) && ReadParam(aReader, &aResult->mEventType) && ReadParam(aReader, &aResult->mDispatchToContent); } }; template <> struct ParamTraits { typedef mozilla::layers::KeyboardMap paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.Shortcuts()); } static bool Read(MessageReader* aReader, paramType* aResult) { nsTArray shortcuts; if (!ReadParam(aReader, &shortcuts)) { return false; } *aResult = mozilla::layers::KeyboardMap(std::move(shortcuts)); return true; } }; template <> struct ParamTraits : public ContiguousEnumSerializerInclusive< mozilla::layers::GeckoContentController_TapType, mozilla::layers::GeckoContentController_TapType::eSingleTap, mozilla::layers::kHighestGeckoContentController_TapType> {}; template <> struct ParamTraits : public ContiguousEnumSerializerInclusive< mozilla::layers::GeckoContentController_APZStateChange, mozilla::layers::GeckoContentController_APZStateChange:: eTransformBegin, mozilla::layers::kHighestGeckoContentController_APZStateChange> {}; template <> struct ParamTraits : public BitFlagsEnumSerializer< mozilla::layers::EventRegionsOverride, mozilla::layers::EventRegionsOverride::ALL_BITS> {}; template <> struct ParamTraits { typedef mozilla::layers::AsyncDragMetrics paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mViewId); WriteParam(aWriter, aParam.mPresShellId); WriteParam(aWriter, aParam.mDragStartSequenceNumber); WriteParam(aWriter, aParam.mScrollbarDragOffset); WriteParam(aWriter, aParam.mDirection); } static bool Read(MessageReader* aReader, paramType* aResult) { return (ReadParam(aReader, &aResult->mViewId) && ReadParam(aReader, &aResult->mPresShellId) && ReadParam(aReader, &aResult->mDragStartSequenceNumber) && ReadParam(aReader, &aResult->mScrollbarDragOffset) && ReadParam(aReader, &aResult->mDirection)); } }; template <> struct ParamTraits : public ContiguousEnumSerializerInclusive< mozilla::layers::BrowserGestureResponse, mozilla::layers::BrowserGestureResponse::NotConsumed, mozilla::layers::BrowserGestureResponse::Consumed> {}; template <> struct ParamTraits { typedef mozilla::layers::CompositorOptions paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mUseAPZ); WriteParam(aWriter, aParam.mUseSoftwareWebRender); WriteParam(aWriter, aParam.mAllowSoftwareWebRenderD3D11); WriteParam(aWriter, aParam.mAllowSoftwareWebRenderOGL); WriteParam(aWriter, aParam.mInitiallyPaused); WriteParam(aWriter, aParam.mNeedFastSnaphot); } static bool Read(MessageReader* aReader, paramType* aResult) { return ReadParam(aReader, &aResult->mUseAPZ) && ReadParam(aReader, &aResult->mUseSoftwareWebRender) && ReadParam(aReader, &aResult->mAllowSoftwareWebRenderD3D11) && ReadParam(aReader, &aResult->mAllowSoftwareWebRenderOGL) && ReadParam(aReader, &aResult->mInitiallyPaused) && ReadParam(aReader, &aResult->mNeedFastSnaphot); } }; template <> struct ParamTraits : public ContiguousEnumSerializerInclusive< mozilla::layers::OverlaySupportType, mozilla::layers::OverlaySupportType::None, mozilla::layers::OverlaySupportType::MAX> {}; template <> struct ParamTraits { typedef mozilla::layers::OverlayInfo paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mSupportsOverlays); WriteParam(aWriter, aParam.mNv12Overlay); WriteParam(aWriter, aParam.mYuy2Overlay); WriteParam(aWriter, aParam.mBgra8Overlay); WriteParam(aWriter, aParam.mRgb10a2Overlay); } static bool Read(MessageReader* aReader, paramType* aResult) { return ReadParam(aReader, &aResult->mSupportsOverlays) && ReadParam(aReader, &aResult->mNv12Overlay) && ReadParam(aReader, &aResult->mYuy2Overlay) && ReadParam(aReader, &aResult->mBgra8Overlay) && ReadParam(aReader, &aResult->mRgb10a2Overlay); } }; template <> struct ParamTraits { typedef mozilla::layers::SwapChainInfo paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mTearingSupported); } static bool Read(MessageReader* aReader, paramType* aResult) { return ReadParam(aReader, &aResult->mTearingSupported); } }; template <> struct ParamTraits : public ContiguousEnumSerializerInclusive< mozilla::layers::ScrollbarLayerType, mozilla::layers::ScrollbarLayerType::None, mozilla::layers::kHighestScrollbarLayerType> {}; template <> struct ParamTraits { typedef mozilla::layers::ScrollbarData paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mDirection); WriteParam(aWriter, aParam.mScrollbarLayerType); WriteParam(aWriter, aParam.mThumbRatio); WriteParam(aWriter, aParam.mThumbStart); WriteParam(aWriter, aParam.mThumbLength); WriteParam(aWriter, aParam.mThumbIsAsyncDraggable); WriteParam(aWriter, aParam.mScrollTrackStart); WriteParam(aWriter, aParam.mScrollTrackLength); WriteParam(aWriter, aParam.mTargetViewId); } static bool Read(MessageReader* aReader, paramType* aResult) { return ReadParam(aReader, &aResult->mDirection) && ReadParam(aReader, &aResult->mScrollbarLayerType) && ReadParam(aReader, &aResult->mThumbRatio) && ReadParam(aReader, &aResult->mThumbStart) && ReadParam(aReader, &aResult->mThumbLength) && ReadParam(aReader, &aResult->mThumbIsAsyncDraggable) && ReadParam(aReader, &aResult->mScrollTrackStart) && ReadParam(aReader, &aResult->mScrollTrackLength) && ReadParam(aReader, &aResult->mTargetViewId); } }; template <> struct ParamTraits : public ContiguousEnumSerializerInclusive< mozilla::layers::CompositionPayloadType, mozilla::layers::CompositionPayloadType::eKeyPress, mozilla::layers::kHighestCompositionPayloadType> {}; template <> struct ParamTraits { typedef mozilla::layers::CompositionPayload paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mType); WriteParam(aWriter, aParam.mTimeStamp); } static bool Read(MessageReader* aReader, paramType* aResult) { return ReadParam(aReader, &aResult->mType) && ReadParam(aReader, &aResult->mTimeStamp); } }; template <> struct ParamTraits { typedef mozilla::RayReferenceData paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mInitialPosition); WriteParam(aWriter, aParam.mContainingBlockRect); } static bool Read(MessageReader* aReader, paramType* aResult) { return (ReadParam(aReader, &aResult->mInitialPosition) && ReadParam(aReader, &aResult->mContainingBlockRect)); } }; template <> struct ParamTraits : public ContiguousEnumSerializerInclusive< mozilla::layers::CantZoomOutBehavior, mozilla::layers::CantZoomOutBehavior::Nothing, mozilla::layers::CantZoomOutBehavior::ZoomIn> {}; template <> struct ParamTraits { typedef mozilla::layers::ZoomTarget paramType; static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.targetRect); WriteParam(aWriter, aParam.cantZoomOutBehavior); WriteParam(aWriter, aParam.elementBoundingRect); WriteParam(aWriter, aParam.documentRelativePointerPosition); } static bool Read(MessageReader* aReader, paramType* aResult) { return (ReadParam(aReader, &aResult->targetRect) && ReadParam(aReader, &aResult->cantZoomOutBehavior) && ReadParam(aReader, &aResult->elementBoundingRect) && ReadParam(aReader, &aResult->documentRelativePointerPosition)); } }; #define IMPL_PARAMTRAITS_BY_SERDE(type_) \ template <> \ struct ParamTraits { \ typedef mozilla::type_ paramType; \ static void Write(MessageWriter* aWriter, const paramType& aParam) { \ mozilla::ipc::ByteBuf v; \ mozilla::DebugOnly rv = Servo_##type_##_Serialize(&aParam, &v); \ MOZ_ASSERT(rv, "Serialize ##type_## failed"); \ WriteParam(aWriter, std::move(v)); \ } \ static bool Read(MessageReader* aReader, paramType* aResult) { \ mozilla::ipc::ByteBuf in; \ bool rv = ReadParam(aReader, &in); \ if (!rv) { \ return false; \ } \ return in.mData && Servo_##type_##_Deserialize(&in, aResult); \ } \ }; IMPL_PARAMTRAITS_BY_SERDE(LengthPercentage) IMPL_PARAMTRAITS_BY_SERDE(StyleOffsetPath) IMPL_PARAMTRAITS_BY_SERDE(StyleOffsetRotate) IMPL_PARAMTRAITS_BY_SERDE(StylePositionOrAuto) IMPL_PARAMTRAITS_BY_SERDE(StyleRotate) IMPL_PARAMTRAITS_BY_SERDE(StyleScale) IMPL_PARAMTRAITS_BY_SERDE(StyleTranslate) IMPL_PARAMTRAITS_BY_SERDE(StyleTransform) IMPL_PARAMTRAITS_BY_SERDE(StyleComputedTimingFunction) } /* namespace IPC */ #endif /* mozilla_layers_LayersMessageUtils */