Bug 1257288 - Move IntersectMaybeRects() to gfx/2d/Rect.h. r=kats draft
authorBotond Ballo <botond@mozilla.com>
Wed, 20 Apr 2016 17:16:09 -0400
changeset 354442 e12db0995ec0f1ffc30e0f01b8c85081236b405c
parent 354441 de34e116f5658b6e0f351999b7c308f99d14291d
child 354443 a2e336bf5b80b94e90ed3d9c9b0f12f1c85cd86f
push id16081
push userbballo@mozilla.com
push dateWed, 20 Apr 2016 22:37:55 +0000
reviewerskats
bugs1257288
milestone48.0a1
Bug 1257288 - Move IntersectMaybeRects() to gfx/2d/Rect.h. r=kats MozReview-Commit-ID: C99GwsLN7Zg
gfx/2d/Rect.h
gfx/layers/composite/AsyncCompositionManager.cpp
gfx/layers/composite/LayerManagerComposite.cpp
--- 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();