Skip to content

Commit

Permalink
[W32] windowsVersion() and osVersionForUAString() are outdated
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=143771

Patch by Руслан Ижбулатов <lrn1986@gmail.com> on 2015-04-15
Reviewed by Darin Adler

Update windowsVersion() and osVersionForUAString()

Add support for newer Windows versions to windowsVersion(), handle
all defined cases in osVersionForUAString(), avoiding warnings like
../webkitgtk-2.4.8/Source/WebCore/platform/win/SystemInfo.cpp: In function 'WTF::String WebCore::osVersionForUAString()':
../webkitgtk-2.4.8/Source/WebCore/platform/win/SystemInfo.cpp:94:12: warning: enumeration value 'WindowsCE5' not handled in switch [-Wswitch]
repeated for each unhandled value

* platform/win/SystemInfo.cpp:
(WebCore::windowsVersion):
(WebCore::osVersionForUAString):
* platform/win/SystemInfo.h:
  • Loading branch information
LRN authored and carlosgcampos committed May 18, 2015
1 parent 8b1ef93 commit 705d057
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 8 deletions.
20 changes: 20 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,23 @@
2015-04-15 Руслан Ижбулатов <lrn1986@gmail.com>

[W32] windowsVersion() and osVersionForUAString() are outdated
https://bugs.webkit.org/show_bug.cgi?id=143771

Reviewed by Darin Adler

Update windowsVersion() and osVersionForUAString()

Add support for newer Windows versions to windowsVersion(), handle
all defined cases in osVersionForUAString(), avoiding warnings like
../webkitgtk-2.4.8/Source/WebCore/platform/win/SystemInfo.cpp: In function 'WTF::String WebCore::osVersionForUAString()':
../webkitgtk-2.4.8/Source/WebCore/platform/win/SystemInfo.cpp:94:12: warning: enumeration value 'WindowsCE5' not handled in switch [-Wswitch]
repeated for each unhandled value

* platform/win/SystemInfo.cpp:
(WebCore::windowsVersion):
(WebCore::osVersionForUAString):
* platform/win/SystemInfo.h:

2015-04-17 Milan Crha <mcrha@redhat.com>

[GTK] Replace M_SQRT2 with sqrtOfTwoDouble
Expand Down
115 changes: 107 additions & 8 deletions Source/WebCore/platform/win/SystemInfo.cpp
Expand Up @@ -29,6 +29,10 @@
#include <windows.h>
#include <wtf/text/WTFString.h>

#ifndef SM_SERVERR2
#define SM_SERVERR2 89
#endif

namespace WebCore {

WindowsVersion windowsVersion(int* major, int* minor)
Expand Down Expand Up @@ -65,15 +69,75 @@ WindowsVersion windowsVersion(int* major, int* minor)
version = (minorVersion == 10) ? Windows98 : WindowsME;
} else {
if (majorVersion == 5) {
if (!minorVersion)
switch (minorVersion) {
default:
case 0:
version = Windows2000;
else
version = (minorVersion == 1) ? WindowsXP : WindowsServer2003;
} else if (majorVersion >= 6) {
if (versionInfo.wProductType == VER_NT_WORKSTATION)
version = (majorVersion == 6 && !minorVersion) ? WindowsVista : Windows7;
else
version = WindowsServer2008;
break;
case 1:
version = WindowsXP;
break;
case 2:
if (versionInfo.wProductType == VER_NT_WORKSTATION)
version = WindowsXP64;
else {
if (!GetSystemMetrics(SM_SERVERR2))
version = WindowsServer2003;
else
version = WindowsServer2003R2;
}
break;
}
} else if (majorVersion == 6) {
if (versionInfo.wProductType == VER_NT_WORKSTATION) {
switch (minorVersion) {
default:
case 0:
version = WindowsVista;
break;
case 1:
version = Windows7;
break;
case 2:
version = Windows8;
break;
case 3:
version = Windows81;
break;
}
} else {
switch (minorVersion) {
default:
case 0:
version = WindowsServer2008;
break;
case 1:
version = WindowsServer2008R2;
break;
case 2:
version = WindowsServer2012;
break;
case 3:
version = WindowsServer2012R2;
break;
}
}
} else if (majorVersion == 10) {
if (versionInfo.wProductType == VER_NT_WORKSTATION) {
switch (minorVersion) {
default:
case 0:
version = Windows10;
break;
}
} else {
switch (minorVersion) {
default:
case 0:
version = WindowsServer2016;
break;
}
}
} else
version = (majorVersion == 4) ? WindowsNT4 : WindowsNT3;
}
Expand All @@ -97,6 +161,9 @@ static String osVersionForUAString()
case WindowsCE3:
return "Windows CE";
case WindowsCE4:
case WindowsCE5:
case WindowsCE6:
case WindowsCE7:
return "Windows CE .NET";
case Windows3_1:
return "Windows 3.1";
Expand All @@ -106,8 +173,40 @@ static String osVersionForUAString()
return "Windows 98";
case WindowsME:
return "Windows 98; Win 9x 4.90";
case WindowsNT3:
return "WinNT3.0";
case WindowsNT4:
return "WinNT4.0";
case Windows2000:
return "Windows 2000";
case WindowsXP:
return "Windows XP";
case WindowsServer2003:
return "Windows Server 2003";
case WindowsXP64:
return "Windows XP Professional x64 Edition";
case WindowsServer2003R2:
return "Windows Server 2003 R2";
case WindowsVista:
return "Windows Vista";
case WindowsServer2008:
return "Windows Server 2008";
case Windows7:
return "Windows 7";
case WindowsServer2008R2:
return "Windows Server 2008 R2";
case Windows8:
return "Windows 8";
case WindowsServer2012:
return "Windows Server 2012";
case Windows81:
return "Windows 8.1";
case WindowsServer2012R2:
return "Windows Server 2012 R2";
case Windows10:
return "Windows 10";
case WindowsServer2016:
return "Windows Server 2016";
}

const char* familyName = (version >= WindowsNT3) ? "Windows NT " : "Windows CE ";
Expand Down
9 changes: 9 additions & 0 deletions Source/WebCore/platform/win/SystemInfo.h
Expand Up @@ -54,9 +54,18 @@ enum WindowsVersion {
Windows2000,
WindowsXP,
WindowsServer2003,
WindowsXP64,
WindowsServer2003R2,
WindowsVista,
WindowsServer2008,
Windows7,
WindowsServer2008R2,
Windows8,
WindowsServer2012,
Windows81,
WindowsServer2012R2,
Windows10,
WindowsServer2016,
};

// If supplied, |major| and |minor| are set to the OSVERSIONINFO::dwMajorVersion
Expand Down

0 comments on commit 705d057

Please sign in to comment.