Bug 932421. Stop including windows.h (via Hal.h) in Screen.h, so we don't screw up our bindings code. r=smaug
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 31 Oct 2013 22:07:10 -0400
changeset 152950 b2add7fd1a7412c2c861a923e54414d4d4cc1b05
parent 152949 a150cb6978b6664b8b5baa459209e3cc066fd111
child 152951 90ca96b3e1988a248c5ed63997c18ccda1870034
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerssmaug
bugs932421
milestone28.0a1
Bug 932421. Stop including windows.h (via Hal.h) in Screen.h, so we don't screw up our bindings code. r=smaug Also stops Hal.h bootlegging Observer.h.
dom/base/nsGlobalWindow.cpp
dom/base/nsScreen.h
dom/ipc/PCOMContentPermissionRequestChild.h
hal/Hal.h
hal/HalScreenConfiguration.h
hal/moz.build
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -31,26 +31,16 @@
 #include "nsDOMWindowList.h"
 #include "nsIDOMWakeLock.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIPermissionManager.h"
 #include "nsIScriptContext.h"
 #include "nsIScriptTimeoutHandler.h"
 #include "nsIController.h"
 
-#ifdef XP_WIN
-// Thanks so much, Microsoft! :(
-#ifdef GetClassName
-#undef GetClassName
-#endif // GetClassName
-#ifdef CreateEvent
-#undef CreateEvent
-#endif
-#endif // XP_WIN
-
 // Helper Classes
 #include "nsJSUtils.h"
 #include "jsapi.h"              // for JSAutoRequest
 #include "js/OldDebugAPI.h"     // for JS_ClearWatchPointsForObject
 #include "jswrapper.h"
 #include "nsReadableUtils.h"
 #include "nsDOMClassInfo.h"
 #include "nsJSEnvironment.h"
@@ -70,16 +60,28 @@
 
 // Interfaces Needed
 #include "nsIFrame.h"
 #include "nsCanvasFrame.h"
 #include "nsIWidget.h"
 #include "nsIWidgetListener.h"
 #include "nsIBaseWindow.h"
 #include "nsDeviceSensors.h"
+
+#ifdef XP_WIN
+// Thanks so much, Microsoft and the people who pull in windows.h via
+// random silly headers! :(
+#ifdef GetClassName
+#undef GetClassName
+#endif // GetClassName
+#ifdef CreateEvent
+#undef CreateEvent
+#endif
+#endif // XP_WIN
+
 #include "nsIContent.h"
 #include "nsIDocShell.h"
 #include "nsIDocCharset.h"
 #include "nsIDocument.h"
 #include "Crypto.h"
 #ifndef MOZ_DISABLE_CRYPTOLEGACY
 #include "nsIDOMCryptoLegacy.h"
 #endif
--- a/dom/base/nsScreen.h
+++ b/dom/base/nsScreen.h
@@ -3,17 +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 nsScreen_h___
 #define nsScreen_h___
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/ScreenOrientation.h"
 #include "mozilla/ErrorResult.h"
-#include "mozilla/Hal.h"
+#include "mozilla/HalScreenConfiguration.h"
 #include "nsIDOMScreen.h"
 #include "nsCOMPtr.h"
 #include "nsDOMEventTargetHelper.h"
 #include "nsRect.h"
 
 class nsDeviceContext;
 
 // Script "screen" object
--- a/dom/ipc/PCOMContentPermissionRequestChild.h
+++ b/dom/ipc/PCOMContentPermissionRequestChild.h
@@ -2,16 +2,18 @@
  * 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 PCOMContentPermissionRequestChild_h
 #define PCOMContentPermissionRequestChild_h
 
 #include "mozilla/dom/PContentPermissionRequestChild.h"
 // Microsoft's API Name hackery sucks
+// XXXbz Doing this in a header is a gigantic footgun.  See
+// https://bugzilla.mozilla.org/show_bug.cgi?id=932421#c3 for why.
 #undef CreateEvent
 
 /*
   PContentPermissionRequestChild implementations also are
   XPCOM objects.  Addref() is called on their implementation
   before SendPContentPermissionRequestConstructor is called.
   When Dealloc is called, IPDLRelease() is called.
   Implementations of this method are expected to call
--- a/hal/Hal.h
+++ b/hal/Hal.h
@@ -5,24 +5,26 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_Hal_h
 #define mozilla_Hal_h
 
 #include "mozilla/hal_sandbox/PHal.h"
 #include "mozilla/HalTypes.h"
 #include "base/basictypes.h"
+#include "mozilla/Observer.h"
 #include "mozilla/Types.h"
 #include "nsTArray.h"
 #include "prlog.h"
 #include "mozilla/dom/battery/Types.h"
 #include "mozilla/dom/network/Types.h"
 #include "mozilla/dom/power/Types.h"
 #include "mozilla/hal_sandbox/PHal.h"
 #include "mozilla/dom/ScreenOrientation.h"
+#include "mozilla/HalScreenConfiguration.h"
 
 /*
  * Hal.h contains the public Hal API.
  *
  * By default, this file defines its functions in the hal namespace, but if
  * MOZ_HAL_NAMESPACE is defined, we'll define our functions in that namespace.
  *
  * This is used by HalImpl.h and HalSandbox.h, which define copies of all the
@@ -33,23 +35,19 @@ class nsIDOMWindow;
 
 #ifndef MOZ_HAL_NAMESPACE
 # define MOZ_HAL_NAMESPACE hal
 # define MOZ_DEFINED_HAL_NAMESPACE 1
 #endif
 
 namespace mozilla {
 
-template <class T>
-class Observer;
-
 namespace hal {
 
 typedef Observer<void_t> AlarmObserver;
-typedef Observer<ScreenConfiguration> ScreenConfigurationObserver;
 
 class WindowIdentifier;
 
 extern PRLogModuleInfo *GetHalLog();
 #define HAL_LOG(msg) PR_LOG(mozilla::hal::GetHalLog(), PR_LOG_DEBUG, msg)
 
 typedef Observer<int64_t> SystemClockChangeObserver;
 typedef Observer<SystemTimezoneChangeInformation> SystemTimezoneChangeObserver;
new file mode 100644
--- /dev/null
+++ b/hal/HalScreenConfiguration.h
@@ -0,0 +1,20 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set sw=2 ts=8 et ft=cpp : */
+/* 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 mozilla_HalScreenConfiguration_h
+#define mozilla_HalScreenConfiguration_h
+
+#include "mozilla/Observer.h"
+
+namespace mozilla {
+namespace hal {
+struct ScreenConfiguration;
+typedef Observer<ScreenConfiguration> ScreenConfigurationObserver;
+} // namespace hal
+} // namespace mozilla
+
+#endif  // mozilla_HalScreenConfiguration_h
+
--- a/hal/moz.build
+++ b/hal/moz.build
@@ -9,16 +9,17 @@ XPIDL_SOURCES += [
 ]
 
 MODULE = 'hal'
 
 EXPORTS.mozilla += [
     'Hal.h',
     'HalImpl.h',
     'HalSandbox.h',
+    'HalScreenConfiguration.h',
     'HalSensor.h',
     'HalTypes.h',
     'HalWakeLock.h',
 ]
 
 TEST_DIRS += ['tests']
 SOURCES += [
     'Hal.cpp',