EffectsInfo.h (2475B)
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_dom_EffectsInfo_h 8 #define mozilla_dom_EffectsInfo_h 9 10 #include "Units.h" 11 #include "nsRect.h" 12 13 namespace mozilla::dom { 14 15 /** 16 * An EffectsInfo contains information for a remote browser about the graphical 17 * effects that are being applied to it by ancestor browsers in different 18 * processes. 19 */ 20 class EffectsInfo { 21 public: 22 EffectsInfo() = default; 23 24 static EffectsInfo VisibleWithinRect( 25 const Maybe<nsRect>& aVisibleRect, const Scale2D& aRasterScale, 26 const ParentLayerToScreenScale2D& aTransformToAncestorScale) { 27 return EffectsInfo{aVisibleRect, aRasterScale, aTransformToAncestorScale}; 28 } 29 static EffectsInfo FullyHidden() { return {}; } 30 31 bool operator==(const EffectsInfo& aOther) const { 32 return mVisibleRect == aOther.mVisibleRect && 33 mRasterScale == aOther.mRasterScale && 34 mTransformToAncestorScale == aOther.mTransformToAncestorScale; 35 } 36 bool operator!=(const EffectsInfo& aOther) const { 37 return !(*this == aOther); 38 } 39 40 bool IsVisible() const { return mVisibleRect.isSome(); } 41 42 // The visible rect of this browser relative to the root frame. This might be 43 // empty in cases where we might still be considered visible, like if we're 44 // zero-size but inside the viewport. 45 Maybe<nsRect> mVisibleRect; 46 // The desired scale factors to apply to rasterized content to match 47 // transforms applied in ancestor browsers. This gets propagated into the 48 // scale in StackingContextHelper. 49 Scale2D mRasterScale; 50 // TransformToAncestorScale to be set on FrameMetrics. It includes CSS 51 // transform scales and cumulative presshell resolution. 52 ParentLayerToScreenScale2D mTransformToAncestorScale; 53 54 // If you add new fields here, you must also update operator== and 55 // TabMessageUtils. 56 57 private: 58 EffectsInfo(const Maybe<nsRect>& aVisibleRect, const Scale2D& aRasterScale, 59 const ParentLayerToScreenScale2D& aTransformToAncestorScale) 60 : mVisibleRect(aVisibleRect), 61 mRasterScale(aRasterScale), 62 mTransformToAncestorScale(aTransformToAncestorScale) {} 63 }; 64 65 } // namespace mozilla::dom 66 67 #endif // mozilla_dom_EffectsInfo_h