Bug 1841966 - Fix verifyOpenLinkInNewPrivateTabContextMenuOptionTest UI test r=aaronmt
[gecko.git] / widget / cocoa / ViewRegion.h
blobb2ed0c883515fe32f551a2c964966d43d6331336
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 ViewRegion_h
8 #define ViewRegion_h
10 #include "Units.h"
11 #include "nsTArray.h"
13 class nsChildView;
15 @class NSView;
17 namespace mozilla {
19 /**
20 * Manages a set of NSViews to cover a LayoutDeviceIntRegion.
22 class ViewRegion {
23 public:
24 ~ViewRegion();
26 mozilla::LayoutDeviceIntRegion Region() { return mRegion; }
28 /**
29 * Update the region.
30 * @param aRegion The new region.
31 * @param aCoordinateConverter The nsChildView to use for converting
32 * LayoutDeviceIntRect device pixel coordinates into Cocoa NSRect
33 * coordinates.
34 * @param aContainerView The view that's going to be the superview of the
35 * NSViews which will be created for this region.
36 * @param aViewCreationCallback A block that instantiates new NSViews.
37 * @return Whether or not the region changed.
39 bool UpdateRegion(const mozilla::LayoutDeviceIntRegion& aRegion,
40 const nsChildView& aCoordinateConverter,
41 NSView* aContainerView, NSView* (^aViewCreationCallback)());
43 /**
44 * Return an NSView from the region, if there is any.
46 NSView* GetAnyView() { return mViews.Length() > 0 ? mViews[0] : NULL; }
48 private:
49 mozilla::LayoutDeviceIntRegion mRegion;
50 nsTArray<NSView*> mViews;
53 } // namespace mozilla
55 #endif // ViewRegion_h