diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 38684d6ae27d..55dd698f1997 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -56,6 +56,7 @@ #include "mozilla/dom/workers/Workers.h" #include "nsJSPrincipals.h" #include "mozilla/Attributes.h" +#include "mozilla/Debug.h" #include "mozilla/MouseEvents.h" // Interfaces Needed @@ -64,19 +65,7 @@ #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 "nsIDeviceSensors.h" #include "nsIContent.h" #include "nsIDocShell.h" #include "nsIDocCharset.h" @@ -219,7 +208,7 @@ #include "mozilla/dom/BrowserElementDictionariesBinding.h" #include "mozilla/dom/FunctionBinding.h" #include "mozilla/dom/WindowBinding.h" -#include "mozilla/dom/TabChild.h" +#include "nsITabChild.h" #include "nsIDOMMediaQueryList.h" #ifdef MOZ_WEBSPEECH @@ -5679,9 +5668,7 @@ nsGlobalWindow::Dump(const nsAString& aStr) if (cstr) { #ifdef XP_WIN - if (IsDebuggerPresent()) { - OutputDebugStringA(cstr); - } + PrintToDebugger(cstr); #endif #ifdef ANDROID __android_log_write(ANDROID_LOG_INFO, "GeckoDump", cstr); @@ -6228,7 +6215,7 @@ nsGlobalWindow::Focus(ErrorResult& aError) } return; } - if (TabChild *child = TabChild::GetFrom(this)) { + if (nsCOMPtr child = do_GetInterface(mDocShell)) { child->SendRequestFocus(canFocus); return; } @@ -12564,13 +12551,13 @@ nsGlobalWindow::SetHasGamepadEventListener(bool aHasGamepad/* = true*/) void nsGlobalWindow::EnableTimeChangeNotifications() { - nsSystemTimeChangeObserver::AddWindowListener(this); + mozilla::time::AddWindowListener(this); } void nsGlobalWindow::DisableTimeChangeNotifications() { - nsSystemTimeChangeObserver::RemoveWindowListener(this); + mozilla::time::RemoveWindowListener(this); } static PLDHashOperator @@ -13212,3 +13199,7 @@ nsGlobalWindow::DisableNetworkEvent(uint32_t aType) #undef BEFOREUNLOAD_EVENT #undef ERROR_EVENT #undef EVENT + +#ifdef _WINDOWS_ +#error "Never include windows.h in this file!" +#endif diff --git a/dom/interfaces/base/nsITabChild.idl b/dom/interfaces/base/nsITabChild.idl index 5f09e1d85694..a1fc3eaaeca9 100644 --- a/dom/interfaces/base/nsITabChild.idl +++ b/dom/interfaces/base/nsITabChild.idl @@ -6,10 +6,11 @@ #include "domstubs.idl" interface nsIContentFrameMessageManager; -// Sole purpose is to be able to identify the concrete class nsTabChild -[uuid(bf1eddf9-731b-4a4b-bd65-9a712a892832)] +[uuid( 60146bc6-31d8-450b-a9eb-4000b6403d5c)] interface nsITabChild : nsISupports { readonly attribute nsIContentFrameMessageManager messageManager; + + [notxpcom] void sendRequestFocus(in boolean canFocus); }; diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index bba78399a77b..f5fa0cbcd5fb 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -71,6 +71,10 @@ #include "nsILoadContext.h" #include "ipc/nsGUIEventIPC.h" +#ifdef DEBUG +#include "PCOMContentPermissionRequestChild.h" +#endif /* DEBUG */ + #define BROWSER_ELEMENT_CHILD_SCRIPT \ NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js") @@ -1141,6 +1145,20 @@ TabChild::ArraysToParams(const InfallibleTArray& aIntParams, } } +#ifdef DEBUG +PContentPermissionRequestChild* +TabChild:: SendPContentPermissionRequestConstructor(PContentPermissionRequestChild* aActor, + const nsCString& aType, + const nsCString& aAccess, + const IPC::Principal& aPrincipal) +{ + PCOMContentPermissionRequestChild* child = static_cast(aActor); + PContentPermissionRequestChild* request = PBrowserChild::SendPContentPermissionRequestConstructor(aActor, aType, aAccess, aPrincipal); + child->mIPCOpen = true; + return request; +} +#endif /* DEBUG */ + void TabChild::DestroyWindow() { @@ -2359,6 +2377,12 @@ TabChild::GetMessageManager(nsIContentFrameMessageManager** aResult) return NS_ERROR_FAILURE; } +void +TabChild::SendRequestFocus(bool aCanFocus) +{ + PBrowserChild::SendRequestFocus(aCanFocus); +} + PIndexedDBChild* TabChild::AllocPIndexedDBChild( const nsCString& aGroup, diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index cdfbc6271768..095ec72784aa 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -8,9 +8,6 @@ #define mozilla_dom_TabChild_h #include "mozilla/dom/PBrowserChild.h" -#ifdef DEBUG -#include "PCOMContentPermissionRequestChild.h" -#endif /* DEBUG */ #include "nsIWebNavigation.h" #include "nsCOMPtr.h" #include "nsAutoPtr.h" @@ -270,16 +267,11 @@ public: nsIDialogParamBlock* aParams); #ifdef DEBUG - virtual PContentPermissionRequestChild* SendPContentPermissionRequestConstructor(PContentPermissionRequestChild* aActor, - const nsCString& aType, - const nsCString& aAccess, - const IPC::Principal& aPrincipal) - { - PCOMContentPermissionRequestChild* child = static_cast(aActor); - PContentPermissionRequestChild* request = PBrowserChild::SendPContentPermissionRequestConstructor(aActor, aType, aAccess, aPrincipal); - child->mIPCOpen = true; - return request; - } + virtual PContentPermissionRequestChild* + SendPContentPermissionRequestConstructor(PContentPermissionRequestChild* aActor, + const nsCString& aType, + const nsCString& aAccess, + const IPC::Principal& aPrincipal); #endif /* DEBUG */ virtual PContentPermissionRequestChild* AllocPContentPermissionRequestChild(const nsCString& aType, diff --git a/dom/system/nsDeviceSensors.h b/dom/system/nsDeviceSensors.h index 957e6cc759a1..23d2d396e697 100644 --- a/dom/system/nsDeviceSensors.h +++ b/dom/system/nsDeviceSensors.h @@ -18,12 +18,6 @@ #include "mozilla/HalSensor.h" #include "nsDataHashtable.h" -#define NS_DEVICE_SENSORS_CID \ -{ 0xecba5203, 0x77da, 0x465a, \ -{ 0x86, 0x5e, 0x78, 0xb7, 0xaf, 0x10, 0xd8, 0xf7 } } - -#define NS_DEVICE_SENSORS_CONTRACTID "@mozilla.org/devicesensors;1" - class nsIDOMWindow; namespace mozilla { diff --git a/dom/time/TimeChangeObserver.cpp b/dom/time/TimeChangeObserver.cpp index 784fcff31995..2d74a7786b47 100644 --- a/dom/time/TimeChangeObserver.cpp +++ b/dom/time/TimeChangeObserver.cpp @@ -4,6 +4,11 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "TimeChangeObserver.h" +#include "mozilla/Hal.h" +#include "mozilla/Observer.h" +#include "mozilla/HalTypes.h" +#include "nsWeakPtr.h" +#include "nsTObserverArray.h" #include "mozilla/ClearOnShutdown.h" #include "mozilla/Services.h" #include "mozilla/StaticPtr.h" @@ -17,6 +22,30 @@ using namespace mozilla; using namespace mozilla::hal; using namespace mozilla::services; +class nsSystemTimeChangeObserver : public SystemClockChangeObserver, + public SystemTimezoneChangeObserver +{ + typedef nsTObserverArray ListenerArray; +public: + static nsSystemTimeChangeObserver* GetInstance(); + virtual ~nsSystemTimeChangeObserver(); + + // Implementing hal::SystemClockChangeObserver::Notify() + void Notify(const int64_t& aClockDeltaMS); + + // Implementing hal::SystemTimezoneChangeObserver::Notify() + void Notify( + const mozilla::hal::SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo); + + nsresult AddWindowListenerImpl(nsPIDOMWindow* aWindow); + nsresult RemoveWindowListenerImpl(nsPIDOMWindow* aWindow); + +private: + nsSystemTimeChangeObserver() { }; + ListenerArray mWindowListeners; + void FireMozTimeChangeEvent(); +}; + StaticAutoPtr sObserver; nsSystemTimeChangeObserver* nsSystemTimeChangeObserver::GetInstance() @@ -79,9 +108,9 @@ nsSystemTimeChangeObserver::Notify( } nsresult -nsSystemTimeChangeObserver::AddWindowListener(nsPIDOMWindow* aWindow) +mozilla::time::AddWindowListener(nsPIDOMWindow* aWindow) { - return GetInstance()->AddWindowListenerImpl(aWindow); + return nsSystemTimeChangeObserver::GetInstance()->AddWindowListenerImpl(aWindow); } nsresult @@ -116,13 +145,13 @@ nsSystemTimeChangeObserver::AddWindowListenerImpl(nsPIDOMWindow* aWindow) } nsresult -nsSystemTimeChangeObserver::RemoveWindowListener(nsPIDOMWindow* aWindow) +mozilla::time::RemoveWindowListener(nsPIDOMWindow* aWindow) { if (!sObserver) { return NS_OK; } - return GetInstance()->RemoveWindowListenerImpl(aWindow); + return nsSystemTimeChangeObserver::GetInstance()->RemoveWindowListenerImpl(aWindow); } nsresult diff --git a/dom/time/TimeChangeObserver.h b/dom/time/TimeChangeObserver.h index 8c96ae8b2ea5..5761a5ee9049 100644 --- a/dom/time/TimeChangeObserver.h +++ b/dom/time/TimeChangeObserver.h @@ -6,39 +6,17 @@ #ifndef _mozilla_time_change_observer_h_ #define _mozilla_time_change_observer_h_ -#include "mozilla/Hal.h" -#include "mozilla/Observer.h" -#include "mozilla/HalTypes.h" -#include "nsPIDOMWindow.h" -#include "nsWeakPtr.h" -#include "nsTObserverArray.h" +#include "nscore.h" -typedef mozilla::Observer SystemClockChangeObserver; -typedef mozilla::Observer SystemTimezoneChangeObserver; +class nsPIDOMWindow; -class nsSystemTimeChangeObserver : public SystemClockChangeObserver, - public SystemTimezoneChangeObserver -{ - typedef nsTObserverArray ListenerArray; -public: - static nsSystemTimeChangeObserver* GetInstance(); - virtual ~nsSystemTimeChangeObserver(); +namespace mozilla { +namespace time { - // Implementing hal::SystemClockChangeObserver::Notify() - void Notify(const int64_t& aClockDeltaMS); +nsresult AddWindowListener(nsPIDOMWindow* aWindow); +nsresult RemoveWindowListener(nsPIDOMWindow* aWindow); - // Implementing hal::SystemTimezoneChangeObserver::Notify() - void Notify( - const mozilla::hal::SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo); - - static nsresult AddWindowListener(nsPIDOMWindow* aWindow); - static nsresult RemoveWindowListener(nsPIDOMWindow* aWindow); -private: - nsresult AddWindowListenerImpl(nsPIDOMWindow* aWindow); - nsresult RemoveWindowListenerImpl(nsPIDOMWindow* aWindow); - nsSystemTimeChangeObserver() { }; - ListenerArray mWindowListeners; - void FireMozTimeChangeEvent(); -}; +} // namespace time +} // namespace mozilla #endif //_mozilla_time_change_observer_h_ diff --git a/xpcom/base/Debug.cpp b/xpcom/base/Debug.cpp new file mode 100644 index 000000000000..19065ab39ee6 --- /dev/null +++ b/xpcom/base/Debug.cpp @@ -0,0 +1,21 @@ +/* -*- Mode: C++; tab-width: 2; 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/. */ + +#include "mozilla/Debug.h" + +#ifdef XP_WIN +#include +#endif + +#ifdef XP_WIN + +void mozilla::PrintToDebugger(const char* aStr) +{ + if (::IsDebuggerPresent()) { + ::OutputDebugStringA(aStr); + } +} + +#endif diff --git a/xpcom/base/Debug.h b/xpcom/base/Debug.h new file mode 100644 index 000000000000..a70c384aaccc --- /dev/null +++ b/xpcom/base/Debug.h @@ -0,0 +1,20 @@ +/* -*- Mode: C++; tab-width: 2; 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 mozilla_Debug_h__ +#define mozilla_Debug_h__ + +namespace mozilla { + +#ifdef XP_WIN + +// Print aStr to a debugger if the debugger is attached. +void PrintToDebugger(const char* aStr); + +#endif + +} // namespace mozilla + +#endif // mozilla_Debug_h__ diff --git a/xpcom/base/moz.build b/xpcom/base/moz.build index cf1508d79252..55fd7a0032b1 100644 --- a/xpcom/base/moz.build +++ b/xpcom/base/moz.build @@ -75,6 +75,7 @@ EXPORTS.mozilla += [ 'AvailableMemoryTracker.h', 'ClearOnShutdown.h', 'CycleCollectedJSRuntime.h', + 'Debug.h', 'nsMemoryInfoDumper.h', 'StackWalk.h', 'StaticMutex.h', @@ -91,6 +92,7 @@ SOURCES += [ 'AvailableMemoryTracker.cpp', 'ClearOnShutdown.cpp', 'CycleCollectedJSRuntime.cpp', + 'Debug.cpp', 'nsConsoleMessage.cpp', 'nsConsoleService.cpp', 'nsCycleCollector.cpp', diff --git a/xpcom/system/nsIDeviceSensors.idl b/xpcom/system/nsIDeviceSensors.idl index 6c805c445886..f6ad25d151db 100644 --- a/xpcom/system/nsIDeviceSensors.idl +++ b/xpcom/system/nsIDeviceSensors.idl @@ -39,3 +39,13 @@ interface nsIDeviceSensors : nsISupports [noscript] void removeWindowListener(in unsigned long aType, in nsIDOMWindow aWindow); [noscript] void removeWindowAsListener(in nsIDOMWindow aWindow); }; + +%{C++ + +#define NS_DEVICE_SENSORS_CID \ +{ 0xecba5203, 0x77da, 0x465a, \ +{ 0x86, 0x5e, 0x78, 0xb7, 0xaf, 0x10, 0xd8, 0xf7 } } + +#define NS_DEVICE_SENSORS_CONTRACTID "@mozilla.org/devicesensors;1" + +%}