Bug 1434250 - Infrastructure for working with Box types in Gecko code. r=kats draft
authorBotond Ballo <botond@mozilla.com>
Wed, 07 Feb 2018 12:52:37 -0500
changeset 753217 6b5f6cf27eb89a0e4a9764246229d5f84485fb5b
parent 753216 bdf1642130f7d7245b2756f7f16e0d7b043009bd
child 753218 4f163eca06a7f99eb3d01c80daf8c4674126d4e0
push id98523
push userbballo@mozilla.com
push dateFri, 09 Feb 2018 20:49:23 +0000
reviewerskats
bugs1434250
milestone60.0a1
Bug 1434250 - Infrastructure for working with Box types in Gecko code. r=kats MozReview-Commit-ID: 5fbTj6vwOwu
gfx/src/moz.build
gfx/src/nsCoordBox.h
layout/base/Units.h
--- a/gfx/src/moz.build
+++ b/gfx/src/moz.build
@@ -18,16 +18,17 @@ EXPORTS += [
     'FilterSupport.h',
     'gfxCrashReporterUtils.h',
     'gfxTelemetry.h',
     'nsBoundingMetrics.h',
     'nsColor.h',
     'nsColorNameList.h',
     'nsColorNames.h',
     'nsCoord.h',
+    'nsCoordBox.h',
     'nsDeviceContext.h',
     'nsFont.h',
     'nsFontMetrics.h',
     'nsGfxCIID.h',
     'nsITheme.h',
     'nsMargin.h',
     'nsPoint.h',
     'nsRect.h',
new file mode 100644
--- /dev/null
+++ b/gfx/src/nsCoordBox.h
@@ -0,0 +1,24 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef NSCOORDBOX_H
+#define NSCOORDBOX_H
+
+#include "mozilla/gfx/Box.h"
+#include "nsCoord.h"
+#include "nsRect.h"
+
+// Would like to call this nsBox, but can't because nsBox is a frame type.
+struct nsCoordBox :
+  public mozilla::gfx::BaseBox<nscoord, nsCoordBox, nsRect> {
+  typedef mozilla::gfx::BaseBox<nscoord, nsCoordBox, nsRect> Super;
+
+  nsCoordBox() : Super() {}
+  nsCoordBox(nscoord aX1, nscoord aY1, nscoord aX2, nscoord aY2) :
+      Super(aX1, aY1, aX2, aY2) {}
+};
+
+#endif /* NSCOORDBOX_H */
--- a/layout/base/Units.h
+++ b/layout/base/Units.h
@@ -2,16 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZ_UNITS_H_
 #define MOZ_UNITS_H_
 
+#include "mozilla/gfx/Box.h"
 #include "mozilla/gfx/Coord.h"
 #include "mozilla/gfx/Point.h"
 #include "mozilla/gfx/Rect.h"
 #include "mozilla/gfx/ScaleFactor.h"
 #include "mozilla/gfx/ScaleFactors2D.h"
 #include "nsMargin.h"
 #include "nsRect.h"
 #include "nsRegion.h"
@@ -69,16 +70,17 @@ typedef gfx::IntMarginTyped<LayoutDevice
 typedef gfx::IntRegionTyped<LayoutDevicePixel> LayoutDeviceIntRegion;
 
 typedef gfx::CoordTyped<LayerPixel> LayerCoord;
 typedef gfx::IntCoordTyped<LayerPixel> LayerIntCoord;
 typedef gfx::PointTyped<LayerPixel> LayerPoint;
 typedef gfx::IntPointTyped<LayerPixel> LayerIntPoint;
 typedef gfx::SizeTyped<LayerPixel> LayerSize;
 typedef gfx::IntSizeTyped<LayerPixel> LayerIntSize;
+typedef gfx::BoxTyped<LayerPixel> LayerBox;
 typedef gfx::RectTyped<LayerPixel> LayerRect;
 typedef gfx::IntRectTyped<LayerPixel> LayerIntRect;
 typedef gfx::MarginTyped<LayerPixel> LayerMargin;
 typedef gfx::IntMarginTyped<LayerPixel> LayerIntMargin;
 typedef gfx::IntRegionTyped<LayerPixel> LayerIntRegion;
 
 typedef gfx::CoordTyped<CSSTransformedLayerPixel> CSSTransformedLayerCoord;
 typedef gfx::IntCoordTyped<CSSTransformedLayerPixel> CSSTransformedLayerIntCoord;