summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPale Moon <git-repo@palemoon.org>2017-01-02 17:15:45 +0100
committerPale Moon <git-repo@palemoon.org>2017-01-02 17:15:45 +0100
commitfe4797de943f1f9350a332e4baa8b181b5062f7b (patch)
tree1f6758fd50b2ee977655c00d5a37277ecf2375f6
parentc2e68c5c2591116dbd0e7da0aadf9f27dd910dc7 (diff)
downloadpalemoon-gre-fe4797de943f1f9350a332e4baa8b181b5062f7b.tar.gz
Remove Windows Metro/WinRT code.
-rw-r--r--CLOBBER2
-rw-r--r--accessible/windows/msaa/AccessibleWrap.cpp7
-rw-r--r--browser/app/nsBrowserApp.cpp47
-rw-r--r--browser/app/profile/firefox.js2
-rw-r--r--build/automation.py.in11
-rw-r--r--build/valgrind/cross-architecture.sup9
-rw-r--r--build/win32/mozconfig.vs2010-win644
-rw-r--r--build/win32/mozconfig.vs2013-win644
-rw-r--r--build/win64/mozconfig.vs20104
-rw-r--r--build/win64/mozconfig.vs20134
-rw-r--r--config/recurse.mk2
-rw-r--r--configure.in26
-rw-r--r--dom/base/nsContentUtils.h2
-rw-r--r--dom/svg/SVGDocument.cpp4
-rw-r--r--gfx/doc/AsyncPanZoom.md2
-rw-r--r--gfx/layers/d3d11/CompositorD3D11.cpp54
-rw-r--r--gfx/thebes/gfxWindowsPlatform.cpp7
-rw-r--r--ipc/glue/WindowsMessageLoop.cpp15
-rw-r--r--js/src/configure.in9
-rw-r--r--layout/reftests/forms/input/color/reftest.list3
-rw-r--r--modules/libpref/Preferences.cpp10
-rw-r--r--profile/dirserviceprovider/nsProfileDirServiceProvider.cpp6
-rw-r--r--services/datareporting/DataReporting.manifest1
-rw-r--r--services/sync/SyncComponents.manifest3
-rw-r--r--services/sync/tps/extensions/mozmill/resource/driver/controller.js20
-rw-r--r--services/sync/tps/extensions/mozmill/resource/stdlib/utils.js11
-rw-r--r--startupcache/StartupCache.cpp12
-rw-r--r--testing/mochitest/Makefile.in3
-rw-r--r--testing/mochitest/browser-harness.xul1
-rw-r--r--testing/mochitest/browser-test.js1
-rw-r--r--testing/mozbase/mozrunner/mozrunner/runners.py19
-rw-r--r--testing/profiles/prefs_general.js4
-rw-r--r--toolkit/components/crashmonitor/CrashMonitor.jsm11
-rw-r--r--toolkit/components/downloads/nsDownloadManager.cpp7
-rw-r--r--toolkit/components/jsdownloads/src/DownloadIntegration.jsm8
-rw-r--r--toolkit/components/startup/nsAppStartup.cpp22
-rw-r--r--toolkit/components/startup/nsAppStartup.h1
-rw-r--r--toolkit/components/startup/public/nsIAppStartup.idl18
-rw-r--r--toolkit/content/widgets/browser.xml2
-rw-r--r--toolkit/library/moz.build12
-rw-r--r--toolkit/locales/en-US/chrome/places/places.properties5
-rw-r--r--toolkit/modules/Finder.jsm6
-rw-r--r--toolkit/mozapps/installer/windows/nsis/common.nsh125
-rw-r--r--toolkit/mozapps/update/common/updatehelper.cpp79
-rw-r--r--toolkit/mozapps/update/common/updatehelper.h5
-rw-r--r--toolkit/mozapps/update/nsIUpdateService.idl5
-rw-r--r--toolkit/mozapps/update/tests/chrome/utils.js13
-rw-r--r--toolkit/mozapps/update/tests/shared.js1
-rw-r--r--toolkit/mozapps/update/tests/unit_aus_update/head_update.js1
-rw-r--r--toolkit/mozapps/update/updater/updater.cpp27
-rw-r--r--toolkit/xre/nsAppRunner.cpp231
-rw-r--r--toolkit/xre/nsEmbedFunctions.cpp17
-rw-r--r--toolkit/xre/nsUpdateDriver.cpp43
-rw-r--r--toolkit/xre/nsWindowsWMain.cpp2
-rw-r--r--toolkit/xre/nsXREDirProvider.cpp6
-rw-r--r--tools/profiler/platform.cpp9
-rw-r--r--uriloader/exthandler/nsExternalHelperAppService.cpp12
-rw-r--r--widget/MetroUIUtils.idl36
-rw-r--r--widget/NativeKeyToDOMKeyName.h2
-rw-r--r--widget/moz.build6
-rw-r--r--widget/nsAppShellSingleton.h19
-rw-r--r--widget/nsIWinMetroUtils.idl152
-rw-r--r--widget/nsWidgetsCID.h4
-rw-r--r--widget/windows/KeyboardLayout.cpp6
-rw-r--r--widget/windows/WinMouseScrollHandler.cpp6
-rw-r--r--widget/windows/WinTaskbar.cpp9
-rw-r--r--widget/windows/WinUtils.cpp40
-rw-r--r--widget/windows/moz.build3
-rw-r--r--widget/windows/nsClipboard.cpp3
-rw-r--r--widget/windows/nsLookAndFeel.cpp5
-rw-r--r--widget/windows/nsTextStore.cpp102
-rw-r--r--widget/windows/nsTextStore.h2
-rw-r--r--widget/windows/nsWidgetFactory.cpp66
-rw-r--r--widget/windows/nsWindow.cpp17
-rw-r--r--widget/windows/winrt/APZController.cpp315
-rw-r--r--widget/windows/winrt/APZController.h79
-rw-r--r--widget/windows/winrt/DisplayInfo_sdk81.h458
-rw-r--r--widget/windows/winrt/FrameworkView.cpp507
-rw-r--r--widget/windows/winrt/FrameworkView.h205
-rw-r--r--widget/windows/winrt/Makefile.in19
-rw-r--r--widget/windows/winrt/MetroApp.cpp282
-rw-r--r--widget/windows/winrt/MetroApp.h62
-rw-r--r--widget/windows/winrt/MetroAppShell.cpp522
-rw-r--r--widget/windows/winrt/MetroAppShell.h44
-rw-r--r--widget/windows/winrt/MetroContracts.cpp576
-rw-r--r--widget/windows/winrt/MetroD3DCheckHelper.h96
-rw-r--r--widget/windows/winrt/MetroInput.cpp1576
-rw-r--r--widget/windows/winrt/MetroInput.h293
-rw-r--r--widget/windows/winrt/MetroUIUtils.js175
-rw-r--r--widget/windows/winrt/MetroUIUtils.manifest3
-rw-r--r--widget/windows/winrt/MetroUtils.cpp190
-rw-r--r--widget/windows/winrt/MetroUtils.h96
-rw-r--r--widget/windows/winrt/MetroWidget.cpp1626
-rw-r--r--widget/windows/winrt/MetroWidget.h277
-rw-r--r--widget/windows/winrt/ToastNotificationHandler.cpp153
-rw-r--r--widget/windows/winrt/ToastNotificationHandler.h44
-rw-r--r--widget/windows/winrt/UIAAccessibilityBridge.cpp54
-rw-r--r--widget/windows/winrt/UIAAccessibilityBridge.h80
-rw-r--r--widget/windows/winrt/UIABridge.cpp801
-rw-r--r--widget/windows/winrt/UIABridge.idl22
-rw-r--r--widget/windows/winrt/UIABridgePrivate.h139
-rw-r--r--widget/windows/winrt/UIABridgePublic.h19
-rw-r--r--widget/windows/winrt/WakeLockListener.cpp29
-rw-r--r--widget/windows/winrt/WakeLockListener.h25
-rw-r--r--widget/windows/winrt/moz.build52
-rw-r--r--widget/windows/winrt/mozwrlbase.h77
-rw-r--r--widget/windows/winrt/nsMetroFilePicker.cpp484
-rw-r--r--widget/windows/winrt/nsMetroFilePicker.h69
-rw-r--r--widget/windows/winrt/nsWinMetroUtils.cpp402
-rw-r--r--widget/windows/winrt/nsWinMetroUtils.h27
-rw-r--r--xpcom/base/ErrorList.h1
-rw-r--r--xpcom/base/nsDebugImpl.cpp3
-rw-r--r--xpcom/base/nsSystemInfo.cpp13
-rw-r--r--xpcom/base/nsWindowsHelpers.h30
-rw-r--r--xpcom/build/IOInterposer.cpp5
-rw-r--r--xpcom/build/nsXULAppAPI.h26
-rw-r--r--xpcom/io/nsAppDirectoryServiceDefs.h1
-rw-r--r--xpcom/io/nsLocalFileWin.cpp3
118 files changed, 136 insertions, 11279 deletions
diff --git a/CLOBBER b/CLOBBER
index 805fed938..303349674 100644
--- a/CLOBBER
+++ b/CLOBBER
@@ -18,4 +18,4 @@
# Modifying this file will now automatically clobber the buildbot machines \o/
#
-Clobber required for libvpx 1.4 update
+Clobber required for removing metro browser platform code.
diff --git a/accessible/windows/msaa/AccessibleWrap.cpp b/accessible/windows/msaa/AccessibleWrap.cpp
index f98cf838b..46f2d4d5f 100644
--- a/accessible/windows/msaa/AccessibleWrap.cpp
+++ b/accessible/windows/msaa/AccessibleWrap.cpp
@@ -1180,13 +1180,6 @@ AccessibleWrap::HandleAccEvent(AccEvent* aEvent)
nsresult rv = Accessible::HandleAccEvent(aEvent);
NS_ENSURE_SUCCESS(rv, rv);
- // Don't fire native MSAA events or mess with the system caret
- // when running in metro mode. This confuses input focus tracking
- // in metro's UIA implementation.
- if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) {
- return NS_OK;
- }
-
uint32_t eventType = aEvent->GetEventType();
static_assert(sizeof(gWinEventMap)/sizeof(gWinEventMap[0]) == nsIAccessibleEvent::EVENT_LAST_ENTRY,
diff --git a/browser/app/nsBrowserApp.cpp b/browser/app/nsBrowserApp.cpp
index f733d3b4b..f9645b0c6 100644
--- a/browser/app/nsBrowserApp.cpp
+++ b/browser/app/nsBrowserApp.cpp
@@ -231,39 +231,32 @@ static int do_main(int argc, char* argv[], nsIFile *xreDirectory)
return result;
}
- bool metroOnDesktop = false;
-
// Desktop browser launch
- if (mainFlags != XRE_MAIN_FLAG_USE_METRO && !metroOnDesktop) {
- ScopedAppData appData(&sAppData);
- nsCOMPtr<nsIFile> exeFile;
- rv = mozilla::BinaryPath::GetFile(argv[0], getter_AddRefs(exeFile));
- if (NS_FAILED(rv)) {
- Output("Couldn't find the application directory.\n");
- return 255;
- }
+ ScopedAppData appData(&sAppData);
+ nsCOMPtr<nsIFile> exeFile;
+ rv = mozilla::BinaryPath::GetFile(argv[0], getter_AddRefs(exeFile));
+ if (NS_FAILED(rv)) {
+ Output("Couldn't find the application directory.\n");
+ return 255;
+ }
- nsCOMPtr<nsIFile> greDir;
- exeFile->GetParent(getter_AddRefs(greDir));
+ nsCOMPtr<nsIFile> greDir;
+ exeFile->GetParent(getter_AddRefs(greDir));
#ifdef XP_MACOSX
- nsCOMPtr<nsIFile> parent;
- greDir->GetParent(getter_AddRefs(parent));
- greDir = parent.forget();
- greDir->AppendNative(NS_LITERAL_CSTRING(kOSXResourcesFolder));
+ nsCOMPtr<nsIFile> parent;
+ greDir->GetParent(getter_AddRefs(parent));
+ greDir = parent.forget();
+ greDir->AppendNative(NS_LITERAL_CSTRING(kOSXResourcesFolder));
#endif
- nsCOMPtr<nsIFile> appSubdir;
- greDir->Clone(getter_AddRefs(appSubdir));
- appSubdir->Append(NS_LITERAL_STRING(kDesktopFolder));
+ nsCOMPtr<nsIFile> appSubdir;
+ greDir->Clone(getter_AddRefs(appSubdir));
+ appSubdir->Append(NS_LITERAL_STRING(kDesktopFolder));
- SetStrongPtr(appData.directory, static_cast<nsIFile*>(appSubdir.get()));
- // xreDirectory already has a refcount from NS_NewLocalFile
- appData.xreDirectory = xreDirectory;
-
- return XRE_main(argc, argv, &appData, mainFlags);
- }
+ SetStrongPtr(appData.directory, static_cast<nsIFile*>(appSubdir.get()));
+ // xreDirectory already has a refcount from NS_NewLocalFile
+ appData.xreDirectory = xreDirectory;
- NS_NOTREACHED("browser do_main failed to pickup proper initialization");
- return 255;
+ return XRE_main(argc, argv, &appData, mainFlags);
}
/**
diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js
index b4b33f568..fe1f67d99 100644
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -123,7 +123,6 @@ pref("app.update.cert.maxErrors", 5);
// |app.update.url.override| user preference has been set for testing updates or
// when the |app.update.cert.checkAttributes| preference is set to false. Also,
// the |app.update.url.override| preference should ONLY be used for testing.
-// IMPORTANT! metro.js should also be updated for updates to certs.X.issuerName
pref("app.update.certs.1.issuerName", "CN=Thawte SSL CA,O=\"Thawte, Inc.\",C=US");
pref("app.update.certs.1.commonName", "aus3.mozilla.org");
@@ -139,7 +138,6 @@ pref("app.update.enabled", true);
pref("app.update.auto", true);
// See chart in nsUpdateService.js source for more details
-// incompatibilities are ignored by updates in Metro
pref("app.update.mode", 1);
// If set to true, the Update Service will present no UI for any event.
diff --git a/build/automation.py.in b/build/automation.py.in
index 1618c3b6e..d3800ab59 100644
--- a/build/automation.py.in
+++ b/build/automation.py.in
@@ -667,9 +667,10 @@ class Automation(object):
stackFixerFunction = lambda line: stackFixerModule.fixSymbols(line)
del sys.path[0]
- # With metro browser runs this script launches the metro test harness which launches the browser.
- # The metro test harness hands back the real browser process id via log output which we need to
+ # With indirect browser runs, this script launches the test harness which launches the browser.
+ # The test harness hands back the real browser process id via log output which we need to
# pick up on and parse out. This variable tracks the real browser process id if we find it.
+ # XXX: Previously used by metro. Do we still need this?
browserProcessId = -1
(line, didTimeout) = self.readWithTimeout(logsource, timeout)
@@ -684,12 +685,6 @@ class Automation(object):
(line, didTimeout) = self.readWithTimeout(logsource, timeout)
- if "METRO_BROWSER_PROCESS" in line:
- index = line.find("=")
- if index:
- browserProcessId = line[index+1:].rstrip()
- self.log.info("INFO | automation.py | metro browser sub process id detected: %s", browserProcessId)
-
if not hitMaxTime and maxTime and datetime.now() - startTime > timedelta(seconds = maxTime):
# Kill the application.
hitMaxTime = True
diff --git a/build/valgrind/cross-architecture.sup b/build/valgrind/cross-architecture.sup
index 1e9d7ab35..9215d3b2d 100644
--- a/build/valgrind/cross-architecture.sup
+++ b/build/valgrind/cross-architecture.sup
@@ -34,15 +34,6 @@
fun:_ZN13CrashReporter14SetupExtraDataEP7nsIFileRK19nsACString_internal
...
}
-{
- We purposely leak the StatisticsReporter object
- Memcheck:Leak
- fun:malloc
- fun:moz_xmalloc
- fun:operator new
- fun:_Z21XRE_CreateStatsObjectv
- ...
-}
####################################
# Leaks in third party libraries #
diff --git a/build/win32/mozconfig.vs2010-win64 b/build/win32/mozconfig.vs2010-win64
index 8a7fc211a..2437c57c4 100644
--- a/build/win32/mozconfig.vs2010-win64
+++ b/build/win32/mozconfig.vs2010-win64
@@ -12,8 +12,8 @@ export WIN32_REDIST_DIR=${_VSPATH}/VC/redist/x86/Microsoft.VC100.CRT
## moz tools location for 64-bit builders ##
export MOZ_TOOLS=C:/mozilla-build/moztools
-## includes: win8 sdk includes, winrt headers for metro, msvc 10 std library, directx sdk for d3d9 ##
-export INCLUDE=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/shared:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/um:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/winrt:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/winrt/wrl:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/winrt/wrl/wrappers:${_VSPATH}/vc/include:${_VSPATH}/vc/atlmfc/include:/c/tools/sdks/dx10/include
+## includes: win8 sdk includes, msvc 10 std library, directx sdk for d3d9 ##
+export INCLUDE=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/shared:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/um:${_VSPATH}/vc/include:${_VSPATH}/vc/atlmfc/include:/c/tools/sdks/dx10/include
## libs: win8 sdk x86 (32-bit) libs, msvc 10 (32-bit) std library, msvc 10 atl libs, directx sdk (32-bit) for d3d9 ##
export LIBPATH=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/Lib/win8/um/x86:${_VSPATH}/vc/lib:${_VSPATH}/vc/atlmfc/lib:/c/tools/sdks/dx10/lib
diff --git a/build/win32/mozconfig.vs2013-win64 b/build/win32/mozconfig.vs2013-win64
index 0adf6cc05..d379e3826 100644
--- a/build/win32/mozconfig.vs2013-win64
+++ b/build/win32/mozconfig.vs2013-win64
@@ -4,8 +4,8 @@ export WIN32_REDIST_DIR=${_VSPATH}/VC/redist/x86/Microsoft.VC120.CRT
## moz tools location for 64-bit builders ##
export MOZ_TOOLS=C:/mozilla-build/moztools
-## includes: win8.1 sdk includes, winrt headers for metro, msvc std library, directx sdk for d3d9 ##
-export INCLUDE=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/shared:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/um:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/winrt:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/winrt/wrl:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/winrt/wrl/wrappers:${_VSPATH}/vc/include:${_VSPATH}/vc/atlmfc/include:/c/tools/sdks/dx10/include
+## includes: win8.1 sdk includes, msvc std library, directx sdk for d3d9 ##
+export INCLUDE=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/shared:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/um:${_VSPATH}/vc/include:${_VSPATH}/vc/atlmfc/include:/c/tools/sdks/dx10/include
## libs: win8.1 sdk x86 (32-bit) libs, msvc (32-bit) std library, msvc atl libs, directx sdk (32-bit) for d3d9 ##
export LIBPATH=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/Lib/winv6.3/um/x86:${_VSPATH}/vc/lib:${_VSPATH}/vc/atlmfc/lib:/c/tools/sdks/dx10/lib
diff --git a/build/win64/mozconfig.vs2010 b/build/win64/mozconfig.vs2010
index 6862fdb63..19fec4330 100644
--- a/build/win64/mozconfig.vs2010
+++ b/build/win64/mozconfig.vs2010
@@ -9,8 +9,8 @@ fi
## SDK redist ##
export WIN32_REDIST_DIR=${_VSPATH}/VC/redist/x64/Microsoft.VC100.CRT
-## includes: win8 sdk includes, winrt headers for metro, msvc 10 std library, directx sdk for d3d9 ##
-export INCLUDE=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/shared:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/um:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/winrt:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/winrt/wrl:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/winrt/wrl/wrappers:${_VSPATH}/vc/include:${_VSPATH}/vc/atlmfc/include:/c/tools/sdks/dx10/include
+## includes: win8 sdk includes, msvc 10 std library, directx sdk for d3d9 ##
+export INCLUDE=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/shared:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/include/um:${_VSPATH}/vc/include:${_VSPATH}/vc/atlmfc/include:/c/tools/sdks/dx10/include
## libs: win8 sdk x64 (64-bit) libs, msvc 10 (64-bit) std library, msvc 10 atl libs, directx sdk (64-bit) for d3d9 ##
export LIBPATH=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.0/Lib/win8/um/x64:${_VSPATH}/vc/lib/amd64:${_VSPATH}/vc/atlmfc/lib/amd64:/c/tools/sdks/dx10/lib/x64
diff --git a/build/win64/mozconfig.vs2013 b/build/win64/mozconfig.vs2013
index 52fa311b0..776c9183e 100644
--- a/build/win64/mozconfig.vs2013
+++ b/build/win64/mozconfig.vs2013
@@ -1,8 +1,8 @@
_VSPATH="/c/tools/vs2013"
export WIN32_REDIST_DIR=${_VSPATH}/VC/redist/x64/Microsoft.VC120.CRT
-## includes: win8.1 sdk includes, winrt headers for metro, msvc std library, directx sdk for d3d9 ##
-export INCLUDE=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/shared:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/um:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/winrt:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/winrt/wrl:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/winrt/wrl/wrappers:${_VSPATH}/vc/include:${_VSPATH}/vc/atlmfc/include:/c/tools/sdks/dx10/include
+## includes: win8.1 sdk includes, msvc std library, directx sdk for d3d9 ##
+export INCLUDE=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/shared:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/um:${_VSPATH}/vc/include:${_VSPATH}/vc/atlmfc/include:/c/tools/sdks/dx10/include
## libs: win8.1 sdk x64 (64-bit) libs, msvc (64-bit) std library, msvc atl libs, directx sdk (64-bit) for d3d9 ##
export LIBPATH=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/Lib/winv6.3/um/x64:${_VSPATH}/vc/lib/amd64:${_VSPATH}/vc/atlmfc/lib/amd64:/c/tools/sdks/dx10/lib/x64
diff --git a/config/recurse.mk b/config/recurse.mk
index 52b13c34e..6b6821d67 100644
--- a/config/recurse.mk
+++ b/config/recurse.mk
@@ -53,7 +53,7 @@ CURRENT_TIER := $(subst recurse_,,$(CURRENT_TIER:-deps=))
# The rules here are doing directory traversal, so we don't want further
# recursion to happen when running make -C subdir $tier. But some make files
# further call make -C something else, and sometimes expect recursion to
-# happen in that case (see browser/metro/locales/Makefile.in for example).
+# happen in that case.
# Conveniently, every invocation of make increases MAKELEVEL, so only stop
# recursion from happening at current MAKELEVEL + 1.
ifdef CURRENT_TIER
diff --git a/configure.in b/configure.in
index ab781bf7a..1e533643a 100644
--- a/configure.in
+++ b/configure.in
@@ -422,20 +422,6 @@ dnl ========================================================
dnl Special win32 checks
dnl ========================================================
-MOZ_ARG_ENABLE_BOOL(metro,
-[ --enable-metro Enable Windows Metro build targets],
- MOZ_METRO=1,
- MOZ_METRO=)
-if test -n "$MOZ_METRO"; then
- AC_DEFINE(MOZ_METRO)
- # toolkit/library/makefile.in needs these, see nsDllMain.
- CRTDLLVERSION=110
- CRTEXPDLLVERSION=1-1-0
-fi
-
-AC_SUBST(CRTDLLVERSION)
-AC_SUBST(CRTEXPDLLVERSION)
-
# Target the Windows 8.1 SDK by default
WINSDK_TARGETVER=603
WINVER=600
@@ -558,16 +544,6 @@ See https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && pwd`
fi
- dnl Confirm we have the pri tools on win8 builds
- if test -n "$MOZ_METRO"; then
- AC_MSG_CHECKING([for makepri])
- AC_CHECK_PROGS(MAKEPRI, makepri, "")
- if test -z "MAKEPRI" ; then
- AC_MSG_ERROR([makepri.exe is required for generating metro browser install components. It should be in the Win8 SDK.])
- fi
- AC_SUBST(MAKEPRI)
- fi
-
dnl Ensure that mt.exe is 'Microsoft (R) Manifest Tool',
dnl not something else like "magnetic tape manipulation utility".
MSMT_TOOL=`${MT-mt} 2>&1|grep 'Microsoft (R) Manifest Tool'`
@@ -8259,8 +8235,6 @@ AC_SUBST(MOZ_HAS_WINSDK_WITH_D3D)
AC_SUBST(MOZ_D3DCOMPILER_VISTA_DLL)
AC_SUBST(MOZ_D3DCOMPILER_VISTA_DLL_PATH)
-AC_SUBST(MOZ_METRO)
-
AC_SUBST(MOZ_ANDROID_HISTORY)
AC_SUBST(MOZ_WEBSMS_BACKEND)
AC_SUBST(MOZ_ANDROID_BEAM)
diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h
index 2acad3e9e..e45d20f6d 100644
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -1871,7 +1871,7 @@ public:
*
* Making the fullscreen API content only is useful on platforms where we
* still want chrome to be visible or accessible while content is
- * fullscreen, like on Windows 8 in Metro mode.
+ * fullscreen.
*
* Note that if the fullscreen API is content only, chrome can still go
* fullscreen by setting the "fullScreen" attribute on its XUL window.
diff --git a/dom/svg/SVGDocument.cpp b/dom/svg/SVGDocument.cpp
index c537bcf7d..715c71916 100644
--- a/dom/svg/SVGDocument.cpp
+++ b/dom/svg/SVGDocument.cpp
@@ -104,7 +104,7 @@ SVGDocument::EnsureNonSVGUserAgentStyleSheetsLoaded()
if (IsBeingUsedAsImage()) {
// nsDocumentViewer::CreateStyleSet skipped loading all user-agent/user
- // style sheets in this case, but we'll need B2G/Fennec/Metro's
+ // style sheets in this case, but we'll need B2G/Fennec's
// content.css. We could load all the sheets registered with the
// nsIStyleSheetService (and maybe we should) but most likely it isn't
// desirable or necessary for foreignObject in SVG-as-an-image. Instead we
@@ -113,7 +113,7 @@ SVGDocument::EnsureNonSVGUserAgentStyleSheetsLoaded()
// SVG-as-an-image down.
//
// We do this before adding UASheet() etc. below because
- // EnsureOnDemandBuiltInUASheet prepends, and B2G/Fennec/Metro's
+ // EnsureOnDemandBuiltInUASheet prepends, and B2G/Fennec's
// content.css must come after UASheet() etc.
nsCOMPtr<nsICategoryManager> catMan =
do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
diff --git a/gfx/doc/AsyncPanZoom.md b/gfx/doc/AsyncPanZoom.md
index bddfb1411..edeb8e2a0 100644
--- a/gfx/doc/AsyncPanZoom.md
+++ b/gfx/doc/AsyncPanZoom.md
@@ -263,7 +263,7 @@ If the CSS touch-action property is enabled, the above steps are modified as fol
The bulk of the input processing in the APZ code happens on what we call "the input thread".
In practice the input thread could be the Goanna main thread, the compositor thread, or some other thread.
There are obvious downsides to using the Goanna main thread - that is, "asynchronous" panning and zooming is not really asynchronous as input events can only be processed while Goanna is idle.
-However, this is the current state of things on B2G and Metro.
+However, this is the current state of things on B2G.
Using the compositor thread as the input thread could work on some platforms, but may be inefficient on others.
For example, on Android (Fennec) we receive input events from the system on a dedicated UI thread.
We would have to redispatch the input events to the compositor thread if we wanted to the input thread to be the same as the compositor thread.
diff --git a/gfx/layers/d3d11/CompositorD3D11.cpp b/gfx/layers/d3d11/CompositorD3D11.cpp
index 28577a5e7..2533b4807 100644
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -345,47 +345,6 @@ CompositorD3D11::Initialize()
mDevice->QueryInterface(dxgiDevice.StartAssignment());
dxgiDevice->GetAdapter(getter_AddRefs(dxgiAdapter));
-#ifdef MOZ_METRO
- if (IsRunningInWindowsMetro()) {
- nsRefPtr<IDXGIFactory2> dxgiFactory;
- dxgiAdapter->GetParent(IID_PPV_ARGS(dxgiFactory.StartAssignment()));
-
- nsIntRect rect;
- mWidget->GetClientBounds(rect);
-
- DXGI_SWAP_CHAIN_DESC1 swapDesc = { 0 };
- // Automatically detect the width and the height from the winrt CoreWindow
- swapDesc.Width = rect.width;
- swapDesc.Height = rect.height;
- // This is the most common swapchain format
- swapDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
- swapDesc.Stereo = false;
- // Don't use multi-sampling
- swapDesc.SampleDesc.Count = 1;
- swapDesc.SampleDesc.Quality = 0;
- swapDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
- // Use double buffering to enable flip
- swapDesc.BufferCount = 2;
- swapDesc.Scaling = DXGI_SCALING_NONE;
- // All Metro style apps must use this SwapEffect
- swapDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
- swapDesc.Flags = 0;
-
- /**
- * Create a swap chain, this swap chain will contain the backbuffer for
- * the window we draw to. The front buffer is the full screen front
- * buffer.
- */
- nsRefPtr<IDXGISwapChain1> swapChain1;
- hr = dxgiFactory->CreateSwapChainForCoreWindow(
- dxgiDevice, (IUnknown *)mWidget->GetNativeData(NS_NATIVE_ICOREWINDOW),
- &swapDesc, nullptr, getter_AddRefs(swapChain1));
- if (FAILED(hr)) {
- return false;
- }
- mSwapChain = swapChain1;
- } else
-#endif
{
nsRefPtr<IDXGIFactory> dxgiFactory;
dxgiAdapter->GetParent(IID_PPV_ARGS(dxgiFactory.StartAssignment()));
@@ -1233,16 +1192,9 @@ CompositorD3D11::VerifyBufferSize()
mDefaultRT = nullptr;
}
- if (IsRunningInWindowsMetro()) {
- hr = mSwapChain->ResizeBuffers(2, mSize.width, mSize.height,
- DXGI_FORMAT_B8G8R8A8_UNORM,
- 0);
- mDisableSequenceForNextFrame = true;
- } else {
- hr = mSwapChain->ResizeBuffers(1, mSize.width, mSize.height,
- DXGI_FORMAT_B8G8R8A8_UNORM,
- 0);
- }
+ hr = mSwapChain->ResizeBuffers(1, mSize.width, mSize.height,
+ DXGI_FORMAT_B8G8R8A8_UNORM,
+ 0);
return Succeeded(hr);
}
diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp
index 8b23a6975..642fa475a 100644
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -111,8 +111,7 @@ DCFromDrawTarget::DCFromDrawTarget(DrawTarget& aDrawTarget)
static const char *kFeatureLevelPref =
"gfx.direct3d.last_used_feature_level_idx";
static const int kSupportedFeatureLevels[] =
- { D3D10_FEATURE_LEVEL_10_1, D3D10_FEATURE_LEVEL_10_0,
- D3D10_FEATURE_LEVEL_9_3 };
+ { D3D10_FEATURE_LEVEL_10_1, D3D10_FEATURE_LEVEL_10_0 };
class GfxD2DSurfaceReporter final : public nsIMemoryReporter
{
@@ -664,10 +663,6 @@ gfxWindowsPlatform::VerifyD2DDevice(bool aAttemptForce)
nsRefPtr<ID3D10Device1> device;
int supportedFeatureLevelsCount = ArrayLength(kSupportedFeatureLevels);
- // If we're not running in Metro don't allow DX9.3
- if (!IsRunningInWindowsMetro()) {
- supportedFeatureLevelsCount--;
- }
nsRefPtr<IDXGIAdapter1> adapter1 = GetDXGIAdapter();
diff --git a/ipc/glue/WindowsMessageLoop.cpp b/ipc/glue/WindowsMessageLoop.cpp
index 69b6c384f..ab7f4b0a5 100644
--- a/ipc/glue/WindowsMessageLoop.cpp
+++ b/ipc/glue/WindowsMessageLoop.cpp
@@ -79,9 +79,6 @@ extern const wchar_t* kPropNameTabContent;
namespace mozilla {
namespace widget {
extern UINT sAppShellGoannaMsgId;
-#ifdef MOZ_METRO
-extern UINT sDefaultBrowserMsgId;
-#endif
}
}
@@ -416,11 +413,6 @@ ProcessOrDeferMessage(HWND hwnd,
if (uMsg && uMsg == mozilla::widget::sAppShellGoannaMsgId) {
// Widget's registered native event callback
deferred = new DeferredSendMessage(hwnd, uMsg, wParam, lParam);
-#ifdef MOZ_METRO
- } else if (uMsg && uMsg == mozilla::widget::sDefaultBrowserMsgId) {
- // Metro widget's system shutdown message
- deferred = new DeferredSendMessage(hwnd, uMsg, wParam, lParam);
-#endif
}
}
}
@@ -498,13 +490,6 @@ WindowIsDeferredWindow(HWND hWnd)
return true;
}
-#ifdef MOZ_METRO
- // immersive UI ICoreWindow
- if (className.EqualsLiteral("Windows.UI.Core.CoreWindow")) {
- return true;
- }
-#endif
-
// Plugin windows that can trigger ipc calls in child:
// 'ShockwaveFlashFullScreen' - flash fullscreen window
// 'QTNSHIDDEN' - QuickTime
diff --git a/js/src/configure.in b/js/src/configure.in
index bdb3db5e8..605617891 100644
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -340,14 +340,6 @@ MOZ_CHECK_COMPILER_WRAPPER
dnl Special win32 checks
dnl ========================================================
-MOZ_ARG_ENABLE_BOOL(metro,
-[ --enable-metro Enable Windows Metro build targets],
- MOZ_METRO=1,
- MOZ_METRO=)
-if test -n "$MOZ_METRO"; then
- AC_DEFINE(MOZ_METRO)
-fi
-
# Target the Windows 8.1 SDK by default
WINSDK_TARGETVER=603
WINVER=600
@@ -3733,7 +3725,6 @@ AC_SUBST(OS_COMPILE_CXXFLAGS)
AC_SUBST(OS_LDFLAGS)
AC_SUBST(OS_LIBS)
AC_SUBST(CROSS_COMPILE)
-AC_SUBST(MOZ_METRO)
AC_SUBST(HOST_CC)
AC_SUBST(HOST_CXX)
diff --git a/layout/reftests/forms/input/color/reftest.list b/layout/reftests/forms/input/color/reftest.list
index dd30d1dcf..074abf570 100644
--- a/layout/reftests/forms/input/color/reftest.list
+++ b/layout/reftests/forms/input/color/reftest.list
@@ -1,6 +1,5 @@
# Simple test. Should fail on platforms where input type color isn't activated
-# yet. Missing platforms are B2G (bug 875751), Android (bug 875750) and Metro
-# (bug 895464).
+# yet. Missing platforms are B2G (bug 875751) and Android (bug 875750).
fails-if(B2G||Android) == input-color-1.html input-color-1-ref.html
default-preferences pref(dom.forms.color,true)
diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp
index 891c67685..015508357 100644
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -804,17 +804,9 @@ Preferences::NotifyServiceObservers(const char *aTopic)
nsresult
Preferences::UseDefaultPrefFile()
{
- nsresult rv;
nsCOMPtr<nsIFile> aFile;
-#if defined(XP_WIN) && defined(MOZ_METRO)
- if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) {
- rv = NS_GetSpecialDirectory(NS_METRO_APP_PREFS_50_FILE, getter_AddRefs(aFile));
- } else
-#endif
- {
- rv = NS_GetSpecialDirectory(NS_APP_PREFS_50_FILE, getter_AddRefs(aFile));
- }
+ nsresult rv = NS_GetSpecialDirectory(NS_APP_PREFS_50_FILE, getter_AddRefs(aFile));
if (NS_SUCCEEDED(rv)) {
rv = ReadAndOwnUserPrefFile(aFile);
diff --git a/profile/dirserviceprovider/nsProfileDirServiceProvider.cpp b/profile/dirserviceprovider/nsProfileDirServiceProvider.cpp
index 0091c31be..fe35213b1 100644
--- a/profile/dirserviceprovider/nsProfileDirServiceProvider.cpp
+++ b/profile/dirserviceprovider/nsProfileDirServiceProvider.cpp
@@ -16,7 +16,6 @@
// File Name Defines
#define PREFS_FILE_50_NAME NS_LITERAL_CSTRING("prefs.js")
-#define PREFS_FILE_METRO_50_NAME NS_LITERAL_CSTRING("metro-prefs.js")
#define USER_CHROME_DIR_50_NAME NS_LITERAL_CSTRING("chrome")
#define LOCAL_STORE_FILE_50_NAME NS_LITERAL_CSTRING("localstore.rdf")
#define PANELS_FILE_50_NAME NS_LITERAL_CSTRING("panels.rdf")
@@ -170,11 +169,6 @@ nsProfileDirServiceProvider::GetFile(const char *prop, bool *persistant, nsIFile
if (NS_SUCCEEDED(rv))
rv = localFile->AppendNative(PREFS_FILE_50_NAME);
}
- else if (strcmp(prop, NS_METRO_APP_PREFS_50_FILE) == 0) {
- rv = domainDir->Clone(getter_AddRefs(localFile));
- if (NS_SUCCEEDED(rv))
- rv = localFile->AppendNative(PREFS_FILE_METRO_50_NAME);
- }
else if (strcmp(prop, NS_APP_USER_PROFILE_50_DIR) == 0) {
rv = domainDir->Clone(getter_AddRefs(localFile));
}
diff --git a/services/datareporting/DataReporting.manifest b/services/datareporting/DataReporting.manifest
index 3a35880c1..112443cc1 100644
--- a/services/datareporting/DataReporting.manifest
+++ b/services/datareporting/DataReporting.manifest
@@ -3,7 +3,6 @@
# mobile/android: {aa3c5121-dab2-40e2-81ca-7ea25febc110}
# mobile/xul: {a23983c0-fd0e-11dc-95ff-0800200c9a66}
# suite (comm): {92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}
-# metro browser: {99bceaaa-e3c6-48c1-b981-ef9b46b67d60}
# The Data Reporting Service drives collection and submission of metrics
# and other useful data to Mozilla. It drives the display of the data
diff --git a/services/sync/SyncComponents.manifest b/services/sync/SyncComponents.manifest
index b1d99f5e8..f6b631f5d 100644
--- a/services/sync/SyncComponents.manifest
+++ b/services/sync/SyncComponents.manifest
@@ -8,7 +8,6 @@
# mobile/android: {aa3c5121-dab2-40e2-81ca-7ea25febc110}
# mobile/xul: {a23983c0-fd0e-11dc-95ff-0800200c9a66}
# suite (comm): {92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}
-# metro browser: {99bceaaa-e3c6-48c1-b981-ef9b46b67d60}
#
# In theory we should do this for all these instructions, but in practice it is
# sufficient to do it for the app-startup one, and the file is simpler that way.
@@ -16,7 +15,7 @@
# Weave.js
component {74b89fb0-f200-4ae8-a3ec-dd164117f6de} Weave.js
contract @mozilla.org/weave/service;1 {74b89fb0-f200-4ae8-a3ec-dd164117f6de}
-category app-startup WeaveService service,@mozilla.org/weave/service;1 application={3c2e2abc-06d4-11e1-ac3b-374f68613e61} application={8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4} application={aa3c5121-dab2-40e2-81ca-7ea25febc110} application={a23983c0-fd0e-11dc-95ff-0800200c9a66} application={92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a} application={99bceaaa-e3c6-48c1-b981-ef9b46b67d60}
+category app-startup WeaveService service,@mozilla.org/weave/service;1 application={3c2e2abc-06d4-11e1-ac3b-374f68613e61} application={8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4} application={aa3c5121-dab2-40e2-81ca-7ea25febc110} application={a23983c0-fd0e-11dc-95ff-0800200c9a66} application={92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}
component {d28f8a0b-95da-48f4-b712-caf37097be41} Weave.js
contract @mozilla.org/network/protocol/about;1?what=sync-log {d28f8a0b-95da-48f4-b712-caf37097be41}
diff --git a/services/sync/tps/extensions/mozmill/resource/driver/controller.js b/services/sync/tps/extensions/mozmill/resource/driver/controller.js
index c3539bcb3..d5948598e 100644
--- a/services/sync/tps/extensions/mozmill/resource/driver/controller.js
+++ b/services/sync/tps/extensions/mozmill/resource/driver/controller.js
@@ -286,7 +286,6 @@ MozMillController.prototype.waitFor = assert.waitFor;
MozMillController.prototype.open = function (url) {
switch (this.mozmillModule.Application) {
case "Firefox":
- case "MetroFirefox":
// Stop a running page load to not overlap requests
if (this.browserObject.selectedBrowser) {
this.browserObject.selectedBrowser.stop();
@@ -937,27 +936,12 @@ Tabs.prototype.__defineGetter__("length", function () {
Tabs.prototype.__defineGetter__("activeTabIndex", function () {
var browser = this.controller.browserObject;
-
- switch(this.controller.mozmillModule.Application) {
- case "MetroFirefox":
- return browser.tabs.indexOf(browser.selectedTab);
- case "Firefox":
- default:
- return browser.tabContainer.selectedIndex;
- }
+ return browser.tabContainer.selectedIndex;
});
Tabs.prototype.selectTabIndex = function (aIndex) {
var browser = this.controller.browserObject;
-
- switch(this.controller.mozmillModule.Application) {
- case "MetroFirefox":
- browser.selectedTab = browser.tabs[aIndex];
- break;
- case "Firefox":
- default:
- browser.selectTabAtIndex(aIndex);
- }
+ browser.selectTabAtIndex(aIndex);
}
function browserAdditions (controller) {
diff --git a/services/sync/tps/extensions/mozmill/resource/stdlib/utils.js b/services/sync/tps/extensions/mozmill/resource/stdlib/utils.js
index 4bb3124ee..3dcca76e0 100644
--- a/services/sync/tps/extensions/mozmill/resource/stdlib/utils.js
+++ b/services/sync/tps/extensions/mozmill/resource/stdlib/utils.js
@@ -19,8 +19,7 @@ Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource://gre/modules/Services.jsm");
const applicationIdMap = {
- '{8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4}': 'Firefox',
- '{99bceaaa-e3c6-48c1-b981-ef9b46b67d60}': 'MetroFirefox'
+ '{8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4}': 'Firefox'
}
const applicationName = applicationIdMap[Services.appinfo.ID] || Services.appinfo.name;
@@ -49,13 +48,7 @@ function Copy (obj) {
* @returns {Object} The browser element
*/
function getBrowserObject(aWindow) {
- switch(applicationName) {
- case "MetroFirefox":
- return aWindow.Browser;
- case "Firefox":
- default:
- return aWindow.gBrowser;
- }
+ return aWindow.gBrowser;
}
function getChromeWindow(aWindow) {
diff --git a/startupcache/StartupCache.cpp b/startupcache/StartupCache.cpp
index a86e2c3b2..700b38080 100644
--- a/startupcache/StartupCache.cpp
+++ b/startupcache/StartupCache.cpp
@@ -82,9 +82,6 @@ StartupCache::CollectReports(nsIHandleReportCallback* aHandleReport,
}
static const char sStartupCacheName[] = "startupCache." SC_WORDSIZE "." SC_ENDIAN;
-#if defined(XP_WIN) && defined(MOZ_METRO)
-static const char sMetroStartupCacheName[] = "metroStartupCache." SC_WORDSIZE "." SC_ENDIAN;
-#endif
StartupCache*
StartupCache::GetSingleton()
@@ -199,14 +196,7 @@ StartupCache::Init()
if (NS_FAILED(rv) && rv != NS_ERROR_FILE_ALREADY_EXISTS)
return rv;
-#if defined(XP_WIN) && defined(MOZ_METRO)
- if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) {
- rv = file->AppendNative(NS_LITERAL_CSTRING(sMetroStartupCacheName));
- } else
-#endif
- {
- rv = file->AppendNative(NS_LITERAL_CSTRING(sStartupCacheName));
- }
+ rv = file->AppendNative(NS_LITERAL_CSTRING(sStartupCacheName));
NS_ENSURE_SUCCESS(rv, rv);
diff --git a/testing/mochitest/Makefile.in b/testing/mochitest/Makefile.in
index 1682efa90..18291f2a1 100644
--- a/testing/mochitest/Makefile.in
+++ b/testing/mochitest/Makefile.in
@@ -57,9 +57,6 @@ endif
ifeq (windows,$(MOZ_WIDGET_TOOLKIT))
TEST_HARNESS_BINS += screenshot$(BIN_SUFFIX)
-ifdef MOZ_METRO
-TEST_HARNESS_BINS += metrotestharness$(BIN_SUFFIX)
-endif
endif
ifdef MOZ_DMD
diff --git a/testing/mochitest/browser-harness.xul b/testing/mochitest/browser-harness.xul
index c4428fbf1..c8b815886 100644
--- a/testing/mochitest/browser-harness.xul
+++ b/testing/mochitest/browser-harness.xul
@@ -245,7 +245,6 @@
var windowMediator = Cc['@mozilla.org/appshell/window-mediator;1'].
getService(Ci.nsIWindowMediator);
var winType = gConfig.testRoot == "browser" ? "navigator:browser" :
- gConfig.testRoot == "metro" ? "navigator:browser" :
gConfig.testRoot == "webapprtChrome" ? "webapprt:webapp" :
null;
if (!winType) {
diff --git a/testing/mochitest/browser-test.js b/testing/mochitest/browser-test.js
index c602385af..4a976fe98 100644
--- a/testing/mochitest/browser-test.js
+++ b/testing/mochitest/browser-test.js
@@ -51,7 +51,6 @@ function b2gStart() {
function testInit() {
gConfig = readConfig();
if (gConfig.testRoot == "browser" ||
- gConfig.testRoot == "metro" ||
gConfig.testRoot == "webapprtChrome") {
// Make sure to launch the test harness for the first opened window only
var prefs = Services.prefs;
diff --git a/testing/mozbase/mozrunner/mozrunner/runners.py b/testing/mozbase/mozrunner/mozrunner/runners.py
index 488b1aea5..94c66877d 100644
--- a/testing/mozbase/mozrunner/mozrunner/runners.py
+++ b/testing/mozbase/mozrunner/mozrunner/runners.py
@@ -65,24 +65,6 @@ def ThunderbirdRunner(*args, **kwargs):
return GoannaRuntimeRunner(*args, **kwargs)
-def MetroRunner(*args, **kwargs):
- """
- Create a Windows metro Firefox runner.
-
- :param binary: Path to metro Firefox binary.
- :param cmdargs: Arguments to pass into binary.
- :param profile: Profile object to use.
- :param env: Environment variables to pass into the goanna process.
- :param clean_profile: If True, restores profile back to original state.
- :param process_class: Class used to launch the binary.
- :param process_args: Arguments to pass into process_class.
- :param symbols_path: Path to symbol files used for crash analysis.
- :returns: A GoannaRuntimeRunner for metro Firefox.
- """
- kwargs['app_ctx'] = get_app_context('metro')()
- return GoannaRuntimeRunner(*args, **kwargs)
-
-
def B2GDesktopRunner(*args, **kwargs):
"""
Create a B2G desktop runner.
@@ -177,7 +159,6 @@ runners = {
'b2g_emulator': B2GEmulatorRunner,
'b2g_device': B2GDeviceRunner,
'firefox': FirefoxRunner,
- 'metro': MetroRunner,
'thunderbird': ThunderbirdRunner,
}
diff --git a/testing/profiles/prefs_general.js b/testing/profiles/prefs_general.js
index 1c38eaef8..ba2a47e29 100644
--- a/testing/profiles/prefs_general.js
+++ b/testing/profiles/prefs_general.js
@@ -196,10 +196,6 @@ user_pref("browser.download.panel.shown", true);
// which test runs first and happens to open about:newtab
user_pref("browser.newtabpage.introShown", true);
-// prefs for firefox metro.
-// Disable first-tun tab
-user_pref("browser.firstrun.count", 0);
-
// Tell the PBackground infrastructure to run a test at startup.
user_pref("pbackground.testing", true);
diff --git a/toolkit/components/crashmonitor/CrashMonitor.jsm b/toolkit/components/crashmonitor/CrashMonitor.jsm
index 17e0ddfb7..b23508c61 100644
--- a/toolkit/components/crashmonitor/CrashMonitor.jsm
+++ b/toolkit/components/crashmonitor/CrashMonitor.jsm
@@ -84,13 +84,9 @@ let CrashMonitorInternal = {
* Path to checkpoint file.
*
* Each time a new notification is received, this file is written to
- * disc to reflect the information in |checkpoints|. Although Firefox for
- * Desktop and Metro share the same profile, they need to keep record of
- * crashes separately.
+ * disc to reflect the information in |checkpoints|.
*/
- path: (Services.metro && Services.metro.immersive) ?
- OS.Path.join(OS.Constants.Path.profileDir, "metro", "sessionCheckpoints.json"):
- OS.Path.join(OS.Constants.Path.profileDir, "sessionCheckpoints.json"),
+ path: OS.Path.join(OS.Constants.Path.profileDir, "sessionCheckpoints.json"),
/**
* Load checkpoints from previous session asynchronously.
@@ -178,9 +174,6 @@ this.CrashMonitor = {
);
CrashMonitorInternal.initialized = true;
- if (Services.metro && Services.metro.immersive) {
- OS.File.makeDir(OS.Path.join(OS.Constants.Path.profileDir, "metro"));
- }
return promise;
},
diff --git a/toolkit/components/downloads/nsDownloadManager.cpp b/toolkit/components/downloads/nsDownloadManager.cpp
index df256a0cb..8c63f1392 100644
--- a/toolkit/components/downloads/nsDownloadManager.cpp
+++ b/toolkit/components/downloads/nsDownloadManager.cpp
@@ -947,13 +947,8 @@ nsDownloadManager::Init()
// When MOZ_JSDOWNLOADS is undefined, we still check the preference that can
// be used to enable the JavaScript API during the migration process.
mUseJSTransfer = Preferences::GetBool(PREF_BD_USEJSTRANSFER, false);
-#elif defined(XP_WIN)
- // When MOZ_JSDOWNLOADS is defined on Windows, this component is disabled
- // unless we are running in Windows Metro. The conversion of Windows Metro
- // to use the JavaScript API for downloads is tracked in bug 906042.
- mUseJSTransfer = !IsRunningInWindowsMetro();
#else
- mUseJSTransfer = true;
+ mUseJSTransfer = true;
#endif
if (mUseJSTransfer)
diff --git a/toolkit/components/jsdownloads/src/DownloadIntegration.jsm b/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
index 7e9a6348f..2ed769371 100644
--- a/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
+++ b/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
@@ -457,13 +457,7 @@ this.DownloadIntegration = {
#elifdef MOZ_WIDGET_GONK
directoryPath = yield this.getSystemDownloadsDirectory();
#else
- // For Metro mode on Windows 8, we want searchability for documents
- // that the user chose to open with an external application.
- if (Services.metro && Services.metro.immersive) {
- directoryPath = yield this.getSystemDownloadsDirectory();
- } else {
- directoryPath = this._getDirectory("TmpD");
- }
+ directoryPath = this._getDirectory("TmpD");
#endif
throw new Task.Result(directoryPath);
}.bind(this));
diff --git a/toolkit/components/startup/nsAppStartup.cpp b/toolkit/components/startup/nsAppStartup.cpp
index 5b32ebcf4..629240add 100644
--- a/toolkit/components/startup/nsAppStartup.cpp
+++ b/toolkit/components/startup/nsAppStartup.cpp
@@ -143,7 +143,6 @@ nsAppStartup::nsAppStartup() :
mInterrupted(false),
mIsSafeModeNecessary(false),
mStartupCrashTrackingEnded(false),
- mRestartTouchEnvironment(false),
mRestartNotSameProfile(false)
{ }
@@ -284,9 +283,7 @@ nsAppStartup::Run(void)
}
nsresult retval = NS_OK;
- if (mRestartTouchEnvironment) {
- retval = NS_SUCCESS_RESTART_METRO_APP;
- } else if (mRestart) {
+ if (mRestart) {
retval = NS_SUCCESS_RESTART_APP;
} else if (mRestartNotSameProfile) {
retval = NS_SUCCESS_RESTART_APP_NOT_SAME_PROFILE;
@@ -384,17 +381,12 @@ nsAppStartup::Quit(uint32_t aMode)
gRestartMode = (aMode & 0xF0);
}
- if (!mRestartTouchEnvironment) {
- mRestartTouchEnvironment = (aMode & eRestartTouchEnvironment) != 0;
- gRestartMode = (aMode & 0xF0);
- }
-
if (!mRestartNotSameProfile) {
mRestartNotSameProfile = (aMode & eRestartNotSameProfile) != 0;
gRestartMode = (aMode & 0xF0);
}
- if (mRestart || mRestartTouchEnvironment || mRestartNotSameProfile) {
+ if (mRestart || mRestartNotSameProfile) {
// Mark the next startup as a restart.
PR_SetEnv("MOZ_APP_RESTART=1");
@@ -464,7 +456,7 @@ nsAppStartup::Quit(uint32_t aMode)
NS_NAMED_LITERAL_STRING(shutdownStr, "shutdown");
NS_NAMED_LITERAL_STRING(restartStr, "restart");
obsService->NotifyObservers(nullptr, "quit-application",
- (mRestart || mRestartTouchEnvironment || mRestartNotSameProfile) ?
+ (mRestart || mRestartNotSameProfile) ?
restartStr.get() : shutdownStr.get());
}
@@ -591,14 +583,6 @@ nsAppStartup::GetWasRestarted(bool *aResult)
}
NS_IMETHODIMP
-nsAppStartup::GetRestartingTouchEnvironment(bool *aResult)
-{
- NS_ENSURE_ARG_POINTER(aResult);
- *aResult = mRestartTouchEnvironment;
- return NS_OK;
-}
-
-NS_IMETHODIMP
nsAppStartup::SetInterrupted(bool aInterrupted)
{
mInterrupted = aInterrupted;
diff --git a/toolkit/components/startup/nsAppStartup.h b/toolkit/components/startup/nsAppStartup.h
index 7b586040c..7f8b9bd61 100644
--- a/toolkit/components/startup/nsAppStartup.h
+++ b/toolkit/components/startup/nsAppStartup.h
@@ -62,7 +62,6 @@ private:
bool mInterrupted; // Was startup interrupted by an interactive prompt?
bool mIsSafeModeNecessary; // Whether safe mode is necessary
bool mStartupCrashTrackingEnded; // Whether startup crash tracking has already ended
- bool mRestartTouchEnvironment; // Quit (eRestartTouchEnvironment)
bool mRestartNotSameProfile; // Quit(eRestartNotSameProfile)
#if defined(XP_WIN)
diff --git a/toolkit/components/startup/public/nsIAppStartup.idl b/toolkit/components/startup/public/nsIAppStartup.idl
index 8edf6b026..b6c899798 100644
--- a/toolkit/components/startup/public/nsIAppStartup.idl
+++ b/toolkit/components/startup/public/nsIAppStartup.idl
@@ -32,11 +32,6 @@ interface nsIAppStartup : nsISupports
* This return code indicates that the application should be
* restarted because quit was called with the eRestart flag.
- * @returnCode NS_SUCCESS_RESTART_METRO_APP
- * This return code indicates that the application should be
- * restarted in metro because quit was called with the
- * eRestartTouchEnviroment flag.
-
* @returnCode NS_SUCCESS_RESTART_APP_NOT_SAME_PROFILE
* This return code indicates that the application should be
* restarted without necessarily using the same profile because
@@ -133,13 +128,6 @@ interface nsIAppStartup : nsISupports
const uint32_t eRestartx86_64 = 0x40;
/**
- * Restart the application in a touch-optimized environment (such as Metro)
- * after quitting. The application will be restarted with the same profile
- * and an empty command line.
- */
- const uint32_t eRestartTouchEnvironment = 0x80;
-
- /**
* Restart the application after quitting. The application will be
* restarted with an empty command line and the normal profile selection
* process will take place on startup.
@@ -185,12 +173,6 @@ interface nsIAppStartup : nsISupports
*/
readonly attribute boolean wasRestarted;
- /**
- * True if the application is being restarted in a touch-optimized
- * environment (such as Metro).
- */
- readonly attribute boolean restartingTouchEnvironment;
-
/**
* Returns an object with main, process, firstPaint, sessionRestored properties.
* Properties may not be available depending on platform or application
diff --git a/toolkit/content/widgets/browser.xml b/toolkit/content/widgets/browser.xml
index b05825210..e0b13dd24 100644
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -658,7 +658,7 @@
<field name="blockedPopups">null</field>
- <!-- Obsolete name for blockedPopups. Used by metro and android. -->
+ <!-- Obsolete name for blockedPopups. Used by android. -->
<property name="pageReport"
onget="return this.blockedPopups;"
readonly="true"/>
diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build
index 98d42392f..1489d2fd3 100644
--- a/toolkit/library/moz.build
+++ b/toolkit/library/moz.build
@@ -28,13 +28,6 @@ def Libxul(name):
'winspool.drv'
]
- if CONFIG['MOZ_METRO']:
- DELAYLOAD_DLLS += [
- 'API-MS-WIN-CORE-WINRT-L' + CONFIG['CRTEXPDLLVERSION'] + '.DLL',
- 'API-MS-WIN-CORE-WINRT-STRING-L' + CONFIG['CRTEXPDLLVERSION'] + '.DLL',
- 'uiautomationcore.dll'
- ]
-
if CONFIG['ACCESSIBILITY']:
DELAYLOAD_DLLS += ['oleacc.dll']
@@ -359,11 +352,6 @@ if CONFIG['OS_ARCH'] == 'WINNT':
OS_LIBS += [
'oleacc',
]
- if CONFIG['MOZ_METRO']:
- OS_LIBS += [
- 'uiautomationcore',
- 'runtimeobject',
- ]
if CONFIG['MOZ_ENABLE_QT']:
OS_LIBS += CONFIG['XEXT_LIBS']
diff --git a/toolkit/locales/en-US/chrome/places/places.properties b/toolkit/locales/en-US/chrome/places/places.properties
index 8b543b8e4..30acd912b 100644
--- a/toolkit/locales/en-US/chrome/places/places.properties
+++ b/toolkit/locales/en-US/chrome/places/places.properties
@@ -29,8 +29,3 @@ localhost=(local files)
# %1$S is the file size
# %2$S is the file size unit
backupFileSizeText=%1$S %2$S
-
-# LOCALIZATION NOTE (windows8TouchTitle): this is the name of the folder used
-# to store bookmarks created in Metro mode and share bookmarks between Metro
-# and Desktop.
-windows8TouchTitle=Windows 8 Touch \ No newline at end of file
diff --git a/toolkit/modules/Finder.jsm b/toolkit/modules/Finder.jsm
index d4d430d04..b4e0959f8 100644
--- a/toolkit/modules/Finder.jsm
+++ b/toolkit/modules/Finder.jsm
@@ -501,7 +501,11 @@ Finder.prototype = {
},
_getWindow: function () {
- return this._docShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
+ try {
+ return this._docShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
+ } catch(e) {
+ Cu.reportError(e);
+ }
},
/**
diff --git a/toolkit/mozapps/installer/windows/nsis/common.nsh b/toolkit/mozapps/installer/windows/nsis/common.nsh
index 636c6488d..39896b8f1 100644
--- a/toolkit/mozapps/installer/windows/nsis/common.nsh
+++ b/toolkit/mozapps/installer/windows/nsis/common.nsh
@@ -7803,128 +7803,3 @@
Exch $0 ; return elapsed seconds
!macroend
-!ifdef MOZ_METRO
-; Removes the CEH registration if it's set to our installation directory.
-; If it's set to some other installation directory, then it should be removed
-; by that installation.
-!macro RemoveDEHRegistrationIfMatchingCall un
-
- Function ${un}RemoveDEHRegistrationIfMatchingCall
- ; Retrieve DEH ID from the stack into $R9
- Exch $R9
- Exch 1
-
- ; Retrieve Protocol Activation ID from stack into $R8
- Exch $R8
- Exch 2
-
- ; Retrieve File Activation ID from stack into $R7
- Exch $R7
-
- ; Backup the old values of R6 and R5 on the stack
- Push $R6
- Push $R5
-
- ; Conditionally remove the DEH as long as we are the default (HKCU)
- ReadRegStr $R6 HKCU "Software\Classes\CLSID\$R9\LocalServer32" ""
- ${${un}GetLongPath} "$INSTDIR" $R5
- StrCmp "$R6" "" next +1
- IfFileExists "$R6" +1 clearHKCU
- ${${un}GetParent} "$R6" $R6
- ${${un}GetLongPath} "$R6" $R6
- StrCmp "$R5" "$R6" clearHKCU next
- clearHKCU:
- DeleteRegKey HKCU "Software\Classes\CLSID\$R9"
- DeleteRegValue HKCU "Software\Classes\$R8\shell\open\command" "DelegateExecute"
- DeleteRegValue HKCU "Software\Classes\$R7\shell\open\command" "DelegateExecute"
- next:
-
- ; Conditionally remove the DEH as long as we are the default (HKLM)
- ReadRegStr $R6 HKLM "Software\Classes\CLSID\$R9\LocalServer32" ""
- ${${un}GetLongPath} "$INSTDIR" $R5
- StrCmp "$R6" "" done +1
- IfFileExists "$R6" +1 clearHKLM
- ${${un}GetParent} "$R6" $R6
- ${${un}GetLongPath} "$R6" $R6
- StrCmp "$R5" "$R6" clearHKLM done
- clearHKLM:
- DeleteRegKey HKLM "Software\Classes\CLSID\$R9"
- DeleteRegValue HKLM "Software\Classes\$R8\shell\open\command" "DelegateExecute"
- DeleteRegValue HKLM "Software\Classes\$R7\shell\open\command" "DelegateExecute"
- done:
-
- ; Always remove the AppUserModelID keys for this installation
- DeleteRegKey HKCU "Software\Classes\$AppUserModelID"
- DeleteRegKey HKLM "Software\Classes\$AppUserModelID"
-
- ; Restore the registers back to their original state
- Pop $R5
- Pop $R6
- Exch $R7
- Exch 2
- Exch $R8
- Exch 1
- Exch $R9
- FunctionEnd
-!macroend
-
-!macro RemoveDEHRegistrationIfMatching
- !insertmacro RemoveDEHRegistrationIfMatchingCall ""
-!macroend
-
-!macro un.RemoveDEHRegistrationIfMatching
- !insertmacro RemoveDEHRegistrationIfMatchingCall "un."
-!macroend
-
-!macro CleanupMetroBrowserHandlerValues un DELEGATE_EXECUTE_HANDLER_ID \
- PROTOCOL_ACTIVATION_ID \
- FILE_ACTIVATION_ID
- Push ${FILE_ACTIVATION_ID}
- Push ${PROTOCOL_ACTIVATION_ID}
- Push ${DELEGATE_EXECUTE_HANDLER_ID}
- Call ${un}RemoveDEHRegistrationIfMatchingCall
-!macroend
-!define CleanupMetroBrowserHandlerValues '!insertmacro CleanupMetroBrowserHandlerValues ""'
-!define un.CleanupMetroBrowserHandlerValues '!insertmacro CleanupMetroBrowserHandlerValues "un."'
-
-!macro AddMetroBrowserHandlerValues DELEGATE_EXECUTE_HANDLER_ID \
- DELEGATE_EXECUTE_HANDLER_PATH \
- APP_USER_MODEL_ID \
- PROTOCOL_ACTIVATION_ID \
- FILE_ACTIVATION_ID
- ; Win8 doesn't use conventional progid command data to launch anymore.
- ; Instead it uses a delegate execute handler which is a light weight COM
- ; server for choosing the metro or desktop browser to launch depending
- ; on the current environment (metro/desktop) it was activated in.
- WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}" "" ""
- WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}\.exe" "" ""
- WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}\.exe\shell" "" "open"
- WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}\.exe\shell\open" "CommandId" "open"
- WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}\.exe\shell\open\command" "" "$2"
- WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}\.exe\shell\open\command" "DelegateExecute" "${DELEGATE_EXECUTE_HANDLER_ID}"
-
- ; Augment the url handler registrations with additional data needed for Metro
- WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}" "AppUserModelID" "${APP_USER_MODEL_ID}"
- WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\Application" "AppUserModelID" "${APP_USER_MODEL_ID}"
- WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\Application" "ApplicationName" "$BrandShortName"
- WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\Application" "ApplicationIcon" "$INSTDIR\${FileMainEXE},0"
- WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\Application" "ApplicationCompany" "${CompanyName}"
- WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\Application" "ApplicationDescription" "$(REG_APP_DESC)"
- WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\shell" "" "open"
- WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\shell\open" "CommandId" "open"
- WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\shell\open\command" "DelegateExecute" "${DELEGATE_EXECUTE_HANDLER_ID}"
-
- ; Augment the file handler registrations with additional data needed for Metro
- WriteRegStr SHCTX "Software\Classes\${FILE_ACTIVATION_ID}" "AppUserModelID" "${APP_USER_MODEL_ID}"
- WriteRegStr SHCTX "Software\Classes\${FILE_ACTIVATION_ID}\shell" "" "open"
- WriteRegStr SHCTX "Software\Classes\${FILE_ACTIVATION_ID}\shell\open" "CommandId" "open"
- WriteRegStr SHCTX "Software\Classes\${FILE_ACTIVATION_ID}\shell\open\command" "DelegateExecute" "${DELEGATE_EXECUTE_HANDLER_ID}"
-
- ; Win8 Metro delegate execute handler registration
- WriteRegStr SHCTX "Software\Classes\CLSID\${DELEGATE_EXECUTE_HANDLER_ID}" "" "$BrandShortName CommandExecuteHandler"
- WriteRegStr SHCTX "Software\Classes\CLSID\${DELEGATE_EXECUTE_HANDLER_ID}" "AppId" "${DELEGATE_EXECUTE_HANDLER_ID}"
- WriteRegStr SHCTX "Software\Classes\CLSID\${DELEGATE_EXECUTE_HANDLER_ID}\LocalServer32" "" "${DELEGATE_EXECUTE_HANDLER_PATH}"
-!macroend
-!define AddMetroBrowserHandlerValues "!insertmacro AddMetroBrowserHandlerValues"
-!endif ;end MOZ_METRO
-
diff --git a/toolkit/mozapps/update/common/updatehelper.cpp b/toolkit/mozapps/update/common/updatehelper.cpp
index f9e1989ef..ed582b61a 100644
--- a/toolkit/mozapps/update/common/updatehelper.cpp
+++ b/toolkit/mozapps/update/common/updatehelper.cpp
@@ -2,17 +2,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/. */
-#ifdef MOZ_METRO
-// Needed for COM calls to launch Metro applications
-#undef WINVER
-#undef _WIN32_WINNT
-#define WINVER 0x602
-#define _WIN32_WINNT 0x602
-#include <objbase.h>
-#include <shobjidl.h>
-#pragma comment(lib, "ole32.lib")
-#endif
-
#include <windows.h>
// Needed for CreateToolhelp32Snapshot
@@ -616,71 +605,3 @@ IsUnpromptedElevation(BOOL &isUnpromptedElevation)
RegCloseKey(baseKey);
return success;
}
-
-#ifdef MOZ_METRO
- /*
- * Retrieve the app model id of the firefox metro browser.
- *
- * @aPathBuffer Buffer to fill
- * @aCharLength Length of buffer to fill in characters
- */
- bool GetDefaultBrowserAppModelID(WCHAR* aIDBuffer, long aCharLength)
- {
- if (!aIDBuffer || aCharLength <= 0)
- return false;
-
- memset(aIDBuffer, 0, (sizeof(WCHAR)*aCharLength));
- static const WCHAR* kDefaultMetroBrowserIDPathKey = L"FirefoxURL";
-
- HKEY key;
- if (RegOpenKeyExW(HKEY_CLASSES_ROOT, kDefaultMetroBrowserIDPathKey,
- 0, KEY_READ, &key) != ERROR_SUCCESS) {
- return false;
- }
- DWORD len = aCharLength * sizeof(WCHAR);
- memset(aIDBuffer, 0, len);
- if (RegQueryValueExW(key, L"AppUserModelID", nullptr, nullptr,
- (LPBYTE)aIDBuffer, &len) != ERROR_SUCCESS || !len) {
- RegCloseKey(key);
- return false;
- }
- RegCloseKey(key);
- return true;
- }
-
- HRESULT
- LaunchDefaultMetroBrowser()
- {
- CoInitialize(nullptr);
- HRESULT hr = E_FAIL;
- // The interface that allows us to activate the browser
- IApplicationActivationManager *activateMgr;
- if (FAILED(hr = CoCreateInstance(CLSID_ApplicationActivationManager,
- nullptr, CLSCTX_LOCAL_SERVER,
- IID_IApplicationActivationManager,
- (void**)&activateMgr))) {
- CoUninitialize();
- return hr;
- }
-
- // Activation is based on the browser's registered app model id
- WCHAR appModelID[256];
- if (!GetDefaultBrowserAppModelID(appModelID, (sizeof(appModelID)/sizeof(WCHAR)))) {
- activateMgr->Release();
- CoUninitialize();
- return hr;
- }
-
- // Hand off focus rights to the out-of-process activation server. Without
- // this the metro interface won't launch.
- CoAllowSetForegroundWindow(activateMgr, nullptr);
-
- // Launch default browser in Metro
- DWORD processID;
- hr = activateMgr->ActivateApplication(appModelID, L"", AO_NOERRORUI,
- &processID);
- activateMgr->Release();
- CoUninitialize();
- return hr;
- }
-#endif
diff --git a/toolkit/mozapps/update/common/updatehelper.h b/toolkit/mozapps/update/common/updatehelper.h
index 8c87ee054..155ac8b0e 100644
--- a/toolkit/mozapps/update/common/updatehelper.h
+++ b/toolkit/mozapps/update/common/updatehelper.h
@@ -26,8 +26,3 @@ BOOL IsUnpromptedElevation(BOOL &isUnpromptedElevation);
#define TEST_ONLY_FALLBACK_KEY_PATH \
BASE_SERVICE_REG_KEY L"\\3932ecacee736d366d6436db0f55bce4"
-#ifdef MOZ_METRO
- bool GetDefaultBrowserAppModelID(WCHAR* aIDBuffer, long aCharLength);
- HRESULT LaunchDefaultMetroBrowser();
-#endif
-
diff --git a/toolkit/mozapps/update/nsIUpdateService.idl b/toolkit/mozapps/update/nsIUpdateService.idl
index 5e05dfd06..4e2e32cb3 100644
--- a/toolkit/mozapps/update/nsIUpdateService.idl
+++ b/toolkit/mozapps/update/nsIUpdateService.idl
@@ -443,9 +443,8 @@ interface nsIApplicationUpdateService : nsISupports
/**
* Whether or not a different instance is handling updates of this
* installation. This currently only ever returns true on Windows
- * when 2 instances of an application are open or when both the Metro
- * and Desktop browsers are open. Only one of the instances will actually
- * handle updates for the installation.
+ * when 2 instances of an application are open. Only one of the
+ * instances will actually handle updates for the installation.
*/
readonly attribute boolean isOtherInstanceHandlingUpdates;
diff --git a/toolkit/mozapps/update/tests/chrome/utils.js b/toolkit/mozapps/update/tests/chrome/utils.js
index 4c7c2699b..963a0c886 100644
--- a/toolkit/mozapps/update/tests/chrome/utils.js
+++ b/toolkit/mozapps/update/tests/chrome/utils.js
@@ -181,7 +181,6 @@ var gCloseWindowTimeoutCounter = 0;
// The following vars are for restoring previous preference values (if present)
// when the test finishes.
var gAppUpdateEnabled; // app.update.enabled
-var gAppUpdateMetroEnabled; // app.update.metro.enabled
var gAppUpdateServiceEnabled; // app.update.service.enabled
var gAppUpdateStagingEnabled; // app.update.staging.enabled
var gAppUpdateURLDefault; // app.update.url (default prefbranch)
@@ -898,11 +897,6 @@ function setupPrefs() {
}
Services.prefs.setBoolPref(PREF_APP_UPDATE_ENABLED, true);
- if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_METRO_ENABLED)) {
- gAppUpdateMetroEnabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_METRO_ENABLED);
- }
- Services.prefs.setBoolPref(PREF_APP_UPDATE_METRO_ENABLED, true);
-
if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_SERVICE_ENABLED)) {
gAppUpdateServiceEnabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_SERVICE_ENABLED);
}
@@ -983,13 +977,6 @@ function resetPrefs() {
Services.prefs.clearUserPref(PREF_APP_UPDATE_ENABLED);
}
- if (gAppUpdateMetroEnabled !== undefined) {
- Services.prefs.setBoolPref(PREF_APP_UPDATE_METRO_ENABLED, gAppUpdateMetroEnabled);
- }
- else if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_METRO_ENABLED)) {
- Services.prefs.clearUserPref(PREF_APP_UPDATE_METRO_ENABLED);
- }
-
if (gAppUpdateServiceEnabled !== undefined) {
Services.prefs.setBoolPref(PREF_APP_UPDATE_SERVICE_ENABLED, gAppUpdateServiceEnabled);
}
diff --git a/toolkit/mozapps/update/tests/shared.js b/toolkit/mozapps/update/tests/shared.js
index 5a5aa8ae2..d70179654 100644
--- a/toolkit/mozapps/update/tests/shared.js
+++ b/toolkit/mozapps/update/tests/shared.js
@@ -22,7 +22,6 @@ const PREF_APP_UPDATE_CERT_MAXERRORS = "app.update.cert.maxErrors";
const PREF_APP_UPDATE_CERT_REQUIREBUILTIN = "app.update.cert.requireBuiltIn";
const PREF_APP_UPDATE_CHANNEL = "app.update.channel";
const PREF_APP_UPDATE_ENABLED = "app.update.enabled";
-const PREF_APP_UPDATE_METRO_ENABLED = "app.update.metro.enabled";
const PREF_APP_UPDATE_IDLETIME = "app.update.idletime";
const PREF_APP_UPDATE_LOG = "app.update.log";
const PREF_APP_UPDATE_NEVER_BRANCH = "app.update.never.";
diff --git a/toolkit/mozapps/update/tests/unit_aus_update/head_update.js b/toolkit/mozapps/update/tests/unit_aus_update/head_update.js
index 8bdc090f7..624932f30 100644
--- a/toolkit/mozapps/update/tests/unit_aus_update/head_update.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/head_update.js
@@ -1047,7 +1047,6 @@ function doTestFinish() {
*/
function setDefaultPrefs() {
Services.prefs.setBoolPref(PREF_APP_UPDATE_ENABLED, true);
- Services.prefs.setBoolPref(PREF_APP_UPDATE_METRO_ENABLED, true);
// Don't display UI for a successful installation. Some apps may not set this
// pref to false like Firefox does.
Services.prefs.setBoolPref(PREF_APP_UPDATE_SHOW_INSTALLED_UI, false);
diff --git a/toolkit/mozapps/update/updater/updater.cpp b/toolkit/mozapps/update/updater/updater.cpp
index 756455d38..204c6c72f 100644
--- a/toolkit/mozapps/update/updater/updater.cpp
+++ b/toolkit/mozapps/update/updater/updater.cpp
@@ -70,7 +70,6 @@
#else
#define PARENT_WAIT 10000
#endif
-#define IMMERSIVE_PARENT_WAIT 15000
#if defined(XP_MACOSX)
// These functions are defined in launchchild_osx.mm
@@ -1804,23 +1803,6 @@ PatchIfFile::Finish(int status)
#include "uachelper.h"
#include "pathhash.h"
-#ifdef MOZ_METRO
-/**
- * Determines if the update came from an Immersive browser
- * @return true if the update came from an immersive browser
- */
-bool
-IsUpdateFromMetro(int argc, NS_tchar **argv)
-{
- for (int i = 0; i < argc; i++) {
- if (!wcsicmp(L"-ServerName:DefaultBrowserServer", argv[i])) {
- return true;
- }
- }
- return false;
-}
-#endif
-
/**
* Launch the post update application (helper.exe). It takes in the path of the
* callback application to calculate the path of helper.exe.
@@ -2624,15 +2606,10 @@ int NS_main(int argc, NS_tchar **argv)
// Otherwise, wait for the parent process to exit before starting the
// update.
if (parent) {
- bool updateFromMetro = false;
-#ifdef MOZ_METRO
- updateFromMetro = IsUpdateFromMetro(argc, argv);
-#endif
- DWORD waitTime = updateFromMetro ?
- IMMERSIVE_PARENT_WAIT : PARENT_WAIT;
+ DWORD waitTime = PARENT_WAIT;
DWORD result = WaitForSingleObject(parent, waitTime);
CloseHandle(parent);
- if (result != WAIT_OBJECT_0 && !updateFromMetro)
+ if (result != WAIT_OBJECT_0)
return 1;
}
}
diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp
index 2964d900a..9b015619b 100644
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -95,9 +95,6 @@
#include <windows.h>
#include "cairo/cairo-features.h"
#include "mozilla/WindowsVersion.h"
-#ifdef MOZ_METRO
-#include <roapi.h>
-#endif
#ifndef PROCESS_DEP_ENABLE
#define PROCESS_DEP_ENABLE 0x1
@@ -126,10 +123,6 @@
#include "nsXREDirProvider.h"
#include "nsToolkitCompsCID.h"
-#if defined(XP_WIN) && defined(MOZ_METRO)
-#include "updatehelper.h"
-#endif
-
#include "nsINIParser.h"
#include "mozilla/Omnijar.h"
#include "mozilla/StartupTimeline.h"
@@ -566,16 +559,13 @@ ProcessDDE(nsINativeAppSupport* aNative, bool aWait)
/**
* Determines if there is support for showing the profile manager
*
- * @return true in all environments except for Windows Metro
+ * @return currently true in all environments
+ * XXX: This was false for Metro. Possibly remove this logic.
*/
static bool
CanShowProfileManager()
{
-#if defined(XP_WIN)
- return XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Desktop;
-#else
return true;
-#endif
}
static bool
@@ -2688,38 +2678,6 @@ static DWORD WINAPI InitDwriteBG(LPVOID lpdwThreadParam)
bool fire_glxtest_process();
#endif
-#if defined(XP_WIN) && defined(MOZ_METRO)
-#ifndef AHE_TYPE
-enum AHE_TYPE {
- AHE_DESKTOP = 0,
- AHE_IMMERSIVE = 1
-};
-#endif
-
-/*
- * The Windows launcher uses this value to decide what front end ui
- * to launch. We always launch the same ui unless the user
- * specifically asks to switch. Update the value on every startup
- * based on the environment requested.
- */
-void
-SetLastWinRunType(AHE_TYPE aType)
-{
- HKEY key;
- LONG result = RegOpenKeyExW(HKEY_CURRENT_USER,
- L"SOFTWARE\\Mozilla\\Firefox",
- 0, KEY_WRITE, &key);
- if (result != ERROR_SUCCESS) {
- return;
- }
- DWORD value = (DWORD)aType;
- result = RegSetValueEx(key, L"MetroLastAHE", 0, REG_DWORD,
- reinterpret_cast<LPBYTE>(&value),
- sizeof(DWORD));
- RegCloseKey(key);
-}
-#endif // defined(XP_WIN) && defined(MOZ_METRO)
-
#include "GoannaProfiler.h"
// Encapsulates startup and shutdown state for XRE_main
@@ -2811,19 +2769,6 @@ XREMain::XRE_mainInit(bool* aExitFlag)
fire_glxtest_process();
#endif
-#if defined(XP_WIN) && defined(MOZ_METRO)
- // Don't remove this arg, we want to pass it on to nsUpdateDriver
- if (CheckArg("metro-update", false, nullptr, false) == ARG_FOUND ||
- XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) {
- // If we're doing a restart update that was initiated from metro land,
- // we'll be running desktop to handle the actual update. Request that
- // after the restart we launch into metro.
- SetLastWinRunType(AHE_IMMERSIVE);
- } else {
- SetLastWinRunType(AHE_DESKTOP);
- }
-#endif
-
SetupErrorHandling(gArgv[0]);
#ifdef CAIRO_HAS_DWRITE_FONT
@@ -3406,12 +3351,6 @@ XREMain::XRE_mainStartup(bool* aExitFlag)
*aExitFlag = true;
return 0;
}
-#if defined(XP_WIN) && defined(MOZ_METRO)
- if (CheckArg("metro-update", false) == ARG_FOUND) {
- *aExitFlag = true;
- return 0;
- }
-#endif
#endif
rv = NS_NewToolkitProfileService(getter_AddRefs(mProfileSvc));
@@ -3868,7 +3807,6 @@ XREMain::XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
// Check for an application initiated restart. This is one that
// corresponds to nsIAppStartup.quit(eRestart)
if (rv == NS_SUCCESS_RESTART_APP
- || rv == NS_SUCCESS_RESTART_METRO_APP
|| rv == NS_SUCCESS_RESTART_APP_NOT_SAME_PROFILE) {
appInitiatedRestart = true;
@@ -3912,15 +3850,7 @@ XREMain::XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
MOZ_gdk_display_close(mGdkDisplay);
#endif
-#if defined(MOZ_METRO) && defined(XP_WIN)
- if (rv == NS_SUCCESS_RESTART_METRO_APP) {
- LaunchDefaultMetroBrowser();
- rv = NS_OK;
- } else
-#endif
- {
- rv = LaunchChild(mNativeApp, true);
- }
+ rv = LaunchChild(mNativeApp, true);
return rv == NS_ERROR_LAUNCHED_CHILD_PROCESS ? 0 : 1;
}
@@ -3936,173 +3866,18 @@ XREMain::XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
return NS_FAILED(rv) ? 1 : 0;
}
-#if defined(MOZ_METRO) && defined(XP_WIN)
-extern bool XRE_MetroCoreApplicationRun();
-static XREMain* xreMainPtr;
-
-// must be called by the thread we want as the main thread
-nsresult
-XRE_metroStartup(bool runXREMain)
-{
- nsresult rv;
-
- // XXX This call, odly enough, will set this thread as
- // the main thread. (see bug 1033358)
- ScopedLogging log;
-
- bool exit = false;
- if (xreMainPtr->XRE_mainStartup(&exit) != 0 || exit)
- return NS_ERROR_FAILURE;
-
- // Start the real application
- xreMainPtr->mScopedXPCOM = MakeUnique<ScopedXPCOMStartup>();
- if (!xreMainPtr->mScopedXPCOM)
- return NS_ERROR_FAILURE;
-
- rv = xreMainPtr->mScopedXPCOM->Initialize();
- NS_ENSURE_SUCCESS(rv, rv);
-
- if (runXREMain) {
- rv = xreMainPtr->XRE_mainRun();
- NS_ENSURE_SUCCESS(rv, rv);
- }
- return NS_OK;
-}
-
-void
-XRE_metroShutdown()
-{
- xreMainPtr->mScopedXPCOM = nullptr;
-
-#ifdef MOZ_INSTRUMENT_EVENT_LOOP
- mozilla::ShutdownEventTracing();
-#endif
-
- // unlock the profile after ScopedXPCOMStartup object (xpcom)
- // has gone out of scope. see bug #386739 for more details
- xreMainPtr->mProfileLock->Unlock();
- gProfileLock = nullptr;
-
- XRE_DeinitCommandLine();
-}
-
-class WinRTInitWrapper
-{
-public:
- WinRTInitWrapper() {
- mResult = ::RoInitialize(RO_INIT_MULTITHREADED);
- }
- ~WinRTInitWrapper() {
- if (SUCCEEDED(mResult)) {
- ::RoUninitialize();
- }
- }
- HRESULT mResult;
-};
-
-int
-XRE_mainMetro(int argc, char* argv[], const nsXREAppData* aAppData)
-{
- char aLocal;
- GoannaProfilerInitRAII profilerGuard(&aLocal);
-
- PROFILER_LABEL("Startup", "XRE_Main",
- js::ProfileEntry::Category::OTHER);
-
- mozilla::IOInterposerInit ioInterposerGuard;
-
- nsresult rv = NS_OK;
-
- xreMainPtr = new XREMain();
- if (!xreMainPtr) {
- return 1;
- }
-
- // Inits Winrt and COM underneath it.
- WinRTInitWrapper wrap;
-
- gArgc = argc;
- gArgv = argv;
-
- NS_ENSURE_TRUE(aAppData, 2);
-
- xreMainPtr->mAppData = new ScopedAppData(aAppData);
- if (!xreMainPtr->mAppData)
- return 1;
- // used throughout this file
- gAppData = xreMainPtr->mAppData;
-
- // init
- bool exit = false;
- if (xreMainPtr->XRE_mainInit(&exit) != 0 || exit)
- return 1;
-
- // Located in widget, will call back into XRE_metroStartup and
- // XRE_metroShutdown above.
- if (!XRE_MetroCoreApplicationRun()) {
- return 1;
- }
-
- // XRE_metroShutdown should have already been called on the worker
- // thread that called XRE_metroStartup.
- NS_ASSERTION(!xreMainPtr->mScopedXPCOM,
- "XPCOM Shutdown hasn't occured, and we are exiting.");
- return 0;
-}
-
-void SetWindowsEnvironment(WindowsEnvironmentType aEnvID);
-#endif // MOZ_METRO || !defined(XP_WIN)
-
void
XRE_StopLateWriteChecks(void) {
mozilla::StopLateWriteChecks();
}
-// Separate stub function to let us specifically suppress it in Valgrind
-void
-XRE_CreateStatsObject()
-{
- // A initializer to initialize histogram collection, a chromium
- // thing used by Telemetry (and effectively a global; it's all static).
- // Note: purposely leaked
- base::StatisticsRecorder* statistics_recorder = new base::StatisticsRecorder();
- MOZ_LSAN_INTENTIONALLY_LEAK_OBJECT(statistics_recorder);
- unused << statistics_recorder;
-}
-
int
XRE_main(int argc, char* argv[], const nsXREAppData* aAppData, uint32_t aFlags)
{
-#if !defined(MOZ_METRO) || !defined(XP_WIN)
XREMain main;
-
- XRE_CreateStatsObject();
int result = main.XRE_main(argc, argv, aAppData);
mozilla::RecordShutdownEndTimeStamp();
return result;
-#else
- if (aFlags == XRE_MAIN_FLAG_USE_METRO) {
- SetWindowsEnvironment(WindowsEnvironmentType_Metro);
- }
-
- // Desktop
- if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Desktop) {
- XREMain main;
- int result = main.XRE_main(argc, argv, aAppData);
- mozilla::RecordShutdownEndTimeStamp();
- return result;
- }
-
- // Metro
- NS_ASSERTION(XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro,
- "Unknown Windows environment");
-
- SetLastWinRunType(AHE_IMMERSIVE);
-
- int result = XRE_mainMetro(argc, argv, aAppData);
- mozilla::RecordShutdownEndTimeStamp();
- return result;
-#endif // MOZ_METRO || !defined(XP_WIN)
}
nsresult
diff --git a/toolkit/xre/nsEmbedFunctions.cpp b/toolkit/xre/nsEmbedFunctions.cpp
index b6b459817..07dac1810 100644
--- a/toolkit/xre/nsEmbedFunctions.cpp
+++ b/toolkit/xre/nsEmbedFunctions.cpp
@@ -796,23 +796,6 @@ XRE_InstallX11ErrorHandler()
}
#endif
-#ifdef XP_WIN
-static WindowsEnvironmentType
-sWindowsEnvironmentType = WindowsEnvironmentType_Desktop;
-
-void
-SetWindowsEnvironment(WindowsEnvironmentType aEnvID)
-{
- sWindowsEnvironmentType = aEnvID;
-}
-
-WindowsEnvironmentType
-XRE_GetWindowsEnvironment()
-{
- return sWindowsEnvironmentType;
-}
-#endif // XP_WIN
-
#ifdef MOZ_B2G_LOADER
extern const nsXREAppData* gAppData;
diff --git a/toolkit/xre/nsUpdateDriver.cpp b/toolkit/xre/nsUpdateDriver.cpp
index 814d598d2..7050e519a 100644
--- a/toolkit/xre/nsUpdateDriver.cpp
+++ b/toolkit/xre/nsUpdateDriver.cpp
@@ -321,19 +321,6 @@ IsOlderVersion(nsIFile *versionFile, const char *appVersion)
return false;
}
-#if defined(XP_WIN) && defined(MOZ_METRO)
-static bool
-IsWindowsMetroUpdateRequest(int appArgc, char **appArgv)
-{
- for (int index = 0; index < appArgc; index++) {
- if (!strcmp(appArgv[index], "--metro-update")) {
- return true;
- }
- }
- return false;
-}
-#endif
-
static bool
CopyFileIntoUpdateDir(nsIFile *parentDir, const char *leafName, nsIFile *updateDir)
{
@@ -574,15 +561,7 @@ SwitchToUpdatedApp(nsIFile *greDir, nsIFile *updateDir,
// just needs to replace the update directory.
pid.AppendLiteral("/replace");
- int immersiveArgc = 0;
-#if defined(XP_WIN) && defined(MOZ_METRO)
- // If this is desktop doing an update for metro, or if we're the metro browser
- // we want to launch the metro browser after we're finished.
- if (IsWindowsMetroUpdateRequest(appArgc, appArgv) || IsRunningInWindowsMetro()) {
- immersiveArgc = 1;
- }
-#endif
- int argc = appArgc + 6 + immersiveArgc;
+ int argc = appArgc + 6;
char **argv = new char*[argc + 1];
if (!argv)
return;
@@ -596,11 +575,6 @@ SwitchToUpdatedApp(nsIFile *greDir, nsIFile *updateDir,
argv[6] = (char*) appFilePath.get();
for (int i = 1; i < appArgc; ++i)
argv[6 + i] = appArgv[i];
-#ifdef XP_WIN
- if (immersiveArgc) {
- argv[argc - 1] = "-ServerName:DefaultBrowserServer";
- }
-#endif
argv[argc] = nullptr;
} else {
argc = 5;
@@ -859,15 +833,7 @@ ApplyUpdate(nsIFile *greDir, nsIFile *updateDir, nsIFile *statusFile,
#endif
}
- int immersiveArgc = 0;
-#if defined(XP_WIN) && defined(MOZ_METRO)
- // If this is desktop doing an update for metro, or if we're the metro browser
- // we want to launch the metro browser after we're finished.
- if (IsWindowsMetroUpdateRequest(appArgc, appArgv) || IsRunningInWindowsMetro()) {
- immersiveArgc = 1;
- }
-#endif
- int argc = appArgc + 6 + immersiveArgc;
+ int argc = appArgc + 6;
char **argv = new char*[argc + 1 ];
if (!argv)
return;
@@ -881,11 +847,6 @@ ApplyUpdate(nsIFile *greDir, nsIFile *updateDir, nsIFile *statusFile,
argv[6] = (char*) appFilePath.get();
for (int i = 1; i < appArgc; ++i)
argv[6 + i] = appArgv[i];
-#ifdef XP_WIN
- if (immersiveArgc) {
- argv[argc - 1] = "-ServerName:DefaultBrowserServer";
- }
-#endif
argv[argc] = nullptr;
} else {
argc = 5;
diff --git a/toolkit/xre/nsWindowsWMain.cpp b/toolkit/xre/nsWindowsWMain.cpp
index dc3edc0ca..4ed4fed53 100644
--- a/toolkit/xre/nsWindowsWMain.cpp
+++ b/toolkit/xre/nsWindowsWMain.cpp
@@ -16,7 +16,7 @@
#include "nsSetDllDirectory.h"
#endif
-#if defined(MOZ_METRO) || defined(__GNUC__)
+#if defined(__GNUC__)
#define XRE_DONT_SUPPORT_XPSP2
#endif
diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp
index c496a14ce..c1df66f0b 100644
--- a/toolkit/xre/nsXREDirProvider.cpp
+++ b/toolkit/xre/nsXREDirProvider.cpp
@@ -406,9 +406,6 @@ nsXREDirProvider::GetFile(const char* aProperty, bool* aPersistent,
else if (!strcmp(aProperty, NS_APP_PREFS_50_FILE)) {
rv = file->AppendNative(NS_LITERAL_CSTRING("prefs.js"));
}
- else if (!strcmp(aProperty, NS_METRO_APP_PREFS_50_FILE)) {
- rv = file->AppendNative(NS_LITERAL_CSTRING("metro-prefs.js"));
- }
else if (!strcmp(aProperty, NS_LOCALSTORE_UNSAFE_FILE)) {
rv = file->AppendNative(NS_LITERAL_CSTRING("localstore.rdf"));
}
@@ -1100,8 +1097,7 @@ nsXREDirProvider::GetUpdateRootDir(nsIFile* *aResult)
// Get the local app data directory and if a vendor name exists append it.
// If only a product name exists, append it. If neither exist fallback to
// old handling. We don't use the product name on purpose because we want a
- // shared update directory for different apps run from the same path (like
- // Metro & Desktop).
+ // shared update directory for different apps run from the same path.
nsCOMPtr<nsIFile> localDir;
if (pathHashResult && (hasVendor || gAppData->name) &&
NS_SUCCEEDED(GetUserDataDirectoryHome(getter_AddRefs(localDir), true)) &&
diff --git a/tools/profiler/platform.cpp b/tools/profiler/platform.cpp
index 56146a5c1..e4793db0d 100644
--- a/tools/profiler/platform.cpp
+++ b/tools/profiler/platform.cpp
@@ -68,10 +68,7 @@ static mozilla::StaticAutoPtr<mozilla::ProfilerIOInterposeObserver>
sInterposeObserver;
// The name that identifies the goanna thread for calls to
-// profiler_register_thread. For all platform except metro
-// the thread that calls mozilla_sampler_init is considered
-// the goanna thread. With metro the goanna thread is
-// registered later based on this thread name.
+// profiler_register_thread.
static const char * gGoannaThreadName = "GoannaMain";
void Sampler::Startup() {
@@ -493,10 +490,6 @@ void mozilla_sampler_init(void* stackTop)
tlsPseudoStack.set(stack);
bool isMainThread = true;
-#ifdef XP_WIN
- // For metrofx, we'll register the main thread once it's created.
- isMainThread = !(XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro);
-#endif
Sampler::RegisterCurrentThread(isMainThread ?
gGoannaThreadName : "Application Thread",
stack, isMainThread, stackTop);
diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp
index d96cdf42d..0f4e5ba18 100644
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -400,18 +400,8 @@ static nsresult GetDownloadDirectory(nsIFile **_directory,
else {
return NS_ERROR_FAILURE;
}
-#elif defined(XP_WIN)
- // On metro we want to be able to search opened files and the temp directory
- // is exlcuded in searches.
- nsresult rv;
- if (IsRunningInWindowsMetro()) {
- rv = NS_GetSpecialDirectory(NS_WIN_DEFAULT_DOWNLOAD_DIR, getter_AddRefs(dir));
- } else {
- rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(dir));
- }
- NS_ENSURE_SUCCESS(rv, rv);
#else
- // On all other platforms, we default to the systems temporary directory.
+ // On all other platforms, we default to the system's temporary directory.
nsresult rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(dir));
NS_ENSURE_SUCCESS(rv, rv);
#endif
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<nsAppShell*>(sAppShell)->Init();
-#else
- if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) {
- rv = static_cast<MetroAppShell*>(sAppShell)->Init();
- } else {
- rv = static_cast<nsAppShell*>(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 <textstor.h>
@@ -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<KeyPair>* 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<nsWindow*>(
- 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<nsWindow*>(
+ 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<nsWindow*>(
- 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<nsWindow*>(
+ 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<nsWindowBase> mWidget;
// Document manager for the currently focused editor
nsRefPtr<ITfDocumentMgr> 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<nsIWidget> 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<nsIWidget> 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<nsIWidget> widget;
-
- if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) {
- return NS_NOINTERFACE;
- } else {
- widget = new ChildWindow;
- }
+ nsCOMPtr<nsIWidget> 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<nsIFilePicker> 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<nsIFilePicker> 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<nsIColorPicker> 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<nsIColorPicker> 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<nsIAppStartup> 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<mozilla::layers::APZCTreeManager> APZController::sAPZC;
-
-/*
- * Metro layout specific - test to see if a sub document is a
- * tab.
- */
-static bool
-IsTab(nsCOMPtr<nsIDocument>& aSubDocument)
-{
- nsRefPtr<nsIDocument> 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<nsIDocument>& aSubDocument,
- nsCOMPtr<nsIContent>& aTargetContent)
-{
- // For tabs and subframes this will return the HTML sub document
- aTargetContent = nsLayoutUtils::FindContentFor(aScrollId);
- if (!aTargetContent) {
- return false;
- }
- nsCOMPtr<mozilla::dom::Element> 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<nsIDocument> subDocument;
- nsCOMPtr<nsIContent> 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<nsIDOMWindowUtils> utils;
- nsCOMPtr<nsIDOMWindow> 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<nsIRunnable> runnable = new TransformedStartEvent();
- NS_DispatchToMainThread(runnable);
- break;
- }
- case APZStateChange::TransformEnd:
- {
- if (NS_IsMainThread()) {
- MetroUtils::FireObserver("apzc-transform-end", L"");
- return;
- }
- nsCOMPtr<nsIRunnable> 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<mozilla::layers::APZCTreeManager> 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<ABI::Windows::Graphics::Display::DisplayInformation*,IInspectable*> : ITypedEventHandler_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::Graphics::Display::DisplayInformation*, ABI::Windows::Graphics::Display::IDisplayInformation*>,IInspectable*> {
-static const wchar_t* z_get_rc_name_impl() {
-return L"Windows.Foundation.TypedEventHandler`2<Windows.Graphics.Display.DisplayInformation, Object>"; }
-};
-typedef ITypedEventHandler<ABI::Windows::Graphics::Display::DisplayInformation*,IInspectable*> __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<nsString>* 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<nsString>();
- 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<MetroInput>(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<ABI::Windows::Graphics::Display::IDisplayPropertiesStatics> dispProps;
- if (SUCCEEDED(GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayProperties).Get(), dispProps.GetAddressOf()))) {
- hr = dispProps->add_LogicalDpiChanged(Callback<ABI::Windows::Graphics::Display::IDisplayPropertiesEventHandler, FrameworkView>(
- this, &FrameworkView::OnLogicalDpiChanged).Get(), &mDisplayPropertiesChanged);
- LogHRESULT(hr);
- }
-
- ComPtr<ABI::Windows::UI::ViewManagement::IInputPaneStatics> inputStatic;
- if (SUCCEEDED(hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_ViewManagement_InputPane).Get(), inputStatic.GetAddressOf()))) {
- ComPtr<ABI::Windows::UI::ViewManagement::IInputPane> 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<ABI::Windows::Graphics::Display::IDisplayPropertiesStatics> dispProps;
- if (mDisplayPropertiesChanged.value &&
- SUCCEEDED(GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayProperties).Get(), dispProps.GetAddressOf()))) {
- dispProps->remove_LogicalDpiChanged(mDisplayPropertiesChanged);
- }
-
- ComPtr<ABI::Windows::UI::ViewManagement::IInputPaneStatics> inputStatic;
- if (mSoftKeyboardHidden.value &&
- SUCCEEDED(GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_ViewManagement_InputPane).Get(), inputStatic.GetAddressOf()))) {
- ComPtr<ABI::Windows::UI::ViewManagement::IInputPane> inputPane;
- if (SUCCEEDED(inputStatic->GetForCurrentView(inputPane.GetAddressOf()))) {
- inputPane->remove_Hiding(mSoftKeyboardHidden);
- inputPane->remove_Showing(mSoftKeyboardShown);
- }
- }
-
- if (mAutomationProvider) {
- ComPtr<IUIABridge> 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<ABI::Windows::UI::Core::ICoreCursorFactory> factory;
- AssertHRESULT(GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_Core_CoreCursor).Get(), factory.GetAddressOf()));
- ComPtr<ABI::Windows::UI::Core::ICoreCursor> 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<ABI::Windows::Graphics::Display::IDisplayPropertiesStatics> 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 <windows.system.h>
-#include <Windows.ApplicationModel.core.h>
-#include <Windows.ApplicationModel.h>
-#include <Windows.Applicationmodel.Activation.h>
-#include <Windows.ApplicationModel.search.h>
-#include <windows.ui.core.h>
-#include <windows.ui.viewmanagement.h>
-#include <windows.ui.applicationsettings.h>
-#include <windows.ui.popups.h>
-#include <windows.graphics.printing.h>
-#include <windows.graphics.display.h>
-#include <windows.media.playto.h>
-#include <d2d1_1.h>
-
-namespace mozilla {
-namespace widget {
-namespace winrt {
-
-class MetroApp;
-
-class FrameworkView : public Microsoft::WRL::RuntimeClass<ABI::Windows::ApplicationModel::Core::IFrameworkView>
-{
- 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<ISearchActivatedEventArgs>& aArgs, bool aStartup);
- void FileActivated(Microsoft::WRL::ComPtr<IFileActivatedEventArgs>& aArgs, bool aStartup);
- void LaunchActivated(Microsoft::WRL::ComPtr<ILaunchActivatedEventArgs>& 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<IInspectable> mAutomationProvider;
- //Microsoft::WRL::ComPtr<ID2D1PrintControl> mD2DPrintControl;
- // Private critical section protects D2D device context for on-screen
- // rendering from that for print/preview in the different thread.
- //Microsoft::WRL::ComPtr<IWICImagingFactory2> mWicFactory;
- Microsoft::WRL::ComPtr<MetroApp> mMetroApp;
- Microsoft::WRL::ComPtr<ICoreWindow> mWindow;
- Microsoft::WRL::ComPtr<MetroWidget> mWidget;
- Microsoft::WRL::ComPtr<MetroInput> 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 <shellapi.h>
-
-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<FrameworkView> sFrameworkView;
-ComPtr<MetroApp> sMetroApp;
-ComPtr<ICoreApplication> 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<FrameworkView>(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<ICoreApplicationExit> 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<bool>* 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<MetroApp>();
-
- 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<nsIFile> 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 <windows.system.h>
-#include <windows.ui.core.h>
-#include <Windows.ApplicationModel.core.h>
-#include <Windows.ApplicationModel.h>
-#include <Windows.Applicationmodel.Activation.h>
-
-class MetroWidget;
-
-namespace mozilla {
-namespace widget {
-namespace winrt {
-
-class MetroApp : public Microsoft::WRL::RuntimeClass<ABI::Windows::ApplicationModel::Core::IFrameworkViewSource>
-{
- 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<bool>* 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 <shellapi.h>
-
-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<MetroApp> sMetroApp;
-} } }
-
-namespace mozilla {
-namespace widget {
-// pulled from win32 app shell
-extern UINT sAppShellGoannaMsgId;
-} }
-
-static ComPtr<ICoreWindowStatic> 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<nsIObserverService> 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<IExecuteCommand> 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<IShellItem> 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<IShellItemArray> shellItemArray;
- hr = SHCreateShellItemArrayFromShellItemDynamic(shellItem, IID_IShellItemArray, getter_AddRefs(shellItemArray));
- if (FAILED(hr))
- return hr;
-
- // Set the path to launch and parameters needed
- nsRefPtr<IObjectWithSelection> 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<nsIPowerManagerService> 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<nsIPowerManagerService> 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<WakeLockListener> wakeLock = InitWakeLock();
- mozilla::widget::StartAudioSession();
- sMetroApp->ActivateBaseView();
- rv = nsBaseAppShell::Run();
- mozilla::widget::StopAudioSession();
- ShutdownWakeLock(wakeLock);
- }
-
- nsCOMPtr<nsIAppStartup> 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<ICoreWindow> window;
- AssertHRESULT(sCoreStatic->GetForCurrentThread(window.GetAddressOf()));
- ComPtr<ICoreDispatcher> 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<bool> 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<MetroAppShell *>(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<LPARAM>(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 <windows.h>
-#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 <wrl/wrappers/corewrappers.h>
-#include <shellapi.h>
-#include <DXGIFormat.h>
-#include <d2d1_1.h>
-#include <printpreview.h>
-#include <D3D10.h>
-#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<nsString>* sSettingsArray;
-
-void
-FrameworkView::SearchActivated(ComPtr<ISearchActivatedEventArgs>& 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<IFileActivatedEventArgs>& aArgs, bool aStartup)
-{
- if (!aArgs)
- return;
-
- ComPtr<IVectorView<ABI::Windows::Storage::IStorageItem*>> list;
- AssertHRESULT(aArgs->get_Files(list.GetAddressOf()));
- ComPtr<ABI::Windows::Storage::IStorageItem> 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<ILaunchActivatedEventArgs>& 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<nsICommandLineRunner> 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<char *>(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<IActivatedEventArgs> args(aArgs);
- if (kind == ActivationKind::ActivationKind_Protocol) {
- WinUtils::Log("Activation argument kind: Protocol");
- ComPtr<IProtocolActivatedEventArgs> protoArgs;
- AssertHRESULT(args.As(&protoArgs));
- ComPtr<IUriRuntimeClass> 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<ISearchActivatedEventArgs> searchArgs;
- args.As(&searchArgs);
- SearchActivated(searchArgs, aStartup);
- } else if (kind == ActivationKind::ActivationKind_File) {
- WinUtils::Log("Activation argument kind: File");
- ComPtr<IFileActivatedEventArgs> fileArgs;
- args.As(&fileArgs);
- FileActivated(fileArgs, aStartup);
- } else if (kind == ActivationKind::ActivationKind_Launch) {
- WinUtils::Log("Activation argument kind: Launch");
- ComPtr<ILaunchActivatedEventArgs> 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<IDataTransferManagerStatics> transStatics;
- hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_DataTransfer_DataTransferManager).Get(),
- transStatics.GetAddressOf());
- AssertHRESULT(hr);
- ComPtr<IDataTransferManager> 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<ISearchPaneStatics> searchStatics;
- hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_Search_SearchPane).Get(),
- searchStatics.GetAddressOf());
- AssertHRESULT(hr);
- ComPtr<ISearchPane> 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<IPlayToManagerStatics> playToStatics;
- hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Media_PlayTo_PlayToManager).Get(),
- playToStatics.GetAddressOf());
- AssertHRESULT(hr);
- ComPtr<IPlayToManager> 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<ISettingsPaneStatics> settingsPaneStatics;
- hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_ApplicationSettings_SettingsPane).Get(),
- settingsPaneStatics.GetAddressOf());
- AssertHRESULT(hr);
- ComPtr<ISettingsPane> 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<IPrintManagerStatic> printStatics;
- hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Printing_PrintManager).Get(),
- printStatics.GetAddressOf());
- AssertHRESULT(hr);
- ComPtr<IPrintManager> 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<nsICommandLineRunner> 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<char **>(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<nsICommandLineRunner> 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<char **>(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<IUriRuntimeClass> 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<nsIMetroUIUtils> 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<IDataRequest> request;
- AssertRetHRESULT(hr = aArg->get_Request(request.GetAddressOf()), hr);
- ComPtr<IDataPackage> dataPackage;
- AssertRetHRESULT(hr = request->get_Data(dataPackage.GetAddressOf()), hr);
- ComPtr<IDataPackagePropertySet> 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<IUriRuntimeClass> 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<IHtmlFormatHelperStatics> 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<nsIStringBundleService> bundleService =
- do_GetService(NS_STRINGBUNDLE_CONTRACTID);
- NS_ENSURE_TRUE(bundleService, E_FAIL);
- nsCOMPtr<nsIStringBundle> 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<IPropertyValue> prop;
- AssertRetHRESULT(hr = aCommand->get_Id((IInspectable**)prop.GetAddressOf()), hr);
- AssertRetHRESULT(hr = prop->GetUInt32(&id), hr);
-
- nsCOMPtr<nsIObserverService> 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<ABI::Windows::UI::ApplicationSettings::ISettingsPaneCommandsRequest> request;
- AssertHRESULT(aArgs->get_Request(request.GetAddressOf()));
-
- // ApplicationCommands - vector that holds SettingsCommand to be invoked
- ComPtr<IVector<ABI::Windows::UI::ApplicationSettings::SettingsCommand*>> list;
- AssertHRESULT(request->get_ApplicationCommands(list.GetAddressOf()));
-
- ComPtr<IUICommand> command;
- ComPtr<ISettingsCommandFactory> factory;
- hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_ApplicationSettings_SettingsCommand).Get(),
- factory.GetAddressOf());
- AssertHRESULT(hr);
-
- // Create the IInspectable string property that identifies this command
- ComPtr<IInspectable> prop;
- ComPtr<IPropertyValueStatics> 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<ABI::Windows::UI::Popups::IUICommandInvokedHandler>(
- 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 <d3d10_1.h>
-#include <dxgi.h>
-#include <d3d10misc.h>
-
-/*
- * 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 <windows.ui.core.h> // ABI::Window::UI::Core namespace
-#include <windows.ui.input.h> // 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<UI::Input::IPointerPointProperties> 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<UI::Input::IPointerPointProperties> 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<UI::Input::IPointerPointProperties> 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<Touch>& aData,
- void *aTouchList)
- {
- WidgetTouchEvent::TouchArray* touches =
- static_cast<WidgetTouchEvent::TouchArray*>(aTouchList);
- nsRefPtr<Touch> 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<UI::Input::IPointerPointProperties> 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<void*>(&aEvent->touches));
-}
-
-bool
-MetroInput::ShouldDeliverInputToRecognizer()
-{
- return mRecognizerWantsEvents;
-}
-
-void
-MetroInput::GetAllowedTouchBehavior(WidgetTouchEvent* aTransformedEvent, nsTArray<TouchBehaviorFlags>& 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<UI::Input::IPointerPoint> currentPoint;
- WRL::ComPtr<Devices::Input::IPointerDevice> 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> 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<Foundation::Collections::IVector<UI::Input::PointerPoint*>>
- 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<UI::Input::IPointerPoint> currentPoint;
- WRL::ComPtr<Devices::Input::IPointerDevice> 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> 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<UI::Input::IPointerPoint> currentPoint;
- WRL::ComPtr<Devices::Input::IPointerDevice> 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> 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<UI::Input::IPointerPointProperties> props;
- WRL::ComPtr<Devices::Input::IPointerDevice> 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(&timestamp);
- 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<UI::Input::IPointerPoint> currentPoint;
- WRL::ComPtr<Devices::Input::IPointerDevice> 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<UI::Input::IPointerPoint> currentPoint;
- WRL::ComPtr<Devices::Input::IPointerDevice> 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<nsIRunnable> runnable =
- NS_NewRunnableMethod(this, &MetroInput::DeliverNextQueuedEventIgnoreStatus);
- NS_DispatchToCurrentThread(runnable);
-}
-
-void
-MetroInput::DeliverNextQueuedEventIgnoreStatus()
-{
- nsAutoPtr<WidgetGUIEvent> event =
- static_cast<WidgetGUIEvent*>(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<nsIPresShell> 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<nsIRunnable> 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<uint32_t>& 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<TouchBehaviorFlags> 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<WidgetTouchEvent*>(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> 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<UI::Input::IEdgeGestureStatics> edgeStatics;
- if (SUCCEEDED(Foundation::GetActivationFactory(
- WRL::Wrappers::HStringReference(
- RuntimeClass_Windows_UI_Input_EdgeGesture).Get(),
- edgeStatics.GetAddressOf()))) {
- WRL::ComPtr<UI::Input::IEdgeGesture> 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<UI::Input::IEdgeGestureStatics> edgeStatics;
- Foundation::GetActivationFactory(
- WRL::Wrappers::HStringReference(
- RuntimeClass_Windows_UI_Input_EdgeGesture)
- .Get(),
- edgeStatics.GetAddressOf());
- WRL::ComPtr<UI::Input::IEdgeGesture> edge;
- edgeStatics->GetForCurrentView(edge.GetAddressOf());
-
- edge->add_Starting(
- WRL::Callback<EdgeGestureHandler>(
- this,
- &MetroInput::OnEdgeGestureStarted).Get(),
- &mTokenEdgeStarted);
-
- edge->add_Canceled(
- WRL::Callback<EdgeGestureHandler>(
- this,
- &MetroInput::OnEdgeGestureCanceled).Get(),
- &mTokenEdgeCanceled);
-
- edge->add_Completed(
- WRL::Callback<EdgeGestureHandler>(
- 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<PointerEventHandler>(
- this,
- &MetroInput::OnPointerPressed).Get(),
- &mTokenPointerPressed);
-
- mWindow->add_PointerReleased(
- WRL::Callback<PointerEventHandler>(
- this,
- &MetroInput::OnPointerReleased).Get(),
- &mTokenPointerReleased);
-
- mWindow->add_PointerMoved(
- WRL::Callback<PointerEventHandler>(
- this,
- &MetroInput::OnPointerMoved).Get(),
- &mTokenPointerMoved);
-
- mWindow->add_PointerEntered(
- WRL::Callback<PointerEventHandler>(
- this,
- &MetroInput::OnPointerEntered).Get(),
- &mTokenPointerEntered);
-
- mWindow->add_PointerExited(
- WRL::Callback<PointerEventHandler>(
- this,
- &MetroInput::OnPointerExited).Get(),
- &mTokenPointerExited);
-
- // Register for the events raised by our Gesture Recognizer
- mGestureRecognizer->add_Tapped(
- WRL::Callback<TappedEventHandler>(
- this,
- &MetroInput::OnTapped).Get(),
- &mTokenTapped);
-
- mGestureRecognizer->add_RightTapped(
- WRL::Callback<RightTappedEventHandler>(
- this,
- &MetroInput::OnRightTapped).Get(),
- &mTokenRightTapped);
-
- mGestureRecognizer->add_ManipulationCompleted(
- WRL::Callback<ManipulationCompletedEventHandler>(
- 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 <EventToken.h> // EventRegistrationToken
-#include <stdint.h> // uint32_t
-#include <wrl\client.h> // Microsoft::WRL::ComPtr class
-#include <wrl\implements.h> // 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<IInspectable>,
- 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<ICoreWindow> mWindow;
- Microsoft::WRL::ComPtr<MetroWidget> mWidget;
- Microsoft::WRL::ComPtr<IGestureRecognizer> 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<TouchBehaviorFlags>& 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<nsUint32HashKey,
- nsRefPtr<mozilla::dom::Touch>,
- nsRefPtr<mozilla::dom::Touch> > 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 <windows.h>
-#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 <wrl/wrappers/corewrappers.h>
-#include <windows.ui.applicationsettings.h>
-#include <windows.graphics.display.h>
-#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<IDisplayInformationStatics> dispInfoStatics;
- if (SUCCEEDED(GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayInformation).Get(),
- dispInfoStatics.GetAddressOf()))) {
- ComPtr<IDisplayInformation> dispInfo;
- if (SUCCEEDED(dispInfoStatics->GetForCurrentView(&dispInfo))) {
- FLOAT dpi;
- if (SUCCEEDED(dispInfo->get_LogicalDpi(&dpi))) {
- return (double)dpi / 96.0f;
- }
- }
- }
-
- ComPtr<IDisplayPropertiesStatics> 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<IDisplayInformationStatics> dispInfoStatics;
- if (SUCCEEDED(GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayInformation).Get(),
- dispInfoStatics.GetAddressOf()))) {
- ComPtr<IDisplayInformation> dispInfo;
- if (SUCCEEDED(dispInfoStatics->GetForCurrentView(&dispInfo))) {
- ResolutionScale scale;
- if (SUCCEEDED(dispInfo->get_ResolutionScale(&scale))) {
- return (double)scale / 100.0;
- }
- }
- }
-
- ComPtr<IDisplayPropertiesStatics> 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<nsIObserverService> observerService =
- mozilla::services::GetObserverService();
- if (observerService) {
- return observerService->NotifyObservers(nullptr, aMessage, aData);
- }
- return NS_ERROR_FAILURE;
-}
-
-HRESULT MetroUtils::CreateUri(HSTRING aUriStr, ComPtr<IUriRuntimeClass>& aUriOut)
-{
- HRESULT hr;
- ComPtr<IUriRuntimeClassFactory> uriFactory;
- hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Foundation_Uri).Get(), &uriFactory);
- AssertRetHRESULT(hr, hr);
- ComPtr<IUriRuntimeClass> uri;
- return uriFactory->CreateUri(aUriStr, &aUriOut);
-}
-
-HRESULT MetroUtils::CreateUri(HString& aHString, ComPtr<IUriRuntimeClass>& aUriOut)
-{
- return MetroUtils::CreateUri(aHString.Get(), aUriOut);
-}
-
-HRESULT
-MetroUtils::GetViewState(ApplicationViewState& aState)
-{
- HRESULT hr;
- ComPtr<IApplicationViewStatics> 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<IApplicationViewStatics> 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<ISettingsPaneStatics> 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 <stdio.h>
-#include <windows.foundation.h>
-#include <windows.ui.viewmanagement.h>
-
-// 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<unsigned int size, typename T>
-HRESULT ActivateGenericInstance(wchar_t const (&RuntimeClassName)[size], Microsoft::WRL::ComPtr<T>& aOutObject) {
- Microsoft::WRL::ComPtr<IActivationFactory> factory;
- HRESULT hr = ABI::Windows::Foundation::GetActivationFactory(Microsoft::WRL::Wrappers::HStringReference(RuntimeClassName).Get(),
- factory.GetAddressOf());
- if (FAILED(hr))
- return hr;
- Microsoft::WRL::ComPtr<IInspectable> 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<IUriRuntimeClass>& aUriOut);
- static HRESULT CreateUri(HString& aHString, Microsoft::WRL::ComPtr<IUriRuntimeClass>& aUriOut);
- static HRESULT GetViewState(ApplicationViewState& aState);
- static HRESULT TryUnsnap(bool* aResult = nullptr);
- static HRESULT ShowSettingsFlyout();
-
-private:
- static nsresult GetBrowserDOMWindow(nsCOMPtr<nsIBrowserDOMWindow> &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 <windows.devices.input.h>
-#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<MetroApp> sMetroApp;
-extern ComPtr<IUIABridge> 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<KeyPair,32> 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<nsIWidget> kungFuDeathGrip(this);
-
- if (ShouldUseAPZC()) {
- nsresult rv;
- nsCOMPtr<nsIObserverService> 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<IPointerDeviceStatics> deviceStatics;
-
- HRESULT hr = GetActivationFactory(
- HStringReference(RuntimeClass_Windows_Devices_Input_PointerDevice).Get(),
- deviceStatics.GetAddressOf());
-
- if (FAILED(hr)) {
- return 0;
- }
-
- ComPtr< IVectorView<PointerDevice*> > 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<IPointerDevice> 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<LPDROPTARGET>(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<int32_t>(aDeltaY) : static_cast<int32_t>(aDeltaX),
- aModifierFlags, aAdditionalFlags);
-}
-
-static void
-CloseGesture()
-{
- LogFunction();
- nsCOMPtr<nsIAppStartup> 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<WidgetGUIEvent*>(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<WidgetGUIEvent*>(cmdEvent);
- }
- break;
- default:
- MOZ_CRASH("unknown event in DispatchScrollEvent");
- break;
- }
- mEventQueue.Push(newEvent);
- nsCOMPtr<nsIRunnable> runnable =
- NS_NewRunnableMethod(this, &MetroWidget::DeliverNextScrollEvent);
- NS_DispatchToCurrentThread(runnable);
- return false;
-}
-
-void
-MetroWidget::DeliverNextScrollEvent()
-{
- WidgetGUIEvent* event =
- static_cast<WidgetInputEvent*>(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<nsIRunnable> 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<WidgetKeyboardEvent*>(aObject);
- if (event->mUniqueId == mId) {
- event->mFlags.mPropagationStopped = true;
- }
- return nullptr;
- }
-protected:
- uint32_t mId;
-};
-
-void
-MetroWidget::DeliverNextKeyboardEvent()
-{
- WidgetKeyboardEvent* event =
- static_cast<WidgetKeyboardEvent*>(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<MetroWidget*>(
- 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<nsIAppStartup> 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<HKL>(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<IRawElementProviderSimple> 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<WNDPROC>(
- GetWindowLongPtr(mWnd, GWLP_WNDPROC));
- if (wndProc != StaticWindowProcedure) {
- if (!SetPropW(mWnd, kMetroSubclassThisProp, this)) {
- NS_NOTREACHED("SetProp failed, can't continue.");
- return;
- }
- mMetroWndProc =
- reinterpret_cast<WNDPROC>(
- SetWindowLongPtr(mWnd, GWLP_WNDPROC,
- reinterpret_cast<LONG_PTR>(StaticWindowProcedure)));
- NS_ASSERTION(mMetroWndProc != StaticWindowProcedure, "WTF?");
- }
-}
-
-void
-MetroWidget::RemoveSubclass()
-{
- if (!mWnd)
- return;
- WNDPROC wndProc = reinterpret_cast<WNDPROC>(
- GetWindowLongPtr(mWnd, GWLP_WNDPROC));
- if (wndProc == StaticWindowProcedure) {
- NS_ASSERTION(mMetroWndProc, "Should have old proc here.");
- SetWindowLongPtr(mWnd, GWLP_WNDPROC,
- reinterpret_cast<LONG_PTR>(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<nsIObserverService> 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<GoannaContentController>
-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<TouchBehaviorFlags>& aOutBehaviors)
-{
- LogFunction();
- return APZController::sAPZC->GetAllowedTouchBehavior(aTransformedEvent, aOutBehaviors);
-}
-
-void
-MetroWidget::ApzcSetAllowedTouchBehavior(uint64_t aInputBlockId,
- nsTArray<TouchBehaviorFlags>& 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<nsIPresShell>
-MetroWidget::GetPresShell()
-{
- if (mWidgetListener) {
- nsCOMPtr<nsIPresShell> 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<Configuration>& 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<IUnknown*>(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 <windows.system.h>
-#include <windows.ui.core.h>
-#include <Windows.ApplicationModel.core.h>
-#include <Windows.ApplicationModel.h>
-#include <Windows.Applicationmodel.Activation.h>
-
-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<mozilla::layers::LayersBackend>& 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<Configuration>& aConfigurations);
- virtual void* GetNativeData(uint32_t aDataType);
- virtual void FreeNativeData(void * data, uint32_t aDataType);
- virtual mozilla::LayoutDeviceIntPoint WidgetToScreenOffset();
-
- already_AddRefed<nsIPresShell> 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<nsITaskbarWindowPreview> 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<TouchBehaviorFlags>& aOutBehaviors);
- void ApzcSetAllowedTouchBehavior(uint64_t aInputBlockId, nsTArray<TouchBehaviorFlags>& 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<GoannaContentController> 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<FrameworkView> mView;
- nsTransparencyMode mTransparencyMode;
- nsIntRegion mInvalidatedRegion;
- nsCOMPtr<nsIIdleServiceInternal> mIdleService;
- HWND mWnd;
- static HWND sICoreHwnd;
- WNDPROC mMetroWndProc;
- bool mTempBasicLayerInUse;
- uint64_t mRootLayerTreeId;
- nsDeque mEventQueue;
- nsDeque mKeyEventQueue;
- nsRefPtr<APZController> mController;
- nsRefPtr<nsNativeDragTarget> 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<IXmlDocument> toastXml =
- InitializeXmlForTemplate(ToastTemplateType::ToastTemplateType_ToastImageAndText03);
- Microsoft::WRL::ComPtr<IXmlNodeList> toastTextElements, toastImageElements;
- Microsoft::WRL::ComPtr<IXmlNode> 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<IXmlNamedNodeMap> 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<IXmlDocument> toastXml =
- InitializeXmlForTemplate(ToastTemplateType::ToastTemplateType_ToastText03);
- Microsoft::WRL::ComPtr<IXmlNodeList> toastTextElements;
- Microsoft::WRL::ComPtr<IXmlNode> 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<IXmlDocument>
-ToastNotificationHandler::InitializeXmlForTemplate(ToastTemplateType templateType) {
- Microsoft::WRL::ComPtr<IXmlDocument> 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<IToastNotification> notification;
- Microsoft::WRL::ComPtr<IToastNotificationFactory> factory;
- AssertRetHRESULT(GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_Notifications_ToastNotification).Get(),
- factory.GetAddressOf()), false);
- AssertRetHRESULT(factory->CreateToastNotification(toastXml, &notification),
- false);
-
- EventRegistrationToken activatedToken;
- AssertRetHRESULT(notification->add_Activated(Callback<ToastActivationHandler>(this,
- &ToastNotificationHandler::OnActivate).Get(), &activatedToken), false);
- EventRegistrationToken dismissedToken;
- AssertRetHRESULT(notification->add_Dismissed(Callback<ToastDismissHandler>(this,
- &ToastNotificationHandler::OnDismiss).Get(), &dismissedToken), false);
-
- Microsoft::WRL::ComPtr<IToastNotifier> notifier;
- if (aAppId.IsEmpty()) {
- AssertRetHRESULT(mToastNotificationManagerStatics->CreateToastNotifier(
- &notifier), false);
- } else {
- AssertRetHRESULT(mToastNotificationManagerStatics->CreateToastNotifierWithId(
- HStringReference(PromiseFlatString(aAppId).get()).Get(),
- &notifier), 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<IXmlNode> node, Microsoft::WRL::ComPtr<IXmlDocument> xml) {
- Microsoft::WRL::ComPtr<IXmlText> inputText;
- Microsoft::WRL::ComPtr<IXmlNode> 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 <windows.ui.notifications.h>
-#include <windows.data.xml.dom.h>
-#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<IXmlNode> node,
- Microsoft::WRL::ComPtr<IXmlDocument> 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<IToastNotificationManagerStatics> mToastNotificationManagerStatics;
-
- bool CreateWindowsNotificationFromXml(IXmlDocument *toastXml,
- const nsAString& aAppId);
- Microsoft::WRL::ComPtr<IXmlDocument> 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 <OAIdl.h>
-
-#include "nsIAccessibleEvent.h"
-#include "nsIPersistentProperties2.h"
-
-// generated
-#include "UIABridge.h"
-
-#include <wrl/implements.h>
-
-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<nsIAccessibleEvent> ev = do_QueryInterface(aSubject);
- if (!ev) {
- return NS_OK;
- }
-
- uint32_t eventType = 0;
- ev->GetEventType(&eventType);
- if (eventType == nsIAccessibleEvent::EVENT_FOCUS) {
- Microsoft::WRL::ComPtr<IUIABridge> 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<nsIObserverService> 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<nsIObserverService> 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<mozilla::a11y::Accessible> mAccess;
- Microsoft::WRL::ComPtr<IUnknown> 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 <wrl.h>
-#include <OAIdl.h>
-#include <windows.graphics.display.h>
-
-#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<IUIABridge> gProviderRoot = nullptr;
-static ComPtr<IUIAElement> gElement = nullptr;
-
-HRESULT
-UIABridge_CreateInstance(IInspectable **retVal)
-{
- HRESULT hr = E_OUTOFMEMORY;
- *retVal = nullptr;
- ComPtr<UIABridge> spProvider = Make<UIABridge>();
- 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<UIATextElement> spProvider = Make<UIATextElement>();
- 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<Accessible>& 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<Accessible>& 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<Accessible> child = mAccessible->FocusedChild();
- if (!child) {
- return S_OK;
- }
-
- if (!ChildHasFocus(child)) {
- ComPtr<IUIAElement> 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<Accessible> child = mAccessible->FocusedChild();
- if (!child) {
- BridgeLog("mAccessible->GetFocusedChild failed.");
- return S_OK;
- }
-
- DumpChildInfo(child);
-
- ComPtr<IUIAElement> 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<ITextProvider*>(this);
- AddRef();
- return S_OK;
- } else if (patternId == UIA_ValuePatternId) {
- BridgeLog("** ValuePattern requested from element.");
- *ppRetVal = static_cast<IValueProvider*>(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 <windows.system.h>
-#include <windows.ui.core.h>
-#include <UIAutomation.h>
-#include <UIAutomationCore.h>
-#include <UIAutomationCoreApi.h>
-
-#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<Microsoft::WRL::RuntimeClassFlags
- <Microsoft::WRL::RuntimeClassType::WinRtClassicComMix>,
- 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<ICoreWindow> mWindow;
-#if defined(ACCESSIBILITY)
- nsRefPtr<AccessibilityBridge> mAccBridge;
- nsRefPtr<mozilla::a11y::Accessible> mAccessible;
-#endif
-};
-
-[uuid("4438135F-F624-43DE-A417-275CE7A1A0CD")]
-class UIATextElement : public Microsoft::WRL::RuntimeClass<Microsoft::WRL::RuntimeClassFlags
- <Microsoft::WRL::RuntimeClassType::WinRtClassicComMix>,
- 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<a11y::Accessible> 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 <windows.system.h>
-#include <windows.ui.core.h>
-#include <UIAutomation.h>
-
-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 <windows.system.display.h>
-
-/*
- * 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<ABI::Windows::System::Display::IDisplayRequest> 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 <wrl.h> 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 <windows.h>
-
-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 <wrl.h>
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 <windows.ui.viewmanagement.h>
-#include <windows.storage.search.h>
-
-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<StorageFile*>* aFile,
- AsyncStatus aStatus)
-{
- if (aStatus != ABI::Windows::Foundation::AsyncStatus::Completed) {
- if (mCallback)
- mCallback->Done(nsIFilePicker::returnCancel);
- return S_OK;
- }
-
- HRESULT hr;
- ComPtr<IStorageFile> 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<IStorageItem> 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<IVectorView<StorageFile*>*>* aFileList,
- AsyncStatus aStatus)
-{
- if (aStatus != ABI::Windows::Foundation::AsyncStatus::Completed) {
- if (mCallback)
- mCallback->Done(nsIFilePicker::returnCancel);
- return S_OK;
- }
-
- HRESULT hr;
- ComPtr<IVectorView<StorageFile*>> 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<IStorageFile> file;
- hr = view->GetAt(idx, file.GetAddressOf());
- if (FAILED(hr)) {
- continue;
- }
-
- ComPtr<IStorageItem> storageItem;
- hr = file.As(&storageItem);
- if (FAILED(hr)) {
- continue;
- }
-
- HSTRING path;
- if (SUCCEEDED(storageItem->get_Path(&path))) {
- nsCOMPtr<nsILocalFile> 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<IAsyncOperation<StorageFile*>> asyncOperation;
- hr = mFileOpenPicker->PickSingleFileAsync(asyncOperation.GetAddressOf());
- AssertRetHRESULT(hr, NS_ERROR_FAILURE);
-
- // Subscribe to the completed event
- ComPtr<IAsyncOperationCompletedHandler<StorageFile*>>
- completedHandler(Callback<IAsyncOperationCompletedHandler<StorageFile*>>(
- 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<StorageFile*> StorageTemplate;
- typedef IAsyncOperation<StorageTemplate*> AsyncCallbackTemplate;
- typedef IAsyncOperationCompletedHandler<StorageTemplate*> HandlerTemplate;
-
- // Initiate the file picker operation
- ComPtr<AsyncCallbackTemplate> asyncOperation;
- hr = mFileOpenPicker->PickMultipleFilesAsync(asyncOperation.GetAddressOf());
- AssertRetHRESULT(hr, NS_ERROR_FAILURE);
-
- // Subscribe to the completed event
- ComPtr<HandlerTemplate> completedHandler(Callback<HandlerTemplate>(
- 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<IMap<HSTRING, IVector<HSTRING>*>> map;
- mFileSavePicker->get_FileTypeChoices(map.GetAddressOf());
- if (map) {
- boolean found = false;
- unsigned int index;
- map->HasKey(mFirstTitle.Get(), &found);
- if (found) {
- ComPtr<IVector<HSTRING>> 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<IAsyncOperation<StorageFile*>> asyncOperation;
- hr = mFileSavePicker->PickSaveFileAsync(asyncOperation.GetAddressOf());
- AssertRetHRESULT(hr, NS_ERROR_FAILURE);
-
- // Subscribe to the completed event
- ComPtr<IAsyncOperationCompletedHandler<StorageFile*>>
- completedHandler(Callback<IAsyncOperationCompletedHandler<StorageFile*>>(
- 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<nsILocalFile> 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<nsIFile> 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<IVector<HSTRING>> {
- 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<HSTRING> **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<HSTRING> mList;
-};
-
-nsresult
-nsMetroFilePicker::ParseFiltersIntoVector(ComPtr<IVector<HSTRING>>& 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<IVector<HSTRING>> 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<IMap<HSTRING,IVector<HSTRING>*>> map;
- hr = mFileSavePicker->get_FileTypeChoices(map.GetAddressOf());
- AssertRetHRESULT(hr, NS_ERROR_FAILURE);
-
- HString key;
- key.Set(aTitle.BeginReading());
-
- ComPtr<IVector<HSTRING>> saveTypes;
- saveTypes = Make<MozHStringVector>();
- 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 <windows.system.h>
-#include <windows.ui.core.h>
-#include <windows.foundation.h>
-#include <windows.storage.pickers.h>
-#include <windows.storage.fileproperties.h>
-
-/**
- * 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<StorageFile*>* aFile, AsyncStatus aStatus);
- HRESULT OnPickMultipleFiles(ABI::Windows::Foundation::IAsyncOperation<ABI::Windows::Foundation::Collections::IVectorView<StorageFile*>*>* aFileList, AsyncStatus aStatus);
-
-private:
- void InitNative(nsIWidget*, const nsAString&) {};
- nsresult ParseFiltersIntoVector(Microsoft::WRL::ComPtr<ABI::Windows::Foundation::Collections::IVector<HSTRING>>& aVector,
- const nsAString& aFilter,
- bool aAllowAll);
- nsCOMArray<nsILocalFile> mFiles;
- Microsoft::WRL::ComPtr<ABI::Windows::Storage::Pickers::IFileOpenPicker> mFileOpenPicker;
- Microsoft::WRL::ComPtr<ABI::Windows::Storage::Pickers::IFileSavePicker> mFileSavePicker;
- HString mFilePath;
- HString mFirstTitle;
- nsRefPtr<nsIFilePickerShownCallback> 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 <shldisp.h>
-#include <shellapi.h>
-#include <windows.ui.viewmanagement.h>
-#include <windows.ui.startscreen.h>
-
-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<MetroApp> sMetroApp;
-extern nsTArray<nsString>* 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<IUriRuntimeClass> 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<ISecondaryTileFactory> tileFactory;
- ComPtr<ISecondaryTile> 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<IAsyncOperationCompletedHandler<bool>> callback(Callback<IAsyncOperationCompletedHandler<bool>>(
- sMetroApp.Get(), &MetroApp::OnAsyncTileCreated));
- ComPtr<IAsyncOperation<bool>> 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<ISecondaryTileFactory> tileFactory;
- ComPtr<ISecondaryTile> 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<IAsyncOperationCompletedHandler<bool>> callback(Callback<IAsyncOperationCompletedHandler<bool>>(
- sMetroApp.Get(), &MetroApp::OnAsyncTileCreated));
- ComPtr<IAsyncOperation<bool>> 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<ISecondaryTileStatics> 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<uint32_t>(floor(FrameworkView::KeyboardVisibleRect().X));
- return NS_OK;
-}
-
-NS_IMETHODIMP
-nsWinMetroUtils::GetKeyboardY(uint32_t *aY)
-{
- *aY = static_cast<uint32_t>(floor(FrameworkView::KeyboardVisibleRect().Y));
- return NS_OK;
-}
-
-NS_IMETHODIMP
-nsWinMetroUtils::GetKeyboardWidth(uint32_t *aWidth)
-{
- *aWidth = static_cast<uint32_t>(ceil(FrameworkView::KeyboardVisibleRect().Width));
- return NS_OK;
-}
-
-NS_IMETHODIMP
-nsWinMetroUtils::GetKeyboardHeight(uint32_t *aHeight)
-{
- *aHeight = static_cast<uint32_t>(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<nsIWindowsRegKey> 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
diff --git a/xpcom/base/ErrorList.h b/xpcom/base/ErrorList.h
index 5eef3550c..8d16d6ac9 100644
--- a/xpcom/base/ErrorList.h
+++ b/xpcom/base/ErrorList.h
@@ -908,7 +908,6 @@
* the application should be restarted. This condition corresponds to the
* case in which nsIAppStartup::Quit was called with the eRestart flag. */
ERROR(NS_SUCCESS_RESTART_APP, SUCCESS(1)),
- ERROR(NS_SUCCESS_RESTART_METRO_APP, SUCCESS(2)),
ERROR(NS_SUCCESS_RESTART_APP_NOT_SAME_PROFILE, SUCCESS(3)),
ERROR(NS_SUCCESS_UNORM_NOTFOUND, SUCCESS(17)),
diff --git a/xpcom/base/nsDebugImpl.cpp b/xpcom/base/nsDebugImpl.cpp
index c15f8bcea..c9494c9a6 100644
--- a/xpcom/base/nsDebugImpl.cpp
+++ b/xpcom/base/nsDebugImpl.cpp
@@ -38,9 +38,6 @@
#if defined(XP_WIN)
#include <tchar.h>
#include "nsString.h"
-#ifdef MOZ_METRO
-#include "nsWindowsHelpers.h"
-#endif
#endif
#if defined(XP_MACOSX) || defined(__DragonFly__) || defined(__FreeBSD__) \
diff --git a/xpcom/base/nsSystemInfo.cpp b/xpcom/base/nsSystemInfo.cpp
index 6d3124c5f..fcb0bd2d7 100644
--- a/xpcom/base/nsSystemInfo.cpp
+++ b/xpcom/base/nsSystemInfo.cpp
@@ -194,22 +194,9 @@ nsSystemInfo::Init()
}
}
-#if defined(XP_WIN) && defined(MOZ_METRO)
- // Create "hasWindowsTouchInterface" property.
- nsAutoString version;
- rv = GetPropertyAsAString(NS_LITERAL_STRING("version"), version);
- NS_ENSURE_SUCCESS(rv, rv);
- double versionDouble = version.ToDouble(&rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = SetPropertyAsBool(NS_ConvertASCIItoUTF16("hasWindowsTouchInterface"),
- versionDouble >= 6.2);
- NS_ENSURE_SUCCESS(rv, rv);
-#else
rv = SetPropertyAsBool(NS_ConvertASCIItoUTF16("hasWindowsTouchInterface"),
false);
NS_ENSURE_SUCCESS(rv, rv);
-#endif
// Additional informations not available through PR_GetSystemInfo.
SetInt32Property(NS_LITERAL_STRING("pagesize"), PR_GetPageSize());
diff --git a/xpcom/base/nsWindowsHelpers.h b/xpcom/base/nsWindowsHelpers.h
index 5f611aa37..f12c23e6a 100644
--- a/xpcom/base/nsWindowsHelpers.h
+++ b/xpcom/base/nsWindowsHelpers.h
@@ -127,36 +127,6 @@ typedef nsAutoRef<HMODULE> nsModuleHandle;
namespace {
-bool inline
-IsRunningInWindowsMetro()
-{
- static bool alreadyChecked = false;
- static bool isMetro = false;
- if (alreadyChecked) {
- return isMetro;
- }
-
- HMODULE user32DLL = LoadLibraryW(L"user32.dll");
- if (!user32DLL) {
- return false;
- }
-
- typedef BOOL (WINAPI* IsImmersiveProcessFunc)(HANDLE aProcess);
- IsImmersiveProcessFunc IsImmersiveProcessPtr =
- (IsImmersiveProcessFunc)GetProcAddress(user32DLL,
- "IsImmersiveProcess");
- FreeLibrary(user32DLL);
- if (!IsImmersiveProcessPtr) {
- // isMetro is already set to false.
- alreadyChecked = true;
- return false;
- }
-
- isMetro = IsImmersiveProcessPtr(GetCurrentProcess());
- alreadyChecked = true;
- return isMetro;
-}
-
HMODULE inline
LoadLibrarySystem32(LPCWSTR aModule)
{
diff --git a/xpcom/build/IOInterposer.cpp b/xpcom/build/IOInterposer.cpp
index e7feba2e6..08d612dbf 100644
--- a/xpcom/build/IOInterposer.cpp
+++ b/xpcom/build/IOInterposer.cpp
@@ -426,12 +426,7 @@ IOInterposer::Init()
if (!sThreadLocalData.init()) {
return false;
}
-#if defined(XP_WIN)
- bool isMainThread =
- XRE_GetWindowsEnvironment() != WindowsEnvironmentType_Metro;
-#else
bool isMainThread = true;
-#endif
RegisterCurrentThread(isMainThread);
sMasterList = new MasterList();
diff --git a/xpcom/build/nsXULAppAPI.h b/xpcom/build/nsXULAppAPI.h
index 0cc00becf..9c8b06214 100644
--- a/xpcom/build/nsXULAppAPI.h
+++ b/xpcom/build/nsXULAppAPI.h
@@ -142,14 +142,6 @@
#define XRE_OS_UPDATE_APPLY_TO_DIR "OSUpdApplyToD"
/**
- * Platform flag values for XRE_main.
- *
- * XRE_MAIN_FLAG_USE_METRO - On Windows, use the winrt backend. Defaults
- * to win32 backend.
- */
-#define XRE_MAIN_FLAG_USE_METRO 0x01
-
-/**
* Begin an XUL application. Does not return until the user exits the
* application.
*
@@ -450,24 +442,6 @@ XRE_API(void,
XRE_API(void,
XRE_StopLateWriteChecks, (void))
-#ifdef XP_WIN
-/**
- * Valid environment types for XRE_GetWindowsEnvironment.
- */
-enum WindowsEnvironmentType
-{
- WindowsEnvironmentType_Desktop = 0,
- WindowsEnvironmentType_Metro = 1
-};
-
-/**
- * Retrieve the Windows desktop environment libXUL is running
- * under. Valid after a call to XRE_main.
- */
-XRE_API(WindowsEnvironmentType,
- XRE_GetWindowsEnvironment, ())
-#endif // XP_WIN
-
#ifdef MOZ_B2G_LOADER
XRE_API(int,
XRE_ProcLoaderServiceRun, (pid_t, int, int argc, const char* argv[],
diff --git a/xpcom/io/nsAppDirectoryServiceDefs.h b/xpcom/io/nsAppDirectoryServiceDefs.h
index 5bc87de83..38e02fab4 100644
--- a/xpcom/io/nsAppDirectoryServiceDefs.h
+++ b/xpcom/io/nsAppDirectoryServiceDefs.h
@@ -63,7 +63,6 @@
#define NS_APP_PREFS_50_DIR "PrefD" // Directory which contains user prefs
#define NS_APP_PREFS_50_FILE "PrefF"
-#define NS_METRO_APP_PREFS_50_FILE "MetroPrefF" // Metro browser prefs file
#define NS_APP_PREFS_DEFAULTS_DIR_LIST "PrefDL"
#define NS_EXT_PREFS_DEFAULTS_DIR_LIST "ExtPrefDL"
#define NS_APP_PREFS_OVERRIDE_DIR "PrefDOverride" // Directory for per-profile defaults
diff --git a/xpcom/io/nsLocalFileWin.cpp b/xpcom/io/nsLocalFileWin.cpp
index f02220fda..ee11a56a0 100644
--- a/xpcom/io/nsLocalFileWin.cpp
+++ b/xpcom/io/nsLocalFileWin.cpp
@@ -212,9 +212,6 @@ private:
SHELLEXECUTEINFOW seinfo;
memset(&seinfo, 0, sizeof(seinfo));
seinfo.cbSize = sizeof(SHELLEXECUTEINFOW);
- if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) {
- seinfo.fMask = SEE_MASK_FLAG_LOG_USAGE;
- }
seinfo.hwnd = nullptr;
seinfo.lpVerb = nullptr;
seinfo.lpFile = mResolvedPath.get();