Jacek Caban : mshtml: Use IE version dependent on compatibility mode for conditional comments.
Alexandre Julliard
julliard at winehq.org
Tue May 9 17:21:02 CDT 2017
Module: wine
Branch: master
Commit: d3d8d4f37a93ba70e7aac9aa6e425dedcd897a26
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d3d8d4f37a93ba70e7aac9aa6e425dedcd897a26
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue May 9 17:32:58 2017 +0200
mshtml: Use IE version dependent on compatibility mode for conditional comments.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/mshtml/htmldoc.c | 14 +----------
dlls/mshtml/mshtml_private.h | 7 ++++++
dlls/mshtml/mutation.c | 41 +++++++++++++++++++------------
dlls/mshtml/tests/documentmode.js | 51 ++++++++++++++++++++++++++++++++++-----
dlls/mshtml/tests/script.c | 2 +-
5 files changed, 79 insertions(+), 36 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index cb1fe55..c216448 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -3096,16 +3096,6 @@ static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface, VARI
{
HTMLDocument *This = impl_from_IHTMLDocument6(iface);
- static const int docmode_values[] = {
- 5, /* DOCMODE_QUIRKS */
- 5, /* DOCMODE_IE5 */
- 7, /* DOCMODE_IE7 */
- 8, /* DOCMODE_IE8 */
- 9, /* DOCMODE_IE8 */
- 10, /* DOCMODE_IE10 */
- 11 /* DOCMODE_IE11 */
- };
-
TRACE("(%p)->(%p)\n", This, p);
if(!This->doc_node) {
@@ -3113,10 +3103,8 @@ static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface, VARI
return E_UNEXPECTED;
}
- assert(This->doc_node->document_mode < sizeof(docmode_values)/sizeof(*docmode_values));
-
V_VT(p) = VT_I4;
- V_I4(p) = docmode_values[This->doc_node->document_mode];
+ V_I4(p) = compat_mode_info[This->doc_node->document_mode].document_mode;
return S_OK;
}
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 876827b..eceadca 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -244,6 +244,13 @@ typedef enum {
#define COMPAT_MODE_CNT (COMPAT_MODE_IE11+1)
#define COMPAT_MODE_NONE COMPAT_MODE_QUIRKS
+typedef struct {
+ unsigned document_mode;
+ unsigned ie_version;
+} compat_mode_info_t;
+
+extern const compat_mode_info_t compat_mode_info[COMPAT_MODE_CNT] DECLSPEC_HIDDEN;
+
typedef struct dispex_data_t dispex_data_t;
typedef struct dispex_dynamic_data_t dispex_dynamic_data_t;
diff --git a/dlls/mshtml/mutation.c b/dlls/mshtml/mutation.c
index ef4c58c..50e162e 100644
--- a/dlls/mshtml/mutation.c
+++ b/dlls/mshtml/mutation.c
@@ -39,8 +39,15 @@
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
-#define IE_MAJOR_VERSION 7
-#define IE_MINOR_VERSION 0
+const compat_mode_info_t compat_mode_info[] = {
+ { 5, 7 }, /* DOCMODE_QUIRKS */
+ { 5, 5 }, /* DOCMODE_IE5 */
+ { 7, 7 }, /* DOCMODE_IE7 */
+ { 8, 8 }, /* DOCMODE_IE8 */
+ { 9, 9 }, /* DOCMODE_IE8 */
+ { 10, 10 }, /* DOCMODE_IE10 */
+ { 11, 11 } /* DOCMODE_IE11 */
+};
static const IID NS_ICONTENTUTILS_CID =
{0x762C4AE7,0xB923,0x422F,{0xB9,0x7E,0xB9,0xBF,0xC1,0xEF,0x7B,0xF0}};
@@ -49,7 +56,7 @@ static nsIContentUtils *content_utils;
static PRUnichar *handle_insert_comment(HTMLDocumentNode *doc, const PRUnichar *comment)
{
- int majorv = 0, minorv = 0;
+ unsigned majorv = 0, minorv = 0, compat_version;
const PRUnichar *ptr, *end;
PRUnichar *buf;
DWORD len;
@@ -130,33 +137,35 @@ static PRUnichar *handle_insert_comment(HTMLDocumentNode *doc, const PRUnichar *
if(memcmp(end, endifW, sizeof(endifW)))
return NULL;
+ compat_version = compat_mode_info[doc->document_mode].ie_version;
+ if(compat_version > 8) {
+ /*
+ * Ideally we should handle higher versions, but right now it would cause more problems than it's worth.
+ * We should revisit that once more IE9 features are implemented, most notably new events APIs.
+ */
+ WARN("Using compat version 8\n");
+ compat_version = 8;
+ }
+
switch(cmpt) {
case CMP_EQ:
- if(majorv == IE_MAJOR_VERSION && minorv == IE_MINOR_VERSION)
+ if(compat_version == majorv && !minorv)
break;
return NULL;
case CMP_LT:
- if(majorv > IE_MAJOR_VERSION)
- break;
- if(majorv == IE_MAJOR_VERSION && minorv > IE_MINOR_VERSION)
+ if(compat_version < majorv || (compat_version == majorv && minorv))
break;
return NULL;
case CMP_LTE:
- if(majorv > IE_MAJOR_VERSION)
- break;
- if(majorv == IE_MAJOR_VERSION && minorv >= IE_MINOR_VERSION)
+ if(compat_version <= majorv)
break;
return NULL;
case CMP_GT:
- if(majorv < IE_MAJOR_VERSION)
- break;
- if(majorv == IE_MAJOR_VERSION && minorv < IE_MINOR_VERSION)
+ if(compat_version > majorv)
break;
return NULL;
case CMP_GTE:
- if(majorv < IE_MAJOR_VERSION)
- break;
- if(majorv == IE_MAJOR_VERSION && minorv <= IE_MINOR_VERSION)
+ if(compat_version >= majorv || (compat_version == majorv && !minorv))
break;
return NULL;
}
diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js
index 292955a..a7340e2 100644
--- a/dlls/mshtml/tests/documentmode.js
+++ b/dlls/mshtml/tests/documentmode.js
@@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+var compat_version;
+
function test_elem_props() {
var elem = document.documentElement;
@@ -35,17 +37,17 @@ function test_elem_props() {
}
function test_doc_mode() {
- var opt = parseInt(document.location.search.substring(1));
+ compat_version = parseInt(document.location.search.substring(1));
- trace("Testing document mode " + opt);
+ trace("Testing compatibility mode " + compat_version);
- if(opt > document.documentMode) {
- win_skip("Document mode not supported (expected " + opt + " got " + document.documentMode + ")");
+ if(compat_version > 6 && compat_version > document.documentMode) {
+ win_skip("Document mode not supported (expected " + compat_version + " got " + document.documentMode + ")");
reportSuccess();
return;
}
- ok(opt === document.documentMode, "documentMode = " + document.documentMode);
+ ok(Math.max(compat_version, 5) === document.documentMode, "documentMode = " + document.documentMode);
if(document.documentMode > 5)
ok(document.compatMode === "CSS1Compat", "document.compatMode = " + document.compatMode);
@@ -55,7 +57,44 @@ function test_doc_mode() {
next_test();
}
+function test_conditional_comments() {
+ var div = document.createElement("div");
+ document.body.appendChild(div);
+
+ function test_version(v) {
+ var version = compat_version ? compat_version : 7;
+
+ /* Uncomment and fix tests below once we support that. */
+ if(version >= 9)
+ return;
+
+ div.innerHTML = "<!--[if lte IE " + v + "]>true<![endif]-->";
+ ok(div.innerText === (version <= v ? "true" : ""),
+ "div.innerText = " + div.innerText + " for version (<=) " + v);
+
+ div.innerHTML = "<!--[if lt IE " + v + "]>true<![endif]-->";
+ ok(div.innerText === (version < v ? "true" : ""),
+ "div.innerText = " + div.innerText + " for version (<) " + v);
+
+ div.innerHTML = "<!--[if gte IE " + v + "]>true<![endif]-->";
+ ok(div.innerText === (version >= v ? "true" : ""),
+ "div.innerText = " + div.innerText + " for version (>=) " + v);
+
+ div.innerHTML = "<!--[if gt IE " + v + "]>true<![endif]-->";
+ ok(div.innerText === (version > v ? "true" : ""),
+ "div.innerText = " + div.innerText + " for version (>) " + v);
+ }
+
+ test_version(5);
+ test_version(6);
+ test_version(7);
+ test_version(8);
+
+ next_test();
+}
+
var tests = [
test_doc_mode,
- test_elem_props
+ test_elem_props,
+ test_conditional_comments
];
diff --git a/dlls/mshtml/tests/script.c b/dlls/mshtml/tests/script.c
index 322314b..2753d7d 100644
--- a/dlls/mshtml/tests/script.c
+++ b/dlls/mshtml/tests/script.c
@@ -3462,7 +3462,7 @@ static void run_js_tests(void)
run_script_as_http_with_mode("navigation.js", NULL, NULL);
run_script_as_http_with_mode("navigation.js", NULL, "11");
- run_script_as_http_with_mode("documentmode.js", "?5", NULL);
+ run_script_as_http_with_mode("documentmode.js", "?0", NULL);
run_script_as_http_with_mode("documentmode.js", "?5", "5");
run_script_as_http_with_mode("documentmode.js", "?5", "6");
run_script_as_http_with_mode("documentmode.js", "?7", "7");
More information about the wine-cvs
mailing list