From fe4797de943f1f9350a332e4baa8b181b5062f7b Mon Sep 17 00:00:00 2001 From: Pale Moon Date: Mon, 2 Jan 2017 17:15:45 +0100 Subject: Remove Windows Metro/WinRT code. --- widget/MetroUIUtils.idl | 36 - widget/NativeKeyToDOMKeyName.h | 2 +- widget/moz.build | 6 - widget/nsAppShellSingleton.h | 19 - widget/nsIWinMetroUtils.idl | 152 -- widget/nsWidgetsCID.h | 4 - widget/windows/KeyboardLayout.cpp | 6 +- widget/windows/WinMouseScrollHandler.cpp | 6 - widget/windows/WinTaskbar.cpp | 9 - widget/windows/WinUtils.cpp | 40 +- widget/windows/moz.build | 3 - widget/windows/nsClipboard.cpp | 3 - widget/windows/nsLookAndFeel.cpp | 5 +- widget/windows/nsTextStore.cpp | 102 +- widget/windows/nsTextStore.h | 2 +- widget/windows/nsWidgetFactory.cpp | 66 +- widget/windows/nsWindow.cpp | 17 - widget/windows/winrt/APZController.cpp | 315 ---- widget/windows/winrt/APZController.h | 79 - widget/windows/winrt/DisplayInfo_sdk81.h | 458 ------ widget/windows/winrt/FrameworkView.cpp | 507 ------- widget/windows/winrt/FrameworkView.h | 205 --- widget/windows/winrt/Makefile.in | 19 - widget/windows/winrt/MetroApp.cpp | 282 ---- widget/windows/winrt/MetroApp.h | 62 - widget/windows/winrt/MetroAppShell.cpp | 522 ------- widget/windows/winrt/MetroAppShell.h | 44 - widget/windows/winrt/MetroContracts.cpp | 576 -------- widget/windows/winrt/MetroD3DCheckHelper.h | 96 -- widget/windows/winrt/MetroInput.cpp | 1576 -------------------- widget/windows/winrt/MetroInput.h | 293 ---- widget/windows/winrt/MetroUIUtils.js | 175 --- widget/windows/winrt/MetroUIUtils.manifest | 3 - widget/windows/winrt/MetroUtils.cpp | 190 --- widget/windows/winrt/MetroUtils.h | 96 -- widget/windows/winrt/MetroWidget.cpp | 1626 --------------------- widget/windows/winrt/MetroWidget.h | 277 ---- widget/windows/winrt/ToastNotificationHandler.cpp | 153 -- widget/windows/winrt/ToastNotificationHandler.h | 44 - widget/windows/winrt/UIAAccessibilityBridge.cpp | 54 - widget/windows/winrt/UIAAccessibilityBridge.h | 80 - widget/windows/winrt/UIABridge.cpp | 801 ---------- widget/windows/winrt/UIABridge.idl | 22 - widget/windows/winrt/UIABridgePrivate.h | 139 -- widget/windows/winrt/UIABridgePublic.h | 19 - widget/windows/winrt/WakeLockListener.cpp | 29 - widget/windows/winrt/WakeLockListener.h | 25 - widget/windows/winrt/moz.build | 52 - widget/windows/winrt/mozwrlbase.h | 77 - widget/windows/winrt/nsMetroFilePicker.cpp | 484 ------ widget/windows/winrt/nsMetroFilePicker.h | 69 - widget/windows/winrt/nsWinMetroUtils.cpp | 402 ----- widget/windows/winrt/nsWinMetroUtils.h | 27 - 53 files changed, 61 insertions(+), 10295 deletions(-) delete mode 100644 widget/MetroUIUtils.idl delete mode 100644 widget/nsIWinMetroUtils.idl delete mode 100644 widget/windows/winrt/APZController.cpp delete mode 100644 widget/windows/winrt/APZController.h delete mode 100644 widget/windows/winrt/DisplayInfo_sdk81.h delete mode 100644 widget/windows/winrt/FrameworkView.cpp delete mode 100644 widget/windows/winrt/FrameworkView.h delete mode 100644 widget/windows/winrt/Makefile.in delete mode 100644 widget/windows/winrt/MetroApp.cpp delete mode 100644 widget/windows/winrt/MetroApp.h delete mode 100644 widget/windows/winrt/MetroAppShell.cpp delete mode 100644 widget/windows/winrt/MetroAppShell.h delete mode 100644 widget/windows/winrt/MetroContracts.cpp delete mode 100644 widget/windows/winrt/MetroD3DCheckHelper.h delete mode 100644 widget/windows/winrt/MetroInput.cpp delete mode 100644 widget/windows/winrt/MetroInput.h delete mode 100644 widget/windows/winrt/MetroUIUtils.js delete mode 100644 widget/windows/winrt/MetroUIUtils.manifest delete mode 100644 widget/windows/winrt/MetroUtils.cpp delete mode 100644 widget/windows/winrt/MetroUtils.h delete mode 100644 widget/windows/winrt/MetroWidget.cpp delete mode 100644 widget/windows/winrt/MetroWidget.h delete mode 100644 widget/windows/winrt/ToastNotificationHandler.cpp delete mode 100644 widget/windows/winrt/ToastNotificationHandler.h delete mode 100644 widget/windows/winrt/UIAAccessibilityBridge.cpp delete mode 100644 widget/windows/winrt/UIAAccessibilityBridge.h delete mode 100644 widget/windows/winrt/UIABridge.cpp delete mode 100644 widget/windows/winrt/UIABridge.idl delete mode 100644 widget/windows/winrt/UIABridgePrivate.h delete mode 100644 widget/windows/winrt/UIABridgePublic.h delete mode 100644 widget/windows/winrt/WakeLockListener.cpp delete mode 100644 widget/windows/winrt/WakeLockListener.h delete mode 100644 widget/windows/winrt/moz.build delete mode 100644 widget/windows/winrt/mozwrlbase.h delete mode 100644 widget/windows/winrt/nsMetroFilePicker.cpp delete mode 100644 widget/windows/winrt/nsMetroFilePicker.h delete mode 100644 widget/windows/winrt/nsWinMetroUtils.cpp delete mode 100644 widget/windows/winrt/nsWinMetroUtils.h (limited to 'widget') diff --git a/widget/MetroUIUtils.idl b/widget/MetroUIUtils.idl deleted file mode 100644 index 43579039b..000000000 --- a/widget/MetroUIUtils.idl +++ /dev/null @@ -1,36 +0,0 @@ -/* 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 "nsISupports.idl" - -[scriptable, uuid(398fb953-335d-42f1-9e91-e238b56bf4ad)] - -interface nsIMetroUIUtils : nsISupports { - /** - * Obtains the current page URI - */ - attribute AString currentPageURI; - - /** - * Obtains the current page title - */ - attribute AString currentPageTitle; - - /** - * Determines if the browser has selected content - */ - attribute boolean hasSelectedContent; - - /** - * Determines the text that should be shared - */ - attribute AString shareText; - - /** - * Determines the HTML that should be shared - */ - attribute AString shareHTML; -}; - diff --git a/widget/NativeKeyToDOMKeyName.h b/widget/NativeKeyToDOMKeyName.h index 8684fa57c..465ccd37f 100644 --- a/widget/NativeKeyToDOMKeyName.h +++ b/widget/NativeKeyToDOMKeyName.h @@ -15,7 +15,7 @@ * aKeyNameIndex is the widget::KeyNameIndex value. */ -// Windows (both Desktop and Metro) +// Windows #define KEY_MAP_WIN(aCPPKeyName, aNativeKey) #define KEY_MAP_WIN_JPN(aCPPKeyName, aNativeKey) #define KEY_MAP_WIN_KOR(aCPPKeyName, aNativeKey) diff --git a/widget/moz.build b/widget/moz.build index d2ab5d4bb..a7d67e402 100644 --- a/widget/moz.build +++ b/widget/moz.build @@ -85,12 +85,6 @@ XPIDL_SOURCES += [ 'nsITransferable.idl', ] -if CONFIG['MOZ_METRO']: - XPIDL_SOURCES += [ - 'MetroUIUtils.idl', - 'nsIWinMetroUtils.idl', - ] - XPIDL_MODULE = 'widget' EXPORTS += [ diff --git a/widget/nsAppShellSingleton.h b/widget/nsAppShellSingleton.h index 84702c028..0b736c8dc 100644 --- a/widget/nsAppShellSingleton.h +++ b/widget/nsAppShellSingleton.h @@ -28,9 +28,6 @@ */ #include "nsXULAppAPI.h" -#if defined(MOZ_METRO) && defined(XP_WIN) -#include "winrt/MetroAppShell.h" -#endif static nsIAppShell *sAppShell; @@ -39,29 +36,13 @@ nsAppShellInit() { NS_ASSERTION(!sAppShell, "already initialized"); -#if !defined(MOZ_METRO) || !defined(XP_WIN) sAppShell = new nsAppShell(); -#else - if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) { - sAppShell = new MetroAppShell(); - } else { - sAppShell = new nsAppShell(); - } -#endif if (!sAppShell) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(sAppShell); nsresult rv; -#if !defined(MOZ_METRO) || !defined(XP_WIN) rv = static_cast(sAppShell)->Init(); -#else - if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) { - rv = static_cast(sAppShell)->Init(); - } else { - rv = static_cast(sAppShell)->Init(); - } -#endif if (NS_FAILED(rv)) { NS_RELEASE(sAppShell); return rv; diff --git a/widget/nsIWinMetroUtils.idl b/widget/nsIWinMetroUtils.idl deleted file mode 100644 index 4cf57e288..000000000 --- a/widget/nsIWinMetroUtils.idl +++ /dev/null @@ -1,152 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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 "nsISupports.idl" - -/** - * Integration with the "Metro"/"Modern" UI environment in Windows 8. - * - * Note: browser/metro/base/content/browser.js contains a stub - * implementation of this interface for non-Windows systems, for testing and - * development purposes only. - */ -[scriptable, uuid(319faae0-82ca-4c2f-8a24-2b2445e5a72a)] -interface nsIWinMetroUtils : nsISupports -{ - /** - * Determine if the current device has the hardware capabilities to run - * in metro mode. - */ - readonly attribute boolean supported; - - /** - * Determine if the current browser is running in the metro immersive - * environment. - */ - readonly attribute boolean immersive; - - /** - * Determine the activation URI - */ - readonly attribute AString activationURI; - - /** - * Determine the previous execution state. The possible values of this - * attribute are exactly those values in the - * Windows::ApplicationModel::Activation enumeration. - */ - readonly attribute long previousExecutionState; - - /** - * Helper for our restart logic up in the about flyout. We set this - * right before we restart for an update so that MetroAppShell can - * communicate this to the ceh. - */ - attribute boolean updatePending; - - /* - * Determine if metro firefox is running in the foreground. - */ - readonly attribute boolean foreground; - - /** - * Show the settings flyout - */ - void showSettingsFlyout(); - - /** - * Launches the specified application with the specified arguments and - * switches to Desktop mode if in metro mode. - */ - void launchInDesktop(in AString aPath, in AString aArguments); - - /** - * Displays a native Windows 8 toast. - * - * @param aAppId Application ID for current application. - * If using Metro mode, it can be null string. - */ - void showNativeToast(in AString aTitle, in AString aMessage, - in AString anImage, in AString aCookie, - [optional] in AString aAppId); - - /** - * Secondary tiles are a Windows 8 specific feature for pinning new tiles - * to the start screen. Tiles can later be activated whether the browser is - * already opened or not. - */ - - /** - * Pins a new tile to the Windows 8 start screen. - * - * @param aTileID An ID which can later be used to remove the tile - * ID must only contain valid filesystem characters - * @param aShortName A short name for the tile - * @param aDiplayName The name that will be displayed on the tile - * @param aActivationArgs The arguments to pass to the browser upon - * activation of the tile - * @param aTileImage An image for the normal tile view - * @param aSmallTileImage An image for the small tile view - */ - void pinTileAsync(in AString aTileID, - in AString aShortName, - in AString aDisplayName, - in AString aActivationArgs, - in AString aTileImage, - in AString aSmallTileImage); - - /** - * Unpins a tile from the Windows 8 start screen. - * - * @param aTileID An existing ID which was previously pinned - * ID must only contain valid filesystem characters - */ - void unpinTileAsync(in AString aTileID); - - /** - * Determines if a tile is pinned to the Windows 8 start screen. - * - * @param aTileID An ID which may have been pinned with pinTileAsync - * ID must only contain valid filesystem characters - * @return true if the tile is pinned - */ - bool isTilePinned(in AString aTileID); - - /** - * Soft keyboard attributes. Used in unison with shown/hidden observer - * events sent via FrameworkView. - * - * keyboardVisible - returns true if the soft keyboard is currently - * displayed, false otherwise. - * keyboardX, keyboardY, keyboardWidth, keyboardHeight - occlude rect - * of the keyboard when displayed in device independent pixels. - */ - readonly attribute boolean keyboardVisible; - readonly attribute unsigned long keyboardX; - readonly attribute unsigned long keyboardY; - readonly attribute unsigned long keyboardWidth; - readonly attribute unsigned long keyboardHeight; - - /** - * Settings panel links. addSettingsPanelEntry adds an entry to - * the settings flyout panel that the user can invoke. - * - * @param aChromePanelId panel id invoked via nsIBrowserDOMWindow's - * ShowPanel api. Example: 'prefs-container' - * @return a unique identifier that will be passed as "data" in the - * "metro-settings-entry-selected" notification when the entry is clicked - */ - unsigned long addSettingsPanelEntry(in AString aLabel); - - /** - * Change the value of the "switch primary and secondary buttons" preference. - * See the Windows SwapMouseButton API docs for details. - * Included here for use in automated tests (see bug 839460). - * - * @param aSwap true to enable the preference, false to disable it. - * @return original value of the preference. - */ - bool swapMouseButton(in bool aSwap); -}; diff --git a/widget/nsWidgetsCID.h b/widget/nsWidgetsCID.h index e4367ab53..19dafa2b8 100644 --- a/widget/nsWidgetsCID.h +++ b/widget/nsWidgetsCID.h @@ -123,10 +123,6 @@ #define NS_WIN_JUMPLISTBUILDER_CID \ { 0x73a5946f, 0x608d, 0x454f, { 0x9d, 0x33, 0xb, 0x8f, 0x8c, 0x72, 0x94, 0xb6 } } -// {DE95B8C9-F0E8-4AD5-95A2-06C12F53EC2E} -#define NS_WIN_METROUTILS_CID \ -{ 0xde95b8c9, 0xf0e8, 0x4ad5, { 0x95, 0xa2, 0x06, 0xc1, 0x2f, 0x53, 0xec, 0x2e }} - // {2B9A1F2C-27CE-45b6-8D4E-755D0E34F8DB} #define NS_WIN_JUMPLISTITEM_CID \ { 0x2b9a1f2c, 0x27ce, 0x45b6, { 0x8d, 0x4e, 0x75, 0x5d, 0x0e, 0x34, 0xf8, 0xdb } } diff --git a/widget/windows/KeyboardLayout.cpp b/widget/windows/KeyboardLayout.cpp index c5f193b39..58667f79e 100644 --- a/widget/windows/KeyboardLayout.cpp +++ b/widget/windows/KeyboardLayout.cpp @@ -142,6 +142,7 @@ static_assert(sizeof(kVirtualKeyName) / sizeof(const char*) == 0x100, // Unique id counter associated with a keydown / keypress events. Used in // identifing keypress events for removal from async event dispatch queue // in metrofx after preventDefault is called on keydown events. +// XXX: Do we still need this? static uint32_t sUniqueKeyEventId = 0; struct DeadKeyEntry @@ -296,11 +297,6 @@ ModifierKeyState::InitMouseEvent(WidgetInputEvent& aMouseEvent) const aMouseEvent.mClass == eSimpleGestureEventClass, "called with non-mouse event"); - if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) { - // Buttons for immersive mode are handled in MetroInput. - return; - } - WidgetMouseEventBase& mouseEvent = *aMouseEvent.AsMouseEventBase(); mouseEvent.buttons = 0; if (::GetKeyState(VK_LBUTTON) < 0) { diff --git a/widget/windows/WinMouseScrollHandler.cpp b/widget/windows/WinMouseScrollHandler.cpp index a05b0a364..822a36467 100644 --- a/widget/windows/WinMouseScrollHandler.cpp +++ b/widget/windows/WinMouseScrollHandler.cpp @@ -326,7 +326,6 @@ bool MouseScrollHandler::DispatchEvent(nsWindowBase* aWidget, WidgetGUIEvent& aEvent) { - // note, in metrofx, this will always return false for now return aWidget->DispatchScrollEvent(&aEvent); } @@ -1095,11 +1094,6 @@ MouseScrollHandler::Device::GetWorkaroundPref(const char* aPrefName, void MouseScrollHandler::Device::Init() { - // Not supported in metro mode. - if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) { - return; - } - sFakeScrollableWindowNeeded = GetWorkaroundPref("ui.trackpoint_hack.enabled", (TrackPoint::IsDriverInstalled() || diff --git a/widget/windows/WinTaskbar.cpp b/widget/windows/WinTaskbar.cpp index 5eb030c3e..29b6fa436 100644 --- a/widget/windows/WinTaskbar.cpp +++ b/widget/windows/WinTaskbar.cpp @@ -243,11 +243,6 @@ WinTaskbar::~WinTaskbar() { // static bool WinTaskbar::GetAppUserModelID(nsAString & aDefaultGroupId) { - // For win8 metro builds, we can't set this. The value is static - // for the app. - if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) { - return false; - } // If marked as such in prefs, use a hash of the profile path for the id // instead of the install path hash setup by the installer. bool useProfile = @@ -336,10 +331,6 @@ WinTaskbar::RegisterAppUserModelID() { if (!IsWin7OrLater()) return false; - if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) { - return false; - } - SetCurrentProcessExplicitAppUserModelIDPtr funcAppUserModelID = nullptr; bool retVal = false; diff --git a/widget/windows/WinUtils.cpp b/widget/windows/WinUtils.cpp index 6310f6f6a..adce82469 100644 --- a/widget/windows/WinUtils.cpp +++ b/widget/windows/WinUtils.cpp @@ -40,10 +40,6 @@ #include "nsIThread.h" #include "MainThreadUtils.h" #include "gfxColor.h" -#ifdef MOZ_METRO -#include "winrt/MetroInput.h" -#include "winrt/MetroUtils.h" -#endif // MOZ_METRO #ifdef NS_ENABLE_TSF #include @@ -539,26 +535,18 @@ double WinUtils::LogToPhysFactor() { // dpi / 96.0 - if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) { -#ifdef MOZ_METRO - return MetroUtils::LogToPhysFactor(); -#else - return 1.0; -#endif - } else { - HDC hdc = ::GetDC(nullptr); - double result = ::GetDeviceCaps(hdc, LOGPIXELSY) / 96.0; - ::ReleaseDC(nullptr, hdc); - - if (result == 0) { - // Bug 1012487 - This can occur when the Screen DC is used off the - // main thread on windows. For now just assume a 100% DPI for this - // drawing call. - // XXX - fixme! - result = 1.0; - } - return result; + HDC hdc = ::GetDC(nullptr); + double result = ::GetDeviceCaps(hdc, LOGPIXELSY) / 96.0; + ::ReleaseDC(nullptr, hdc); + + if (result == 0) { + // Bug 1012487 - This can occur when the Screen DC is used off the + // main thread on windows. For now just assume a 100% DPI for this + // drawing call. + // XXX - fixme! + result = 1.0; } + return result; } /* static */ @@ -1682,11 +1670,7 @@ WinUtils::SetupKeyModifiersSequence(nsTArray* aArray, bool WinUtils::ShouldHideScrollbars() { -#ifdef MOZ_METRO - if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) { - return widget::winrt::MetroInput::IsInputModeImprecise(); - } -#endif // MOZ_METRO + // Optional for future environments. Make it a pref for users? return false; } diff --git a/widget/windows/moz.build b/widget/windows/moz.build index 23bfd41c4..d8ed352be 100644 --- a/widget/windows/moz.build +++ b/widget/windows/moz.build @@ -4,9 +4,6 @@ # 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/. -if CONFIG['MOZ_METRO']: - DIRS += ['winrt'] - TEST_DIRS += ['tests'] EXPORTS += [ diff --git a/widget/windows/nsClipboard.cpp b/widget/windows/nsClipboard.cpp index 9d5850e4e..b0ffa22ec 100644 --- a/widget/windows/nsClipboard.cpp +++ b/widget/windows/nsClipboard.cpp @@ -294,9 +294,6 @@ nsresult nsClipboard::GetGlobalData(HGLOBAL aHGBL, void ** aData, uint32_t * aLe result = NS_OK; } } else { -#ifdef MOZ_METRO - return result; -#endif // We really shouldn't ever get here // but just in case *aData = nullptr; diff --git a/widget/windows/nsLookAndFeel.cpp b/widget/windows/nsLookAndFeel.cpp index f5e784cbd..cb3bcc80e 100644 --- a/widget/windows/nsLookAndFeel.cpp +++ b/widget/windows/nsLookAndFeel.cpp @@ -482,11 +482,10 @@ nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult) aResult = 0; break; case eIntID_ColorPickerAvailable: - // We don't have a color picker implemented on Metro yet (bug 895464) - aResult = (XRE_GetWindowsEnvironment() != WindowsEnvironmentType_Metro); + aResult = true; break; case eIntID_UseOverlayScrollbars: - aResult = (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro); + aResult = false; break; case eIntID_AllowOverlayScrollbarsOverlap: aResult = 0; diff --git a/widget/windows/nsTextStore.cpp b/widget/windows/nsTextStore.cpp index 9222f6944..8fd51654f 100644 --- a/widget/windows/nsTextStore.cpp +++ b/widget/windows/nsTextStore.cpp @@ -10,9 +10,6 @@ #include "nscore.h" #include "nsWindow.h" -#ifdef MOZ_METRO -#include "winrt/MetroWidget.h" -#endif #include "nsPrintfCString.h" #include "WinUtils.h" #include "mozilla/Preferences.h" @@ -3209,22 +3206,20 @@ nsTextStore::GetTextExt(TsViewCookie vcView, if (event.mReply.mRect.height <= 0) event.mReply.mRect.height = 1; - if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Desktop) { - // convert to unclipped screen rect - nsWindow* refWindow = static_cast( - event.mReply.mFocusedWidget ? event.mReply.mFocusedWidget : mWidget); - // Result rect is in top level widget coordinates - refWindow = refWindow->GetTopLevelWindow(false); - if (!refWindow) { - PR_LOG(sTextStoreLog, PR_LOG_ERROR, - ("TSF: 0x%p nsTextStore::GetTextExt() FAILED due to " - "no top level window", this)); - return E_FAIL; - } - - event.mReply.mRect.MoveBy(refWindow->WidgetToScreenOffset()); + // convert to unclipped screen rect + nsWindow* refWindow = static_cast( + event.mReply.mFocusedWidget ? event.mReply.mFocusedWidget : mWidget); + // Result rect is in top level widget coordinates + refWindow = refWindow->GetTopLevelWindow(false); + if (!refWindow) { + PR_LOG(sTextStoreLog, PR_LOG_ERROR, + ("TSF: 0x%p nsTextStore::GetTextExt() FAILED due to " + "no top level window", this)); + return E_FAIL; } + event.mReply.mRect.MoveBy(refWindow->WidgetToScreenOffset()); + // get bounding screen rect to test for clipping if (!GetScreenExtInternal(*prc)) { PR_LOG(sTextStoreLog, PR_LOG_ERROR, @@ -3322,50 +3317,36 @@ nsTextStore::GetScreenExtInternal(RECT &aScreenExt) return false; } - if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) { - nsIntRect boundRect; - if (NS_FAILED(mWidget->GetClientBounds(boundRect))) { - PR_LOG(sTextStoreLog, PR_LOG_ERROR, - ("TSF: 0x%p nsTextStore::GetScreenExtInternal() FAILED due to " - "failed to get the client bounds", this)); - return false; - } - ::SetRect(&aScreenExt, boundRect.x, boundRect.y, - boundRect.XMost(), boundRect.YMost()); - } else { - NS_ASSERTION(XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Desktop, - "environment isn't WindowsEnvironmentType_Desktop!"); - nsWindow* refWindow = static_cast( - event.mReply.mFocusedWidget ? - event.mReply.mFocusedWidget : mWidget); - // Result rect is in top level widget coordinates - refWindow = refWindow->GetTopLevelWindow(false); - if (!refWindow) { - PR_LOG(sTextStoreLog, PR_LOG_ERROR, - ("TSF: 0x%p nsTextStore::GetScreenExtInternal() FAILED due to " - "no top level window", this)); - return false; - } + nsWindow* refWindow = static_cast( + event.mReply.mFocusedWidget ? + event.mReply.mFocusedWidget : mWidget); + // Result rect is in top level widget coordinates + refWindow = refWindow->GetTopLevelWindow(false); + if (!refWindow) { + PR_LOG(sTextStoreLog, PR_LOG_ERROR, + ("TSF: 0x%p nsTextStore::GetScreenExtInternal() FAILED due to " + "no top level window", this)); + return false; + } - nsIntRect boundRect; - if (NS_FAILED(refWindow->GetClientBounds(boundRect))) { - PR_LOG(sTextStoreLog, PR_LOG_ERROR, - ("TSF: 0x%p nsTextStore::GetScreenExtInternal() FAILED due to " - "failed to get the client bounds", this)); - return false; - } + nsIntRect boundRect; + if (NS_FAILED(refWindow->GetClientBounds(boundRect))) { + PR_LOG(sTextStoreLog, PR_LOG_ERROR, + ("TSF: 0x%p nsTextStore::GetScreenExtInternal() FAILED due to " + "failed to get the client bounds", this)); + return false; + } - boundRect.MoveTo(0, 0); + boundRect.MoveTo(0, 0); - // Clip frame rect to window rect - boundRect.IntersectRect(LayoutDevicePixel::ToUntyped(event.mReply.mRect), boundRect); - if (!boundRect.IsEmpty()) { - boundRect.MoveBy(refWindow->WidgetToScreenOffsetUntyped()); - ::SetRect(&aScreenExt, boundRect.x, boundRect.y, - boundRect.XMost(), boundRect.YMost()); - } else { - ::SetRectEmpty(&aScreenExt); - } + // Clip frame rect to window rect + boundRect.IntersectRect(LayoutDevicePixel::ToUntyped(event.mReply.mRect), boundRect); + if (!boundRect.IsEmpty()) { + boundRect.MoveBy(refWindow->WidgetToScreenOffsetUntyped()); + ::SetRect(&aScreenExt, boundRect.x, boundRect.y, + boundRect.XMost(), boundRect.YMost()); + } else { + ::SetRectEmpty(&aScreenExt); } PR_LOG(sTextStoreLog, PR_LOG_DEBUG, @@ -4296,11 +4277,6 @@ nsTextStore::OnMouseButtonEventInternal(const IMENotification& aIMENotification) void nsTextStore::CreateNativeCaret() { - // This method must work only on desktop application. - if (XRE_GetWindowsEnvironment() != WindowsEnvironmentType_Desktop) { - return; - } - PR_LOG(sTextStoreLog, PR_LOG_DEBUG, ("TSF: 0x%p nsTextStore::CreateNativeCaret(), " "mComposition.IsComposing()=%s", diff --git a/widget/windows/nsTextStore.h b/widget/windows/nsTextStore.h index 0f1b58416..fcd1a9315 100644 --- a/widget/windows/nsTextStore.h +++ b/widget/windows/nsTextStore.h @@ -297,7 +297,7 @@ protected: // application. Otherwise, this does nothing. void CreateNativeCaret(); - // Holds the pointer to our current win32 or metro widget + // Holds the pointer to our current win32 widget nsRefPtr mWidget; // Document manager for the currently focused editor nsRefPtr mDocumentMgr; diff --git a/widget/windows/nsWidgetFactory.cpp b/widget/windows/nsWidgetFactory.cpp index 73fb13894..96ed545bf 100644 --- a/widget/windows/nsWidgetFactory.cpp +++ b/widget/windows/nsWidgetFactory.cpp @@ -31,13 +31,6 @@ #include "nsWindow.h" // Content processes #include "nsFilePickerProxy.h" -// Metro -#ifdef MOZ_METRO -#include "winrt/MetroAppShell.h" -#include "winrt/MetroWidget.h" -#include "winrt/nsMetroFilePicker.h" -#include "winrt/nsWinMetroUtils.h" -#endif // Drag & Drop, Clipboard #include "nsClipboardHelper.h" @@ -68,18 +61,8 @@ WindowConstructor(nsISupports *aOuter, REFNSIID aIID, if (aOuter != nullptr) { return NS_ERROR_NO_AGGREGATION; } - nsCOMPtr widget; - - if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) { -#ifdef MOZ_METRO - widget = new MetroWidget; -#else - NS_RUNTIMEABORT("build does not support metro."); -#endif - } else { - widget = new nsWindow; - } - + + nsCOMPtr widget = new nsWindow; return widget->QueryInterface(aIID, aResult); } @@ -91,14 +74,8 @@ ChildWindowConstructor(nsISupports *aOuter, REFNSIID aIID, if (aOuter != nullptr) { return NS_ERROR_NO_AGGREGATION; } - nsCOMPtr widget; - - if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) { - return NS_NOINTERFACE; - } else { - widget = new ChildWindow; - } + nsCOMPtr widget = new ChildWindow; return widget->QueryInterface(aIID, aResult); } @@ -110,17 +87,8 @@ FilePickerConstructor(nsISupports *aOuter, REFNSIID aIID, if (aOuter != nullptr) { return NS_ERROR_NO_AGGREGATION; } - nsCOMPtr picker; - if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) { -#ifdef MOZ_METRO - picker = new nsMetroFilePicker; -#else - NS_RUNTIMEABORT("build does not support metro."); -#endif - } else { - picker = new nsFilePicker; - } + nsCOMPtr picker = new nsFilePicker; return picker->QueryInterface(aIID, aResult); } @@ -132,20 +100,8 @@ ColorPickerConstructor(nsISupports *aOuter, REFNSIID aIID, if (aOuter != nullptr) { return NS_ERROR_NO_AGGREGATION; } - nsCOMPtr picker; - if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) { -#ifdef MOZ_METRO - // TODO - // picker = new nsMetroColorPicker; - NS_ERROR("metro color picker isn't implemented currently"); - return NS_ERROR_NO_INTERFACE; -#else - NS_RUNTIMEABORT("build does not support metro."); -#endif - } else { - picker = new nsColorPicker; - } + nsCOMPtr picker = new nsColorPicker; return picker->QueryInterface(aIID, aResult); } @@ -164,9 +120,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable) NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService) NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) -#ifdef MOZ_METRO -NS_GENERIC_FACTORY_CONSTRUCTOR(nsWinMetroUtils) -#endif #ifdef NS_PRINTING NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsWin, Init) NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorWin) @@ -201,9 +154,6 @@ NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTITEM_CID); NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTSEPARATOR_CID); NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTLINK_CID); NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTSHORTCUT_CID); -#ifdef MOZ_METRO -NS_DEFINE_NAMED_CID(NS_WIN_METROUTILS_CID); -#endif NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID); NS_DEFINE_NAMED_CID(NS_BIDIKEYBOARD_CID); #ifdef NS_PRINTING @@ -238,9 +188,6 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = { { &kNS_WIN_JUMPLISTSHORTCUT_CID, false, nullptr, JumpListShortcutConstructor }, { &kNS_DRAGSERVICE_CID, false, nullptr, nsDragServiceConstructor, Module::MAIN_PROCESS_ONLY }, { &kNS_BIDIKEYBOARD_CID, false, nullptr, nsBidiKeyboardConstructor }, -#ifdef MOZ_METRO - { &kNS_WIN_METROUTILS_CID, false, nullptr, nsWinMetroUtilsConstructor }, -#endif #ifdef NS_PRINTING { &kNS_PRINTSETTINGSSERVICE_CID, false, nullptr, nsPrintOptionsWinConstructor }, { &kNS_PRINTER_ENUMERATOR_CID, false, nullptr, nsPrinterEnumeratorWinConstructor }, @@ -273,9 +220,6 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = { { "@mozilla.org/windows-jumplistshortcut;1", &kNS_WIN_JUMPLISTSHORTCUT_CID }, { "@mozilla.org/widget/dragservice;1", &kNS_DRAGSERVICE_CID, Module::MAIN_PROCESS_ONLY }, { "@mozilla.org/widget/bidikeyboard;1", &kNS_BIDIKEYBOARD_CID }, -#ifdef MOZ_METRO - { "@mozilla.org/windows-metroutils;1", &kNS_WIN_METROUTILS_CID }, -#endif #ifdef NS_PRINTING { "@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID }, { "@mozilla.org/gfx/printerenumerator;1", &kNS_PRINTER_ENUMERATOR_CID }, diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 6be5ba693..43d95dca9 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -5411,23 +5411,6 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam, } break; - case WM_SETTINGCHANGE: - if (IsWin8OrLater() && lParam && - !wcsicmp(L"ConvertibleSlateMode", (wchar_t*)lParam)) { - // If we're switching into slate mode, switch to Metro for hardware - // that supports this feature if the pref is set. - if (GetSystemMetrics(SM_CONVERTIBLESLATEMODE) == 0 && - Preferences::GetBool("browser.shell.desktop-auto-switch-enabled", - false)) { - nsCOMPtr appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID)); - if (appStartup) { - appStartup->Quit(nsIAppStartup::eForceQuit | - nsIAppStartup::eRestartTouchEnvironment); - } - } - } - break; - default: { if (msg == nsAppShell::GetTaskbarButtonCreatedMessage()) { diff --git a/widget/windows/winrt/APZController.cpp b/widget/windows/winrt/APZController.cpp deleted file mode 100644 index a196f472c..000000000 --- a/widget/windows/winrt/APZController.cpp +++ /dev/null @@ -1,315 +0,0 @@ -/* 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 "APZController.h" -#include "base/message_loop.h" -#include "mozilla/layers/GoannaContentController.h" -#include "nsThreadUtils.h" -#include "MetroUtils.h" -#include "nsPrintfCString.h" -#include "mozilla/layers/APZCCallbackHelper.h" -#include "nsIDocument.h" -#include "nsPresContext.h" -#include "nsIDOMElement.h" -#include "mozilla/dom/Element.h" -#include "nsIDOMWindowUtils.h" -#include "nsIInterfaceRequestorUtils.h" -#include "nsLayoutUtils.h" -#include "mozilla/TouchEvents.h" - -//#define DEBUG_CONTROLLER 1 - -#ifdef DEBUG_CONTROLLER -#include "WinUtils.h" -using namespace mozilla::widget; -#endif - -namespace mozilla { -namespace widget { -namespace winrt { - -nsRefPtr APZController::sAPZC; - -/* - * Metro layout specific - test to see if a sub document is a - * tab. - */ -static bool -IsTab(nsCOMPtr& aSubDocument) -{ - nsRefPtr parent = aSubDocument->GetParentDocument(); - if (!parent) { - NS_WARNING("huh? IsTab should always get a sub document for a parameter"); - return false; - } - return parent->IsRootDisplayDocument(); -} - -/* - * Returns the sub document associated with the scroll id. - */ -static bool -GetDOMTargets(uint64_t aScrollId, - nsCOMPtr& aSubDocument, - nsCOMPtr& aTargetContent) -{ - // For tabs and subframes this will return the HTML sub document - aTargetContent = nsLayoutUtils::FindContentFor(aScrollId); - if (!aTargetContent) { - return false; - } - nsCOMPtr domElement = do_QueryInterface(aTargetContent); - if (!domElement) { - return false; - } - - aSubDocument = domElement->OwnerDoc(); - - if (!aSubDocument) { - return false; - } - - // If the root element equals domElement, FindElementWithViewId found - // a document, vs. an element within a document. - if (aSubDocument->GetRootElement() == domElement && IsTab(aSubDocument)) { - aTargetContent = nullptr; - } - - return true; -} - -void -APZController::SetPendingResponseFlusher(APZPendingResponseFlusher* aFlusher) -{ - mFlusher = aFlusher; -} - -void -APZController::ContentReceivedInputBlock(const uint64_t aInputBlockId, bool aPreventDefault) -{ - if (!sAPZC) { - return; - } - sAPZC->ContentReceivedInputBlock(aInputBlockId, aPreventDefault); -} - -bool -APZController::HitTestAPZC(ScreenIntPoint& aPoint) -{ - if (!sAPZC) { - return false; - } - return sAPZC->HitTestAPZC(aPoint); -} - -void -APZController::TransformCoordinateToGoanna(const ScreenIntPoint& aPoint, - LayoutDeviceIntPoint* aRefPointOut) -{ - if (!sAPZC || !aRefPointOut) { - return; - } - sAPZC->TransformCoordinateToGoanna(aPoint, aRefPointOut); -} - -nsEventStatus -APZController::ReceiveInputEvent(WidgetInputEvent* aEvent, - ScrollableLayerGuid* aOutTargetGuid, - uint64_t* aOutInputBlockId) -{ - MOZ_ASSERT(aEvent); - - if (!sAPZC) { - return nsEventStatus_eIgnore; - } - return sAPZC->ReceiveInputEvent(*aEvent->AsInputEvent(), aOutTargetGuid, aOutInputBlockId); -} - -// APZC sends us this request when we need to update the display port on -// the scrollable frame the apzc is managing. -void -APZController::RequestContentRepaint(const FrameMetrics& aFrameMetrics) -{ -#ifdef DEBUG_CONTROLLER - WinUtils::Log("APZController::RequestContentRepaint scrollid=%I64d", - aFrameMetrics.GetScrollId()); -#endif - - // This must be on the goanna thread since we access the dom - MOZ_ASSERT(NS_IsMainThread()); - -#ifdef DEBUG_CONTROLLER - WinUtils::Log("APZController: mScrollOffset: %f %f", aFrameMetrics.mScrollOffset.x, - aFrameMetrics.mScrollOffset.y); -#endif - - nsCOMPtr subDocument; - nsCOMPtr targetContent; - if (!GetDOMTargets(aFrameMetrics.GetScrollId(), - subDocument, targetContent)) { - return; - } - - // If we're dealing with a sub frame or content editable element, - // call UpdateSubFrame. - if (targetContent) { -#ifdef DEBUG_CONTROLLER - WinUtils::Log("APZController: detected subframe or content editable"); -#endif - FrameMetrics metrics = aFrameMetrics; - mozilla::layers::APZCCallbackHelper::UpdateSubFrame(targetContent, metrics); - return; - } - -#ifdef DEBUG_CONTROLLER - WinUtils::Log("APZController: detected tab"); -#endif - - // We're dealing with a tab, call UpdateRootFrame. - nsCOMPtr utils; - nsCOMPtr window = subDocument->GetDefaultView(); - if (window) { - utils = do_GetInterface(window); - if (utils) { - FrameMetrics metrics = aFrameMetrics; - mozilla::layers::APZCCallbackHelper::UpdateRootFrame(utils, metrics); - -#ifdef DEBUG_CONTROLLER - WinUtils::Log("APZController: %I64d mDisplayPortMargins: %0.2f %0.2f %0.2f %0.2f", - metrics.GetScrollId(), - metrics.GetDisplayPortMargins().left, - metrics.GetDisplayPortMargins().top, - metrics.GetDisplayPortMargins().right, - metrics.GetDisplayPortMargins().bottom); -#endif - } - } -} - -void -APZController::AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId, - const uint32_t& aScrollGeneration) -{ -#ifdef DEBUG_CONTROLLER - WinUtils::Log("APZController::AcknowledgeScrollUpdate scrollid=%I64d gen=%lu", - aScrollId, aScrollGeneration); -#endif - mozilla::layers::APZCCallbackHelper::AcknowledgeScrollUpdate(aScrollId, aScrollGeneration); -} - -void -APZController::HandleDoubleTap(const CSSPoint& aPoint, - int32_t aModifiers, - const ScrollableLayerGuid& aGuid) -{ -} - -void -APZController::HandleSingleTap(const CSSPoint& aPoint, - int32_t aModifiers, - const ScrollableLayerGuid& aGuid) -{ -} - -void -APZController::HandleLongTap(const CSSPoint& aPoint, - int32_t aModifiers, - const mozilla::layers::ScrollableLayerGuid& aGuid, - uint64_t aInputBlockId) -{ - if (mFlusher) { - mFlusher->FlushPendingContentResponse(); - } - ContentReceivedInputBlock(aInputBlockId, false); -} - -void -APZController::HandleLongTapUp(const CSSPoint& aPoint, - int32_t aModifiers, - const ScrollableLayerGuid& aGuid) -{ -} - -// requests that we send a mozbrowserasyncscroll domevent. not in use. -void -APZController::SendAsyncScrollDOMEvent(bool aIsRoot, - const CSSRect &aContentRect, - const CSSSize &aScrollableSize) -{ -} - -void -APZController::PostDelayedTask(Task* aTask, int aDelayMs) -{ - MessageLoop::current()->PostDelayedTask(FROM_HERE, aTask, aDelayMs); -} - -bool -APZController::GetRootZoomConstraints(ZoomConstraints* aOutConstraints) -{ - if (aOutConstraints) { - // Until we support the meta-viewport tag properly allow zooming - // from 1/4 to 4x by default. - aOutConstraints->mAllowZoom = true; - aOutConstraints->mAllowDoubleTapZoom = false; - aOutConstraints->mMinZoom = CSSToParentLayerScale(0.25f); - aOutConstraints->mMaxZoom = CSSToParentLayerScale(4.0f); - return true; - } - return false; -} - -// apzc notifications - -class TransformedStartEvent : public nsRunnable -{ - NS_IMETHOD Run() { - MetroUtils::FireObserver("apzc-transform-start", L""); - return NS_OK; - } -}; - -class TransformedEndEvent : public nsRunnable -{ - NS_IMETHOD Run() { - MetroUtils::FireObserver("apzc-transform-end", L""); - return NS_OK; - } -}; - -void -APZController::NotifyAPZStateChange(const ScrollableLayerGuid& aGuid, - APZStateChange aChange, - int aArg) -{ - switch (aChange) { - case APZStateChange::TransformBegin: - { - if (NS_IsMainThread()) { - MetroUtils::FireObserver("apzc-transform-begin", L""); - return; - } - nsCOMPtr runnable = new TransformedStartEvent(); - NS_DispatchToMainThread(runnable); - break; - } - case APZStateChange::TransformEnd: - { - if (NS_IsMainThread()) { - MetroUtils::FireObserver("apzc-transform-end", L""); - return; - } - nsCOMPtr runnable = new TransformedEndEvent(); - NS_DispatchToMainThread(runnable); - break; - } - default: - { - // We don't currently care about other state changes. - break; - } - } -} - -} } } diff --git a/widget/windows/winrt/APZController.h b/widget/windows/winrt/APZController.h deleted file mode 100644 index b2df8b620..000000000 --- a/widget/windows/winrt/APZController.h +++ /dev/null @@ -1,79 +0,0 @@ -/* 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/. */ - -#pragma once - -#include "mozwrlbase.h" - -#include "mozilla/layers/GoannaContentController.h" -#include "mozilla/layers/APZCTreeManager.h" -#include "mozilla/EventForwards.h" -#include "FrameMetrics.h" -#include "Units.h" - -namespace mozilla { -namespace widget { -namespace winrt { - -class APZPendingResponseFlusher -{ -public: - virtual void FlushPendingContentResponse() = 0; -}; - -class APZController : - public mozilla::layers::GoannaContentController -{ - typedef mozilla::layers::FrameMetrics FrameMetrics; - typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid; - typedef mozilla::layers::ZoomConstraints ZoomConstraints; - -public: - APZController() : - mFlusher(nullptr) - { - } - - // GoannaContentController interface - virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics); - virtual void AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId, const uint32_t& aScrollGeneration); - virtual void HandleDoubleTap(const mozilla::CSSPoint& aPoint, - int32_t aModifiers, - const mozilla::layers::ScrollableLayerGuid& aGuid); - virtual void HandleSingleTap(const mozilla::CSSPoint& aPoint, - int32_t aModifiers, - const mozilla::layers::ScrollableLayerGuid& aGuid); - virtual void HandleLongTap(const mozilla::CSSPoint& aPoint, - int32_t aModifiers, - const mozilla::layers::ScrollableLayerGuid& aGuid, - uint64_t aInputBlockId); - virtual void HandleLongTapUp(const mozilla::CSSPoint& aPoint, - int32_t aModifiers, - const mozilla::layers::ScrollableLayerGuid& aGuid); - virtual void SendAsyncScrollDOMEvent(bool aIsRoot, const mozilla::CSSRect &aContentRect, const mozilla::CSSSize &aScrollableSize); - virtual void PostDelayedTask(Task* aTask, int aDelayMs); - virtual bool GetRootZoomConstraints(ZoomConstraints* aOutConstraints); - virtual void NotifyAPZStateChange(const ScrollableLayerGuid& aGuid, - APZStateChange aChange, - int aArg); - - void SetPendingResponseFlusher(APZPendingResponseFlusher* aFlusher); - - bool HitTestAPZC(mozilla::ScreenIntPoint& aPoint); - void TransformCoordinateToGoanna(const mozilla::ScreenIntPoint& aPoint, - LayoutDeviceIntPoint* aRefPointOut); - void ContentReceivedInputBlock(uint64_t aInputBlockId, bool aPreventDefault); - nsEventStatus ReceiveInputEvent(mozilla::WidgetInputEvent* aEvent, - ScrollableLayerGuid* aOutTargetGuid, - uint64_t* aOutInputBlockId); - -public: - // todo: make this a member variable as prep for multiple views - static nsRefPtr sAPZC; - -private: - APZPendingResponseFlusher* mFlusher; -}; - -} } } diff --git a/widget/windows/winrt/DisplayInfo_sdk81.h b/widget/windows/winrt/DisplayInfo_sdk81.h deleted file mode 100644 index 3298d2601..000000000 --- a/widget/windows/winrt/DisplayInfo_sdk81.h +++ /dev/null @@ -1,458 +0,0 @@ - -/* this file contains the definitions for DisplayInformation related interfaces - copied over from Windows.Graphics.Display.h file in the windows 8.1 SDK - This file can be deleted once our build system moves to 8.1. */ - - /* File created by MIDL compiler version 8.00.0603 */ -/* @@MIDL_FILE_HEADING( ) */ - -/* Forward Declarations */ - -#ifndef ____FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable_FWD_DEFINED__ -#define ____FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable_FWD_DEFINED__ -typedef interface __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable; - -#endif /* ____FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable_FWD_DEFINED__ */ - - -#ifndef ____x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformationStatics_FWD_DEFINED__ -#define ____x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformationStatics_FWD_DEFINED__ -typedef interface __x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformationStatics __x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformationStatics; - -#ifdef __cplusplus -namespace ABI { - namespace Windows { - namespace Graphics { - namespace Display { - interface IDisplayInformationStatics; - } /* end namespace */ - } /* end namespace */ - } /* end namespace */ -} /* end namespace */ - -#endif /* __cplusplus */ - -#endif /* ____x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformationStatics_FWD_DEFINED__ */ - - -#ifndef ____x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformation_FWD_DEFINED__ -#define ____x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformation_FWD_DEFINED__ -typedef interface __x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformation __x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformation; - -#ifdef __cplusplus -namespace ABI { - namespace Windows { - namespace Graphics { - namespace Display { - interface IDisplayInformation; - } /* end namespace */ - } /* end namespace */ - } /* end namespace */ -} /* end namespace */ - -#endif /* __cplusplus */ - -#endif /* ____x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformation_FWD_DEFINED__ */ - - -#ifdef __cplusplus -namespace ABI { -namespace Windows { -namespace Graphics { -namespace Display { -class DisplayInformation; -} /*Display*/ -} /*Graphics*/ -} /*Windows*/ -} -#endif - -#ifdef __cplusplus -namespace ABI { -namespace Windows { -namespace Graphics { -namespace Display { -interface IDisplayInformation; -} /*Display*/ -} /*Graphics*/ -} /*Windows*/ -} -#endif - -interface IInspectable; - - -/* interface __MIDL_itf_windows2Egraphics2Edisplay_0000_0000 */ -/* [local] */ - - - - - -extern RPC_IF_HANDLE __MIDL_itf_windows2Egraphics2Edisplay_0000_0000_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_windows2Egraphics2Edisplay_0000_0000_v0_0_s_ifspec; - -/* interface __MIDL_itf_windows2Egraphics2Edisplay_0000_0580 */ - - - - -/* interface __MIDL_itf_windows2Egraphics2Edisplay_0000_0580 */ - - - - -extern RPC_IF_HANDLE __MIDL_itf_windows2Egraphics2Edisplay_0000_0580_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_windows2Egraphics2Edisplay_0000_0580_v0_0_s_ifspec; - -/* interface __MIDL_itf_windows2Egraphics2Edisplay_0000_0001 */ -/* [local] */ - -#ifndef DEF___FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable_USE -#define DEF___FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable_USE -#if defined(__cplusplus) && !defined(RO_NO_TEMPLATE_NAME) -namespace ABI { namespace Windows { namespace Foundation { -template <> -struct __declspec(uuid("86c4f619-67b6-51c7-b30d-d8cf13625327")) -ITypedEventHandler : ITypedEventHandler_impl,IInspectable*> { -static const wchar_t* z_get_rc_name_impl() { -return L"Windows.Foundation.TypedEventHandler`2"; } -}; -typedef ITypedEventHandler __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable_t; -#define ____FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable_FWD_DEFINED__ -#define __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable ABI::Windows::Foundation::__FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable_t - -/* ABI */ } /* Windows */ } /* Foundation */ } -#endif //__cplusplus -#endif /* DEF___FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable_USE */ - -#ifndef DEF___FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable -#define DEF___FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable -#if !defined(__cplusplus) || defined(RO_NO_TEMPLATE_NAME) - - -/* interface __MIDL_itf_windows2Egraphics2Edisplay_0000_0004 */ -/* [local] */ - - - -extern RPC_IF_HANDLE __MIDL_itf_windows2Egraphics2Edisplay_0000_0004_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_windows2Egraphics2Edisplay_0000_0004_v0_0_s_ifspec; - -#ifndef ____FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable_INTERFACE_DEFINED__ -#define ____FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable_INTERFACE_DEFINED__ - -/* interface __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable */ -/* [unique][uuid][object] */ - - - -/* interface __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable */ -/* [unique][uuid][object] */ - - -EXTERN_C const IID IID___FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("86c4f619-67b6-51c7-b30d-d8cf13625327") - __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE Invoke( - /* [in] */ __RPC__in_opt ABI::Windows::Graphics::Display::IDisplayInformation *sender, - /* [in] */ __RPC__in_opt IInspectable *e) = 0; - - }; - - -#else /* C style interface */ - - typedef struct __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectableVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - __RPC__in __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable * This, - /* [in] */ __RPC__in REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - __RPC__in __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - __RPC__in __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable * This); - - HRESULT ( STDMETHODCALLTYPE *Invoke )( - __RPC__in __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable * This, - /* [in] */ __RPC__in_opt __x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformation *sender, - /* [in] */ __RPC__in_opt IInspectable *e); - - END_INTERFACE - } __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectableVtbl; - - interface __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable - { - CONST_VTBL struct __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectableVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable_Invoke(This,sender,e) \ - ( (This)->lpVtbl -> Invoke(This,sender,e) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* ____FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_windows2Egraphics2Edisplay_0000_0005 */ -/* [local] */ - -#endif /* pinterface */ -#endif /* DEF___FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable */ - - -/* interface __MIDL_itf_windows2Egraphics2Edisplay_0000_0005 */ -/* [local] */ - - -/* interface __x_ABI_CWindows_CGraphics_CDisplay_CIDisplayPropertiesEventHandler */ -/* [uuid][object] */ - - - -/* interface ABI::Windows::Graphics::Display::IDisplayPropertiesEventHandler */ -/* [uuid][object] */ - - - - -/* interface __MIDL_itf_windows2Egraphics2Edisplay_0000_0006 */ -/* [local] */ - -#if !defined(____x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformationStatics_INTERFACE_DEFINED__) -extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_Graphics_Display_IDisplayInformationStatics[] = L"Windows.Graphics.Display.IDisplayInformationStatics"; -#endif /* !defined(____x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformationStatics_INTERFACE_DEFINED__) */ - - -/* interface __MIDL_itf_windows2Egraphics2Edisplay_0000_0006 */ -/* [local] */ - - - -extern RPC_IF_HANDLE __MIDL_itf_windows2Egraphics2Edisplay_0000_0006_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_windows2Egraphics2Edisplay_0000_0006_v0_0_s_ifspec; - -#ifndef ____x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformationStatics_INTERFACE_DEFINED__ -#define ____x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformationStatics_INTERFACE_DEFINED__ - -/* interface __x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformationStatics */ -/* [uuid][object] */ - - - -/* interface ABI::Windows::Graphics::Display::IDisplayInformationStatics */ -/* [uuid][object] */ - - -EXTERN_C const IID IID___x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformationStatics; - -#if defined(__cplusplus) && !defined(CINTERFACE) - namespace ABI { - namespace Windows { - namespace Graphics { - namespace Display { - - MIDL_INTERFACE("C6A02A6C-D452-44DC-BA07-96F3C6ADF9D1") - IDisplayInformationStatics : public IInspectable - { - public: - virtual HRESULT STDMETHODCALLTYPE GetForCurrentView( - /* [out][retval] */ __RPC__deref_out_opt ABI::Windows::Graphics::Display::IDisplayInformation **current) = 0; - - virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_AutoRotationPreferences( - /* [out][retval] */ __RPC__out ABI::Windows::Graphics::Display::DisplayOrientations *value) = 0; - - virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_AutoRotationPreferences( - /* [in] */ ABI::Windows::Graphics::Display::DisplayOrientations value) = 0; - - virtual HRESULT STDMETHODCALLTYPE add_DisplayContentsInvalidated( - /* [in] */ __RPC__in_opt __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable *handler, - /* [out][retval] */ __RPC__out EventRegistrationToken *token) = 0; - - virtual HRESULT STDMETHODCALLTYPE remove_DisplayContentsInvalidated( - /* [in] */ EventRegistrationToken token) = 0; - - }; - - extern const __declspec(selectany) IID & IID_IDisplayInformationStatics = __uuidof(IDisplayInformationStatics); - - - } /* end namespace */ - } /* end namespace */ - } /* end namespace */ - } /* end namespace */ - -#endif /* C style interface */ - - - - -#endif /* ____x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformationStatics_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_windows2Egraphics2Edisplay_0000_0007 */ -/* [local] */ - -#if !defined(____x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformation_INTERFACE_DEFINED__) -extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_Graphics_Display_IDisplayInformation[] = L"Windows.Graphics.Display.IDisplayInformation"; -#endif /* !defined(____x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformation_INTERFACE_DEFINED__) */ - - -/* interface __MIDL_itf_windows2Egraphics2Edisplay_0000_0007 */ -/* [local] */ - - - -extern RPC_IF_HANDLE __MIDL_itf_windows2Egraphics2Edisplay_0000_0007_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_windows2Egraphics2Edisplay_0000_0007_v0_0_s_ifspec; - -#ifndef ____x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformation_INTERFACE_DEFINED__ -#define ____x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformation_INTERFACE_DEFINED__ - -/* interface __x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformation */ -/* [uuid][object] */ - - - -/* interface ABI::Windows::Graphics::Display::IDisplayInformation */ -/* [uuid][object] */ - - -EXTERN_C const IID IID___x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformation; - -#if defined(__cplusplus) && !defined(CINTERFACE) - namespace ABI { - namespace Windows { - namespace Graphics { - namespace Display { - - MIDL_INTERFACE("BED112AE-ADC3-4DC9-AE65-851F4D7D4799") - IDisplayInformation : public IInspectable - { - public: - virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_CurrentOrientation( - /* [out][retval] */ __RPC__out ABI::Windows::Graphics::Display::DisplayOrientations *value) = 0; - - virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_NativeOrientation( - /* [out][retval] */ __RPC__out ABI::Windows::Graphics::Display::DisplayOrientations *value) = 0; - - virtual HRESULT STDMETHODCALLTYPE add_OrientationChanged( - /* [in] */ __RPC__in_opt __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable *handler, - /* [out][retval] */ __RPC__out EventRegistrationToken *token) = 0; - - virtual HRESULT STDMETHODCALLTYPE remove_OrientationChanged( - /* [in] */ EventRegistrationToken token) = 0; - - virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ResolutionScale( - /* [out][retval] */ __RPC__out ABI::Windows::Graphics::Display::ResolutionScale *value) = 0; - - virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_LogicalDpi( - /* [out][retval] */ __RPC__out FLOAT *value) = 0; - - virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_RawDpiX( - /* [out][retval] */ __RPC__out FLOAT *value) = 0; - - virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_RawDpiY( - /* [out][retval] */ __RPC__out FLOAT *value) = 0; - - virtual HRESULT STDMETHODCALLTYPE add_DpiChanged( - /* [in] */ __RPC__in_opt __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable *handler, - /* [out][retval] */ __RPC__out EventRegistrationToken *token) = 0; - - virtual HRESULT STDMETHODCALLTYPE remove_DpiChanged( - /* [in] */ EventRegistrationToken token) = 0; - - virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_StereoEnabled( - /* [out][retval] */ __RPC__out boolean *value) = 0; - - virtual HRESULT STDMETHODCALLTYPE add_StereoEnabledChanged( - /* [in] */ __RPC__in_opt __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable *handler, - /* [out][retval] */ __RPC__out EventRegistrationToken *token) = 0; - - virtual HRESULT STDMETHODCALLTYPE remove_StereoEnabledChanged( - /* [in] */ EventRegistrationToken token) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetColorProfileAsync( - /* [out][retval] */ __RPC__deref_out_opt __FIAsyncOperation_1_Windows__CStorage__CStreams__CIRandomAccessStream **asyncInfo) = 0; - - virtual HRESULT STDMETHODCALLTYPE add_ColorProfileChanged( - /* [in] */ __RPC__in_opt __FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable *handler, - /* [out][retval] */ __RPC__out EventRegistrationToken *token) = 0; - - virtual HRESULT STDMETHODCALLTYPE remove_ColorProfileChanged( - /* [in] */ EventRegistrationToken token) = 0; - - }; - - extern const __declspec(selectany) IID & IID_IDisplayInformation = __uuidof(IDisplayInformation); - - - } /* end namespace */ - } /* end namespace */ - } /* end namespace */ - } /* end namespace */ - -#endif /* C style interface */ - - - - -#endif /* ____x_ABI_CWindows_CGraphics_CDisplay_CIDisplayInformation_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_windows2Egraphics2Edisplay_0000_0008 */ -/* [local] */ - - -/* interface __MIDL_itf_windows2Egraphics2Edisplay_0000_0009 */ -/* [local] */ - -#ifndef RUNTIMECLASS_Windows_Graphics_Display_DisplayInformation_DEFINED -#define RUNTIMECLASS_Windows_Graphics_Display_DisplayInformation_DEFINED -extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_Graphics_Display_DisplayInformation[] = L"Windows.Graphics.Display.DisplayInformation"; -#endif - - -/* interface __MIDL_itf_windows2Egraphics2Edisplay_0000_0009 */ -/* [local] */ - - - -extern RPC_IF_HANDLE __MIDL_itf_windows2Egraphics2Edisplay_0000_0009_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_windows2Egraphics2Edisplay_0000_0009_v0_0_s_ifspec; - -/* Additional Prototypes for ALL interfaces */ - -/* end of Additional Prototypes */ diff --git a/widget/windows/winrt/FrameworkView.cpp b/widget/windows/winrt/FrameworkView.cpp deleted file mode 100644 index 363d772fd..000000000 --- a/widget/windows/winrt/FrameworkView.cpp +++ /dev/null @@ -1,507 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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 "FrameworkView.h" -#include "MetroAppShell.h" -#include "MetroWidget.h" -#include "mozilla/AutoRestore.h" -#include "MetroUtils.h" -#include "MetroApp.h" -#include "UIABridgePublic.h" -#include "KeyboardLayout.h" - -// generated -#include "UIABridge.h" - -using namespace mozilla; -using namespace mozilla::widget::winrt; -#ifdef ACCESSIBILITY -using namespace mozilla::a11y; -#endif -using namespace ABI::Windows::ApplicationModel; -using namespace ABI::Windows::ApplicationModel::Core; -using namespace ABI::Windows::ApplicationModel::Activation; -using namespace ABI::Windows::UI::Core; -using namespace ABI::Windows::UI::ViewManagement; -using namespace ABI::Windows::UI::Input; -using namespace ABI::Windows::Devices::Input; -using namespace ABI::Windows::System; -using namespace ABI::Windows::Foundation; -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; - -namespace mozilla { -namespace widget { -namespace winrt { - -// statics -bool FrameworkView::sKeyboardIsVisible = false; -Rect FrameworkView::sKeyboardRect; -HSTRING FrameworkView::sActivationURI = NULL; -ApplicationExecutionState FrameworkView::sPreviousExecutionState; -nsTArray* sSettingsArray; - -FrameworkView::FrameworkView(MetroApp* aMetroApp) : - mDPI(-1.0f), - mWidget(nullptr), - mShuttingDown(false), - mMetroApp(aMetroApp), - mWindow(nullptr), - mMetroInput(nullptr), - mWinVisible(false), - mWinActiveState(false) -{ - mActivated.value = 0; - mWindowActivated.value = 0; - mWindowVisibilityChanged.value = 0; - mWindowSizeChanged.value = 0; - mSoftKeyboardHidden.value = 0; - mSoftKeyboardShown.value = 0; - mDisplayPropertiesChanged.value = 0; - mAutomationProviderRequested.value = 0; - mDataTransferRequested.value = 0; - mSearchQuerySubmitted.value = 0; - mPlayToRequested.value = 0; - mSettingsPane.value = 0; - mPrintManager.value = 0; - memset(&sKeyboardRect, 0, sizeof(Rect)); - sSettingsArray = new nsTArray(); - LogFunction(); -} - -//////////////////////////////////////////////////// -// IFrameworkView impl. - -HRESULT -FrameworkView::Initialize(ICoreApplicationView* aAppView) -{ - LogFunction(); - if (mShuttingDown) - return E_FAIL; - - aAppView->add_Activated(Callback<__FITypedEventHandler_2_Windows__CApplicationModel__CCore__CCoreApplicationView_Windows__CApplicationModel__CActivation__CIActivatedEventArgs_t>( - this, &FrameworkView::OnActivated).Get(), &mActivated); - - //CoCreateInstance(CLSID_WICImagingFactory, nullptr, - // CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&mWicFactory)); - return S_OK; -} - -HRESULT -FrameworkView::Uninitialize() -{ - return S_OK; -} - -HRESULT -FrameworkView::Load(HSTRING aEntryPoint) -{ - return S_OK; -} - -// called by winrt on startup -HRESULT -FrameworkView::Run() -{ - LogFunction(); - - // Initialize XPCOM, create mWidget and go! We get a - // callback in MetroAppShell::Run, in which we kick - // off normal browser execution / event dispatching. - mMetroApp->Run(); - - // Goanna is completely shut down at this point. - WinUtils::Log("Exiting FrameworkView::Run()"); - - WindowsDeleteString(sActivationURI); - return S_OK; -} - -HRESULT -FrameworkView::ActivateView() -{ - LogFunction(); - - UpdateWidgetSizeAndPosition(); - - nsIntRegion region(nsIntRect(0, 0, mWindowBounds.width, mWindowBounds.height)); - mWidget->Paint(region); - - // Activate the window, this kills the splash screen - mWindow->Activate(); - - ProcessLaunchArguments(); - AddEventHandlers(); - SetupContracts(); - - return S_OK; -} - -HRESULT -FrameworkView::SetWindow(ICoreWindow* aWindow) -{ - LogFunction(); - - NS_ASSERTION(!mWindow, "Attempting to set a window on a view that already has a window!"); - NS_ASSERTION(aWindow, "Attempting to set a null window on a view!"); - - mWindow = aWindow; - UpdateLogicalDPI(); - return S_OK; -} - -//////////////////////////////////////////////////// -// FrameworkView impl. - -void -FrameworkView::AddEventHandlers() { - NS_ASSERTION(mWindow, "SetWindow must be called before AddEventHandlers!"); - NS_ASSERTION(mWidget, "SetWidget must be called before AddEventHAndlers!"); - - mMetroInput = Make(mWidget.Get(), - mWindow.Get()); - - mWindow->add_VisibilityChanged(Callback<__FITypedEventHandler_2_Windows__CUI__CCore__CCoreWindow_Windows__CUI__CCore__CVisibilityChangedEventArgs>( - this, &FrameworkView::OnWindowVisibilityChanged).Get(), &mWindowVisibilityChanged); - mWindow->add_Activated(Callback<__FITypedEventHandler_2_Windows__CUI__CCore__CCoreWindow_Windows__CUI__CCore__CWindowActivatedEventArgs_t>( - this, &FrameworkView::OnWindowActivated).Get(), &mWindowActivated); - mWindow->add_SizeChanged(Callback<__FITypedEventHandler_2_Windows__CUI__CCore__CCoreWindow_Windows__CUI__CCore__CWindowSizeChangedEventArgs_t>( - this, &FrameworkView::OnWindowSizeChanged).Get(), &mWindowSizeChanged); - - mWindow->add_AutomationProviderRequested(Callback<__FITypedEventHandler_2_Windows__CUI__CCore__CCoreWindow_Windows__CUI__CCore__CAutomationProviderRequestedEventArgs_t>( - this, &FrameworkView::OnAutomationProviderRequested).Get(), &mAutomationProviderRequested); - - HRESULT hr; - ComPtr dispProps; - if (SUCCEEDED(GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayProperties).Get(), dispProps.GetAddressOf()))) { - hr = dispProps->add_LogicalDpiChanged(Callback( - this, &FrameworkView::OnLogicalDpiChanged).Get(), &mDisplayPropertiesChanged); - LogHRESULT(hr); - } - - ComPtr inputStatic; - if (SUCCEEDED(hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_ViewManagement_InputPane).Get(), inputStatic.GetAddressOf()))) { - ComPtr inputPane; - if (SUCCEEDED(inputStatic->GetForCurrentView(inputPane.GetAddressOf()))) { - inputPane->add_Hiding(Callback<__FITypedEventHandler_2_Windows__CUI__CViewManagement__CInputPane_Windows__CUI__CViewManagement__CInputPaneVisibilityEventArgs_t>( - this, &FrameworkView::OnSoftkeyboardHidden).Get(), &mSoftKeyboardHidden); - inputPane->add_Showing(Callback<__FITypedEventHandler_2_Windows__CUI__CViewManagement__CInputPane_Windows__CUI__CViewManagement__CInputPaneVisibilityEventArgs_t>( - this, &FrameworkView::OnSoftkeyboardShown).Get(), &mSoftKeyboardShown); - } - } -} - -// Called by MetroApp -void -FrameworkView::Shutdown() -{ - LogFunction(); - mShuttingDown = true; - - if (mWindow && mWindowVisibilityChanged.value) { - mWindow->remove_VisibilityChanged(mWindowVisibilityChanged); - mWindow->remove_Activated(mWindowActivated); - mWindow->remove_Closed(mWindowClosed); - mWindow->remove_SizeChanged(mWindowSizeChanged); - mWindow->remove_AutomationProviderRequested(mAutomationProviderRequested); - } - - ComPtr dispProps; - if (mDisplayPropertiesChanged.value && - SUCCEEDED(GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayProperties).Get(), dispProps.GetAddressOf()))) { - dispProps->remove_LogicalDpiChanged(mDisplayPropertiesChanged); - } - - ComPtr inputStatic; - if (mSoftKeyboardHidden.value && - SUCCEEDED(GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_ViewManagement_InputPane).Get(), inputStatic.GetAddressOf()))) { - ComPtr inputPane; - if (SUCCEEDED(inputStatic->GetForCurrentView(inputPane.GetAddressOf()))) { - inputPane->remove_Hiding(mSoftKeyboardHidden); - inputPane->remove_Showing(mSoftKeyboardShown); - } - } - - if (mAutomationProvider) { - ComPtr provider; - mAutomationProvider.As(&provider); - if (provider) { - provider->Disconnect(); - } - } - mAutomationProvider = nullptr; - - mMetroInput = nullptr; - delete sSettingsArray; - sSettingsArray = nullptr; - mWidget = nullptr; - mMetroApp = nullptr; - mWindow = nullptr; -} - -void -FrameworkView::SetCursor(CoreCursorType aCursorType, DWORD aCustomId) -{ - if (mShuttingDown) { - return; - } - NS_ASSERTION(mWindow, "SetWindow must be called before SetCursor!"); - ComPtr factory; - AssertHRESULT(GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_Core_CoreCursor).Get(), factory.GetAddressOf())); - ComPtr cursor; - AssertHRESULT(factory->CreateCursor(aCursorType, aCustomId, cursor.GetAddressOf())); - mWindow->put_PointerCursor(cursor.Get()); -} - -void -FrameworkView::ClearCursor() -{ - if (mShuttingDown) { - return; - } - NS_ASSERTION(mWindow, "SetWindow must be called before ClearCursor!"); - mWindow->put_PointerCursor(nullptr); -} - -void -FrameworkView::UpdateLogicalDPI() -{ - ComPtr dispProps; - HRESULT hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayProperties).Get(), - dispProps.GetAddressOf()); - AssertHRESULT(hr); - FLOAT value; - AssertHRESULT(dispProps->get_LogicalDpi(&value)); - SetDpi(value); -} - -void -FrameworkView::GetBounds(nsIntRect &aRect) -{ - // May be called by compositor thread - if (mShuttingDown) { - return; - } - aRect = mWindowBounds; -} - -void -FrameworkView::UpdateWidgetSizeAndPosition() -{ - if (mShuttingDown) - return; - - NS_ASSERTION(mWindow, "SetWindow must be called before UpdateWidgetSizeAndPosition!"); - NS_ASSERTION(mWidget, "SetWidget must be called before UpdateWidgetSizeAndPosition!"); - - UpdateBounds(); - mWidget->Move(0, 0); - mWidget->Resize(0, 0, mWindowBounds.width, mWindowBounds.height, true); - mWidget->SizeModeChanged(); -} - -bool -FrameworkView::IsEnabled() const -{ - return mWinActiveState; -} - -bool -FrameworkView::IsVisible() const -{ - // we could check the wnd in MetroWidget for this, but - // generally we don't let nsIWidget control visibility - // or activation. - return mWinVisible; -} - -void FrameworkView::SetDpi(float aDpi) -{ - if (aDpi != mDPI) { - LogFunction(); - - mDPI = aDpi; - - // notify the widget that dpi has changed - if (mWidget) { - mWidget->ChangedDPI(); - UpdateBounds(); - } - } -} - -void -FrameworkView::UpdateBounds() -{ - if (!mWidget) - return; - - RECT winRect; - GetClientRect(mWidget->GetICoreWindowHWND(), &winRect); - - mWindowBounds = nsIntRect(winRect.left, - winRect.top, - winRect.right - winRect.left, - winRect.bottom - winRect.top); -} - -void -FrameworkView::SetWidget(MetroWidget* aWidget) -{ - NS_ASSERTION(!mWidget, "Attempting to set a widget for a view that already has a widget!"); - NS_ASSERTION(aWidget, "Attempting to set a null widget for a view!"); - LogFunction(); - mWidget = aWidget; - mWidget->FindMetroWindow(); - UpdateBounds(); -} - -//////////////////////////////////////////////////// -// Event handlers - -void -FrameworkView::SendActivationEvent() -{ - if (mShuttingDown) { - return; - } - NS_ASSERTION(mWindow, "SetWindow must be called before SendActivationEvent!"); - mWidget->Activated(mWinActiveState); - if (mWinActiveState) { - UpdateWidgetSizeAndPosition(); - } - EnsureAutomationProviderCreated(); -} - -HRESULT -FrameworkView::OnWindowVisibilityChanged(ICoreWindow* aWindow, - IVisibilityChangedEventArgs* aArgs) -{ - // If we're visible, or we can't determine if we're visible, just store - // that we are visible. - boolean visible; - mWinVisible = FAILED(aArgs->get_Visible(&visible)) || visible; - return S_OK; -} - -HRESULT -FrameworkView::OnActivated(ICoreApplicationView* aApplicationView, - IActivatedEventArgs* aArgs) -{ - LogFunction(); - - if (mShuttingDown) { - return S_OK; - } - - aArgs->get_PreviousExecutionState(&sPreviousExecutionState); - bool startup = sPreviousExecutionState == ApplicationExecutionState::ApplicationExecutionState_Terminated || - sPreviousExecutionState == ApplicationExecutionState::ApplicationExecutionState_ClosedByUser || - sPreviousExecutionState == ApplicationExecutionState::ApplicationExecutionState_NotRunning; - ProcessActivationArgs(aArgs, startup); - return S_OK; -} - -HRESULT -FrameworkView::OnSoftkeyboardHidden(IInputPane* aSender, - IInputPaneVisibilityEventArgs* aArgs) -{ - LogFunction(); - sKeyboardIsVisible = false; - memset(&sKeyboardRect, 0, sizeof(Rect)); - MetroUtils::FireObserver("metro_softkeyboard_hidden"); - aArgs->put_EnsuredFocusedElementInView(true); - return S_OK; -} - -HRESULT -FrameworkView::OnSoftkeyboardShown(IInputPane* aSender, - IInputPaneVisibilityEventArgs* aArgs) -{ - LogFunction(); - sKeyboardIsVisible = true; - aSender->get_OccludedRect(&sKeyboardRect); - MetroUtils::FireObserver("metro_softkeyboard_shown"); - aArgs->put_EnsuredFocusedElementInView(true); - return S_OK; -} - -HRESULT -FrameworkView::OnWindowSizeChanged(ICoreWindow* aSender, IWindowSizeChangedEventArgs* aArgs) -{ - LogFunction(); - UpdateWidgetSizeAndPosition(); - return S_OK; -} - -HRESULT -FrameworkView::OnWindowActivated(ICoreWindow* aSender, IWindowActivatedEventArgs* aArgs) -{ - LogFunction(); - if (!mWidget) { - return S_OK; - } - CoreWindowActivationState state; - aArgs->get_WindowActivationState(&state); - mWinActiveState = !(state == CoreWindowActivationState::CoreWindowActivationState_Deactivated); - SendActivationEvent(); - return S_OK; -} - -HRESULT -FrameworkView::OnLogicalDpiChanged(IInspectable* aSender) -{ - LogFunction(); - UpdateLogicalDPI(); - if (mWidget) { - mWidget->Invalidate(); - } - return S_OK; -} - -bool -FrameworkView::EnsureAutomationProviderCreated() -{ -#ifdef ACCESSIBILITY - if (!mWidget || mShuttingDown) - return false; - - if (mAutomationProvider) { - return true; - } - - Accessible *rootAccessible = mWidget->GetRootAccessible(); - if (rootAccessible) { - IInspectable* inspectable; - HRESULT hr; - AssertRetHRESULT(hr = UIABridge_CreateInstance(&inspectable), hr); // Addref - IUIABridge* bridge = nullptr; - inspectable->QueryInterface(IID_IUIABridge, (void**)&bridge); // Addref - if (bridge) { - bridge->Init(this, mWindow.Get(), (ULONG)rootAccessible); - mAutomationProvider = inspectable; - inspectable->Release(); - return true; - } - } -#endif - return false; -} - -HRESULT -FrameworkView::OnAutomationProviderRequested(ICoreWindow* aSender, - IAutomationProviderRequestedEventArgs* aArgs) -{ - LogFunction(); - if (!EnsureAutomationProviderCreated()) - return E_FAIL; - HRESULT hr = aArgs->put_AutomationProvider(mAutomationProvider.Get()); - if (FAILED(hr)) { - WinUtils::Log("put failed? %X", hr); - } - return S_OK; -} - -} } } diff --git a/widget/windows/winrt/FrameworkView.h b/widget/windows/winrt/FrameworkView.h deleted file mode 100644 index ad4e0ac74..000000000 --- a/widget/windows/winrt/FrameworkView.h +++ /dev/null @@ -1,205 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#pragma once - -#include "MetroWidget.h" -#include "MetroInput.h" -#include "gfxWindowsPlatform.h" -#include "nsDataHashtable.h" - -#include "mozwrlbase.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace mozilla { -namespace widget { -namespace winrt { - -class MetroApp; - -class FrameworkView : public Microsoft::WRL::RuntimeClass -{ - InspectableClass(L"FrameworkView", TrustLevel::BaseTrust) - - typedef mozilla::layers::LayerManager LayerManager; - - typedef ABI::Windows::Foundation::Rect Rect; - typedef ABI::Windows::UI::Core::IWindowSizeChangedEventArgs IWindowSizeChangedEventArgs; - typedef ABI::Windows::UI::Core::ICoreWindowEventArgs ICoreWindowEventArgs; - typedef ABI::Windows::UI::Core::IWindowActivatedEventArgs IWindowActivatedEventArgs; - typedef ABI::Windows::UI::Core::IAutomationProviderRequestedEventArgs IAutomationProviderRequestedEventArgs; - typedef ABI::Windows::UI::Core::ICoreWindow ICoreWindow; - typedef ABI::Windows::UI::Core::ICoreDispatcher ICoreDispatcher; - typedef ABI::Windows::UI::Core::IVisibilityChangedEventArgs IVisibilityChangedEventArgs; - typedef ABI::Windows::UI::ViewManagement::IInputPaneVisibilityEventArgs IInputPaneVisibilityEventArgs; - typedef ABI::Windows::UI::ViewManagement::IInputPane IInputPane; - typedef ABI::Windows::UI::ViewManagement::ApplicationViewState ApplicationViewState; - typedef ABI::Windows::UI::ApplicationSettings::ISettingsPane ISettingsPane; - typedef ABI::Windows::UI::ApplicationSettings::ISettingsPaneCommandsRequestedEventArgs ISettingsPaneCommandsRequestedEventArgs; - typedef ABI::Windows::UI::Popups::IUICommand IUICommand; - typedef ABI::Windows::ApplicationModel::Activation::ILaunchActivatedEventArgs ILaunchActivatedEventArgs; - typedef ABI::Windows::ApplicationModel::Activation::IActivatedEventArgs IActivatedEventArgs; - typedef ABI::Windows::ApplicationModel::Activation::ISearchActivatedEventArgs ISearchActivatedEventArgs; - typedef ABI::Windows::ApplicationModel::Activation::IFileActivatedEventArgs IFileActivatedEventArgs; - typedef ABI::Windows::ApplicationModel::Core::ICoreApplicationView ICoreApplicationView; - typedef ABI::Windows::ApplicationModel::DataTransfer::IDataTransferManager IDataTransferManager; - typedef ABI::Windows::ApplicationModel::DataTransfer::IDataRequestedEventArgs IDataRequestedEventArgs; - typedef ABI::Windows::ApplicationModel::Search::ISearchPane ISearchPane; - typedef ABI::Windows::ApplicationModel::Search::ISearchPaneQuerySubmittedEventArgs ISearchPaneQuerySubmittedEventArgs; - typedef ABI::Windows::Media::PlayTo::IPlayToManager IPlayToManager; - typedef ABI::Windows::Media::PlayTo::IPlayToSourceRequestedEventArgs IPlayToSourceRequestedEventArgs; - typedef ABI::Windows::Graphics::Printing::IPrintManager IPrintManager; - typedef ABI::Windows::Graphics::Printing::IPrintTaskRequestedEventArgs IPrintTaskRequestedEventArgs; - typedef ABI::Windows::Graphics::Printing::IPrintTaskSourceRequestedArgs IPrintTaskSourceRequestedArgs; - -public: - FrameworkView(MetroApp* aMetroApp); - - // IFrameworkView Methods - STDMETHODIMP Initialize(ICoreApplicationView* aAppView); - STDMETHODIMP SetWindow(ICoreWindow* aWindow); - STDMETHODIMP Load(HSTRING aEntryPoint); - STDMETHODIMP Run(); - STDMETHODIMP Uninitialize(); - - HRESULT ActivateView(); - - // Public apis for MetroWidget - float GetDPI() { return mDPI; } - ICoreWindow* GetCoreWindow() { return mWindow.Get(); } - void SetWidget(MetroWidget* aWidget); - MetroWidget* GetWidget() { return mWidget.Get(); } - void GetBounds(nsIntRect &aRect); - void SetCursor(ABI::Windows::UI::Core::CoreCursorType aCursorType, DWORD aCustomId = 0); - void ClearCursor(); - bool IsEnabled() const; - bool IsVisible() const; - - // Activation apis for nsIWinMetroUtils - static int GetPreviousExecutionState() { return sPreviousExecutionState; } - static void GetActivationURI(nsAString &aActivationURI) { - unsigned int length; - aActivationURI = WindowsGetStringRawBuffer(sActivationURI, &length); - } - - // Soft keyboard info for nsIWinMetroUtils - static bool IsKeyboardVisible() { return sKeyboardIsVisible; } - static ABI::Windows::Foundation::Rect KeyboardVisibleRect() { return sKeyboardRect; } - - // MetroApp apis - void SetupContracts(); - void Shutdown(); - - // MetroContracts settings panel enumerator entry - void AddSetting(ISettingsPaneCommandsRequestedEventArgs* aArgs, uint32_t aId, - Microsoft::WRL::Wrappers::HString& aSettingName); -protected: - // Event Handlers - HRESULT OnActivated(ICoreApplicationView* aApplicationView, - IActivatedEventArgs* aArgs); - HRESULT OnWindowVisibilityChanged(ICoreWindow* aCoreWindow, - IVisibilityChangedEventArgs* aArgs); - - HRESULT OnWindowSizeChanged(ICoreWindow* aSender, - IWindowSizeChangedEventArgs* aArgs); - HRESULT OnWindowActivated(ICoreWindow* aSender, - IWindowActivatedEventArgs* aArgs); - HRESULT OnLogicalDpiChanged(IInspectable* aSender); - - HRESULT OnAutomationProviderRequested(ICoreWindow* aSender, - IAutomationProviderRequestedEventArgs* aArgs); - - HRESULT OnSoftkeyboardHidden(IInputPane* aSender, - IInputPaneVisibilityEventArgs* aArgs); - HRESULT OnSoftkeyboardShown(IInputPane* aSender, - IInputPaneVisibilityEventArgs* aArgs); - - HRESULT OnDataShareRequested(IDataTransferManager*, IDataRequestedEventArgs* aArgs); - HRESULT OnSearchQuerySubmitted(ISearchPane* aPane, ISearchPaneQuerySubmittedEventArgs* aArgs); - HRESULT OnSettingsCommandsRequested(ISettingsPane* aPane, ISettingsPaneCommandsRequestedEventArgs* aArgs); - HRESULT OnPlayToSourceRequested(IPlayToManager* aPane, IPlayToSourceRequestedEventArgs* aArgs); - HRESULT OnSettingsCommandInvoked(IUICommand* aCommand); - HRESULT OnPrintTaskRequested(IPrintManager* aMgr, IPrintTaskRequestedEventArgs* aArgs); - HRESULT OnPrintTaskSourceRequested(IPrintTaskSourceRequestedArgs* aArgs); - -protected: - void SetDpi(float aDpi); - void UpdateWidgetSizeAndPosition(); - void PerformURILoad(Microsoft::WRL::Wrappers::HString& aString); - void PerformSearch(Microsoft::WRL::Wrappers::HString& aQuery); - void PerformURILoadOrSearch(Microsoft::WRL::Wrappers::HString& aString); - bool EnsureAutomationProviderCreated(); - void SearchActivated(Microsoft::WRL::ComPtr& aArgs, bool aStartup); - void FileActivated(Microsoft::WRL::ComPtr& aArgs, bool aStartup); - void LaunchActivated(Microsoft::WRL::ComPtr& aArgs, bool aStartup); - void ProcessActivationArgs(IActivatedEventArgs* aArgs, bool aStartup); - void UpdateForWindowSizeChange(); - void SendActivationEvent(); - void UpdateLogicalDPI(); - void FireViewStateObservers(); - void ProcessLaunchArguments(); - void UpdateBounds(); - - // Printing and preview - void CreatePrintControl(IPrintDocumentPackageTarget* aDocPackageTarget, - D2D1_PRINT_CONTROL_PROPERTIES* aPrintControlProperties); - HRESULT ClosePrintControl(); - void PrintPage(uint32_t aPageNumber, D2D1_RECT_F aImageableArea, - D2D1_SIZE_F aPageSize, IStream* aPagePrintTicketStream); - void AddEventHandlers(); - -private: - EventRegistrationToken mActivated; - EventRegistrationToken mWindowActivated; - EventRegistrationToken mWindowVisibilityChanged; - EventRegistrationToken mWindowClosed; - EventRegistrationToken mWindowSizeChanged; - EventRegistrationToken mSoftKeyboardHidden; - EventRegistrationToken mSoftKeyboardShown; - EventRegistrationToken mDisplayPropertiesChanged; - EventRegistrationToken mAutomationProviderRequested; - EventRegistrationToken mDataTransferRequested; - EventRegistrationToken mSearchQuerySubmitted; - EventRegistrationToken mPlayToRequested; - EventRegistrationToken mSettingsPane; - EventRegistrationToken mPrintManager; - -private: - nsIntRect mWindowBounds; // in device-pixel coordinates - float mDPI; - bool mShuttingDown; - nsAutoString mActivationCommandLine; - Microsoft::WRL::ComPtr mAutomationProvider; - //Microsoft::WRL::ComPtr mD2DPrintControl; - // Private critical section protects D2D device context for on-screen - // rendering from that for print/preview in the different thread. - //Microsoft::WRL::ComPtr mWicFactory; - Microsoft::WRL::ComPtr mMetroApp; - Microsoft::WRL::ComPtr mWindow; - Microsoft::WRL::ComPtr mWidget; - Microsoft::WRL::ComPtr mMetroInput; - bool mWinVisible; - bool mWinActiveState; - - static bool sKeyboardIsVisible; - static Rect sKeyboardRect; - static HSTRING sActivationURI; - static ABI::Windows::ApplicationModel::Activation::ApplicationExecutionState sPreviousExecutionState; -}; - -} } } diff --git a/widget/windows/winrt/Makefile.in b/widget/windows/winrt/Makefile.in deleted file mode 100644 index 60e54eb3e..000000000 --- a/widget/windows/winrt/Makefile.in +++ /dev/null @@ -1,19 +0,0 @@ -# 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/. - -MIDL_GENERATED_FILES = \ - UIABridge_i.c \ - UIABridge_p.c \ - dlldata.c \ - $(NULL) - -GARBAGE += $(MIDL_GENERATED_FILES) done_gen - -do_interfaces_gen: UIABridge.idl - $(MIDL) $(srcdir)/UIABridge.idl -I $(srcdir) - touch $@ - -export:: do_interfaces_gen - -include $(topsrcdir)/config/rules.mk diff --git a/widget/windows/winrt/MetroApp.cpp b/widget/windows/winrt/MetroApp.cpp deleted file mode 100644 index 6b445d484..000000000 --- a/widget/windows/winrt/MetroApp.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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 "MetroApp.h" -#include "MetroWidget.h" -#include "mozilla/IOInterposer.h" -#include "mozilla/widget/AudioSession.h" -#include "nsIRunnable.h" -#include "MetroUtils.h" -#include "MetroAppShell.h" -#include "nsICommandLineRunner.h" -#include "FrameworkView.h" -#include "nsAppDirectoryServiceDefs.h" -#include "GoannaProfiler.h" -#include - -using namespace ABI::Windows::ApplicationModel; -using namespace ABI::Windows::ApplicationModel::Core; -using namespace ABI::Windows::UI::Core; -using namespace ABI::Windows::System; -using namespace ABI::Windows::Foundation; -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; -using namespace mozilla::widget; - -// Metro specific XRE methods we call from here on an -// appropriate thread. -extern nsresult XRE_metroStartup(bool runXREMain); -extern void XRE_metroShutdown(); - -static const char* gGoannaThreadName = "GoannaMain"; - -#ifdef PR_LOGGING -extern PRLogModuleInfo* gWindowsLog; -#endif - -namespace mozilla { -namespace widget { -namespace winrt { - -ComPtr sFrameworkView; -ComPtr sMetroApp; -ComPtr sCoreApp; -bool MetroApp::sGoannaShuttingDown = false; - -//////////////////////////////////////////////////// -// IFrameworkViewSource impl. - -// Called after CoreApplication::Run(app) -HRESULT -MetroApp::CreateView(ABI::Windows::ApplicationModel::Core::IFrameworkView **aViewProvider) -{ - // This entry point is called on the metro main thread, but the thread won't - // be recognized as such until after Run() is called below. XPCOM has not - // gone through startup at this point. - - // Note that we create the view which creates our native window for us. The - // goanna widget gets created by goanna, and the two get hooked up later in - // MetroWidget::Create(). - - LogFunction(); - - sFrameworkView = Make(this); - sFrameworkView.Get()->AddRef(); - *aViewProvider = sFrameworkView.Get(); - return !sFrameworkView ? E_FAIL : S_OK; -} - -//////////////////////////////////////////////////// -// MetroApp impl. - -void -MetroApp::Run() -{ - LogThread(); - - // Name this thread for debugging and register it with the profiler - // and IOInterposer as the main goanna thread. - char aLocal; - PR_SetCurrentThreadName(gGoannaThreadName); - profiler_register_thread(gGoannaThreadName, &aLocal); - IOInterposer::RegisterCurrentThread(true); - - HRESULT hr; - hr = sCoreApp->add_Suspending(Callback<__FIEventHandler_1_Windows__CApplicationModel__CSuspendingEventArgs_t>( - this, &MetroApp::OnSuspending).Get(), &mSuspendEvent); - AssertHRESULT(hr); - - hr = sCoreApp->add_Resuming(Callback<__FIEventHandler_1_IInspectable_t>( - this, &MetroApp::OnResuming).Get(), &mResumeEvent); - AssertHRESULT(hr); - - WinUtils::Log("Calling XRE_metroStartup."); - nsresult rv = XRE_metroStartup(true); - WinUtils::Log("Exiting XRE_metroStartup."); - if (NS_FAILED(rv)) { - WinUtils::Log("XPCOM startup initialization failed, bailing. rv=%X", rv); - CoreExit(); - } -} - -// Free all xpcom related resources before calling the xre shutdown call. -// Must be called on the metro main thread. Currently called from appshell. -void -MetroApp::Shutdown() -{ - LogThread(); - - if (sCoreApp) { - sCoreApp->remove_Suspending(mSuspendEvent); - sCoreApp->remove_Resuming(mResumeEvent); - } - - if (sFrameworkView) { - sFrameworkView->Shutdown(); - } - - MetroApp::sGoannaShuttingDown = true; - - // Shut down xpcom - XRE_metroShutdown(); - - // Unhook this thread from the profiler - profiler_unregister_thread(); -} - -// Request a shutdown of the application -void -MetroApp::CoreExit() -{ - LogFunction(); - HRESULT hr; - ComPtr coreExit; - HStringReference className(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication); - hr = GetActivationFactory(className.Get(), coreExit.GetAddressOf()); - NS_ASSERTION(SUCCEEDED(hr), "Activation of ICoreApplicationExit"); - if (SUCCEEDED(hr)) { - coreExit->Exit(); - } -} - -void -MetroApp::ActivateBaseView() -{ - if (sFrameworkView) { - sFrameworkView->ActivateView(); - } -} - -/* - * TBD: when we support multiple widgets, we'll need a way to sync up the view - * created in CreateView with the widget goanna creates. Currently we only have - * one view (sFrameworkView) and one main widget. - */ -void -MetroApp::SetWidget(MetroWidget* aPtr) -{ - LogThread(); - - NS_ASSERTION(aPtr, "setting null base widget?"); - - // Both of these calls AddRef the ptr we pass in - aPtr->SetView(sFrameworkView.Get()); - sFrameworkView->SetWidget(aPtr); -} - -//////////////////////////////////////////////////// -// MetroApp events - -HRESULT -MetroApp::OnSuspending(IInspectable* aSender, ISuspendingEventArgs* aArgs) -{ - LogThread(); - PostSuspendResumeProcessNotification(true); - return S_OK; -} - -HRESULT -MetroApp::OnResuming(IInspectable* aSender, IInspectable* aArgs) -{ - LogThread(); - PostSuspendResumeProcessNotification(false); - return S_OK; -} - -HRESULT -MetroApp::OnAsyncTileCreated(ABI::Windows::Foundation::IAsyncOperation* aOperation, - AsyncStatus aStatus) -{ - WinUtils::Log("Async operation status: %d", aStatus); - MetroUtils::FireObserver("metro_on_async_tile_created"); - return S_OK; -} - -// static -void -MetroApp::PostSuspendResumeProcessNotification(const bool aIsSuspend) -{ - static bool isSuspend = false; - if (isSuspend == aIsSuspend) { - return; - } - isSuspend = aIsSuspend; - MetroUtils::FireObserver(aIsSuspend ? "suspend_process_notification" : - "resume_process_notification"); -} - -// static -void -MetroApp::PostSleepWakeNotification(const bool aIsSleep) -{ - static bool isSleep = false; - if (isSleep == aIsSleep) { - return; - } - isSleep = aIsSleep; - MetroUtils::FireObserver(aIsSleep ? "sleep_notification" : - "wake_notification"); -} - -} } } - - -static bool -IsBackgroundSessionClosedStartup() -{ - int argc; - LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc); - bool backgroundSessionClosed = argc > 1 && !wcsicmp(argv[1], L"-BackgroundSessionClosed"); - LocalFree(argv); - return backgroundSessionClosed; -} - -bool -XRE_MetroCoreApplicationRun() -{ - HRESULT hr; - LogThread(); - - using namespace mozilla::widget::winrt; - - sMetroApp = Make(); - - HStringReference className(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication); - hr = GetActivationFactory(className.Get(), sCoreApp.GetAddressOf()); - if (FAILED(hr)) { - LogHRESULT(hr); - return false; - } - - // Perform any cleanup for unclean shutdowns here, such as when the background session - // is closed via the appbar on the left when outside of Metro. Windows restarts the - // process solely for cleanup reasons. - if (IsBackgroundSessionClosedStartup() && SUCCEEDED(XRE_metroStartup(false))) { - - // Whether or not to use sessionstore depends on if the bak exists. Since host process - // shutdown isn't a crash we shouldn't restore sessionstore. - nsCOMPtr sessionBAK; - if (NS_FAILED(NS_GetSpecialDirectory("ProfDS", getter_AddRefs(sessionBAK)))) { - return false; - } - - sessionBAK->AppendNative(nsDependentCString("sessionstore.bak")); - bool exists; - if (NS_SUCCEEDED(sessionBAK->Exists(&exists)) && exists) { - sessionBAK->Remove(false); - } - return false; - } - - hr = sCoreApp->Run(sMetroApp.Get()); - - WinUtils::Log("Exiting CoreApplication::Run"); - - sCoreApp = nullptr; - sMetroApp = nullptr; - - return true; -} - diff --git a/widget/windows/winrt/MetroApp.h b/widget/windows/winrt/MetroApp.h deleted file mode 100644 index c9748dd53..000000000 --- a/widget/windows/winrt/MetroApp.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#pragma once - -#include "mozwrlbase.h" - -#include -#include -#include -#include -#include - -class MetroWidget; - -namespace mozilla { -namespace widget { -namespace winrt { - -class MetroApp : public Microsoft::WRL::RuntimeClass -{ - InspectableClass(L"MetroApp", TrustLevel::BaseTrust) - - typedef ABI::Windows::UI::Core::CoreDispatcherPriority CoreDispatcherPriority; - typedef ABI::Windows::ApplicationModel::Activation::LaunchActivatedEventArgs LaunchActivatedEventArgs; - typedef ABI::Windows::ApplicationModel::ISuspendingEventArgs ISuspendingEventArgs; - typedef ABI::Windows::ApplicationModel::Core::IFrameworkView IFrameworkView; - typedef ABI::Windows::ApplicationModel::Core::ICoreApplication ICoreApplication; - -public: - // IFrameworkViewSource - STDMETHODIMP CreateView(IFrameworkView **viewProvider); - - // ICoreApplication event - HRESULT OnSuspending(IInspectable* aSender, ISuspendingEventArgs* aArgs); - HRESULT OnResuming(IInspectable* aSender, IInspectable* aArgs); - - // nsIWinMetroUtils tile related async callbacks - HRESULT OnAsyncTileCreated(ABI::Windows::Foundation::IAsyncOperation* aOperation, AsyncStatus aStatus); - - void Run(); - void CoreExit(); - void Shutdown(); - void ActivateBaseView(); - - // Set when goanna enters xpcom shutdown. - static bool sGoannaShuttingDown; - - // Shared pointers between framework and widget - void SetWidget(MetroWidget* aPtr); - - static void PostSuspendResumeProcessNotification(bool aIsSuspend); - static void PostSleepWakeNotification(bool aIsSuspend); - -private: - EventRegistrationToken mSuspendEvent; - EventRegistrationToken mResumeEvent; -}; - -} } } diff --git a/widget/windows/winrt/MetroAppShell.cpp b/widget/windows/winrt/MetroAppShell.cpp deleted file mode 100644 index 9aa94e69f..000000000 --- a/widget/windows/winrt/MetroAppShell.cpp +++ /dev/null @@ -1,522 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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 "MetroAppShell.h" - -#include "mozilla/AutoRestore.h" -#include "mozilla/TimeStamp.h" -#include "mozilla/widget/AudioSession.h" -#include "mozilla/ipc/WindowsMessageLoop.h" - -#include "nsIObserverService.h" -#include "nsIAppStartup.h" -#include "nsToolkitCompsCID.h" -#include "nsIPowerManagerService.h" - -#include "nsXULAppAPI.h" -#include "nsServiceManagerUtils.h" -#include "WinUtils.h" -#include "nsWinMetroUtils.h" -#include "MetroUtils.h" -#include "MetroApp.h" -#include "FrameworkView.h" -#include "WakeLockListener.h" - -#include - -using namespace mozilla; -using namespace mozilla::widget; -using namespace mozilla::widget::winrt; -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; -using namespace ABI::Windows::UI::Core; -using namespace ABI::Windows::Foundation; - -// ProcessNextNativeEvent message wait timeout, see bug 907410. -#define MSG_WAIT_TIMEOUT 250 -// MetroInput will occasionally ask us to flush all input so that the dom is -// up to date. This is the maximum amount of time we'll agree to spend in -// NS_ProcessPendingEvents. -#define PURGE_MAX_TIMEOUT 50 - -namespace mozilla { -namespace widget { -namespace winrt { -extern ComPtr sMetroApp; -} } } - -namespace mozilla { -namespace widget { -// pulled from win32 app shell -extern UINT sAppShellGoannaMsgId; -} } - -static ComPtr sCoreStatic; -static bool sIsDispatching = false; -static bool sShouldPurgeThreadQueue = false; -static bool sBlockNativeEvents = false; -static TimeStamp sPurgeThreadQueueStart; - -MetroAppShell::~MetroAppShell() -{ - if (mEventWnd) { - SendMessage(mEventWnd, WM_CLOSE, 0, 0); - } -} - -nsresult -MetroAppShell::Init() -{ - LogFunction(); - - WNDCLASSW wc; - HINSTANCE module = GetModuleHandle(nullptr); - - mozilla::ipc::windows::InitUIThread(); - - const char16_t *const kWindowClass = L"nsAppShell:EventWindowClass"; - if (!GetClassInfoW(module, kWindowClass, &wc)) { - wc.style = 0; - wc.lpfnWndProc = EventWindowProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = module; - wc.hIcon = nullptr; - wc.hCursor = nullptr; - wc.hbrBackground = (HBRUSH) nullptr; - wc.lpszMenuName = (LPCWSTR) nullptr; - wc.lpszClassName = kWindowClass; - RegisterClassW(&wc); - } - - mEventWnd = CreateWindowW(kWindowClass, L"nsAppShell:EventWindow", - 0, 0, 0, 10, 10, nullptr, nullptr, module, nullptr); - NS_ENSURE_STATE(mEventWnd); - - nsresult rv; - nsCOMPtr observerService = - do_GetService("@mozilla.org/observer-service;1", &rv); - if (NS_SUCCEEDED(rv)) { - observerService->AddObserver(this, "dl-start", false); - observerService->AddObserver(this, "dl-done", false); - observerService->AddObserver(this, "dl-cancel", false); - observerService->AddObserver(this, "dl-failed", false); - } - - return nsBaseAppShell::Init(); -} - -HRESULT -SHCreateShellItemArrayFromShellItemDynamic(IShellItem *psi, REFIID riid, void **ppv) -{ - HMODULE shell32DLL = LoadLibraryW(L"shell32.dll"); - if (!shell32DLL) { - return E_FAIL; - } - - typedef BOOL (WINAPI* SHFn)(IShellItem *psi, REFIID riid, void **ppv); - - HRESULT hr = E_FAIL; - SHFn SHCreateShellItemArrayFromShellItemDynamicPtr = - (SHFn)GetProcAddress(shell32DLL, "SHCreateShellItemArrayFromShellItem"); - FreeLibrary(shell32DLL); - if (SHCreateShellItemArrayFromShellItemDynamicPtr) { - hr = SHCreateShellItemArrayFromShellItemDynamicPtr(psi, riid, ppv); - } - - FreeLibrary(shell32DLL); - return hr; -} - -HRESULT -WinLaunchDeferredMetroFirefox() -{ - // Create an instance of the Firefox Metro CEH which is used to launch the browser - const CLSID CLSID_FirefoxMetroDEH = {0x5100FEC1,0x212B, 0x4BF5 ,{0x9B,0xF8, 0x3E,0x65, 0x0F,0xD7,0x94,0xA3}}; - - nsRefPtr executeCommand; - HRESULT hr = CoCreateInstance(CLSID_FirefoxMetroDEH, - nullptr, - CLSCTX_LOCAL_SERVER, - IID_IExecuteCommand, - getter_AddRefs(executeCommand)); - if (FAILED(hr)) - return hr; - - // Get the currently running exe path - WCHAR exePath[MAX_PATH + 1] = { L'\0' }; - if (!::GetModuleFileNameW(0, exePath, MAX_PATH)) - return hr; - - // Convert the path to a long path since GetModuleFileNameW returns the path - // that was used to launch Firefox which is not necessarily a long path. - if (!::GetLongPathNameW(exePath, exePath, MAX_PATH)) - return hr; - - // Create an IShellItem for the current browser path - nsRefPtr shellItem; - hr = WinUtils::SHCreateItemFromParsingName(exePath, nullptr, IID_IShellItem, - getter_AddRefs(shellItem)); - if (FAILED(hr)) - return hr; - - // Convert to an IShellItemArray which is used for the path to launch - nsRefPtr shellItemArray; - hr = SHCreateShellItemArrayFromShellItemDynamic(shellItem, IID_IShellItemArray, getter_AddRefs(shellItemArray)); - if (FAILED(hr)) - return hr; - - // Set the path to launch and parameters needed - nsRefPtr selection; - hr = executeCommand->QueryInterface(IID_IObjectWithSelection, getter_AddRefs(selection)); - if (FAILED(hr)) - return hr; - hr = selection->SetSelection(shellItemArray); - if (FAILED(hr)) - return hr; - - if (nsWinMetroUtils::sUpdatePending) { - hr = executeCommand->SetParameters(L"--metro-update"); - } else { - hr = executeCommand->SetParameters(L"--metro-restart"); - } - if (FAILED(hr)) - return hr; - - // Run the default browser through the CEH - return executeCommand->Execute(); -} - -static WakeLockListener* -InitWakeLock() -{ - nsCOMPtr powerManagerService = - do_GetService(POWERMANAGERSERVICE_CONTRACTID); - if (powerManagerService) { - WakeLockListener* pLock = new WakeLockListener(); - powerManagerService->AddWakeLockListener(pLock); - return pLock; - } - else { - NS_WARNING("Failed to retrieve PowerManagerService, wakelocks will be broken!"); - } - return nullptr; -} - -static void -ShutdownWakeLock(WakeLockListener* aLock) -{ - if (!aLock) { - return; - } - nsCOMPtr powerManagerService = - do_GetService(POWERMANAGERSERVICE_CONTRACTID); - if (powerManagerService) { - powerManagerService->RemoveWakeLockListener(aLock); - } -} - -// Called by appstartup->run in xre, which is initiated by a call to -// XRE_metroStartup in MetroApp. This call is on the metro main thread. -NS_IMETHODIMP -MetroAppShell::Run(void) -{ - LogFunction(); - nsresult rv = NS_OK; - - switch(XRE_GetProcessType()) { - case GoannaProcessType_Content: - case GoannaProcessType_IPDLUnitTest: - mozilla::widget::StartAudioSession(); - rv = nsBaseAppShell::Run(); - mozilla::widget::StopAudioSession(); - break; - case GoannaProcessType_Plugin: - NS_WARNING("We don't support plugins currently."); - // Just exit - rv = NS_ERROR_NOT_IMPLEMENTED; - break; - case GoannaProcessType_Default: { - { - nsRefPtr wakeLock = InitWakeLock(); - mozilla::widget::StartAudioSession(); - sMetroApp->ActivateBaseView(); - rv = nsBaseAppShell::Run(); - mozilla::widget::StopAudioSession(); - ShutdownWakeLock(wakeLock); - } - - nsCOMPtr appStartup (do_GetService(NS_APPSTARTUP_CONTRACTID)); - bool restartingInMetro = false, restartingInDesktop = false; - - if (!appStartup || NS_FAILED(appStartup->GetRestarting(&restartingInDesktop))) { - WinUtils::Log("appStartup->GetRestarting() unsuccessful"); - } - - if (appStartup && NS_SUCCEEDED(appStartup->GetRestartingTouchEnvironment(&restartingInMetro)) && - restartingInMetro) { - restartingInDesktop = false; - } - - // This calls XRE_metroShutdown() in xre. Shuts down goanna, including - // releasing the profile, and destroys MessagePump. - sMetroApp->Shutdown(); - - // Handle update restart or browser switch requests - if (restartingInDesktop) { - WinUtils::Log("Relaunching desktop browser"); - // We can't call into the ceh to do this. Microsoft prevents switching to - // desktop unless we go through shell execute. - SHELLEXECUTEINFOW sinfo; - memset(&sinfo, 0, sizeof(SHELLEXECUTEINFOW)); - sinfo.cbSize = sizeof(SHELLEXECUTEINFOW); - // Per microsoft's metro style enabled desktop browser documentation - // SEE_MASK_FLAG_LOG_USAGE is needed if we want to change from immersive - // mode to desktop mode. - sinfo.fMask = SEE_MASK_FLAG_LOG_USAGE; - // The ceh will filter out this fake target. - sinfo.lpFile = L"http://-desktop/"; - sinfo.lpVerb = L"open"; - sinfo.lpParameters = L"--desktop-restart"; - sinfo.nShow = SW_SHOWNORMAL; - ShellExecuteEx(&sinfo); - } else if (restartingInMetro) { - HRESULT hresult = WinLaunchDeferredMetroFirefox(); - WinUtils::Log("Relaunching metro browser (hr=%X)", hresult); - } - - // This will free the real main thread in CoreApplication::Run() - // once winrt cleans up this thread. - sMetroApp->CoreExit(); - } - break; - } - - return rv; -} - -// Called in certain cases where we have async input events in the thread -// queue and need to make sure they get dispatched before the stack unwinds. -void // static -MetroAppShell::MarkEventQueueForPurge() -{ - sShouldPurgeThreadQueue = true; - - // If we're dispatching native events, wait until the dispatcher is - // off the stack. - if (sIsDispatching) { - return; - } - - // Safe to process pending events now - DispatchAllGoannaEvents(); -} - -// Notification from MetroInput that all events it wanted delivered -// have been dispatched. It is safe to start processing windowing -// events. -void // static -MetroAppShell::InputEventsDispatched() -{ - sBlockNativeEvents = false; -} - -// static -void -MetroAppShell::DispatchAllGoannaEvents() -{ - // Only do this if requested and when we're not shutting down - if (!sShouldPurgeThreadQueue || MetroApp::sGoannaShuttingDown) { - return; - } - - NS_ASSERTION(NS_IsMainThread(), "DispatchAllGoannaEvents should be called on the main thread"); - - sShouldPurgeThreadQueue = false; - sPurgeThreadQueueStart = TimeStamp::Now(); - - sBlockNativeEvents = true; - nsIThread *thread = NS_GetCurrentThread(); - NS_ProcessPendingEvents(thread, PURGE_MAX_TIMEOUT); - sBlockNativeEvents = false; -} - -static void -ProcessNativeEvents(CoreProcessEventsOption eventOption) -{ - HRESULT hr; - if (!sCoreStatic) { - hr = GetActivationFactory(HStringReference(L"Windows.UI.Core.CoreWindow").Get(), sCoreStatic.GetAddressOf()); - NS_ASSERTION(SUCCEEDED(hr), "GetActivationFactory failed?"); - AssertHRESULT(hr); - } - - ComPtr window; - AssertHRESULT(sCoreStatic->GetForCurrentThread(window.GetAddressOf())); - ComPtr dispatcher; - hr = window->get_Dispatcher(&dispatcher); - NS_ASSERTION(SUCCEEDED(hr), "get_Dispatcher failed?"); - AssertHRESULT(hr); - dispatcher->ProcessEvents(eventOption); -} - -// static -bool -MetroAppShell::ProcessOneNativeEventIfPresent() -{ - if (sIsDispatching) { - // Calling into ProcessNativeEvents is harmless, but won't actually process any - // native events. So we log here so we can spot this and get a handle on the - // corner cases where this can happen. - WinUtils::Log("WARNING: Reentrant call into process events detected, returning early."); - return false; - } - - { - AutoRestore dispatching(sIsDispatching); - sIsDispatching = true; - ProcessNativeEvents(CoreProcessEventsOption::CoreProcessEventsOption_ProcessOneIfPresent); - } - - DispatchAllGoannaEvents(); - - return !!HIWORD(::GetQueueStatus(MOZ_QS_ALLEVENT)); -} - -bool -MetroAppShell::ProcessNextNativeEvent(bool mayWait) -{ - // NS_ProcessPendingEvents will process thread events *and* call - // nsBaseAppShell::OnProcessNextEvent to process native events. However - // we do not want native events getting dispatched while we are trying - // to dispatch pending input in DispatchAllGoannaEvents since a native - // event may be a UIA Automation call coming in to check focus. - if (sBlockNativeEvents) { - if ((TimeStamp::Now() - sPurgeThreadQueueStart).ToMilliseconds() - < PURGE_MAX_TIMEOUT) { - return false; - } - sBlockNativeEvents = false; - } - - if (ProcessOneNativeEventIfPresent()) { - return true; - } - if (mayWait) { - DWORD result = ::MsgWaitForMultipleObjectsEx(0, nullptr, MSG_WAIT_TIMEOUT, - MOZ_QS_ALLEVENT, - MWMO_INPUTAVAILABLE|MWMO_ALERTABLE); - NS_WARN_IF_FALSE(result != WAIT_FAILED, "Wait failed"); - } - return ProcessOneNativeEventIfPresent(); -} - -void -MetroAppShell::NativeCallback() -{ - NS_ASSERTION(NS_IsMainThread(), "Native callbacks must be on the metro main thread"); - - // We shouldn't process native events during xpcom shutdown - this can - // trigger unexpected xpcom event dispatching for the main thread when - // the thread manager is in the process of shutting down non-main threads, - // resulting in shutdown hangs. - if (MetroApp::sGoannaShuttingDown) { - return; - } - - NativeEventCallback(); -} - -// static -LRESULT CALLBACK -MetroAppShell::EventWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - if (uMsg == sAppShellGoannaMsgId) { - MetroAppShell *as = reinterpret_cast(lParam); - as->NativeCallback(); - NS_RELEASE(as); - return TRUE; - } - return DefWindowProc(hwnd, uMsg, wParam, lParam); -} - -void -MetroAppShell::ScheduleNativeEventCallback() -{ - NS_ADDREF_THIS(); - PostMessage(mEventWnd, sAppShellGoannaMsgId, 0, reinterpret_cast(this)); -} - -void -MetroAppShell::DoProcessMoreGoannaEvents() -{ - ScheduleNativeEventCallback(); -} - -static HANDLE -PowerCreateRequestDyn(REASON_CONTEXT *context) -{ - typedef HANDLE (WINAPI * PowerCreateRequestPtr)(REASON_CONTEXT *context); - static HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll"); - static PowerCreateRequestPtr powerCreateRequest = - (PowerCreateRequestPtr)GetProcAddress(kernel32, "PowerCreateRequest"); - if (!powerCreateRequest) - return INVALID_HANDLE_VALUE; - return powerCreateRequest(context); -} - -static BOOL -PowerClearRequestDyn(HANDLE powerRequest, POWER_REQUEST_TYPE requestType) -{ - typedef BOOL (WINAPI * PowerClearRequestPtr)(HANDLE powerRequest, POWER_REQUEST_TYPE requestType); - static HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll"); - static PowerClearRequestPtr powerClearRequest = - (PowerClearRequestPtr)GetProcAddress(kernel32, "PowerClearRequest"); - if (!powerClearRequest) - return FALSE; - return powerClearRequest(powerRequest, requestType); -} - -static BOOL -PowerSetRequestDyn(HANDLE powerRequest, POWER_REQUEST_TYPE requestType) -{ - typedef BOOL (WINAPI * PowerSetRequestPtr)(HANDLE powerRequest, POWER_REQUEST_TYPE requestType); - static HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll"); - static PowerSetRequestPtr powerSetRequest = - (PowerSetRequestPtr)GetProcAddress(kernel32, "PowerSetRequest"); - if (!powerSetRequest) - return FALSE; - return powerSetRequest(powerRequest, requestType); -} - -NS_IMETHODIMP -MetroAppShell::Observe(nsISupports *subject, const char *topic, - const char16_t *data) -{ - NS_ENSURE_ARG_POINTER(topic); - if (!strcmp(topic, "dl-start")) { - if (mPowerRequestCount++ == 0) { - WinUtils::Log("Download started - Disallowing suspend"); - REASON_CONTEXT context; - context.Version = POWER_REQUEST_CONTEXT_VERSION; - context.Flags = POWER_REQUEST_CONTEXT_SIMPLE_STRING; - context.Reason.SimpleReasonString = L"downloading"; - mPowerRequest.own(PowerCreateRequestDyn(&context)); - PowerSetRequestDyn(mPowerRequest, PowerRequestExecutionRequired); - } - return NS_OK; - } else if (!strcmp(topic, "dl-done") || - !strcmp(topic, "dl-cancel") || - !strcmp(topic, "dl-failed")) { - if (--mPowerRequestCount == 0 && mPowerRequest) { - WinUtils::Log("All downloads ended - Allowing suspend"); - PowerClearRequestDyn(mPowerRequest, PowerRequestExecutionRequired); - mPowerRequest.reset(); - } - return NS_OK; - } - - return nsBaseAppShell::Observe(subject, topic, data); -} diff --git a/widget/windows/winrt/MetroAppShell.h b/widget/windows/winrt/MetroAppShell.h deleted file mode 100644 index 3abcfdd87..000000000 --- a/widget/windows/winrt/MetroAppShell.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#pragma once - -#include "nsBaseAppShell.h" -#include -#include "nsWindowsHelpers.h" -#include "nsIObserver.h" - -class MetroAppShell : public nsBaseAppShell -{ -public: - NS_DECL_NSIOBSERVER - - MetroAppShell() : - mEventWnd(nullptr), - mPowerRequestCount(0) - { - } - - nsresult Init(); - void DoProcessMoreGoannaEvents(); - void NativeCallback(); - - static LRESULT CALLBACK EventWindowProc(HWND, UINT, WPARAM, LPARAM); - static bool ProcessOneNativeEventIfPresent(); - static void MarkEventQueueForPurge(); - static void InputEventsDispatched(); - -protected: - NS_IMETHOD Run(); - - virtual void ScheduleNativeEventCallback(); - virtual bool ProcessNextNativeEvent(bool mayWait); - static void DispatchAllGoannaEvents(); - virtual ~MetroAppShell(); - - HWND mEventWnd; - nsAutoHandle mPowerRequest; - ULONG mPowerRequestCount; -}; diff --git a/widget/windows/winrt/MetroContracts.cpp b/widget/windows/winrt/MetroContracts.cpp deleted file mode 100644 index 7bb04e431..000000000 --- a/widget/windows/winrt/MetroContracts.cpp +++ /dev/null @@ -1,576 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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 "FrameworkView.h" -#include "MetroUtils.h" -#include "nsICommandLineRunner.h" -#include "nsNetUtil.h" -#include "nsIDOMChromeWindow.h" -#include "nsIURI.h" -#include "nsPrintfCString.h" -#include "mozilla/Services.h" -#include -#include -#include -#include -#include -#include -#include "MetroUIUtils.h" -#include "nsIStringBundle.h" - -using namespace mozilla; -using namespace ABI::Windows::Foundation; -using namespace ABI::Windows::Foundation::Collections; -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; - -// Play to contract -using namespace ABI::Windows::Media::PlayTo; - -// Activation contracts -using namespace ABI::Windows::ApplicationModel::Activation; -using namespace ABI::Windows::ApplicationModel::DataTransfer; -using namespace ABI::Windows::ApplicationModel::Search; - -// Settings contract -using namespace ABI::Windows::UI::ApplicationSettings; -using namespace ABI::Windows::UI::Popups; - -// Print contract -using namespace ABI::Windows::Graphics::Printing; - -namespace mozilla { -namespace widget { -namespace winrt { - -extern nsTArray* sSettingsArray; - -void -FrameworkView::SearchActivated(ComPtr& aArgs, bool aStartup) -{ - if (!aArgs) - return; - - HString data; - AssertHRESULT(aArgs->get_QueryText(data.GetAddressOf())); - if (WindowsIsStringEmpty(data.Get())) - return; - - unsigned int length; - WinUtils::LogW(L"SearchActivated text=%s", data.GetRawBuffer(&length)); - if (aStartup) { - WindowsDuplicateString(data.Get(), &sActivationURI); - } else { - PerformURILoadOrSearch(data); - } -} - -void -FrameworkView::FileActivated(ComPtr& aArgs, bool aStartup) -{ - if (!aArgs) - return; - - ComPtr> list; - AssertHRESULT(aArgs->get_Files(list.GetAddressOf())); - ComPtr item; - AssertHRESULT(list->GetAt(0, item.GetAddressOf())); - HString filePath; - AssertHRESULT(item->get_Path(filePath.GetAddressOf())); - - if (aStartup) { - WindowsDuplicateString(filePath.Get(), &sActivationURI); - } else { - PerformURILoad(filePath); - } -} - -void -FrameworkView::LaunchActivated(ComPtr& aArgs, bool aStartup) -{ - if (!aArgs) - return; - HString data; - AssertHRESULT(aArgs->get_Arguments(data.GetAddressOf())); - if (WindowsIsStringEmpty(data.Get())) - return; - - // If we're being launched from a secondary tile then we have a 2nd command line param of --url - // and a third of the secondary tile. We want it in sActivationURI so that browser.js will - // load it in without showing the start UI. - int argc; - unsigned int length; - LPWSTR* argv = CommandLineToArgvW(data.GetRawBuffer(&length), &argc); - if (aStartup && argc == 2 && - (!wcsicmp(argv[0], L"-url") || - !wcsicmp(argv[0], L"--url") || - !wcsicmp(argv[0], L"/url"))) { - WindowsCreateString(argv[1], wcslen(argv[1]), &sActivationURI); - } else { - // Some other command line or this is not a startup. - // If it is startup we process it later when XPCOM is initialilzed. - mActivationCommandLine = data.GetRawBuffer(&length); - if (!aStartup) { - ProcessLaunchArguments(); - } - } -} - -void -FrameworkView::ProcessLaunchArguments() -{ - if (!mActivationCommandLine.Length()) - return; - - int argc; - LPWSTR* argv = CommandLineToArgvW(mActivationCommandLine.BeginReading(), &argc); - nsCOMPtr cmdLine = - (do_CreateInstance("@mozilla.org/toolkit/command-line;1")); - if (!cmdLine) { - NS_WARNING("Unable to instantiate command line runner."); - return; - } - - LPSTR *argvUTF8 = new LPSTR[argc]; - for (int i = 0; i < argc; ++i) { - NS_ConvertUTF16toUTF8 arg(argv[i]); - argvUTF8[i] = new char[arg.Length() + 1]; - strcpy(argvUTF8[i], const_cast(arg.BeginReading())); - WinUtils::LogW(L"Launch arg[%d]: '%s'", i, argv[i]); - } - - nsresult rv = cmdLine->Init(argc, - argvUTF8, - nullptr, - nsICommandLine::STATE_REMOTE_EXPLICIT); - if (NS_SUCCEEDED(rv)) { - cmdLine->Run(); - } else { - NS_WARNING("cmdLine->Init failed."); - } - - for (int i = 0; i < argc; ++i) { - delete[] argvUTF8[i]; - } - delete[] argvUTF8; -} - -void -FrameworkView::ProcessActivationArgs(IActivatedEventArgs* aArgs, bool aStartup) -{ - ActivationKind kind; - if (!aArgs || FAILED(aArgs->get_Kind(&kind))) - return; - ComPtr args(aArgs); - if (kind == ActivationKind::ActivationKind_Protocol) { - WinUtils::Log("Activation argument kind: Protocol"); - ComPtr protoArgs; - AssertHRESULT(args.As(&protoArgs)); - ComPtr uri; - AssertHRESULT(protoArgs->get_Uri(uri.GetAddressOf())); - if (!uri) - return; - - HString data; - AssertHRESULT(uri->get_AbsoluteUri(data.GetAddressOf())); - if (WindowsIsStringEmpty(data.Get())) - return; - - if (aStartup) { - WindowsDuplicateString(data.Get(), &sActivationURI); - } else { - PerformURILoad(data); - } - } else if (kind == ActivationKind::ActivationKind_Search) { - WinUtils::Log("Activation argument kind: Search"); - ComPtr searchArgs; - args.As(&searchArgs); - SearchActivated(searchArgs, aStartup); - } else if (kind == ActivationKind::ActivationKind_File) { - WinUtils::Log("Activation argument kind: File"); - ComPtr fileArgs; - args.As(&fileArgs); - FileActivated(fileArgs, aStartup); - } else if (kind == ActivationKind::ActivationKind_Launch) { - WinUtils::Log("Activation argument kind: Launch"); - ComPtr launchArgs; - args.As(&launchArgs); - LaunchActivated(launchArgs, aStartup); - } -} - -void -FrameworkView::SetupContracts() -{ - LogFunction(); - HRESULT hr; - - // Add support for the share charm to indicate that we share data to other apps - ComPtr transStatics; - hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_DataTransfer_DataTransferManager).Get(), - transStatics.GetAddressOf()); - AssertHRESULT(hr); - ComPtr trans; - AssertHRESULT(transStatics->GetForCurrentView(trans.GetAddressOf())); - trans->add_DataRequested(Callback<__FITypedEventHandler_2_Windows__CApplicationModel__CDataTransfer__CDataTransferManager_Windows__CApplicationModel__CDataTransfer__CDataRequestedEventArgs_t>( - this, &FrameworkView::OnDataShareRequested).Get(), &mDataTransferRequested); - - // Add support for the search charm to indicate that you can search using our app. - ComPtr searchStatics; - hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_Search_SearchPane).Get(), - searchStatics.GetAddressOf()); - AssertHRESULT(hr); - ComPtr searchPane; - AssertHRESULT(searchStatics->GetForCurrentView(searchPane.GetAddressOf())); - searchPane->add_QuerySubmitted(Callback<__FITypedEventHandler_2_Windows__CApplicationModel__CSearch__CSearchPane_Windows__CApplicationModel__CSearch__CSearchPaneQuerySubmittedEventArgs_t>( - this, &FrameworkView::OnSearchQuerySubmitted).Get(), &mSearchQuerySubmitted); - - // Add support for the devices play to charm - ComPtr playToStatics; - hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Media_PlayTo_PlayToManager).Get(), - playToStatics.GetAddressOf()); - AssertHRESULT(hr); - ComPtr playTo; - AssertHRESULT(playToStatics->GetForCurrentView(playTo.GetAddressOf())); - playTo->add_SourceRequested(Callback<__FITypedEventHandler_2_Windows__CMedia__CPlayTo__CPlayToManager_Windows__CMedia__CPlayTo__CPlayToSourceRequestedEventArgs_t>( - this, &FrameworkView::OnPlayToSourceRequested).Get(), &mPlayToRequested); - - // Add support for the settings charm - ComPtr settingsPaneStatics; - hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_ApplicationSettings_SettingsPane).Get(), - settingsPaneStatics.GetAddressOf()); - AssertHRESULT(hr); - ComPtr settingsPane; - AssertHRESULT(settingsPaneStatics->GetForCurrentView(settingsPane.GetAddressOf())); - settingsPane->add_CommandsRequested(Callback<__FITypedEventHandler_2_Windows__CUI__CApplicationSettings__CSettingsPane_Windows__CUI__CApplicationSettings__CSettingsPaneCommandsRequestedEventArgs_t>( - this, &FrameworkView::OnSettingsCommandsRequested).Get(), &mSettingsPane); - - // Add support for the settings print charm - ComPtr printStatics; - hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Printing_PrintManager).Get(), - printStatics.GetAddressOf()); - AssertHRESULT(hr); - ComPtr printManager; - AssertHRESULT(printStatics->GetForCurrentView(printManager.GetAddressOf())); - printManager->add_PrintTaskRequested(Callback<__FITypedEventHandler_2_Windows__CGraphics__CPrinting__CPrintManager_Windows__CGraphics__CPrinting__CPrintTaskRequestedEventArgs_t>( - this, &FrameworkView::OnPrintTaskRequested).Get(), &mPrintManager); -} - -void -FrameworkView::PerformURILoad(HString& aURI) -{ - LogFunction(); - - unsigned int length; - WinUtils::LogW(L"PerformURILoad uri=%s", aURI.GetRawBuffer(&length)); - - nsCOMPtr cmdLine = - (do_CreateInstance("@mozilla.org/toolkit/command-line;1")); - if (!cmdLine) { - NS_WARNING("Unable to instantiate command line runner."); - return; - } - - nsAutoCString utf8data(NS_ConvertUTF16toUTF8(aURI.GetRawBuffer(&length))); - - // NB: The first argument gets stripped by nsICommandLineRunner::Init, - // so it doesn't matter what we pass as the first argument, but we - // have to pass something. - const char *argv[] = { "", // This argument gets stripped - "-url", - utf8data.BeginReading() }; - nsresult rv = cmdLine->Init(ArrayLength(argv), - const_cast(argv), nullptr, - nsICommandLine::STATE_REMOTE_EXPLICIT); - if (NS_FAILED(rv)) { - NS_WARNING("cmdLine->Init failed."); - return; - } - cmdLine->Run(); -} - -void -FrameworkView::PerformSearch(HString& aQuery) -{ - LogFunction(); - - nsCOMPtr cmdLine = - (do_CreateInstance("@mozilla.org/toolkit/command-line;1")); - if (!cmdLine) { - NS_WARNING("Unable to instantiate command line runner."); - return; - } - - nsAutoCString parameter; - parameter.Append('"'); - unsigned int length; - parameter.Append(NS_ConvertUTF16toUTF8(aQuery.GetRawBuffer(&length))); - parameter.Append('"'); - - // NB: The first argument gets stripped by nsICommandLineRunner::Init, - // so it doesn't matter what we pass as the first argument, but we - // have to pass something. - const char *argv[] = { "", // This argument gets stripped - "-search", - parameter.BeginReading() }; - nsresult rv = cmdLine->Init(ArrayLength(argv), - const_cast(argv), nullptr, - nsICommandLine::STATE_REMOTE_EXPLICIT); - if (NS_FAILED(rv)) { - NS_WARNING("cmdLine->Init failed."); - return; - } - cmdLine->Run(); -} - -void -FrameworkView::PerformURILoadOrSearch(HString& aString) -{ - LogFunction(); - - if (WindowsIsStringEmpty(aString.Get())) { - WinUtils::Log("Emptry string passed to PerformURILoadOrSearch"); - return; - } - - // If we have a URI then devert to load the URI directly - ComPtr uri; - MetroUtils::CreateUri(aString.Get(), uri); - if (uri) { - PerformURILoad(aString); - } else { - PerformSearch(aString); - } -} - -HRESULT -FrameworkView::OnDataShareRequested(IDataTransferManager* aDTM, - IDataRequestedEventArgs* aArg) -{ - // Only share pages that contain a title and a URI - nsCOMPtr metroUIUtils = do_CreateInstance("@mozilla.org/metro-ui-utils;1"); - if (!metroUIUtils) - return E_FAIL; - - nsString url, title; - nsresult rv = metroUIUtils->GetCurrentPageURI(url); - nsresult rv2 = metroUIUtils->GetCurrentPageTitle(title); - if (NS_FAILED(rv) || NS_FAILED(rv2)) { - return E_FAIL; - } - - // Get the package to share - HRESULT hr; - ComPtr request; - AssertRetHRESULT(hr = aArg->get_Request(request.GetAddressOf()), hr); - ComPtr dataPackage; - AssertRetHRESULT(hr = request->get_Data(dataPackage.GetAddressOf()), hr); - ComPtr props; - AssertRetHRESULT(hr = dataPackage->get_Properties(props.GetAddressOf()), hr); - - // Only add a URI to the package when there is no selected content. - // This is because most programs treat URIs as highest priority to generate - // their own preview, but we only want the selected content to show up. - bool hasSelectedContent = false; - metroUIUtils->GetHasSelectedContent(&hasSelectedContent); - if (!hasSelectedContent) { - ComPtr uri; - AssertRetHRESULT(hr = MetroUtils::CreateUri(HStringReference(url.BeginReading()).Get(), uri), hr); - - // If there is no selection, then we don't support sharing for sites that - // are not HTTP, HTTPS, FTP, and FILE. - HString schemeHString; - uri->get_SchemeName(schemeHString.GetAddressOf()); - unsigned int length; - LPCWSTR scheme = schemeHString.GetRawBuffer(&length); - if (!scheme || wcscmp(scheme, L"http") && wcscmp(scheme, L"https") && - wcscmp(scheme, L"ftp") && wcscmp(scheme, L"file")) { - return S_OK; - } - - AssertRetHRESULT(hr = dataPackage->SetUri(uri.Get()), hr); - } - - // Add whatever content metroUIUtils wants us to for the text sharing - nsString shareText; - if (NS_SUCCEEDED(metroUIUtils->GetShareText(shareText)) && shareText.Length()) { - AssertRetHRESULT(hr = dataPackage->SetText(HStringReference(shareText.BeginReading()).Get()) ,hr); - } - - // Add whatever content metroUIUtils wants us to for the HTML sharing - nsString shareHTML; - if (NS_SUCCEEDED(metroUIUtils->GetShareHTML(shareHTML)) && shareHTML.Length()) { - // The sharing format needs some special headers, so pass it through Windows - ComPtr htmlFormatHelper; - hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_DataTransfer_HtmlFormatHelper).Get(), - htmlFormatHelper.GetAddressOf()); - AssertRetHRESULT(hr, hr); - HSTRING fixedHTML; - htmlFormatHelper->CreateHtmlFormat(HStringReference(shareHTML.BeginReading()).Get(), &fixedHTML); - - // And now add the fixed HTML to the data package - AssertRetHRESULT(hr = dataPackage->SetHtmlFormat(fixedHTML), hr); - } - - // Obtain the brand name - nsCOMPtr bundleService = - do_GetService(NS_STRINGBUNDLE_CONTRACTID); - NS_ENSURE_TRUE(bundleService, E_FAIL); - nsCOMPtr brandBundle; - nsString brandName; - bundleService->CreateBundle("chrome://branding/locale/brand.properties", - getter_AddRefs(brandBundle)); - NS_ENSURE_TRUE(brandBundle, E_FAIL); - if(brandBundle) { - brandBundle->GetStringFromName(MOZ_UTF16("brandFullName"), - getter_Copies(brandName)); - } - - // Set these properties at the end. Otherwise users can get a - // "There was a problem with the data package" error when there - // is simply nothing to share. - props->put_ApplicationName(HStringReference(brandName.BeginReading()).Get()); - if (title.Length()) { - props->put_Title(HStringReference(title.BeginReading()).Get()); - } else { - props->put_Title(HStringReference(brandName.BeginReading()).Get()); - } - props->put_Description(HStringReference(url.BeginReading()).Get()); - - return S_OK; -} - -HRESULT -FrameworkView::OnSearchQuerySubmitted(ISearchPane* aPane, - ISearchPaneQuerySubmittedEventArgs* aArgs) -{ - LogFunction(); - HString aQuery; - aArgs->get_QueryText(aQuery.GetAddressOf()); - PerformURILoadOrSearch(aQuery); - return S_OK; -} - -HRESULT -FrameworkView::OnSettingsCommandInvoked(IUICommand* aCommand) -{ - LogFunction(); - HRESULT hr; - uint32_t id; - ComPtr prop; - AssertRetHRESULT(hr = aCommand->get_Id((IInspectable**)prop.GetAddressOf()), hr); - AssertRetHRESULT(hr = prop->GetUInt32(&id), hr); - - nsCOMPtr obs = mozilla::services::GetObserverService(); - if (obs) { - NS_ConvertASCIItoUTF16 idStr(nsPrintfCString("%lu", id)); - obs->NotifyObservers(nullptr, "metro-settings-entry-selected", idStr.BeginReading()); - } - - return S_OK; -} - -void -FrameworkView::AddSetting(ISettingsPaneCommandsRequestedEventArgs* aArgs, - uint32_t aId, HString& aSettingName) -{ - HRESULT hr; - - ComPtr request; - AssertHRESULT(aArgs->get_Request(request.GetAddressOf())); - - // ApplicationCommands - vector that holds SettingsCommand to be invoked - ComPtr> list; - AssertHRESULT(request->get_ApplicationCommands(list.GetAddressOf())); - - ComPtr command; - ComPtr factory; - hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_ApplicationSettings_SettingsCommand).Get(), - factory.GetAddressOf()); - AssertHRESULT(hr); - - // Create the IInspectable string property that identifies this command - ComPtr prop; - ComPtr propStatics; - hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Foundation_PropertyValue).Get(), - propStatics.GetAddressOf()); - AssertHRESULT(hr); - hr = propStatics->CreateUInt32(aId, prop.GetAddressOf()); - AssertHRESULT(hr); - - // Create the command - hr = factory->CreateSettingsCommand(prop.Get(), aSettingName.Get(), - Callback( - this, &FrameworkView::OnSettingsCommandInvoked).Get(), command.GetAddressOf()); - AssertHRESULT(hr); - - // Add it to the list - hr = list->Append(command.Get()); - AssertHRESULT(hr); -} - -HRESULT -FrameworkView::OnSettingsCommandsRequested(ISettingsPane* aPane, - ISettingsPaneCommandsRequestedEventArgs* aArgs) -{ - if (!sSettingsArray) - return E_FAIL; - if (!sSettingsArray->Length()) - return S_OK; - for (uint32_t i = 0; i < sSettingsArray->Length(); i++) { - HString label; - label.Set(sSettingsArray->ElementAt(i).BeginReading()); - AddSetting(aArgs, i, label); - } - return S_OK; -} - -HRESULT -FrameworkView::OnPlayToSourceRequested(IPlayToManager* aPlayToManager, - IPlayToSourceRequestedEventArgs* aArgs) -{ - // TODO: Implement PlayTo, find the element on the page and then do something similar to this: - // PlayToReceiver::Dispatcher.Helper.BeginInvoke( - // mMediaElement = ref new Windows::UI::Xaml::Controls::MediaElement(); - // mMediaElement->Source = ref new Uri("http://www.youtube.com/watch?v=2U0NFgoNI7s"); - // aArgs->SourceRequest->SetSource(mMediaElement->PlayToSource); - return S_OK; -} - -HRESULT -FrameworkView::OnPrintTaskSourceRequested(IPrintTaskSourceRequestedArgs* aArgs) -{ - return S_OK; -} - -HRESULT -FrameworkView::OnPrintTaskRequested(IPrintManager* aPrintManager, - IPrintTaskRequestedEventArgs* aArgs) -{ - return S_OK; -} - -void -FrameworkView::CreatePrintControl(IPrintDocumentPackageTarget* docPackageTarget, - D2D1_PRINT_CONTROL_PROPERTIES* printControlProperties) -{ -} - -HRESULT -FrameworkView::ClosePrintControl() -{ - return S_OK; -} - -// Print out one page, with the given print ticket. -// This sample has only one page and we ignore pageNumber below. -void FrameworkView::PrintPage(uint32_t pageNumber, - D2D1_RECT_F imageableArea, - D2D1_SIZE_F pageSize, - IStream* pagePrintTicketStream) -{ -} - -} } } diff --git a/widget/windows/winrt/MetroD3DCheckHelper.h b/widget/windows/winrt/MetroD3DCheckHelper.h deleted file mode 100644 index 6a44ba701..000000000 --- a/widget/windows/winrt/MetroD3DCheckHelper.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#pragma once - -/* this file is included by exe stubs, don't pull xpcom into it. */ - -#include -#include -#include - -/* - * Checks to see if the d3d implementation supports feature level 9.3 or - * above. Metrofx can't run on systems that fail this check. - * - * Note, this can hit perf, don't call this unless you absolutely have to. - * Both the ceh and winrt widget code save a cached result in the registry. - */ -static bool D3DFeatureLevelCheck() -{ - HMODULE dxgiModule = LoadLibraryA("dxgi.dll"); - if (!dxgiModule) { - return false; - } - decltype(CreateDXGIFactory1)* createDXGIFactory1 = - (decltype(CreateDXGIFactory1)*) GetProcAddress(dxgiModule, "CreateDXGIFactory1"); - if (!createDXGIFactory1) { - FreeLibrary(dxgiModule); - return false; - } - - HMODULE d3d10module = LoadLibraryA("d3d10_1.dll"); - if (!d3d10module) { - FreeLibrary(dxgiModule); - return false; - } - decltype(D3D10CreateDevice1)* createD3DDevice = - (decltype(D3D10CreateDevice1)*) GetProcAddress(d3d10module, - "D3D10CreateDevice1"); - if (!createD3DDevice) { - FreeLibrary(d3d10module); - FreeLibrary(dxgiModule); - return false; - } - - IDXGIFactory1* factory1; - if (FAILED(createDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&factory1))) { - FreeLibrary(d3d10module); - FreeLibrary(dxgiModule); - return false; - } - - IDXGIAdapter1* adapter1; - if (FAILED(factory1->EnumAdapters1(0, &adapter1))) { - factory1->Release(); - FreeLibrary(d3d10module); - FreeLibrary(dxgiModule); - return false; - } - - // Try for DX10.1 - ID3D10Device1* device; - if (FAILED(createD3DDevice(adapter1, D3D10_DRIVER_TYPE_HARDWARE, nullptr, - D3D10_CREATE_DEVICE_BGRA_SUPPORT | - D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS, - D3D10_FEATURE_LEVEL_10_1, - D3D10_1_SDK_VERSION, &device))) { - // Try for DX10 - if (FAILED(createD3DDevice(adapter1, D3D10_DRIVER_TYPE_HARDWARE, nullptr, - D3D10_CREATE_DEVICE_BGRA_SUPPORT | - D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS, - D3D10_FEATURE_LEVEL_10_0, - D3D10_1_SDK_VERSION, &device))) { - // Try for DX9.3 (we fall back to cairo and cairo has support for D3D 9.3) - if (FAILED(createD3DDevice(adapter1, D3D10_DRIVER_TYPE_HARDWARE, nullptr, - D3D10_CREATE_DEVICE_BGRA_SUPPORT | - D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS, - D3D10_FEATURE_LEVEL_9_3, - D3D10_1_SDK_VERSION, &device))) { - adapter1->Release(); - factory1->Release(); - FreeLibrary(d3d10module); - FreeLibrary(dxgiModule); - return false; - } - } - } - device->Release(); - adapter1->Release(); - factory1->Release(); - FreeLibrary(d3d10module); - FreeLibrary(dxgiModule); - return true; -} diff --git a/widget/windows/winrt/MetroInput.cpp b/widget/windows/winrt/MetroInput.cpp deleted file mode 100644 index 6b93d078e..000000000 --- a/widget/windows/winrt/MetroInput.cpp +++ /dev/null @@ -1,1576 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -// Moz headers (alphabetical) -#include "MetroInput.h" -#include "MetroUtils.h" // Logging, POINT_CEIL_*, ActivateGenericInstance, etc -#include "MetroWidget.h" // MetroInput::mWidget -#include "mozilla/dom/Touch.h" // Touch -#include "nsTArray.h" // Touch lists -#include "nsIDOMSimpleGestureEvent.h" // Constants for gesture events -#include "InputData.h" -#include "UIABridgePrivate.h" -#include "MetroAppShell.h" -#include "mozilla/EventStateManager.h" -#include "mozilla/EventStates.h" -#include "mozilla/MouseEvents.h" -#include "mozilla/TouchEvents.h" -#include "mozilla/Preferences.h" // for Preferences -#include "WinUtils.h" -#include "nsIPresShell.h" - -// System headers (alphabetical) -#include // ABI::Window::UI::Core namespace -#include // ABI::Window::UI::Input namespace - -//#define DEBUG_INPUT - -// Using declarations -using namespace ABI::Windows; // UI, System, Foundation namespaces -using namespace Microsoft; // WRL namespace (ComPtr, possibly others) -using namespace mozilla; -using namespace mozilla::widget; -using namespace mozilla::widget::winrt; -using namespace mozilla::dom; - -// File-scoped statics (unnamed namespace) -namespace { - // XXX: Set these min values appropriately - const double SWIPE_MIN_DISTANCE = 5.0; - const double SWIPE_MIN_VELOCITY = 5.0; - - // Convenience typedefs for event handler types - typedef Foundation::__FITypedEventHandler_2_Windows__CUI__CInput__CEdgeGesture_Windows__CUI__CInput__CEdgeGestureEventArgs_t EdgeGestureHandler; - typedef Foundation::__FITypedEventHandler_2_Windows__CUI__CCore__CCoreDispatcher_Windows__CUI__CCore__CAcceleratorKeyEventArgs_t AcceleratorKeyActivatedHandler; - typedef Foundation::__FITypedEventHandler_2_Windows__CUI__CCore__CCoreWindow_Windows__CUI__CCore__CPointerEventArgs_t PointerEventHandler; - typedef Foundation::__FITypedEventHandler_2_Windows__CUI__CInput__CGestureRecognizer_Windows__CUI__CInput__CTappedEventArgs_t TappedEventHandler; - typedef Foundation::__FITypedEventHandler_2_Windows__CUI__CInput__CGestureRecognizer_Windows__CUI__CInput__CRightTappedEventArgs_t RightTappedEventHandler; - typedef Foundation::__FITypedEventHandler_2_Windows__CUI__CInput__CGestureRecognizer_Windows__CUI__CInput__CManipulationStartedEventArgs_t ManipulationStartedEventHandler; - typedef Foundation::__FITypedEventHandler_2_Windows__CUI__CInput__CGestureRecognizer_Windows__CUI__CInput__CManipulationUpdatedEventArgs_t ManipulationUpdatedEventHandler; - typedef Foundation::__FITypedEventHandler_2_Windows__CUI__CInput__CGestureRecognizer_Windows__CUI__CInput__CManipulationCompletedEventArgs_t ManipulationCompletedEventHandler; - - // Other convenience typedefs - typedef ABI::Windows::UI::Core::ICoreAcceleratorKeys ICoreAcceleratorKeys; - - /** - * Specifies whether touch-action property is in force. - */ - static bool gTouchActionPropertyEnabled = false; - - /** - * Creates and returns a new {@link Touch} from the given - * ABI::Windows::UI::Input::IPointerPoint. Note that the caller is - * responsible for freeing the memory for the Touch returned from - * this function. - * - * @param aPoint the ABI::Windows::UI::Input::IPointerPoint containing the - * metadata from which to create our new {@link Touch} - * @return a new {@link Touch} representing the touch point. The caller - * is responsible for freeing the memory for this touch point. - */ - Touch* - CreateDOMTouch(UI::Input::IPointerPoint* aPoint) { - WRL::ComPtr props; - Foundation::Point position; - uint32_t pointerId; - Foundation::Rect contactRect; - float pressure; - float tiltX; - float tiltY; - - aPoint->get_Properties(props.GetAddressOf()); - aPoint->get_Position(&position); - aPoint->get_PointerId(&pointerId); - props->get_ContactRect(&contactRect); - props->get_Pressure(&pressure); - props->get_XTilt(&tiltX); - props->get_YTilt(&tiltY); - - nsIntPoint touchPoint = MetroUtils::LogToPhys(position); - nsIntPoint touchRadius; - touchRadius.x = WinUtils::LogToPhys(contactRect.Width) / 2; - touchRadius.y = WinUtils::LogToPhys(contactRect.Height) / 2; - Touch* touch = - new Touch(pointerId, - touchPoint, - // Rotation radius and angle. - // W3C touch events v1 do not use these. - // The draft for W3C touch events v2 explains that - // radius and angle should describe the ellipse that - // most closely circumscribes the touching area. Since - // Windows gives us a bounding rectangle rather than an - // ellipse, we provide the ellipse that is most closely - // circumscribed by the bounding rectangle that Windows - // gave us. - touchRadius, - 0.0f, - // Pressure - // W3C touch events v1 do not use this. - // The current draft for W3C touch events v2 says that - // this should be a value between 0.0 and 1.0, which is - // consistent with what Windows provides us here. - // XXX: Windows defaults to 0.5, but the current W3C - // draft says that the value should be 0.0 if no value - // known. - pressure); - touch->tiltX = tiltX; - touch->tiltY = tiltY; - return touch; - } - - /** - * Test if a touchpoint position has moved. See Touch.Equals for - * criteria. - * - * @param aTouch previous touch point - * @param aPoint new winrt touch point - * @return true if the point has moved - */ - bool - HasPointMoved(Touch* aTouch, UI::Input::IPointerPoint* aPoint) { - WRL::ComPtr props; - Foundation::Point position; - Foundation::Rect contactRect; - float pressure; - - aPoint->get_Properties(props.GetAddressOf()); - aPoint->get_Position(&position); - props->get_ContactRect(&contactRect); - props->get_Pressure(&pressure); - nsIntPoint touchPoint = MetroUtils::LogToPhys(position); - nsIntPoint touchRadius; - touchRadius.x = WinUtils::LogToPhys(contactRect.Width) / 2; - touchRadius.y = WinUtils::LogToPhys(contactRect.Height) / 2; - - // from Touch.Equals - return touchPoint != aTouch->mRefPoint || - pressure != aTouch->Force() || - /* mRotationAngle == aTouch->RotationAngle() || */ - touchRadius.x != aTouch->RadiusX() || - touchRadius.y != aTouch->RadiusY(); - } - - /** - * Converts from the Devices::Input::PointerDeviceType enumeration - * to a nsIDOMMouseEvent::MOZ_SOURCE_* value. - * - * @param aDeviceType the value to convert - * @param aMozInputSource the converted value - */ - void - MozInputSourceFromDeviceType( - Devices::Input::PointerDeviceType const& aDeviceType, - unsigned short& aMozInputSource) { - if (Devices::Input::PointerDeviceType::PointerDeviceType_Mouse - == aDeviceType) { - aMozInputSource = nsIDOMMouseEvent::MOZ_SOURCE_MOUSE; - } else if (Devices::Input::PointerDeviceType::PointerDeviceType_Touch - == aDeviceType) { - aMozInputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH; - } else if (Devices::Input::PointerDeviceType::PointerDeviceType_Pen - == aDeviceType) { - aMozInputSource = nsIDOMMouseEvent::MOZ_SOURCE_PEN; - } - } - - int16_t - ButtonsForPointerPoint(UI::Input::IPointerPoint* aPoint) { - WRL::ComPtr props; - aPoint->get_Properties(props.GetAddressOf()); - - int16_t buttons = 0; - boolean buttonPressed; - - props->get_IsLeftButtonPressed(&buttonPressed); - if (buttonPressed) { - buttons |= WidgetMouseEvent::eLeftButtonFlag; - } - props->get_IsMiddleButtonPressed(&buttonPressed); - if (buttonPressed) { - buttons |= WidgetMouseEvent::eMiddleButtonFlag; - } - props->get_IsRightButtonPressed(&buttonPressed); - if (buttonPressed) { - buttons |= WidgetMouseEvent::eRightButtonFlag; - } - props->get_IsXButton1Pressed(&buttonPressed); - if (buttonPressed) { - buttons |= WidgetMouseEvent::e4thButtonFlag; - } - props->get_IsXButton2Pressed(&buttonPressed); - if (buttonPressed) { - buttons |= WidgetMouseEvent::e5thButtonFlag; - } - return buttons; - } - - /** - * This function is for use with mTouches.Enumerate. It will - * append each element it encounters to the {@link nsTArray} - * of {@link mozilla::dom::Touch}es passed in through the third (void*) - * parameter. - * - * NOTE: This function will set the `mChanged` member of each - * element it encounters to `false`, since this function is only - * used to populate a touchlist that is about to be dispatched - * in a goanna touch event. - * - * @param aKey the key of the current element being enumerated - * @param aData the value of the current element being enumerated - * @param aTouchList the {@link WidgetTouchEvent::TouchArray} to append to - */ - PLDHashOperator - AppendToTouchList(const unsigned int& aKey, - nsRefPtr& aData, - void *aTouchList) - { - WidgetTouchEvent::TouchArray* touches = - static_cast(aTouchList); - nsRefPtr copy = new Touch(aData->mIdentifier, - aData->mRefPoint, - aData->mRadius, - aData->mRotationAngle, - aData->mForce); - copy->tiltX = aData->tiltX; - copy->tiltY = aData->tiltY; - touches->AppendElement(copy); - aData->mChanged = false; - return PL_DHASH_NEXT; - } - - // Helper for making sure event ptrs get freed. - class AutoDeleteEvent - { - public: - AutoDeleteEvent(WidgetGUIEvent* aPtr) : - mPtr(aPtr) {} - ~AutoDeleteEvent() { - if (mPtr) { - delete mPtr; - } - } - WidgetGUIEvent* mPtr; - }; -} - -namespace mozilla { -namespace widget { -namespace winrt { - -MetroInput::InputPrecisionLevel MetroInput::sCurrentInputLevel = - MetroInput::InputPrecisionLevel::LEVEL_IMPRECISE; - -MetroInput::MetroInput(MetroWidget* aWidget, - UI::Core::ICoreWindow* aWindow) - : mWidget(aWidget), - mNonApzTargetForTouch(false), - mWindow(aWindow), - mInputBlockId(0) -{ - LogFunction(); - NS_ASSERTION(aWidget, "Attempted to create MetroInput for null widget!"); - NS_ASSERTION(aWindow, "Attempted to create MetroInput for null window!"); - - mWidget->SetApzPendingResponseFlusher(this); - - Preferences::AddBoolVarCache(&gTouchActionPropertyEnabled, "layout.css.touch_action.enabled", gTouchActionPropertyEnabled); - mTokenPointerPressed.value = 0; - mTokenPointerReleased.value = 0; - mTokenPointerMoved.value = 0; - mTokenPointerEntered.value = 0; - mTokenPointerExited.value = 0; - mTokenEdgeStarted.value = 0; - mTokenEdgeCanceled.value = 0; - mTokenEdgeCompleted.value = 0; - mTokenManipulationCompleted.value = 0; - mTokenTapped.value = 0; - mTokenRightTapped.value = 0; - - // Create our Gesture Recognizer - ActivateGenericInstance(RuntimeClass_Windows_UI_Input_GestureRecognizer, - mGestureRecognizer); - NS_ASSERTION(mGestureRecognizer, "Failed to create GestureRecognizer!"); - - RegisterInputEvents(); -} - -MetroInput::~MetroInput() -{ - LogFunction(); - UnregisterInputEvents(); -} - -/* static */ -bool MetroInput::IsInputModeImprecise() -{ - return sCurrentInputLevel == LEVEL_IMPRECISE; -} - -/** - * Tracks the current input level (precise/imprecise) and fires an observer - * when the mode changes. - */ -void -MetroInput::UpdateInputLevel(InputPrecisionLevel aInputLevel) -{ - // ignore mouse input if we have active touch input. - if (aInputLevel == LEVEL_PRECISE && mTouches.Count() > 0) { - return; - } - if (sCurrentInputLevel != aInputLevel) { - sCurrentInputLevel = aInputLevel; - MetroUtils::FireObserver(sCurrentInputLevel == LEVEL_PRECISE ? - "metro_precise_input" : "metro_imprecise_input"); - } -} - -/** - * Processes an IEdgeGestureEventArgs and returns the input source type - * for the event. Also updates input level via UpdateInputLevel. - */ -uint16_t -MetroInput::ProcessInputTypeForGesture(UI::Input::IEdgeGestureEventArgs* aArgs) -{ - MOZ_ASSERT(aArgs); - UI::Input::EdgeGestureKind kind; - aArgs->get_Kind(&kind); - switch(kind) { - case UI::Input::EdgeGestureKind::EdgeGestureKind_Touch: - UpdateInputLevel(LEVEL_IMPRECISE); - return nsIDOMMouseEvent::MOZ_SOURCE_TOUCH; - break; - case UI::Input::EdgeGestureKind::EdgeGestureKind_Keyboard: - return nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD; - break; - case UI::Input::EdgeGestureKind::EdgeGestureKind_Mouse: - UpdateInputLevel(LEVEL_PRECISE); - return nsIDOMMouseEvent::MOZ_SOURCE_MOUSE; - break; - } - return nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN; -} - -/** - * When the user swipes her/his finger in from the top of the screen, - * we receive this event. - * - * @param sender the CoreDispatcher that fired this event - * @param aArgs the event-specific args we use when processing this event - * @returns S_OK - */ -HRESULT -MetroInput::OnEdgeGestureStarted(UI::Input::IEdgeGesture* sender, - UI::Input::IEdgeGestureEventArgs* aArgs) -{ -#ifdef DEBUG_INPUT - LogFunction(); -#endif - WidgetSimpleGestureEvent goannaEvent(true, - NS_SIMPLE_GESTURE_EDGE_STARTED, - mWidget.Get()); - mModifierKeyState.Update(); - mModifierKeyState.InitInputEvent(goannaEvent); - goannaEvent.time = ::GetMessageTime(); - goannaEvent.inputSource = ProcessInputTypeForGesture(aArgs); - - // Safe - DispatchEventIgnoreStatus(&goannaEvent); - return S_OK; -} - -/** - * This event can be received if the user swipes her/his finger back to - * the top of the screen, or continues moving her/his finger such that - * the movement is interpreted as a "grab this window" gesture - * - * @param sender the CoreDispatcher that fired this event - * @param aArgs the event-specific args we use when processing this event - * @returns S_OK - */ -HRESULT -MetroInput::OnEdgeGestureCanceled(UI::Input::IEdgeGesture* sender, - UI::Input::IEdgeGestureEventArgs* aArgs) -{ -#ifdef DEBUG_INPUT - LogFunction(); -#endif - WidgetSimpleGestureEvent goannaEvent(true, - NS_SIMPLE_GESTURE_EDGE_CANCELED, - mWidget.Get()); - mModifierKeyState.Update(); - mModifierKeyState.InitInputEvent(goannaEvent); - goannaEvent.time = ::GetMessageTime(); - goannaEvent.inputSource = ProcessInputTypeForGesture(aArgs); - - // Safe - DispatchEventIgnoreStatus(&goannaEvent); - return S_OK; -} - -/** - * This event is received if the user presses ctrl+Z or lifts her/his - * finger after causing an EdgeGestureStarting event to fire. - * - * @param sender the CoreDispatcher that fired this event - * @param aArgs the event-specific args we use when processing this event - * @returns S_OK - */ -HRESULT -MetroInput::OnEdgeGestureCompleted(UI::Input::IEdgeGesture* sender, - UI::Input::IEdgeGestureEventArgs* aArgs) -{ -#ifdef DEBUG_INPUT - LogFunction(); -#endif - WidgetSimpleGestureEvent goannaEvent(true, - NS_SIMPLE_GESTURE_EDGE_COMPLETED, - mWidget.Get()); - mModifierKeyState.Update(); - mModifierKeyState.InitInputEvent(goannaEvent); - goannaEvent.time = ::GetMessageTime(); - goannaEvent.inputSource = ProcessInputTypeForGesture(aArgs); - - // Safe - DispatchEventIgnoreStatus(&goannaEvent); - return S_OK; -} - -/** - * This helper function is used by our processing of PointerPressed, - * PointerReleased, and PointerMoved events. - * It dispatches a goanna event in response to the input received. This - * function should only be called for non-touch (i.e. pen or mouse) input - * events. - * - * @param aPoint the PointerPoint for the input event - */ -void -MetroInput::OnPointerNonTouch(UI::Input::IPointerPoint* aPoint) { - WRL::ComPtr props; - UI::Input::PointerUpdateKind pointerUpdateKind; - - aPoint->get_Properties(props.GetAddressOf()); - props->get_PointerUpdateKind(&pointerUpdateKind); - - uint32_t message = NS_MOUSE_MOVE; - int16_t button = 0; - - switch (pointerUpdateKind) { - case UI::Input::PointerUpdateKind::PointerUpdateKind_LeftButtonPressed: - button = WidgetMouseEvent::buttonType::eLeftButton; - message = NS_MOUSE_BUTTON_DOWN; - break; - case UI::Input::PointerUpdateKind::PointerUpdateKind_MiddleButtonPressed: - button = WidgetMouseEvent::buttonType::eMiddleButton; - message = NS_MOUSE_BUTTON_DOWN; - break; - case UI::Input::PointerUpdateKind::PointerUpdateKind_RightButtonPressed: - button = WidgetMouseEvent::buttonType::eRightButton; - message = NS_MOUSE_BUTTON_DOWN; - break; - case UI::Input::PointerUpdateKind::PointerUpdateKind_LeftButtonReleased: - button = WidgetMouseEvent::buttonType::eLeftButton; - message = NS_MOUSE_BUTTON_UP; - break; - case UI::Input::PointerUpdateKind::PointerUpdateKind_MiddleButtonReleased: - button = WidgetMouseEvent::buttonType::eMiddleButton; - message = NS_MOUSE_BUTTON_UP; - break; - case UI::Input::PointerUpdateKind::PointerUpdateKind_RightButtonReleased: - button = WidgetMouseEvent::buttonType::eRightButton; - message = NS_MOUSE_BUTTON_UP; - break; - } - - UpdateInputLevel(LEVEL_PRECISE); - - WidgetMouseEvent* event = - new WidgetMouseEvent(true, message, mWidget.Get(), - WidgetMouseEvent::eReal, - WidgetMouseEvent::eNormal); - event->button = button; - aPoint->get_PointerId(&event->pointerId); - InitGoannaMouseEventFromPointerPoint(event, aPoint); - DispatchAsyncEventIgnoreStatus(event); -} - -void -MetroInput::InitTouchEventTouchList(WidgetTouchEvent* aEvent) -{ - MOZ_ASSERT(aEvent); - mTouches.Enumerate(&AppendToTouchList, - static_cast(&aEvent->touches)); -} - -bool -MetroInput::ShouldDeliverInputToRecognizer() -{ - return mRecognizerWantsEvents; -} - -void -MetroInput::GetAllowedTouchBehavior(WidgetTouchEvent* aTransformedEvent, nsTArray& aOutBehaviors) -{ - mWidget->ApzcGetAllowedTouchBehavior(aTransformedEvent, aOutBehaviors); - - for (uint32_t i = 0; i < aOutBehaviors.Length(); i++) { - if (aOutBehaviors[i] & AllowedTouchBehavior::UNKNOWN) { - // performing hit testing fallback: asking content to perform hit testing itself - // (in spite that this operation has high latency). - aOutBehaviors[i] = mWidget->ContentGetAllowedTouchBehavior(aTransformedEvent->touches[i]->mRefPoint); - } - } -} - -// This event is raised when the user pushes the left mouse button, presses a -// pen to the surface, or presses a touch screen. -HRESULT -MetroInput::OnPointerPressed(UI::Core::ICoreWindow* aSender, - UI::Core::IPointerEventArgs* aArgs) -{ -#ifdef DEBUG_INPUT - LogFunction(); -#endif - - WRL::ComPtr currentPoint; - WRL::ComPtr device; - Devices::Input::PointerDeviceType deviceType; - - aArgs->get_CurrentPoint(currentPoint.GetAddressOf()); - currentPoint->get_PointerDevice(device.GetAddressOf()); - device->get_PointerDeviceType(&deviceType); - - // For mouse and pen input, simply call our helper function - if (deviceType != - Devices::Input::PointerDeviceType::PointerDeviceType_Touch) { - OnPointerNonTouch(currentPoint.Get()); - mGestureRecognizer->ProcessDownEvent(currentPoint.Get()); - return S_OK; - } - - // This is touch input. - UpdateInputLevel(LEVEL_IMPRECISE); - - // Create the new touch point and add it to our event. - uint32_t pointerId; - currentPoint->get_PointerId(&pointerId); - nsRefPtr touch = CreateDOMTouch(currentPoint.Get()); - touch->mChanged = true; - mTouches.Put(pointerId, touch); - - WidgetTouchEvent* touchEvent = - new WidgetTouchEvent(true, NS_TOUCH_START, mWidget.Get()); - - if (mTouches.Count() == 1) { - // If this is the first touchstart of a touch session reset some - // tracking flags. - mRecognizerWantsEvents = true; - } - - InitTouchEventTouchList(touchEvent); - DispatchAsyncTouchEvent(touchEvent); - - if (ShouldDeliverInputToRecognizer()) { - mGestureRecognizer->ProcessDownEvent(currentPoint.Get()); - } - return S_OK; -} - -void -MetroInput::AddPointerMoveDataToRecognizer(UI::Core::IPointerEventArgs* aArgs) -{ - if (ShouldDeliverInputToRecognizer()) { - WRL::ComPtr> - pointerPoints; - aArgs->GetIntermediatePoints(pointerPoints.GetAddressOf()); - mGestureRecognizer->ProcessMoveEvents(pointerPoints.Get()); - } -} - -// This event is raised when the user moves the mouse, moves a pen that is -// in contact with the surface, or moves a finger that is in contact with -// a touch screen. -HRESULT -MetroInput::OnPointerMoved(UI::Core::ICoreWindow* aSender, - UI::Core::IPointerEventArgs* aArgs) -{ -#ifdef DEBUG_INPUT - LogFunction(); -#endif - - WRL::ComPtr currentPoint; - WRL::ComPtr device; - Devices::Input::PointerDeviceType deviceType; - - aArgs->get_CurrentPoint(currentPoint.GetAddressOf()); - currentPoint->get_PointerDevice(device.GetAddressOf()); - device->get_PointerDeviceType(&deviceType); - - // For mouse and pen input, simply call our helper function - if (deviceType != - Devices::Input::PointerDeviceType::PointerDeviceType_Touch) { - OnPointerNonTouch(currentPoint.Get()); - AddPointerMoveDataToRecognizer(aArgs); - return S_OK; - } - - // This is touch input. - UpdateInputLevel(LEVEL_IMPRECISE); - - // Get the touch associated with this touch point. - uint32_t pointerId; - currentPoint->get_PointerId(&pointerId); - nsRefPtr touch = mTouches.Get(pointerId); - - // Some old drivers cause us to receive a PointerMoved event for a touchId - // after we've already received a PointerReleased event for that touchId. - // To work around those busted drivers, we simply ignore TouchMoved events - // for touchIds that we are not currently tracking. See bug 819223. - if (!touch) { - return S_OK; - } - - AddPointerMoveDataToRecognizer(aArgs); - - // If the point hasn't moved, filter it out per the spec. Pres shell does - // this as well, but we need to know when our first touchmove is going to - // get delivered so we can check the result. - if (!HasPointMoved(touch, currentPoint.Get())) { - return S_OK; - } - - touch = CreateDOMTouch(currentPoint.Get()); - touch->mChanged = true; - // replacing old touch point in mTouches map - mTouches.Put(pointerId, touch); - - WidgetTouchEvent* touchEvent = - new WidgetTouchEvent(true, NS_TOUCH_MOVE, mWidget.Get()); - InitTouchEventTouchList(touchEvent); - DispatchAsyncTouchEvent(touchEvent); - - return S_OK; -} - -// This event is raised when the user lifts the left mouse button, lifts a -// pen from the surface, or lifts her/his finger from a touch screen. -HRESULT -MetroInput::OnPointerReleased(UI::Core::ICoreWindow* aSender, - UI::Core::IPointerEventArgs* aArgs) -{ -#ifdef DEBUG_INPUT - LogFunction(); -#endif - - WRL::ComPtr currentPoint; - WRL::ComPtr device; - Devices::Input::PointerDeviceType deviceType; - - aArgs->get_CurrentPoint(currentPoint.GetAddressOf()); - currentPoint->get_PointerDevice(device.GetAddressOf()); - device->get_PointerDeviceType(&deviceType); - - // For mouse and pen input, simply call our helper function - if (deviceType != - Devices::Input::PointerDeviceType::PointerDeviceType_Touch) { - OnPointerNonTouch(currentPoint.Get()); - mGestureRecognizer->ProcessUpEvent(currentPoint.Get()); - return S_OK; - } - - // This is touch input. - UpdateInputLevel(LEVEL_IMPRECISE); - - // Get the touch associated with this touch point. - uint32_t pointerId; - currentPoint->get_PointerId(&pointerId); - nsRefPtr touch = mTouches.Get(pointerId); - - // Purge any pending moves for this pointer - if (touch->mChanged) { - WidgetTouchEvent* touchEvent = - new WidgetTouchEvent(true, NS_TOUCH_MOVE, mWidget.Get()); - InitTouchEventTouchList(touchEvent); - DispatchAsyncTouchEvent(touchEvent); - } - - // Remove this touch point from our map. Eventually all touch points are - // removed for this session since we receive released events for every - // point. - mTouches.Remove(pointerId); - - // touchend events only have a single touch; the touch that has been removed - WidgetTouchEvent* touchEvent = - new WidgetTouchEvent(true, NS_TOUCH_END, mWidget.Get()); - touchEvent->touches.AppendElement(CreateDOMTouch(currentPoint.Get())); - DispatchAsyncTouchEvent(touchEvent); - - if (ShouldDeliverInputToRecognizer()) { - mGestureRecognizer->ProcessUpEvent(currentPoint.Get()); - } - - return S_OK; -} - -// Tests for chrome vs. content target so we know whether input coordinates need -// to be transformed through the apz. Eventually this hit testing should move -// into the apz (bug 918288). -bool -MetroInput::HitTestChrome(const LayoutDeviceIntPoint& pt) -{ - // Confirm this event targets content. We pick this up in browser's input.js. - WidgetMouseEvent hittest(true, NS_MOUSE_MOZHITTEST, mWidget.Get(), - WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal); - hittest.refPoint = pt; - nsEventStatus status; - mWidget->DispatchEvent(&hittest, status); - return (status == nsEventStatus_eConsumeNoDefault); -} - -/** - * Returns true if the position is in chrome, false otherwise. - */ -bool -MetroInput::TransformRefPoint(const Foundation::Point& aPosition, LayoutDeviceIntPoint& aRefPointOut) -{ - // If this event is destined for content we need to transform our ref point through - // the apz so that zoom can be accounted for. - aRefPointOut = LayoutDeviceIntPoint::FromUntyped(MetroUtils::LogToPhys(aPosition)); - ScreenIntPoint spt(aRefPointOut.x, aRefPointOut.y); - // This is currently a general contained rect hit test, it may produce a false positive for - // overlay chrome elements. - bool apzIntersect = mWidget->ApzHitTest(spt); - if (!apzIntersect) { - return true; - } - if (HitTestChrome(aRefPointOut)) { - return true; - } - mWidget->ApzTransformGoannaCoordinate(spt, &aRefPointOut); - return false; -} - -void -MetroInput::TransformTouchEvent(WidgetTouchEvent* aEvent) -{ - WidgetTouchEvent::TouchArray& touches = aEvent->touches; - for (uint32_t i = 0; i < touches.Length(); ++i) { - dom::Touch* touch = touches[i]; - if (touch) { - LayoutDeviceIntPoint lpt; - ScreenIntPoint spt; - spt.x = touch->mRefPoint.x; - spt.y = touch->mRefPoint.y; - mWidget->ApzTransformGoannaCoordinate(spt, &lpt); - touch->mRefPoint.x = lpt.x; - touch->mRefPoint.y = lpt.y; - } - } -} - -void -MetroInput::InitGoannaMouseEventFromPointerPoint( - WidgetMouseEvent* aEvent, - UI::Input::IPointerPoint* aPointerPoint) -{ - NS_ASSERTION(aPointerPoint, "InitGoannaMouseEventFromPointerPoint " - "called with null PointerPoint!"); - - WRL::ComPtr props; - WRL::ComPtr device; - Devices::Input::PointerDeviceType deviceType; - Foundation::Point position; - uint64_t timestamp; - float pressure; - boolean canBeDoubleTap; - float tiltX; - float tiltY; - - aPointerPoint->get_Position(&position); - aPointerPoint->get_Timestamp(×tamp); - aPointerPoint->get_PointerDevice(device.GetAddressOf()); - device->get_PointerDeviceType(&deviceType); - aPointerPoint->get_Properties(props.GetAddressOf()); - aPointerPoint->get_PointerId(&aEvent->pointerId); - props->get_Pressure(&pressure); - props->get_XTilt(&tiltX); - props->get_YTilt(&tiltY); - - mGestureRecognizer->CanBeDoubleTap(aPointerPoint, &canBeDoubleTap); - - TransformRefPoint(position, aEvent->refPoint); - - if (!canBeDoubleTap) { - aEvent->clickCount = 1; - } else { - aEvent->clickCount = 2; - } - aEvent->pressure = pressure; - aEvent->tiltX = tiltX; - aEvent->tiltY = tiltY; - aEvent->buttons = ButtonsForPointerPoint(aPointerPoint); - - MozInputSourceFromDeviceType(deviceType, aEvent->inputSource); -} - -// This event is raised when a precise pointer moves into the bounding box of -// our window. For touch input, this will be raised before the PointerPressed -// event. -HRESULT -MetroInput::OnPointerEntered(UI::Core::ICoreWindow* aSender, - UI::Core::IPointerEventArgs* aArgs) -{ -#ifdef DEBUG_INPUT - LogFunction(); -#endif - - WRL::ComPtr currentPoint; - WRL::ComPtr device; - Devices::Input::PointerDeviceType deviceType; - - aArgs->get_CurrentPoint(currentPoint.GetAddressOf()); - currentPoint->get_PointerDevice(device.GetAddressOf()); - device->get_PointerDeviceType(&deviceType); - - // We only dispatch mouseenter and mouseexit events for mouse and pen input. - if (deviceType != - Devices::Input::PointerDeviceType::PointerDeviceType_Touch) { - WidgetMouseEvent* event = - new WidgetMouseEvent(true, NS_MOUSE_ENTER, mWidget.Get(), - WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal); - UpdateInputLevel(LEVEL_PRECISE); - InitGoannaMouseEventFromPointerPoint(event, currentPoint.Get()); - DispatchAsyncEventIgnoreStatus(event); - return S_OK; - } - UpdateInputLevel(LEVEL_IMPRECISE); - return S_OK; -} - -// This event is raised when a precise pointer leaves the bounding box of -// our window. For touch input, this will be raised before the -// PointerReleased event. -HRESULT -MetroInput::OnPointerExited(UI::Core::ICoreWindow* aSender, - UI::Core::IPointerEventArgs* aArgs) -{ -#ifdef DEBUG_INPUT - LogFunction(); -#endif - - WRL::ComPtr currentPoint; - WRL::ComPtr device; - Devices::Input::PointerDeviceType deviceType; - - aArgs->get_CurrentPoint(currentPoint.GetAddressOf()); - currentPoint->get_PointerDevice(device.GetAddressOf()); - device->get_PointerDeviceType(&deviceType); - - // We only dispatch mouseenter and mouseexit events for mouse and pen input. - if (deviceType != - Devices::Input::PointerDeviceType::PointerDeviceType_Touch) { - WidgetMouseEvent* event = - new WidgetMouseEvent(true, NS_MOUSE_EXIT, mWidget.Get(), - WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal); - event->exit = WidgetMouseEvent::eTopLevel; - UpdateInputLevel(LEVEL_PRECISE); - InitGoannaMouseEventFromPointerPoint(event, currentPoint.Get()); - DispatchAsyncEventIgnoreStatus(event); - return S_OK; - } - UpdateInputLevel(LEVEL_IMPRECISE); - return S_OK; -} - -// Goanna expects a "finished" event to be sent that has the cumulative -// changes since the gesture began. The idea is that consumers could hook -// only this last event and still effectively support magnification and -// rotation. We accomplish sending this "finished" event by calling our -// helper function with a cumulative "delta" value. -// -// After sending the "finished" event, this function detects and sends -// swipe gestures. -HRESULT -MetroInput::OnManipulationCompleted( - UI::Input::IGestureRecognizer* aSender, - UI::Input::IManipulationCompletedEventArgs* aArgs) -{ -#ifdef DEBUG_INPUT - LogFunction(); -#endif - - Devices::Input::PointerDeviceType deviceType; - aArgs->get_PointerDeviceType(&deviceType); - if (deviceType == - Devices::Input::PointerDeviceType::PointerDeviceType_Mouse) { - return S_OK; - } - - UI::Input::ManipulationDelta delta; - Foundation::Point position; - - aArgs->get_Position(&position); - aArgs->get_Cumulative(&delta); - - // We check that the distance the user's finger traveled and the - // velocity with which it traveled exceed our thresholds for - // classifying the movement as a swipe. - UI::Input::ManipulationVelocities velocities; - aArgs->get_Velocities(&velocities); - - bool isHorizontalSwipe = - abs(velocities.Linear.X) >= SWIPE_MIN_VELOCITY - && abs(delta.Translation.X) >= SWIPE_MIN_DISTANCE; - bool isVerticalSwipe = - abs(velocities.Linear.Y) >= SWIPE_MIN_VELOCITY - && abs(delta.Translation.Y) >= SWIPE_MIN_DISTANCE; - - // If our thresholds were exceeded for both a vertical and a horizontal - // swipe, it means the user is flinging her/his finger around and we - // should just ignore the input. - if (isHorizontalSwipe && isVerticalSwipe) { - return S_OK; - } - - if (isHorizontalSwipe) { - WidgetSimpleGestureEvent* swipeEvent = - new WidgetSimpleGestureEvent(true, NS_SIMPLE_GESTURE_SWIPE, - mWidget.Get()); - swipeEvent->direction = delta.Translation.X > 0 - ? nsIDOMSimpleGestureEvent::DIRECTION_RIGHT - : nsIDOMSimpleGestureEvent::DIRECTION_LEFT; - swipeEvent->delta = delta.Translation.X; - swipeEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH; - swipeEvent->refPoint = LayoutDeviceIntPoint::FromUntyped(MetroUtils::LogToPhys(position)); - DispatchAsyncEventIgnoreStatus(swipeEvent); - } - - if (isVerticalSwipe) { - WidgetSimpleGestureEvent* swipeEvent = - new WidgetSimpleGestureEvent(true, NS_SIMPLE_GESTURE_SWIPE, - mWidget.Get()); - swipeEvent->direction = delta.Translation.Y > 0 - ? nsIDOMSimpleGestureEvent::DIRECTION_DOWN - : nsIDOMSimpleGestureEvent::DIRECTION_UP; - swipeEvent->delta = delta.Translation.Y; - swipeEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH; - swipeEvent->refPoint = LayoutDeviceIntPoint::FromUntyped(MetroUtils::LogToPhys(position)); - DispatchAsyncEventIgnoreStatus(swipeEvent); - } - - return S_OK; -} - -// This event is raised when a sequence of pointer events has been -// interpreted by the GestureRecognizer as a tap (this could be a mouse -// click, a pen tap, or a tap on a touch surface). -HRESULT -MetroInput::OnTapped(UI::Input::IGestureRecognizer* aSender, - UI::Input::ITappedEventArgs* aArgs) -{ -#ifdef DEBUG_INPUT - LogFunction(); -#endif - - Devices::Input::PointerDeviceType deviceType; - aArgs->get_PointerDeviceType(&deviceType); - - unsigned int tapCount; - aArgs->get_TapCount(&tapCount); - - // For mouse and pen input, we send mousedown/mouseup/mousemove - // events as soon as we detect the input event. For touch input, a set of - // mousedown/mouseup events will be sent only once a tap has been detected. - if (deviceType != Devices::Input::PointerDeviceType::PointerDeviceType_Touch) { - return S_OK; - } - - Foundation::Point position; - aArgs->get_Position(&position); - HandleTap(position, tapCount); - return S_OK; -} - -// This event is raised when a sequence of pointer events has been -// interpreted by the GestureRecognizer as a right tap. -// This could be a mouse right-click, a right-click on a pen, or -// a tap-and-hold on a touch surface. -HRESULT -MetroInput::OnRightTapped(UI::Input::IGestureRecognizer* aSender, - UI::Input::IRightTappedEventArgs* aArgs) -{ -#ifdef DEBUG_INPUT - LogFunction(); -#endif - - Devices::Input::PointerDeviceType deviceType; - aArgs->get_PointerDeviceType(&deviceType); - - Foundation::Point position; - aArgs->get_Position(&position); - HandleLongTap(position); - - return S_OK; -} - -void -MetroInput::HandleTap(const Foundation::Point& aPoint, unsigned int aTapCount) -{ -#ifdef DEBUG_INPUT - LogFunction(); -#endif - - LayoutDeviceIntPoint refPoint; - TransformRefPoint(aPoint, refPoint); - - WidgetMouseEvent* mouseEvent = - new WidgetMouseEvent(true, NS_MOUSE_MOVE, mWidget.Get(), - WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal); - mouseEvent->refPoint = refPoint; - mouseEvent->clickCount = aTapCount; - mouseEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH; - DispatchAsyncEventIgnoreStatus(mouseEvent); - - mouseEvent = - new WidgetMouseEvent(true, NS_MOUSE_BUTTON_DOWN, mWidget.Get(), - WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal); - mouseEvent->refPoint = refPoint; - mouseEvent->clickCount = aTapCount; - mouseEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH; - mouseEvent->button = WidgetMouseEvent::buttonType::eLeftButton; - DispatchAsyncEventIgnoreStatus(mouseEvent); - - mouseEvent = - new WidgetMouseEvent(true, NS_MOUSE_BUTTON_UP, mWidget.Get(), - WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal); - mouseEvent->refPoint = refPoint; - mouseEvent->clickCount = aTapCount; - mouseEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH; - mouseEvent->button = WidgetMouseEvent::buttonType::eLeftButton; - DispatchAsyncEventIgnoreStatus(mouseEvent); - - // Make sure all goanna events are dispatched and the dom is up to date - // so that when ui automation comes in looking for focus info it gets - // the right information. - MetroAppShell::MarkEventQueueForPurge(); -} - -void -MetroInput::HandleLongTap(const Foundation::Point& aPoint) -{ -#ifdef DEBUG_INPUT - LogFunction(); -#endif - LayoutDeviceIntPoint refPoint; - TransformRefPoint(aPoint, refPoint); - - WidgetMouseEvent* contextEvent = - new WidgetMouseEvent(true, NS_CONTEXTMENU, mWidget.Get(), - WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal); - contextEvent->refPoint = refPoint; - contextEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH; - DispatchAsyncEventIgnoreStatus(contextEvent); -} - -/** - * Implementation Details - */ -nsEventStatus MetroInput::sThrowawayStatus; - -void -MetroInput::DispatchAsyncEventIgnoreStatus(WidgetInputEvent* aEvent) -{ - aEvent->time = ::GetMessageTime(); - mModifierKeyState.Update(); - mModifierKeyState.InitInputEvent(*aEvent); - mInputEventQueue.Push(aEvent); - nsCOMPtr runnable = - NS_NewRunnableMethod(this, &MetroInput::DeliverNextQueuedEventIgnoreStatus); - NS_DispatchToCurrentThread(runnable); -} - -void -MetroInput::DeliverNextQueuedEventIgnoreStatus() -{ - nsAutoPtr event = - static_cast(mInputEventQueue.PopFront()); - MOZ_ASSERT(event.get()); - DispatchEventIgnoreStatus(event.get()); - - // Let app shell know we've delivered that last input we wanted purged - // via a call to MarkEventQueueForPurge(). - if (event->message == NS_MOUSE_BUTTON_UP) { - MetroAppShell::InputEventsDispatched(); - } - - // Clear :hover/:active states for mouse events generated by HandleTap - WidgetMouseEvent* mouseEvent = event.get()->AsMouseEvent(); - if (!mouseEvent) { - return; - } - if (mouseEvent->message != NS_MOUSE_BUTTON_UP || - mouseEvent->inputSource != nsIDOMMouseEvent::MOZ_SOURCE_TOUCH) { - return; - } - nsCOMPtr presShell = mWidget->GetPresShell(); - if (presShell) { - EventStateManager* esm = presShell->GetPresContext()->EventStateManager(); - if (esm) { - esm->SetContentState(nullptr, NS_EVENT_STATE_HOVER); - } - } -} - -void -MetroInput::DispatchAsyncTouchEvent(WidgetTouchEvent* aEvent) -{ - aEvent->time = ::GetMessageTime(); - mModifierKeyState.Update(); - mModifierKeyState.InitInputEvent(*aEvent); - mInputEventQueue.Push(aEvent); - nsCOMPtr runnable = - NS_NewRunnableMethod(this, &MetroInput::DeliverNextQueuedTouchEvent); - NS_DispatchToCurrentThread(runnable); -} - -static void DumpTouchIds(const char* aTarget, WidgetTouchEvent* aEvent) -{ - // comment out for touch moves - if (aEvent->message == NS_TOUCH_MOVE) { - return; - } - switch(aEvent->message) { - case NS_TOUCH_START: - WinUtils::Log("DumpTouchIds: NS_TOUCH_START block"); - break; - case NS_TOUCH_MOVE: - WinUtils::Log("DumpTouchIds: NS_TOUCH_MOVE block"); - break; - case NS_TOUCH_END: - WinUtils::Log("DumpTouchIds: NS_TOUCH_END block"); - break; - case NS_TOUCH_CANCEL: - WinUtils::Log("DumpTouchIds: NS_TOUCH_CANCEL block"); - break; - } - WidgetTouchEvent::TouchArray& touches = aEvent->touches; - for (uint32_t i = 0; i < touches.Length(); ++i) { - dom::Touch* touch = touches[i]; - if (!touch) { - continue; - } - int32_t id = touch->Identifier(); - WinUtils::Log(" id=%d target=%s", id, aTarget); - } -} - -static void DumpTouchBehavior(nsTArray& aBehavior) -{ - WinUtils::Log("DumpTouchBehavior: Touch behavior flags set for current touch session:"); - for (uint32_t i = 0; i < aBehavior.Length(); i++) { - if (mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN & aBehavior[i]) { - WinUtils::Log("VERTICAL_PAN"); - } - - if (mozilla::layers::AllowedTouchBehavior::HORIZONTAL_PAN & aBehavior[i]) { - WinUtils::Log("HORIZONTAL_PAN"); - } - - if (mozilla::layers::AllowedTouchBehavior::UNKNOWN & aBehavior[i]) { - WinUtils::Log("UNKNOWN"); - } - - if ((mozilla::layers::AllowedTouchBehavior::NONE & aBehavior[i]) == 0) { - WinUtils::Log("NONE"); - } - } -} - -/* - * nsPreShell's processing of WidgetTouchEvent events: - * - * NS_TOUCH_START: - * Interprets a single touch point as the first touch point of a block and will reset its - * queue when it receives this. For multiple touch points it sets all points in its queue - * and marks new points as changed. - * NS_TOUCH_MOVE: - * Uses the equality tests in dom::Touch to test if a touch point has changed (moved). - * If a point has moved, keeps this touch point in the event, otherwise it removes - * the touch point. Note if no points have changed, it exits without sending a dom event. - * NS_TOUCH_CANCEL/NS_TOUCH_END - * Assumes any point in touchEvent->touches has been removed or canceled. -*/ - -//#define DUMP_TOUCH_IDS(aTarget, aEvent) DumpTouchIds(aTarget, aEvent) -#define DUMP_TOUCH_IDS(...) - -//#define DUMP_ALLOWED_TOUCH_BEHAVIOR(aBehavior) DumpTouchBehavior(aBehavior) -#define DUMP_ALLOWED_TOUCH_BEHAVIOR(...) - -void -MetroInput::HandleTouchStartEvent(WidgetTouchEvent* aEvent) -{ - // This is the start of a new touch block. See what the APZ wants to do with it. - - WidgetTouchEvent transformedEvent(*aEvent); - DUMP_TOUCH_IDS("APZC(1)", aEvent); - nsEventStatus result = mWidget->ApzReceiveInputEvent(&transformedEvent, &mTargetAPZCGuid, &mInputBlockId); - if (result == nsEventStatus_eConsumeNoDefault) { - // The APZ said: throw this event away entirely. - CancelGesture(); - return; - } - - // If the APZ is using this block, send it touch-action behavior. - if (gTouchActionPropertyEnabled) { - nsTArray touchBehaviors; - // Retrieving touch behaviors from apzctm and from the content (if needed) - // then setting it back to the apzc. The apzc we retrieved touch behaviors - // from and we're setting to may changes if there are multiple touches (in that - // case apzctm needs to take common ancestor of them). - GetAllowedTouchBehavior(&transformedEvent, touchBehaviors); - // Setting the touch behaviors to the apzc that will be responsible - // for interpreting it. It may be not the same apzc we retrieved touch - // action values from. E.g. for zooming we're taking parent apzc of a few ones - // that were touched but touch behaviors would be taken from childs. - DUMP_ALLOWED_TOUCH_BEHAVIOR(touchBehaviors); - mWidget->ApzcSetAllowedTouchBehavior(mInputBlockId, touchBehaviors); - } - - // Pass the event on to content - DUMP_TOUCH_IDS("DOM(2)", aEvent); - nsEventStatus contentStatus = nsEventStatus_eIgnore; - mWidget->DispatchEvent(&transformedEvent, contentStatus); - if (nsEventStatus_eConsumeNoDefault == contentStatus) { - // Content consumed the event, so we need to notify the APZ - // to not do anything with this touch block. - mWidget->ApzContentConsumingTouch(mInputBlockId); - mCancelable = false; - - // Also cancel the gesture detection. - CancelGesture(); - } -} - -void -MetroInput::HandleFirstTouchMoveEvent(WidgetTouchEvent* aEvent) -{ - // If the APZ is using this block, pass the event to it. - WidgetTouchEvent transformedEvent(*aEvent); - DUMP_TOUCH_IDS("APZC(2)", aEvent); - nsEventStatus apzcStatus = mWidget->ApzReceiveInputEvent(&transformedEvent, &mTargetAPZCGuid, &mInputBlockId); - if (apzcStatus == nsEventStatus_eConsumeNoDefault) { - // The APZ said: throw this event away entirely. - CancelGesture(); - return; - } - - // ==== RANDOM INTERLUDE ABOut POINTER EVENTS ==== - // We need to dispatch here only touch event, not pointer one. - // That's because according to the spec pointer events doesn't imply pointermove event - // between pointerdown and pointercancel (If default touch behavior is triggered). - // But at the same time we need to dispatch at least touchmove event to let content to - // consume it (or not consume). - // TODO: determine how to dispatch only one kind of events: currently there are two options: - // 1) Create two separate instances of the WidgetTouchEvent and WidgetPointerEvent and - // dispatch them separately. - // 2) Add a boolean flag to the WidgetTouchEvent that states whether this event should produce - // both touch and pointer event or only touch one. - // Anyway it's worth to add this stuff only after patches from bug 822898 (Pointer events) are - // fully commited. - // ==== END RANDOM INTERLUDE ABOut POINTER EVENTS ==== - - // And pass the untransformed event to content. - DUMP_TOUCH_IDS("DOM(3)", aEvent); - nsEventStatus contentStatus = nsEventStatus_eIgnore; - mWidget->DispatchEvent(&transformedEvent, contentStatus); - - // Let the apz know if content wants to consume touch events. - if (mCancelable) { - if (nsEventStatus_eConsumeNoDefault == contentStatus) { - mWidget->ApzContentConsumingTouch(mInputBlockId); - } else { - mWidget->ApzContentIgnoringTouch(mInputBlockId); - if (apzcStatus == nsEventStatus_eConsumeDoDefault) { - SendPointerCancelToContent(transformedEvent); - } - } - mCancelable = false; - } - - // Cancel the gesture detection as well if content is taking this block. - if (nsEventStatus_eConsumeNoDefault == contentStatus) { - CancelGesture(); - } -} - -void -MetroInput::SendPointerCancelToContent(const WidgetTouchEvent& aEvent) -{ - // The APZ is consuming the touch pointers specified in |aEvent| so - // we need to send pointer-cancel events for them to content. We - // do that by sending touchcancel events which the EventStateManager - // turns into pointer-cancel events - WidgetTouchEvent cancel(aEvent); - cancel.message = NS_TOUCH_CANCEL; - for (uint32_t i = 0; i < cancel.touches.Length(); i++) { - cancel.touches[i]->convertToPointer = true; - } - nsEventStatus status; - mWidget->DispatchEvent(&cancel, status); -} - -bool -MetroInput::SendPendingResponseToApz() -{ - // If this is called, content has missed its chance to consume this event block - // so we should notify the APZ that content is ignoring this touch block. - if (mCancelable) { - mWidget->ApzContentIgnoringTouch(mInputBlockId); - mCancelable = false; - return true; - } - return false; -} - -void -MetroInput::FlushPendingContentResponse() -{ - SendPendingResponseToApz(); -} - -void -MetroInput::CancelGesture() -{ - if (mRecognizerWantsEvents) { - mRecognizerWantsEvents = false; - mGestureRecognizer->CompleteGesture(); - } -} - -void -MetroInput::DeliverNextQueuedTouchEvent() -{ - /* - * Note: never rely on the contents of mTouches here, since this is a delayed - * callback. mTouches will likely have been modified. - */ - - nsEventStatus status = nsEventStatus_eIgnore; - - WidgetTouchEvent* event = - static_cast(mInputEventQueue.PopFront()); - MOZ_ASSERT(event); - - AutoDeleteEvent wrap(event); - - // This is the start of a new touch block. If we haven't - // responded to the APZ about the last touch block, do that - // now, and reset variables for the new touch block. - if (event->message == NS_TOUCH_START) { - SendPendingResponseToApz(); - - mCancelable = true; - mTargetAPZCGuid = ScrollableLayerGuid(); - mInputBlockId = 0; - } - - // Test for non-apz vs. apz target. To do this we only use the first touch - // point since that will be the input batch target. Cache this for touch events - // since HitTestChrome has to send a dom event. - if (event->message == NS_TOUCH_START && event->touches.Length() == 1) { - nsRefPtr touch = event->touches[0]; - LayoutDeviceIntPoint pt = LayoutDeviceIntPoint::FromUntyped(touch->mRefPoint); - // This is currently a general contained rect hit test, it may produce a false - // positive for overlay chrome elements. Also, some content pages won't support - // apzc, so this may be false for content as well. - bool apzIntersect = mWidget->ApzHitTest(mozilla::ScreenIntPoint(pt.x, pt.y)); - mNonApzTargetForTouch = (!apzIntersect || HitTestChrome(pt)); - } - - // If this event is destined for dom, deliver it directly there bypassing - // the apz. Continue doing this until the number of active touch points drops - // to zero. After that we recompute mNonApzTargetForTouch in the block above. - if (mNonApzTargetForTouch) { - DUMP_TOUCH_IDS("DOM(1)", event); - mWidget->DispatchEvent(event, status); - if (mCancelable) { - // Disable gesture based events (taps, swipes, rotation) if - // preventDefault is called on touchstart. - if (nsEventStatus_eConsumeNoDefault == status) { - CancelGesture(); - } - if (event->message == NS_TOUCH_MOVE) { - mCancelable = false; - } - } - return; - } - - // Special handling for the start and first move events - if (event->message == NS_TOUCH_START) { - HandleTouchStartEvent(event); - return; - } else if (mCancelable && event->message == NS_TOUCH_MOVE) { - HandleFirstTouchMoveEvent(event); - return; - } - - // If we get here, content has already had its chance to consume this event - // block. If it didn't do so we can inform the APZ that content is ignoring - // this event block. - bool responseSent = SendPendingResponseToApz(); - - // Normal processing of events. Send it to the APZ first for handling and - // untransformation. then pass the untransformed event to content. - DUMP_TOUCH_IDS("APZC(3)", event); - status = mWidget->ApzReceiveInputEvent(event, nullptr, nullptr); - if (status == nsEventStatus_eConsumeNoDefault) { - CancelGesture(); - return; - } - if (responseSent && status == nsEventStatus_eConsumeDoDefault) { - SendPointerCancelToContent(*event); - return; - } - DUMP_TOUCH_IDS("DOM(4)", event); - mWidget->DispatchEvent(event, status); -} - -void -MetroInput::DispatchEventIgnoreStatus(WidgetGUIEvent *aEvent) -{ - mWidget->DispatchEvent(aEvent, sThrowawayStatus); -} - -void -MetroInput::UnregisterInputEvents() { - // Unregister ourselves for the edge swipe event - WRL::ComPtr edgeStatics; - if (SUCCEEDED(Foundation::GetActivationFactory( - WRL::Wrappers::HStringReference( - RuntimeClass_Windows_UI_Input_EdgeGesture).Get(), - edgeStatics.GetAddressOf()))) { - WRL::ComPtr edge; - if (SUCCEEDED(edgeStatics->GetForCurrentView(edge.GetAddressOf()))) { - edge->remove_Starting(mTokenEdgeStarted); - edge->remove_Canceled(mTokenEdgeCanceled); - edge->remove_Completed(mTokenEdgeCompleted); - } - } - // Unregister ourselves from the window events. This is extremely important; - // once this object is destroyed we don't want Windows to try to send events - // to it. - mWindow->remove_PointerPressed(mTokenPointerPressed); - mWindow->remove_PointerReleased(mTokenPointerReleased); - mWindow->remove_PointerMoved(mTokenPointerMoved); - mWindow->remove_PointerEntered(mTokenPointerEntered); - mWindow->remove_PointerExited(mTokenPointerExited); - - // Unregistering from the gesture recognizer events probably isn't as - // necessary since we're about to destroy the gesture recognizer, but - // it can't hurt. - mGestureRecognizer->remove_ManipulationCompleted( - mTokenManipulationCompleted); - mGestureRecognizer->remove_Tapped(mTokenTapped); - mGestureRecognizer->remove_RightTapped(mTokenRightTapped); -} - -void -MetroInput::RegisterInputEvents() -{ - NS_ASSERTION(mWindow, "Must have a window to register for input events!"); - NS_ASSERTION(mGestureRecognizer, - "Must have a GestureRecognizer for input events!"); - // Register for edge swipe - WRL::ComPtr edgeStatics; - Foundation::GetActivationFactory( - WRL::Wrappers::HStringReference( - RuntimeClass_Windows_UI_Input_EdgeGesture) - .Get(), - edgeStatics.GetAddressOf()); - WRL::ComPtr edge; - edgeStatics->GetForCurrentView(edge.GetAddressOf()); - - edge->add_Starting( - WRL::Callback( - this, - &MetroInput::OnEdgeGestureStarted).Get(), - &mTokenEdgeStarted); - - edge->add_Canceled( - WRL::Callback( - this, - &MetroInput::OnEdgeGestureCanceled).Get(), - &mTokenEdgeCanceled); - - edge->add_Completed( - WRL::Callback( - this, - &MetroInput::OnEdgeGestureCompleted).Get(), - &mTokenEdgeCompleted); - - // Set up our Gesture Recognizer to raise events for the gestures we - // care about - mGestureRecognizer->put_GestureSettings( - UI::Input::GestureSettings::GestureSettings_Tap - | UI::Input::GestureSettings::GestureSettings_DoubleTap - | UI::Input::GestureSettings::GestureSettings_RightTap - | UI::Input::GestureSettings::GestureSettings_Hold - | UI::Input::GestureSettings::GestureSettings_ManipulationTranslateX - | UI::Input::GestureSettings::GestureSettings_ManipulationTranslateY); - - // Register for the pointer events on our Window - mWindow->add_PointerPressed( - WRL::Callback( - this, - &MetroInput::OnPointerPressed).Get(), - &mTokenPointerPressed); - - mWindow->add_PointerReleased( - WRL::Callback( - this, - &MetroInput::OnPointerReleased).Get(), - &mTokenPointerReleased); - - mWindow->add_PointerMoved( - WRL::Callback( - this, - &MetroInput::OnPointerMoved).Get(), - &mTokenPointerMoved); - - mWindow->add_PointerEntered( - WRL::Callback( - this, - &MetroInput::OnPointerEntered).Get(), - &mTokenPointerEntered); - - mWindow->add_PointerExited( - WRL::Callback( - this, - &MetroInput::OnPointerExited).Get(), - &mTokenPointerExited); - - // Register for the events raised by our Gesture Recognizer - mGestureRecognizer->add_Tapped( - WRL::Callback( - this, - &MetroInput::OnTapped).Get(), - &mTokenTapped); - - mGestureRecognizer->add_RightTapped( - WRL::Callback( - this, - &MetroInput::OnRightTapped).Get(), - &mTokenRightTapped); - - mGestureRecognizer->add_ManipulationCompleted( - WRL::Callback( - this, - &MetroInput::OnManipulationCompleted).Get(), - &mTokenManipulationCompleted); -} - -} } } diff --git a/widget/windows/winrt/MetroInput.h b/widget/windows/winrt/MetroInput.h deleted file mode 100644 index 580e5b38c..000000000 --- a/widget/windows/winrt/MetroInput.h +++ /dev/null @@ -1,293 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#pragma once - -// Moz headers (alphabetical) -#include "APZController.h" -#include "keyboardlayout.h" // mModifierKeyState -#include "nsBaseHashtable.h" // mTouches -#include "nsHashKeys.h" // type of key for mTouches -#include "mozwrlbase.h" -#include "nsDeque.h" -#include "mozilla/EventForwards.h" -#include "mozilla/layers/APZCTreeManager.h" - -// System headers (alphabetical) -#include // EventRegistrationToken -#include // uint32_t -#include // Microsoft::WRL::ComPtr class -#include // Microsoft::WRL::InspectableClass macro - -// Moz forward declarations -class MetroWidget; -struct nsIntPoint; - -namespace mozilla { -namespace dom { -class Touch; -} -} - -// Windows forward declarations -namespace ABI { - namespace Windows { - namespace Devices { - namespace Input { - enum PointerDeviceType; - } - }; - namespace Foundation { - struct Point; - }; - namespace UI { - namespace Core { - struct ICoreWindow; - struct IAcceleratorKeyEventArgs; - struct IKeyEventArgs; - struct IPointerEventArgs; - }; - namespace Input { - struct IEdgeGesture; - struct IEdgeGestureEventArgs; - struct IGestureRecognizer; - struct IManipulationCompletedEventArgs; - struct IManipulationStartedEventArgs; - struct IManipulationUpdatedEventArgs; - struct IPointerPoint; - struct IRightTappedEventArgs; - struct ITappedEventArgs; - struct ManipulationDelta; - }; - }; - }; -}; - -namespace mozilla { -namespace widget { -namespace winrt { - -class MetroInput : public Microsoft::WRL::RuntimeClass, - public APZPendingResponseFlusher -{ - InspectableClass(L"MetroInput", BaseTrust); - -private: - typedef mozilla::layers::AllowedTouchBehavior AllowedTouchBehavior; - typedef uint32_t TouchBehaviorFlags; - - // Devices - typedef ABI::Windows::Devices::Input::PointerDeviceType PointerDeviceType; - - // Foundation - typedef ABI::Windows::Foundation::Point Point; - - // UI::Core - typedef ABI::Windows::UI::Core::ICoreWindow ICoreWindow; - typedef ABI::Windows::UI::Core::IAcceleratorKeyEventArgs \ - IAcceleratorKeyEventArgs; - typedef ABI::Windows::UI::Core::IKeyEventArgs IKeyEventArgs; - typedef ABI::Windows::UI::Core::IPointerEventArgs IPointerEventArgs; - - // UI::Input - typedef ABI::Windows::UI::Input::IEdgeGesture IEdgeGesture; - typedef ABI::Windows::UI::Input::IEdgeGestureEventArgs IEdgeGestureEventArgs; - typedef ABI::Windows::UI::Input::IGestureRecognizer IGestureRecognizer; - typedef ABI::Windows::UI::Input::IManipulationCompletedEventArgs \ - IManipulationCompletedEventArgs; - typedef ABI::Windows::UI::Input::IManipulationStartedEventArgs \ - IManipulationStartedEventArgs; - typedef ABI::Windows::UI::Input::IManipulationUpdatedEventArgs \ - IManipulationUpdatedEventArgs; - typedef ABI::Windows::UI::Input::IPointerPoint IPointerPoint; - typedef ABI::Windows::UI::Input::IRightTappedEventArgs IRightTappedEventArgs; - typedef ABI::Windows::UI::Input::ITappedEventArgs ITappedEventArgs; - typedef ABI::Windows::UI::Input::ManipulationDelta ManipulationDelta; - - typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid; - -public: - MetroInput(MetroWidget* aWidget, - ICoreWindow* aWindow); - virtual ~MetroInput(); - - // These input events are received from our window. These are basic - // pointer and keyboard press events. MetroInput responds to them - // by sending goanna events and forwarding these input events to its - // GestureRecognizer to be processed into more complex input events - // (tap, rightTap, rotate, etc) - HRESULT OnPointerPressed(ICoreWindow* aSender, - IPointerEventArgs* aArgs); - HRESULT OnPointerReleased(ICoreWindow* aSender, - IPointerEventArgs* aArgs); - HRESULT OnPointerMoved(ICoreWindow* aSender, - IPointerEventArgs* aArgs); - HRESULT OnPointerEntered(ICoreWindow* aSender, - IPointerEventArgs* aArgs); - HRESULT OnPointerExited(ICoreWindow* aSender, - IPointerEventArgs* aArgs); - - // The Edge gesture event is special. It does not come from our window - // or from our GestureRecognizer. - HRESULT OnEdgeGestureStarted(IEdgeGesture* aSender, - IEdgeGestureEventArgs* aArgs); - HRESULT OnEdgeGestureCanceled(IEdgeGesture* aSender, - IEdgeGestureEventArgs* aArgs); - HRESULT OnEdgeGestureCompleted(IEdgeGesture* aSender, - IEdgeGestureEventArgs* aArgs); - - // Swipe gesture callback from the GestureRecognizer. - HRESULT OnManipulationCompleted(IGestureRecognizer* aSender, - IManipulationCompletedEventArgs* aArgs); - - // Tap gesture callback from the GestureRecognizer. - HRESULT OnTapped(IGestureRecognizer* aSender, ITappedEventArgs* aArgs); - HRESULT OnRightTapped(IGestureRecognizer* aSender, - IRightTappedEventArgs* aArgs); - - void HandleTap(const Point& aPoint, unsigned int aTapCount); - void HandleLongTap(const Point& aPoint); - - // The APZPendingResponseFlusher implementation - void FlushPendingContentResponse(); - - static bool IsInputModeImprecise(); - -private: - Microsoft::WRL::ComPtr mWindow; - Microsoft::WRL::ComPtr mWidget; - Microsoft::WRL::ComPtr mGestureRecognizer; - - ModifierKeyState mModifierKeyState; - - // Tracking input level - enum InputPrecisionLevel { - LEVEL_PRECISE, - LEVEL_IMPRECISE - }; - static InputPrecisionLevel sCurrentInputLevel; - void UpdateInputLevel(InputPrecisionLevel aInputLevel); - - // Initialization/Uninitialization helpers - void RegisterInputEvents(); - void UnregisterInputEvents(); - - // Hit testing for apz content - bool mNonApzTargetForTouch; - bool HitTestChrome(const LayoutDeviceIntPoint& pt); - - // Event processing helpers. See function definitions for more info. - bool TransformRefPoint(const Point& aPosition, - LayoutDeviceIntPoint& aRefPointOut); - void TransformTouchEvent(WidgetTouchEvent* aEvent); - void OnPointerNonTouch(IPointerPoint* aPoint); - void AddPointerMoveDataToRecognizer(IPointerEventArgs* aArgs); - void InitGoannaMouseEventFromPointerPoint(WidgetMouseEvent* aEvent, - IPointerPoint* aPoint); - void ProcessManipulationDelta(ManipulationDelta const& aDelta, - Point const& aPosition, - uint32_t aMagEventType, - uint32_t aRotEventType); - uint16_t ProcessInputTypeForGesture(IEdgeGestureEventArgs* aArgs); - bool ShouldDeliverInputToRecognizer(); - - // Returns array of allowed touch behaviors for touch points of given TouchEvent. - // Note: event argument should be transformed via apzc before supplying to this method. - void GetAllowedTouchBehavior(WidgetTouchEvent* aTransformedEvent, nsTArray& aOutBehaviors); - - // First, read the comment in gfx/layers/apz/src/TouchBlockState.h. - // The following booleans track the following pieces of state: - // mCancelable - if we have not yet notified the APZ code about the prevent- - // default status of the current touch block. This is flipped from true - // to false when this notification happens. - // mRecognizerWantsEvents - If the gesture recognizer should be receiving - // events. This is normally true, but will be set to false if the APZ - // decides the touch block should be thrown away entirely, or if content - // consumes the touch block. - // XXX There is a hazard with mRecognizerWantsEvents because it is accessed - // both in the sync and async portions of the code. - bool mCancelable; - bool mRecognizerWantsEvents; - - // In the old Win32 way of doing things, we would receive a WM_TOUCH event - // that told us the state of every touchpoint on the touch surface. If - // multiple touchpoints had moved since the last update we would learn - // about all their movement simultaneously. - // - // In the new WinRT way of doing things, we receive a separate - // PointerPressed/PointerMoved/PointerReleased event for each touchpoint - // that has changed. - // - // When we learn of touch input, we dispatch goanna events in response. - // With the new WinRT way of doing things, we would end up sending many - // more goanna events than we would using the Win32 mechanism. E.g., - // for 5 active touchpoints, we would be sending 5 times as many goanna - // events. This caused performance to visibly degrade on modestly-powered - // machines. In response, we no longer send touch events immediately - // upon receiving PointerPressed or PointerMoved. Instead, we store - // the updated touchpoint info and record the fact that the touchpoint - // has changed. If ever we try to update a touchpoint has already - // changed, we dispatch a touch event containing all the changed touches. - void InitTouchEventTouchList(WidgetTouchEvent* aEvent); - nsBaseHashtable, - nsRefPtr > mTouches; - - // These registration tokens are set when we register ourselves to receive - // events from our window. We must hold on to them for the entire duration - // that we want to receive these events. When we are done, we must - // unregister ourself with the window using these tokens. - EventRegistrationToken mTokenPointerPressed; - EventRegistrationToken mTokenPointerReleased; - EventRegistrationToken mTokenPointerMoved; - EventRegistrationToken mTokenPointerEntered; - EventRegistrationToken mTokenPointerExited; - - // When we register ourselves to handle edge gestures, we receive a - // token. To we unregister ourselves, we must use the token we received. - EventRegistrationToken mTokenEdgeStarted; - EventRegistrationToken mTokenEdgeCanceled; - EventRegistrationToken mTokenEdgeCompleted; - - // These registration tokens are set when we register ourselves to receive - // events from our GestureRecognizer. It's probably not a huge deal if we - // don't unregister ourselves with our GestureRecognizer before destroying - // the GestureRecognizer, but it can't hurt. - EventRegistrationToken mTokenManipulationCompleted; - EventRegistrationToken mTokenTapped; - EventRegistrationToken mTokenRightTapped; - - // Due to a limitation added in 8.1 the ui thread can't re-enter the main - // native event dispatcher in MetroAppShell. So all events delivered to us - // on the ui thread via a native event dispatch call get bounced through - // the goanna thread event queue using runnables. Most events can be sent - // async without the need to see the status result. Those that do have - // specialty callbacks. Note any event that arrives to us on the ui thread - // that originates from another thread is safe to send sync. - - // Async event dispatching - void DispatchAsyncEventIgnoreStatus(WidgetInputEvent* aEvent); - void DispatchAsyncTouchEvent(WidgetTouchEvent* aEvent); - - // Async event callbacks - void DeliverNextQueuedEventIgnoreStatus(); - void DeliverNextQueuedTouchEvent(); - - void HandleTouchStartEvent(WidgetTouchEvent* aEvent); - void HandleFirstTouchMoveEvent(WidgetTouchEvent* aEvent); - void SendPointerCancelToContent(const WidgetTouchEvent& aEvent); - bool SendPendingResponseToApz(); - void CancelGesture(); - - // Sync event dispatching - void DispatchEventIgnoreStatus(WidgetGUIEvent* aEvent); - - nsDeque mInputEventQueue; - mozilla::layers::ScrollableLayerGuid mTargetAPZCGuid; - uint64_t mInputBlockId; - static nsEventStatus sThrowawayStatus; -}; - -} } } diff --git a/widget/windows/winrt/MetroUIUtils.js b/widget/windows/winrt/MetroUIUtils.js deleted file mode 100644 index 372e4bc14..000000000 --- a/widget/windows/winrt/MetroUIUtils.js +++ /dev/null @@ -1,175 +0,0 @@ -/* 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/. */ - -const Cc = Components.classes; -const Ci = Components.interfaces; -const Cu = Components.utils; -const Cr = Components.results; - -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); - -function MetroUIUtils() { -} - -const URLElements = { - "a": "href", - "applet": ["archive", "code", "codebase"], - "area": "href", - "audio": "src", - "base": "href", - "blockquote": ["cite"], - "body": "background", - "button": "formaction", - "command": "icon", - "del": ["cite"], - "embed": "src", - "form": "action", - "frame": ["longdesc", "src"], - "iframe": ["longdesc", "src"], - "img": ["longdesc", "src"], - "input": ["formaction", "src"], - "ins": ["cite"], - "link": "href", - "object": ["archive", "codebase", "data"], - "q": ["cite"], - "script": "src", - "source": "src", -}; - -MetroUIUtils.prototype = { - classID : Components.ID("e4626085-17f7-4068-a225-66c1acc0485c"), - QueryInterface : XPCOMUtils.generateQI([Ci.nsIMetroUIUtils]), - /** - * Loads the specified panel in the browser. - * @ param aPanelId The identifier of the pane to load - */ - showPanel: function(aPanelId) { - let browserWin = Services.wm.getMostRecentWindow("navigator:browser"); - browserWin.PanelUI.show(aPanelId); - }, - - /** - * Determines if the browser has selected content - */ - get hasSelectedContent() { - try { - let browserWin = Services.wm.getMostRecentWindow("navigator:browser"); - let tabBrowser = browserWin.getBrowser(); - if (!browserWin || !tabBrowser || !tabBrowser.contentWindow) { - return false; - } - - let sel = tabBrowser.contentWindow.getSelection(); - return sel && sel.toString(); - } catch(e) { - return false; - } - }, - - /** - * Obtains the current page title - */ - get currentPageTitle() { - let browserWin = Services.wm.getMostRecentWindow("navigator:browser"); - if (!browserWin || !browserWin.content || !browserWin.content.document) { - throw Cr.NS_ERROR_FAILURE; - } - return browserWin.content.document.title || ""; - }, - - /** - * Obtains the current page URI - */ - get currentPageURI() { - let browserWin = Services.wm.getMostRecentWindow("navigator:browser"); - if (!browserWin || !browserWin.content || !browserWin.content.document) { - throw Cr.NS_ERROR_FAILURE; - } - return browserWin.content.document.URL || ""; - }, - - /** - * Determines the text that should be shared - */ - get shareText() { - let browserWin = Services.wm.getMostRecentWindow("navigator:browser"); - let tabBrowser = browserWin.getBrowser(); - if (browserWin && tabBrowser && tabBrowser.contentWindow) { - let sel = tabBrowser.contentWindow.getSelection(); - if (sel && sel.rangeCount) - return sel; - } - - throw Cr.NS_ERROR_FAILURE; - }, - - /** - * Replaces the node's attribute value to be a fully qualified URL - */ - _expandAttribute : function(ioService, doc, node, attrName) { - let attrValue = node.getAttribute(attrName); - if (!attrValue) - return; - - try { - let uri = ioService.newURI(attrValue, null, doc.baseURIObject); - node.setAttribute(attrName, uri.spec); - } catch (e) { - } - }, - - /* - * Replaces all attribute values in 'n' which contain URLs recursiely - * to fully qualified URLs. - */ - _expandURLs: function(doc, n) { - let ioService = Cc["@mozilla.org/network/io-service;1"]. - getService(Ci.nsIIOService); - for (let i = 0; i < n.children.length; i++) { - let child = n.children[i]; - let childTagName = child.tagName.toLowerCase(); - - // Iterate through all known tags which can contain URLs. A tag either - // contains a single attribute name or an array of attribute names. - for (let tagName in URLElements) { - if (tagName === childTagName) { - if (URLElements[tagName] instanceof Array) { - URLElements[tagName].forEach(function(attrName) { - this._expandAttribute(ioService ,doc, child, attrName); - }, this); - } else { - this._expandAttribute(ioService ,doc, child, URLElements[tagName]); - } - } - } - - this._expandURLs(doc, child); - } - }, - - /** - * Determines the HTML that should be shared - */ - get shareHTML() { - let browserWin = Services.wm.getMostRecentWindow("navigator:browser"); - let tabBrowser = browserWin.getBrowser(); - let sel; - if (browserWin && tabBrowser && tabBrowser.contentWindow && - (sel = tabBrowser.contentWindow.getSelection()) && sel.rangeCount) { - let div = tabBrowser.contentWindow.document.createElement("DIV"); - for (let i = 0; i < sel.rangeCount; i++) { - let contents = sel.getRangeAt(i).cloneContents(true); - div.appendChild(contents); - } - this._expandURLs(tabBrowser.contentWindow.document, div); - return div.outerHTML; - } - - throw Cr.NS_ERROR_FAILURE; - } -}; - -var component = [MetroUIUtils]; -this.NSGetFactory = XPCOMUtils.generateNSGetFactory(component); diff --git a/widget/windows/winrt/MetroUIUtils.manifest b/widget/windows/winrt/MetroUIUtils.manifest deleted file mode 100644 index 48620c9d9..000000000 --- a/widget/windows/winrt/MetroUIUtils.manifest +++ /dev/null @@ -1,3 +0,0 @@ -# MetroUIUtils.js -component {e4626085-17f7-4068-a225-66c1acc0485c} MetroUIUtils.js -contract @mozilla.org/metro-ui-utils;1 {e4626085-17f7-4068-a225-66c1acc0485c} diff --git a/widget/windows/winrt/MetroUtils.cpp b/widget/windows/winrt/MetroUtils.cpp deleted file mode 100644 index e6731b44c..000000000 --- a/widget/windows/winrt/MetroUtils.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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 "MetroUtils.h" -#include -#include "nsICommandLineRunner.h" -#include "nsNetUtil.h" -#include "nsIBrowserDOMWindow.h" -#include "nsIWebNavigation.h" -#include "nsIDocShellTreeItem.h" -#include "nsIDOMWindow.h" -#include "nsIDOMChromeWindow.h" -#include "nsIWindowMediator.h" -#include "nsIURI.h" -#include "prlog.h" -#include "nsIObserverService.h" -#include "nsRect.h" - -#include -#include -#include -#include "DisplayInfo_sdk81.h" - -using namespace ABI::Windows::UI::ApplicationSettings; - -using namespace mozilla; - -using namespace ABI::Windows::Foundation; -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; -using namespace ABI::Windows::UI::ViewManagement; -using namespace ABI::Windows::Graphics::Display; - -// Conversion between logical and physical coordinates - -double -MetroUtils::LogToPhysFactor() -{ - ComPtr dispInfoStatics; - if (SUCCEEDED(GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayInformation).Get(), - dispInfoStatics.GetAddressOf()))) { - ComPtr dispInfo; - if (SUCCEEDED(dispInfoStatics->GetForCurrentView(&dispInfo))) { - FLOAT dpi; - if (SUCCEEDED(dispInfo->get_LogicalDpi(&dpi))) { - return (double)dpi / 96.0f; - } - } - } - - ComPtr dispProps; - if (SUCCEEDED(GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayProperties).Get(), - dispProps.GetAddressOf()))) { - FLOAT dpi; - if (SUCCEEDED(dispProps->get_LogicalDpi(&dpi))) { - return (double)dpi / 96.0f; - } - } - - return 1.0; -} - -double -MetroUtils::PhysToLogFactor() -{ - return 1.0 / LogToPhysFactor(); -} - -double -MetroUtils::ScaleFactor() -{ - // Return the resolution scale factor reported by the metro environment. - // XXX TODO: also consider the desktop resolution setting, as IE appears to do? - ComPtr dispInfoStatics; - if (SUCCEEDED(GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayInformation).Get(), - dispInfoStatics.GetAddressOf()))) { - ComPtr dispInfo; - if (SUCCEEDED(dispInfoStatics->GetForCurrentView(&dispInfo))) { - ResolutionScale scale; - if (SUCCEEDED(dispInfo->get_ResolutionScale(&scale))) { - return (double)scale / 100.0; - } - } - } - - ComPtr dispProps; - if (SUCCEEDED(GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayProperties).Get(), - dispProps.GetAddressOf()))) { - ResolutionScale scale; - if (SUCCEEDED(dispProps->get_ResolutionScale(&scale))) { - return (double)scale / 100.0; - } - } - - return 1.0; -} - -nsIntPoint -MetroUtils::LogToPhys(const Point& aPt) -{ - double factor = LogToPhysFactor(); - return nsIntPoint(int32_t(NS_round(aPt.X * factor)), int32_t(NS_round(aPt.Y * factor))); -} - -nsIntRect -MetroUtils::LogToPhys(const Rect& aRect) -{ - double factor = LogToPhysFactor(); - return nsIntRect(int32_t(NS_round(aRect.X * factor)), - int32_t(NS_round(aRect.Y * factor)), - int32_t(NS_round(aRect.Width * factor)), - int32_t(NS_round(aRect.Height * factor))); -} - -Point -MetroUtils::PhysToLog(const nsIntPoint& aPt) -{ - // Points contain FLOATs - FLOAT factor = (FLOAT)PhysToLogFactor(); - Point p = { FLOAT(aPt.x) * factor, FLOAT(aPt.y) * factor }; - return p; -} - -nsresult -MetroUtils::FireObserver(const char* aMessage, const char16_t* aData) -{ - nsCOMPtr observerService = - mozilla::services::GetObserverService(); - if (observerService) { - return observerService->NotifyObservers(nullptr, aMessage, aData); - } - return NS_ERROR_FAILURE; -} - -HRESULT MetroUtils::CreateUri(HSTRING aUriStr, ComPtr& aUriOut) -{ - HRESULT hr; - ComPtr uriFactory; - hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Foundation_Uri).Get(), &uriFactory); - AssertRetHRESULT(hr, hr); - ComPtr uri; - return uriFactory->CreateUri(aUriStr, &aUriOut); -} - -HRESULT MetroUtils::CreateUri(HString& aHString, ComPtr& aUriOut) -{ - return MetroUtils::CreateUri(aHString.Get(), aUriOut); -} - -HRESULT -MetroUtils::GetViewState(ApplicationViewState& aState) -{ - HRESULT hr; - ComPtr appViewStatics; - hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_ViewManagement_ApplicationView).Get(), - appViewStatics.GetAddressOf()); - AssertRetHRESULT(hr, hr); - hr = appViewStatics->get_Value(&aState); - return hr; -} - -HRESULT -MetroUtils::TryUnsnap(bool* aResult) -{ - HRESULT hr; - ComPtr appViewStatics; - hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_ViewManagement_ApplicationView).Get(), - appViewStatics.GetAddressOf()); - AssertRetHRESULT(hr, hr); - boolean success = false; - hr = appViewStatics->TryUnsnap(&success); - if (aResult) - *aResult = success; - return hr; -} - -HRESULT -MetroUtils::ShowSettingsFlyout() -{ - ComPtr settingsPaneStatics; - HRESULT hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_ApplicationSettings_SettingsPane).Get(), - settingsPaneStatics.GetAddressOf()); - if (SUCCEEDED(hr)) { - settingsPaneStatics->Show(); - } - - return hr; -} diff --git a/widget/windows/winrt/MetroUtils.h b/widget/windows/winrt/MetroUtils.h deleted file mode 100644 index ec1b650db..000000000 --- a/widget/windows/winrt/MetroUtils.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#pragma once - -#include "nsDebug.h" -#include "nsThreadUtils.h" -#include "nsString.h" -#include "nsPoint.h" -#include "WinUtils.h" - -#include "mozwrlbase.h" - -#include -#include -#include - -// HRESULT checkers, these warn on failure in debug builds -#ifdef DEBUG -#define DebugLogHR(hr) LogHRESULT(hr) -#else -#define DebugLogHR(hr) -#endif -#define AssertHRESULT(hr) \ - if (FAILED(hr)) { \ - DebugLogHR(hr); \ - return; \ - } -#define AssertRetHRESULT(hr, res) \ - if (FAILED(hr)) { \ - DebugLogHR(hr); \ - return res; \ - } - -// MS Point helpers -#define POINT_CEIL_X(position) (uint32_t)ceil(position.X) -#define POINT_CEIL_Y(position) (uint32_t)ceil(position.Y) - -class nsIBrowserDOMWindow; -class nsIDOMWindow; -struct nsIntRect; - -namespace mozilla { -namespace widget { -namespace winrt { - -template -HRESULT ActivateGenericInstance(wchar_t const (&RuntimeClassName)[size], Microsoft::WRL::ComPtr& aOutObject) { - Microsoft::WRL::ComPtr factory; - HRESULT hr = ABI::Windows::Foundation::GetActivationFactory(Microsoft::WRL::Wrappers::HStringReference(RuntimeClassName).Get(), - factory.GetAddressOf()); - if (FAILED(hr)) - return hr; - Microsoft::WRL::ComPtr inspect; - hr = factory->ActivateInstance(inspect.GetAddressOf()); - if (FAILED(hr)) - return hr; - return inspect.As(&aOutObject); -} - -} } } - -class MetroUtils -{ - typedef ABI::Windows::Foundation::IUriRuntimeClass IUriRuntimeClass; - typedef Microsoft::WRL::Wrappers::HString HString; - typedef ABI::Windows::UI::ViewManagement::ApplicationViewState ApplicationViewState; - typedef ABI::Windows::Foundation::Point Point; - typedef ABI::Windows::Foundation::Rect Rect; - -public: - // Functions to convert between logical pixels as used by most Windows APIs - // and physical (device) pixels. - static double LogToPhysFactor(); - static double PhysToLogFactor(); - static nsIntPoint LogToPhys(const Point& aPt); - static nsIntRect LogToPhys(const Rect& aRect); - static Point PhysToLog(const nsIntPoint& aPt); - - // Resolution scale factor - static double ScaleFactor(); - - static nsresult FireObserver(const char* aMessage, const char16_t* aData = nullptr); - - static HRESULT CreateUri(HSTRING aUriStr, Microsoft::WRL::ComPtr& aUriOut); - static HRESULT CreateUri(HString& aHString, Microsoft::WRL::ComPtr& aUriOut); - static HRESULT GetViewState(ApplicationViewState& aState); - static HRESULT TryUnsnap(bool* aResult = nullptr); - static HRESULT ShowSettingsFlyout(); - -private: - static nsresult GetBrowserDOMWindow(nsCOMPtr &aBWin); - static nsresult GetMostRecentWindow(const char16_t* aType, nsIDOMWindow** aWindow); -}; diff --git a/widget/windows/winrt/MetroWidget.cpp b/widget/windows/winrt/MetroWidget.cpp deleted file mode 100644 index 8312d791d..000000000 --- a/widget/windows/winrt/MetroWidget.cpp +++ /dev/null @@ -1,1626 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; 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/. */ - -#include "ContentHelper.h" -#include "MetroWidget.h" -#include "MetroApp.h" -#include "mozilla/Preferences.h" -#include "nsToolkit.h" -#include "KeyboardLayout.h" -#include "MetroUtils.h" -#include "WinUtils.h" -#include "nsToolkitCompsCID.h" -#include "nsIAppStartup.h" -#include "../resource.h" -#include "nsIWidgetListener.h" -#include "nsIPresShell.h" -#include "nsPrintfCString.h" -#include "nsWindowDefs.h" -#include "FrameworkView.h" -#include "nsTextStore.h" -#include "Layers.h" -#include "ClientLayerManager.h" -#include "BasicLayers.h" -#include "FrameMetrics.h" -#include -#include "Windows.Graphics.Display.h" -#include "DisplayInfo_sdk81.h" -#include "nsNativeDragTarget.h" -#include "UIABridgePrivate.h" -#include "WinMouseScrollHandler.h" -#include "InputData.h" -#include "mozilla/TextEvents.h" -#include "mozilla/TouchEvents.h" -#include "mozilla/MiscEvents.h" -#include "gfxPrefs.h" - -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; - -using namespace mozilla; -using namespace mozilla::widget; -using namespace mozilla::layers; -using namespace mozilla::widget::winrt; - -using namespace ABI::Windows::ApplicationModel; -using namespace ABI::Windows::ApplicationModel::Core; -using namespace ABI::Windows::ApplicationModel::Activation; -using namespace ABI::Windows::UI::Input; -using namespace ABI::Windows::Devices::Input; -using namespace ABI::Windows::UI::Core; -using namespace ABI::Windows::System; -using namespace ABI::Windows::Foundation; -using namespace ABI::Windows::Foundation::Collections; -using namespace ABI::Windows::Graphics::Display; - -#ifdef PR_LOGGING -extern PRLogModuleInfo* gWindowsLog; -#endif - -#if !defined(SM_CONVERTIBLESLATEMODE) -#define SM_CONVERTIBLESLATEMODE 0x2003 -#endif - -static uint32_t gInstanceCount = 0; -const char16_t* kMetroSubclassThisProp = L"MetroSubclassThisProp"; -HWND MetroWidget::sICoreHwnd = nullptr; - -namespace mozilla { -namespace widget { -UINT sDefaultBrowserMsgId = RegisterWindowMessageW(L"DefaultBrowserClosing"); -} } - -// WM_GETOBJECT id pulled from uia headers -#define MOZOBJID_UIAROOT -25 - -namespace mozilla { -namespace widget { -namespace winrt { -extern ComPtr sMetroApp; -extern ComPtr gProviderRoot; -} } } - -namespace { - - void SendInputs(uint32_t aModifiers, INPUT* aExtraInputs, uint32_t aExtraInputsLen) - { - // keySequence holds the virtual key values of each of the keys we intend - // to press - nsAutoTArray keySequence; - for (uint32_t i = 0; i < ArrayLength(sModifierKeyMap); ++i) { - const uint32_t* map = sModifierKeyMap[i]; - if (aModifiers & map[0]) { - keySequence.AppendElement(KeyPair(map[1], map[2])); - } - } - - uint32_t const len = keySequence.Length() * 2 + aExtraInputsLen; - - // The `inputs` array is a sequence of input events that will happen - // serially. We set the array up so that each modifier key is pressed - // down, then the additional input events happen, - // then each modifier key is released in reverse order of when - // it was pressed down. We pass this array to `SendInput`. - // - // inputs[0]: modifier key (e.g. shift, ctrl, etc) down - // ... ... - // inputs[keySequence.Length()-1]: modifier key (e.g. shift, ctrl, etc) down - // inputs[keySequence.Length()]: aExtraInputs[0] - // inputs[keySequence.Length()+1]: aExtraInputs[1] - // ... ... - // inputs[keySequence.Length() + aExtraInputsLen - 1]: aExtraInputs[aExtraInputsLen - 1] - // inputs[keySequence.Length() + aExtraInputsLen]: modifier key (e.g. shift, ctrl, etc) up - // ... ... - // inputs[len-1]: modifier key (e.g. shift, ctrl, etc) up - INPUT* inputs = new INPUT[len]; - memset(inputs, 0, len * sizeof(INPUT)); - for (uint32_t i = 0; i < keySequence.Length(); ++i) { - inputs[i].type = inputs[len-i-1].type = INPUT_KEYBOARD; - inputs[i].ki.wVk = inputs[len-i-1].ki.wVk = keySequence[i].mSpecific - ? keySequence[i].mSpecific - : keySequence[i].mGeneral; - inputs[len-i-1].ki.dwFlags |= KEYEVENTF_KEYUP; - } - for (uint32_t i = 0; i < aExtraInputsLen; i++) { - inputs[keySequence.Length()+i] = aExtraInputs[i]; - } - WinUtils::Log(" Sending inputs"); - for (uint32_t i = 0; i < len; i++) { - if (inputs[i].type == INPUT_KEYBOARD) { - WinUtils::Log(" Key press: 0x%x %s", - inputs[i].ki.wVk, - inputs[i].ki.dwFlags & KEYEVENTF_KEYUP - ? "UP" - : "DOWN"); - } else if(inputs[i].type == INPUT_MOUSE) { - WinUtils::Log(" Mouse input: 0x%x 0x%x", - inputs[i].mi.dwFlags, - inputs[i].mi.mouseData); - } else { - WinUtils::Log(" Unknown input type!"); - } - } - ::SendInput(len, inputs, sizeof(INPUT)); - delete[] inputs; - - // The inputs have been sent, and the WM_* messages they generate are - // waiting to be processed by our event loop. Now we manually pump - // those messages so that, upon our return, all the inputs have been - // processed. - WinUtils::Log(" Inputs sent. Waiting for input messages to clear"); - MSG msg; - while (WinUtils::PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) { - if (nsTextStore::ProcessRawKeyMessage(msg)) { - continue; // the message is consumed by TSF - } - ::TranslateMessage(&msg); - ::DispatchMessage(&msg); - WinUtils::Log(" Dispatched 0x%x 0x%x 0x%x", msg.message, msg.wParam, msg.lParam); - } - WinUtils::Log(" No more input messages"); - } -} - -NS_IMPL_ISUPPORTS_INHERITED0(MetroWidget, nsBaseWidget) - -MetroWidget::MetroWidget() : - mTransparencyMode(eTransparencyOpaque), - mWnd(nullptr), - mMetroWndProc(nullptr), - mTempBasicLayerInUse(false), - mRootLayerTreeId(), - nsWindowBase() -{ - // Global initialization - if (!gInstanceCount) { - UserActivity(); - nsTextStore::Initialize(); - MouseScrollHandler::Initialize(); - KeyboardLayout::GetInstance()->OnLayoutChange(::GetKeyboardLayout(0)); - } // !gInstanceCount - gInstanceCount++; -} - -MetroWidget::~MetroWidget() -{ - LogThis(); - - gInstanceCount--; - - // Global shutdown - if (!gInstanceCount) { - APZController::sAPZC = nullptr; - nsTextStore::Terminate(); - } // !gInstanceCount -} - -static bool gTopLevelAssigned = false; -NS_IMETHODIMP -MetroWidget::Create(nsIWidget *aParent, - nsNativeWidget aNativeParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData) -{ - LogFunction(); - - nsWidgetInitData defaultInitData; - if (!aInitData) - aInitData = &defaultInitData; - - mWindowType = aInitData->mWindowType; - - // Ensure that the toolkit is created. - nsToolkit::GetToolkit(); - - BaseCreate(aParent, aRect, aInitData); - - if (mWindowType != eWindowType_toplevel) { - switch(mWindowType) { - case eWindowType_dialog: - WinUtils::Log("eWindowType_dialog window requested, returning failure."); - break; - case eWindowType_child: - WinUtils::Log("eWindowType_child window requested, returning failure."); - break; - case eWindowType_popup: - WinUtils::Log("eWindowType_popup window requested, returning failure."); - break; - case eWindowType_plugin: - WinUtils::Log("eWindowType_plugin window requested, returning failure."); - break; - // we should support toolkit's eWindowType_invisible at some point. - case eWindowType_invisible: - WinUtils::Log("eWindowType_invisible window requested, this doesn't actually exist!"); - return NS_OK; - } - NS_WARNING("Invalid window type requested."); - return NS_ERROR_FAILURE; - } - - if (gTopLevelAssigned) { - // Need to accept so that the mochitest-chrome test harness window - // can be created. - NS_WARNING("New eWindowType_toplevel window requested after FrameworkView widget created."); - NS_WARNING("Widget created but the physical window does not exist! Fix me!"); - return NS_OK; - } - - // the main widget gets created first - gTopLevelAssigned = true; - sMetroApp->SetWidget(this); - WinUtils::SetNSWindowBasePtr(mWnd, this); - - if (mWidgetListener) { - mWidgetListener->WindowActivated(); - } - - return NS_OK; -} - -void -MetroWidget::SetView(FrameworkView* aView) -{ - mView = aView; - // If we've already set this up, it points to a useless - // layer manager, so reset it. - mLayerManager = nullptr; -} - -NS_IMETHODIMP -MetroWidget::Destroy() -{ - if (mOnDestroyCalled) - return NS_OK; - WinUtils::Log("[%X] %s mWnd=%X type=%d", this, __FUNCTION__, mWnd, mWindowType); - mOnDestroyCalled = true; - - nsCOMPtr kungFuDeathGrip(this); - - if (ShouldUseAPZC()) { - nsresult rv; - nsCOMPtr observerService = do_GetService("@mozilla.org/observer-service;1", &rv); - if (NS_SUCCEEDED(rv)) { - observerService->RemoveObserver(this, "apzc-scroll-offset-changed"); - observerService->RemoveObserver(this, "apzc-zoom-to-rect"); - observerService->RemoveObserver(this, "apzc-disable-zoom"); - } - } - - RemoveSubclass(); - NotifyWindowDestroyed(); - - // Prevent the widget from sending additional events. - mWidgetListener = nullptr; - mAttachedWidgetListener = nullptr; - - // Release references to children, device context, toolkit, and app shell. - nsBaseWidget::Destroy(); - nsBaseWidget::OnDestroy(); - WinUtils::SetNSWindowBasePtr(mWnd, nullptr); - - if (mLayerManager) { - mLayerManager->Destroy(); - } - - mLayerManager = nullptr; - mView = nullptr; - mIdleService = nullptr; - mWnd = nullptr; - - return NS_OK; -} - -NS_IMETHODIMP -MetroWidget::SetParent(nsIWidget *aNewParent) -{ - return NS_OK; -} - -NS_IMETHODIMP -MetroWidget::Show(bool bState) -{ - return NS_OK; -} - -uint32_t -MetroWidget::GetMaxTouchPoints() const -{ - ComPtr deviceStatics; - - HRESULT hr = GetActivationFactory( - HStringReference(RuntimeClass_Windows_Devices_Input_PointerDevice).Get(), - deviceStatics.GetAddressOf()); - - if (FAILED(hr)) { - return 0; - } - - ComPtr< IVectorView > deviceList; - hr = deviceStatics->GetPointerDevices(&deviceList); - - if (FAILED(hr)) { - return 0; - } - - uint32_t deviceNum = 0; - deviceList->get_Size(&deviceNum); - - uint32_t maxTouchPoints = 0; - for (uint32_t index = 0; index < deviceNum; ++index) { - ComPtr device; - PointerDeviceType deviceType; - - if (FAILED(deviceList->GetAt(index, device.GetAddressOf()))) { - continue; - } - - if (FAILED(device->get_PointerDeviceType(&deviceType))) { - continue; - } - - if (deviceType == PointerDeviceType_Touch) { - uint32_t deviceMaxTouchPoints = 0; - device->get_MaxContacts(&deviceMaxTouchPoints); - maxTouchPoints = std::max(maxTouchPoints, deviceMaxTouchPoints); - } - } - - return maxTouchPoints; -} - -NS_IMETHODIMP -MetroWidget::IsVisible(bool & aState) -{ - aState = mView->IsVisible(); - return NS_OK; -} - -bool -MetroWidget::IsVisible() const -{ - if (!mView) - return false; - return mView->IsVisible(); -} - -NS_IMETHODIMP -MetroWidget::EnableDragDrop(bool aEnable) { - if (aEnable) { - if (nullptr == mNativeDragTarget) { - mNativeDragTarget = new nsNativeDragTarget(this); - if (!mNativeDragTarget) { - return NS_ERROR_FAILURE; - } - } - - HRESULT hr = ::RegisterDragDrop(mWnd, static_cast(mNativeDragTarget)); - return SUCCEEDED(hr) ? NS_OK : NS_ERROR_FAILURE; - } else { - if (nullptr == mNativeDragTarget) { - return NS_OK; - } - - HRESULT hr = ::RevokeDragDrop(mWnd); - return SUCCEEDED(hr) ? NS_OK : NS_ERROR_FAILURE; - } -} - -NS_IMETHODIMP -MetroWidget::IsEnabled(bool *aState) -{ - *aState = mView->IsEnabled(); - return NS_OK; -} - -bool -MetroWidget::IsEnabled() const -{ - if (!mView) - return false; - return mView->IsEnabled(); -} - -NS_IMETHODIMP -MetroWidget::Enable(bool bState) -{ - return NS_OK; -} - -NS_IMETHODIMP -MetroWidget::GetBounds(nsIntRect &aRect) -{ - if (mView) { - mView->GetBounds(aRect); - } else { - nsIntRect rect(0,0,0,0); - aRect = rect; - } - return NS_OK; -} - -NS_IMETHODIMP -MetroWidget::GetScreenBounds(nsIntRect &aRect) -{ - if (mView) { - mView->GetBounds(aRect); - } else { - nsIntRect rect(0,0,0,0); - aRect = rect; - } - return NS_OK; -} - -NS_IMETHODIMP -MetroWidget::GetClientBounds(nsIntRect &aRect) -{ - if (mView) { - mView->GetBounds(aRect); - } else { - nsIntRect rect(0,0,0,0); - aRect = rect; - } - return NS_OK; -} - -NS_IMETHODIMP -MetroWidget::SetCursor(nsCursor aCursor) -{ - if (!mView) - return NS_ERROR_FAILURE; - - switch (aCursor) { - case eCursor_select: - mView->SetCursor(CoreCursorType::CoreCursorType_IBeam); - break; - case eCursor_wait: - mView->SetCursor(CoreCursorType::CoreCursorType_Wait); - break; - case eCursor_hyperlink: - mView->SetCursor(CoreCursorType::CoreCursorType_Hand); - break; - case eCursor_standard: - mView->SetCursor(CoreCursorType::CoreCursorType_Arrow); - break; - case eCursor_n_resize: - case eCursor_s_resize: - mView->SetCursor(CoreCursorType::CoreCursorType_SizeNorthSouth); - break; - case eCursor_w_resize: - case eCursor_e_resize: - mView->SetCursor(CoreCursorType::CoreCursorType_SizeWestEast); - break; - case eCursor_nw_resize: - case eCursor_se_resize: - mView->SetCursor(CoreCursorType::CoreCursorType_SizeNorthwestSoutheast); - break; - case eCursor_ne_resize: - case eCursor_sw_resize: - mView->SetCursor(CoreCursorType::CoreCursorType_SizeNortheastSouthwest); - break; - case eCursor_crosshair: - mView->SetCursor(CoreCursorType::CoreCursorType_Cross); - break; - case eCursor_move: - mView->SetCursor(CoreCursorType::CoreCursorType_SizeAll); - break; - case eCursor_help: - mView->SetCursor(CoreCursorType::CoreCursorType_Help); - break; - // CSS3 custom cursors - case eCursor_copy: - mView->SetCursor(CoreCursorType::CoreCursorType_Custom, IDC_COPY); - break; - case eCursor_alias: - mView->SetCursor(CoreCursorType::CoreCursorType_Custom, IDC_ALIAS); - break; - case eCursor_cell: - mView->SetCursor(CoreCursorType::CoreCursorType_Custom, IDC_CELL); - break; - case eCursor_grab: - mView->SetCursor(CoreCursorType::CoreCursorType_Custom, IDC_GRAB); - break; - case eCursor_grabbing: - mView->SetCursor(CoreCursorType::CoreCursorType_Custom, IDC_GRABBING); - break; - case eCursor_spinning: - mView->SetCursor(CoreCursorType::CoreCursorType_Wait); - break; - case eCursor_context_menu: - mView->SetCursor(CoreCursorType::CoreCursorType_Arrow); - break; - case eCursor_zoom_in: - mView->SetCursor(CoreCursorType::CoreCursorType_Custom, IDC_ZOOMIN); - break; - case eCursor_zoom_out: - mView->SetCursor(CoreCursorType::CoreCursorType_Custom, IDC_ZOOMOUT); - break; - case eCursor_not_allowed: - case eCursor_no_drop: - mView->SetCursor(CoreCursorType::CoreCursorType_UniversalNo); - break; - case eCursor_col_resize: - mView->SetCursor(CoreCursorType::CoreCursorType_Custom, IDC_COLRESIZE); - break; - case eCursor_row_resize: - mView->SetCursor(CoreCursorType::CoreCursorType_Custom, IDC_ROWRESIZE); - break; - case eCursor_vertical_text: - mView->SetCursor(CoreCursorType::CoreCursorType_Custom, IDC_VERTICALTEXT); - break; - case eCursor_all_scroll: - mView->SetCursor(CoreCursorType::CoreCursorType_SizeAll); - break; - case eCursor_nesw_resize: - mView->SetCursor(CoreCursorType::CoreCursorType_SizeNortheastSouthwest); - break; - case eCursor_nwse_resize: - mView->SetCursor(CoreCursorType::CoreCursorType_SizeNorthwestSoutheast); - break; - case eCursor_ns_resize: - mView->SetCursor(CoreCursorType::CoreCursorType_SizeNorthSouth); - break; - case eCursor_ew_resize: - mView->SetCursor(CoreCursorType::CoreCursorType_SizeWestEast); - break; - case eCursor_none: - mView->ClearCursor(); - break; - default: - NS_WARNING("Invalid cursor type"); - break; - } - return NS_OK; -} - -nsresult -MetroWidget::SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout, - int32_t aNativeKeyCode, - uint32_t aModifierFlags, - const nsAString& aCharacters, - const nsAString& aUnmodifiedCharacters) -{ - KeyboardLayout* keyboardLayout = KeyboardLayout::GetInstance(); - return keyboardLayout->SynthesizeNativeKeyEvent( - this, aNativeKeyboardLayout, aNativeKeyCode, aModifierFlags, - aCharacters, aUnmodifiedCharacters); -} - -nsresult -MetroWidget::SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint, - uint32_t aNativeMessage, - uint32_t aModifierFlags) -{ - WinUtils::Log("ENTERED SynthesizeNativeMouseEvent"); - - INPUT inputs[2]; - memset(inputs, 0, 2*sizeof(INPUT)); - inputs[0].type = inputs[1].type = INPUT_MOUSE; - inputs[0].mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE; - // Inexplicably, the x and y coordinates that we want to move the mouse to - // are specified as values in the range (0, 65535). (0,0) represents the - // top left of the primary monitor and (65535, 65535) represents the - // bottom right of the primary monitor. - inputs[0].mi.dx = (aPoint.x * 65535) / ::GetSystemMetrics(SM_CXSCREEN); - inputs[0].mi.dy = (aPoint.y * 65535) / ::GetSystemMetrics(SM_CYSCREEN); - inputs[1].mi.dwFlags = aNativeMessage; - SendInputs(aModifierFlags, inputs, 2); - - WinUtils::Log("Exiting SynthesizeNativeMouseEvent"); - return NS_OK; -} - -nsresult -MetroWidget::SynthesizeNativeMouseScrollEvent(LayoutDeviceIntPoint aPoint, - uint32_t aNativeMessage, - double aDeltaX, - double aDeltaY, - double aDeltaZ, - uint32_t aModifierFlags, - uint32_t aAdditionalFlags) -{ - return MouseScrollHandler::SynthesizeNativeMouseScrollEvent( - this, aPoint, aNativeMessage, - (aNativeMessage == WM_MOUSEWHEEL || aNativeMessage == WM_VSCROLL) ? - static_cast(aDeltaY) : static_cast(aDeltaX), - aModifierFlags, aAdditionalFlags); -} - -static void -CloseGesture() -{ - LogFunction(); - nsCOMPtr appStartup = - do_GetService(NS_APPSTARTUP_CONTRACTID); - if (appStartup) { - appStartup->Quit(nsIAppStartup::eForceQuit); - } -} - -// Async event sending for mouse and keyboard input. - -// defined in nsWindowBase, called from shared module WinMouseScrollHandler. -bool -MetroWidget::DispatchScrollEvent(mozilla::WidgetGUIEvent* aEvent) -{ - WidgetGUIEvent* newEvent = nullptr; - switch(aEvent->mClass) { - case eWheelEventClass: - { - WidgetWheelEvent* oldEvent = aEvent->AsWheelEvent(); - WidgetWheelEvent* wheelEvent = - new WidgetWheelEvent(oldEvent->mFlags.mIsTrusted, oldEvent->message, oldEvent->widget); - wheelEvent->AssignWheelEventData(*oldEvent, true); - newEvent = static_cast(wheelEvent); - } - break; - case eContentCommandEventClass: - { - WidgetContentCommandEvent* oldEvent = aEvent->AsContentCommandEvent(); - WidgetContentCommandEvent* cmdEvent = - new WidgetContentCommandEvent(oldEvent->mFlags.mIsTrusted, oldEvent->message, oldEvent->widget); - cmdEvent->AssignContentCommandEventData(*oldEvent, true); - newEvent = static_cast(cmdEvent); - } - break; - default: - MOZ_CRASH("unknown event in DispatchScrollEvent"); - break; - } - mEventQueue.Push(newEvent); - nsCOMPtr runnable = - NS_NewRunnableMethod(this, &MetroWidget::DeliverNextScrollEvent); - NS_DispatchToCurrentThread(runnable); - return false; -} - -void -MetroWidget::DeliverNextScrollEvent() -{ - WidgetGUIEvent* event = - static_cast(mEventQueue.PopFront()); - DispatchWindowEvent(event); - delete event; -} - -// defined in nsWindowBase, called from shared module KeyboardLayout. -bool -MetroWidget::DispatchKeyboardEvent(WidgetGUIEvent* aEvent) -{ - MOZ_ASSERT(aEvent); - WidgetKeyboardEvent* oldKeyEvent = aEvent->AsKeyboardEvent(); - WidgetKeyboardEvent* keyEvent = - new WidgetKeyboardEvent(oldKeyEvent->mFlags.mIsTrusted, - oldKeyEvent->message, oldKeyEvent->widget); - // XXX note this leaves pluginEvent null, which is fine for now. - keyEvent->AssignKeyEventData(*oldKeyEvent, true); - mKeyEventQueue.Push(keyEvent); - nsCOMPtr runnable = - NS_NewRunnableMethod(this, &MetroWidget::DeliverNextKeyboardEvent); - NS_DispatchToCurrentThread(runnable); - return false; -} - -// Used in conjunction with mKeyEventQueue to find a keypress event -// that should not be delivered due to the return result of the -// preceeding keydown. -class KeyQueryIdAndCancel : public nsDequeFunctor { -public: - KeyQueryIdAndCancel(uint32_t aIdToCancel) : - mId(aIdToCancel) { - } - virtual void* operator() (void* aObject) { - WidgetKeyboardEvent* event = static_cast(aObject); - if (event->mUniqueId == mId) { - event->mFlags.mPropagationStopped = true; - } - return nullptr; - } -protected: - uint32_t mId; -}; - -void -MetroWidget::DeliverNextKeyboardEvent() -{ - WidgetKeyboardEvent* event = - static_cast(mKeyEventQueue.PopFront()); - if (event->mFlags.mPropagationStopped) { - // This can happen if a keypress was previously cancelled. - delete event; - return; - } - - if (DispatchWindowEvent(event) && event->message == NS_KEY_DOWN) { - // keydown events may be followed by multiple keypress events which - // shouldn't be sent if preventDefault is called on keydown. - KeyQueryIdAndCancel query(event->mUniqueId); - mKeyEventQueue.ForEach(query); - } - delete event; -} - -// static -LRESULT CALLBACK -MetroWidget::StaticWindowProcedure(HWND aWnd, UINT aMsg, WPARAM aWParam, LPARAM aLParam) -{ - MetroWidget* self = reinterpret_cast( - GetProp(aWnd, kMetroSubclassThisProp)); - if (!self) { - NS_NOTREACHED("Missing 'this' prop on subclassed metro window, this is bad."); - return 0; - } - return self->WindowProcedure(aWnd, aMsg, aWParam, aLParam); -} - -LRESULT -MetroWidget::WindowProcedure(HWND aWnd, UINT aMsg, WPARAM aWParam, LPARAM aLParam) -{ - if(sDefaultBrowserMsgId == aMsg) { - CloseGesture(); - } else if (WM_SETTINGCHANGE == aMsg) { - if (aLParam && !wcsicmp(L"ConvertibleSlateMode", (wchar_t*)aLParam)) { - // If we're switching away from slate mode, switch to Desktop for - // hardware that supports this feature if the pref is set. - if (GetSystemMetrics(SM_CONVERTIBLESLATEMODE) != 0 && - Preferences::GetBool("browser.shell.metro-auto-switch-enabled", - false)) { - nsCOMPtr appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID)); - if (appStartup) { - appStartup->Quit(nsIAppStartup::eForceQuit | nsIAppStartup::eRestart); - } - } - } - } - - // Indicates if we should hand messages to the default windows - // procedure for processing. - bool processDefault = true; - - // The result returned if we do not do default processing. - LRESULT processResult = 0; - - MSGResult msgResult(&processResult); - MouseScrollHandler::ProcessMessage(this, aMsg, aWParam, aLParam, msgResult); - if (msgResult.mConsumed) { - return processResult; - } - - nsTextStore::ProcessMessage(this, aMsg, aWParam, aLParam, msgResult); - if (msgResult.mConsumed) { - return processResult; - } - - switch (aMsg) { - case WM_POWERBROADCAST: - { - switch (aWParam) - { - case PBT_APMSUSPEND: - MetroApp::PostSleepWakeNotification(true); - break; - case PBT_APMRESUMEAUTOMATIC: - case PBT_APMRESUMECRITICAL: - case PBT_APMRESUMESUSPEND: - MetroApp::PostSleepWakeNotification(false); - break; - } - break; - } - - // Keyboard handling is passed to KeyboardLayout, which delivers goanna events - // via DispatchKeyboardEvent. - - case WM_KEYDOWN: - case WM_SYSKEYDOWN: - { - MSG msg = WinUtils::InitMSG(aMsg, aWParam, aLParam, aWnd); - // If this method doesn't call NativeKey::HandleKeyDownMessage(), this - // method must clean up the redirected message information itself. For - // more information, see above comment of - // RedirectedKeyDownMessageManager::AutoFlusher class definition in - // KeyboardLayout.h. - RedirectedKeyDownMessageManager::AutoFlusher - redirectedMsgFlusher(this, msg); - - if (nsTextStore::IsComposingOn(this)) { - break; - } - - ModifierKeyState modKeyState; - NativeKey nativeKey(this, msg, modKeyState); - processDefault = !nativeKey.HandleKeyDownMessage(); - // HandleKeyDownMessage cleaned up the redirected message information - // itself, so, we should do nothing. - redirectedMsgFlusher.Cancel(); - break; - } - - case WM_KEYUP: - case WM_SYSKEYUP: - { - if (nsTextStore::IsComposingOn(this)) { - break; - } - - MSG msg = WinUtils::InitMSG(aMsg, aWParam, aLParam, aWnd); - ModifierKeyState modKeyState; - NativeKey nativeKey(this, msg, modKeyState); - processDefault = !nativeKey.HandleKeyUpMessage(); - break; - } - - case WM_CHAR: - case WM_SYSCHAR: - { - if (nsTextStore::IsComposingOn(this)) { - nsTextStore::CommitComposition(false); - } - - MSG msg = WinUtils::InitMSG(aMsg, aWParam, aLParam, aWnd); - ModifierKeyState modKeyState; - NativeKey nativeKey(this, msg, modKeyState); - processDefault = !nativeKey.HandleCharMessage(msg); - break; - } - - case WM_INPUTLANGCHANGE: - { - KeyboardLayout::GetInstance()-> - OnLayoutChange(reinterpret_cast(aLParam)); - processResult = 1; - break; - } - - case WM_APPCOMMAND: - { - MSG msg = WinUtils::InitMSG(aMsg, aWParam, aLParam, aWnd); - processDefault = HandleAppCommandMsg(msg, &processResult); - break; - } - - case WM_GETOBJECT: - { - DWORD dwObjId = (LPARAM)(DWORD) aLParam; - // Passing this to CallWindowProc can result in a failure due to a timing issue - // in winrt core window server code, so we call it directly here. Also, it's not - // clear Windows::UI::Core::WindowServer::OnAutomationProviderRequestedEvent is - // compatible with metro enabled desktop browsers, it makes an initial call to - // UiaReturnRawElementProvider passing the return result from FrameworkView - // OnAutomationProviderRequested as the hwnd (me scratches head) which results in - // GetLastError always being set to invalid handle (6) after CallWindowProc returns. - if (dwObjId == MOZOBJID_UIAROOT && gProviderRoot) { - ComPtr simple; - gProviderRoot.As(&simple); - if (simple) { - LRESULT res = UiaReturnRawElementProvider(aWnd, aWParam, aLParam, simple.Get()); - if (res) { - return res; - } - NS_ASSERTION(res, "UiaReturnRawElementProvider failed!"); - WinUtils::Log("UiaReturnRawElementProvider failed! GetLastError=%X", GetLastError()); - } - } - break; - } - - default: - { - break; - } - } - - if (processDefault) { - return CallWindowProc(mMetroWndProc, aWnd, aMsg, aWParam, - aLParam); - } - return processResult; -} - -static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) -{ - WCHAR className[56]; - if (GetClassNameW(hwnd, className, sizeof(className)/sizeof(WCHAR)) && - !wcscmp(L"Windows.UI.Core.CoreWindow", className)) { - DWORD processID = 0; - GetWindowThreadProcessId(hwnd, &processID); - if (processID && processID == GetCurrentProcessId()) { - *((HWND*)lParam) = hwnd; - return FALSE; - } - } - return TRUE; -} - -void -MetroWidget::FindMetroWindow() -{ - LogFunction(); - if (mWnd) - return; - EnumWindows(EnumWindowsProc, (LPARAM)&mWnd); - NS_ASSERTION(mWnd, "Couldn't find our metro CoreWindow, this is bad."); - - // subclass it - SetSubclass(); - sICoreHwnd = mWnd; - return; -} - -void -MetroWidget::SetSubclass() -{ - if (!mWnd) { - NS_NOTREACHED("SetSubclass called without a valid hwnd."); - return; - } - - WNDPROC wndProc = reinterpret_cast( - GetWindowLongPtr(mWnd, GWLP_WNDPROC)); - if (wndProc != StaticWindowProcedure) { - if (!SetPropW(mWnd, kMetroSubclassThisProp, this)) { - NS_NOTREACHED("SetProp failed, can't continue."); - return; - } - mMetroWndProc = - reinterpret_cast( - SetWindowLongPtr(mWnd, GWLP_WNDPROC, - reinterpret_cast(StaticWindowProcedure))); - NS_ASSERTION(mMetroWndProc != StaticWindowProcedure, "WTF?"); - } -} - -void -MetroWidget::RemoveSubclass() -{ - if (!mWnd) - return; - WNDPROC wndProc = reinterpret_cast( - GetWindowLongPtr(mWnd, GWLP_WNDPROC)); - if (wndProc == StaticWindowProcedure) { - NS_ASSERTION(mMetroWndProc, "Should have old proc here."); - SetWindowLongPtr(mWnd, GWLP_WNDPROC, - reinterpret_cast(mMetroWndProc)); - mMetroWndProc = nullptr; - } - RemovePropW(mWnd, kMetroSubclassThisProp); -} - -bool -MetroWidget::ShouldUseOffMainThreadCompositing() -{ - // Either we're not initialized yet, or this is the toolkit widget - if (!mView) { - return false; - } - // toolkit or test widgets can't use omtc, they don't have ICoreWindow. - return gfxPlatform::UsesOffMainThreadCompositing() && - mWindowType == eWindowType_toplevel; -} - -bool -MetroWidget::ShouldUseBasicManager() -{ - // toolkit or test widgets fall back on empty shadow layers - return (mWindowType != eWindowType_toplevel); -} - -bool -MetroWidget::ShouldUseAPZC() -{ - return gfxPrefs::AsyncPanZoomEnabled(); -} - -void -MetroWidget::SetWidgetListener(nsIWidgetListener* aWidgetListener) -{ - mWidgetListener = aWidgetListener; -} - -void -MetroWidget::ConfigureAPZCTreeManager() -{ - nsBaseWidget::ConfigureAPZCTreeManager(); - - nsresult rv; - nsCOMPtr observerService = do_GetService("@mozilla.org/observer-service;1", &rv); - if (NS_SUCCEEDED(rv)) { - observerService->AddObserver(this, "apzc-scroll-offset-changed", false); - observerService->AddObserver(this, "apzc-zoom-to-rect", false); - observerService->AddObserver(this, "apzc-disable-zoom", false); - } -} - -already_AddRefed -MetroWidget::CreateRootContentController() -{ - MOZ_ASSERT(!mController); - - mController = new APZController(); - return mController; -} - -MetroWidget::TouchBehaviorFlags -MetroWidget::ContentGetAllowedTouchBehavior(const nsIntPoint& aPoint) -{ - return ContentHelper::GetAllowedTouchBehavior(this, aPoint); -} - -void -MetroWidget::ApzcGetAllowedTouchBehavior(WidgetInputEvent* aTransformedEvent, - nsTArray& aOutBehaviors) -{ - LogFunction(); - return APZController::sAPZC->GetAllowedTouchBehavior(aTransformedEvent, aOutBehaviors); -} - -void -MetroWidget::ApzcSetAllowedTouchBehavior(uint64_t aInputBlockId, - nsTArray& aBehaviors) -{ - LogFunction(); - if (!APZController::sAPZC) { - return; - } - APZController::sAPZC->SetAllowedTouchBehavior(aInputBlockId, aBehaviors); -} - -void -MetroWidget::ApzContentConsumingTouch(uint64_t aInputBlockId) -{ - LogFunction(); - if (!mController) { - return; - } - mController->ContentReceivedInputBlock(aInputBlockId, true); -} - -void -MetroWidget::ApzContentIgnoringTouch(uint64_t aInputBlockId) -{ - LogFunction(); - if (!mController) { - return; - } - mController->ContentReceivedInputBlock(aInputBlockId, false); -} - -bool -MetroWidget::ApzHitTest(ScreenIntPoint& pt) -{ - if (!mController) { - return false; - } - return mController->HitTestAPZC(pt); -} - -void -MetroWidget::ApzTransformGoannaCoordinate(const ScreenIntPoint& aPoint, - LayoutDeviceIntPoint* aRefPointOut) -{ - if (!mController) { - return; - } - mController->TransformCoordinateToGoanna(aPoint, aRefPointOut); -} - -nsEventStatus -MetroWidget::ApzReceiveInputEvent(WidgetInputEvent* aEvent, - ScrollableLayerGuid* aOutTargetGuid, - uint64_t* aOutInputBlockId) -{ - MOZ_ASSERT(aEvent); - - if (!mController) { - return nsEventStatus_eIgnore; - } - return mController->ReceiveInputEvent(aEvent, aOutTargetGuid, aOutInputBlockId); -} - -void -MetroWidget::SetApzPendingResponseFlusher(APZPendingResponseFlusher* aFlusher) -{ - mController->SetPendingResponseFlusher(aFlusher); -} - -LayerManager* -MetroWidget::GetLayerManager(PLayerTransactionChild* aShadowManager, - LayersBackend aBackendHint, - LayerManagerPersistence aPersistence, - bool* aAllowRetaining) -{ - bool retaining = true; - - // If we initialized earlier than the view, recreate the layer manager now - if (mLayerManager && - mTempBasicLayerInUse && - ShouldUseOffMainThreadCompositing()) { - mLayerManager = nullptr; - mTempBasicLayerInUse = false; - retaining = false; - } - - HRESULT hr = S_OK; - - // Create a layer manager: try to use an async compositor first, if enabled. - // Otherwise fall back on the main thread d3d manager. - if (!mLayerManager) { - if (ShouldUseOffMainThreadCompositing()) { - NS_ASSERTION(aShadowManager == nullptr, "Async Compositor not supported with e10s"); - CreateCompositor(); - } else { - mLayerManager = CreateBasicLayerManager(); - } - // Either we're not ready to initialize yet due to a missing view pointer, - // or something has gone wrong. - if (!mLayerManager) { - if (!mView) { - NS_WARNING("Using temporary basic layer manager."); - mLayerManager = new BasicLayerManager(this); - mTempBasicLayerInUse = true; - } else { - NS_RUNTIMEABORT("Couldn't create layer manager"); - } - } - } - - if (aAllowRetaining) { - *aAllowRetaining = retaining; - } - - return mLayerManager; -} - -NS_IMETHODIMP -MetroWidget::Invalidate(bool aEraseBackground, - bool aUpdateNCArea, - bool aIncludeChildren) -{ - nsIntRect rect; - if (mView) { - mView->GetBounds(rect); - } - Invalidate(rect); - return NS_OK; -} - -NS_IMETHODIMP -MetroWidget::Invalidate(const nsIntRect & aRect) -{ - if (mWnd) { - RECT rect; - rect.left = aRect.x; - rect.top = aRect.y; - rect.right = aRect.x + aRect.width; - rect.bottom = aRect.y + aRect.height; - InvalidateRect(mWnd, &rect, FALSE); - } - - return NS_OK; -} - -nsTransparencyMode -MetroWidget::GetTransparencyMode() -{ - return mTransparencyMode; -} - -void -MetroWidget::SetTransparencyMode(nsTransparencyMode aMode) -{ - mTransparencyMode = aMode; -} - -nsIWidgetListener* -MetroWidget::GetPaintListener() -{ - if (mOnDestroyCalled) - return nullptr; - return mAttachedWidgetListener ? mAttachedWidgetListener : - mWidgetListener; -} - -void MetroWidget::Paint(const nsIntRegion& aInvalidRegion) -{ - gfxWindowsPlatform::GetPlatform()->UpdateRenderMode(); - - nsIWidgetListener* listener = GetPaintListener(); - if (!listener) - return; - - listener->WillPaintWindow(this); - - // Refresh since calls like WillPaintWindow can destroy the widget - listener = GetPaintListener(); - if (!listener) - return; - - listener->PaintWindow(this, aInvalidRegion); - - listener = GetPaintListener(); - if (!listener) - return; - - listener->DidPaintWindow(); -} - -void MetroWidget::UserActivity() -{ - // Check if we have the idle service, if not we try to get it. - if (!mIdleService) { - mIdleService = do_GetService("@mozilla.org/widget/idleservice;1"); - } - - // Check that we now have the idle service. - if (mIdleService) { - mIdleService->ResetIdleTimeOut(0); - } -} - -// InitEvent assumes physical coordinates and is used by shared win32 code. Do -// not hand winrt event coordinates to this routine. -void -MetroWidget::InitEvent(WidgetGUIEvent& event, nsIntPoint* aPoint) -{ - if (!aPoint) { - event.refPoint.x = event.refPoint.y = 0; - } else { - event.refPoint.x = aPoint->x; - event.refPoint.y = aPoint->y; - } - event.time = ::GetMessageTime(); -} - -bool -MetroWidget::DispatchWindowEvent(WidgetGUIEvent* aEvent) -{ - MOZ_ASSERT(aEvent); - nsEventStatus status = nsEventStatus_eIgnore; - DispatchEvent(aEvent, status); - return (status == nsEventStatus_eConsumeNoDefault); -} - -NS_IMETHODIMP -MetroWidget::DispatchEvent(WidgetGUIEvent* event, nsEventStatus & aStatus) -{ - if (event->AsInputEvent()) { - UserActivity(); - } - - aStatus = nsEventStatus_eIgnore; - - // Top level windows can have a view attached which requires events be sent - // to the underlying base window and the view. Added when we combined the - // base chrome window with the main content child for nc client area (title - // bar) rendering. - if (mAttachedWidgetListener) { - aStatus = mAttachedWidgetListener->HandleEvent(event, mUseAttachedEvents); - } - else if (mWidgetListener) { - aStatus = mWidgetListener->HandleEvent(event, mUseAttachedEvents); - } - - // the window can be destroyed during processing of seemingly innocuous events like, say, - // mousedowns due to the magic of scripting. mousedowns will return nsEventStatus_eIgnore, - // which causes problems with the deleted window. therefore: - if (mOnDestroyCalled) - aStatus = nsEventStatus_eConsumeNoDefault; - return NS_OK; -} - -#ifdef ACCESSIBILITY -mozilla::a11y::Accessible* -MetroWidget::GetAccessible() -{ - // We want the ability to forcibly disable a11y on windows, because - // some non-a11y-related components attempt to bring it up. See bug - // 538530 for details; we have a pref here that allows it to be disabled - // for performance and testing resons. - // - // This pref is checked only once, and the browser needs a restart to - // pick up any changes. - static int accForceDisable = -1; - - if (accForceDisable == -1) { - const char* kPrefName = "accessibility.win32.force_disabled"; - if (Preferences::GetBool(kPrefName, false)) { - accForceDisable = 1; - } else { - accForceDisable = 0; - } - } - - // If the pref was true, return null here, disabling a11y. - if (accForceDisable) - return nullptr; - - return GetRootAccessible(); -} -#endif - -double -MetroWidget::GetDefaultScaleInternal() -{ - return MetroUtils::ScaleFactor(); -} - -LayoutDeviceIntPoint -MetroWidget::CSSIntPointToLayoutDeviceIntPoint(const CSSIntPoint &aCSSPoint) -{ - CSSToLayoutDeviceScale scale = GetDefaultScale(); - LayoutDeviceIntPoint devPx(int32_t(NS_round(scale.scale * aCSSPoint.x)), - int32_t(NS_round(scale.scale * aCSSPoint.y))); - return devPx; -} - -float -MetroWidget::GetDPI() -{ - if (!mView) { - return 96.0; - } - return mView->GetDPI(); -} - -void -MetroWidget::ChangedDPI() -{ - if (mWidgetListener) { - nsIPresShell* presShell = mWidgetListener->GetPresShell(); - if (presShell) { - presShell->BackingScaleFactorChanged(); - } - } -} - -already_AddRefed -MetroWidget::GetPresShell() -{ - if (mWidgetListener) { - nsCOMPtr ps = mWidgetListener->GetPresShell(); - return ps.forget(); - } - return nullptr; -} - -NS_IMETHODIMP -MetroWidget::ConstrainPosition(bool aAllowSlop, int32_t *aX, int32_t *aY) -{ - return NS_OK; -} - -void -MetroWidget::SizeModeChanged() -{ - if (mWidgetListener) { - mWidgetListener->SizeModeChanged(nsSizeMode_Normal); - } -} - -void -MetroWidget::Activated(bool aActiveated) -{ - if (mWidgetListener) { - aActiveated ? - mWidgetListener->WindowActivated() : - mWidgetListener->WindowDeactivated(); - } -} - -NS_IMETHODIMP -MetroWidget::Move(double aX, double aY) -{ - NotifyWindowMoved(aX, aY); - return NS_OK; -} - -NS_IMETHODIMP -MetroWidget::Resize(double aWidth, double aHeight, bool aRepaint) -{ - return Resize(0, 0, aWidth, aHeight, aRepaint); -} - -NS_IMETHODIMP -MetroWidget::Resize(double aX, double aY, double aWidth, double aHeight, bool aRepaint) -{ - WinUtils::Log("Resize: %f %f %f %f", aX, aY, aWidth, aHeight); - if (mAttachedWidgetListener) { - mAttachedWidgetListener->WindowResized(this, aWidth, aHeight); - } - if (mWidgetListener) { - mWidgetListener->WindowResized(this, aWidth, aHeight); - } - Invalidate(); - return NS_OK; -} - -NS_IMETHODIMP -MetroWidget::SetFocus(bool aRaise) -{ - return NS_OK; -} - -nsresult -MetroWidget::ConfigureChildren(const nsTArray& aConfigurations) -{ - return NS_OK; -} - -void* -MetroWidget::GetNativeData(uint32_t aDataType) -{ - switch(aDataType) { - case NS_NATIVE_WINDOW: - return mWnd; - case NS_NATIVE_ICOREWINDOW: - if (mView) { - return reinterpret_cast(mView->GetCoreWindow()); - } - break; - case NS_NATIVE_TSF_THREAD_MGR: - case NS_NATIVE_TSF_CATEGORY_MGR: - case NS_NATIVE_TSF_DISPLAY_ATTR_MGR: - return nsTextStore::GetNativeData(aDataType); - } - return nullptr; -} - -void -MetroWidget::FreeNativeData(void * data, uint32_t aDataType) -{ -} - -NS_IMETHODIMP -MetroWidget::SetTitle(const nsAString& aTitle) -{ - return NS_OK; -} - -LayoutDeviceIntPoint -MetroWidget::WidgetToScreenOffset() -{ - return LayoutDeviceIntPoint(0,0); -} - -NS_IMETHODIMP -MetroWidget::CaptureRollupEvents(nsIRollupListener * aListener, - bool aDoCapture) -{ - return NS_OK; -} - -NS_IMETHODIMP_(void) -MetroWidget::SetInputContext(const InputContext& aContext, - const InputContextAction& aAction) -{ - // XXX This should set mInputContext.mNativeIMEContext properly - mInputContext = aContext; - nsTextStore::SetInputContext(this, mInputContext, aAction); - bool enable = (mInputContext.mIMEState.mEnabled == IMEState::ENABLED || - mInputContext.mIMEState.mEnabled == IMEState::PLUGIN); - if (enable && - mInputContext.mIMEState.mOpen != IMEState::DONT_CHANGE_OPEN_STATE) { - bool open = (mInputContext.mIMEState.mOpen == IMEState::OPEN); - nsTextStore::SetIMEOpenState(open); - } -} - -NS_IMETHODIMP_(nsIWidget::InputContext) -MetroWidget::GetInputContext() -{ - return mInputContext; -} - -nsresult -MetroWidget::NotifyIMEInternal(const IMENotification& aIMENotification) -{ - switch (aIMENotification.mMessage) { - case REQUEST_TO_COMMIT_COMPOSITION: - nsTextStore::CommitComposition(false); - return NS_OK; - case REQUEST_TO_CANCEL_COMPOSITION: - nsTextStore::CommitComposition(true); - return NS_OK; - case NOTIFY_IME_OF_FOCUS: - return nsTextStore::OnFocusChange(true, this, mInputContext); - case NOTIFY_IME_OF_BLUR: - return nsTextStore::OnFocusChange(false, this, mInputContext); - case NOTIFY_IME_OF_SELECTION_CHANGE: - return nsTextStore::OnSelectionChange(); - case NOTIFY_IME_OF_TEXT_CHANGE: - return nsTextStore::OnTextChange(aIMENotification); - case NOTIFY_IME_OF_POSITION_CHANGE: - return nsTextStore::OnLayoutChange(); - case NOTIFY_IME_OF_MOUSE_BUTTON_EVENT: - return nsTextStore::OnMouseButtonEvent(aIMENotification); - default: - return NS_ERROR_NOT_IMPLEMENTED; - } -} - -NS_IMETHODIMP -MetroWidget::GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState) -{ - NS_ENSURE_ARG_POINTER(aLEDState); - *aLEDState = (::GetKeyState(aKeyCode) & 1) != 0; - return NS_OK; -} - -nsIMEUpdatePreference -MetroWidget::GetIMEUpdatePreference() -{ - return nsTextStore::GetIMEUpdatePreference(); -} - -NS_IMETHODIMP -MetroWidget::ReparentNativeWidget(nsIWidget* aNewParent) -{ - return NS_OK; -} - -void -MetroWidget::SuppressBlurEvents(bool aSuppress) -{ -} - -bool -MetroWidget::BlurEventsSuppressed() -{ - return false; -} - -void -MetroWidget::PickerOpen() -{ -} - -void -MetroWidget::PickerClosed() -{ -} - -bool -MetroWidget::HasPendingInputEvent() -{ - if (HIWORD(GetQueueStatus(QS_INPUT))) - return true; - return false; -} - -NS_IMETHODIMP -MetroWidget::Observe(nsISupports *subject, const char *topic, const char16_t *data) -{ - NS_ENSURE_ARG_POINTER(topic); - if (!strcmp(topic, "apzc-zoom-to-rect")) { - CSSRect rect = CSSRect(); - uint64_t viewId = 0; - int32_t presShellId = 0; - - int reScan = swscanf(data, L"%f,%f,%f,%f,%d,%llu", - &rect.x, &rect.y, &rect.width, &rect.height, - &presShellId, &viewId); - if(reScan != 6) { - NS_WARNING("Malformed apzc-zoom-to-rect message"); - } - - ScrollableLayerGuid guid = ScrollableLayerGuid(mRootLayerTreeId, presShellId, viewId); - APZController::sAPZC->ZoomToRect(guid, rect); - } - else if (!strcmp(topic, "apzc-disable-zoom")) { - uint64_t viewId = 0; - int32_t presShellId = 0; - - int reScan = swscanf(data, L"%d,%llu", - &presShellId, &viewId); - if (reScan != 2) { - NS_WARNING("Malformed apzc-disable-zoom message"); - } - - ScrollableLayerGuid guid = ScrollableLayerGuid(mRootLayerTreeId, presShellId, viewId); - APZController::sAPZC->UpdateZoomConstraints(guid, - ZoomConstraints(false, false, CSSToScreenScale(1.0f), CSSToScreenScale(1.0f))); - } - return NS_OK; -} diff --git a/widget/windows/winrt/MetroWidget.h b/widget/windows/winrt/MetroWidget.h deleted file mode 100644 index 8532d8918..000000000 --- a/widget/windows/winrt/MetroWidget.h +++ /dev/null @@ -1,277 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#pragma once - -#include "nscore.h" -#include "nsdefs.h" -#include "prlog.h" -#include "nsAutoPtr.h" -#include "nsBaseWidget.h" -#include "nsWindowBase.h" -#include "nsString.h" -#include "nsTArray.h" -#include "nsWindowDbg.h" -#include "WindowHook.h" -#include "TaskbarWindowPreview.h" -#include "nsIdleService.h" -#ifdef ACCESSIBILITY -#include "mozilla/a11y/Accessible.h" -#endif -#include "mozilla/EventForwards.h" -#include "mozilla/layers/CompositorParent.h" -#include "mozilla/layers/LayerManagerComposite.h" -#include "nsDeque.h" -#include "APZController.h" - -#include "mozwrlbase.h" - -#include -#include -#include -#include -#include - -class nsNativeDragTarget; - -namespace mozilla { -namespace widget { -namespace winrt { - -class APZPendingResponseFlusher; -class FrameworkView; - -} } } - -class DispatchMsg; - -class MetroWidget : public nsWindowBase, - public nsIObserver -{ - typedef uint32_t TouchBehaviorFlags; - - typedef mozilla::widget::WindowHook WindowHook; - typedef mozilla::widget::TaskbarWindowPreview TaskbarWindowPreview; - typedef ABI::Windows::UI::Input::IPointerPoint IPointerPoint; - typedef ABI::Windows::UI::Core::IPointerEventArgs IPointerEventArgs; - typedef ABI::Windows::UI::Core::IKeyEventArgs IKeyEventArgs; - typedef ABI::Windows::UI::Core::ICharacterReceivedEventArgs ICharacterReceivedEventArgs; - typedef mozilla::widget::winrt::FrameworkView FrameworkView; - typedef mozilla::widget::winrt::APZController APZController; - typedef mozilla::widget::winrt::APZPendingResponseFlusher APZPendingResponseFlusher; - typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid; - - static LRESULT CALLBACK - StaticWindowProcedure(HWND aWnd, UINT aMsg, WPARAM aWParan, LPARAM aLParam); - LRESULT WindowProcedure(HWND aWnd, UINT aMsg, WPARAM aWParan, LPARAM aLParam); - -public: - MetroWidget(); - virtual ~MetroWidget(); - - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIOBSERVER - - static HWND GetICoreWindowHWND() { return sICoreHwnd; } - - // nsWindowBase - virtual bool DispatchWindowEvent(mozilla::WidgetGUIEvent* aEvent) override; - virtual bool DispatchKeyboardEvent(mozilla::WidgetGUIEvent* aEvent) override; - virtual bool DispatchScrollEvent(mozilla::WidgetGUIEvent* aEvent) override; - virtual bool DispatchPluginEvent(const MSG &aMsg) override { return false; } - virtual bool IsTopLevelWidget() override { return true; } - virtual nsWindowBase* GetParentWindowBase(bool aIncludeOwner) override { return nullptr; } - // InitEvent assumes physical coordinates and is used by shared win32 code. Do - // not hand winrt event coordinates to this routine. - virtual void InitEvent(mozilla::WidgetGUIEvent& aEvent, - nsIntPoint* aPoint = nullptr) override; - - // nsBaseWidget - virtual void SetWidgetListener(nsIWidgetListener* aWidgetListener); - - // nsIWidget interface - NS_IMETHOD Create(nsIWidget *aParent, - nsNativeWidget aNativeParent, - const nsIntRect &aRect, - nsWidgetInitData *aInitData = nullptr); - NS_IMETHOD Destroy(); - NS_IMETHOD EnableDragDrop(bool aEnable); - NS_IMETHOD SetParent(nsIWidget *aNewParent); - NS_IMETHOD Show(bool bState); - NS_IMETHOD IsVisible(bool & aState); - NS_IMETHOD IsEnabled(bool *aState); - NS_IMETHOD GetBounds(nsIntRect &aRect); - NS_IMETHOD GetScreenBounds(nsIntRect &aRect); - NS_IMETHOD GetClientBounds(nsIntRect &aRect); - NS_IMETHOD Invalidate(bool aEraseBackground = false, - bool aUpdateNCArea = false, - bool aIncludeChildren = false); - NS_IMETHOD Invalidate(const nsIntRect & aRect); - NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent, - nsEventStatus& aStatus); - NS_IMETHOD ConstrainPosition(bool aAllowSlop, int32_t *aX, int32_t *aY); - NS_IMETHOD Move(double aX, double aY); - NS_IMETHOD Resize(double aWidth, double aHeight, bool aRepaint); - NS_IMETHOD Resize(double aX, double aY, double aWidth, double aHeight, bool aRepaint); - NS_IMETHOD SetFocus(bool aRaise); - NS_IMETHOD Enable(bool aState); - NS_IMETHOD SetCursor(nsCursor aCursor); - NS_IMETHOD SetTitle(const nsAString& aTitle); - NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, - bool aDoCapture); - NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent); - virtual nsresult SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout, - int32_t aNativeKeyCode, - uint32_t aModifierFlags, - const nsAString& aCharacters, - const nsAString& aUnmodifiedCharacters); - virtual nsresult SynthesizeNativeMouseEvent(mozilla::LayoutDeviceIntPoint aPoint, - uint32_t aNativeMessage, - uint32_t aModifierFlags); - virtual nsresult SynthesizeNativeMouseScrollEvent(mozilla::LayoutDeviceIntPoint aPoint, - uint32_t aNativeMessage, - double aDeltaX, - double aDeltaY, - double aDeltaZ, - uint32_t aModifierFlags, - uint32_t aAdditionalFlags); - virtual bool HasPendingInputEvent(); - virtual double GetDefaultScaleInternal(); - float GetDPI(); - mozilla::LayoutDeviceIntPoint CSSIntPointToLayoutDeviceIntPoint(const mozilla::CSSIntPoint &aCSSPoint); - void ChangedDPI(); - virtual uint32_t GetMaxTouchPoints() const override; - virtual bool IsVisible() const; - virtual bool IsEnabled() const; - // ShouldUseOffMainThreadCompositing is defined in base widget - virtual bool ShouldUseOffMainThreadCompositing(); - bool ShouldUseBasicManager(); - bool ShouldUseAPZC(); - virtual LayerManager* GetLayerManager(PLayerTransactionChild* aShadowManager = nullptr, - LayersBackend aBackendHint = mozilla::layers::LayersBackend::LAYERS_NONE, - LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT, - bool* aAllowRetaining = nullptr); - virtual void GetPreferredCompositorBackends(nsTArray& aHints) { aHints.AppendElement(mozilla::layers::LayersBackend::LAYERS_D3D11); } - - // IME related interfaces - NS_IMETHOD_(void) SetInputContext(const InputContext& aContext, - const InputContextAction& aAction); - NS_IMETHOD_(nsIWidget::InputContext) GetInputContext(); - NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState); - virtual nsIMEUpdatePreference GetIMEUpdatePreference() override; - - // FrameworkView helpers - void SizeModeChanged(); - void Activated(bool aActiveated); - void Paint(const nsIntRegion& aInvalidRegion); - - MetroWidget* MetroWidget::GetTopLevelWindow(bool aStopOnDialogOrPopup) { return this; } - virtual nsresult ConfigureChildren(const nsTArray& aConfigurations); - virtual void* GetNativeData(uint32_t aDataType); - virtual void FreeNativeData(void * data, uint32_t aDataType); - virtual mozilla::LayoutDeviceIntPoint WidgetToScreenOffset(); - - already_AddRefed GetPresShell(); - - void UserActivity(); - -#ifdef ACCESSIBILITY - mozilla::a11y::Accessible* DispatchAccessibleEvent(uint32_t aEventType); - mozilla::a11y::Accessible* GetAccessible(); -#endif // ACCESSIBILITY - - // needed for current nsIFilePicker - void PickerOpen(); - void PickerClosed(); - bool DestroyCalled() { return false; } - void SuppressBlurEvents(bool aSuppress); - bool BlurEventsSuppressed(); - - // needed for nsITaskbarWindowPreview - bool HasTaskbarIconBeenCreated() { return false; } - void SetHasTaskbarIconBeenCreated(bool created = true) { } - already_AddRefed GetTaskbarPreview() { return nullptr; } - void SetTaskbarPreview(nsITaskbarWindowPreview *preview) { } - WindowHook& GetWindowHook() { return mWindowHook; } - - void SetView(FrameworkView* aView); - void FindMetroWindow(); - virtual void SetTransparencyMode(nsTransparencyMode aMode); - virtual nsTransparencyMode GetTransparencyMode(); - - TouchBehaviorFlags ContentGetAllowedTouchBehavior(const nsIntPoint& aPoint); - - // apzc controller related api - void ApzcGetAllowedTouchBehavior(mozilla::WidgetInputEvent* aTransformedEvent, nsTArray& aOutBehaviors); - void ApzcSetAllowedTouchBehavior(uint64_t aInputBlockId, nsTArray& aBehaviors); - - // Hit test a point to see if an apzc would consume input there - bool ApzHitTest(mozilla::ScreenIntPoint& pt); - // Transforms a coord so that it properly targets goanna content based - // on apzc transforms currently applied. - void ApzTransformGoannaCoordinate(const mozilla::ScreenIntPoint& pt, - mozilla::LayoutDeviceIntPoint* aRefPointOut); - // send ContentRecievedTouch calls to the apz with appropriate preventDefault params - void ApzContentConsumingTouch(uint64_t aInputBlockId); - void ApzContentIgnoringTouch(uint64_t aInputBlockId); - // Input handling - nsEventStatus ApzReceiveInputEvent(mozilla::WidgetInputEvent* aEvent, - ScrollableLayerGuid* aOutTargetGuid, - uint64_t* aOutInputBlockId); - // Callback for the APZController - void SetApzPendingResponseFlusher(APZPendingResponseFlusher* aFlusher); - -protected: - friend class FrameworkView; - - struct OleInitializeWrapper { - HRESULT const hr; - - OleInitializeWrapper() - : hr(::OleInitialize(nullptr)) - { - } - - ~OleInitializeWrapper() { - if (SUCCEEDED(hr)) { - ::OleFlushClipboard(); - ::OleUninitialize(); - } - } - }; - - // nsBaseWidget - void ConfigureAPZCTreeManager() override; - already_AddRefed NewRootContentController() override; - - void SetSubclass(); - void RemoveSubclass(); - nsIWidgetListener* GetPaintListener(); - - virtual nsresult NotifyIMEInternal( - const IMENotification& aIMENotification) override; - - // Async event dispatching - void DispatchAsyncScrollEvent(DispatchMsg* aEvent); - void DeliverNextScrollEvent(); - void DeliverNextKeyboardEvent(); - -protected: - OleInitializeWrapper mOleInitializeWrapper; - WindowHook mWindowHook; - Microsoft::WRL::ComPtr mView; - nsTransparencyMode mTransparencyMode; - nsIntRegion mInvalidatedRegion; - nsCOMPtr mIdleService; - HWND mWnd; - static HWND sICoreHwnd; - WNDPROC mMetroWndProc; - bool mTempBasicLayerInUse; - uint64_t mRootLayerTreeId; - nsDeque mEventQueue; - nsDeque mKeyEventQueue; - nsRefPtr mController; - nsRefPtr mNativeDragTarget; -}; diff --git a/widget/windows/winrt/ToastNotificationHandler.cpp b/widget/windows/winrt/ToastNotificationHandler.cpp deleted file mode 100644 index 1466cfef4..000000000 --- a/widget/windows/winrt/ToastNotificationHandler.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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 "ToastNotificationHandler.h" -#include "MetroUtils.h" -#include "mozilla/Services.h" -#include "FrameworkView.h" - -using namespace ABI::Windows::Foundation; -using namespace ABI::Windows::Data::Xml::Dom; -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; -using namespace mozilla; -using namespace ABI::Windows::UI::Notifications; - -typedef __FITypedEventHandler_2_Windows__CUI__CNotifications__CToastNotification_IInspectable_t ToastActivationHandler; -typedef __FITypedEventHandler_2_Windows__CUI__CNotifications__CToastNotification_Windows__CUI__CNotifications__CToastDismissedEventArgs ToastDismissHandler; - -bool -ToastNotificationHandler::DisplayNotification(HSTRING title, - HSTRING msg, - HSTRING imagePath, - const nsAString& aCookie, - const nsAString& aAppId) -{ - mCookie = aCookie; - - Microsoft::WRL::ComPtr toastXml = - InitializeXmlForTemplate(ToastTemplateType::ToastTemplateType_ToastImageAndText03); - Microsoft::WRL::ComPtr toastTextElements, toastImageElements; - Microsoft::WRL::ComPtr titleTextNodeRoot, msgTextNodeRoot, imageNodeRoot, srcAttribute; - - HSTRING textNodeStr, imageNodeStr, srcNodeStr; - HSTRING_HEADER textHeader, imageHeader, srcHeader; - WindowsCreateStringReference(L"text", 4, &textHeader, &textNodeStr); - WindowsCreateStringReference(L"image", 5, &imageHeader, &imageNodeStr); - WindowsCreateStringReference(L"src", 3, &srcHeader, &srcNodeStr); - toastXml->GetElementsByTagName(textNodeStr, &toastTextElements); - toastXml->GetElementsByTagName(imageNodeStr, &toastImageElements); - - AssertRetHRESULT(toastTextElements->Item(0, &titleTextNodeRoot), false); - AssertRetHRESULT(toastTextElements->Item(1, &msgTextNodeRoot), false); - AssertRetHRESULT(toastImageElements->Item(0, &imageNodeRoot), false); - - Microsoft::WRL::ComPtr attributes; - AssertRetHRESULT(imageNodeRoot->get_Attributes(&attributes), false); - AssertRetHRESULT(attributes->GetNamedItem(srcNodeStr, &srcAttribute), false); - - SetNodeValueString(title, titleTextNodeRoot.Get(), toastXml.Get()); - SetNodeValueString(msg, msgTextNodeRoot.Get(), toastXml.Get()); - SetNodeValueString(imagePath, srcAttribute.Get(), toastXml.Get()); - - return CreateWindowsNotificationFromXml(toastXml.Get(), aAppId); -} - -bool -ToastNotificationHandler::DisplayTextNotification(HSTRING title, - HSTRING msg, - const nsAString& aCookie, - const nsAString& aAppId) -{ - mCookie = aCookie; - - Microsoft::WRL::ComPtr toastXml = - InitializeXmlForTemplate(ToastTemplateType::ToastTemplateType_ToastText03); - Microsoft::WRL::ComPtr toastTextElements; - Microsoft::WRL::ComPtr titleTextNodeRoot, msgTextNodeRoot; - - HSTRING textNodeStr; - HSTRING_HEADER textHeader; - WindowsCreateStringReference(L"text", 4, &textHeader, &textNodeStr); - toastXml->GetElementsByTagName(textNodeStr, &toastTextElements); - - AssertRetHRESULT(toastTextElements->Item(0, &titleTextNodeRoot), false); - AssertRetHRESULT(toastTextElements->Item(1, &msgTextNodeRoot), false); - - SetNodeValueString(title, titleTextNodeRoot.Get(), toastXml.Get()); - SetNodeValueString(msg, msgTextNodeRoot.Get(), toastXml.Get()); - - return CreateWindowsNotificationFromXml(toastXml.Get(), aAppId); -} - -Microsoft::WRL::ComPtr -ToastNotificationHandler::InitializeXmlForTemplate(ToastTemplateType templateType) { - Microsoft::WRL::ComPtr toastXml; - - AssertRetHRESULT(GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_Notifications_ToastNotificationManager).Get(), - mToastNotificationManagerStatics.GetAddressOf()), nullptr); - - mToastNotificationManagerStatics->GetTemplateContent(templateType, &toastXml); - - return toastXml; -} - -bool -ToastNotificationHandler::CreateWindowsNotificationFromXml(IXmlDocument *toastXml, - const nsAString& aAppId) -{ - Microsoft::WRL::ComPtr notification; - Microsoft::WRL::ComPtr factory; - AssertRetHRESULT(GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_Notifications_ToastNotification).Get(), - factory.GetAddressOf()), false); - AssertRetHRESULT(factory->CreateToastNotification(toastXml, ¬ification), - false); - - EventRegistrationToken activatedToken; - AssertRetHRESULT(notification->add_Activated(Callback(this, - &ToastNotificationHandler::OnActivate).Get(), &activatedToken), false); - EventRegistrationToken dismissedToken; - AssertRetHRESULT(notification->add_Dismissed(Callback(this, - &ToastNotificationHandler::OnDismiss).Get(), &dismissedToken), false); - - Microsoft::WRL::ComPtr notifier; - if (aAppId.IsEmpty()) { - AssertRetHRESULT(mToastNotificationManagerStatics->CreateToastNotifier( - ¬ifier), false); - } else { - AssertRetHRESULT(mToastNotificationManagerStatics->CreateToastNotifierWithId( - HStringReference(PromiseFlatString(aAppId).get()).Get(), - ¬ifier), false); - } - AssertRetHRESULT(notifier->Show(notification.Get()), false); - - MetroUtils::FireObserver("metro_native_toast_shown", mCookie.get()); - - return true; -} - -void ToastNotificationHandler::SetNodeValueString(HSTRING inputString, - Microsoft::WRL::ComPtr node, Microsoft::WRL::ComPtr xml) { - Microsoft::WRL::ComPtr inputText; - Microsoft::WRL::ComPtr inputTextNode, pAppendedChild; - - AssertHRESULT(xml->CreateTextNode(inputString, &inputText)); - AssertHRESULT(inputText.As(&inputTextNode)); - AssertHRESULT(node->AppendChild(inputTextNode.Get(), &pAppendedChild)); -} - -HRESULT ToastNotificationHandler::OnActivate(IToastNotification *notification, IInspectable *inspectable) { - MetroUtils::FireObserver("metro_native_toast_clicked", mCookie.get()); - return S_OK; -} - -HRESULT -ToastNotificationHandler::OnDismiss(IToastNotification *notification, - IToastDismissedEventArgs* aArgs) -{ - MetroUtils::FireObserver("metro_native_toast_dismissed", mCookie.get()); - delete this; - return S_OK; -} diff --git a/widget/windows/winrt/ToastNotificationHandler.h b/widget/windows/winrt/ToastNotificationHandler.h deleted file mode 100644 index 4935f8d4a..000000000 --- a/widget/windows/winrt/ToastNotificationHandler.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#pragma once - -#include -#include -#include "mozwrlbase.h" -#include "nsString.h" - - -class ToastNotificationHandler { - typedef ABI::Windows::UI::Notifications::IToastNotification IToastNotification; - typedef ABI::Windows::UI::Notifications::IToastDismissedEventArgs IToastDismissedEventArgs; - typedef ABI::Windows::UI::Notifications::IToastNotificationManagerStatics IToastNotificationManagerStatics; - typedef ABI::Windows::UI::Notifications::ToastTemplateType ToastTemplateType; - typedef ABI::Windows::Data::Xml::Dom::IXmlNode IXmlNode; - typedef ABI::Windows::Data::Xml::Dom::IXmlDocument IXmlDocument; - - void SetNodeValueString(HSTRING inputString,Microsoft::WRL::ComPtr node, - Microsoft::WRL::ComPtr xml); - public: - ToastNotificationHandler() {}; - ~ToastNotificationHandler() {}; - - bool DisplayNotification(HSTRING title, HSTRING msg, HSTRING imagePath, - const nsAString& aCookie, const nsAString& aAppId); - bool DisplayTextNotification(HSTRING title, HSTRING msg, - const nsAString& aCookie, - const nsAString& aAppId); - HRESULT OnActivate(IToastNotification *notification, IInspectable *inspectable); - HRESULT OnDismiss(IToastNotification *notification, - IToastDismissedEventArgs* aArgs); - - private: - nsString mCookie; - Microsoft::WRL::ComPtr mToastNotificationManagerStatics; - - bool CreateWindowsNotificationFromXml(IXmlDocument *toastXml, - const nsAString& aAppId); - Microsoft::WRL::ComPtr InitializeXmlForTemplate(ToastTemplateType templateType); -}; diff --git a/widget/windows/winrt/UIAAccessibilityBridge.cpp b/widget/windows/winrt/UIAAccessibilityBridge.cpp deleted file mode 100644 index 0603462f3..000000000 --- a/widget/windows/winrt/UIAAccessibilityBridge.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#if defined(ACCESSIBILITY) - -#include "UIAAccessibilityBridge.h" -#include "MetroUtils.h" - -#include - -#include "nsIAccessibleEvent.h" -#include "nsIPersistentProperties2.h" - -// generated -#include "UIABridge.h" - -#include - -using namespace mozilla::a11y; - -namespace mozilla { -namespace widget { -namespace winrt { - -using namespace Microsoft::WRL; - -NS_IMPL_ISUPPORTS(AccessibilityBridge, nsIObserver) - -nsresult -AccessibilityBridge::Observe(nsISupports *aSubject, const char *aTopic, const char16_t *aData) -{ - nsCOMPtr ev = do_QueryInterface(aSubject); - if (!ev) { - return NS_OK; - } - - uint32_t eventType = 0; - ev->GetEventType(&eventType); - if (eventType == nsIAccessibleEvent::EVENT_FOCUS) { - Microsoft::WRL::ComPtr bridgePtr; - mBridge.As(&bridgePtr); - if (bridgePtr) { - bridgePtr->FocusChangeEvent(); - } - } - - return NS_OK; -} - -} } } - -#endif // ACCESSIBILITY diff --git a/widget/windows/winrt/UIAAccessibilityBridge.h b/widget/windows/winrt/UIAAccessibilityBridge.h deleted file mode 100644 index a541035d8..000000000 --- a/widget/windows/winrt/UIAAccessibilityBridge.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#pragma once - -#if defined(ACCESSIBILITY) - -#include "nsCOMPtr.h" -#include "nsIObserver.h" -#include "nsIObserverService.h" -#include "nsServiceManagerUtils.h" -#include "mozilla/a11y/Accessible.h" - -#include "mozwrlbase.h" - -namespace mozilla { -namespace widget { -namespace winrt { - -// Connects to our accessibility framework to receive -// events and query the dom. -class AccessibilityBridge : public nsIObserver -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIOBSERVER - - AccessibilityBridge() {} - - ~AccessibilityBridge() { - Disconnect(); - } - - bool Init(IUnknown* aBridge, mozilla::a11y::Accessible* aPtr) { - mAccess = aPtr; - mBridge = aBridge; - return Connect(); - } - - bool Connect() { - nsresult rv; - - nsCOMPtr observerService = - do_GetService("@mozilla.org/observer-service;1", &rv); - if (NS_FAILED(rv)) { - return false; - } - rv = observerService->AddObserver(this, "accessible-event", false); - if (NS_FAILED(rv)) { - return false; - } - return true; - } - - bool Connected() { - return mAccess ? true : false; - } - - void Disconnect() { - nsresult rv; - nsCOMPtr observerService = - do_GetService("@mozilla.org/observer-service;1", &rv); - if (NS_FAILED(rv)) { - NS_WARNING("failed to get observersvc on shutdown."); - return; - } - observerService->RemoveObserver(this, "accessible-event"); - mAccess = nullptr; - } - -private: - nsRefPtr mAccess; - Microsoft::WRL::ComPtr mBridge; -}; - -} } } - -#endif // ACCESSIBILITY diff --git a/widget/windows/winrt/UIABridge.cpp b/widget/windows/winrt/UIABridge.cpp deleted file mode 100644 index 14c17454b..000000000 --- a/widget/windows/winrt/UIABridge.cpp +++ /dev/null @@ -1,801 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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 "UIABridge.h" -#include "MetroUtils.h" -#include "UIABridgePrivate.h" -#include "MetroWidget.h" -#include "WinUtils.h" - -#include -#include -#include - -#ifdef ACCESSIBILITY -using namespace mozilla::a11y; -#endif -using namespace mozilla::widget; -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; -using namespace ABI::Windows::UI; -using namespace ABI::Windows::UI::Core; -using namespace ABI::Windows::Foundation; -using namespace ABI::Windows::System; - -//#define DEBUG_BRIDGE -#if !defined(DEBUG_BRIDGE) -#undef LogThread -#undef LogFunction -#define LogThread() -#define LogFunction() -#define BridgeLog(...) -#else -#define BridgeLog(...) WinUtils::Log(__VA_ARGS__) -#endif - -#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \ - const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}} -MIDL_DEFINE_GUID(IID, IID_IUIABridge, 0xc78b35b5, 0x5db, 0x43aa, 0xae, 0x73, 0x94, 0xc2, 0x33, 0xa9, 0x3c, 0x98); - -namespace mozilla { -namespace widget { -namespace winrt { - -#define ProviderOptions_UseClientCoordinates (ProviderOptions)0x100 - -static int gIDIndex = 2; -ComPtr gProviderRoot = nullptr; -static ComPtr gElement = nullptr; - -HRESULT -UIABridge_CreateInstance(IInspectable **retVal) -{ - HRESULT hr = E_OUTOFMEMORY; - *retVal = nullptr; - ComPtr spProvider = Make(); - if (spProvider != nullptr && - SUCCEEDED(hr = spProvider.Get()->QueryInterface(IID_PPV_ARGS(retVal))) && - SUCCEEDED(hr = spProvider.Get()->QueryInterface(IID_PPV_ARGS(&gProviderRoot)))) { - return S_OK; - } - return hr; -} - -HRESULT -UIATextElement_CreateInstance(IRawElementProviderFragmentRoot* aRoot) -{ - LogFunction(); - HRESULT hr = E_OUTOFMEMORY; - ComPtr spProvider = Make(); - if (spProvider != nullptr && - SUCCEEDED(hr = spProvider.Get()->QueryInterface(IID_PPV_ARGS(&gElement)))) { - spProvider->SetIndexID(gIDIndex++); - return S_OK; - } - return hr; -} - -// IUIABridge - -HRESULT -UIABridge::Init(IInspectable* aView, IInspectable* aWindow, LONG_PTR aInnerPtr) -{ - LogFunction(); - NS_ASSERTION(aView, "invalid framework view pointer"); - NS_ASSERTION(aWindow, "invalid window pointer"); - NS_ASSERTION(aInnerPtr, "invalid Accessible pointer"); - -#if defined(ACCESSIBILITY) - // init AccessibilityBridge and connect to accessibility - mAccBridge = new AccessibilityBridge(); - if (!mAccBridge->Init(CastToUnknown(), (Accessible*)aInnerPtr)) { - return E_FAIL; - } - - aWindow->QueryInterface(IID_PPV_ARGS(&mWindow)); - - if (FAILED(UIATextElement_CreateInstance(this))) - return E_FAIL; - - mAccessible = (Accessible*)aInnerPtr; - - return S_OK; -#endif - return E_FAIL; -} - -HRESULT -UIABridge::Disconnect() -{ - LogFunction(); -#if defined(ACCESSIBILITY) - mAccBridge->Disconnect(); - mAccessible = nullptr; -#endif - mWindow = nullptr; - gElement = nullptr; - gProviderRoot = nullptr; - return S_OK; -} - -bool -UIABridge::Connected() -{ - return !!mAccessible; -} - -// IUIAElement - -HRESULT -UIABridge::SetFocusInternal(LONG_PTR aAccessible) -{ - LogFunction(); - return S_OK; -} - -HRESULT -UIABridge::ClearFocus() -{ - LogFunction(); - return S_OK; -} - -static void -DumpChildInfo(nsRefPtr& aChild) -{ -#ifdef DEBUG - if (!aChild) { - return; - } - nsString str; - aChild->Name(str); - BridgeLog("name: %ls", str.BeginReading()); - aChild->Description(str); - BridgeLog("description: %ls", str.BeginReading()); -#endif -} - -static bool -ChildHasFocus(nsRefPtr& aChild) -{ - BridgeLog("Focus element flags: editable:%d focusable:%d readonly:%d", - ((aChild->NativeState() & mozilla::a11y::states::EDITABLE) > 0), - ((aChild->NativeState() & mozilla::a11y::states::FOCUSABLE) > 0), - ((aChild->NativeState() & mozilla::a11y::states::READONLY) > 0)); - return (((aChild->NativeState() & mozilla::a11y::states::EDITABLE) > 0) && - ((aChild->NativeState() & mozilla::a11y::states::READONLY) == 0)); -} - -HRESULT -UIABridge::FocusChangeEvent() -{ - LogFunction(); - if (!Connected()) { - return UIA_E_ELEMENTNOTAVAILABLE; - } - - nsRefPtr child = mAccessible->FocusedChild(); - if (!child) { - return S_OK; - } - - if (!ChildHasFocus(child)) { - ComPtr element; - gElement.As(&element); - if (!element) { - return S_OK; - } - element->ClearFocus(); - UiaRaiseAutomationEvent(this, UIA_AutomationFocusChangedEventId); - } - - return S_OK; -} - -// IRawElementProviderFragmentRoot - -HRESULT -UIABridge::ElementProviderFromPoint(double x, double y, IRawElementProviderFragment ** retVal) -{ - LogFunction(); - *retVal = nullptr; - if (!Connected()) { - return UIA_E_ELEMENTNOTAVAILABLE; - } - gElement.Get()->QueryInterface(IID_PPV_ARGS(retVal)); - return S_OK; -} - -// Windows calls this looking for the current focus element. Windows -// will call here before accessible sends us any observer events through -// the accessibility bridge, so update child focus information. -HRESULT -UIABridge::GetFocus(IRawElementProviderFragment ** retVal) -{ - LogFunction(); - if (!Connected()) { - return UIA_E_ELEMENTNOTAVAILABLE; - } - - nsRefPtr child = mAccessible->FocusedChild(); - if (!child) { - BridgeLog("mAccessible->GetFocusedChild failed."); - return S_OK; - } - - DumpChildInfo(child); - - ComPtr element; - gElement.As(&element); - if (!element) { - BridgeLog("gElement as IUIAElement failed."); - return S_OK; - } - - if (!ChildHasFocus(child)) { - element->ClearFocus(); - } else { - element->SetFocusInternal((LONG_PTR)child.get()); - element.Get()->QueryInterface(IID_PPV_ARGS(retVal)); - } - - return S_OK; -} - -// IRawElementProviderFragment - -HRESULT -UIABridge::Navigate(NavigateDirection direction, IRawElementProviderFragment ** retVal) -{ - LogFunction(); - if (!Connected()) { - return UIA_E_ELEMENTNOTAVAILABLE; - } - *retVal = nullptr; - - switch(direction) { - case NavigateDirection_Parent: - BridgeLog("UIABridge::Navigate NavigateDirection_Parent"); - break; - case NavigateDirection_NextSibling: - BridgeLog("UIABridge::Navigate NavigateDirection_NextSibling"); - break; - case NavigateDirection_PreviousSibling: - BridgeLog("UIABridge::Navigate NavigateDirection_PreviousSibling"); - break; - case NavigateDirection_FirstChild: - BridgeLog("UIABridge::Navigate NavigateDirection_FirstChild"); - gElement.Get()->QueryInterface(IID_PPV_ARGS(retVal)); - break; - case NavigateDirection_LastChild: - BridgeLog("UIABridge::Navigate NavigateDirection_LastChild"); - gElement.Get()->QueryInterface(IID_PPV_ARGS(retVal)); - break; - } - - // For the other directions (parent, next, previous) the default of nullptr is correct - return S_OK; -} - -HRESULT -UIABridge::GetRuntimeId(SAFEARRAY ** retVal) -{ - LogFunction(); - if (!Connected()) { - return UIA_E_ELEMENTNOTAVAILABLE; - } - - int runtimeId[2] = { UiaAppendRuntimeId, 1 }; // always 1 - *retVal = SafeArrayCreateVector(VT_I4, 0, ARRAYSIZE(runtimeId)); - if (*retVal != nullptr) { - for (long index = 0; index < ARRAYSIZE(runtimeId); ++index) { - SafeArrayPutElement(*retVal, &index, &runtimeId[index]); - } - } else { - return E_OUTOFMEMORY; - } - return S_OK; -} - -HRESULT -UIABridge::get_BoundingRectangle(UiaRect * retVal) -{ - LogFunction(); - if (!Connected() || !mWindow) { - return UIA_E_ELEMENTNOTAVAILABLE; - } - - // returns logical pixels - Rect bounds; - mWindow->get_Bounds(&bounds); - - // we need to return physical pixels - retVal->left = WinUtils::LogToPhys(bounds.X); - retVal->top = WinUtils::LogToPhys(bounds.Y); - retVal->width = WinUtils::LogToPhys(bounds.Width); - retVal->height = WinUtils::LogToPhys(bounds.Height); - - return S_OK; -} - -HRESULT -UIABridge::GetEmbeddedFragmentRoots(SAFEARRAY ** retVal) -{ - if (!Connected()) { - return UIA_E_ELEMENTNOTAVAILABLE; - } - // doesn't apply according to msdn. - *retVal = nullptr; - return S_OK; -} - -HRESULT -UIABridge::SetFocus() -{ - LogFunction(); - if (!Connected()) { - return UIA_E_ELEMENTNOTAVAILABLE; - } - return S_OK; -} - -HRESULT -UIABridge::get_FragmentRoot(IRawElementProviderFragmentRoot ** retVal) -{ - // we are the fragment root. Our children return us for this call. - return QueryInterface(IID_PPV_ARGS(retVal)); -} - -// IRawElementProviderSimple - -HRESULT -UIABridge::get_ProviderOptions(ProviderOptions * pRetVal) -{ - LogFunction(); - if (!Connected()) { - return E_FAIL; - } - *pRetVal = ProviderOptions_ServerSideProvider | - ProviderOptions_UseComThreading | - ProviderOptions_UseClientCoordinates; - return S_OK; -} - -HRESULT -UIABridge::GetPatternProvider(PATTERNID patternId, IUnknown **ppRetVal) -{ - LogFunction(); - BridgeLog("UIABridge::GetPatternProvider=%d", patternId); - - // The root window doesn't support any specific pattern - *ppRetVal = nullptr; - - return S_OK; -} - -HRESULT -UIABridge::GetPropertyValue(PROPERTYID idProp, VARIANT * pRetVal) -{ - pRetVal->vt = VT_EMPTY; - - switch (idProp) { - case UIA_AutomationIdPropertyId: - BridgeLog("UIABridge::GetPropertyValue: idProp=UIA_AutomationIdPropertyId"); - break; - case UIA_ControlTypePropertyId: - BridgeLog("UIABridge::GetPropertyValue: idProp=UIA_ControlTypePropertyId"); - break; - case UIA_IsKeyboardFocusablePropertyId: - BridgeLog("UIABridge::GetPropertyValue: idProp=UIA_IsKeyboardFocusablePropertyId"); - break; - case UIA_IsContentElementPropertyId: - BridgeLog("UIABridge::GetPropertyValue: idProp=UIA_IsContentElementPropertyId"); - break; - case UIA_IsControlElementPropertyId: - BridgeLog("UIABridge::GetPropertyValue: idProp=UIA_IsControlElementPropertyId"); - break; - case UIA_IsEnabledPropertyId: - BridgeLog("UIABridge::GetPropertyValue: idProp=UIA_IsEnabledPropertyId"); - break; - case UIA_HasKeyboardFocusPropertyId: - BridgeLog("UIABridge::GetPropertyValue: idProp=UIA_HasKeyboardFocusPropertyId"); - break; - case UIA_NamePropertyId: - BridgeLog("UIABridge::GetPropertyValue: idProp=UIA_NamePropertyId"); - break; - case UIA_IsPasswordPropertyId: - BridgeLog("UIABridge::GetPropertyValue: idProp=UIA_IsPasswordPropertyId"); - break; - case UIA_NativeWindowHandlePropertyId: - BridgeLog("UIABridge::GetPropertyValue: idProp=UIA_NativeWindowHandlePropertyId"); - break; - default: - BridgeLog("UIABridge::GetPropertyValue: idProp=%d", idProp); - break; - } - - if (!Connected()) { - return E_FAIL; - } - - switch (idProp) { - case UIA_AutomationIdPropertyId: - pRetVal->bstrVal = SysAllocString(L"MozillaAccessibilityBridge0001"); - pRetVal->vt = VT_BSTR; - break; - - case UIA_ControlTypePropertyId: - pRetVal->vt = VT_I4; - pRetVal->lVal = UIA_WindowControlTypeId; - break; - - case UIA_IsKeyboardFocusablePropertyId: - case UIA_IsContentElementPropertyId: - case UIA_IsControlElementPropertyId: - case UIA_IsEnabledPropertyId: - pRetVal->boolVal = VARIANT_TRUE; - pRetVal->vt = VT_BOOL; - break; - - case UIA_HasKeyboardFocusPropertyId: - pRetVal->vt = VT_BOOL; - pRetVal->boolVal = VARIANT_FALSE; - break; - - case UIA_NamePropertyId: - pRetVal->bstrVal = SysAllocString(L"MozillaAccessibilityBridge"); - pRetVal->vt = VT_BSTR; - break; - - case UIA_IsPasswordPropertyId: - pRetVal->vt = VT_BOOL; - pRetVal->boolVal = VARIANT_FALSE; - break; - - case UIA_NativeWindowHandlePropertyId: - pRetVal->vt = VT_I4; - pRetVal->lVal = (LONG)MetroWidget::GetICoreWindowHWND(); - break; - - default: - BridgeLog("UIABridge: Unhandled property"); - break; - } - return S_OK; -} - -HRESULT -UIABridge::get_HostRawElementProvider(IRawElementProviderSimple **ppRetVal) -{ - // We only have this in the root bridge - this is our parent ICoreWindow. - *ppRetVal = nullptr; - if (mWindow != nullptr) { - IInspectable *pHostAsInspectable = nullptr; - if (SUCCEEDED(mWindow->get_AutomationHostProvider(&pHostAsInspectable))) { - pHostAsInspectable->QueryInterface(ppRetVal); - pHostAsInspectable->Release(); - } - } - return S_OK; -} - -/////////////////////////////////////////////////////////////////////////////// -// Element - -HRESULT -UIATextElement::SetFocusInternal(LONG_PTR aAccessible) -{ - LogFunction(); -#if defined(ACCESSIBILITY) - NS_ASSERTION(mAccessItem, "Bad accessible pointer"); - if (mAccessItem == (Accessible*)aAccessible) { - return E_UNEXPECTED; - } - mAccessItem = (Accessible*)aAccessible; - return S_OK; -#endif - return E_FAIL; -} - -HRESULT -UIATextElement::ClearFocus() -{ - LogFunction(); - mAccessItem = nullptr; - return S_OK; -} - -// IRawElementProviderFragment - -HRESULT -UIATextElement::Navigate(NavigateDirection direction, IRawElementProviderFragment ** retVal) -{ - LogFunction(); - - *retVal = nullptr; - switch(direction) { - case NavigateDirection_Parent: - gProviderRoot.Get()->QueryInterface(IID_PPV_ARGS(retVal)); - break; - case NavigateDirection_NextSibling: - break; - case NavigateDirection_PreviousSibling: - break; - case NavigateDirection_FirstChild: - break; - case NavigateDirection_LastChild: - break; - } - return S_OK; -} - -HRESULT -UIATextElement::GetRuntimeId(SAFEARRAY ** retVal) -{ - LogFunction(); - int runtimeId[2] = { UiaAppendRuntimeId, mIndexID }; - *retVal = SafeArrayCreateVector(VT_I4, 0, ARRAYSIZE(runtimeId)); - if (*retVal != nullptr) { - for (long index = 0; index < ARRAYSIZE(runtimeId); ++index) { - SafeArrayPutElement(*retVal, &index, &runtimeId[index]); - } - } else { - return E_OUTOFMEMORY; - } - return S_OK; -} - -HRESULT -UIATextElement::get_BoundingRectangle(UiaRect * retVal) -{ - LogFunction(); - - if (!mAccessItem) { - return UIA_E_ELEMENTNOTAVAILABLE; - } - - // bounds are in physical pixels - nsIntRect rect = mAccessItem->Bounds(); - - retVal->left = rect.x; - retVal->top = rect.y; - retVal->width = rect.width; - retVal->height = rect.height; - - BridgeLog("get_BoundingRectangle: left=%d top=%d right=%d bottom=%d", rect.x, rect.y, rect.x + rect.width, rect.y + rect.height); - return S_OK; -} - -HRESULT -UIATextElement::GetEmbeddedFragmentRoots(SAFEARRAY ** retVal) -{ - *retVal = nullptr; - return S_OK; -} - -HRESULT -UIATextElement::SetFocus() -{ - LogFunction(); - return S_OK; -} - -HRESULT -UIATextElement::get_FragmentRoot(IRawElementProviderFragmentRoot ** retVal) -{ - return gProviderRoot.Get()->QueryInterface(IID_PPV_ARGS(retVal)); -} - -// IRawElementProviderSimple - -HRESULT -UIATextElement::get_ProviderOptions(ProviderOptions * pRetVal) -{ - *pRetVal = ProviderOptions_ServerSideProvider | - ProviderOptions_UseComThreading | - ProviderOptions_UseClientCoordinates; - return S_OK; -} - -HRESULT -UIATextElement::GetPatternProvider(PATTERNID patternId, IUnknown **ppRetVal) -{ - LogFunction(); - BridgeLog("UIATextElement::GetPatternProvider=%d", patternId); - - // UIA_ValuePatternId - 10002 - // UIA_TextPatternId - 10014 - // UIA_TextChildPatternId - 10029 - - *ppRetVal = nullptr; - if (patternId == UIA_TextPatternId) { - BridgeLog("** TextPattern requested from element."); - *ppRetVal = static_cast(this); - AddRef(); - return S_OK; - } else if (patternId == UIA_ValuePatternId) { - BridgeLog("** ValuePattern requested from element."); - *ppRetVal = static_cast(this); - AddRef(); - return S_OK; - } - - return S_OK; -} - -HRESULT -UIATextElement::GetPropertyValue(PROPERTYID idProp, VARIANT * pRetVal) -{ - pRetVal->vt = VT_EMPTY; - - // native hwnd, we don't have one for elements - if (idProp == 30020) { - return S_OK; - } - - switch (idProp) { - case UIA_AutomationIdPropertyId: - BridgeLog("UIATextElement::GetPropertyValue: idProp=UIA_AutomationIdPropertyId"); - break; - case UIA_ControlTypePropertyId: - BridgeLog("UIATextElement::GetPropertyValue: idProp=UIA_ControlTypePropertyId"); - break; - case UIA_IsKeyboardFocusablePropertyId: - BridgeLog("UIATextElement::GetPropertyValue: idProp=UIA_IsKeyboardFocusablePropertyId"); - break; - case UIA_IsContentElementPropertyId: - BridgeLog("UIATextElement::GetPropertyValue: idProp=UIA_IsContentElementPropertyId"); - break; - case UIA_IsControlElementPropertyId: - BridgeLog("UIATextElement::GetPropertyValue: idProp=UIA_IsControlElementPropertyId"); - break; - case UIA_IsEnabledPropertyId: - BridgeLog("UIATextElement::GetPropertyValue: idProp=UIA_IsEnabledPropertyId"); - break; - case UIA_HasKeyboardFocusPropertyId: - BridgeLog("UIATextElement::GetPropertyValue: idProp=UIA_HasKeyboardFocusPropertyId"); - break; - case UIA_NamePropertyId: - BridgeLog("UIATextElement::GetPropertyValue: idProp=UIA_NamePropertyId"); - break; - case UIA_IsPasswordPropertyId: - BridgeLog("UIATextElement::GetPropertyValue: idProp=UIA_IsPasswordPropertyId"); - break; - default: - BridgeLog("UIATextElement::GetPropertyValue: idProp=%d", idProp); - break; - } - - switch (idProp) { - case UIA_AutomationIdPropertyId: - pRetVal->bstrVal = SysAllocString(L"MozillaDocument0001"); - pRetVal->vt = VT_BSTR; - break; - - case UIA_ControlTypePropertyId: - pRetVal->vt = VT_I4; - pRetVal->lVal = UIA_EditControlTypeId; - break; - - case UIA_IsTextPatternAvailablePropertyId: - case UIA_IsKeyboardFocusablePropertyId: - case UIA_IsContentElementPropertyId: - case UIA_IsControlElementPropertyId: - case UIA_IsEnabledPropertyId: - pRetVal->boolVal = VARIANT_TRUE; - pRetVal->vt = VT_BOOL; - break; - - case UIA_LocalizedControlTypePropertyId: - case UIA_LabeledByPropertyId: - break; - - case UIA_HasKeyboardFocusPropertyId: - { - if (mAccessItem) { - if (mAccessItem->NativeState() & mozilla::a11y::states::FOCUSED) { - pRetVal->vt = VT_BOOL; - pRetVal->boolVal = VARIANT_TRUE; - return S_OK; - } - } - pRetVal->vt = VT_BOOL; - pRetVal->boolVal = VARIANT_FALSE; - break; - } - - case UIA_NamePropertyId: - pRetVal->bstrVal = SysAllocString(L"MozillaDocument"); - pRetVal->vt = VT_BSTR; - break; - - case UIA_IsPasswordPropertyId: - pRetVal->vt = VT_BOOL; - pRetVal->boolVal = VARIANT_FALSE; - break; - - default: - BridgeLog("UIATextElement: Unhandled property"); - break; - } - return S_OK; -} - -HRESULT -UIATextElement::get_HostRawElementProvider(IRawElementProviderSimple **ppRetVal) -{ - *ppRetVal = nullptr; - return S_OK; -} - -// ITextProvider - -HRESULT -UIATextElement::GetSelection(SAFEARRAY * *pRetVal) -{ - LogFunction(); - return E_NOTIMPL; -} - -HRESULT -UIATextElement::GetVisibleRanges(SAFEARRAY * *pRetVal) -{ - LogFunction(); - return E_NOTIMPL; -} - -HRESULT -UIATextElement::RangeFromChild(IRawElementProviderSimple *childElement, ITextRangeProvider **pRetVal) -{ - LogFunction(); - return E_NOTIMPL; -} - -HRESULT -UIATextElement::RangeFromPoint(UiaPoint point, ITextRangeProvider **pRetVal) -{ - LogFunction(); - return E_NOTIMPL; -} - -HRESULT -UIATextElement::get_DocumentRange(ITextRangeProvider **pRetVal) -{ - LogFunction(); - return E_NOTIMPL; -} - -HRESULT -UIATextElement::get_SupportedTextSelection(SupportedTextSelection *pRetVal) -{ - LogFunction(); - return E_NOTIMPL; -} - -// IValueProvider - -IFACEMETHODIMP -UIATextElement::SetValue(LPCWSTR val) -{ - LogFunction(); - return E_NOTIMPL; -} - -IFACEMETHODIMP -UIATextElement::get_Value(BSTR *pRetVal) -{ - LogFunction(); - return E_NOTIMPL; -} - -IFACEMETHODIMP -UIATextElement::get_IsReadOnly(BOOL *pRetVal) -{ - LogFunction(); - *pRetVal = FALSE; - return S_OK; -} - -} } } diff --git a/widget/windows/winrt/UIABridge.idl b/widget/windows/winrt/UIABridge.idl deleted file mode 100644 index 9b869b8e3..000000000 --- a/widget/windows/winrt/UIABridge.idl +++ /dev/null @@ -1,22 +0,0 @@ -/* 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/. */ - -#define DO_NO_IMPORTS 1 - -import "oaidl.idl"; -import "oleacc.idl"; -import "Inspectable.idl"; - - [uuid(C78B35B5-05DB-43AA-AE73-94C233A93C98)] - interface IUIABridge : IInspectable { - HRESULT Init([in] IInspectable* view, [in] IInspectable* window, [in] LONG_PTR inner); - HRESULT Disconnect(); - HRESULT FocusChangeEvent(); - }; - - [uuid(9F57311C-E8AE-4991-8D9F-E069EEE96D85)] - interface IUIAElement : IInspectable { - HRESULT SetFocusInternal([in] LONG_PTR accessible); - HRESULT ClearFocus(); - }; diff --git a/widget/windows/winrt/UIABridgePrivate.h b/widget/windows/winrt/UIABridgePrivate.h deleted file mode 100644 index 509d505c2..000000000 --- a/widget/windows/winrt/UIABridgePrivate.h +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#pragma once - -#include -#include -#include -#include -#include - -#include "mozwrlbase.h" - -#include "nsCOMPtr.h" -#include "mozilla/a11y/Accessible.h" -#include "UIAAccessibilityBridge.h" - -// generated -#include "UIABridge.h" - -namespace mozilla { -namespace widget { -namespace winrt { - -// represents the root window to UIA -[uuid("D3EDD951-0715-4501-A8E5-25D97EF35D5A")] -class UIABridge : public Microsoft::WRL::RuntimeClass, - IUIABridge, - IUIAElement, - IRawElementProviderSimple, - IRawElementProviderFragment, - IRawElementProviderFragmentRoot> -{ - typedef ABI::Windows::UI::Core::ICoreWindow ICoreWindow; - - InspectableClass(L"IUIABridge", BaseTrust); - -public: - UIABridge() {} - - // IUIABridge - IFACEMETHODIMP Init(IInspectable* view, IInspectable* window, LONG_PTR inner); - IFACEMETHODIMP Disconnect(); - IFACEMETHODIMP FocusChangeEvent(); - - // IUIAElement - IFACEMETHODIMP SetFocusInternal(LONG_PTR aAccessible); - IFACEMETHODIMP ClearFocus(); - - // IRawElementProviderFragmentRoot - IFACEMETHODIMP ElementProviderFromPoint(double x, double y, IRawElementProviderFragment ** retVal); - IFACEMETHODIMP GetFocus(IRawElementProviderFragment ** retVal); - - // IRawElementProviderFragment - IFACEMETHODIMP Navigate(NavigateDirection direction, IRawElementProviderFragment ** retVal); - IFACEMETHODIMP GetRuntimeId(SAFEARRAY ** retVal); - IFACEMETHODIMP get_BoundingRectangle(UiaRect * retVal); - IFACEMETHODIMP GetEmbeddedFragmentRoots(SAFEARRAY ** retVal); - IFACEMETHODIMP SetFocus(); - IFACEMETHODIMP get_FragmentRoot(IRawElementProviderFragmentRoot * * retVal); - - // IRawElementProviderSimple - IFACEMETHODIMP get_ProviderOptions(ProviderOptions * retVal); - IFACEMETHODIMP GetPatternProvider(PATTERNID iid, IUnknown * * retVal); - IFACEMETHODIMP GetPropertyValue(PROPERTYID idProp, VARIANT * retVal ); - IFACEMETHODIMP get_HostRawElementProvider(IRawElementProviderSimple ** retVal); - -protected: - bool Connected(); - -private: - Microsoft::WRL::ComPtr mWindow; -#if defined(ACCESSIBILITY) - nsRefPtr mAccBridge; - nsRefPtr mAccessible; -#endif -}; - -[uuid("4438135F-F624-43DE-A417-275CE7A1A0CD")] -class UIATextElement : public Microsoft::WRL::RuntimeClass, - IUIAElement, - IRawElementProviderSimple, - IRawElementProviderFragment, - ITextProvider, - IValueProvider > -{ - typedef ABI::Windows::Foundation::Rect Rect; - - InspectableClass(L"UIATextElement", BaseTrust); - -public: - UIATextElement() {} - - // IUIAElement - IFACEMETHODIMP SetFocusInternal(LONG_PTR aAccessible); - IFACEMETHODIMP ClearFocus(); - IFACEMETHODIMP FocusChangeEvent(); - - // IRawElementProviderFragment - IFACEMETHODIMP Navigate(NavigateDirection direction, IRawElementProviderFragment ** retVal); - IFACEMETHODIMP GetRuntimeId(SAFEARRAY ** retVal); - IFACEMETHODIMP get_BoundingRectangle(UiaRect * retVal); - IFACEMETHODIMP GetEmbeddedFragmentRoots(SAFEARRAY ** retVal); - IFACEMETHODIMP SetFocus(); - IFACEMETHODIMP get_FragmentRoot(IRawElementProviderFragmentRoot * * retVal); - - // IRawElementProviderSimple - IFACEMETHODIMP get_ProviderOptions(ProviderOptions * retVal); - IFACEMETHODIMP GetPatternProvider(PATTERNID iid, IUnknown * * retVal); - IFACEMETHODIMP GetPropertyValue(PROPERTYID idProp, VARIANT * retVal ); - IFACEMETHODIMP get_HostRawElementProvider(IRawElementProviderSimple ** retVal); - - // ITextProvider - IFACEMETHODIMP GetSelection(SAFEARRAY * *pRetVal); - IFACEMETHODIMP GetVisibleRanges(SAFEARRAY * *pRetVal); - IFACEMETHODIMP RangeFromChild(IRawElementProviderSimple *childElement, ITextRangeProvider **pRetVal); - IFACEMETHODIMP RangeFromPoint(UiaPoint point, ITextRangeProvider **pRetVal); - IFACEMETHODIMP get_DocumentRange(ITextRangeProvider **pRetVal); - IFACEMETHODIMP get_SupportedTextSelection(SupportedTextSelection *pRetVal); - - // IValueProvider - IFACEMETHODIMP SetValue(LPCWSTR val); - IFACEMETHODIMP get_Value(BSTR *pRetVal); - IFACEMETHODIMP get_IsReadOnly(BOOL *pRetVal); - - void SetIndexID(int id) { - mIndexID = id; - } - -private: - int mIndexID; - nsRefPtr mAccessItem; -}; - -} } } diff --git a/widget/windows/winrt/UIABridgePublic.h b/widget/windows/winrt/UIABridgePublic.h deleted file mode 100644 index e31b6a965..000000000 --- a/widget/windows/winrt/UIABridgePublic.h +++ /dev/null @@ -1,19 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#pragma once - -#include -#include -#include - -namespace mozilla { -namespace widget { -namespace winrt { - -// Factory function for UIABridge -HRESULT UIABridge_CreateInstance(IInspectable **retVal); - -} } } diff --git a/widget/windows/winrt/WakeLockListener.cpp b/widget/windows/winrt/WakeLockListener.cpp deleted file mode 100644 index 3286059ff..000000000 --- a/widget/windows/winrt/WakeLockListener.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* 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 "WakeLockListener.h" -#include "MetroUtils.h" - -using namespace mozilla::widget::winrt; - -NS_IMPL_ISUPPORTS(WakeLockListener, nsIDOMMozWakeLockListener) - -NS_IMETHODIMP -WakeLockListener::Callback(const nsAString& aTopic, const nsAString& aState) -{ - if (!mDisplayRequest) { - if (FAILED(ActivateGenericInstance(RuntimeClass_Windows_System_Display_DisplayRequest, mDisplayRequest))) { - NS_WARNING("Failed to instantiate IDisplayRequest, wakelocks will be broken!"); - return NS_OK; - } - } - - if (aState.EqualsLiteral("locked-foreground")) { - mDisplayRequest->RequestActive(); - } else { - mDisplayRequest->RequestRelease(); - } - - return NS_OK; -} diff --git a/widget/windows/winrt/WakeLockListener.h b/widget/windows/winrt/WakeLockListener.h deleted file mode 100644 index ecf0483f2..000000000 --- a/widget/windows/winrt/WakeLockListener.h +++ /dev/null @@ -1,25 +0,0 @@ -/* 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 "mozwrlbase.h" - -#include "nscore.h" -#include "nsString.h" -#include "nsIDOMWakeLockListener.h" - -#include - -/* - * A wake lock is used by dom to prevent the device from turning off the - * screen when the user is viewing certain types of content, like video. - */ -class WakeLockListener : - public nsIDOMMozWakeLockListener { -public: - NS_DECL_ISUPPORTS; - NS_DECL_NSIDOMMOZWAKELOCKLISTENER; - -private: - Microsoft::WRL::ComPtr mDisplayRequest; -}; diff --git a/widget/windows/winrt/moz.build b/widget/windows/winrt/moz.build deleted file mode 100644 index be72f7038..000000000 --- a/widget/windows/winrt/moz.build +++ /dev/null @@ -1,52 +0,0 @@ -# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# 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/. - -SOURCES += [ - 'APZController.cpp', - 'FrameworkView.cpp', - 'MetroApp.cpp', - 'MetroAppShell.cpp', - 'MetroContracts.cpp', - 'MetroInput.cpp', - 'MetroUtils.cpp', - 'MetroWidget.cpp', - 'nsMetroFilePicker.cpp', - 'nsWinMetroUtils.cpp', - 'ToastNotificationHandler.cpp', - 'UIAAccessibilityBridge.cpp', - 'UIABridge.cpp', - 'WakeLockListener.cpp', -] - -EXTRA_COMPONENTS += [ - 'MetroUIUtils.js', - 'MetroUIUtils.manifest', -] - -EXPORTS.mozilla.widget += [ - 'MetroD3DCheckHelper.h', -] - -include('/ipc/chromium/chromium-config.mozbuild') - -FINAL_LIBRARY = 'xul' - -LOCAL_INCLUDES += [ - '../', - '/layout/generic', - '/layout/xul', - '/toolkit/xre', - '/widget', - '/xpcom/base', -] - -DEFINES['MOZ_UNICODE'] = True - -for var in ('MOZ_ENABLE_D3D9_LAYER', 'MOZ_ENABLE_D3D10_LAYER'): - if CONFIG[var]: - DEFINES[var] = True - -CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS'] diff --git a/widget/windows/winrt/mozwrlbase.h b/widget/windows/winrt/mozwrlbase.h deleted file mode 100644 index d82be8f04..000000000 --- a/widget/windows/winrt/mozwrlbase.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#pragma once - -/* - * Includes and it's children. Defines imports needed by - * corewrappers.h in the case where windows.h has already been - * included w/WINVER < 0x600. Also ups WINVER/_WIN32_WINNT prior - * to including wrl.h. Mozilla's build currently has WINVER set to - * 0x502 for XP support. - */ - -#if _WIN32_WINNT < 0x600 - -#include - -VOID -WINAPI -ReleaseSRWLockExclusive( - _Inout_ PSRWLOCK SRWLock - ); - -VOID -WINAPI -ReleaseSRWLockShared( - _Inout_ PSRWLOCK SRWLock - ); - -BOOL -WINAPI -InitializeCriticalSectionEx( - _Out_ LPCRITICAL_SECTION lpCriticalSection, - _In_ DWORD dwSpinCount, - _In_ DWORD Flags - ); - -VOID -WINAPI -InitializeSRWLock( - _Out_ PSRWLOCK SRWLock - ); - -VOID -WINAPI -AcquireSRWLockExclusive( - _Inout_ PSRWLOCK SRWLock - ); - -BOOLEAN -WINAPI -TryAcquireSRWLockExclusive( - _Inout_ PSRWLOCK SRWLock - ); - -BOOLEAN -WINAPI -TryAcquireSRWLockShared( - _Inout_ PSRWLOCK SRWLock - ); - -VOID -WINAPI -AcquireSRWLockShared( - _Inout_ PSRWLOCK SRWLock - ); - -#undef WINVER -#undef _WIN32_WINNT -#define WINVER 0x600 -#define _WIN32_WINNT 0x600 - -#endif // _WIN32_WINNT < 0x600 - -#include diff --git a/widget/windows/winrt/nsMetroFilePicker.cpp b/widget/windows/winrt/nsMetroFilePicker.cpp deleted file mode 100644 index 0d9097fa5..000000000 --- a/widget/windows/winrt/nsMetroFilePicker.cpp +++ /dev/null @@ -1,484 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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 "nsMetroFilePicker.h" -#include "nsComponentManagerUtils.h" -#include "nsNetUtil.h" -#include "nsAutoPtr.h" -#include "MetroUtils.h" - -#include -#include - -using namespace ABI::Windows::Foundation; -using namespace ABI::Windows::Foundation::Collections; -using namespace ABI::Windows::Storage; -using namespace ABI::Windows::Storage::Pickers; -using namespace ABI::Windows::Storage::Streams; -using namespace ABI::Windows::UI; -using namespace ABI::Windows::UI::ViewManagement; -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; -using namespace mozilla::widget::winrt; - -/////////////////////////////////////////////////////////////////////////////// -// nsIFilePicker - -nsMetroFilePicker::nsMetroFilePicker() -{ -} - -nsMetroFilePicker::~nsMetroFilePicker() -{ -} - -NS_IMPL_ISUPPORTS(nsMetroFilePicker, nsIFilePicker) - -NS_IMETHODIMP -nsMetroFilePicker::Init(nsIDOMWindow *parent, const nsAString& title, int16_t mode) -{ - mMode = mode; - HRESULT hr; - switch(mMode) { - case nsIFilePicker::modeOpen: - case nsIFilePicker::modeOpenMultiple: - hr = ActivateGenericInstance(RuntimeClass_Windows_Storage_Pickers_FileOpenPicker, mFileOpenPicker); - AssertRetHRESULT(hr, NS_ERROR_UNEXPECTED); - return NS_OK; - case nsIFilePicker::modeSave: - hr = ActivateGenericInstance(RuntimeClass_Windows_Storage_Pickers_FileSavePicker, mFileSavePicker); - AssertRetHRESULT(hr, NS_ERROR_UNEXPECTED); - return NS_OK; - default: - return NS_ERROR_NOT_IMPLEMENTED; - } -} - -NS_IMETHODIMP -nsMetroFilePicker::Show(int16_t *aReturnVal) -{ - // Metro file picker only offers an async variant which calls back to the - // UI thread, which is the main thread. We therefore can't call it - // synchronously from the main thread. - return NS_ERROR_NOT_IMPLEMENTED; -} - -HRESULT nsMetroFilePicker::OnPickSingleFile(IAsyncOperation* aFile, - AsyncStatus aStatus) -{ - if (aStatus != ABI::Windows::Foundation::AsyncStatus::Completed) { - if (mCallback) - mCallback->Done(nsIFilePicker::returnCancel); - return S_OK; - } - - HRESULT hr; - ComPtr file; - hr = aFile->GetResults(file.GetAddressOf()); - // When the user cancels hr == S_OK and file is nullptr - if (FAILED(hr) || !file) { - if (mCallback) - mCallback->Done(nsIFilePicker::returnCancel); - return S_OK; - } - ComPtr storageItem; - hr = file.As(&storageItem); - if (FAILED(hr)) { - if (mCallback) - mCallback->Done(nsIFilePicker::returnCancel); - return S_OK; - } - - HSTRING path; - if (FAILED(storageItem->get_Path(&path))) { - if (mCallback) - mCallback->Done(nsIFilePicker::returnCancel); - return S_OK; - } - WindowsDuplicateString(path, mFilePath.GetAddressOf()); - WindowsDeleteString(path); - - if (mCallback) { - mCallback->Done(nsIFilePicker::returnOK); - } - return S_OK; -} - -HRESULT nsMetroFilePicker::OnPickMultipleFiles(IAsyncOperation*>* aFileList, - AsyncStatus aStatus) -{ - if (aStatus != ABI::Windows::Foundation::AsyncStatus::Completed) { - if (mCallback) - mCallback->Done(nsIFilePicker::returnCancel); - return S_OK; - } - - HRESULT hr; - ComPtr> view; - hr = aFileList->GetResults(view.GetAddressOf()); - if (FAILED(hr)) { - if (mCallback) - mCallback->Done(nsIFilePicker::returnCancel); - return S_OK; - } - - unsigned int length; - view->get_Size(&length); - for (unsigned int idx = 0; idx < length; idx++) { - ComPtr file; - hr = view->GetAt(idx, file.GetAddressOf()); - if (FAILED(hr)) { - continue; - } - - ComPtr storageItem; - hr = file.As(&storageItem); - if (FAILED(hr)) { - continue; - } - - HSTRING path; - if (SUCCEEDED(storageItem->get_Path(&path))) { - nsCOMPtr file = - do_CreateInstance("@mozilla.org/file/local;1"); - unsigned int tmp; - if (NS_SUCCEEDED(file->InitWithPath( - nsAutoString(WindowsGetStringRawBuffer(path, &tmp))))) { - mFiles.AppendObject(file); - } - } - WindowsDeleteString(path); - } - - if (mCallback) { - mCallback->Done(nsIFilePicker::returnOK); - } - return S_OK; -} - -NS_IMETHODIMP -nsMetroFilePicker::Open(nsIFilePickerShownCallback *aCallback) -{ - HRESULT hr; - // Capture a reference to the callback which we'll also pass into the - // closure to ensure it's not freed. - mCallback = aCallback; - - // The filepicker cannot open when in snapped view, try to unsnapp - // before showing the filepicker. - ApplicationViewState viewState; - MetroUtils::GetViewState(viewState); - if (viewState == ApplicationViewState::ApplicationViewState_Snapped) { - bool unsnapped = SUCCEEDED(MetroUtils::TryUnsnap()); - NS_ENSURE_TRUE(unsnapped, NS_ERROR_FAILURE); - } - - switch(mMode) { - case nsIFilePicker::modeOpen: { - NS_ENSURE_ARG_POINTER(mFileOpenPicker); - - // Initiate the file picker operation - ComPtr> asyncOperation; - hr = mFileOpenPicker->PickSingleFileAsync(asyncOperation.GetAddressOf()); - AssertRetHRESULT(hr, NS_ERROR_FAILURE); - - // Subscribe to the completed event - ComPtr> - completedHandler(Callback>( - this, &nsMetroFilePicker::OnPickSingleFile)); - hr = asyncOperation->put_Completed(completedHandler.Get()); - AssertRetHRESULT(hr, NS_ERROR_UNEXPECTED); - break; - } - - case nsIFilePicker::modeOpenMultiple: { - NS_ENSURE_ARG_POINTER(mFileOpenPicker); - - typedef IVectorView StorageTemplate; - typedef IAsyncOperation AsyncCallbackTemplate; - typedef IAsyncOperationCompletedHandler HandlerTemplate; - - // Initiate the file picker operation - ComPtr asyncOperation; - hr = mFileOpenPicker->PickMultipleFilesAsync(asyncOperation.GetAddressOf()); - AssertRetHRESULT(hr, NS_ERROR_FAILURE); - - // Subscribe to the completed event - ComPtr completedHandler(Callback( - this, &nsMetroFilePicker::OnPickMultipleFiles)); - hr = asyncOperation->put_Completed(completedHandler.Get()); - AssertRetHRESULT(hr, NS_ERROR_UNEXPECTED); - break; - } - - case nsIFilePicker::modeSave: { - NS_ENSURE_ARG_POINTER(mFileSavePicker); - - // Set the default file name - mFileSavePicker->put_SuggestedFileName(HStringReference(mDefaultFilename.BeginReading()).Get()); - - // Set the default file extension - if (mDefaultExtension.Length() > 0) { - nsAutoString defaultFileExtension(mDefaultExtension); - - // Touch up the extansion format platform hands us. - if (defaultFileExtension[0] == L'*') { - defaultFileExtension.Cut(0, 1); - } else if (defaultFileExtension[0] != L'.') { - defaultFileExtension.Insert(L".", 0); - } - - // Sometimes the default file extension is not passed in correctly, - // so we purposfully ignore failures here. - HString ext; - ext.Set(defaultFileExtension.BeginReading()); - hr = mFileSavePicker->put_DefaultFileExtension(ext.Get()); - NS_ASSERTION(SUCCEEDED(hr), "put_DefaultFileExtension failed, bad format for extension?"); - - // Due to a bug in the WinRT file picker, the first file extension in the - // list is always used when saving a file. So we explicitly make sure the - // default extension is the first one in the list here. - if (mFirstTitle.Get()) { - ComPtr*>> map; - mFileSavePicker->get_FileTypeChoices(map.GetAddressOf()); - if (map) { - boolean found = false; - unsigned int index; - map->HasKey(mFirstTitle.Get(), &found); - if (found) { - ComPtr> list; - if (SUCCEEDED(map->Lookup(mFirstTitle.Get(), list.GetAddressOf()))) { - HString ext; - ext.Set(defaultFileExtension.get()); - found = false; - list->IndexOf(HStringReference(defaultFileExtension.get()).Get(), &index, &found); - if (found) { - list->RemoveAt(index); - list->InsertAt(0, HStringReference(defaultFileExtension.get()).Get()); - } - } - } - } - } - } - - // Dispatch the async show operation - ComPtr> asyncOperation; - hr = mFileSavePicker->PickSaveFileAsync(asyncOperation.GetAddressOf()); - AssertRetHRESULT(hr, NS_ERROR_FAILURE); - - // Subscribe to the completed event - ComPtr> - completedHandler(Callback>( - this, &nsMetroFilePicker::OnPickSingleFile)); - hr = asyncOperation->put_Completed(completedHandler.Get()); - AssertRetHRESULT(hr, NS_ERROR_UNEXPECTED); - break; - } - - case modeGetFolder: - return NS_ERROR_NOT_IMPLEMENTED; - - default: - return NS_ERROR_NOT_IMPLEMENTED; - } - return NS_OK; -} - -NS_IMETHODIMP -nsMetroFilePicker::GetFile(nsIFile **aFile) -{ - NS_ENSURE_ARG_POINTER(aFile); - *aFile = nullptr; - - if (WindowsIsStringEmpty(mFilePath.Get())) - return NS_OK; - - nsCOMPtr file(do_CreateInstance("@mozilla.org/file/local;1")); - NS_ENSURE_TRUE(file, NS_ERROR_FAILURE); - unsigned int length; - file->InitWithPath(nsAutoString(mFilePath.GetRawBuffer(&length))); - NS_ADDREF(*aFile = file); - return NS_OK; -} - -NS_IMETHODIMP -nsMetroFilePicker::GetFileURL(nsIURI **aFileURL) -{ - *aFileURL = nullptr; - nsCOMPtr file; - nsresult rv = GetFile(getter_AddRefs(file)); - if (!file) - return rv; - - return NS_NewFileURI(aFileURL, file); -} - -NS_IMETHODIMP -nsMetroFilePicker::GetFiles(nsISimpleEnumerator **aFiles) -{ - NS_ENSURE_ARG_POINTER(aFiles); - return NS_NewArrayEnumerator(aFiles, mFiles); -} - -// Set the filter index -NS_IMETHODIMP -nsMetroFilePicker::GetFilterIndex(int32_t *aFilterIndex) -{ - // No associated concept with a Metro file picker - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsMetroFilePicker::SetFilterIndex(int32_t aFilterIndex) -{ - // No associated concept with a Metro file picker - return NS_ERROR_NOT_IMPLEMENTED; -} - -// AFACT, it's up to use to supply the implementation of a vector list. -class MozHStringVector : public RuntimeClass> { - InspectableClass(L"MozHStringVector", TrustLevel::BaseTrust) - ~MozHStringVector() { - Clear(); - } - - // See IVector_impl in windows.foundation.collections.h -public: - STDMETHOD(GetAt)(unsigned aIndex, HSTRING* aString) { - if (aIndex >= mList.Length()) { - return E_INVALIDARG; - } - return WindowsDuplicateString(mList[aIndex], aString); - } - - STDMETHOD(get_Size)(unsigned int* aLength) { - if (!aLength) { - return E_INVALIDARG; - } - *aLength = mList.Length(); - return S_OK; - } - - STDMETHOD(Append)(HSTRING aString) { - HSTRING str; - if (FAILED(WindowsDuplicateString(aString, &str))) { - return E_INVALIDARG; - } - mList.AppendElement(str); - return S_OK; - } - - STDMETHOD(Clear)() { - int length = mList.Length(); - for (int idx = 0; idx < length; idx++) - WindowsDeleteString(mList[idx]); - mList.Clear(); - return S_OK; - } - - // interfaces picker code doesn't seem to need - STDMETHOD(GetView)(IVectorView **aView) { return E_NOTIMPL; } - STDMETHOD(IndexOf)(HSTRING aValue, unsigned *aIndex, boolean *found) { return E_NOTIMPL; } - STDMETHOD(SetAt)(unsigned aIndex, HSTRING aString) { return E_NOTIMPL; } - STDMETHOD(InsertAt)(unsigned aIndex, HSTRING aString) { return E_NOTIMPL; } - STDMETHOD(RemoveAt)(unsigned aIndex) { return E_NOTIMPL; } - STDMETHOD(RemoveAtEnd)() { return E_NOTIMPL; } - -private: - nsTArray mList; -}; - -nsresult -nsMetroFilePicker::ParseFiltersIntoVector(ComPtr>& aVector, - const nsAString& aFilter, - bool aAllowAll) -{ - const char16_t *beg = aFilter.BeginReading(); - const char16_t *end = aFilter.EndReading(); - for (const char16_t *cur = beg, *fileTypeStart = beg; cur <= end; ++cur) { - // Start of a a filetype, example: *.png - if (cur == end || char16_t(' ') == *cur) { - int32_t startPos = fileTypeStart - beg; - int32_t endPos = cur - fileTypeStart - (cur == end ? 0 : 1); - const nsAString& fileType = Substring(aFilter, - startPos, - endPos); - // There is no way to say show all files in Metro save file picker, so - // just use .data if * or *.* is specified. - if (fileType.IsEmpty() || - fileType.Equals(L"*") || - fileType.Equals(L"*.*")) { - HString str; - if (aAllowAll) { - str.Set(L"*"); - aVector->Append(str.Get()); - } else { - str.Set(L".data"); - aVector->Append(str.Get()); - } - } else { - nsAutoString filter(fileType); - if (filter[0] == L'*') { - filter.Cut(0, 1); - } else if (filter[0] != L'.') { - filter.Insert(L".", 0); - } - HString str; - str.Set(filter.BeginReading()); - aVector->Append(str.Get()); - } - - fileTypeStart = cur + 1; - } - } - return NS_OK; -} - -NS_IMETHODIMP -nsMetroFilePicker::AppendFilter(const nsAString& aTitle, - const nsAString& aFilter) -{ - HRESULT hr; - switch(mMode) { - case nsIFilePicker::modeOpen: - case nsIFilePicker::modeOpenMultiple: { - NS_ENSURE_ARG_POINTER(mFileOpenPicker); - ComPtr> list; - mFileOpenPicker->get_FileTypeFilter(list.GetAddressOf()); - nsresult rv = ParseFiltersIntoVector(list, aFilter, true); - NS_ENSURE_SUCCESS(rv, rv); - } - - case nsIFilePicker::modeSave: { - NS_ENSURE_ARG_POINTER(mFileSavePicker); - - ComPtr*>> map; - hr = mFileSavePicker->get_FileTypeChoices(map.GetAddressOf()); - AssertRetHRESULT(hr, NS_ERROR_FAILURE); - - HString key; - key.Set(aTitle.BeginReading()); - - ComPtr> saveTypes; - saveTypes = Make(); - nsresult rv = ParseFiltersIntoVector(saveTypes, aFilter, false); - NS_ENSURE_SUCCESS(rv, rv); - - if (WindowsIsStringEmpty(mFirstTitle.Get())) { - mFirstTitle.Set(key.Get()); - } - - boolean replaced; - map->Insert(key.Get(), saveTypes.Get(), &replaced); - } - break; - - default: - return NS_ERROR_FAILURE; - } - return NS_OK; -} - diff --git a/widget/windows/winrt/nsMetroFilePicker.h b/widget/windows/winrt/nsMetroFilePicker.h deleted file mode 100644 index 0117111dd..000000000 --- a/widget/windows/winrt/nsMetroFilePicker.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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 nsMetroFilePicker_h__ -#define nsMetroFilePicker_h__ - -#include "../nsFilePicker.h" -#include "nsString.h" -#include "nsCOMArray.h" -#include "nsCOMPtr.h" -#include "nsILocalFile.h" - -#include "mozwrlbase.h" - -#include -#include -#include -#include -#include - -/** - * Metro file picker - */ - -class nsMetroFilePicker : - public nsBaseWinFilePicker -{ - typedef Microsoft::WRL::Wrappers::HString HString; - typedef ABI::Windows::Storage::StorageFile StorageFile; - typedef ABI::Windows::Foundation::AsyncStatus AsyncStatus; - -public: - nsMetroFilePicker(); - virtual ~nsMetroFilePicker(); - - NS_DECL_ISUPPORTS - - // nsIFilePicker (less what's in nsBaseFilePicker) - NS_IMETHOD GetFilterIndex(int32_t *aFilterIndex); - NS_IMETHOD SetFilterIndex(int32_t aFilterIndex); - NS_IMETHOD GetFile(nsIFile * *aFile); - NS_IMETHOD GetFileURL(nsIURI * *aFileURL); - NS_IMETHOD GetFiles(nsISimpleEnumerator **aFiles); - NS_IMETHOD Show(int16_t *aReturnVal); - NS_IMETHOD Open(nsIFilePickerShownCallback *aCallback); - NS_IMETHOD AppendFilter(const nsAString& aTitle, const nsAString& aFilter); - NS_IMETHOD Init(nsIDOMWindow *parent, const nsAString& title, - int16_t mode); - - // Async callbacks - HRESULT OnPickSingleFile(ABI::Windows::Foundation::IAsyncOperation* aFile, AsyncStatus aStatus); - HRESULT OnPickMultipleFiles(ABI::Windows::Foundation::IAsyncOperation*>* aFileList, AsyncStatus aStatus); - -private: - void InitNative(nsIWidget*, const nsAString&) {}; - nsresult ParseFiltersIntoVector(Microsoft::WRL::ComPtr>& aVector, - const nsAString& aFilter, - bool aAllowAll); - nsCOMArray mFiles; - Microsoft::WRL::ComPtr mFileOpenPicker; - Microsoft::WRL::ComPtr mFileSavePicker; - HString mFilePath; - HString mFirstTitle; - nsRefPtr mCallback; -}; - -#endif // nsMetroFilePicker_h__ diff --git a/widget/windows/winrt/nsWinMetroUtils.cpp b/widget/windows/winrt/nsWinMetroUtils.cpp deleted file mode 100644 index 67cff5dd5..000000000 --- a/widget/windows/winrt/nsWinMetroUtils.cpp +++ /dev/null @@ -1,402 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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 "nsWinMetroUtils.h" -#include "MetroUtils.h" -#include "nsXULAppAPI.h" -#include "FrameworkView.h" -#include "MetroApp.h" -#include "ToastNotificationHandler.h" -#include "mozilla/Preferences.h" -#include "mozilla/WindowsVersion.h" -#include "nsIWindowsRegKey.h" -#include "mozilla/widget/MetroD3DCheckHelper.h" - -#include -#include -#include -#include - -using namespace ABI::Windows::Foundation; -using namespace ABI::Windows::UI::StartScreen; -using namespace ABI::Windows::UI::ViewManagement; -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; -using namespace mozilla::widget::winrt; - -namespace mozilla { -namespace widget { -namespace winrt { -extern ComPtr sMetroApp; -extern nsTArray* sSettingsArray; -} } } - -namespace mozilla { -namespace widget { - -bool nsWinMetroUtils::sUpdatePending = false; - -NS_IMPL_ISUPPORTS(nsWinMetroUtils, nsIWinMetroUtils) - -nsWinMetroUtils::nsWinMetroUtils() -{ -} - -nsWinMetroUtils::~nsWinMetroUtils() -{ -} - -/** - * Pins a new tile to the Windows 8 start screen. - * - * @param aTileID An ID which can later be used to remove the tile - * @param aShortName A short name for the tile - * @param aDiplayName The name that will be displayed on the tile - * @param aActivationArgs The arguments to pass to the browser upon - * activation of the tile - * @param aTileImage An image for the normal tile view - * @param aSmallTileImage An image for the small tile view - */ -NS_IMETHODIMP -nsWinMetroUtils::PinTileAsync(const nsAString &aTileID, - const nsAString &aShortName, - const nsAString &aDisplayName, - const nsAString &aActivationArgs, - const nsAString &aTileImage, - const nsAString &aSmallTileImage) -{ - if (XRE_GetWindowsEnvironment() != WindowsEnvironmentType_Metro) { - NS_WARNING("PinTileAsync can't be called on the desktop."); - return NS_ERROR_FAILURE; - } - HRESULT hr; - - HString logoStr, smallLogoStr, displayName, shortName; - - logoStr.Set(aTileImage.BeginReading()); - smallLogoStr.Set(aSmallTileImage.BeginReading()); - displayName.Set(aDisplayName.BeginReading()); - shortName.Set(aShortName.BeginReading()); - - ComPtr logo, smallLogo; - AssertRetHRESULT(MetroUtils::CreateUri(logoStr, logo), NS_ERROR_FAILURE); - AssertRetHRESULT(MetroUtils::CreateUri(smallLogoStr, smallLogo), NS_ERROR_FAILURE); - - HString tileActivationArgumentsStr, tileIdStr; - tileActivationArgumentsStr.Set(aActivationArgs.BeginReading()); - tileIdStr.Set(aTileID.BeginReading()); - - ComPtr tileFactory; - ComPtr secondaryTile; - hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_StartScreen_SecondaryTile).Get(), - tileFactory.GetAddressOf()); - AssertRetHRESULT(hr, NS_ERROR_FAILURE); - hr = tileFactory->CreateWithId(tileIdStr.Get(), secondaryTile.GetAddressOf()); - AssertRetHRESULT(hr, NS_ERROR_FAILURE); - - secondaryTile->put_Logo(logo.Get()); - secondaryTile->put_SmallLogo(smallLogo.Get()); - secondaryTile->put_DisplayName(displayName.Get()); - secondaryTile->put_ShortName(shortName.Get()); - secondaryTile->put_Arguments(tileActivationArgumentsStr.Get()); - secondaryTile->put_TileOptions(TileOptions::TileOptions_ShowNameOnLogo); - - // The tile is created and we can now attempt to pin the tile. - ComPtr> callback(Callback>( - sMetroApp.Get(), &MetroApp::OnAsyncTileCreated)); - ComPtr> operation; - AssertRetHRESULT(secondaryTile->RequestCreateAsync(operation.GetAddressOf()), NS_ERROR_FAILURE); - operation->put_Completed(callback.Get()); - return NS_OK; -} - -/** - * Unpins a tile from the Windows 8 start screen. - * - * @param aTileID An existing ID which was previously pinned - */ -NS_IMETHODIMP -nsWinMetroUtils::UnpinTileAsync(const nsAString &aTileID) -{ - if (XRE_GetWindowsEnvironment() != WindowsEnvironmentType_Metro) { - NS_WARNING("UnpinTileAsync can't be called on the desktop."); - return NS_ERROR_FAILURE; - } - HRESULT hr; - HString tileIdStr; - tileIdStr.Set(aTileID.BeginReading()); - - ComPtr tileFactory; - ComPtr secondaryTile; - hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_StartScreen_SecondaryTile).Get(), - tileFactory.GetAddressOf()); - AssertRetHRESULT(hr, NS_ERROR_FAILURE); - hr = tileFactory->CreateWithId(tileIdStr.Get(), secondaryTile.GetAddressOf()); - AssertRetHRESULT(hr, NS_ERROR_FAILURE); - - // Attempt to unpin the tile - ComPtr> callback(Callback>( - sMetroApp.Get(), &MetroApp::OnAsyncTileCreated)); - ComPtr> operation; - AssertRetHRESULT(secondaryTile->RequestDeleteAsync(operation.GetAddressOf()), NS_ERROR_FAILURE); - operation->put_Completed(callback.Get()); - return NS_OK; -} - -/** - * Determines if a tile is pinned to the Windows 8 start screen. - * - * @param aTileID An ID which may have been pinned with pinTileAsync - * @param aIsPinned Out parameter for determining if the tile is pinned or not - */ -NS_IMETHODIMP -nsWinMetroUtils::IsTilePinned(const nsAString &aTileID, bool *aIsPinned) -{ - if (XRE_GetWindowsEnvironment() != WindowsEnvironmentType_Metro) { - NS_WARNING("IsTilePinned can't be called on the desktop."); - return NS_ERROR_FAILURE; - } - NS_ENSURE_ARG_POINTER(aIsPinned); - - HRESULT hr; - HString tileIdStr; - tileIdStr.Set(aTileID.BeginReading()); - - ComPtr tileStatics; - hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_StartScreen_SecondaryTile).Get(), - tileStatics.GetAddressOf()); - AssertRetHRESULT(hr, NS_ERROR_FAILURE); - boolean result = false; - tileStatics->Exists(tileIdStr.Get(), &result); - *aIsPinned = result; - return NS_OK; -} - -/** - * Launches the specified application with the specified arguments and - * switches to Desktop mode if in metro mode. -*/ -NS_IMETHODIMP -nsWinMetroUtils::LaunchInDesktop(const nsAString &aPath, const nsAString &aArguments) -{ - SHELLEXECUTEINFOW sinfo; - memset(&sinfo, 0, sizeof(SHELLEXECUTEINFOW)); - sinfo.cbSize = sizeof(SHELLEXECUTEINFOW); - // Per the Metro style enabled desktop browser, for some reason, - // SEE_MASK_FLAG_LOG_USAGE is needed to change from immersive mode - // to desktop. - sinfo.fMask = SEE_MASK_FLAG_LOG_USAGE; - sinfo.hwnd = nullptr; - sinfo.lpFile = aPath.BeginReading(); - sinfo.lpParameters = aArguments.BeginReading(); - sinfo.lpVerb = L"open"; - sinfo.nShow = SW_SHOWNORMAL; - - if (!ShellExecuteEx(&sinfo)) { - return NS_ERROR_FAILURE; - } - return NS_OK; -} - -NS_IMETHODIMP -nsWinMetroUtils::ShowNativeToast(const nsAString &aTitle, - const nsAString &aMessage, const nsAString &anImage, - const nsAString &aCookie, const nsAString& aAppId) -{ - ToastNotificationHandler* notification_handler = - new ToastNotificationHandler; - - HSTRING title = HStringReference(aTitle.BeginReading()).Get(); - HSTRING msg = HStringReference(aMessage.BeginReading()).Get(); - - bool ret; - if (anImage.Length() > 0) { - HSTRING imagePath = HStringReference(anImage.BeginReading()).Get(); - ret = notification_handler->DisplayNotification(title, msg, imagePath, - aCookie, - aAppId); - } else { - ret = notification_handler->DisplayTextNotification(title, msg, aCookie, - aAppId); - } - - if (!ret) { - delete notification_handler; - return NS_ERROR_FAILURE; - } - - return NS_OK; -} - -NS_IMETHODIMP -nsWinMetroUtils::ShowSettingsFlyout() -{ - if (XRE_GetWindowsEnvironment() != WindowsEnvironmentType_Metro) { - NS_WARNING("Settings flyout can't be shown on the desktop."); - return NS_ERROR_FAILURE; - } - - HRESULT hr = MetroUtils::ShowSettingsFlyout(); - return SUCCEEDED(hr) ? NS_OK : NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsWinMetroUtils::GetImmersive(bool *aImersive) -{ - *aImersive = - XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro; - return NS_OK; -} - -NS_IMETHODIMP -nsWinMetroUtils::GetActivationURI(nsAString &aActivationURI) -{ - if (XRE_GetWindowsEnvironment() != WindowsEnvironmentType_Metro) { - return NS_ERROR_FAILURE; - } - FrameworkView::GetActivationURI(aActivationURI); - return NS_OK; -} - -NS_IMETHODIMP -nsWinMetroUtils::GetPreviousExecutionState(int32_t *out) -{ - if (XRE_GetWindowsEnvironment() != WindowsEnvironmentType_Metro) { - return NS_ERROR_FAILURE; - } - *out = FrameworkView::GetPreviousExecutionState(); - return NS_OK; -} - -NS_IMETHODIMP -nsWinMetroUtils::GetKeyboardVisible(bool *aImersive) -{ - *aImersive = FrameworkView::IsKeyboardVisible(); - return NS_OK; -} - -NS_IMETHODIMP -nsWinMetroUtils::GetKeyboardX(uint32_t *aX) -{ - *aX = static_cast(floor(FrameworkView::KeyboardVisibleRect().X)); - return NS_OK; -} - -NS_IMETHODIMP -nsWinMetroUtils::GetKeyboardY(uint32_t *aY) -{ - *aY = static_cast(floor(FrameworkView::KeyboardVisibleRect().Y)); - return NS_OK; -} - -NS_IMETHODIMP -nsWinMetroUtils::GetKeyboardWidth(uint32_t *aWidth) -{ - *aWidth = static_cast(ceil(FrameworkView::KeyboardVisibleRect().Width)); - return NS_OK; -} - -NS_IMETHODIMP -nsWinMetroUtils::GetKeyboardHeight(uint32_t *aHeight) -{ - *aHeight = static_cast(ceil(FrameworkView::KeyboardVisibleRect().Height)); - return NS_OK; -} - -NS_IMETHODIMP -nsWinMetroUtils::AddSettingsPanelEntry(const nsAString &aLabel, uint32_t *aId) -{ - NS_ENSURE_ARG_POINTER(aId); - if (!sSettingsArray) - return NS_ERROR_UNEXPECTED; - - *aId = sSettingsArray->Length(); - sSettingsArray->AppendElement(nsString(aLabel)); - return NS_OK; -} - -NS_IMETHODIMP -nsWinMetroUtils::SwapMouseButton(bool aValue, bool *aOriginalValue) -{ - *aOriginalValue = ::SwapMouseButton(aValue); - return NS_OK; -} - -NS_IMETHODIMP -nsWinMetroUtils::GetUpdatePending(bool *aUpdatePending) -{ - *aUpdatePending = sUpdatePending; - return NS_OK; -} - -NS_IMETHODIMP -nsWinMetroUtils::SetUpdatePending(bool aUpdatePending) -{ - sUpdatePending = aUpdatePending; - return NS_OK; -} - -NS_IMETHODIMP -nsWinMetroUtils::GetForeground(bool* aForeground) -{ - *aForeground = (::GetActiveWindow() == ::GetForegroundWindow()); - return NS_OK; -} - -NS_IMETHODIMP -nsWinMetroUtils::GetSupported(bool *aSupported) -{ - *aSupported = false; - if (!IsWin8OrLater()) { - return NS_OK; - } - - // if last_used_feature_level_idx is set, we've previously created a - // d3d device that's compatible. See gfxEindowsPlatform for details. - if (Preferences::GetInt("gfx.direct3d.last_used_feature_level_idx", -1) != -1) { - *aSupported = true; - return NS_OK; - } - - // if last_used_feature_level_idx isn't set, gfx hasn't attempted to create - // a device yet. This could be a case where d2d is pref'd off or blacklisted - // on desktop, or we tried to create a device and failed. This could also be - // a first run case where we haven't created an accelerated top level window - // yet. - - NS_NAMED_LITERAL_STRING(metroRegValueName, "MetroD3DAvailable"); - NS_NAMED_LITERAL_STRING(metroRegValuePath, "Software\\Mozilla\\Firefox"); - - // Check to see if the ceh launched us, it also does this check and caches - // a flag in the registry. - nsresult rv; - uint32_t value = 0; - nsCOMPtr regKey = - do_CreateInstance("@mozilla.org/windows-registry-key;1", &rv); - if (NS_SUCCEEDED(rv)) { - rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER, - metroRegValuePath, - nsIWindowsRegKey::ACCESS_ALL); - if (NS_SUCCEEDED(rv)) { - rv = regKey->ReadIntValue(metroRegValueName, &value); - if (NS_SUCCEEDED(rv)) { - *aSupported = (bool)value; - return NS_OK; - } - - // If all else fails, do the check here. This call is costly but - // we shouldn't hit this except in rare situations where the - // ceh never launched the browser that's running. - value = D3DFeatureLevelCheck(); - regKey->WriteIntValue(metroRegValueName, value); - *aSupported = (bool)value; - return NS_OK; - } - } - return NS_OK; -} - -} // widget -} // mozilla diff --git a/widget/windows/winrt/nsWinMetroUtils.h b/widget/windows/winrt/nsWinMetroUtils.h deleted file mode 100644 index 41072725b..000000000 --- a/widget/windows/winrt/nsWinMetroUtils.h +++ /dev/null @@ -1,27 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#pragma once - -#include "nsIWinMetroUtils.h" -#include "nsString.h" - -namespace mozilla { -namespace widget { - -class nsWinMetroUtils : public nsIWinMetroUtils -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIWINMETROUTILS - - nsWinMetroUtils(); - virtual ~nsWinMetroUtils(); - - static bool sUpdatePending; -}; - -} // widget -} // mozilla -- cgit v1.2.3