Bug 908726. Add AppUnits.h so we don't need nsDeviceContext.h for AppUnitsPerCSSPixel(). r=ehsan
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Fri, 06 Sep 2013 16:15:04 -0400
changeset 159173 12d7c0e889d150081d4b5baf6394a77532e078e6
parent 159172 2fce3bcfb3c83e922f652175daa8ec0f292a8738
child 159174 39bba9d8dbac46ba46285ee16aaf5cf638d61bac
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs908726
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 908726. Add AppUnits.h so we don't need nsDeviceContext.h for AppUnitsPerCSSPixel(). r=ehsan
content/events/src/Touch.h
gfx/src/AppUnits.h
gfx/src/moz.build
gfx/src/nsDeviceContext.h
layout/base/Units.h
layout/base/nsPresContext.h
--- a/content/events/src/Touch.h
+++ b/content/events/src/Touch.h
@@ -3,16 +3,17 @@
  * 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 mozilla_dom_Touch_h
 #define mozilla_dom_Touch_h
 
 #include "mozilla/Attributes.h"
 #include "nsWrapperCache.h"
+#include "nsAutoPtr.h"
 #include "Units.h"
 
 class nsPresContext;
 class nsEvent;
 
 namespace mozilla {
 namespace dom {
 
new file mode 100644
--- /dev/null
+++ b/gfx/src/AppUnits.h
@@ -0,0 +1,11 @@
+/* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* 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 _NS_APPUNITS_H_
+#define _NS_APPUNITS_H_
+namespace mozilla {
+static int32_t AppUnitsPerCSSPixel() { return 60; }
+}
+#endif /* _NS_APPUNITS_H_ */
--- a/gfx/src/moz.build
+++ b/gfx/src/moz.build
@@ -29,16 +29,20 @@ EXPORTS += [
     'nsRect.h',
     'nsRegion.h',
     'nsRenderingContext.h',
     'nsSize.h',
     'nsThemeConstants.h',
     'nsTransform2D.h',
 ]
 
+EXPORTS.mozilla += [
+    'AppUnits.h',
+]
+
 if CONFIG['MOZ_X11']:
     EXPORTS.mozilla += ['X11Util.h']
     CPP_SOURCES += [
         'X11Util.cpp',
     ]
 
 CPP_SOURCES += [
     'gfxCrashReporterUtils.cpp',
--- a/gfx/src/nsDeviceContext.h
+++ b/gfx/src/nsDeviceContext.h
@@ -12,16 +12,17 @@
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT_HELPER2
 #include "nsAutoPtr.h"                  // for nsRefPtr
 #include "nsCOMPtr.h"                   // for nsCOMPtr
 #include "nsCoord.h"                    // for nscoord
 #include "nsError.h"                    // for nsresult
 #include "nsISupports.h"                // for NS_INLINE_DECL_REFCOUNTING
 #include "nsMathUtils.h"                // for NS_round
 #include "nscore.h"                     // for PRUnichar, nsAString
+#include "mozilla/AppUnits.h"           // for AppUnits
 
 class gfxASurface;
 class gfxUserFontSet;
 class nsFont;
 class nsFontCache;
 class nsFontMetrics;
 class nsIAtom;
 class nsIDeviceContextSpec;
@@ -60,17 +61,17 @@ public:
      * @return error status
      */
     nsresult CreateRenderingContext(nsRenderingContext *&aContext);
 
     /**
      * Gets the number of app units in one CSS pixel; this number is global,
      * not unique to each device context.
      */
-    static int32_t AppUnitsPerCSSPixel() { return 60; }
+    static int32_t AppUnitsPerCSSPixel() { return mozilla::AppUnitsPerCSSPixel(); }
 
     /**
      * Gets the number of app units in one device pixel; this number
      * is usually a factor of AppUnitsPerCSSPixel(), although that is
      * not guaranteed.
      */
     int32_t AppUnitsPerDevPixel() const { return mAppUnitsPerDevPixel; }
 
--- a/layout/base/Units.h
+++ b/layout/base/Units.h
@@ -7,16 +7,17 @@
 #ifndef MOZ_UNITS_H_
 #define MOZ_UNITS_H_
 
 #include "mozilla/gfx/Point.h"
 #include "mozilla/gfx/Rect.h"
 #include "mozilla/gfx/ScaleFactor.h"
 #include "nsDeviceContext.h"
 #include "nsRect.h"
+#include "mozilla/AppUnits.h"
 
 namespace mozilla {
 
 struct CSSPixel;
 struct LayoutDevicePixel;
 struct LayerPixel;
 struct ScreenPixel;
 
@@ -73,69 +74,69 @@ typedef gfx::ScaleFactor<ScreenPixel, Sc
 /*
  * The pixels that content authors use to specify sizes in.
  */
 struct CSSPixel {
 
   // Conversions from app units
 
   static CSSPoint FromAppUnits(const nsPoint& aPoint) {
-    return CSSPoint(NSAppUnitsToFloatPixels(aPoint.x, float(nsDeviceContext::AppUnitsPerCSSPixel())),
-                    NSAppUnitsToFloatPixels(aPoint.y, float(nsDeviceContext::AppUnitsPerCSSPixel())));
+    return CSSPoint(NSAppUnitsToFloatPixels(aPoint.x, float(AppUnitsPerCSSPixel())),
+                    NSAppUnitsToFloatPixels(aPoint.y, float(AppUnitsPerCSSPixel())));
   }
 
   static CSSRect FromAppUnits(const nsRect& aRect) {
-    return CSSRect(NSAppUnitsToFloatPixels(aRect.x, float(nsDeviceContext::AppUnitsPerCSSPixel())),
-                   NSAppUnitsToFloatPixels(aRect.y, float(nsDeviceContext::AppUnitsPerCSSPixel())),
-                   NSAppUnitsToFloatPixels(aRect.width, float(nsDeviceContext::AppUnitsPerCSSPixel())),
-                   NSAppUnitsToFloatPixels(aRect.height, float(nsDeviceContext::AppUnitsPerCSSPixel())));
+    return CSSRect(NSAppUnitsToFloatPixels(aRect.x, float(AppUnitsPerCSSPixel())),
+                   NSAppUnitsToFloatPixels(aRect.y, float(AppUnitsPerCSSPixel())),
+                   NSAppUnitsToFloatPixels(aRect.width, float(AppUnitsPerCSSPixel())),
+                   NSAppUnitsToFloatPixels(aRect.height, float(AppUnitsPerCSSPixel())));
   }
 
   static CSSIntPoint FromAppUnitsRounded(const nsPoint& aPoint) {
-    return CSSIntPoint(NSAppUnitsToIntPixels(aPoint.x, float(nsDeviceContext::AppUnitsPerCSSPixel())),
-                       NSAppUnitsToIntPixels(aPoint.y, float(nsDeviceContext::AppUnitsPerCSSPixel())));
+    return CSSIntPoint(NSAppUnitsToIntPixels(aPoint.x, float(AppUnitsPerCSSPixel())),
+                       NSAppUnitsToIntPixels(aPoint.y, float(AppUnitsPerCSSPixel())));
   }
 
   static CSSIntSize FromAppUnitsRounded(const nsSize& aSize)
   {
-    return CSSIntSize(NSAppUnitsToIntPixels(aSize.width, float(nsDeviceContext::AppUnitsPerCSSPixel())),
-                      NSAppUnitsToIntPixels(aSize.height, float(nsDeviceContext::AppUnitsPerCSSPixel())));
+    return CSSIntSize(NSAppUnitsToIntPixels(aSize.width, float(AppUnitsPerCSSPixel())),
+                      NSAppUnitsToIntPixels(aSize.height, float(AppUnitsPerCSSPixel())));
   }
 
   static CSSIntRect FromAppUnitsRounded(const nsRect& aRect) {
-    return CSSIntRect(NSAppUnitsToIntPixels(aRect.x, float(nsDeviceContext::AppUnitsPerCSSPixel())),
-                      NSAppUnitsToIntPixels(aRect.y, float(nsDeviceContext::AppUnitsPerCSSPixel())),
-                      NSAppUnitsToIntPixels(aRect.width, float(nsDeviceContext::AppUnitsPerCSSPixel())),
-                      NSAppUnitsToIntPixels(aRect.height, float(nsDeviceContext::AppUnitsPerCSSPixel())));
+    return CSSIntRect(NSAppUnitsToIntPixels(aRect.x, float(AppUnitsPerCSSPixel())),
+                      NSAppUnitsToIntPixels(aRect.y, float(AppUnitsPerCSSPixel())),
+                      NSAppUnitsToIntPixels(aRect.width, float(AppUnitsPerCSSPixel())),
+                      NSAppUnitsToIntPixels(aRect.height, float(AppUnitsPerCSSPixel())));
   }
 
   // Conversions to app units
 
   static nsPoint ToAppUnits(const CSSPoint& aPoint) {
-    return nsPoint(NSToCoordRoundWithClamp(aPoint.x * float(nsDeviceContext::AppUnitsPerCSSPixel())),
-                   NSToCoordRoundWithClamp(aPoint.y * float(nsDeviceContext::AppUnitsPerCSSPixel())));
+    return nsPoint(NSToCoordRoundWithClamp(aPoint.x * float(AppUnitsPerCSSPixel())),
+                   NSToCoordRoundWithClamp(aPoint.y * float(AppUnitsPerCSSPixel())));
   }
 
   static nsPoint ToAppUnits(const CSSIntPoint& aPoint) {
-    return nsPoint(NSToCoordRoundWithClamp(float(aPoint.x) * float(nsDeviceContext::AppUnitsPerCSSPixel())),
-                   NSToCoordRoundWithClamp(float(aPoint.y) * float(nsDeviceContext::AppUnitsPerCSSPixel())));
+    return nsPoint(NSToCoordRoundWithClamp(float(aPoint.x) * float(AppUnitsPerCSSPixel())),
+                   NSToCoordRoundWithClamp(float(aPoint.y) * float(AppUnitsPerCSSPixel())));
   }
 
   static nsRect ToAppUnits(const CSSRect& aRect) {
-    return nsRect(NSToCoordRoundWithClamp(aRect.x * float(nsDeviceContext::AppUnitsPerCSSPixel())),
-                  NSToCoordRoundWithClamp(aRect.y * float(nsDeviceContext::AppUnitsPerCSSPixel())),
-                  NSToCoordRoundWithClamp(aRect.width * float(nsDeviceContext::AppUnitsPerCSSPixel())),
-                  NSToCoordRoundWithClamp(aRect.height * float(nsDeviceContext::AppUnitsPerCSSPixel())));
+    return nsRect(NSToCoordRoundWithClamp(aRect.x * float(AppUnitsPerCSSPixel())),
+                  NSToCoordRoundWithClamp(aRect.y * float(AppUnitsPerCSSPixel())),
+                  NSToCoordRoundWithClamp(aRect.width * float(AppUnitsPerCSSPixel())),
+                  NSToCoordRoundWithClamp(aRect.height * float(AppUnitsPerCSSPixel())));
   }
 };
 
 /*
  * The pixels that are referred to as "device pixels" in layout code. In
  * general this is obtained by converting a value in app units value by the
- * nsDeviceContext::AppUnitsPerDevPixel() value. The size of these pixels
+ * AppUnitsPerDevPixel() value. The size of these pixels
  * are affected by:
  * 1) the "full zoom" (see nsPresContext::SetFullZoom)
  * 2) the "widget scale" (see nsIWidget::GetDefaultScale)
  */
 struct LayoutDevicePixel {
   static LayoutDeviceIntPoint FromUntyped(const nsIntPoint& aPoint) {
     return LayoutDeviceIntPoint(aPoint.x, aPoint.y);
   }
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -27,16 +27,17 @@
 #include "nsChangeHint.h"
 #include <algorithm>
 // This also pulls in gfxTypes.h, which we cannot include directly.
 #include "gfxRect.h"
 #include "nsTArray.h"
 #include "nsAutoPtr.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/TimeStamp.h"
+#include "mozilla/AppUnits.h"
 #include "prclist.h"
 #include "nsThreadUtils.h"
 #include "ScrollbarStyles.h"
 
 #ifdef IBMBIDI
 class nsBidiPresUtils;
 #endif // IBMBIDI
 
@@ -551,43 +552,43 @@ public:
    *
    * If |aChanged| is non-null, then aChanged is filled in with whether
    * the return value has changed since either:
    *  a. the last time the function was called with non-null aChanged, or
    *  b. the first time the function was called.
    */
   float ScreenWidthInchesForFontInflation(bool* aChanged = nullptr);
 
-  static int32_t AppUnitsPerCSSPixel() { return nsDeviceContext::AppUnitsPerCSSPixel(); }
+  static int32_t AppUnitsPerCSSPixel() { return mozilla::AppUnitsPerCSSPixel(); }
   int32_t AppUnitsPerDevPixel() const  { return mDeviceContext->AppUnitsPerDevPixel(); }
   static int32_t AppUnitsPerCSSInch() { return nsDeviceContext::AppUnitsPerCSSInch(); }
 
   static nscoord CSSPixelsToAppUnits(int32_t aPixels)
   { return NSToCoordRoundWithClamp(float(aPixels) *
-             float(nsDeviceContext::AppUnitsPerCSSPixel())); }
+             float(AppUnitsPerCSSPixel())); }
 
   static nscoord CSSPixelsToAppUnits(float aPixels)
   { return NSToCoordRoundWithClamp(aPixels *
-             float(nsDeviceContext::AppUnitsPerCSSPixel())); }
+             float(AppUnitsPerCSSPixel())); }
 
   static int32_t AppUnitsToIntCSSPixels(nscoord aAppUnits)
   { return NSAppUnitsToIntPixels(aAppUnits,
-             float(nsDeviceContext::AppUnitsPerCSSPixel())); }
+             float(AppUnitsPerCSSPixel())); }
 
   static float AppUnitsToFloatCSSPixels(nscoord aAppUnits)
   { return NSAppUnitsToFloatPixels(aAppUnits,
-             float(nsDeviceContext::AppUnitsPerCSSPixel())); }
+             float(AppUnitsPerCSSPixel())); }
 
   nscoord DevPixelsToAppUnits(int32_t aPixels) const
   { return NSIntPixelsToAppUnits(aPixels,
                                  mDeviceContext->AppUnitsPerDevPixel()); }
 
   int32_t AppUnitsToDevPixels(nscoord aAppUnits) const
   { return NSAppUnitsToIntPixels(aAppUnits,
-             float(mDeviceContext->AppUnitsPerDevPixel())); }
+             float(AppUnitsPerDevPixel())); }
 
   int32_t CSSPixelsToDevPixels(int32_t aPixels)
   { return AppUnitsToDevPixels(CSSPixelsToAppUnits(aPixels)); }
 
   float CSSPixelsToDevPixels(float aPixels)
   {
     return NSAppUnitsToFloatPixels(CSSPixelsToAppUnits(aPixels),
                                    float(mDeviceContext->AppUnitsPerDevPixel()));