Bug 1257288 - Move IntersectMaybeRects() to gfx/2d/Rect.h. r=kats
MozReview-Commit-ID: C99GwsLN7Zg
--- a/gfx/2d/Rect.h
+++ b/gfx/2d/Rect.h
@@ -6,16 +6,17 @@
#ifndef MOZILLA_GFX_RECT_H_
#define MOZILLA_GFX_RECT_H_
#include "BaseRect.h"
#include "BaseMargin.h"
#include "NumericTools.h"
#include "Point.h"
#include "Tools.h"
+#include "mozilla/Maybe.h"
#include <cmath>
namespace mozilla {
template <typename> struct IsPixel;
namespace gfx {
@@ -235,12 +236,27 @@ IntRectTyped<units> TruncatedToInt(const
}
template<class units>
RectTyped<units> IntRectToRect(const IntRectTyped<units>& aRect)
{
return RectTyped<units>(aRect.x, aRect.y, aRect.width, aRect.height);
}
+// Convenience function for intersecting two IntRects wrapped in Maybes.
+template <typename Units>
+Maybe<IntRectTyped<Units>>
+IntersectMaybeRects(const Maybe<IntRectTyped<Units>>& a,
+ const Maybe<IntRectTyped<Units>>& b)
+{
+ if (!a) {
+ return b;
+ } else if (!b) {
+ return a;
+ } else {
+ return Some(a->Intersect(*b));
+ }
+}
+
} // namespace gfx
} // namespace mozilla
#endif /* MOZILLA_GFX_RECT_H_ */
--- a/gfx/layers/composite/AsyncCompositionManager.cpp
+++ b/gfx/layers/composite/AsyncCompositionManager.cpp
@@ -777,30 +777,16 @@ MoveScrollbarForLayerMargin(Layer* aRoot
// assuming a particular layer tree structure but short of adding more
// flags to the layer there doesn't appear to be a good way to do this.
ExpandRootClipRect(scrollbar->GetParent(), aFixedLayerMargins);
}
}
}
#endif
-template <typename Units>
-Maybe<IntRectTyped<Units>>
-IntersectMaybeRects(const Maybe<IntRectTyped<Units>>& a,
- const Maybe<IntRectTyped<Units>>& b)
-{
- if (!a) {
- return b;
- } else if (!b) {
- return a;
- } else {
- return Some(a->Intersect(*b));
- }
-}
-
bool
AsyncCompositionManager::ApplyAsyncContentTransformToTree(Layer *aLayer,
bool* aOutFoundRoot,
Maybe<ParentLayerIntRect>& aClipDeferredToParent)
{
Maybe<ParentLayerIntRect> clipDeferredFromChildren;
bool appliedTransform = false;
for (Layer* child = aLayer->GetFirstChild();
--- a/gfx/layers/composite/LayerManagerComposite.cpp
+++ b/gfx/layers/composite/LayerManagerComposite.cpp
@@ -192,29 +192,16 @@ LayerManagerComposite::BeginTransactionW
}
mIsCompositorReady = true;
mCompositor->SetTargetContext(aTarget, aRect);
mTarget = aTarget;
mTargetBounds = aRect;
}
-template<typename RectType>
-Maybe<RectType>
-IntersectMaybeRects(const Maybe<RectType>& aRect1, const Maybe<RectType>& aRect2)
-{
- if (aRect1) {
- if (aRect2) {
- return Some(aRect1->Intersect(*aRect2));
- }
- return aRect1;
- }
- return aRect2;
-}
-
/**
* Get accumulated transform of from the context creating layer to the
* given layer.
*/
static Matrix4x4
GetAccTransformIn3DContext(Layer* aLayer) {
Matrix4x4 transform = aLayer->GetLocalTransform();
for (Layer* layer = aLayer->GetParent();