Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / widget / cocoa / ViewRegion.h
blobd44bde5f71bf3e644fce61e2b29a2207b6089450
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 "nsRegion.h"
12 #include "nsTArray.h"
14 class nsChildView;
16 @class NSView;
18 namespace mozilla {
20 /**
21 * Manages a set of NSViews to cover a LayoutDeviceIntRegion.
23 class ViewRegion {
24 public:
25 ~ViewRegion();
27 mozilla::LayoutDeviceIntRegion Region() { return mRegion; }
29 /**
30 * Update the region.
31 * @param aRegion The new region.
32 * @param aCoordinateConverter The nsChildView to use for converting
33 * LayoutDeviceIntRect device pixel coordinates into Cocoa NSRect
34 * coordinates.
35 * @param aContainerView The view that's going to be the superview of the
36 * NSViews which will be created for this region.
37 * @param aViewCreationCallback A block that instantiates new NSViews.
38 * @return Whether or not the region changed.
40 bool UpdateRegion(const mozilla::LayoutDeviceIntRegion& aRegion,
41 const nsChildView& aCoordinateConverter,
42 NSView* aContainerView, NSView* (^aViewCreationCallback)());
44 /**
45 * Return an NSView from the region, if there is any.
47 NSView* GetAnyView() { return mViews.Length() > 0 ? mViews[0] : NULL; }
49 private:
50 mozilla::LayoutDeviceIntRegion mRegion;
51 nsTArray<NSView*> mViews;
54 } // namespace mozilla
56 #endif // ViewRegion_h