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 "nsRect.h"
11 
12 namespace mozilla {
13 namespace 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:
EffectsInfo()22   EffectsInfo() { *this = EffectsInfo::FullyHidden(); }
23 
VisibleWithinRect(const nsRect & aVisibleRect,float aScaleX,float aScaleY)24   static EffectsInfo VisibleWithinRect(const nsRect& aVisibleRect,
25                                        float aScaleX, float aScaleY) {
26     return EffectsInfo{aVisibleRect, aScaleX, aScaleY};
27   }
FullyHidden()28   static EffectsInfo FullyHidden() { return EffectsInfo{nsRect(), 1.0f, 1.0f}; }
29 
30   bool operator==(const EffectsInfo& aOther) {
31     return mVisibleRect == aOther.mVisibleRect && mScaleX == aOther.mScaleX &&
32            mScaleY == aOther.mScaleY;
33   }
34   bool operator!=(const EffectsInfo& aOther) { return !(*this == aOther); }
35 
IsVisible()36   bool IsVisible() const { return !mVisibleRect.IsEmpty(); }
37 
38   // The visible rect of this browser relative to the root frame. If this is
39   // empty then the browser can be considered invisible.
40   nsRect mVisibleRect;
41   // The desired scale factors to apply to rasterized content to match
42   // transforms applied in ancestor browsers.
43   float mScaleX;
44   float mScaleY;
45   // If you add new fields here, you must also update operator==
46 
47  private:
EffectsInfo(const nsRect & aVisibleRect,float aScaleX,float aScaleY)48   EffectsInfo(const nsRect& aVisibleRect, float aScaleX, float aScaleY)
49       : mVisibleRect(aVisibleRect), mScaleX(aScaleX), mScaleY(aScaleY) {}
50 };
51 
52 }  // namespace dom
53 }  // namespace mozilla
54 
55 #endif  // mozilla_dom_EffectsInfo_h
56