Backed out changeset b4a0f8afc02e (bug 1857946) for causing bc failures at browser...
[gecko.git] / widget / cocoa / ViewRegion.h
blob4c98fab882da3b5efcd627912c6e1707e8b77986
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 coordinates.
33 * @param aContainerView The view that's going to be the superview of the
34 * NSViews which will be created for this region.
35 * @param aViewCreationCallback A block that instantiates new NSViews.
36 * @return Whether or not the region changed.
38 bool UpdateRegion(const mozilla::LayoutDeviceIntRegion& aRegion,
39 const nsChildView& aCoordinateConverter, NSView* aContainerView,
40 NSView* (^aViewCreationCallback)());
42 /**
43 * Return an NSView from the region, if there is any.
45 NSView* GetAnyView() { return mViews.Length() > 0 ? mViews[0] : NULL; }
47 private:
48 mozilla::LayoutDeviceIntRegion mRegion;
49 nsTArray<NSView*> mViews;
52 } // namespace mozilla
54 #endif // ViewRegion_h