LCOV - code coverage report
Current view: top level - gfx/layers/ipc - LayersMessageUtils.h (source / functions) Hit Total Coverage
Test: output.info Lines: 211 271 77.9 %
Date: 2017-07-14 16:53:18 Functions: 31 41 75.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set sw=2 ts=8 et tw=80 : */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef mozilla_layers_LayersMessageUtils
       8             : #define mozilla_layers_LayersMessageUtils
       9             : 
      10             : #include "FrameMetrics.h"
      11             : #include "base/process_util.h"
      12             : #include "chrome/common/ipc_message_utils.h"
      13             : #include "gfxTelemetry.h"
      14             : #include "ipc/IPCMessageUtils.h"
      15             : #include "ipc/nsGUIEventIPC.h"
      16             : #include "mozilla/GfxMessageUtils.h"
      17             : #include "mozilla/layers/AsyncDragMetrics.h"
      18             : #include "mozilla/layers/CompositorOptions.h"
      19             : #include "mozilla/layers/CompositorTypes.h"
      20             : #include "mozilla/layers/FocusTarget.h"
      21             : #include "mozilla/layers/GeckoContentController.h"
      22             : #include "mozilla/layers/KeyboardMap.h"
      23             : #include "mozilla/layers/LayerAttributes.h"
      24             : #include "mozilla/layers/LayersTypes.h"
      25             : #include "mozilla/Move.h"
      26             : 
      27             : #include <stdint.h>
      28             : 
      29             : #ifdef _MSC_VER
      30             : #pragma warning( disable : 4800 )
      31             : #endif
      32             : 
      33             : namespace IPC {
      34             : 
      35             : template <>
      36             : struct ParamTraits<mozilla::layers::LayersBackend>
      37             :   : public ContiguousEnumSerializer<
      38             :              mozilla::layers::LayersBackend,
      39             :              mozilla::layers::LayersBackend::LAYERS_NONE,
      40             :              mozilla::layers::LayersBackend::LAYERS_LAST>
      41             : {};
      42             : 
      43             : template <>
      44             : struct ParamTraits<mozilla::layers::ScaleMode>
      45             :   : public ContiguousEnumSerializerInclusive<
      46             :              mozilla::layers::ScaleMode,
      47             :              mozilla::layers::ScaleMode::SCALE_NONE,
      48             :              mozilla::layers::kHighestScaleMode>
      49             : {};
      50             : 
      51             : template <>
      52             : struct ParamTraits<mozilla::layers::TextureFlags>
      53             :   : public BitFlagsEnumSerializer<
      54             :             mozilla::layers::TextureFlags,
      55             :             mozilla::layers::TextureFlags::ALL_BITS>
      56             : {};
      57             : 
      58             : template <>
      59             : struct ParamTraits<mozilla::layers::DiagnosticTypes>
      60             :   : public BitFlagsEnumSerializer<
      61             :              mozilla::layers::DiagnosticTypes,
      62             :              mozilla::layers::DiagnosticTypes::ALL_BITS>
      63             : {};
      64             : 
      65             : template <>
      66             : struct ParamTraits<mozilla::layers::ScrollDirection>
      67             :   : public ContiguousEnumSerializerInclusive<
      68             :             mozilla::layers::ScrollDirection,
      69             :             mozilla::layers::ScrollDirection::NONE,
      70             :             mozilla::layers::kHighestScrollDirection>
      71             : {};
      72             : 
      73             : template<>
      74             : struct ParamTraits<mozilla::layers::FrameMetrics::ScrollOffsetUpdateType>
      75             :   : public ContiguousEnumSerializerInclusive<
      76             :              mozilla::layers::FrameMetrics::ScrollOffsetUpdateType,
      77             :              mozilla::layers::FrameMetrics::ScrollOffsetUpdateType::eNone,
      78             :              mozilla::layers::FrameMetrics::sHighestScrollOffsetUpdateType>
      79             : {};
      80             : 
      81             : template<>
      82             : struct ParamTraits<mozilla::layers::LayerHandle>
      83             : {
      84             :   typedef mozilla::layers::LayerHandle paramType;
      85             : 
      86         469 :   static void Write(Message* msg, const paramType& param) {
      87         469 :     WriteParam(msg, param.mHandle);
      88         469 :   }
      89         469 :   static bool Read(const Message* msg, PickleIterator* iter, paramType* result) {
      90         469 :     return ReadParam(msg, iter, &result->mHandle);
      91             :   }
      92             : };
      93             : 
      94             : template<>
      95             : struct ParamTraits<mozilla::layers::CompositableHandle>
      96             : {
      97             :   typedef mozilla::layers::CompositableHandle paramType;
      98             : 
      99         129 :   static void Write(Message* msg, const paramType& param) {
     100         129 :     WriteParam(msg, param.mHandle);
     101         129 :   }
     102         129 :   static bool Read(const Message* msg, PickleIterator* iter, paramType* result) {
     103         129 :     return ReadParam(msg, iter, &result->mHandle);
     104             :   }
     105             : };
     106             : 
     107             : template<>
     108             : struct ParamTraits<mozilla::layers::ReadLockHandle>
     109             : {
     110             :   typedef mozilla::layers::ReadLockHandle paramType;
     111             : 
     112          66 :   static void Write(Message* msg, const paramType& param) {
     113          66 :     WriteParam(msg, param.mHandle);
     114          66 :   }
     115          66 :   static bool Read(const Message* msg, PickleIterator* iter, paramType* result) {
     116          66 :     return ReadParam(msg, iter, &result->mHandle);
     117             :   }
     118             : };
     119             : 
     120             : // Helper class for reading bitfields.
     121             : // If T has bitfields members, derive ParamTraits<T> from BitfieldHelper<T>.
     122             : template <typename ParamType>
     123             : struct BitfieldHelper
     124             : {
     125             :   // We need this helper because we can't get the address of a bitfield to
     126             :   // pass directly to ReadParam. So instead we read it into a temporary bool
     127             :   // and set the bitfield using a setter function
     128         243 :   static bool ReadBoolForBitfield(const Message* aMsg, PickleIterator* aIter,
     129             :         ParamType* aResult, void (ParamType::*aSetter)(bool))
     130             :   {
     131             :     bool value;
     132         243 :     if (ReadParam(aMsg, aIter, &value)) {
     133         243 :       (aResult->*aSetter)(value);
     134         243 :       return true;
     135             :     }
     136           0 :     return false;
     137             :   }
     138             : };
     139             : 
     140             : template <>
     141             : struct ParamTraits<mozilla::layers::FrameMetrics>
     142             :     : BitfieldHelper<mozilla::layers::FrameMetrics>
     143             : {
     144             :   typedef mozilla::layers::FrameMetrics paramType;
     145             : 
     146          27 :   static void Write(Message* aMsg, const paramType& aParam)
     147             :   {
     148          27 :     WriteParam(aMsg, aParam.mScrollId);
     149          27 :     WriteParam(aMsg, aParam.mPresShellResolution);
     150          27 :     WriteParam(aMsg, aParam.mCompositionBounds);
     151          27 :     WriteParam(aMsg, aParam.mDisplayPort);
     152          27 :     WriteParam(aMsg, aParam.mCriticalDisplayPort);
     153          27 :     WriteParam(aMsg, aParam.mScrollableRect);
     154          27 :     WriteParam(aMsg, aParam.mCumulativeResolution);
     155          27 :     WriteParam(aMsg, aParam.mDevPixelsPerCSSPixel);
     156          27 :     WriteParam(aMsg, aParam.mScrollOffset);
     157          27 :     WriteParam(aMsg, aParam.mZoom);
     158          27 :     WriteParam(aMsg, aParam.mScrollGeneration);
     159          27 :     WriteParam(aMsg, aParam.mSmoothScrollOffset);
     160          27 :     WriteParam(aMsg, aParam.mRootCompositionSize);
     161          27 :     WriteParam(aMsg, aParam.mDisplayPortMargins);
     162          27 :     WriteParam(aMsg, aParam.mPresShellId);
     163          27 :     WriteParam(aMsg, aParam.mViewport);
     164          27 :     WriteParam(aMsg, aParam.mExtraResolution);
     165          27 :     WriteParam(aMsg, aParam.mPaintRequestTime);
     166          27 :     WriteParam(aMsg, aParam.mScrollUpdateType);
     167          27 :     WriteParam(aMsg, aParam.mIsRootContent);
     168          27 :     WriteParam(aMsg, aParam.mDoSmoothScroll);
     169          27 :     WriteParam(aMsg, aParam.mUseDisplayPortMargins);
     170          27 :     WriteParam(aMsg, aParam.mIsScrollInfoLayer);
     171          27 :   }
     172             : 
     173          27 :   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
     174             :   {
     175          54 :     return (ReadParam(aMsg, aIter, &aResult->mScrollId) &&
     176          54 :             ReadParam(aMsg, aIter, &aResult->mPresShellResolution) &&
     177          54 :             ReadParam(aMsg, aIter, &aResult->mCompositionBounds) &&
     178          54 :             ReadParam(aMsg, aIter, &aResult->mDisplayPort) &&
     179          54 :             ReadParam(aMsg, aIter, &aResult->mCriticalDisplayPort) &&
     180          54 :             ReadParam(aMsg, aIter, &aResult->mScrollableRect) &&
     181          54 :             ReadParam(aMsg, aIter, &aResult->mCumulativeResolution) &&
     182          54 :             ReadParam(aMsg, aIter, &aResult->mDevPixelsPerCSSPixel) &&
     183          54 :             ReadParam(aMsg, aIter, &aResult->mScrollOffset) &&
     184          54 :             ReadParam(aMsg, aIter, &aResult->mZoom) &&
     185          54 :             ReadParam(aMsg, aIter, &aResult->mScrollGeneration) &&
     186          54 :             ReadParam(aMsg, aIter, &aResult->mSmoothScrollOffset) &&
     187          54 :             ReadParam(aMsg, aIter, &aResult->mRootCompositionSize) &&
     188          54 :             ReadParam(aMsg, aIter, &aResult->mDisplayPortMargins) &&
     189          54 :             ReadParam(aMsg, aIter, &aResult->mPresShellId) &&
     190          54 :             ReadParam(aMsg, aIter, &aResult->mViewport) &&
     191          54 :             ReadParam(aMsg, aIter, &aResult->mExtraResolution) &&
     192          54 :             ReadParam(aMsg, aIter, &aResult->mPaintRequestTime) &&
     193          54 :             ReadParam(aMsg, aIter, &aResult->mScrollUpdateType) &&
     194          54 :             ReadBoolForBitfield(aMsg, aIter, aResult, &paramType::SetIsRootContent) &&
     195          54 :             ReadBoolForBitfield(aMsg, aIter, aResult, &paramType::SetDoSmoothScroll) &&
     196          81 :             ReadBoolForBitfield(aMsg, aIter, aResult, &paramType::SetUseDisplayPortMargins) &&
     197          54 :             ReadBoolForBitfield(aMsg, aIter, aResult, &paramType::SetIsScrollInfoLayer));
     198             :   }
     199             : };
     200             : 
     201             : template <>
     202             : struct ParamTraits<mozilla::layers::ScrollSnapInfo>
     203             : {
     204             :   typedef mozilla::layers::ScrollSnapInfo paramType;
     205             : 
     206          27 :   static void Write(Message* aMsg, const paramType& aParam)
     207             :   {
     208          27 :     WriteParam(aMsg, aParam.mScrollSnapTypeX);
     209          27 :     WriteParam(aMsg, aParam.mScrollSnapTypeY);
     210          27 :     WriteParam(aMsg, aParam.mScrollSnapIntervalX);
     211          27 :     WriteParam(aMsg, aParam.mScrollSnapIntervalY);
     212          27 :     WriteParam(aMsg, aParam.mScrollSnapDestination);
     213          27 :     WriteParam(aMsg, aParam.mScrollSnapCoordinates);
     214          27 :   }
     215             : 
     216          27 :   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
     217             :   {
     218          54 :     return (ReadParam(aMsg, aIter, &aResult->mScrollSnapTypeX) &&
     219          54 :             ReadParam(aMsg, aIter, &aResult->mScrollSnapTypeY) &&
     220          54 :             ReadParam(aMsg, aIter, &aResult->mScrollSnapIntervalX) &&
     221          54 :             ReadParam(aMsg, aIter, &aResult->mScrollSnapIntervalY) &&
     222          81 :             ReadParam(aMsg, aIter, &aResult->mScrollSnapDestination) &&
     223          54 :             ReadParam(aMsg, aIter, &aResult->mScrollSnapCoordinates));
     224             :   }
     225             : };
     226             : 
     227             : template <>
     228             : struct ParamTraits<mozilla::layers::LayerClip>
     229             : {
     230             :   typedef mozilla::layers::LayerClip paramType;
     231             : 
     232           3 :   static void Write(Message* aMsg, const paramType& aParam)
     233             :   {
     234           3 :     WriteParam(aMsg, aParam.mClipRect);
     235           3 :     WriteParam(aMsg, aParam.mMaskLayerIndex);
     236           3 :   }
     237             : 
     238           3 :   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
     239             :   {
     240           6 :     return (ReadParam(aMsg, aIter, &aResult->mClipRect) &&
     241           6 :             ReadParam(aMsg, aIter, &aResult->mMaskLayerIndex));
     242             :   }
     243             : };
     244             : 
     245             : template <>
     246             : struct ParamTraits<mozilla::layers::ScrollMetadata>
     247             :     : BitfieldHelper<mozilla::layers::ScrollMetadata>
     248             : {
     249             :   typedef mozilla::layers::ScrollMetadata paramType;
     250             : 
     251          27 :   static void Write(Message* aMsg, const paramType& aParam)
     252             :   {
     253          27 :     WriteParam(aMsg, aParam.mMetrics);
     254          27 :     WriteParam(aMsg, aParam.mSnapInfo);
     255          27 :     WriteParam(aMsg, aParam.mScrollParentId);
     256          27 :     WriteParam(aMsg, aParam.mBackgroundColor);
     257          27 :     WriteParam(aMsg, aParam.GetContentDescription());
     258          27 :     WriteParam(aMsg, aParam.mLineScrollAmount);
     259          27 :     WriteParam(aMsg, aParam.mPageScrollAmount);
     260          27 :     WriteParam(aMsg, aParam.mScrollClip);
     261          27 :     WriteParam(aMsg, aParam.mHasScrollgrab);
     262          27 :     WriteParam(aMsg, aParam.mAllowVerticalScrollWithWheel);
     263          27 :     WriteParam(aMsg, aParam.mIsLayersIdRoot);
     264          27 :     WriteParam(aMsg, aParam.mUsesContainerScrolling);
     265          27 :     WriteParam(aMsg, aParam.mForceDisableApz);
     266          27 :   }
     267             : 
     268          27 :   static bool ReadContentDescription(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
     269             :   {
     270          54 :     nsCString str;
     271          27 :     if (!ReadParam(aMsg, aIter, &str)) {
     272           0 :       return false;
     273             :     }
     274          27 :     aResult->SetContentDescription(str);
     275          27 :     return true;
     276             :   }
     277             : 
     278          27 :   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
     279             :   {
     280          54 :     return (ReadParam(aMsg, aIter, &aResult->mMetrics) &&
     281          54 :             ReadParam(aMsg, aIter, &aResult->mSnapInfo) &&
     282          54 :             ReadParam(aMsg, aIter, &aResult->mScrollParentId) &&
     283          54 :             ReadParam(aMsg, aIter, &aResult->mBackgroundColor) &&
     284          54 :             ReadContentDescription(aMsg, aIter, aResult) &&
     285          54 :             ReadParam(aMsg, aIter, &aResult->mLineScrollAmount) &&
     286          54 :             ReadParam(aMsg, aIter, &aResult->mPageScrollAmount) &&
     287          54 :             ReadParam(aMsg, aIter, &aResult->mScrollClip) &&
     288          54 :             ReadBoolForBitfield(aMsg, aIter, aResult, &paramType::SetHasScrollgrab) &&
     289          54 :             ReadBoolForBitfield(aMsg, aIter, aResult, &paramType::SetAllowVerticalScrollWithWheel) &&
     290          54 :             ReadBoolForBitfield(aMsg, aIter, aResult, &paramType::SetIsLayersIdRoot) &&
     291          81 :             ReadBoolForBitfield(aMsg, aIter, aResult, &paramType::SetUsesContainerScrolling) &&
     292          54 :             ReadBoolForBitfield(aMsg, aIter, aResult, &paramType::SetForceDisableApz));
     293             :   }
     294             : };
     295             : 
     296             : template<>
     297             : struct ParamTraits<mozilla::layers::TextureFactoryIdentifier>
     298             : {
     299             :   typedef mozilla::layers::TextureFactoryIdentifier paramType;
     300             : 
     301           2 :   static void Write(Message* aMsg, const paramType& aParam)
     302             :   {
     303           2 :     WriteParam(aMsg, aParam.mParentBackend);
     304           2 :     WriteParam(aMsg, aParam.mParentProcessType);
     305           2 :     WriteParam(aMsg, aParam.mMaxTextureSize);
     306           2 :     WriteParam(aMsg, aParam.mCompositorUseANGLE);
     307           2 :     WriteParam(aMsg, aParam.mSupportsTextureBlitting);
     308           2 :     WriteParam(aMsg, aParam.mSupportsPartialUploads);
     309           2 :     WriteParam(aMsg, aParam.mSupportsComponentAlpha);
     310           2 :     WriteParam(aMsg, aParam.mSupportsBackdropCopyForComponentAlpha);
     311           2 :     WriteParam(aMsg, aParam.mUsingAdvancedLayers);
     312           2 :     WriteParam(aMsg, aParam.mSyncHandle);
     313           2 :   }
     314             : 
     315           2 :   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
     316             :   {
     317           4 :     bool result = ReadParam(aMsg, aIter, &aResult->mParentBackend) &&
     318           4 :                   ReadParam(aMsg, aIter, &aResult->mParentProcessType) &&
     319           4 :                   ReadParam(aMsg, aIter, &aResult->mMaxTextureSize) &&
     320           4 :                   ReadParam(aMsg, aIter, &aResult->mCompositorUseANGLE) &&
     321           4 :                   ReadParam(aMsg, aIter, &aResult->mSupportsTextureBlitting) &&
     322           4 :                   ReadParam(aMsg, aIter, &aResult->mSupportsPartialUploads) &&
     323           4 :                   ReadParam(aMsg, aIter, &aResult->mSupportsComponentAlpha) &&
     324           4 :                   ReadParam(aMsg, aIter, &aResult->mSupportsBackdropCopyForComponentAlpha) &&
     325           6 :                   ReadParam(aMsg, aIter, &aResult->mUsingAdvancedLayers) &&
     326           4 :                   ReadParam(aMsg, aIter, &aResult->mSyncHandle);
     327           2 :     return result;
     328             :   }
     329             : };
     330             : 
     331             : template<>
     332             : struct ParamTraits<mozilla::layers::TextureInfo>
     333             : {
     334             :   typedef mozilla::layers::TextureInfo paramType;
     335             : 
     336          22 :   static void Write(Message* aMsg, const paramType& aParam)
     337             :   {
     338          22 :     WriteParam(aMsg, aParam.mCompositableType);
     339          22 :     WriteParam(aMsg, aParam.mTextureFlags);
     340          22 :   }
     341             : 
     342          22 :   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
     343             :   {
     344          44 :     return ReadParam(aMsg, aIter, &aResult->mCompositableType) &&
     345          44 :            ReadParam(aMsg, aIter, &aResult->mTextureFlags);
     346             :   }
     347             : };
     348             : 
     349             : template <>
     350             : struct ParamTraits<mozilla::layers::CompositableType>
     351             :   : public ContiguousEnumSerializer<
     352             :              mozilla::layers::CompositableType,
     353             :              mozilla::layers::CompositableType::UNKNOWN,
     354             :              mozilla::layers::CompositableType::COUNT>
     355             : {};
     356             : 
     357             : template <>
     358             : struct ParamTraits<mozilla::layers::ScrollableLayerGuid>
     359             : {
     360             :   typedef mozilla::layers::ScrollableLayerGuid paramType;
     361             : 
     362           7 :   static void Write(Message* aMsg, const paramType& aParam)
     363             :   {
     364           7 :     WriteParam(aMsg, aParam.mLayersId);
     365           7 :     WriteParam(aMsg, aParam.mPresShellId);
     366           7 :     WriteParam(aMsg, aParam.mScrollId);
     367           7 :   }
     368             : 
     369           7 :   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
     370             :   {
     371          14 :     return (ReadParam(aMsg, aIter, &aResult->mLayersId) &&
     372          14 :             ReadParam(aMsg, aIter, &aResult->mPresShellId) &&
     373          14 :             ReadParam(aMsg, aIter, &aResult->mScrollId));
     374             :   }
     375             : };
     376             : 
     377             : 
     378             : template <>
     379             : struct ParamTraits<mozilla::layers::ZoomConstraints>
     380             : {
     381             :   typedef mozilla::layers::ZoomConstraints paramType;
     382             : 
     383           1 :   static void Write(Message* aMsg, const paramType& aParam)
     384             :   {
     385           1 :     WriteParam(aMsg, aParam.mAllowZoom);
     386           1 :     WriteParam(aMsg, aParam.mAllowDoubleTapZoom);
     387           1 :     WriteParam(aMsg, aParam.mMinZoom);
     388           1 :     WriteParam(aMsg, aParam.mMaxZoom);
     389           1 :   }
     390             : 
     391           1 :   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
     392             :   {
     393           2 :     return (ReadParam(aMsg, aIter, &aResult->mAllowZoom) &&
     394           2 :             ReadParam(aMsg, aIter, &aResult->mAllowDoubleTapZoom) &&
     395           3 :             ReadParam(aMsg, aIter, &aResult->mMinZoom) &&
     396           2 :             ReadParam(aMsg, aIter, &aResult->mMaxZoom));
     397             :   }
     398             : };
     399             : 
     400             : template <>
     401             : struct ParamTraits<mozilla::layers::EventRegions>
     402             : {
     403             :   typedef mozilla::layers::EventRegions paramType;
     404             : 
     405         124 :   static void Write(Message* aMsg, const paramType& aParam)
     406             :   {
     407         124 :     WriteParam(aMsg, aParam.mHitRegion);
     408         124 :     WriteParam(aMsg, aParam.mDispatchToContentHitRegion);
     409         124 :     WriteParam(aMsg, aParam.mNoActionRegion);
     410         124 :     WriteParam(aMsg, aParam.mHorizontalPanRegion);
     411         124 :     WriteParam(aMsg, aParam.mVerticalPanRegion);
     412         124 :   }
     413             : 
     414         124 :   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
     415             :   {
     416         248 :     return (ReadParam(aMsg, aIter, &aResult->mHitRegion) &&
     417         248 :             ReadParam(aMsg, aIter, &aResult->mDispatchToContentHitRegion) &&
     418         248 :             ReadParam(aMsg, aIter, &aResult->mNoActionRegion) &&
     419         372 :             ReadParam(aMsg, aIter, &aResult->mHorizontalPanRegion) &&
     420         248 :             ReadParam(aMsg, aIter, &aResult->mVerticalPanRegion));
     421             :   }
     422             : };
     423             : 
     424             : template <>
     425             : struct ParamTraits<mozilla::layers::FocusTarget::ScrollTargets>
     426             : {
     427             :   typedef mozilla::layers::FocusTarget::ScrollTargets paramType;
     428             : 
     429           0 :   static void Write(Message* aMsg, const paramType& aParam)
     430             :   {
     431           0 :     WriteParam(aMsg, aParam.mHorizontal);
     432           0 :     WriteParam(aMsg, aParam.mVertical);
     433           0 :   }
     434             : 
     435           0 :   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
     436             :   {
     437           0 :     return ReadParam(aMsg, aIter, &aResult->mHorizontal) &&
     438           0 :            ReadParam(aMsg, aIter, &aResult->mVertical);
     439             :   }
     440             : };
     441             : 
     442             : template <>
     443             : struct ParamTraits<mozilla::layers::FocusTarget::FocusTargetType>
     444             :   : public ContiguousEnumSerializerInclusive<
     445             :              mozilla::layers::FocusTarget::FocusTargetType,
     446             :              mozilla::layers::FocusTarget::eNone,
     447             :              mozilla::layers::FocusTarget::sHighestFocusTargetType>
     448             : {};
     449             : 
     450             : template <>
     451             : struct ParamTraits<mozilla::layers::FocusTarget>
     452             : {
     453             :   typedef mozilla::layers::FocusTarget paramType;
     454             : 
     455          28 :   static void Write(Message* aMsg, const paramType& aParam)
     456             :   {
     457          28 :     WriteParam(aMsg, aParam.mSequenceNumber);
     458          28 :     WriteParam(aMsg, aParam.mFocusHasKeyEventListeners);
     459          28 :     WriteParam(aMsg, aParam.mType);
     460          28 :     if (aParam.mType == mozilla::layers::FocusTarget::eRefLayer) {
     461           0 :       WriteParam(aMsg, aParam.mData.mRefLayerId);
     462          28 :     } else if (aParam.mType == mozilla::layers::FocusTarget::eScrollLayer) {
     463           0 :       WriteParam(aMsg, aParam.mData.mScrollTargets);
     464             :     }
     465          28 :   }
     466             : 
     467          28 :   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
     468             :   {
     469          84 :     if (!ReadParam(aMsg, aIter, &aResult->mSequenceNumber) ||
     470          56 :         !ReadParam(aMsg, aIter, &aResult->mFocusHasKeyEventListeners) ||
     471          28 :         !ReadParam(aMsg, aIter, &aResult->mType)) {
     472           0 :       return false;
     473             :     }
     474             : 
     475          28 :     if (aResult->mType == mozilla::layers::FocusTarget::eRefLayer) {
     476           0 :       return ReadParam(aMsg, aIter, &aResult->mData.mRefLayerId);
     477          28 :     } else if (aResult->mType == mozilla::layers::FocusTarget::eScrollLayer) {
     478           0 :       return ReadParam(aMsg, aIter, &aResult->mData.mScrollTargets);
     479             :     }
     480             : 
     481          28 :     return true;
     482             :   }
     483             : };
     484             : 
     485             : template <>
     486             : struct ParamTraits<mozilla::layers::KeyboardScrollAction::KeyboardScrollActionType>
     487             :   : public ContiguousEnumSerializerInclusive<
     488             :              mozilla::layers::KeyboardScrollAction::KeyboardScrollActionType,
     489             :              mozilla::layers::KeyboardScrollAction::KeyboardScrollActionType::eScrollCharacter,
     490             :              mozilla::layers::KeyboardScrollAction::sHighestKeyboardScrollActionType>
     491             : {};
     492             : 
     493             : template <>
     494             : struct ParamTraits<mozilla::layers::KeyboardScrollAction>
     495             : {
     496             :   typedef mozilla::layers::KeyboardScrollAction paramType;
     497             : 
     498           0 :   static void Write(Message* aMsg, const paramType& aParam)
     499             :   {
     500           0 :     WriteParam(aMsg, aParam.mType);
     501           0 :     WriteParam(aMsg, aParam.mForward);
     502           0 :   }
     503             : 
     504           0 :   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
     505             :   {
     506           0 :     return ReadParam(aMsg, aIter, &aResult->mType) &&
     507           0 :            ReadParam(aMsg, aIter, &aResult->mForward);
     508             :   }
     509             : };
     510             : 
     511             : template <>
     512             : struct ParamTraits<mozilla::layers::KeyboardShortcut>
     513             : {
     514             :   typedef mozilla::layers::KeyboardShortcut paramType;
     515             : 
     516           0 :   static void Write(Message* aMsg, const paramType& aParam)
     517             :   {
     518           0 :     WriteParam(aMsg, aParam.mAction);
     519           0 :     WriteParam(aMsg, aParam.mKeyCode);
     520           0 :     WriteParam(aMsg, aParam.mCharCode);
     521           0 :     WriteParam(aMsg, aParam.mModifiers);
     522           0 :     WriteParam(aMsg, aParam.mModifiersMask);
     523           0 :     WriteParam(aMsg, aParam.mEventType);
     524           0 :     WriteParam(aMsg, aParam.mDispatchToContent);
     525           0 :   }
     526             : 
     527           0 :   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
     528             :   {
     529           0 :     return ReadParam(aMsg, aIter, &aResult->mAction) &&
     530           0 :            ReadParam(aMsg, aIter, &aResult->mKeyCode) &&
     531           0 :            ReadParam(aMsg, aIter, &aResult->mCharCode) &&
     532           0 :            ReadParam(aMsg, aIter, &aResult->mModifiers) &&
     533           0 :            ReadParam(aMsg, aIter, &aResult->mModifiersMask) &&
     534           0 :            ReadParam(aMsg, aIter, &aResult->mEventType) &&
     535           0 :            ReadParam(aMsg, aIter, &aResult->mDispatchToContent);
     536             :   }
     537             : };
     538             : 
     539             : template <>
     540             : struct ParamTraits<mozilla::layers::KeyboardMap>
     541             : {
     542             :   typedef mozilla::layers::KeyboardMap paramType;
     543             : 
     544           0 :   static void Write(Message* aMsg, const paramType& aParam)
     545             :   {
     546           0 :     WriteParam(aMsg, aParam.Shortcuts());
     547           0 :   }
     548             : 
     549           0 :   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
     550             :   {
     551           0 :     nsTArray<mozilla::layers::KeyboardShortcut> shortcuts;
     552           0 :     if (!ReadParam(aMsg, aIter, &shortcuts)) {
     553           0 :       return false;
     554             :     }
     555           0 :     *aResult = mozilla::layers::KeyboardMap(mozilla::Move(shortcuts));
     556           0 :     return true;
     557             :   }
     558             : };
     559             : 
     560             : typedef mozilla::layers::GeckoContentController GeckoContentController;
     561             : typedef GeckoContentController::TapType TapType;
     562             : 
     563             : template <>
     564             : struct ParamTraits<TapType>
     565             :   : public ContiguousEnumSerializerInclusive<
     566             :              TapType,
     567             :              TapType::eSingleTap,
     568             :              GeckoContentController::sHighestTapType>
     569             : {};
     570             : 
     571             : typedef GeckoContentController::APZStateChange APZStateChange;
     572             : 
     573             : template <>
     574             : struct ParamTraits<APZStateChange>
     575             :   : public ContiguousEnumSerializerInclusive<
     576             :              APZStateChange,
     577             :              APZStateChange::eTransformBegin,
     578             :              GeckoContentController::sHighestAPZStateChange>
     579             : {};
     580             : 
     581             : template<>
     582             : struct ParamTraits<mozilla::layers::EventRegionsOverride>
     583             :   : public BitFlagsEnumSerializer<
     584             :             mozilla::layers::EventRegionsOverride,
     585             :             mozilla::layers::EventRegionsOverride::ALL_BITS>
     586             : {};
     587             : 
     588             : template<>
     589             : struct ParamTraits<mozilla::layers::AsyncDragMetrics>
     590             : {
     591             :   typedef mozilla::layers::AsyncDragMetrics paramType;
     592             : 
     593           0 :   static void Write(Message* aMsg, const paramType& aParam)
     594             :   {
     595           0 :     WriteParam(aMsg, aParam.mViewId);
     596           0 :     WriteParam(aMsg, aParam.mPresShellId);
     597           0 :     WriteParam(aMsg, aParam.mDragStartSequenceNumber);
     598           0 :     WriteParam(aMsg, aParam.mScrollbarDragOffset);
     599           0 :     WriteParam(aMsg, aParam.mDirection);
     600           0 :   }
     601             : 
     602           0 :   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
     603             :   {
     604           0 :     return (ReadParam(aMsg, aIter, &aResult->mViewId) &&
     605           0 :             ReadParam(aMsg, aIter, &aResult->mPresShellId) &&
     606           0 :             ReadParam(aMsg, aIter, &aResult->mDragStartSequenceNumber) &&
     607           0 :             ReadParam(aMsg, aIter, &aResult->mScrollbarDragOffset) &&
     608           0 :             ReadParam(aMsg, aIter, &aResult->mDirection));
     609             :   }
     610             : };
     611             : 
     612             : template <>
     613             : struct ParamTraits<mozilla::layers::CompositorOptions>
     614             : {
     615             :   typedef mozilla::layers::CompositorOptions paramType;
     616             : 
     617           2 :   static void Write(Message* aMsg, const paramType& aParam) {
     618           2 :     WriteParam(aMsg, aParam.mUseAPZ);
     619           2 :     WriteParam(aMsg, aParam.mUseWebRender);
     620           2 :     WriteParam(aMsg, aParam.mUseAdvancedLayers);
     621           2 :   }
     622             : 
     623           2 :   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) {
     624           2 :     return ReadParam(aMsg, aIter, &aResult->mUseAPZ)
     625           2 :         && ReadParam(aMsg, aIter, &aResult->mUseWebRender)
     626           4 :         && ReadParam(aMsg, aIter, &aResult->mUseAdvancedLayers);
     627             :   }
     628             : };
     629             : 
     630             : template <>
     631             : struct ParamTraits<mozilla::layers::SimpleLayerAttributes>
     632             :   : public PlainOldDataSerializer<mozilla::layers::SimpleLayerAttributes>
     633             : { };
     634             : 
     635             : } /* namespace IPC */
     636             : 
     637             : #endif /* mozilla_layers_LayersMessageUtils */

Generated by: LCOV version 1.13