TestWRScrollData.h (2274B)
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/. */ 6 7 #ifndef mozilla_layers_TestWRScrollData_h 8 #define mozilla_layers_TestWRScrollData_h 9 10 #include "mozilla/gfx/MatrixFwd.h" 11 #include "mozilla/layers/WebRenderScrollData.h" 12 13 namespace mozilla { 14 namespace layers { 15 16 class APZUpdater; 17 18 // Extends WebRenderScrollData with some methods useful for gtests. 19 class TestWRScrollData : public WebRenderScrollData { 20 public: 21 TestWRScrollData() = default; 22 TestWRScrollData(TestWRScrollData&& aOther) = default; 23 TestWRScrollData& operator=(TestWRScrollData&& aOther) = default; 24 25 /* 26 * Create a WebRenderLayerScrollData tree described by |aTreeShape|. 27 * |aTreeShape| is expected to be a string where each character is 28 * either 'x' to indicate a node in the tree, or a '(' or ')' to indicate 29 * the start/end of a subtree. 30 * 31 * Example "x(x(x(xx)x))" would yield: 32 * x 33 * | 34 * x 35 * / \ 36 * x x 37 * / \ 38 * x x 39 * 40 * The caller may optionally provide visible rects and/or transforms 41 * for the nodes. If provided, the array should contain one element 42 * for each node, in the same order as in |aTreeShape|. 43 */ 44 static TestWRScrollData Create(const char* aTreeShape, 45 const APZUpdater& aUpdater, 46 const LayerIntRect* aVisibleRects = nullptr, 47 const gfx::Matrix4x4* aTransforms = nullptr); 48 49 // These methods allow accessing and manipulating layers based on an index 50 // representing the order in which they appear in |aTreeShape|. 51 WebRenderLayerScrollData* operator[](size_t aLayerIndex); 52 const WebRenderLayerScrollData* operator[](size_t aLayerIndex) const; 53 void SetScrollMetadata(size_t aLayerIndex, 54 const nsTArray<ScrollMetadata>& aMetadata); 55 56 private: 57 std::map<size_t, size_t> mIndexMap; // Used to implement GetLayer() 58 }; 59 60 } // namespace layers 61 } // namespace mozilla 62 63 #endif