summaryrefslogtreecommitdiffstats
path: root/widget/windows
diff options
context:
space:
mode:
Diffstat (limited to 'widget/windows')
-rw-r--r--widget/windows/GfxInfo.cpp179
-rw-r--r--widget/windows/KeyboardLayout.cpp179
-rw-r--r--widget/windows/KeyboardLayout.h5
-rw-r--r--widget/windows/LSPAnnotator.cpp161
-rw-r--r--widget/windows/TSFTextStore.cpp3
-rw-r--r--widget/windows/TaskbarPreview.cpp2
-rw-r--r--widget/windows/WinMouseScrollHandler.cpp7
-rw-r--r--widget/windows/WinTaskbar.cpp52
-rw-r--r--widget/windows/WinUtils.cpp59
-rw-r--r--widget/windows/WindowsUIUtils.cpp4
-rw-r--r--widget/windows/moz.build5
-rw-r--r--widget/windows/mozwrlbase.h77
-rw-r--r--widget/windows/nsAppShell.cpp4
-rw-r--r--widget/windows/nsClipboard.cpp2
-rw-r--r--widget/windows/nsDataObj.cpp102
-rw-r--r--widget/windows/nsDataObj.h1
-rw-r--r--widget/windows/nsFilePicker.cpp542
-rw-r--r--widget/windows/nsFilePicker.h37
-rw-r--r--widget/windows/nsLookAndFeel.cpp117
-rw-r--r--widget/windows/nsLookAndFeel.h40
-rw-r--r--widget/windows/nsNativeThemeWin.cpp463
-rw-r--r--widget/windows/nsNativeThemeWin.h3
-rw-r--r--widget/windows/nsUXThemeConstants.h2
-rw-r--r--widget/windows/nsUXThemeData.cpp8
-rw-r--r--widget/windows/nsWinGesture.h155
-rw-r--r--widget/windows/nsWindow.cpp115
-rw-r--r--widget/windows/nsWindow.h3
27 files changed, 446 insertions, 1881 deletions
diff --git a/widget/windows/GfxInfo.cpp b/widget/windows/GfxInfo.cpp
index 0cbd323de..8a429ad32 100644
--- a/widget/windows/GfxInfo.cpp
+++ b/widget/windows/GfxInfo.cpp
@@ -21,12 +21,6 @@
#include "nsPrintfCString.h"
#include "jsapi.h"
-#if defined(MOZ_CRASHREPORTER)
-#include "nsExceptionHandler.h"
-#include "nsICrashReporter.h"
-#define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1"
-#endif
-
using namespace mozilla;
using namespace mozilla::gfx;
using namespace mozilla::widget;
@@ -241,9 +235,6 @@ ParseIDFromDeviceID(const nsAString &key, const char *prefix, int length)
// based on http://msdn.microsoft.com/en-us/library/ms724834(VS.85).aspx
enum {
kWindowsUnknown = 0,
- kWindowsXP = 0x50001,
- kWindowsServer2003 = 0x50002,
- kWindowsVista = 0x60000,
kWindows7 = 0x60001,
kWindows8 = 0x60002,
kWindows8_1 = 0x60003,
@@ -724,114 +715,16 @@ GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active)
return NS_OK;
}
-#if defined(MOZ_CRASHREPORTER)
-/* Cisco's VPN software can cause corruption of the floating point state.
- * Make a note of this in our crash reports so that some weird crashes
- * make more sense */
-static void
-CheckForCiscoVPN() {
- LONG result;
- HKEY key;
- /* This will give false positives, but hopefully no false negatives */
- result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Cisco Systems\\VPN Client", 0, KEY_QUERY_VALUE, &key);
- if (result == ERROR_SUCCESS) {
- RegCloseKey(key);
- CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("Cisco VPN\n"));
- }
-}
-#endif
-
void
GfxInfo::AddCrashReportAnnotations()
{
-#if defined(MOZ_CRASHREPORTER)
- CheckForCiscoVPN();
-
- if (mHasDriverVersionMismatch) {
- CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("DriverVersionMismatch\n"));
- }
-
- nsString deviceID, vendorID, driverVersion, subsysID;
- nsCString narrowDeviceID, narrowVendorID, narrowDriverVersion, narrowSubsysID;
-
- GetAdapterDeviceID(deviceID);
- CopyUTF16toUTF8(deviceID, narrowDeviceID);
- GetAdapterVendorID(vendorID);
- CopyUTF16toUTF8(vendorID, narrowVendorID);
- GetAdapterDriverVersion(driverVersion);
- CopyUTF16toUTF8(driverVersion, narrowDriverVersion);
- GetAdapterSubsysID(subsysID);
- CopyUTF16toUTF8(subsysID, narrowSubsysID);
-
- CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterVendorID"),
- narrowVendorID);
- CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDeviceID"),
- narrowDeviceID);
- CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDriverVersion"),
- narrowDriverVersion);
- CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterSubsysID"),
- narrowSubsysID);
-
- /* Add an App Note for now so that we get the data immediately. These
- * can go away after we store the above in the socorro db */
- nsAutoCString note;
- /* AppendPrintf only supports 32 character strings, mrghh. */
- note.AppendLiteral("AdapterVendorID: ");
- note.Append(narrowVendorID);
- note.AppendLiteral(", AdapterDeviceID: ");
- note.Append(narrowDeviceID);
- note.AppendLiteral(", AdapterSubsysID: ");
- note.Append(narrowSubsysID);
- note.AppendLiteral(", AdapterDriverVersion: ");
- note.Append(NS_LossyConvertUTF16toASCII(driverVersion));
-
- if (vendorID == GfxDriverInfo::GetDeviceVendor(VendorAll)) {
- /* if we didn't find a valid vendorID lets append the mDeviceID string to try to find out why */
- note.AppendLiteral(", ");
- LossyAppendUTF16toASCII(mDeviceID, note);
- note.AppendLiteral(", ");
- LossyAppendUTF16toASCII(mDeviceKeyDebug, note);
- LossyAppendUTF16toASCII(mDeviceKeyDebug, note);
- }
- note.Append("\n");
-
- if (mHasDualGPU) {
- nsString deviceID2, vendorID2, subsysID2;
- nsAutoString adapterDriverVersionString2;
- nsCString narrowDeviceID2, narrowVendorID2, narrowSubsysID2;
-
- note.AppendLiteral("Has dual GPUs. GPU #2: ");
- GetAdapterDeviceID2(deviceID2);
- CopyUTF16toUTF8(deviceID2, narrowDeviceID2);
- GetAdapterVendorID2(vendorID2);
- CopyUTF16toUTF8(vendorID2, narrowVendorID2);
- GetAdapterDriverVersion2(adapterDriverVersionString2);
- GetAdapterSubsysID(subsysID2);
- CopyUTF16toUTF8(subsysID2, narrowSubsysID2);
- note.AppendLiteral("AdapterVendorID2: ");
- note.Append(narrowVendorID2);
- note.AppendLiteral(", AdapterDeviceID2: ");
- note.Append(narrowDeviceID2);
- note.AppendLiteral(", AdapterSubsysID2: ");
- note.Append(narrowSubsysID2);
- note.AppendLiteral(", AdapterDriverVersion2: ");
- note.Append(NS_LossyConvertUTF16toASCII(adapterDriverVersionString2));
- }
- CrashReporter::AppendAppNotesToCrashReport(note);
-
-#endif
+ /*** STUB ***/
}
static OperatingSystem
WindowsVersionToOperatingSystem(int32_t aWindowsVersion)
{
switch(aWindowsVersion) {
- case kWindowsXP:
- return OperatingSystem::WindowsXP;
- case kWindowsServer2003:
- return OperatingSystem::WindowsServer2003;
- case kWindowsVista:
- return OperatingSystem::WindowsVista;
case kWindows7:
return OperatingSystem::Windows7;
case kWindows8:
@@ -860,11 +753,6 @@ GfxInfo::GetGfxDriverInfo()
/*
* NVIDIA entries
*/
- APPEND_TO_DRIVER_BLOCKLIST(OperatingSystem::WindowsXP,
- (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), GfxDriverInfo::allDevices,
- GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
- DRIVER_LESS_THAN_OR_EQUAL, V(6,14,11,8745), "FEATURE_FAILURE_NV_XP", "nVidia driver > 187.45" );
-
/*
* The last 5 digit of the NVIDIA driver version maps to the version that
* NVIDIA uses. The minor version (15, 16, 17) corresponds roughtly to the
@@ -875,33 +763,17 @@ GfxInfo::GetGfxDriverInfo()
* 187.45 (late October 2009) and earlier contain a bug which can cause us
* to crash on shutdown.
*/
- APPEND_TO_DRIVER_BLOCKLIST(OperatingSystem::WindowsVista,
- (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), GfxDriverInfo::allDevices,
- GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
- DRIVER_LESS_THAN_OR_EQUAL, V(8,15,11,8745),
- "FEATURE_FAILURE_NV_VISTA_15", "nVidia driver > 187.45" );
APPEND_TO_DRIVER_BLOCKLIST(OperatingSystem::Windows7,
(nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), GfxDriverInfo::allDevices,
GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
DRIVER_LESS_THAN_OR_EQUAL, V(8,15,11,8745),
"FEATURE_FAILURE_NV_W7_15", "nVidia driver > 187.45" );
- APPEND_TO_DRIVER_BLOCKLIST_RANGE(OperatingSystem::WindowsVista,
- (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), GfxDriverInfo::allDevices,
- GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
- DRIVER_BETWEEN_INCLUSIVE_START, V(8,16,10,0000), V(8,16,11,8745),
- "FEATURE_FAILURE_NV_VISTA_16", "nVidia driver > 187.45" );
APPEND_TO_DRIVER_BLOCKLIST_RANGE(OperatingSystem::Windows7,
(nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), GfxDriverInfo::allDevices,
GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
DRIVER_BETWEEN_INCLUSIVE_START, V(8,16,10,0000), V(8,16,11,8745),
"FEATURE_FAILURE_NV_W7_16", "nVidia driver > 187.45" );
// Telemetry doesn't show any driver in this range so it might not even be required.
- APPEND_TO_DRIVER_BLOCKLIST_RANGE(OperatingSystem::WindowsVista,
- (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), GfxDriverInfo::allDevices,
- GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
- DRIVER_BETWEEN_INCLUSIVE_START, V(8,17,10,0000), V(8,17,11,8745),
- "FEATURE_FAILURE_NV_VISTA_17", "nVidia driver > 187.45" );
- // Telemetry doesn't show any driver in this range so it might not even be required.
APPEND_TO_DRIVER_BLOCKLIST_RANGE(OperatingSystem::Windows7,
(nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), GfxDriverInfo::allDevices,
GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
@@ -999,13 +871,6 @@ GfxInfo::GetGfxDriverInfo()
nsIGfxInfo::FEATURE_DIRECT2D, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, \
DRIVER_BUILD_ID_LESS_THAN, driverVer, ruleId )
- IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::WindowsVista, IntelGMA500, 1006, "FEATURE_FAILURE_594877_1");
- IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::WindowsVista, IntelGMA900, GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_594877_2");
- IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::WindowsVista, IntelGMA950, 1504, "FEATURE_FAILURE_594877_3");
- IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::WindowsVista, IntelGMA3150, 2124, "FEATURE_FAILURE_594877_4");
- IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::WindowsVista, IntelGMAX3000, 1666, "FEATURE_FAILURE_594877_5");
- IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::WindowsVista, IntelHDGraphicsToSandyBridge, 2202, "FEATURE_FAILURE_594877_6");
-
IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::Windows7, IntelGMA500, 2026, "FEATURE_FAILURE_594877_7");
IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::Windows7, IntelGMA900, GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_594877_8");
IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::Windows7, IntelGMA950, 1930, "FEATURE_FAILURE_594877_9");
@@ -1022,31 +887,6 @@ GfxInfo::GetGfxDriverInfo()
nsIGfxInfo::FEATURE_DIRECT2D, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_1180379");
- IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsXP, IntelGMA500, V(3,0,20,3200), "FEATURE_FAILURE_INTEL_1");
- IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsXP, IntelGMA900, V(6,14,10,4764), "FEATURE_FAILURE_INTEL_2");
- IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsXP, IntelGMA950, V(6,14,10,4926), "FEATURE_FAILURE_INTEL_3");
- IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsXP, IntelGMA3150, V(6,14,10,5134), "FEATURE_FAILURE_INTEL_4");
- IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsXP, IntelGMAX3000, V(6,14,10,5218), "FEATURE_FAILURE_INTEL_5");
- IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsXP, IntelGMAX4500HD, V(6,14,10,4969), "FEATURE_FAILURE_INTEL_6");
- IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsXP, IntelHDGraphicsToSandyBridge, V(6,14,10,4969), "FEATURE_FAILURE_INTEL_7");
-
- // StrechRect seems to suffer from precision issues which leads to artifacting
- // during content drawing starting with at least version 6.14.10.5082
- // and going until 6.14.10.5218. See bug 919454 and bug 949275 for more info.
- APPEND_TO_DRIVER_BLOCKLIST_RANGE(OperatingSystem::WindowsXP,
- const_cast<nsAString&>(GfxDriverInfo::GetDeviceVendor(VendorIntel)),
- const_cast<GfxDeviceFamily*>(GfxDriverInfo::GetDeviceFamily(IntelGMAX4500HD)),
- GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
- DRIVER_BETWEEN_EXCLUSIVE, V(6,14,10,5076), V(6,14,10,5218), "FEATURE_FAILURE_INTEL_8", "6.14.10.5218");
-
- IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsVista, IntelGMA500, V(3,0,20,3200), "FEATURE_FAILURE_INTEL_9");
- IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsVista, IntelGMA900, GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_INTEL_10");
- IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsVista, IntelGMA950, V(7,14,10,1504), "FEATURE_FAILURE_INTEL_11");
- IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsVista, IntelGMA3150, V(7,14,10,1910), "FEATURE_FAILURE_INTEL_12");
- IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsVista, IntelGMAX3000, V(7,15,10,1666), "FEATURE_FAILURE_INTEL_13");
- IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsVista, IntelGMAX4500HD, V(7,15,10,1666), "FEATURE_FAILURE_INTEL_14");
- IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsVista, IntelHDGraphicsToSandyBridge, V(7,15,10,1666), "FEATURE_FAILURE_INTEL_15");
-
IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::Windows7, IntelGMA500, V(5,0,0,2026), "FEATURE_FAILURE_INTEL_16");
IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::Windows7, IntelGMA900, GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_INTEL_17");
IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::Windows7, IntelGMA950, V(8,15,10,1930), "FEATURE_FAILURE_INTEL_18");
@@ -1300,23 +1140,6 @@ GfxInfo::GetFeatureStatusImpl(int32_t aFeature,
return NS_OK;
}
- // special-case the WinXP test slaves: they have out-of-date drivers, but we still want to
- // whitelist them, actually we do know that this combination of device and driver version
- // works well.
- if (mWindowsVersion == kWindowsXP &&
- adapterVendorID.Equals(GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), nsCaseInsensitiveStringComparator()) &&
- adapterDeviceID.LowerCaseEqualsLiteral("0x0861") && // GeForce 9400
- driverVersion == V(6,14,11,7756))
- {
- *aStatus = FEATURE_STATUS_OK;
- return NS_OK;
- }
-
- // Windows Server 2003 should be just like Windows XP for present purpose, but still has a different version number.
- // OTOH Windows Server 2008 R1 and R2 already have the same version numbers as Vista and Seven respectively
- if (os == OperatingSystem::WindowsServer2003)
- os = OperatingSystem::WindowsXP;
-
if (mHasDriverVersionMismatch) {
*aStatus = nsIGfxInfo::FEATURE_BLOCKED_MISMATCHED_VERSION;
return NS_OK;
diff --git a/widget/windows/KeyboardLayout.cpp b/widget/windows/KeyboardLayout.cpp
index 11f657874..9166d97d7 100644
--- a/widget/windows/KeyboardLayout.cpp
+++ b/widget/windows/KeyboardLayout.cpp
@@ -13,9 +13,6 @@
#include "mozilla/WindowsVersion.h"
#include "nsAlgorithm.h"
-#ifdef MOZ_CRASHREPORTER
-#include "nsExceptionHandler.h"
-#endif
#include "nsGkAtoms.h"
#include "nsIDOMKeyEvent.h"
#include "nsIIdleServiceInternal.h"
@@ -1363,34 +1360,6 @@ NativeKey::InitWithKeyChar()
break;
}
- if (!CanComputeVirtualKeyCodeFromScanCode()) {
- // The right control key and the right alt key are extended keys.
- // Therefore, we never get VK_RCONTRL and VK_RMENU for the result of
- // MapVirtualKeyEx() on WinXP or WinServer2003.
- //
- // If VK_SHIFT, VK_CONTROL or VK_MENU key message is caused by well
- // known scan code, we should decide it as Right key. Otherwise,
- // decide it as Left key.
- switch (mOriginalVirtualKeyCode) {
- case VK_CONTROL:
- mVirtualKeyCode =
- mIsExtended && mScanCode == 0x1D ? VK_RCONTROL : VK_LCONTROL;
- break;
- case VK_MENU:
- mVirtualKeyCode =
- mIsExtended && mScanCode == 0x38 ? VK_RMENU : VK_LMENU;
- break;
- case VK_SHIFT:
- // Neither left shift nor right shift is an extended key,
- // let's use VK_LSHIFT for unknown mapping.
- mVirtualKeyCode = VK_LSHIFT;
- break;
- default:
- MOZ_CRASH("Unsupported mOriginalVirtualKeyCode");
- }
- break;
- }
-
NS_ASSERTION(!mVirtualKeyCode,
"mVirtualKeyCode has been computed already");
@@ -1447,11 +1416,6 @@ NativeKey::InitWithKeyChar()
// scancode, we cannot compute virtual keycode. I.e., with such
// applications, we cannot generate proper KeyboardEvent.code value.
- // We cannot compute the virtual key code from WM_CHAR message on WinXP
- // if it's caused by an extended key.
- if (!CanComputeVirtualKeyCodeFromScanCode()) {
- break;
- }
mVirtualKeyCode = mOriginalVirtualKeyCode =
ComputeVirtualKeyCodeFromScanCodeEx();
NS_ASSERTION(mVirtualKeyCode, "Failed to compute virtual keycode");
@@ -1869,18 +1833,6 @@ NativeKey::GetKeyLocation() const
}
}
-bool
-NativeKey::CanComputeVirtualKeyCodeFromScanCode() const
-{
- // Vista or later supports ScanCodeEx.
- if (IsVistaOrLater()) {
- return true;
- }
- // Otherwise, MapVirtualKeyEx() can compute virtual keycode only with
- // non-extended key.
- return !mIsExtended;
-}
-
uint8_t
NativeKey::ComputeVirtualKeyCodeFromScanCode() const
{
@@ -1894,12 +1846,6 @@ NativeKey::ComputeVirtualKeyCodeFromScanCodeEx() const
// MapVirtualKeyEx() has been improved for supporting extended keys since
// Vista. When we call it for mapping a scancode of an extended key and
// a virtual keycode, we need to add 0xE000 to the scancode.
- // On the other hand, neither WinXP nor WinServer2003 doesn't support 0xE000.
- // Therefore, we have no way to get virtual keycode from scan code of
- // extended keys.
- if (NS_WARN_IF(!CanComputeVirtualKeyCodeFromScanCode())) {
- return 0;
- }
return static_cast<uint8_t>(
::MapVirtualKeyEx(GetScanCodeWithExtendedFlag(), MAPVK_VSC_TO_VK_EX,
mKeyboardLayout));
@@ -1910,8 +1856,7 @@ NativeKey::ComputeScanCodeExFromVirtualKeyCode(UINT aVirtualKeyCode) const
{
return static_cast<uint16_t>(
::MapVirtualKeyEx(aVirtualKeyCode,
- IsVistaOrLater() ? MAPVK_VK_TO_VSC_EX :
- MAPVK_VK_TO_VSC,
+ MAPVK_VK_TO_VSC_EX,
mKeyboardLayout));
}
@@ -2792,42 +2737,6 @@ NativeKey::NeedsToHandleWithoutFollowingCharMessages() const
return mIsPrintableKey;
}
-#ifdef MOZ_CRASHREPORTER
-
-static nsCString
-GetResultOfInSendMessageEx()
-{
- DWORD ret = ::InSendMessageEx(nullptr);
- if (!ret) {
- return NS_LITERAL_CSTRING("ISMEX_NOSEND");
- }
- nsAutoCString result;
- if (ret & ISMEX_CALLBACK) {
- result = "ISMEX_CALLBACK";
- }
- if (ret & ISMEX_NOTIFY) {
- if (!result.IsEmpty()) {
- result += " | ";
- }
- result += "ISMEX_NOTIFY";
- }
- if (ret & ISMEX_REPLIED) {
- if (!result.IsEmpty()) {
- result += " | ";
- }
- result += "ISMEX_REPLIED";
- }
- if (ret & ISMEX_SEND) {
- if (!result.IsEmpty()) {
- result += " | ";
- }
- result += "ISMEX_SEND";
- }
- return result;
-}
-
-#endif // #ifdef MOZ_CRASHREPORTER
-
bool
NativeKey::MayBeSameCharMessage(const MSG& aCharMsg1,
const MSG& aCharMsg2) const
@@ -3071,33 +2980,6 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg)
}
if (doCrash) {
-#ifdef MOZ_CRASHREPORTER
- nsPrintfCString info("\nPeekMessage() failed to remove char message! "
- "\nActive keyboard layout=0x%08X (%s), "
- "\nHandling message: %s, InSendMessageEx()=%s, "
- "\nFound message: %s, "
- "\nWM_NULL has been removed: %d, "
- "\nNext key message in all windows: %s, "
- "time=%d, ",
- KeyboardLayout::GetActiveLayout(),
- KeyboardLayout::GetActiveLayoutName().get(),
- ToString(mMsg).get(),
- GetResultOfInSendMessageEx().get(),
- ToString(kFoundCharMsg).get(), i,
- ToString(nextKeyMsgInAllWindows).get(),
- nextKeyMsgInAllWindows.time);
- CrashReporter::AppendAppNotesToCrashReport(info);
- MSG nextMsg;
- if (WinUtils::PeekMessage(&nextMsg, 0, 0, 0,
- PM_NOREMOVE | PM_NOYIELD)) {
- nsPrintfCString info("\nNext message in all windows: %s, time=%d",
- ToString(nextMsg).get(), nextMsg.time);
- CrashReporter::AppendAppNotesToCrashReport(info);
- } else {
- CrashReporter::AppendAppNotesToCrashReport(
- NS_LITERAL_CSTRING("\nThere is no message in any window"));
- }
-#endif // #ifdef MOZ_CRASHREPORTER
MOZ_CRASH("We lost the following char message");
}
@@ -3216,63 +3098,12 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg)
"nextKeyMsg=%s, kFoundCharMsg=%s",
this, ToString(removedMsg).get(), ToString(nextKeyMsg).get(),
ToString(kFoundCharMsg).get()));
-#ifdef MOZ_CRASHREPORTER
- nsPrintfCString info("\nPeekMessage() removed unexpcted char message! "
- "\nActive keyboard layout=0x%08X (%s), "
- "\nHandling message: %s, InSendMessageEx()=%s, "
- "\nFound message: %s, "
- "\nRemoved message: %s, ",
- KeyboardLayout::GetActiveLayout(),
- KeyboardLayout::GetActiveLayoutName().get(),
- ToString(mMsg).get(),
- GetResultOfInSendMessageEx().get(),
- ToString(kFoundCharMsg).get(),
- ToString(removedMsg).get());
- CrashReporter::AppendAppNotesToCrashReport(info);
- // What's the next key message?
- MSG nextKeyMsgAfter;
- if (WinUtils::PeekMessage(&nextKeyMsgAfter, mMsg.hwnd,
- WM_KEYFIRST, WM_KEYLAST,
- PM_NOREMOVE | PM_NOYIELD)) {
- nsPrintfCString info("\nNext key message after unexpected char message "
- "removed: %s, ",
- ToString(nextKeyMsgAfter).get());
- CrashReporter::AppendAppNotesToCrashReport(info);
- } else {
- CrashReporter::AppendAppNotesToCrashReport(
- NS_LITERAL_CSTRING("\nThere is no key message after unexpected char "
- "message removed, "));
- }
- // Another window has a key message?
- if (WinUtils::PeekMessage(&nextKeyMsgInAllWindows, 0,
- WM_KEYFIRST, WM_KEYLAST,
- PM_NOREMOVE | PM_NOYIELD)) {
- nsPrintfCString info("\nNext key message in all windows: %s.",
- ToString(nextKeyMsgInAllWindows).get());
- CrashReporter::AppendAppNotesToCrashReport(info);
- } else {
- CrashReporter::AppendAppNotesToCrashReport(
- NS_LITERAL_CSTRING("\nThere is no key message in any windows."));
- }
-#endif // #ifdef MOZ_CRASHREPORTER
MOZ_CRASH("PeekMessage() removed unexpected message");
}
MOZ_LOG(sNativeKeyLogger, LogLevel::Error,
("%p NativeKey::GetFollowingCharMessage(), FAILED, removed messages "
"are all WM_NULL, nextKeyMsg=%s",
this, ToString(nextKeyMsg).get()));
-#ifdef MOZ_CRASHREPORTER
- nsPrintfCString info("\nWe lost following char message! "
- "\nActive keyboard layout=0x%08X (%s), "
- "\nHandling message: %s, InSendMessageEx()=%s, \n"
- "Found message: %s, removed a lot of WM_NULL",
- KeyboardLayout::GetActiveLayout(),
- KeyboardLayout::GetActiveLayoutName().get(),
- ToString(mMsg).get(),
- GetResultOfInSendMessageEx().get(),
- ToString(kFoundCharMsg).get());
- CrashReporter::AppendAppNotesToCrashReport(info);
-#endif // #ifdef MOZ_CRASHREPORTER
MOZ_CRASH("We lost the following char message");
return false;
}
@@ -4345,8 +4176,7 @@ KeyboardLayout::LoadLayout(HKL aLayout)
if (MOZ_LOG_TEST(sKeyboardLayoutLogger, LogLevel::Verbose)) {
static const UINT kExtendedScanCode[] = { 0x0000, 0xE000 };
- static const UINT kMapType =
- IsVistaOrLater() ? MAPVK_VSC_TO_VK_EX : MAPVK_VSC_TO_VK;
+ static const UINT kMapType = MAPVK_VSC_TO_VK_EX;
MOZ_LOG(sKeyboardLayoutLogger, LogLevel::Verbose,
("Logging virtual keycode values for scancode (0x%p)...",
mKeyboardLayout));
@@ -4358,11 +4188,6 @@ KeyboardLayout::LoadLayout(HKL aLayout)
MOZ_LOG(sKeyboardLayoutLogger, LogLevel::Verbose,
("0x%04X, %s", scanCode, kVirtualKeyName[virtualKeyCode]));
}
- // XP and Server 2003 don't support 0xE0 prefix of the scancode.
- // Therefore, we don't need to continue on them.
- if (!IsVistaOrLater()) {
- break;
- }
}
}
}
diff --git a/widget/windows/KeyboardLayout.h b/widget/windows/KeyboardLayout.h
index dd2ac0bfc..70aacc80e 100644
--- a/widget/windows/KeyboardLayout.h
+++ b/widget/windows/KeyboardLayout.h
@@ -560,11 +560,6 @@ private:
bool GetFollowingCharMessage(MSG& aCharMsg);
/**
- * Whether the key event can compute virtual keycode from the scancode value.
- */
- bool CanComputeVirtualKeyCodeFromScanCode() const;
-
- /**
* Wraps MapVirtualKeyEx() with MAPVK_VSC_TO_VK.
*/
uint8_t ComputeVirtualKeyCodeFromScanCode() const;
diff --git a/widget/windows/LSPAnnotator.cpp b/widget/windows/LSPAnnotator.cpp
deleted file mode 100644
index de4a40d2a..000000000
--- a/widget/windows/LSPAnnotator.cpp
+++ /dev/null
@@ -1,161 +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/. */
-
-/**
- * LSPs are evil little bits of code that are allowed to inject into our
- * networking stack by Windows. Once they have wormed into our process
- * they gnaw at our innards until we crash. Here we force the buggers
- * into the light by recording them in our crash information.
- * We do the enumeration on a thread because I'm concerned about startup perf
- * on machines with several LSPs.
- */
-
-#if _WIN32_WINNT < 0x0600
-// Redefining _WIN32_WINNT for some Vista APIs that we call
-#undef _WIN32_WINNT
-#define _WIN32_WINNT 0x0600
-#endif
-#include "nsICrashReporter.h"
-#include "nsISupportsImpl.h"
-#include "nsServiceManagerUtils.h"
-#include "nsThreadUtils.h"
-#include "nsQueryObject.h"
-#include "nsWindowsHelpers.h"
-#include <windows.h>
-#include <rpc.h>
-#include <ws2spi.h>
-
-namespace mozilla {
-namespace crashreporter {
-
-class LSPAnnotationGatherer : public Runnable
-{
- ~LSPAnnotationGatherer() {}
-
-public:
- NS_DECL_THREADSAFE_ISUPPORTS
- NS_DECL_NSIRUNNABLE
-
- void Annotate();
- nsCString mString;
- nsCOMPtr<nsIThread> mThread;
-};
-
-NS_IMPL_ISUPPORTS(LSPAnnotationGatherer, nsIRunnable)
-
-void
-LSPAnnotationGatherer::Annotate()
-{
- nsCOMPtr<nsICrashReporter> cr =
- do_GetService("@mozilla.org/toolkit/crash-reporter;1");
- bool enabled;
- if (cr && NS_SUCCEEDED(cr->GetEnabled(&enabled)) && enabled) {
- cr->AnnotateCrashReport(NS_LITERAL_CSTRING("Winsock_LSP"), mString);
- }
- mThread->AsyncShutdown();
-}
-
-NS_IMETHODIMP
-LSPAnnotationGatherer::Run()
-{
- PR_SetCurrentThreadName("LSP Annotator");
-
- mThread = NS_GetCurrentThread();
-
- DWORD size = 0;
- int err;
- // Get the size of the buffer we need
- if (SOCKET_ERROR != WSCEnumProtocols(nullptr, nullptr, &size, &err) ||
- err != WSAENOBUFS) {
- // Er, what?
- NS_NOTREACHED("WSCEnumProtocols suceeded when it should have failed ...");
- return NS_ERROR_FAILURE;
- }
-
- auto byteArray = MakeUnique<char[]>(size);
- WSAPROTOCOL_INFOW* providers =
- reinterpret_cast<WSAPROTOCOL_INFOW*>(byteArray.get());
-
- int n = WSCEnumProtocols(nullptr, providers, &size, &err);
- if (n == SOCKET_ERROR) {
- // Lame. We provided the right size buffer; we'll just give up now.
- NS_WARNING("Could not get LSP list");
- return NS_ERROR_FAILURE;
- }
-
- nsCString str;
- for (int i = 0; i < n; i++) {
- AppendUTF16toUTF8(nsDependentString(providers[i].szProtocol), str);
- str.AppendLiteral(" : ");
- str.AppendInt(providers[i].iVersion);
- str.AppendLiteral(" : ");
- str.AppendInt(providers[i].iAddressFamily);
- str.AppendLiteral(" : ");
- str.AppendInt(providers[i].iSocketType);
- str.AppendLiteral(" : ");
- str.AppendInt(providers[i].iProtocol);
- str.AppendLiteral(" : ");
- str.AppendPrintf("0x%x", providers[i].dwServiceFlags1);
- str.AppendLiteral(" : ");
- str.AppendPrintf("0x%x", providers[i].dwProviderFlags);
- str.AppendLiteral(" : ");
-
- wchar_t path[MAX_PATH];
- int pathLen = MAX_PATH;
- if (!WSCGetProviderPath(&providers[i].ProviderId, path, &pathLen, &err)) {
- AppendUTF16toUTF8(nsDependentString(path), str);
- }
-
- str.AppendLiteral(" : ");
- // If WSCGetProviderInfo is available, we should call it to obtain the
- // category flags for this provider. When present, these flags inform
- // Windows as to which order to chain the providers.
- nsModuleHandle ws2_32(LoadLibraryW(L"ws2_32.dll"));
- if (ws2_32) {
- decltype(WSCGetProviderInfo)* pWSCGetProviderInfo =
- reinterpret_cast<decltype(WSCGetProviderInfo)*>(
- GetProcAddress(ws2_32, "WSCGetProviderInfo"));
- if (pWSCGetProviderInfo) {
- DWORD categoryInfo;
- size_t categoryInfoSize = sizeof(categoryInfo);
- if (!pWSCGetProviderInfo(&providers[i].ProviderId,
- ProviderInfoLspCategories,
- (PBYTE)&categoryInfo, &categoryInfoSize, 0,
- &err)) {
- str.AppendPrintf("0x%x", categoryInfo);
- }
- }
- }
-
- str.AppendLiteral(" : ");
- if (providers[i].ProtocolChain.ChainLen <= BASE_PROTOCOL) {
- // If we're dealing with a catalog entry that identifies an individual
- // base or layer provider, log its provider GUID.
- RPC_CSTR provIdStr = nullptr;
- if (UuidToStringA(&providers[i].ProviderId, &provIdStr) == RPC_S_OK) {
- str.Append(reinterpret_cast<char*>(provIdStr));
- RpcStringFreeA(&provIdStr);
- }
- }
-
- if (i + 1 != n) {
- str.AppendLiteral(" \n ");
- }
- }
-
- mString = str;
- NS_DispatchToMainThread(NewRunnableMethod(this, &LSPAnnotationGatherer::Annotate));
- return NS_OK;
-}
-
-void LSPAnnotate()
-{
- nsCOMPtr<nsIThread> thread;
- nsCOMPtr<nsIRunnable> runnable =
- do_QueryObject(new LSPAnnotationGatherer());
- NS_NewThread(getter_AddRefs(thread), runnable);
-}
-
-} // namespace crashreporter
-} // namespace mozilla
diff --git a/widget/windows/TSFTextStore.cpp b/widget/windows/TSFTextStore.cpp
index fb0505aa3..7224126b8 100644
--- a/widget/windows/TSFTextStore.cpp
+++ b/widget/windows/TSFTextStore.cpp
@@ -5762,8 +5762,7 @@ TSFTextStore::Initialize()
return;
}
- bool enableTsf =
- IsVistaOrLater() && Preferences::GetBool(kPrefNameEnableTSF, false);
+ bool enableTsf = Preferences::GetBool(kPrefNameEnableTSF, false);
MOZ_LOG(sTextStoreLog, LogLevel::Info,
(" TSFTextStore::Initialize(), TSF is %s",
enableTsf ? "enabled" : "disabled"));
diff --git a/widget/windows/TaskbarPreview.cpp b/widget/windows/TaskbarPreview.cpp
index c897af021..6c15df2e0 100644
--- a/widget/windows/TaskbarPreview.cpp
+++ b/widget/windows/TaskbarPreview.cpp
@@ -28,7 +28,9 @@
#include "mozilla/Telemetry.h"
// Defined in dwmapi in a header that needs a higher numbered _WINNT #define
+#ifndef DWM_SIT_DISPLAYFRAME
#define DWM_SIT_DISPLAYFRAME 0x1
+#endif
namespace mozilla {
namespace widget {
diff --git a/widget/windows/WinMouseScrollHandler.cpp b/widget/windows/WinMouseScrollHandler.cpp
index 10937ba51..e157b1be2 100644
--- a/widget/windows/WinMouseScrollHandler.cpp
+++ b/widget/windows/WinMouseScrollHandler.cpp
@@ -992,10 +992,7 @@ MouseScrollHandler::SystemSettings::InitScrollChars()
&mScrollChars, 0)) {
MOZ_LOG(gMouseScrollLog, LogLevel::Info,
("MouseScroll::SystemSettings::InitScrollChars(): ::SystemParametersInfo("
- "SPI_GETWHEELSCROLLCHARS) failed, %s",
- IsVistaOrLater() ?
- "this is unexpected on Vista or later" :
- "but on XP or earlier, this is not a problem"));
+ "SPI_GETWHEELSCROLLCHARS) failed, this is unexpected on Vista or later"));
// XXX Should we use DefaultScrollChars()?
mScrollChars = 1;
}
@@ -1081,7 +1078,7 @@ bool
MouseScrollHandler::SystemSettings::IsOverridingSystemScrollSpeedAllowed()
{
return mScrollLines == DefaultScrollLines() &&
- (!IsVistaOrLater() || mScrollChars == DefaultScrollChars());
+ mScrollChars == DefaultScrollChars();
}
/******************************************************************************
diff --git a/widget/windows/WinTaskbar.cpp b/widget/windows/WinTaskbar.cpp
index 698b7ec0e..530cfd5b9 100644
--- a/widget/windows/WinTaskbar.cpp
+++ b/widget/windows/WinTaskbar.cpp
@@ -34,8 +34,6 @@
#include <propkey.h>
#include <shellapi.h>
-const wchar_t kShellLibraryName[] = L"shell32.dll";
-
static NS_DEFINE_CID(kJumpListBuilderCID, NS_WIN_JUMPLISTBUILDER_CID);
namespace {
@@ -77,30 +75,14 @@ SetWindowAppUserModelProp(mozIDOMWindow *aParent,
if (!toplevelHWND)
return NS_ERROR_INVALID_ARG;
- typedef HRESULT (WINAPI * SHGetPropertyStoreForWindowPtr)
- (HWND hwnd, REFIID riid, void** ppv);
- SHGetPropertyStoreForWindowPtr funcGetProStore = nullptr;
-
- HMODULE hDLL = ::LoadLibraryW(kShellLibraryName);
- funcGetProStore = (SHGetPropertyStoreForWindowPtr)
- GetProcAddress(hDLL, "SHGetPropertyStoreForWindow");
-
- if (!funcGetProStore) {
- FreeLibrary(hDLL);
- return NS_ERROR_NO_INTERFACE;
- }
-
- IPropertyStore* pPropStore;
- if (FAILED(funcGetProStore(toplevelHWND,
- IID_PPV_ARGS(&pPropStore)))) {
- FreeLibrary(hDLL);
+ RefPtr<IPropertyStore> pPropStore;
+ if (FAILED(SHGetPropertyStoreForWindow(toplevelHWND, IID_IPropertyStore,
+ getter_AddRefs(pPropStore)))) {
return NS_ERROR_INVALID_ARG;
}
PROPVARIANT pv;
if (FAILED(InitPropVariantFromString(aIdentifier.get(), &pv))) {
- pPropStore->Release();
- FreeLibrary(hDLL);
return NS_ERROR_UNEXPECTED;
}
@@ -111,8 +93,6 @@ SetWindowAppUserModelProp(mozIDOMWindow *aParent,
}
PropVariantClear(&pv);
- pPropStore->Release();
- FreeLibrary(hDLL);
return rv;
}
@@ -339,40 +319,18 @@ WinTaskbar::GetDefaultGroupId(nsAString & aDefaultGroupId) {
// (static) Called from AppShell
bool
WinTaskbar::RegisterAppUserModelID() {
- if (!IsWin7OrLater())
- return false;
-
- SetCurrentProcessExplicitAppUserModelIDPtr funcAppUserModelID = nullptr;
- bool retVal = false;
-
nsAutoString uid;
if (!GetAppUserModelID(uid))
return false;
- HMODULE hDLL = ::LoadLibraryW(kShellLibraryName);
-
- funcAppUserModelID = (SetCurrentProcessExplicitAppUserModelIDPtr)
- GetProcAddress(hDLL, "SetCurrentProcessExplicitAppUserModelID");
-
- if (!funcAppUserModelID) {
- ::FreeLibrary(hDLL);
- return false;
- }
-
- if (SUCCEEDED(funcAppUserModelID(uid.get())))
- retVal = true;
-
- if (hDLL)
- ::FreeLibrary(hDLL);
-
- return retVal;
+ return SUCCEEDED(SetCurrentProcessExplicitAppUserModelID(uid.get()));
}
NS_IMETHODIMP
WinTaskbar::GetAvailable(bool *aAvailable) {
// ITaskbarList4::HrInit() may fail with shell extensions like blackbox
// installed. Initialize early to return available=false in those cases.
- *aAvailable = IsWin7OrLater() && Initialize();
+ *aAvailable = Initialize();
return NS_OK;
}
diff --git a/widget/windows/WinUtils.cpp b/widget/windows/WinUtils.cpp
index 3ff46513e..bd42e78f6 100644
--- a/widget/windows/WinUtils.cpp
+++ b/widget/windows/WinUtils.cpp
@@ -462,7 +462,7 @@ static NtTestAlertPtr sNtTestAlert = nullptr;
void
WinUtils::Initialize()
{
- if (!sDwmDll && IsVistaOrLater()) {
+ if (!sDwmDll) {
sDwmDll = ::LoadLibraryW(kDwmLibraryName);
if (sDwmDll) {
@@ -601,7 +601,7 @@ WinUtils::SystemScaleFactor()
return systemScale;
}
-#ifndef WM_DPICHANGED
+#if WINVER < 0x603
typedef enum {
MDT_EFFECTIVE_DPI = 0,
MDT_ANGULAR_DPI = 1,
@@ -628,16 +628,14 @@ GETPROCESSDPIAWARENESSPROC sGetProcessDpiAwareness;
static bool
SlowIsPerMonitorDPIAware()
{
- if (IsVistaOrLater()) {
- // Intentionally leak the handle.
- HMODULE shcore =
- LoadLibraryEx(L"shcore", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
- if (shcore) {
- sGetDpiForMonitor =
- (GETDPIFORMONITORPROC) GetProcAddress(shcore, "GetDpiForMonitor");
- sGetProcessDpiAwareness =
- (GETPROCESSDPIAWARENESSPROC) GetProcAddress(shcore, "GetProcessDpiAwareness");
- }
+ // Intentionally leak the handle.
+ HMODULE shcore =
+ LoadLibraryEx(L"shcore", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
+ if (shcore) {
+ sGetDpiForMonitor =
+ (GETDPIFORMONITORPROC) GetProcAddress(shcore, "GetDpiForMonitor");
+ sGetProcessDpiAwareness =
+ (GETPROCESSDPIAWARENESSPROC) GetProcAddress(shcore, "GetProcessDpiAwareness");
}
PROCESS_DPI_AWARENESS dpiAwareness;
return sGetDpiForMonitor && sGetProcessDpiAwareness &&
@@ -760,7 +758,7 @@ static DWORD
GetWaitFlags()
{
DWORD result = MWMO_INPUTAVAILABLE;
- if (IsVistaOrLater() && XRE_IsContentProcess()) {
+ if (XRE_IsContentProcess()) {
result |= MWMO_ALERTABLE;
}
return result;
@@ -1879,7 +1877,7 @@ WinUtils::IsTouchDeviceSupportPresent()
uint32_t
WinUtils::GetMaxTouchPoints()
{
- if (IsWin7OrLater() && IsTouchDeviceSupportPresent()) {
+ if (IsTouchDeviceSupportPresent()) {
return GetSystemMetrics(SM_MAXIMUMTOUCHES);
}
return 0;
@@ -1894,11 +1892,6 @@ typedef DWORD (WINAPI * GetFinalPathNameByHandlePtr)(HANDLE hFile,
bool
WinUtils::ResolveJunctionPointsAndSymLinks(std::wstring& aPath)
{
- // Users folder was introduced with Vista.
- if (!IsVistaOrLater()) {
- return true;
- }
-
wchar_t path[MAX_PATH] = { 0 };
nsAutoHandle handle(
@@ -2026,21 +2019,19 @@ WinUtils::GetAppInitDLLs(nsAString& aOutput)
}
nsAutoRegKey key(hkey);
LONG status;
- if (IsVistaOrLater()) {
- const wchar_t kLoadAppInitDLLs[] = L"LoadAppInit_DLLs";
- DWORD loadAppInitDLLs = 0;
- DWORD loadAppInitDLLsLen = sizeof(loadAppInitDLLs);
- status = RegQueryValueExW(hkey, kLoadAppInitDLLs, nullptr,
- nullptr, (LPBYTE)&loadAppInitDLLs,
- &loadAppInitDLLsLen);
- if (status != ERROR_SUCCESS) {
- return false;
- }
- if (!loadAppInitDLLs) {
- // If loadAppInitDLLs is zero then AppInit_DLLs is disabled.
- // In this case we'll return true along with an empty output string.
- return true;
- }
+ const wchar_t kLoadAppInitDLLs[] = L"LoadAppInit_DLLs";
+ DWORD loadAppInitDLLs = 0;
+ DWORD loadAppInitDLLsLen = sizeof(loadAppInitDLLs);
+ status = RegQueryValueExW(hkey, kLoadAppInitDLLs, nullptr,
+ nullptr, (LPBYTE)&loadAppInitDLLs,
+ &loadAppInitDLLsLen);
+ if (status != ERROR_SUCCESS) {
+ return false;
+ }
+ if (!loadAppInitDLLs) {
+ // If loadAppInitDLLs is zero then AppInit_DLLs is disabled.
+ // In this case we'll return true along with an empty output string.
+ return true;
}
DWORD numBytes = 0;
const wchar_t kAppInitDLLs[] = L"AppInit_DLLs";
diff --git a/widget/windows/WindowsUIUtils.cpp b/widget/windows/WindowsUIUtils.cpp
index 223511859..1c270b5ec 100644
--- a/widget/windows/WindowsUIUtils.cpp
+++ b/widget/windows/WindowsUIUtils.cpp
@@ -5,7 +5,8 @@
#include <windows.h>
#include <winsdkver.h>
-#include "mozwrlbase.h"
+#include <wrl.h>
+
#include "nsServiceManagerUtils.h"
#include "WindowsUIUtils.h"
@@ -179,4 +180,3 @@ WindowsUIUtils::UpdateTabletModeState()
return NS_OK;
}
-
diff --git a/widget/windows/moz.build b/widget/windows/moz.build
index d4f089eea..1e7fc4b02 100644
--- a/widget/windows/moz.build
+++ b/widget/windows/moz.build
@@ -79,11 +79,6 @@ SOURCES += [
'WinMouseScrollHandler.cpp',
]
-if CONFIG['MOZ_CRASHREPORTER']:
- UNIFIED_SOURCES += [
- 'LSPAnnotator.cpp',
- ]
-
if CONFIG['NS_PRINTING']:
UNIFIED_SOURCES += [
'nsDeviceContextSpecWin.cpp',
diff --git a/widget/windows/mozwrlbase.h b/widget/windows/mozwrlbase.h
deleted file mode 100644
index d82be8f04..000000000
--- a/widget/windows/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/nsAppShell.cpp b/widget/windows/nsAppShell.cpp
index c8820e7d1..c3e99b2d3 100644
--- a/widget/windows/nsAppShell.cpp
+++ b/widget/windows/nsAppShell.cpp
@@ -213,10 +213,6 @@ nsAppShell::~nsAppShell()
nsresult
nsAppShell::Init()
{
-#ifdef MOZ_CRASHREPORTER
- LSPAnnotate();
-#endif
-
mLastNativeEventScheduled = TimeStamp::NowLoRes();
mozilla::ipc::windows::InitUIThread();
diff --git a/widget/windows/nsClipboard.cpp b/widget/windows/nsClipboard.cpp
index 1afee3496..0db1dd342 100644
--- a/widget/windows/nsClipboard.cpp
+++ b/widget/windows/nsClipboard.cpp
@@ -65,7 +65,7 @@ nsClipboard::nsClipboard() : nsBaseClipboard()
nsCOMPtr<nsIObserverService> observerService =
do_GetService("@mozilla.org/observer-service;1");
if (observerService)
- observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
+ observerService->AddObserver(this, NS_XPCOM_WILL_SHUTDOWN_OBSERVER_ID, PR_FALSE);
}
//-------------------------------------------------------------------------
diff --git a/widget/windows/nsDataObj.cpp b/widget/windows/nsDataObj.cpp
index fc45968ae..977a87c08 100644
--- a/widget/windows/nsDataObj.cpp
+++ b/widget/windows/nsDataObj.cpp
@@ -443,6 +443,82 @@ STDMETHODIMP_(ULONG) nsDataObj::AddRef()
return m_cRef;
}
+namespace {
+class RemoveTempFileHelper : public nsIObserver
+{
+public:
+ explicit RemoveTempFileHelper(nsIFile* aTempFile)
+ : mTempFile(aTempFile)
+ {
+ MOZ_ASSERT(mTempFile);
+ }
+
+ // The attach method is seperate from the constructor as we may be addref-ing
+ // ourself, and we want to be sure someone has a strong reference to us.
+ void Attach()
+ {
+ // We need to listen to both the xpcom shutdown message and our timer, and
+ // fire when the first of either of these two messages is received.
+ nsresult rv;
+ mTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv);
+ if (NS_WARN_IF(NS_FAILED(rv))) {
+ return;
+ }
+ mTimer->Init(this, 500, nsITimer::TYPE_ONE_SHOT);
+
+ nsCOMPtr<nsIObserverService> observerService =
+ do_GetService("@mozilla.org/observer-service;1");
+ if (NS_WARN_IF(!observerService)) {
+ mTimer->Cancel();
+ mTimer = nullptr;
+ return;
+ }
+ observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
+ }
+
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIOBSERVER
+
+private:
+ ~RemoveTempFileHelper()
+ {
+ if (mTempFile) {
+ mTempFile->Remove(false);
+ }
+ }
+
+ nsCOMPtr<nsIFile> mTempFile;
+ nsCOMPtr<nsITimer> mTimer;
+};
+
+NS_IMPL_ISUPPORTS(RemoveTempFileHelper, nsIObserver);
+
+NS_IMETHODIMP
+RemoveTempFileHelper::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData)
+{
+ // Let's be careful and make sure that we don't die immediately
+ RefPtr<RemoveTempFileHelper> grip = this;
+
+ // Make sure that we aren't called again by destroying references to ourself.
+ nsCOMPtr<nsIObserverService> observerService =
+ do_GetService("@mozilla.org/observer-service;1");
+ if (observerService) {
+ observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
+ }
+
+ if (mTimer) {
+ mTimer->Cancel();
+ mTimer = nullptr;
+ }
+
+ // Remove the tempfile
+ if (mTempFile) {
+ mTempFile->Remove(false);
+ mTempFile = nullptr;
+ }
+ return NS_OK;
+}
+} // namespace
//-----------------------------------------------------
STDMETHODIMP_(ULONG) nsDataObj::Release()
@@ -456,17 +532,12 @@ STDMETHODIMP_(ULONG) nsDataObj::Release()
// We have released our last ref on this object and need to delete the
// temp file. External app acting as drop target may still need to open the
// temp file. Addref a timer so it can delay deleting file and destroying
- // this object. Delete file anyway and destroy this obj if there's a problem.
+ // this object.
if (mCachedTempFile) {
- nsresult rv;
- mTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv);
- if (NS_SUCCEEDED(rv)) {
- mTimer->InitWithFuncCallback(nsDataObj::RemoveTempFile, this,
- 500, nsITimer::TYPE_ONE_SHOT);
- return AddRef();
- }
- mCachedTempFile->Remove(false);
+ RefPtr<RemoveTempFileHelper> helper =
+ new RemoveTempFileHelper(mCachedTempFile);
mCachedTempFile = nullptr;
+ helper->Attach();
}
delete this;
@@ -1148,8 +1219,7 @@ nsDataObj :: GetFileContentsInternetShortcut ( FORMATETC& aFE, STGMEDIUM& aSTG )
const char *shortcutFormatStr;
int totalLen;
nsCString path;
- if (!Preferences::GetBool(kShellIconPref, true) ||
- !IsVistaOrLater()) {
+ if (!Preferences::GetBool(kShellIconPref, true)) {
shortcutFormatStr = "[InternetShortcut]\r\nURL=%s\r\n";
const int formatLen = strlen(shortcutFormatStr) - 2; // don't include %s
totalLen = formatLen + asciiUrl.Length(); // don't include null character
@@ -2154,13 +2224,3 @@ HRESULT nsDataObj::GetFileContents_IStream(FORMATETC& aFE, STGMEDIUM& aSTG)
return S_OK;
}
-
-void nsDataObj::RemoveTempFile(nsITimer* aTimer, void* aClosure)
-{
- nsDataObj *timedDataObj = static_cast<nsDataObj *>(aClosure);
- if (timedDataObj->mCachedTempFile) {
- timedDataObj->mCachedTempFile->Remove(false);
- timedDataObj->mCachedTempFile = nullptr;
- }
- timedDataObj->Release();
-}
diff --git a/widget/windows/nsDataObj.h b/widget/windows/nsDataObj.h
index 2d7fb75ee..61f209e85 100644
--- a/widget/windows/nsDataObj.h
+++ b/widget/windows/nsDataObj.h
@@ -289,7 +289,6 @@ protected:
bool LookupArbitraryFormat(FORMATETC *aFormat, LPDATAENTRY *aDataEntry, BOOL aAddorUpdate);
bool CopyMediumData(STGMEDIUM *aMediumDst, STGMEDIUM *aMediumSrc, LPFORMATETC aFormat, BOOL aSetData);
- static void RemoveTempFile(nsITimer* aTimer, void* aClosure);
};
diff --git a/widget/windows/nsFilePicker.cpp b/widget/windows/nsFilePicker.cpp
index 53857cf5e..4e942968a 100644
--- a/widget/windows/nsFilePicker.cpp
+++ b/widget/windows/nsFilePicker.cpp
@@ -28,7 +28,6 @@
#include "nsPIDOMWindow.h"
#include "GeckoProfiler.h"
-using mozilla::IsVistaOrLater;
using mozilla::IsWin8OrLater;
using mozilla::MakeUnique;
using mozilla::mscom::EnsureMTA;
@@ -219,191 +218,6 @@ STDMETHODIMP nsFilePicker::QueryInterface(REFIID refiid, void** ppvResult)
return E_NOINTERFACE;
}
-/*
- * XP picker callbacks
- */
-
-// Show - Display the file dialog
-int CALLBACK
-BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
-{
- if (uMsg == BFFM_INITIALIZED)
- {
- char16_t * filePath = (char16_t *) lpData;
- if (filePath)
- ::SendMessageW(hwnd, BFFM_SETSELECTIONW,
- TRUE /* true because lpData is a path string */,
- lpData);
- }
- return 0;
-}
-
-static void
-EnsureWindowVisible(HWND hwnd)
-{
- // Obtain the monitor which has the largest area of intersection
- // with the window, or nullptr if there is no intersection.
- HMONITOR monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONULL);
- if (!monitor) {
- // The window is not visible, we should reposition it to the same place as its parent
- HWND parentHwnd = GetParent(hwnd);
- RECT parentRect;
- GetWindowRect(parentHwnd, &parentRect);
- SetWindowPos(hwnd, nullptr, parentRect.left, parentRect.top, 0, 0,
- SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
- }
-}
-
-// Callback hook which will ensure that the window is visible. Currently
-// only in use on os <= XP.
-UINT_PTR CALLBACK
-nsFilePicker::FilePickerHook(HWND hwnd,
- UINT msg,
- WPARAM wParam,
- LPARAM lParam)
-{
- switch(msg) {
- case WM_NOTIFY:
- {
- LPOFNOTIFYW lpofn = (LPOFNOTIFYW) lParam;
- if (!lpofn || !lpofn->lpOFN) {
- return 0;
- }
-
- if (CDN_INITDONE == lpofn->hdr.code) {
- // The Window will be automatically moved to the last position after
- // CDN_INITDONE. We post a message to ensure the window will be visible
- // so it will be done after the automatic last position window move.
- PostMessage(hwnd, MOZ_WM_ENSUREVISIBLE, 0, 0);
- }
- }
- break;
- case MOZ_WM_ENSUREVISIBLE:
- EnsureWindowVisible(GetParent(hwnd));
- break;
- case WM_INITDIALOG:
- {
- OPENFILENAMEW* pofn = reinterpret_cast<OPENFILENAMEW*>(lParam);
- SetProp(hwnd, kDialogPtrProp, (HANDLE)pofn->lCustData);
- nsFilePicker* picker = reinterpret_cast<nsFilePicker*>(pofn->lCustData);
- if (picker) {
- picker->SetDialogHandle(hwnd);
- SetTimer(hwnd, kDialogTimerID, kDialogTimerTimeout, nullptr);
- }
- }
- break;
- case WM_TIMER:
- {
- // Check to see if our parent has been torn down, if so, we close too.
- if (wParam == kDialogTimerID) {
- nsFilePicker* picker =
- reinterpret_cast<nsFilePicker*>(GetProp(hwnd, kDialogPtrProp));
- if (picker && picker->ClosePickerIfNeeded(true)) {
- KillTimer(hwnd, kDialogTimerID);
- }
- }
- }
- break;
- }
- return 0;
-}
-
-
-// Callback hook which will dynamically allocate a buffer large enough
-// for the file picker dialog. Currently only in use on os <= XP.
-UINT_PTR CALLBACK
-nsFilePicker::MultiFilePickerHook(HWND hwnd,
- UINT msg,
- WPARAM wParam,
- LPARAM lParam)
-{
- switch (msg) {
- case WM_INITDIALOG:
- {
- // Finds the child drop down of a File Picker dialog and sets the
- // maximum amount of text it can hold when typed in manually.
- // A wParam of 0 mean 0x7FFFFFFE characters.
- HWND comboBox = FindWindowEx(GetParent(hwnd), nullptr,
- L"ComboBoxEx32", nullptr );
- if(comboBox)
- SendMessage(comboBox, CB_LIMITTEXT, 0, 0);
- // Store our nsFilePicker ptr for future use
- OPENFILENAMEW* pofn = reinterpret_cast<OPENFILENAMEW*>(lParam);
- SetProp(hwnd, kDialogPtrProp, (HANDLE)pofn->lCustData);
- nsFilePicker* picker =
- reinterpret_cast<nsFilePicker*>(pofn->lCustData);
- if (picker) {
- picker->SetDialogHandle(hwnd);
- SetTimer(hwnd, kDialogTimerID, kDialogTimerTimeout, nullptr);
- }
- }
- break;
- case WM_NOTIFY:
- {
- LPOFNOTIFYW lpofn = (LPOFNOTIFYW) lParam;
- if (!lpofn || !lpofn->lpOFN) {
- return 0;
- }
- // CDN_SELCHANGE is sent when the selection in the list box of the file
- // selection dialog changes
- if (lpofn->hdr.code == CDN_SELCHANGE) {
- HWND parentHWND = GetParent(hwnd);
-
- // Get the required size for the selected files buffer
- UINT newBufLength = 0;
- int requiredBufLength = CommDlg_OpenSave_GetSpecW(parentHWND,
- nullptr, 0);
- if(requiredBufLength >= 0)
- newBufLength += requiredBufLength;
- else
- newBufLength += MAX_PATH;
-
- // If the user selects multiple files, the buffer contains the
- // current directory followed by the file names of the selected
- // files. So make room for the directory path. If the user
- // selects a single file, it is no harm to add extra space.
- requiredBufLength = CommDlg_OpenSave_GetFolderPathW(parentHWND,
- nullptr, 0);
- if(requiredBufLength >= 0)
- newBufLength += requiredBufLength;
- else
- newBufLength += MAX_PATH;
-
- // Check if lpstrFile and nMaxFile are large enough
- if (newBufLength > lpofn->lpOFN->nMaxFile) {
- if (lpofn->lpOFN->lpstrFile)
- delete[] lpofn->lpOFN->lpstrFile;
-
- // We allocate FILE_BUFFER_SIZE more bytes than is needed so that
- // if the user selects a file and holds down shift and down to
- // select additional items, we will not continuously reallocate
- newBufLength += FILE_BUFFER_SIZE;
-
- wchar_t* filesBuffer = new wchar_t[newBufLength];
- ZeroMemory(filesBuffer, newBufLength * sizeof(wchar_t));
-
- lpofn->lpOFN->lpstrFile = filesBuffer;
- lpofn->lpOFN->nMaxFile = newBufLength;
- }
- }
- }
- break;
- case WM_TIMER:
- {
- // Check to see if our parent has been torn down, if so, we close too.
- if (wParam == kDialogTimerID) {
- nsFilePicker* picker =
- reinterpret_cast<nsFilePicker*>(GetProp(hwnd, kDialogPtrProp));
- if (picker && picker->ClosePickerIfNeeded(true)) {
- KillTimer(hwnd, kDialogTimerID);
- }
- }
- }
- break;
- }
-
- return FilePickerHook(hwnd, msg, wParam, lParam);
-}
/*
* Vista+ callbacks
@@ -476,25 +290,18 @@ nsFilePicker::OnOverwrite(IFileDialog *pfd,
*/
bool
-nsFilePicker::ClosePickerIfNeeded(bool aIsXPDialog)
+nsFilePicker::ClosePickerIfNeeded()
{
if (!mParentWidget || !mDlgWnd)
return false;
nsWindow *win = static_cast<nsWindow *>(mParentWidget.get());
- // Note, the xp callbacks hand us an inner window, so we have to step up
- // one to get the actual dialog.
- HWND dlgWnd;
- if (aIsXPDialog)
- dlgWnd = GetParent(mDlgWnd);
- else
- dlgWnd = mDlgWnd;
- if (IsWindow(dlgWnd) && IsWindowVisible(dlgWnd) && win->DestroyCalled()) {
+ if (IsWindow(mDlgWnd) && IsWindowVisible(mDlgWnd) && win->DestroyCalled()) {
wchar_t className[64];
// Make sure we have the right window
- if (GetClassNameW(dlgWnd, className, mozilla::ArrayLength(className)) &&
+ if (GetClassNameW(mDlgWnd, className, mozilla::ArrayLength(className)) &&
!wcscmp(className, L"#32770") &&
- DestroyWindow(dlgWnd)) {
+ DestroyWindow(mDlgWnd)) {
mDlgWnd = nullptr;
return true;
}
@@ -506,7 +313,7 @@ void
nsFilePicker::PickerCallbackTimerFunc(nsITimer *aTimer, void *aCtx)
{
nsFilePicker* picker = (nsFilePicker*)aCtx;
- if (picker->ClosePickerIfNeeded(false)) {
+ if (picker->ClosePickerIfNeeded()) {
aTimer->Cancel();
}
}
@@ -523,62 +330,15 @@ nsFilePicker::SetDialogHandle(HWND aWnd)
* Folder picker invocation
*/
-// Open the older XP style folder picker dialog. We end up in this call
-// on XP systems or when platform is built without the longhorn SDK.
-bool
-nsFilePicker::ShowXPFolderPicker(const nsString& aInitialDir)
-{
- bool result = false;
-
- auto dirBuffer = MakeUnique<wchar_t[]>(FILE_BUFFER_SIZE);
- wcsncpy(dirBuffer.get(), aInitialDir.get(), FILE_BUFFER_SIZE);
- dirBuffer[FILE_BUFFER_SIZE-1] = '\0';
-
- AutoDestroyTmpWindow adtw((HWND)(mParentWidget.get() ?
- mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW) : nullptr));
-
- BROWSEINFOW browserInfo = {0};
- browserInfo.pidlRoot = nullptr;
- browserInfo.pszDisplayName = dirBuffer.get();
- browserInfo.lpszTitle = mTitle.get();
- browserInfo.ulFlags = BIF_USENEWUI | BIF_RETURNONLYFSDIRS;
- browserInfo.hwndOwner = adtw.get();
- browserInfo.iImage = 0;
- browserInfo.lParam = reinterpret_cast<LPARAM>(this);
-
- if (!aInitialDir.IsEmpty()) {
- // the dialog is modal so that |initialDir.get()| will be valid in
- // BrowserCallbackProc. Thus, we don't need to clone it.
- browserInfo.lParam = (LPARAM) aInitialDir.get();
- browserInfo.lpfn = &BrowseCallbackProc;
- } else {
- browserInfo.lParam = 0;
- browserInfo.lpfn = nullptr;
- }
-
- LPITEMIDLIST list = ::SHBrowseForFolderW(&browserInfo);
- if (list) {
- result = ::SHGetPathFromIDListW(list, dirBuffer.get());
- if (result)
- mUnicodeFile.Assign(static_cast<const wchar_t*>(dirBuffer.get()));
- // free PIDL
- CoTaskMemFree(list);
- }
-
- return result;
-}
-
/*
- * Show a folder picker post Windows XP
- *
+ * Show a folder picker.
+ *
* @param aInitialDir The initial directory, the last used directory will be
* used if left blank.
- * @param aWasInitError Out parameter will hold true if there was an error
- * before the folder picker is shown.
* @return true if a file was selected successfully.
*/
bool
-nsFilePicker::ShowFolderPicker(const nsString& aInitialDir, bool &aWasInitError)
+nsFilePicker::ShowFolderPicker(const nsString& aInitialDir)
{
if (!IsWin8OrLater()) {
// Some Windows 7 users are experiencing a race condition when some dlls
@@ -593,10 +353,8 @@ nsFilePicker::ShowFolderPicker(const nsString& aInitialDir, bool &aWasInitError)
if (FAILED(CoCreateInstance(CLSID_FileOpenDialog, nullptr, CLSCTX_INPROC,
IID_IFileOpenDialog,
getter_AddRefs(dialog)))) {
- aWasInitError = true;
return false;
}
- aWasInitError = false;
// hook up event callbacks
dialog->Advise(this, &mFDECookie);
@@ -658,233 +416,15 @@ nsFilePicker::ShowFolderPicker(const nsString& aInitialDir, bool &aWasInitError)
* File open and save picker invocation
*/
-/* static */ bool
-nsFilePicker::GetFileNameWrapper(OPENFILENAMEW* ofn, PickerType aType)
-{
- MOZ_SEH_TRY {
- if (aType == PICKER_TYPE_OPEN)
- return ::GetOpenFileNameW(ofn);
- else if (aType == PICKER_TYPE_SAVE)
- return ::GetSaveFileNameW(ofn);
- } MOZ_SEH_EXCEPT(true) {
- NS_ERROR("nsFilePicker GetFileName win32 call generated an exception! This is bad!");
- }
- return false;
-}
-
-bool
-nsFilePicker::FilePickerWrapper(OPENFILENAMEW* ofn, PickerType aType)
-{
- if (!ofn)
- return false;
- AutoWidgetPickerState awps(mParentWidget);
- return GetFileNameWrapper(ofn, aType);
-}
-
-bool
-nsFilePicker::ShowXPFilePicker(const nsString& aInitialDir)
-{
- OPENFILENAMEW ofn = {0};
- ofn.lStructSize = sizeof(ofn);
- nsString filterBuffer = mFilterList;
-
- auto fileBuffer = MakeUnique<wchar_t[]>(FILE_BUFFER_SIZE);
- wcsncpy(fileBuffer.get(), mDefaultFilePath.get(), FILE_BUFFER_SIZE);
- fileBuffer[FILE_BUFFER_SIZE-1] = '\0'; // null terminate in case copy truncated
-
- if (!aInitialDir.IsEmpty()) {
- ofn.lpstrInitialDir = aInitialDir.get();
- }
-
- AutoDestroyTmpWindow adtw((HWND) (mParentWidget.get() ?
- mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW) : nullptr));
-
- ofn.lpstrTitle = (LPCWSTR)mTitle.get();
- ofn.lpstrFilter = (LPCWSTR)filterBuffer.get();
- ofn.nFilterIndex = mSelectedType;
- ofn.lpstrFile = fileBuffer.get();
- ofn.nMaxFile = FILE_BUFFER_SIZE;
- ofn.hwndOwner = adtw.get();
- ofn.lCustData = reinterpret_cast<LPARAM>(this);
- ofn.Flags = OFN_SHAREAWARE | OFN_LONGNAMES | OFN_OVERWRITEPROMPT |
- OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_ENABLESIZING |
- OFN_EXPLORER;
-
- // Windows Vista and up won't allow you to use the new looking dialogs with
- // a hook procedure. The hook procedure fixes a problem on XP dialogs for
- // file picker visibility. Vista and up automatically ensures the file
- // picker is always visible.
- if (!IsVistaOrLater()) {
- ofn.lpfnHook = FilePickerHook;
- ofn.Flags |= OFN_ENABLEHOOK;
- }
-
- // Handle add to recent docs settings
- if (IsPrivacyModeEnabled() || !mAddToRecentDocs) {
- ofn.Flags |= OFN_DONTADDTORECENT;
- }
-
- NS_NAMED_LITERAL_STRING(htmExt, "html");
-
- if (!mDefaultExtension.IsEmpty()) {
- ofn.lpstrDefExt = mDefaultExtension.get();
- } else if (IsDefaultPathHtml()) {
- // Get file extension from suggested filename to detect if we are
- // saving an html file.
- // This is supposed to append ".htm" if user doesn't supply an
- // extension but the behavior is sort of weird:
- // - Often appends ".html" even if you have an extension
- // - It obeys your extension if you put quotes around name
- ofn.lpstrDefExt = htmExt.get();
- }
-
- // When possible, instead of using OFN_NOCHANGEDIR to ensure the current
- // working directory will not change from this call, we will retrieve the
- // current working directory before the call and restore it after the
- // call. This flag causes problems on Windows XP for paths that are
- // selected like C:test.txt where the user is currently at C:\somepath
- // In which case expected result should be C:\somepath\test.txt
- AutoRestoreWorkingPath restoreWorkingPath;
- // If we can't get the current working directory, the best case is to
- // use the OFN_NOCHANGEDIR flag
- if (!restoreWorkingPath.HasWorkingPath()) {
- ofn.Flags |= OFN_NOCHANGEDIR;
- }
-
- bool result = false;
-
- switch(mMode) {
- case modeOpen:
- // FILE MUST EXIST!
- ofn.Flags |= OFN_FILEMUSTEXIST;
- result = FilePickerWrapper(&ofn, PICKER_TYPE_OPEN);
- break;
-
- case modeOpenMultiple:
- ofn.Flags |= OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT;
-
- // The hook set here ensures that the buffer returned will always be
- // large enough to hold all selected files. The hook may modify the
- // value of ofn.lpstrFile and deallocate the old buffer that it pointed
- // to (fileBuffer). The hook assumes that the passed in value is heap
- // allocated and that the returned value should be freed by the caller.
- // If the hook changes the buffer, it will deallocate the old buffer.
- // This fix would be nice to have in Vista and up, but it would force
- // the file picker to use the old style dialogs because hooks are not
- // allowed in the new file picker UI. We need to eventually move to
- // the new Common File Dialogs for Vista and up.
- if (!IsVistaOrLater()) {
- ofn.lpfnHook = MultiFilePickerHook;
- fileBuffer.release();
- result = FilePickerWrapper(&ofn, PICKER_TYPE_OPEN);
- fileBuffer.reset(ofn.lpstrFile);
- } else {
- result = FilePickerWrapper(&ofn, PICKER_TYPE_OPEN);
- }
- break;
-
- case modeSave:
- {
- ofn.Flags |= OFN_NOREADONLYRETURN;
-
- // Don't follow shortcuts when saving a shortcut, this can be used
- // to trick users (bug 271732)
- if (IsDefaultPathLink())
- ofn.Flags |= OFN_NODEREFERENCELINKS;
-
- result = FilePickerWrapper(&ofn, PICKER_TYPE_SAVE);
- if (!result) {
- // Error, find out what kind.
- if (GetLastError() == ERROR_INVALID_PARAMETER ||
- CommDlgExtendedError() == FNERR_INVALIDFILENAME) {
- // Probably the default file name is too long or contains illegal
- // characters. Try again, without a starting file name.
- ofn.lpstrFile[0] = L'\0';
- result = FilePickerWrapper(&ofn, PICKER_TYPE_SAVE);
- }
- }
- }
- break;
-
- default:
- NS_NOTREACHED("unsupported file picker mode");
- return false;
- }
-
- if (!result)
- return false;
-
- // Remember what filter type the user selected
- mSelectedType = (int16_t)ofn.nFilterIndex;
-
- // Single file selection, we're done
- if (mMode != modeOpenMultiple) {
- GetQualifiedPath(fileBuffer.get(), mUnicodeFile);
- return true;
- }
-
- // Set user-selected location of file or directory. From msdn's "Open and
- // Save As Dialog Boxes" section:
- // If you specify OFN_EXPLORER, the directory and file name strings are '\0'
- // separated, with an extra '\0' character after the last file name. This
- // format enables the Explorer-style dialog boxes to return long file names
- // that include spaces.
- wchar_t *current = fileBuffer.get();
-
- nsAutoString dirName(current);
- // Sometimes dirName contains a trailing slash and sometimes it doesn't:
- if (current[dirName.Length() - 1] != '\\')
- dirName.Append((char16_t)'\\');
-
- while (current && *current && *(current + wcslen(current) + 1)) {
- current = current + wcslen(current) + 1;
-
- nsCOMPtr<nsIFile> file = do_CreateInstance("@mozilla.org/file/local;1");
- NS_ENSURE_TRUE(file, false);
-
- // Only prepend the directory if the path specified is a relative path
- nsAutoString path;
- if (PathIsRelativeW(current)) {
- path = dirName + nsDependentString(current);
- } else {
- path = current;
- }
-
- nsAutoString canonicalizedPath;
- GetQualifiedPath(path.get(), canonicalizedPath);
- if (NS_FAILED(file->InitWithPath(canonicalizedPath)) ||
- !mFiles.AppendObject(file))
- return false;
- }
-
- // Handle the case where the user selected just one file. From msdn: If you
- // specify OFN_ALLOWMULTISELECT and the user selects only one file the
- // lpstrFile string does not have a separator between the path and file name.
- if (current && *current && (current == fileBuffer.get())) {
- nsCOMPtr<nsIFile> file = do_CreateInstance("@mozilla.org/file/local;1");
- NS_ENSURE_TRUE(file, false);
-
- nsAutoString canonicalizedPath;
- GetQualifiedPath(current, canonicalizedPath);
- if (NS_FAILED(file->InitWithPath(canonicalizedPath)) ||
- !mFiles.AppendObject(file))
- return false;
- }
-
- return true;
-}
-
/*
- * Show a file picker post Windows XP
- *
+ * Show a file picker.
+ *
* @param aInitialDir The initial directory, the last used directory will be
* used if left blank.
- * @param aWasInitError Out parameter will hold true if there was an error
- * before the file picker is shown.
* @return true if a file was selected successfully.
*/
bool
-nsFilePicker::ShowFilePicker(const nsString& aInitialDir, bool &aWasInitError)
+nsFilePicker::ShowFilePicker(const nsString& aInitialDir)
{
PROFILER_LABEL_FUNC(js::ProfileEntry::Category::OTHER);
@@ -902,18 +442,15 @@ nsFilePicker::ShowFilePicker(const nsString& aInitialDir, bool &aWasInitError)
if (FAILED(CoCreateInstance(CLSID_FileOpenDialog, nullptr, CLSCTX_INPROC,
IID_IFileOpenDialog,
getter_AddRefs(dialog)))) {
- aWasInitError = true;
return false;
}
} else {
if (FAILED(CoCreateInstance(CLSID_FileSaveDialog, nullptr, CLSCTX_INPROC,
IID_IFileSaveDialog,
getter_AddRefs(dialog)))) {
- aWasInitError = true;
return false;
}
}
- aWasInitError = false;
// hook up event callbacks
dialog->Advise(this, &mFDECookie);
@@ -1080,22 +617,11 @@ nsFilePicker::ShowW(int16_t *aReturnVal)
// with our context set temporarily to system-dpi-aware
WinUtils::AutoSystemDpiAware dpiAwareness;
- // Launch the XP file/folder picker on XP and as a fallback on Vista+.
- // The CoCreateInstance call to CLSID_FileOpenDialog fails with "(0x80040111)
- // ClassFactory cannot supply requested class" when the checkbox for
- // Disable Visual Themes is on in the compatability tab within the shortcut
- // properties.
- bool result = false, wasInitError = true;
+ bool result = false;
if (mMode == modeGetFolder) {
- if (IsVistaOrLater())
- result = ShowFolderPicker(initialDir, wasInitError);
- if (!result && wasInitError)
- result = ShowXPFolderPicker(initialDir);
+ result = ShowFolderPicker(initialDir);
} else {
- if (IsVistaOrLater())
- result = ShowFilePicker(initialDir, wasInitError);
- if (!result && wasInitError)
- result = ShowXPFilePicker(initialDir);
+ result = ShowFilePicker(initialDir);
}
// exit, and return returnCancel in aReturnVal
@@ -1247,48 +773,10 @@ nsFilePicker::InitNative(nsIWidget *aParent,
mTitle.Assign(aTitle);
}
-void
-nsFilePicker::GetQualifiedPath(const wchar_t *aInPath, nsString &aOutPath)
-{
- // Prefer a qualified path over a non qualified path.
- // Things like c:file.txt would be accepted in Win XP but would later
- // fail to open from the download manager.
- wchar_t qualifiedFileBuffer[MAX_PATH];
- if (PathSearchAndQualifyW(aInPath, qualifiedFileBuffer, MAX_PATH)) {
- aOutPath.Assign(qualifiedFileBuffer);
- } else {
- aOutPath.Assign(aInPath);
- }
-}
-
-void
-nsFilePicker::AppendXPFilter(const nsAString& aTitle, const nsAString& aFilter)
-{
- mFilterList.Append(aTitle);
- mFilterList.Append(char16_t('\0'));
-
- if (aFilter.EqualsLiteral("..apps"))
- mFilterList.AppendLiteral("*.exe;*.com");
- else
- {
- nsAutoString filter(aFilter);
- filter.StripWhitespace();
- if (filter.EqualsLiteral("*"))
- filter.AppendLiteral(".*");
- mFilterList.Append(filter);
- }
-
- mFilterList.Append(char16_t('\0'));
-}
-
NS_IMETHODIMP
nsFilePicker::AppendFilter(const nsAString& aTitle, const nsAString& aFilter)
{
- if (IsVistaOrLater()) {
- mComFilterList.Append(aTitle, aFilter);
- } else {
- AppendXPFilter(aTitle, aFilter);
- }
+ mComFilterList.Append(aTitle, aFilter);
return NS_OK;
}
diff --git a/widget/windows/nsFilePicker.h b/widget/windows/nsFilePicker.h
index 90d8c15bc..740f07a7d 100644
--- a/widget/windows/nsFilePicker.h
+++ b/widget/windows/nsFilePicker.h
@@ -9,17 +9,6 @@
#include <windows.h>
-// For Vista IFileDialog interfaces which aren't exposed
-// unless _WIN32_WINNT >= _WIN32_WINNT_LONGHORN.
-#if _WIN32_WINNT < _WIN32_WINNT_LONGHORN
-#define _WIN32_WINNT_bak _WIN32_WINNT
-#undef _WIN32_WINNT
-#define _WIN32_WINNT _WIN32_WINNT_LONGHORN
-#define _WIN32_IE_bak _WIN32_IE
-#undef _WIN32_IE
-#define _WIN32_IE _WIN32_IE_IE70
-#endif
-
#include "nsIFile.h"
#include "nsITimer.h"
#include "nsISimpleEnumerator.h"
@@ -87,32 +76,19 @@ public:
HRESULT STDMETHODCALLTYPE OnOverwrite(IFileDialog *pfd, IShellItem *psi, FDE_OVERWRITE_RESPONSE *pResponse);
protected:
- enum PickerType {
- PICKER_TYPE_OPEN,
- PICKER_TYPE_SAVE,
- };
-
/* method from nsBaseFilePicker */
virtual void InitNative(nsIWidget *aParent,
const nsAString& aTitle);
- static void GetQualifiedPath(const wchar_t *aInPath, nsString &aOutPath);
void GetFilterListArray(nsString& aFilterList);
- static bool GetFileNameWrapper(OPENFILENAMEW* ofn, PickerType aType);
- bool FilePickerWrapper(OPENFILENAMEW* ofn, PickerType aType);
- bool ShowXPFolderPicker(const nsString& aInitialDir);
- bool ShowXPFilePicker(const nsString& aInitialDir);
- bool ShowFolderPicker(const nsString& aInitialDir, bool &aWasInitError);
- bool ShowFilePicker(const nsString& aInitialDir, bool &aWasInitError);
- void AppendXPFilter(const nsAString& aTitle, const nsAString& aFilter);
+ bool ShowFolderPicker(const nsString& aInitialDir);
+ bool ShowFilePicker(const nsString& aInitialDir);
void RememberLastUsedDirectory();
bool IsPrivacyModeEnabled();
bool IsDefaultPathLink();
bool IsDefaultPathHtml();
void SetDialogHandle(HWND aWnd);
- bool ClosePickerIfNeeded(bool aIsXPDialog);
+ bool ClosePickerIfNeeded();
static void PickerCallbackTimerFunc(nsITimer *aTimer, void *aPicker);
- static UINT_PTR CALLBACK MultiFilePickerHook(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
- static UINT_PTR CALLBACK FilePickerHook(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
nsCOMPtr<nsILoadContext> mLoadContext;
nsCOMPtr<nsIWidget> mParentWidget;
@@ -154,11 +130,4 @@ protected:
DWORD mFDECookie;
};
-#if defined(_WIN32_WINNT_bak)
-#undef _WIN32_WINNT
-#define _WIN32_WINNT _WIN32_WINNT_bak
-#undef _WIN32_IE
-#define _WIN32_IE _WIN32_IE_bak
-#endif
-
#endif // nsFilePicker_h__
diff --git a/widget/windows/nsLookAndFeel.cpp b/widget/windows/nsLookAndFeel.cpp
index 7c427ac9f..06eee3771 100644
--- a/widget/windows/nsLookAndFeel.cpp
+++ b/widget/windows/nsLookAndFeel.cpp
@@ -32,12 +32,8 @@ nsLookAndFeel::GetOperatingSystemVersion()
version = eOperatingSystemVersion_Windows10;
} else if (IsWin8OrLater()) {
version = eOperatingSystemVersion_Windows8;
- } else if (IsWin7OrLater()) {
- version = eOperatingSystemVersion_Windows7;
- } else if (IsVistaOrLater()) {
- version = eOperatingSystemVersion_WindowsVista;
} else {
- version = eOperatingSystemVersion_WindowsXP;
+ version = eOperatingSystemVersion_Windows7;
}
return version;
@@ -183,8 +179,7 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
idx = COLOR_HIGHLIGHT;
break;
case eColorID__moz_menubarhovertext:
- if (!IsVistaOrLater() || !IsAppThemed())
- {
+ if (!IsAppThemed()) {
idx = nsUXThemeData::sFlatMenus ?
COLOR_HIGHLIGHTTEXT :
COLOR_MENUTEXT;
@@ -192,8 +187,7 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
}
// Fall through
case eColorID__moz_menuhovertext:
- if (IsVistaOrLater() && IsAppThemed())
- {
+ if (IsAppThemed()) {
res = ::GetColorFromTheme(eUXMenu,
MENU_POPUPITEM, MPI_HOT, TMT_TEXTCOLOR, aColor);
if (NS_SUCCEEDED(res))
@@ -267,8 +261,25 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
case eColorID__moz_cellhighlight:
idx = COLOR_3DFACE;
break;
+ case eColorID__moz_win_accentcolor:
+ res = GetAccentColor(aColor);
+ if (NS_SUCCEEDED(res)) {
+ return res;
+ }
+ NS_WARNING("Using fallback for accent color - UI code failed to use the "
+ "-moz-windows-accent-color-applies media query properly");
+ // Seems to be the default color (hardcoded because of bug 1065998)
+ aColor = NS_RGB(158, 158, 158);
+ return NS_OK;
+ case eColorID__moz_win_accentcolortext:
+ res = GetAccentColorText(aColor);
+ if (NS_SUCCEEDED(res)) {
+ return res;
+ }
+ aColor = NS_RGB(0, 0, 0);
+ return NS_OK;
case eColorID__moz_win_mediatext:
- if (IsVistaOrLater() && IsAppThemed()) {
+ if (IsAppThemed()) {
res = ::GetColorFromTheme(eUXMediaToolbar,
TP_BUTTON, TS_NORMAL, TMT_TEXTCOLOR, aColor);
if (NS_SUCCEEDED(res))
@@ -278,8 +289,7 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
idx = COLOR_WINDOWTEXT;
break;
case eColorID__moz_win_communicationstext:
- if (IsVistaOrLater() && IsAppThemed())
- {
+ if (IsAppThemed()) {
res = ::GetColorFromTheme(eUXCommunicationsToolbar,
TP_BUTTON, TS_NORMAL, TMT_TEXTCOLOR, aColor);
if (NS_SUCCEEDED(res))
@@ -419,6 +429,20 @@ nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult)
case eIntID_DWMCompositor:
aResult = nsUXThemeData::CheckForCompositor();
break;
+ case eIntID_WindowsAccentColorApplies:
+ {
+ nscolor unused;
+ aResult = NS_SUCCEEDED(GetAccentColor(unused)) ? 1 : 0;
+ }
+ break;
+ case eIntID_WindowsAccentColorIsDark:
+ {
+ nscolor accentColor;
+ if (NS_SUCCEEDED(GetAccentColor(accentColor))) {
+ aResult = AccentColorIsDark(accentColor) ? 1 : 0;
+ }
+ }
+ break;
case eIntID_WindowsGlass:
// Aero Glass is only available prior to Windows 8 when DWM is used.
aResult = (nsUXThemeData::CheckForCompositor() && !IsWin8OrLater());
@@ -699,3 +723,72 @@ nsLookAndFeel::SetIntCacheImpl(const nsTArray<LookAndFeelInt>& aLookAndFeelIntCa
}
}
+/* static */ nsresult
+nsLookAndFeel::GetAccentColor(nscolor& aColor)
+{
+ nsresult rv;
+
+ if (!mDwmKey) {
+ mDwmKey = do_CreateInstance("@mozilla.org/windows-registry-key;1", &rv);
+ if (NS_WARN_IF(NS_FAILED(rv))) {
+ return rv;
+ }
+ }
+
+ rv = mDwmKey->Open(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER,
+ NS_LITERAL_STRING("SOFTWARE\\Microsoft\\Windows\\DWM"),
+ nsIWindowsRegKey::ACCESS_QUERY_VALUE);
+ if (NS_WARN_IF(NS_FAILED(rv))) {
+ return rv;
+ }
+
+ // The ColorPrevalence value is set to 1 when the "Show color on title bar"
+ // setting in the Color section of Window's Personalization settings is
+ // turned on.
+ uint32_t accentColor, colorPrevalence;
+ if (NS_SUCCEEDED(mDwmKey->ReadIntValue(NS_LITERAL_STRING("AccentColor"), &accentColor)) &&
+ NS_SUCCEEDED(mDwmKey->ReadIntValue(NS_LITERAL_STRING("ColorPrevalence"), &colorPrevalence)) &&
+ colorPrevalence == 1) {
+ // The order of the color components in the DWORD stored in the registry
+ // happens to be the same order as we store the components in nscolor
+ // so we can just assign directly here.
+ aColor = accentColor;
+ rv = NS_OK;
+ } else {
+ rv = NS_ERROR_NOT_AVAILABLE;
+ }
+
+ mDwmKey->Close();
+
+ return rv;
+}
+
+bool
+nsLookAndFeel::AccentColorIsDark(nscolor aColor)
+{
+ float luminance = (NS_GET_R(aColor) * 2 +
+ NS_GET_G(aColor) * 5 +
+ NS_GET_B(aColor)) / 8;
+
+ return luminance <= 128;
+}
+
+/* static */ nsresult
+nsLookAndFeel::GetAccentColorText(nscolor& aColor)
+{
+ nscolor accentColor;
+ nsresult rv = GetAccentColor(accentColor);
+ if (NS_WARN_IF(NS_FAILED(rv))) {
+ return rv;
+ }
+
+ // We want the color that we return for text that will be drawn over
+ // a background that has the accent color to have good contrast with
+ // the accent color. Windows itself uses either white or black text
+ // depending on how light or dark the accent color is. We do the same
+ // here based on the luminance of the accent color.
+
+ aColor = AccentColorIsDark(accentColor) ? NS_RGB(255, 255, 255) : NS_RGB(0, 0, 0);
+
+ return NS_OK;
+}
diff --git a/widget/windows/nsLookAndFeel.h b/widget/windows/nsLookAndFeel.h
index bc2d158b6..a77808322 100644
--- a/widget/windows/nsLookAndFeel.h
+++ b/widget/windows/nsLookAndFeel.h
@@ -5,7 +5,9 @@
#ifndef __nsLookAndFeel
#define __nsLookAndFeel
+
#include "nsXPLookAndFeel.h"
+#include "nsIWindowsRegKey.h"
/*
* Gesture System Metrics
@@ -27,18 +29,6 @@
#ifndef SM_SYSTEMDOCKED
#define SM_CONVERTIBLESLATEMODE 0x00002003
#define SM_SYSTEMDOCKED 0x00002004
-typedef enum _AR_STATE
-{
- AR_ENABLED = 0x0,
- AR_DISABLED = 0x1,
- AR_SUPPRESSED = 0x2,
- AR_REMOTESESSION = 0x4,
- AR_MULTIMON = 0x8,
- AR_NOSENSOR = 0x10,
- AR_NOT_SUPPORTED = 0x20,
- AR_DOCKED = 0x40,
- AR_LAPTOP = 0x80
-} AR_STATE, *PAR_STATE;
#endif
class nsLookAndFeel: public nsXPLookAndFeel {
@@ -59,7 +49,33 @@ public:
virtual void SetIntCacheImpl(const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache);
private:
+ /**
+ * Fetches the Windows accent color from the Windows settings if
+ * the accent color is set to apply to the title bar, otherwise
+ * returns an error code.
+ */
+ nsresult GetAccentColor(nscolor& aColor);
+
+ /**
+ * Determines whether the Windows accent color is considered dark
+ * with a threshhold value and formula that are specified in the
+ * UWP guidelines.
+ * See: https://docs.microsoft.com/en-us/windows/uwp/style/color
+ */
+ bool AccentColorIsDark(nscolor aColor);
+
+ /**
+ * If the Windows accent color from the Windows settings is set
+ * to apply to the title bar, this computes the color that should
+ * be used for text that is to be written over a background that has
+ * the accent color. Otherwise, (if the accent color should not
+ * apply to the title bar) this returns an error code.
+ */
+ nsresult GetAccentColorText(nscolor& aColor);
+
int32_t mUseAccessibilityTheme;
+
+ nsCOMPtr<nsIWindowsRegKey> mDwmKey;
};
#endif
diff --git a/widget/windows/nsNativeThemeWin.cpp b/widget/windows/nsNativeThemeWin.cpp
index 4ff6b0af9..8950dcf90 100644
--- a/widget/windows/nsNativeThemeWin.cpp
+++ b/widget/windows/nsNativeThemeWin.cpp
@@ -39,7 +39,6 @@
#include "nsUXThemeConstants.h"
#include <algorithm>
-using mozilla::IsVistaOrLater;
using namespace mozilla;
using namespace mozilla::widget;
@@ -301,10 +300,6 @@ DrawThemeBGRTLAware(HANDLE aTheme, HDC aHdc, int aPart, int aState,
* aero basic max 0 2 1 2
* aero basic close 1 2 1 2
*
- * xp theme min 0 2 0 2
- * xp theme max 0 2 1 2
- * xp theme close 1 2 2 2
- *
* 'cold' button padding - generic button padding, should
* be handled in css.
* left top right bottom
@@ -315,16 +310,11 @@ DrawThemeBGRTLAware(HANDLE aTheme, HDC aHdc, int aPart, int aState,
* aero basic min 0 0 1 0
* aero basic max 1 0 0 0
* aero basic close 0 0 0 0
- *
- * xp theme min 0 0 1 0
- * xp theme max 1 0 0 0
- * xp theme close 0 0 0 0
*/
enum CaptionDesktopTheme {
CAPTION_CLASSIC = 0,
CAPTION_BASIC,
- CAPTION_XPTHEME,
};
enum CaptionButton {
@@ -358,8 +348,6 @@ AddPaddingRect(LayoutDeviceIntSize* aSize, CaptionButton button) {
RECT offset;
if (!IsAppThemed())
offset = buttonData[CAPTION_CLASSIC].hotPadding[button];
- else if (!IsVistaOrLater())
- offset = buttonData[CAPTION_XPTHEME].hotPadding[button];
else
offset = buttonData[CAPTION_BASIC].hotPadding[button];
aSize->width += offset.left + offset.right;
@@ -373,8 +361,6 @@ OffsetBackgroundRect(RECT& rect, CaptionButton button) {
RECT offset;
if (!IsAppThemed())
offset = buttonData[CAPTION_CLASSIC].hotPadding[button];
- else if (!IsVistaOrLater())
- offset = buttonData[CAPTION_XPTHEME].hotPadding[button];
else
offset = buttonData[CAPTION_BASIC].hotPadding[button];
rect.left += offset.left;
@@ -419,9 +405,7 @@ OffsetBackgroundRect(RECT& rect, CaptionButton button) {
static const double kProgressDeterminateTimeSpan = 3.0;
static const double kProgressIndeterminateTimeSpan = 5.0;
// The width of the overlay used to animate the horizontal progress bar (Vista and later).
-static const int32_t kProgressHorizontalVistaOverlaySize = 120;
-// The width of the overlay used for the horizontal indeterminate progress bars on XP.
-static const int32_t kProgressHorizontalXPOverlaySize = 55;
+static const int32_t kProgressHorizontalOverlaySize = 120;
// The height of the overlay used to animate the vertical progress bar (Vista and later).
static const int32_t kProgressVerticalOverlaySize = 45;
// The height of the overlay used for the vertical indeterminate progress bar (Vista and later).
@@ -435,18 +419,8 @@ static const int32_t kProgressClassicOverlaySize = 40;
*/
static int32_t
GetProgressOverlayStyle(bool aIsVertical)
-{
- if (aIsVertical) {
- if (IsVistaOrLater()) {
- return PP_MOVEOVERLAYVERT;
- }
- return PP_CHUNKVERT;
- } else {
- if (IsVistaOrLater()) {
- return PP_MOVEOVERLAY;
- }
- return PP_CHUNK;
- }
+{
+ return aIsVertical ? PP_MOVEOVERLAYVERT : PP_MOVEOVERLAY;
}
/*
@@ -457,14 +431,11 @@ GetProgressOverlayStyle(bool aIsVertical)
static int32_t
GetProgressOverlaySize(bool aIsVertical, bool aIsIndeterminate)
{
- if (IsVistaOrLater()) {
- if (aIsVertical) {
- return aIsIndeterminate ? kProgressVerticalIndeterminateOverlaySize
- : kProgressVerticalOverlaySize;
- }
- return kProgressHorizontalVistaOverlaySize;
+ if (aIsVertical) {
+ return aIsIndeterminate ? kProgressVerticalIndeterminateOverlaySize
+ : kProgressVerticalOverlaySize;
}
- return kProgressHorizontalXPOverlaySize;
+ return kProgressHorizontalOverlaySize;
}
/*
@@ -554,87 +525,6 @@ nsNativeThemeWin::CalculateProgressOverlayRect(nsIFrame* aFrame,
}
/*
- * DrawChunkProgressMeter - renders an xp style chunked progress meter. Called
- * by DrawProgressMeter.
- *
- * @param aTheme progress theme handle
- * @param aHdc hdc returned by gfxWindowsNativeDrawing
- * @param aPart the PP_X progress part
- * @param aState the theme state
- * @param aFrame the elements frame
- * @param aWidgetRect bounding rect for the widget
- * @param aClipRect dirty rect that needs drawing.
- * @param aAppUnits app units per device pixel
- * @param aIsIndeterm is an indeterminate progress?
- * @param aIsVertical render a vertical progress?
- * @param aIsRtl direction is rtl
- */
-static void
-DrawChunkProgressMeter(HTHEME aTheme, HDC aHdc, int aPart,
- int aState, nsIFrame* aFrame, RECT* aWidgetRect,
- RECT* aClipRect, gfxFloat aAppUnits, bool aIsIndeterm,
- bool aIsVertical, bool aIsRtl)
-{
- NS_ASSERTION(aTheme, "Bad theme.");
- NS_ASSERTION(aHdc, "Bad hdc.");
- NS_ASSERTION(aWidgetRect, "Bad rect.");
- NS_ASSERTION(aClipRect, "Bad clip rect.");
- NS_ASSERTION(aFrame, "Bad frame.");
-
- // For horizontal meters, the theme lib paints the right graphic but doesn't
- // paint the chunks, so we do that manually. For vertical meters, the theme
- // library draws everything correctly.
- if (aIsVertical) {
- DrawThemeBackground(aTheme, aHdc, aPart, aState, aWidgetRect, aClipRect);
- return;
- }
-
- // query for the proper chunk metrics
- int chunkSize, spaceSize;
- if (FAILED(GetThemeMetric(aTheme, aHdc, aPart, aState,
- TMT_PROGRESSCHUNKSIZE, &chunkSize)) ||
- FAILED(GetThemeMetric(aTheme, aHdc, aPart, aState,
- TMT_PROGRESSSPACESIZE, &spaceSize))) {
- DrawThemeBackground(aTheme, aHdc, aPart, aState, aWidgetRect, aClipRect);
- return;
- }
-
- // render chunks
- if (!aIsRtl || aIsIndeterm) {
- for (int chunk = aWidgetRect->left; chunk <= aWidgetRect->right;
- chunk += (chunkSize+spaceSize)) {
- if (!aIsIndeterm && ((chunk + chunkSize) > aWidgetRect->right)) {
- // aWidgetRect->right represents the end of the meter. Partial blocks
- // don't get rendered with one exception, so exit here if we don't have
- // a full chunk to draw.
- // The above is true *except* when the meter is at 100% fill, in which
- // case Windows renders any remaining partial block. Query the parent
- // frame to find out if we're at 100%.
- if (!IsProgressMeterFilled(aFrame)) {
- break;
- }
- }
- RECT bounds =
- { chunk, aWidgetRect->top, chunk + chunkSize, aWidgetRect->bottom };
- DrawThemeBackground(aTheme, aHdc, aPart, aState, &bounds, aClipRect);
- }
- } else {
- // rtl needs to grow in the opposite direction to look right.
- for (int chunk = aWidgetRect->right; chunk >= aWidgetRect->left;
- chunk -= (chunkSize+spaceSize)) {
- if ((chunk - chunkSize) < aWidgetRect->left) {
- if (!IsProgressMeterFilled(aFrame)) {
- break;
- }
- }
- RECT bounds =
- { chunk - chunkSize, aWidgetRect->top, chunk, aWidgetRect->bottom };
- DrawThemeBackground(aTheme, aHdc, aPart, aState, &bounds, aClipRect);
- }
- }
-}
-
-/*
* DrawProgressMeter - render an appropriate progress meter based on progress
* meter style, orientation, and os. Note, this does not render the underlying
* progress track.
@@ -653,8 +543,7 @@ void
nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType,
HANDLE aTheme, HDC aHdc,
int aPart, int aState,
- RECT* aWidgetRect, RECT* aClipRect,
- gfxFloat aAppUnits)
+ RECT* aWidgetRect, RECT* aClipRect)
{
if (!aFrame || !aTheme || !aHdc)
return;
@@ -665,12 +554,6 @@ nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType,
RECT adjWidgetRect, adjClipRect;
adjWidgetRect = *aWidgetRect;
adjClipRect = *aClipRect;
- if (!IsVistaOrLater()) {
- // Adjust clipping out by one pixel. XP progress meters are inset,
- // Vista+ are not.
- InflateRect(&adjWidgetRect, 1, 1);
- InflateRect(&adjClipRect, 1, 1);
- }
nsIFrame* parentFrame = aFrame->GetParent();
if (!parentFrame) {
@@ -685,20 +568,13 @@ nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType,
bool indeterminate = IsIndeterminateProgress(parentFrame, eventStates);
bool animate = indeterminate;
- if (IsVistaOrLater()) {
- // Vista and up progress meter is fill style, rendered here. We render
- // the pulse overlay in the follow up section below.
- DrawThemeBackground(aTheme, aHdc, aPart, aState,
- &adjWidgetRect, &adjClipRect);
- if (!IsProgressMeterFilled(aFrame)) {
- animate = true;
- }
- } else if (!indeterminate) {
- // XP progress meters are 'chunk' style.
- DrawChunkProgressMeter(aTheme, aHdc, aPart, aState, aFrame,
- &adjWidgetRect, &adjClipRect, aAppUnits,
- indeterminate, vertical, IsFrameRTL(aFrame));
- }
+ // Vista and up progress meter is fill style, rendered here. We render
+ // the pulse overlay in the follow up section below.
+ DrawThemeBackground(aTheme, aHdc, aPart, aState,
+ &adjWidgetRect, &adjClipRect);
+ if (!IsProgressMeterFilled(aFrame)) {
+ animate = true;
+ }
if (animate) {
// Indeterminate rendering
@@ -706,14 +582,8 @@ nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType,
RECT overlayRect =
CalculateProgressOverlayRect(aFrame, &adjWidgetRect, vertical,
indeterminate, false);
- if (IsVistaOrLater()) {
- DrawThemeBackground(aTheme, aHdc, overlayPart, aState, &overlayRect,
- &adjClipRect);
- } else {
- DrawChunkProgressMeter(aTheme, aHdc, overlayPart, aState, aFrame,
- &overlayRect, &adjClipRect, aAppUnits,
- indeterminate, vertical, IsFrameRTL(aFrame));
- }
+ DrawThemeBackground(aTheme, aHdc, overlayPart, aState, &overlayRect,
+ &adjClipRect);
if (!QueueAnimatedContentForRefresh(aFrame->GetContent(), 60)) {
NS_WARNING("unable to animate progress widget!");
@@ -724,15 +594,6 @@ nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType,
HANDLE
nsNativeThemeWin::GetTheme(uint8_t aWidgetType)
{
- if (!IsVistaOrLater()) {
- // On XP or earlier, render dropdowns as textfields;
- // doing it the right way works fine with the MS themes,
- // but breaks on a lot of custom themes (presumably because MS
- // apps do the textfield border business as well).
- if (aWidgetType == NS_THEME_MENULIST)
- aWidgetType = NS_THEME_TEXTFIELD;
- }
-
switch (aWidgetType) {
case NS_THEME_BUTTON:
case NS_THEME_RADIO:
@@ -745,9 +606,7 @@ nsNativeThemeWin::GetTheme(uint8_t aWidgetType)
case NS_THEME_FOCUS_OUTLINE:
return nsUXThemeData::GetTheme(eUXEdit);
case NS_THEME_TOOLTIP:
- // XP/2K3 should force a classic treatment of tooltips
- return !IsVistaOrLater() ?
- nullptr : nsUXThemeData::GetTheme(eUXTooltip);
+ return nsUXThemeData::GetTheme(eUXTooltip);
case NS_THEME_TOOLBOX:
return nsUXThemeData::GetTheme(eUXRebar);
case NS_THEME_WIN_MEDIA_TOOLBOX:
@@ -874,12 +733,6 @@ nsresult
nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType,
int32_t& aPart, int32_t& aState)
{
- if (!IsVistaOrLater()) {
- // See GetTheme
- if (aWidgetType == NS_THEME_MENULIST)
- aWidgetType = NS_THEME_TEXTFIELD;
- }
-
switch (aWidgetType) {
case NS_THEME_BUTTON: {
aPart = BP_BUTTON;
@@ -952,63 +805,43 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType,
case NS_THEME_TEXTFIELD_MULTILINE: {
EventStates eventState = GetContentState(aFrame, aWidgetType);
- if (IsVistaOrLater()) {
- /* Note: the NOSCROLL type has a rounded corner in each
- * corner. The more specific HSCROLL, VSCROLL, HVSCROLL types
- * have side and/or top/bottom edges rendered as straight
- * horizontal lines with sharp corners to accommodate a
- * scrollbar. However, the scrollbar gets rendered on top of
- * this for us, so we don't care, and can just use NOSCROLL
- * here.
- */
- aPart = TFP_EDITBORDER_NOSCROLL;
-
- if (!aFrame) {
- aState = TFS_EDITBORDER_NORMAL;
- } else if (IsDisabled(aFrame, eventState)) {
- aState = TFS_EDITBORDER_DISABLED;
- } else if (IsReadOnly(aFrame)) {
- /* no special read-only state */
- aState = TFS_EDITBORDER_NORMAL;
- } else {
- nsIContent* content = aFrame->GetContent();
+ /* Note: the NOSCROLL type has a rounded corner in each corner. The more
+ * specific HSCROLL, VSCROLL, HVSCROLL types have side and/or top/bottom
+ * edges rendered as straight horizontal lines with sharp corners to
+ * accommodate a scrollbar. However, the scrollbar gets rendered on top
+ * of this for us, so we don't care, and can just use NOSCROLL here.
+ */
+ aPart = TFP_EDITBORDER_NOSCROLL;
- /* XUL textboxes don't get focused themselves, because they have child
- * html:input.. but we can check the XUL focused attributes on them
- */
- if (content && content->IsXULElement() && IsFocused(aFrame))
- aState = TFS_EDITBORDER_FOCUSED;
- else if (eventState.HasAtLeastOneOfStates(NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS))
- aState = TFS_EDITBORDER_FOCUSED;
- else if (eventState.HasState(NS_EVENT_STATE_HOVER))
- aState = TFS_EDITBORDER_HOVER;
- else
- aState = TFS_EDITBORDER_NORMAL;
- }
+ if (!aFrame) {
+ aState = TFS_EDITBORDER_NORMAL;
+ } else if (IsDisabled(aFrame, eventState)) {
+ aState = TFS_EDITBORDER_DISABLED;
+ } else if (IsReadOnly(aFrame)) {
+ /* no special read-only state */
+ aState = TFS_EDITBORDER_NORMAL;
} else {
- aPart = TFP_TEXTFIELD;
-
- if (!aFrame)
- aState = TS_NORMAL;
- else if (IsDisabled(aFrame, eventState))
- aState = TS_DISABLED;
- else if (IsReadOnly(aFrame))
- aState = TFS_READONLY;
+ nsIContent* content = aFrame->GetContent();
+
+ /* XUL textboxes don't get focused themselves, because they have child
+ * html:input.. but we can check the XUL focused attributes on them
+ */
+ if (content && content->IsXULElement() && IsFocused(aFrame))
+ aState = TFS_EDITBORDER_FOCUSED;
+ else if (eventState.HasAtLeastOneOfStates(NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS))
+ aState = TFS_EDITBORDER_FOCUSED;
+ else if (eventState.HasState(NS_EVENT_STATE_HOVER))
+ aState = TFS_EDITBORDER_HOVER;
else
- aState = StandardGetState(aFrame, aWidgetType, true);
+ aState = TFS_EDITBORDER_NORMAL;
}
return NS_OK;
}
case NS_THEME_FOCUS_OUTLINE: {
- if (IsVistaOrLater()) {
- // XXX the EDITBORDER values don't respect DTBG_OMITCONTENT
- aPart = TFP_TEXTFIELD; //TFP_EDITBORDER_NOSCROLL;
- aState = TS_FOCUSED; //TFS_EDITBORDER_FOCUSED;
- } else {
- aPart = TFP_TEXTFIELD;
- aState = TS_FOCUSED;
- }
+ // XXX the EDITBORDER values don't respect DTBG_OMITCONTENT
+ aPart = TFP_TEXTFIELD; //TFP_EDITBORDER_NOSCROLL;
+ aState = TS_FOCUSED; //TFS_EDITBORDER_FOCUSED;
return NS_OK;
}
case NS_THEME_TOOLTIP: {
@@ -1032,11 +865,9 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType,
nsIFrame* parentFrame = aFrame->GetParent();
if (aWidgetType == NS_THEME_PROGRESSCHUNK_VERTICAL ||
IsVerticalProgress(parentFrame)) {
- aPart = IsVistaOrLater() ?
- PP_FILLVERT : PP_CHUNKVERT;
+ aPart = PP_FILLVERT;
} else {
- aPart = IsVistaOrLater() ?
- PP_FILL : PP_CHUNK;
+ aPart = PP_FILL;
}
aState = PBBVS_NORMAL;
@@ -1100,8 +931,7 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType,
aState += TS_ACTIVE;
else if (eventState.HasState(NS_EVENT_STATE_HOVER))
aState += TS_HOVER;
- else if (IsVistaOrLater() &&
- parentState.HasState(NS_EVENT_STATE_HOVER))
+ else if (parentState.HasState(NS_EVENT_STATE_HOVER))
aState = (aWidgetType - NS_THEME_SCROLLBARBUTTON_UP) + SP_BUTTON_IMPLICIT_HOVER_BASE;
else
aState += TS_NORMAL;
@@ -1204,14 +1034,7 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType,
case NS_THEME_SCROLLBAR:
case NS_THEME_SCROLLBAR_SMALL: {
aState = 0;
- if (IsVistaOrLater()) {
- // On vista, they have a part
- aPart = RP_BACKGROUND;
- } else {
- // Otherwise, they don't. (But I bet
- // RP_BACKGROUND would work here, too);
- aPart = 0;
- }
+ aPart = RP_BACKGROUND;
return NS_OK;
}
case NS_THEME_TOOLBAR: {
@@ -1336,8 +1159,7 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType,
aFrame = parentFrame;
EventStates eventState = GetContentState(aFrame, aWidgetType);
- aPart = IsVistaOrLater() ?
- CBP_DROPMARKER_VISTA : CBP_DROPMARKER;
+ aPart = CBP_DROPMARKER_VISTA;
// For HTML controls with author styling, we should fall
// back to the old dropmarker style to avoid clashes with
@@ -1357,28 +1179,25 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType,
else
isOpen = IsOpenButton(aFrame);
- if (IsVistaOrLater()) {
- if (isHTML || IsMenuListEditable(aFrame)) {
- if (isOpen) {
- /* Hover is propagated, but we need to know whether we're
- * hovering just the combobox frame, not the dropdown frame.
- * But, we can't get that information, since hover is on the
- * content node, and they share the same content node. So,
- * instead, we cheat -- if the dropdown is open, we always
- * show the hover state. This looks fine in practice.
- */
- aState = TS_HOVER;
- return NS_OK;
- }
- } else {
- /* On Vista, the dropdown indicator on a menulist button in
- * chrome is not given a hover effect. When the frame isn't
- * isn't HTML content, we cheat and force the dropdown state
- * to be normal. (Bug 430434)
+ if (isHTML || IsMenuListEditable(aFrame)) {
+ if (isOpen) {
+ /* Hover is propagated, but we need to know whether we're hovering
+ * just the combobox frame, not the dropdown frame. But, we can't get
+ * that information, since hover is on the content node, and they
+ * share the same content node. So, instead, we cheat -- if the
+ * dropdown is open, we always show the hover state. This looks fine
+ * in practice.
*/
- aState = TS_NORMAL;
+ aState = TS_HOVER;
return NS_OK;
}
+ } else {
+ /* The dropdown indicator on a menulist button in chrome is not given a
+ * hover effect. When the frame isn't isn't HTML content, we cheat and
+ * force the dropdown state to be normal. (Bug 430434)
+ */
+ aState = TS_NORMAL;
+ return NS_OK;
}
aState = TS_NORMAL;
@@ -1879,7 +1698,7 @@ RENDER_AGAIN:
else if (aWidgetType == NS_THEME_PROGRESSCHUNK ||
aWidgetType == NS_THEME_PROGRESSCHUNK_VERTICAL) {
DrawThemedProgressMeter(aFrame, aWidgetType, theme, hdc, part, state,
- &widgetRect, &clipRect, p2a);
+ &widgetRect, &clipRect);
}
else if (aWidgetType == NS_THEME_FOCUS_OUTLINE) {
// Inflate 'widgetRect' with the focus outline size.
@@ -2145,41 +1964,39 @@ nsNativeThemeWin::GetWidgetPadding(nsDeviceContext* aContext,
return ok;
}
- if (IsVistaOrLater()) {
- if (aWidgetType == NS_THEME_NUMBER_INPUT ||
- aWidgetType == NS_THEME_TEXTFIELD ||
- aWidgetType == NS_THEME_TEXTFIELD_MULTILINE ||
- aWidgetType == NS_THEME_MENULIST)
- {
- /* If we have author-specified padding for these elements, don't do the fixups below */
- if (aFrame->PresContext()->HasAuthorSpecifiedRules(aFrame, NS_AUTHOR_SPECIFIED_PADDING))
- return false;
- }
+ if (aWidgetType == NS_THEME_NUMBER_INPUT ||
+ aWidgetType == NS_THEME_TEXTFIELD ||
+ aWidgetType == NS_THEME_TEXTFIELD_MULTILINE ||
+ aWidgetType == NS_THEME_MENULIST)
+ {
+ // If we have author-specified padding for these elements, don't do the
+ // fixups below.
+ if (aFrame->PresContext()->HasAuthorSpecifiedRules(aFrame, NS_AUTHOR_SPECIFIED_PADDING))
+ return false;
+ }
- /* textfields need extra pixels on all sides, otherwise they
- * wrap their content too tightly. The actual border is drawn 1px
- * inside the specified rectangle, so Gecko will end up making the
- * contents look too small. Instead, we add 2px padding for the
- * contents and fix this. (Used to be 1px added, see bug 430212)
+ /* textfields need extra pixels on all sides, otherwise they wrap their
+ * content too tightly. The actual border is drawn 1px inside the specified
+ * rectangle, so Gecko will end up making the contents look too small.
+ * Instead, we add 2px padding for the contents and fix this. (Used to be 1px
+ * added, see bug 430212)
+ */
+ if (aWidgetType == NS_THEME_NUMBER_INPUT ||
+ aWidgetType == NS_THEME_TEXTFIELD ||
+ aWidgetType == NS_THEME_TEXTFIELD_MULTILINE) {
+ aResult->top = aResult->bottom = 2;
+ aResult->left = aResult->right = 2;
+ ScaleForFrameDPI(aResult, aFrame);
+ return ok;
+ } else if (IsHTMLContent(aFrame) && aWidgetType == NS_THEME_MENULIST) {
+ /* For content menulist controls, we need an extra pixel so that we have
+ * room to draw our focus rectangle stuff. Otherwise, the focus rect might
+ * overlap the control's border.
*/
- if (aWidgetType == NS_THEME_NUMBER_INPUT ||
- aWidgetType == NS_THEME_TEXTFIELD ||
- aWidgetType == NS_THEME_TEXTFIELD_MULTILINE) {
- aResult->top = aResult->bottom = 2;
- aResult->left = aResult->right = 2;
- ScaleForFrameDPI(aResult, aFrame);
- return ok;
- } else if (IsHTMLContent(aFrame) && aWidgetType == NS_THEME_MENULIST) {
- /* For content menulist controls, we need an extra pixel so
- * that we have room to draw our focus rectangle stuff.
- * Otherwise, the focus rect might overlap the control's
- * border.
- */
- aResult->top = aResult->bottom = 1;
- aResult->left = aResult->right = 1;
- ScaleForFrameDPI(aResult, aFrame);
- return ok;
- }
+ aResult->top = aResult->bottom = 1;
+ aResult->left = aResult->right = 1;
+ ScaleForFrameDPI(aResult, aFrame);
+ return ok;
}
int32_t right, left, top, bottom;
@@ -2244,23 +2061,21 @@ nsNativeThemeWin::GetWidgetOverflow(nsDeviceContext* aContext,
* a border only shows up if the widget is being hovered.
*/
#if 0
- if (IsVistaOrLater()) {
- /* We explicitly draw dropdown buttons in HTML content 1px bigger
- * up, right, and bottom so that they overlap the dropdown's border
- * like they're supposed to.
- */
- if (aWidgetType == NS_THEME_MENULIST_BUTTON &&
- IsHTMLContent(aFrame) &&
- !IsWidgetStyled(aFrame->GetParent()->PresContext(),
- aFrame->GetParent(),
- NS_THEME_MENULIST))
- {
- int32_t p2a = aContext->AppUnitsPerDevPixel();
- /* Note: no overflow on the left */
- nsMargin m(p2a, p2a, p2a, 0);
- aOverflowRect->Inflate (m);
- return true;
- }
+ /* We explicitly draw dropdown buttons in HTML content 1px bigger up, right,
+ * and bottom so that they overlap the dropdown's border like they're
+ * supposed to.
+ */
+ if (aWidgetType == NS_THEME_MENULIST_BUTTON &&
+ IsHTMLContent(aFrame) &&
+ !IsWidgetStyled(aFrame->GetParent()->PresContext(),
+ aFrame->GetParent(),
+ NS_THEME_MENULIST))
+ {
+ int32_t p2a = aContext->AppUnitsPerDevPixel();
+ /* Note: no overflow on the left */
+ nsMargin m(p2a, p2a, p2a, 0);
+ aOverflowRect->Inflate (m);
+ return true;
}
#endif
@@ -2384,22 +2199,18 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aF
case NS_THEME_SCALETHUMB_VERTICAL:
{
*aIsOverridable = false;
- // on Vista, GetThemePartAndState returns odd values for
+ // On Vista, GetThemePartAndState returns odd values for
// scale thumbs, so use a hardcoded size instead.
- if (IsVistaOrLater()) {
- if (aWidgetType == NS_THEME_SCALETHUMB_HORIZONTAL ||
- (aWidgetType == NS_THEME_RANGE_THUMB && IsRangeHorizontal(aFrame))) {
- aResult->width = 12;
- aResult->height = 20;
- }
- else {
- aResult->width = 20;
- aResult->height = 12;
- }
- ScaleForFrameDPI(aResult, aFrame);
- return rv;
+ if (aWidgetType == NS_THEME_SCALETHUMB_HORIZONTAL ||
+ (aWidgetType == NS_THEME_RANGE_THUMB && IsRangeHorizontal(aFrame))) {
+ aResult->width = 12;
+ aResult->height = 20;
+ } else {
+ aResult->width = 20;
+ aResult->height = 12;
}
- break;
+ ScaleForFrameDPI(aResult, aFrame);
+ return rv;
}
case NS_THEME_SCROLLBAR:
@@ -2438,11 +2249,6 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aF
// stores that info in nsUXThemeData.
aResult->width = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_RESTORE].cx;
aResult->height = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_RESTORE].cy;
- // For XP, subtract 4 from system metrics dimensions.
- if (!IsVistaOrLater()) {
- aResult->width -= 4;
- aResult->height -= 4;
- }
AddPaddingRect(aResult, CAPTIONBUTTON_RESTORE);
*aIsOverridable = false;
return rv;
@@ -2450,10 +2256,6 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aF
case NS_THEME_WINDOW_BUTTON_MINIMIZE:
aResult->width = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_MINIMIZE].cx;
aResult->height = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_MINIMIZE].cy;
- if (!IsVistaOrLater()) {
- aResult->width -= 4;
- aResult->height -= 4;
- }
AddPaddingRect(aResult, CAPTIONBUTTON_MINIMIZE);
*aIsOverridable = false;
return rv;
@@ -2461,10 +2263,6 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aF
case NS_THEME_WINDOW_BUTTON_CLOSE:
aResult->width = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_CLOSE].cx;
aResult->height = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_CLOSE].cy;
- if (!IsVistaOrLater()) {
- aResult->width -= 4;
- aResult->height -= 4;
- }
AddPaddingRect(aResult, CAPTIONBUTTON_CLOSE);
*aIsOverridable = false;
return rv;
@@ -2594,18 +2392,9 @@ nsNativeThemeWin::WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType,
return NS_OK;
}
- // On Vista, the scrollbar buttons need to change state when the track has/doesn't have hover
- if (!IsVistaOrLater() &&
- (aWidgetType == NS_THEME_SCROLLBAR_VERTICAL ||
- aWidgetType == NS_THEME_SCROLLBAR_HORIZONTAL)) {
- *aShouldRepaint = false;
- return NS_OK;
- }
-
// We need to repaint the dropdown arrow in vista HTML combobox controls when
// the control is closed to get rid of the hover effect.
- if (IsVistaOrLater() &&
- (aWidgetType == NS_THEME_MENULIST || aWidgetType == NS_THEME_MENULIST_BUTTON) &&
+ if ((aWidgetType == NS_THEME_MENULIST || aWidgetType == NS_THEME_MENULIST_BUTTON) &&
IsHTMLContent(aFrame))
{
*aShouldRepaint = true;
diff --git a/widget/windows/nsNativeThemeWin.h b/widget/windows/nsNativeThemeWin.h
index f20649444..32b82b1e1 100644
--- a/widget/windows/nsNativeThemeWin.h
+++ b/widget/windows/nsNativeThemeWin.h
@@ -117,8 +117,7 @@ protected:
void DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType,
HANDLE aTheme, HDC aHdc,
int aPart, int aState,
- RECT* aWidgetRect, RECT* aClipRect,
- gfxFloat aAppUnits);
+ RECT* aWidgetRect, RECT* aClipRect);
private:
TimeStamp mProgressDeterminateTimeStamp;
diff --git a/widget/windows/nsUXThemeConstants.h b/widget/windows/nsUXThemeConstants.h
index 731dcedf2..ba7afde82 100644
--- a/widget/windows/nsUXThemeConstants.h
+++ b/widget/windows/nsUXThemeConstants.h
@@ -67,7 +67,7 @@
#define SP_GRIPPERHOR 8
#define SP_GRIPPERVERT 9
-// Vista only; implict hover state.
+// Implicit hover state.
// BASE + 0 = UP, + 1 = DOWN, etc.
#define SP_BUTTON_IMPLICIT_HOVER_BASE 17
diff --git a/widget/windows/nsUXThemeData.cpp b/widget/windows/nsUXThemeData.cpp
index bcbd32484..4d9ac9570 100644
--- a/widget/windows/nsUXThemeData.cpp
+++ b/widget/windows/nsUXThemeData.cpp
@@ -143,10 +143,8 @@ nsUXThemeData::InitTitlebarInfo()
sCommandButtons[3].cx = sCommandButtons[0].cx * 3;
sCommandButtons[3].cy = sCommandButtons[0].cy;
- // Use system metrics for pre-vista, otherwise trigger a
- // refresh on the next layout.
- sTitlebarInfoPopulatedAero = sTitlebarInfoPopulatedThemed =
- !IsVistaOrLater();
+ // Trigger a refresh on the next layout.
+ sTitlebarInfoPopulatedAero = sTitlebarInfoPopulatedThemed = false;
}
// static
@@ -306,7 +304,7 @@ void
nsUXThemeData::UpdateNativeThemeInfo()
{
// Trigger a refresh of themed button metrics if needed
- sTitlebarInfoPopulatedThemed = !IsVistaOrLater();
+ sTitlebarInfoPopulatedThemed = false;
sIsDefaultWindowsTheme = false;
sThemeId = LookAndFeel::eWindowsTheme_Generic;
diff --git a/widget/windows/nsWinGesture.h b/widget/windows/nsWinGesture.h
index 24c1f6b2d..fdd1588b6 100644
--- a/widget/windows/nsWinGesture.h
+++ b/widget/windows/nsWinGesture.h
@@ -17,155 +17,6 @@
#include "mozilla/EventForwards.h"
#include "mozilla/TouchEvents.h"
-// Desktop builds target apis for 502. Win8 Metro builds target 602.
-#if WINVER < 0x0602
-
-DECLARE_HANDLE(HGESTUREINFO);
-
-/*
- * Gesture flags - GESTUREINFO.dwFlags
- */
-#define GF_BEGIN 0x00000001
-#define GF_INERTIA 0x00000002
-#define GF_END 0x00000004
-
-/*
- * Gesture configuration structure
- * - Used in SetGestureConfig and GetGestureConfig
- * - Note that any setting not included in either GESTURECONFIG.dwWant or
- * GESTURECONFIG.dwBlock will use the parent window's preferences or
- * system defaults.
- */
-typedef struct tagGESTURECONFIG {
- DWORD dwID; // gesture ID
- DWORD dwWant; // settings related to gesture ID that are to be turned on
- DWORD dwBlock; // settings related to gesture ID that are to be turned off
-} GESTURECONFIG, *PGESTURECONFIG;
-
-/*
- * Gesture information structure
- * - Pass the HGESTUREINFO received in the WM_GESTURE message lParam into the
- * GetGestureInfo function to retrieve this information.
- * - If cbExtraArgs is non-zero, pass the HGESTUREINFO received in the WM_GESTURE
- * message lParam into the GetGestureExtraArgs function to retrieve extended
- * argument information.
- */
-typedef struct tagGESTUREINFO {
- UINT cbSize; // size, in bytes, of this structure (including variable length Args field)
- DWORD dwFlags; // see GF_* flags
- DWORD dwID; // gesture ID, see GID_* defines
- HWND hwndTarget; // handle to window targeted by this gesture
- POINTS ptsLocation; // current location of this gesture
- DWORD dwInstanceID; // internally used
- DWORD dwSequenceID; // internally used
- ULONGLONG ullArguments; // arguments for gestures whose arguments fit in 8 BYTES
- UINT cbExtraArgs; // size, in bytes, of extra arguments, if any, that accompany this gesture
-} GESTUREINFO, *PGESTUREINFO;
-typedef GESTUREINFO const * PCGESTUREINFO;
-
-/*
- * Gesture notification structure
- * - The WM_GESTURENOTIFY message lParam contains a pointer to this structure.
- * - The WM_GESTURENOTIFY message notifies a window that gesture recognition is
- * in progress and a gesture will be generated if one is recognized under the
- * current gesture settings.
- */
-typedef struct tagGESTURENOTIFYSTRUCT {
- UINT cbSize; // size, in bytes, of this structure
- DWORD dwFlags; // unused
- HWND hwndTarget; // handle to window targeted by the gesture
- POINTS ptsLocation; // starting location
- DWORD dwInstanceID; // internally used
-} GESTURENOTIFYSTRUCT, *PGESTURENOTIFYSTRUCT;
-
-
-/*
- * Gesture argument helpers
- * - Angle should be a double in the range of -2pi to +2pi
- * - Argument should be an unsigned 16-bit value
- */
-#define GID_ROTATE_ANGLE_TO_ARGUMENT(_arg_) ((USHORT)((((_arg_) + 2.0 * 3.14159265) / (4.0 * 3.14159265)) * 65535.0))
-#define GID_ROTATE_ANGLE_FROM_ARGUMENT(_arg_) ((((double)(_arg_) / 65535.0) * 4.0 * 3.14159265) - 2.0 * 3.14159265)
-
-/*
- * Gesture configuration flags
- */
-#define GC_ALLGESTURES 0x00000001
-
-#define GC_ZOOM 0x00000001
-
-#define GC_PAN 0x00000001
-#define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002
-#define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004
-#define GC_PAN_WITH_GUTTER 0x00000008
-#define GC_PAN_WITH_INERTIA 0x00000010
-
-#define GC_ROTATE 0x00000001
-
-#define GC_TWOFINGERTAP 0x00000001
-
-#define GC_PRESSANDTAP 0x00000001
-
-/*
- * Gesture IDs
- */
-#define GID_BEGIN 1
-#define GID_END 2
-#define GID_ZOOM 3
-#define GID_PAN 4
-#define GID_ROTATE 5
-#define GID_TWOFINGERTAP 6
-#define GID_PRESSANDTAP 7
-
-// Maximum number of gestures that can be included
-// in a single call to SetGestureConfig / GetGestureConfig
-#define GESTURECONFIGMAXCOUNT 256
-
-// If specified, GetGestureConfig returns consolidated configuration
-// for the specified window and it's parent window chain
-#define GCF_INCLUDE_ANCESTORS 0x00000001
-
-// Window events we need to respond to or receive
-#define WM_GESTURE 0x0119
-#define WM_GESTURENOTIFY 0x011A
-
-typedef struct _TOUCHINPUT {
- LONG x;
- LONG y;
- HANDLE hSource;
- DWORD dwID;
- DWORD dwFlags;
- DWORD dwMask;
- DWORD dwTime;
- ULONG_PTR dwExtraInfo;
- DWORD cxContact;
- DWORD cyContact;
-} TOUCHINPUT, *PTOUCHINPUT;
-
-typedef HANDLE HTOUCHINPUT;
-
-#define WM_TOUCH 0x0240
-
-#define TOUCHEVENTF_MOVE 0x0001
-#define TOUCHEVENTF_DOWN 0x0002
-#define TOUCHEVENTF_UP 0x0004
-#define TOUCHEVENTF_INRANGE 0x0008
-#define TOUCHEVENTF_PRIMARY 0x0010
-#define TOUCHEVENTF_NOCOALESCE 0x0020
-#define TOUCHEVENTF_PEN 0x0040
-#define TOUCHEVENTF_PALM 0x0080
-
-#define TOUCHINPUTMASKF_TIMEFROMSYSTEM 0x0001
-#define TOUCHINPUTMASKF_EXTRAINFO 0x0002
-#define TOUCHINPUTMASKF_CONTACTAREA 0x0004
-
-#define TOUCH_COORD_TO_PIXEL(C) (C/100)
-
-#define TWF_FINETOUCH 0x0001
-#define TWF_WANTPALM 0x0002
-
-#endif // WINVER < 0x0602
-
// WM_TABLET_QUERYSYSTEMGESTURESTATUS return values
#define TABLET_ROTATE_GESTURE_ENABLE 0x02000000
@@ -205,7 +56,7 @@ public:
bool GetTouchInputInfo(HTOUCHINPUT hTouchInput, uint32_t cInputs, PTOUCHINPUT pInputs);
bool CloseTouchInputHandle(HTOUCHINPUT hTouchInput);
bool IsAvailable();
-
+
// Simple gesture process
bool ProcessGestureMessage(HWND hWnd, WPARAM wParam, LPARAM lParam, mozilla::WidgetSimpleGestureEvent& evt);
@@ -216,7 +67,7 @@ public:
void UpdatePanFeedbackX(HWND hWnd, int32_t scrollOverflow, bool& endFeedback);
void UpdatePanFeedbackY(HWND hWnd, int32_t scrollOverflow, bool& endFeedback);
void PanFeedbackFinalize(HWND hWnd, bool endFeedback);
-
+
public:
// Helpers
bool GetGestureInfo(HGESTUREINFO hGestureInfo, PGESTUREINFO pGestureInfo);
@@ -284,5 +135,3 @@ private:
};
#endif /* WinGesture_h__ */
-
-
diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp
index 2172f2aa0..b2bb59bd3 100644
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -266,8 +266,7 @@ LONG nsWindow::sLastMouseDownTime = 0L;
LONG nsWindow::sLastClickCount = 0L;
BYTE nsWindow::sLastMouseButton = 0;
-// Trim heap on minimize. (initialized, but still true.)
-int nsWindow::sTrimOnMinimize = 2;
+bool nsWindow::sHaveInitializedPrefs = false;
TriStateBool nsWindow::sHasBogusPopupsDropShadowOnMultiMonitor = TRI_UNKNOWN;
@@ -783,7 +782,7 @@ nsWindow::Create(nsIWidget* aParent,
parent = nullptr;
}
- if (IsVistaOrLater() && !IsWin8OrLater() &&
+ if (!IsWin8OrLater() &&
HasBogusPopupsDropShadowOnMultiMonitor()) {
extendedStyle |= WS_EX_COMPOSITED;
}
@@ -908,20 +907,13 @@ nsWindow::Create(nsIWidget* aParent,
mDefaultIMC.Init(this);
IMEHandler::InitInputContext(this, mInputContext);
- // If the internal variable set by the config.trim_on_minimize pref has not
- // been initialized, and if this is the hidden window (conveniently created
- // before any visible windows, and after the profile has been initialized),
- // do some initialization work.
- if (sTrimOnMinimize == 2 && mWindowType == eWindowType_invisible) {
- // Our internal trim prevention logic is effective on 2K/XP at maintaining
- // the working set when windows are minimized, but on Vista and up it has
- // little to no effect. Since this feature has been the source of numerous
- // bugs over the years, disable it (sTrimOnMinimize=1) on Vista and up.
- sTrimOnMinimize =
- Preferences::GetBool("config.trim_on_minimize",
- IsVistaOrLater() ? 1 : 0);
+ // Do some initialization work, but only if (a) it hasn't already been done,
+ // and (b) this is the hidden window (which is conveniently created before
+ // any visible windows but after the profile has been initialized).
+ if (!sHaveInitializedPrefs && mWindowType == eWindowType_invisible) {
sSwitchKeyboardLayout =
Preferences::GetBool("intl.keyboard.per_window_layout", false);
+ sHaveInitializedPrefs = true;
}
// Query for command button metric data for rendering the titlebar. We
@@ -1647,9 +1639,10 @@ bool nsWindow::IsVisible() const
// XP and Vista visual styles sometimes require window clipping regions to be applied for proper
// transparency. These routines are called on size and move operations.
+// XXX this is apparently still needed in Windows 7 and later
void nsWindow::ClearThemeRegion()
{
- if (IsVistaOrLater() && !HasGlass() &&
+ if (!HasGlass() &&
(mWindowType == eWindowType_popup && !IsPopupWithTitleBar() &&
(mPopupType == ePopupTypeTooltip || mPopupType == ePopupTypePanel))) {
SetWindowRgn(mWnd, nullptr, false);
@@ -1663,7 +1656,7 @@ void nsWindow::SetThemeRegion()
// so default constants are used for part and state. At some point we might need part and
// state values from nsNativeThemeWin's GetThemePartAndState, but currently windows that
// change shape based on state haven't come up.
- if (IsVistaOrLater() && !HasGlass() &&
+ if (!HasGlass() &&
(mWindowType == eWindowType_popup && !IsPopupWithTitleBar() &&
(mPopupType == ePopupTypeTooltip || mPopupType == ePopupTypePanel))) {
HRGN hRgn = nullptr;
@@ -2080,13 +2073,7 @@ nsWindow::SetSizeMode(nsSizeMode aMode)
break;
case nsSizeMode_Minimized :
- // Using SW_SHOWMINIMIZED prevents the working set from being trimmed but
- // keeps the window active in the tray. So after the window is minimized,
- // windows will fire WM_WINDOWPOSCHANGED (OnWindowPosChanged) at which point
- // we will do some additional processing to get the active window set right.
- // If sTrimOnMinimize is set, we let windows handle minimization normally
- // using SW_MINIMIZE.
- mode = sTrimOnMinimize ? SW_MINIMIZE : SW_SHOWMINIMIZED;
+ mode = SW_MINIMIZE;
break;
default :
@@ -5084,12 +5071,19 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
case WM_SETTINGCHANGE:
{
- if (IsWin10OrLater() && mWindowType == eWindowType_invisible && lParam) {
+ if (lParam) {
auto lParamString = reinterpret_cast<const wchar_t*>(lParam);
- if (!wcscmp(lParamString, L"UserInteractionMode")) {
- nsCOMPtr<nsIWindowsUIUtils> uiUtils(do_GetService("@mozilla.org/windows-ui-utils;1"));
- if (uiUtils) {
- uiUtils->UpdateTabletModeState();
+ if (!wcscmp(lParamString, L"ImmersiveColorSet")) {
+ // WM_SYSCOLORCHANGE is not dispatched for accent color changes
+ OnSysColorChanged();
+ break;
+ }
+ if (IsWin10OrLater() && mWindowType == eWindowType_invisible) {
+ if (!wcscmp(lParamString, L"UserInteractionMode")) {
+ nsCOMPtr<nsIWindowsUIUtils> uiUtils(do_GetService("@mozilla.org/windows-ui-utils;1"));
+ if (uiUtils) {
+ uiUtils->UpdateTabletModeState();
+ }
}
}
}
@@ -5582,12 +5576,13 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
DispatchPendingEvents();
break;
- // Windows doesn't provide to customize the behavior of 4th nor 5th button
- // of mouse. If 5-button mouse works with standard mouse deriver of
- // Windows, users cannot disable 4th button (browser back) nor 5th button
- // (browser forward). We should allow to do it with our prefs since we can
- // prevent Windows to generate WM_APPCOMMAND message if WM_XBUTTONUP
- // messages are not sent to DefWindowProc.
+ // Windows doesn't provide a way to customize the behavior of 4th or 5th
+ // button of a mouse. If a 5-button mouse works with the standard mouse
+ // driver of Windows, users cannot disable the 4th button (browser back)
+ // nor the 5th button (browser forward).
+ // We can disable it here with our prefs since we can prevent Windows
+ // from generating WM_APPCOMMAND messages if WM_XBUTTONUP messages are
+ // not sent to DefWindowProc.
case WM_XBUTTONDOWN:
case WM_XBUTTONUP:
case WM_NCXBUTTONDOWN:
@@ -5595,10 +5590,10 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
*aRetValue = TRUE;
switch (GET_XBUTTON_WPARAM(wParam)) {
case XBUTTON1:
- result = !Preferences::GetBool("mousebutton.4th.enabled", true);
+ result = !Preferences::GetBool("mouse.button4.enabled", true);
break;
case XBUTTON2:
- result = !Preferences::GetBool("mousebutton.5th.enabled", true);
+ result = !Preferences::GetBool("mouse.button5.enabled", true);
break;
default:
break;
@@ -5820,12 +5815,6 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
case WM_SYSCOMMAND:
{
WPARAM filteredWParam = (wParam &0xFFF0);
- // prevent Windows from trimming the working set. bug 76831
- if (!sTrimOnMinimize && filteredWParam == SC_MINIMIZE) {
- ::ShowWindow(mWnd, SW_SHOWMINIMIZED);
- result = true;
- }
-
if (mSizeMode == nsSizeMode_Fullscreen &&
filteredWParam == SC_RESTORE &&
GetCurrentShowCmd(mWnd) != SW_SHOWMINIMIZED) {
@@ -6443,14 +6432,6 @@ void nsWindow::OnWindowPosChanged(WINDOWPOS* wp)
else
mSizeMode = nsSizeMode_Normal;
- // If !sTrimOnMinimize, we minimize windows using SW_SHOWMINIMIZED (See
- // SetSizeMode for internal calls, and WM_SYSCOMMAND for external). This
- // prevents the working set from being trimmed but keeps the window active.
- // After the window is minimized, we need to do some touch up work on the
- // active window. (bugs 76831 & 499816)
- if (!sTrimOnMinimize && nsSizeMode_Minimized == mSizeMode)
- ActivateOtherWindowHelper(mWnd);
-
#ifdef WINSTATE_DEBUG_OUTPUT
switch (mSizeMode) {
case nsSizeMode_Normal:
@@ -6571,31 +6552,6 @@ void nsWindow::OnWindowPosChanged(WINDOWPOS* wp)
}
}
-// static
-void nsWindow::ActivateOtherWindowHelper(HWND aWnd)
-{
- // Find the next window that is enabled, visible, and not minimized.
- HWND hwndBelow = ::GetNextWindow(aWnd, GW_HWNDNEXT);
- while (hwndBelow && (!::IsWindowEnabled(hwndBelow) || !::IsWindowVisible(hwndBelow) ||
- ::IsIconic(hwndBelow))) {
- hwndBelow = ::GetNextWindow(hwndBelow, GW_HWNDNEXT);
- }
-
- // Push ourselves to the bottom of the stack, then activate the
- // next window.
- ::SetWindowPos(aWnd, HWND_BOTTOM, 0, 0, 0, 0,
- SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
- if (hwndBelow)
- ::SetForegroundWindow(hwndBelow);
-
- // Play the minimize sound while we're here, since that is also
- // forgotten when we use SW_SHOWMINIMIZED.
- nsCOMPtr<nsISound> sound(do_CreateInstance("@mozilla.org/sound;1"));
- if (sound) {
- sound->PlaySystemSound(NS_LITERAL_STRING("Minimize"));
- }
-}
-
void nsWindow::OnWindowPosChanging(LPWINDOWPOS& info)
{
// Update non-client margins if the frame size is changing, and let the
@@ -7131,6 +7087,13 @@ nsWindow::OnSysColorChanged()
// so all presentations get notified properly.
// See nsWindow::GlobalMsgWindowProc.
NotifySysColorChanged();
+ // On Windows 10 only, we trigger a theme change to pick up changed media
+ // queries that are needed for accent color changes.
+ // We also set a temp pref to notify the FE that the colors have changed.
+ if (IsWin10OrLater()) {
+ NotifyThemeChanged();
+ Preferences::SetBool("ui.colorChanged", true);
+ }
}
}
diff --git a/widget/windows/nsWindow.h b/widget/windows/nsWindow.h
index 248978bd7..199500e9c 100644
--- a/widget/windows/nsWindow.h
+++ b/widget/windows/nsWindow.h
@@ -486,7 +486,6 @@ protected:
bool aIntersectWithExisting) override;
nsIntRegion GetRegionToPaint(bool aForceFullRepaint,
PAINTSTRUCT ps, HDC aDC);
- static void ActivateOtherWindowHelper(HWND aWnd);
void ClearCachedResources();
nsIWidgetListener* GetPaintListener();
@@ -552,7 +551,7 @@ protected:
static bool sJustGotDeactivate;
static bool sJustGotActivate;
static bool sIsInMouseCapture;
- static int sTrimOnMinimize;
+ static bool sHaveInitializedPrefs;
// Always use the helper method to read this property. See bug 603793.
static TriStateBool sHasBogusPopupsDropShadowOnMultiMonitor;