Bug 1861467 - [wpt-sync] Update web-platform-tests to eedf737ce39c512d0ca3471f988972e...
[gecko.git] / dom / ipc / EffectsInfo.h
blob3c24b7a1cff168c672125fd63e9e89861c23e446
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 #ifndef mozilla_dom_EffectsInfo_h
8 #define mozilla_dom_EffectsInfo_h
10 #include "nsRect.h"
11 #include "Units.h"
13 namespace mozilla::dom {
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.
20 class EffectsInfo {
21 public:
22 EffectsInfo() = default;
24 static EffectsInfo VisibleWithinRect(
25 const Maybe<nsRect>& aVisibleRect, const Scale2D& aRasterScale,
26 const ParentLayerToScreenScale2D& aTransformToAncestorScale) {
27 return EffectsInfo{aVisibleRect, aRasterScale, aTransformToAncestorScale};
29 static EffectsInfo FullyHidden() { return {}; }
31 bool operator==(const EffectsInfo& aOther) const {
32 return mVisibleRect == aOther.mVisibleRect &&
33 mRasterScale == aOther.mRasterScale &&
34 mTransformToAncestorScale == aOther.mTransformToAncestorScale;
36 bool operator!=(const EffectsInfo& aOther) const {
37 return !(*this == aOther);
40 bool IsVisible() const { return mVisibleRect.isSome(); }
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;
54 // If you add new fields here, you must also update operator== and
55 // TabMessageUtils.
57 private:
58 EffectsInfo(const Maybe<nsRect>& aVisibleRect, const Scale2D& aRasterScale,
59 const ParentLayerToScreenScale2D& aTransformToAncestorScale)
60 : mVisibleRect(aVisibleRect),
61 mRasterScale(aRasterScale),
62 mTransformToAncestorScale(aTransformToAncestorScale) {}
65 } // namespace mozilla::dom
67 #endif // mozilla_dom_EffectsInfo_h