Bug 1632310 [wpt PR 23186] - Add test for computed versus resolved style., a=testonly
[gecko.git] / gfx / layers / wr / RenderRootTypes.cpp
blob7d141c75903ed7ec08be8ac22f92f1f310af5683
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 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/. */
7 #include "RenderRootTypes.h"
8 #include "mozilla/layers/WebRenderMessageUtils.h"
9 #include "mozilla/layers/WebRenderBridgeChild.h"
11 namespace mozilla {
12 namespace ipc {
14 void IPDLParamTraits<mozilla::layers::RenderRootDisplayListData>::Write(
15 IPC::Message* aMsg, IProtocol* aActor, paramType&& aParam) {
16 WriteIPDLParam(aMsg, aActor, aParam.mRenderRoot);
17 WriteIPDLParam(aMsg, aActor, aParam.mIdNamespace);
18 WriteIPDLParam(aMsg, aActor, aParam.mRect);
19 WriteIPDLParam(aMsg, aActor, aParam.mCommands);
20 WriteIPDLParam(aMsg, aActor, aParam.mContentSize);
21 WriteIPDLParam(aMsg, aActor, std::move(aParam.mDL));
22 WriteIPDLParam(aMsg, aActor, aParam.mDLDesc);
23 WriteIPDLParam(aMsg, aActor, aParam.mRemotePipelineIds);
24 WriteIPDLParam(aMsg, aActor, aParam.mResourceUpdates);
25 WriteIPDLParam(aMsg, aActor, aParam.mSmallShmems);
26 WriteIPDLParam(aMsg, aActor, std::move(aParam.mLargeShmems));
27 WriteIPDLParam(aMsg, aActor, aParam.mScrollData);
30 bool IPDLParamTraits<mozilla::layers::RenderRootDisplayListData>::Read(
31 const IPC::Message* aMsg, PickleIterator* aIter, IProtocol* aActor,
32 paramType* aResult) {
33 if (ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRenderRoot) &&
34 ReadIPDLParam(aMsg, aIter, aActor, &aResult->mIdNamespace) &&
35 ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRect) &&
36 ReadIPDLParam(aMsg, aIter, aActor, &aResult->mCommands) &&
37 ReadIPDLParam(aMsg, aIter, aActor, &aResult->mContentSize) &&
38 ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDL) &&
39 ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDLDesc) &&
40 ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRemotePipelineIds) &&
41 ReadIPDLParam(aMsg, aIter, aActor, &aResult->mResourceUpdates) &&
42 ReadIPDLParam(aMsg, aIter, aActor, &aResult->mSmallShmems) &&
43 ReadIPDLParam(aMsg, aIter, aActor, &aResult->mLargeShmems) &&
44 ReadIPDLParam(aMsg, aIter, aActor, &aResult->mScrollData)) {
45 return true;
47 return false;
50 void WriteScrollUpdates(IPC::Message* aMsg, IProtocol* aActor,
51 layers::ScrollUpdatesMap& aParam) {
52 // ICK: we need to manually serialize this map because
53 // nsDataHashTable doesn't support it (and other maps cause other issues)
54 WriteIPDLParam(aMsg, aActor, aParam.Count());
55 for (auto it = aParam.Iter(); !it.Done(); it.Next()) {
56 WriteIPDLParam(aMsg, aActor, it.Key());
57 WriteIPDLParam(aMsg, aActor, it.Data());
61 bool ReadScrollUpdates(const IPC::Message* aMsg, PickleIterator* aIter,
62 IProtocol* aActor, layers::ScrollUpdatesMap* aResult) {
63 // Manually deserialize mScrollUpdates as a stream of K,V pairs
64 uint32_t count;
65 if (!ReadIPDLParam(aMsg, aIter, aActor, &count)) {
66 return false;
69 layers::ScrollUpdatesMap map(count);
70 for (size_t i = 0; i < count; ++i) {
71 layers::ScrollableLayerGuid::ViewID key;
72 layers::ScrollUpdateInfo data;
73 if (!ReadIPDLParam(aMsg, aIter, aActor, &key) ||
74 !ReadIPDLParam(aMsg, aIter, aActor, &data)) {
75 return false;
77 map.Put(key, data);
80 MOZ_RELEASE_ASSERT(map.Count() == count);
81 *aResult = std::move(map);
82 return true;
85 void IPDLParamTraits<mozilla::layers::RenderRootUpdates>::Write(
86 IPC::Message* aMsg, IProtocol* aActor, paramType&& aParam) {
87 WriteIPDLParam(aMsg, aActor, aParam.mRenderRoot);
88 WriteIPDLParam(aMsg, aActor, aParam.mCommands);
89 WriteIPDLParam(aMsg, aActor, aParam.mResourceUpdates);
90 WriteIPDLParam(aMsg, aActor, aParam.mSmallShmems);
91 WriteIPDLParam(aMsg, aActor, std::move(aParam.mLargeShmems));
92 WriteScrollUpdates(aMsg, aActor, aParam.mScrollUpdates);
93 WriteIPDLParam(aMsg, aActor, aParam.mPaintSequenceNumber);
96 bool IPDLParamTraits<mozilla::layers::RenderRootUpdates>::Read(
97 const IPC::Message* aMsg, PickleIterator* aIter, IProtocol* aActor,
98 paramType* aResult) {
99 if (ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRenderRoot) &&
100 ReadIPDLParam(aMsg, aIter, aActor, &aResult->mCommands) &&
101 ReadIPDLParam(aMsg, aIter, aActor, &aResult->mResourceUpdates) &&
102 ReadIPDLParam(aMsg, aIter, aActor, &aResult->mSmallShmems) &&
103 ReadIPDLParam(aMsg, aIter, aActor, &aResult->mLargeShmems) &&
104 ReadScrollUpdates(aMsg, aIter, aActor, &aResult->mScrollUpdates) &&
105 ReadIPDLParam(aMsg, aIter, aActor, &aResult->mPaintSequenceNumber)) {
106 return true;
108 return false;
111 } // namespace ipc
112 } // namespace mozilla