Jacek Caban : mshtml: Move handle_insert_comment to mutation.c.

Alexandre Julliard julliard at winehq.org
Wed Dec 31 07:45:03 CST 2008


Module: wine
Branch: master
Commit: 91af3c56caeac3aa5aed4c42711c83a52f900606
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=91af3c56caeac3aa5aed4c42711c83a52f900606

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Dec 30 21:20:57 2008 +0100

mshtml: Move handle_insert_comment to mutation.c.

---

 dlls/mshtml/mshtml_private.h |    1 -
 dlls/mshtml/mutation.c       |  138 ++++++++++++++++++++++++++++++++++++++++++
 dlls/mshtml/nsevents.c       |  138 ------------------------------------------
 3 files changed, 138 insertions(+), 139 deletions(-)

diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 8b40fea..58f662a 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -506,7 +506,6 @@ void NSContainer_Release(NSContainer*);
 
 void init_mutation(NSContainer*);
 void set_mutation_observer(NSContainer*,nsIDOMHTMLDocument*);
-BOOL handle_insert_comment(HTMLDocument *doc, const PRUnichar *comment);
 
 void HTMLDocument_LockContainer(HTMLDocument*,BOOL);
 void show_context_menu(HTMLDocument*,DWORD,POINT*,IDispatch*);
diff --git a/dlls/mshtml/mutation.c b/dlls/mshtml/mutation.c
index 1711908..edd3dca 100644
--- a/dlls/mshtml/mutation.c
+++ b/dlls/mshtml/mutation.c
@@ -55,6 +55,144 @@ void set_mutation_observer(NSContainer *nscontainer, nsIDOMHTMLDocument *nshtmld
     nsIDOMNSDocument_Release(nsdoc);
 }
 
+#define IE_MAJOR_VERSION 7
+#define IE_MINOR_VERSION 0
+
+static BOOL handle_insert_comment(HTMLDocument *doc, const PRUnichar *comment)
+{
+    DWORD len;
+    int majorv = 0, minorv = 0;
+    const PRUnichar *ptr, *end;
+    nsAString nsstr;
+    PRUnichar *buf;
+    nsresult nsres;
+
+    enum {
+        CMP_EQ,
+        CMP_LT,
+        CMP_LTE,
+        CMP_GT,
+        CMP_GTE
+    } cmpt = CMP_EQ;
+
+    static const PRUnichar endifW[] = {'<','!','[','e','n','d','i','f',']'};
+
+    if(comment[0] != '[' || comment[1] != 'i' || comment[2] != 'f')
+        return FALSE;
+
+    ptr = comment+3;
+    while(isspaceW(*ptr))
+        ptr++;
+
+    if(ptr[0] == 'l' && ptr[1] == 't') {
+        ptr += 2;
+        if(*ptr == 'e') {
+            cmpt = CMP_LTE;
+            ptr++;
+        }else {
+            cmpt = CMP_LT;
+        }
+    }else if(ptr[0] == 'g' && ptr[1] == 't') {
+        ptr += 2;
+        if(*ptr == 'e') {
+            cmpt = CMP_GTE;
+            ptr++;
+        }else {
+            cmpt = CMP_GT;
+        }
+    }
+
+    if(!isspaceW(*ptr++))
+        return FALSE;
+    while(isspaceW(*ptr))
+        ptr++;
+
+    if(ptr[0] != 'I' || ptr[1] != 'E')
+        return FALSE;
+
+    ptr +=2;
+    if(!isspaceW(*ptr++))
+        return FALSE;
+    while(isspaceW(*ptr))
+        ptr++;
+
+    if(!isdigitW(*ptr))
+        return FALSE;
+    while(isdigitW(*ptr))
+        majorv = majorv*10 + (*ptr++ - '0');
+
+    if(*ptr == '.') {
+        if(!isdigitW(*ptr))
+            return FALSE;
+        while(isdigitW(*ptr))
+            minorv = minorv*10 + (*ptr++ - '0');
+    }
+
+    while(isspaceW(*ptr))
+        ptr++;
+    if(ptr[0] != ']' || ptr[1] != '>')
+        return FALSE;
+    ptr += 2;
+
+    len = strlenW(ptr);
+    if(len < sizeof(endifW)/sizeof(WCHAR))
+        return FALSE;
+
+    end = ptr + len-sizeof(endifW)/sizeof(WCHAR);
+    if(memcmp(end, endifW, sizeof(endifW)))
+        return FALSE;
+
+    switch(cmpt) {
+    case CMP_EQ:
+        if(majorv == IE_MAJOR_VERSION && minorv == IE_MINOR_VERSION)
+            break;
+        return FALSE;
+    case CMP_LT:
+        if(majorv > IE_MAJOR_VERSION)
+            break;
+        if(majorv == IE_MAJOR_VERSION && minorv > IE_MINOR_VERSION)
+            break;
+        return FALSE;
+    case CMP_LTE:
+        if(majorv > IE_MAJOR_VERSION)
+            break;
+        if(majorv == IE_MAJOR_VERSION && minorv >= IE_MINOR_VERSION)
+            break;
+        return FALSE;
+    case CMP_GT:
+        if(majorv < IE_MAJOR_VERSION)
+            break;
+        if(majorv == IE_MAJOR_VERSION && minorv < IE_MINOR_VERSION)
+            break;
+        return FALSE;
+    case CMP_GTE:
+        if(majorv < IE_MAJOR_VERSION)
+            break;
+        if(majorv == IE_MAJOR_VERSION && minorv <= IE_MINOR_VERSION)
+            break;
+        return FALSE;
+    }
+
+    buf = heap_alloc((end-ptr+1)*sizeof(WCHAR));
+    if(!buf)
+        return FALSE;
+
+    memcpy(buf, ptr, (end-ptr)*sizeof(WCHAR));
+    buf[end-ptr] = 0;
+    nsAString_Init(&nsstr, buf);
+    heap_free(buf);
+
+    /* FIXME: Find better way to insert HTML to document. */
+    nsres = nsIDOMHTMLDocument_Write(doc->nsdoc, &nsstr);
+    nsAString_Finish(&nsstr);
+    if(NS_FAILED(nsres)) {
+        ERR("Write failed: %08x\n", nsres);
+        return FALSE;
+    }
+
+    return TRUE;
+}
+
 static void add_script_runner(NSContainer *This)
 {
     nsIDOMNSDocument *nsdoc;
diff --git a/dlls/mshtml/nsevents.c b/dlls/mshtml/nsevents.c
index ac4572c..1933c57 100644
--- a/dlls/mshtml/nsevents.c
+++ b/dlls/mshtml/nsevents.c
@@ -175,144 +175,6 @@ static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event
     return NS_OK;
 }
 
-#define IE_MAJOR_VERSION 7
-#define IE_MINOR_VERSION 0
-
-BOOL handle_insert_comment(HTMLDocument *doc, const PRUnichar *comment)
-{
-    DWORD len;
-    int majorv = 0, minorv = 0;
-    const PRUnichar *ptr, *end;
-    nsAString nsstr;
-    PRUnichar *buf;
-    nsresult nsres;
-
-    enum {
-        CMP_EQ,
-        CMP_LT,
-        CMP_LTE,
-        CMP_GT,
-        CMP_GTE
-    } cmpt = CMP_EQ;
-
-    static const PRUnichar endifW[] = {'<','!','[','e','n','d','i','f',']'};
-
-    if(comment[0] != '[' || comment[1] != 'i' || comment[2] != 'f')
-        return FALSE;
-
-    ptr = comment+3;
-    while(isspaceW(*ptr))
-        ptr++;
-
-    if(ptr[0] == 'l' && ptr[1] == 't') {
-        ptr += 2;
-        if(*ptr == 'e') {
-            cmpt = CMP_LTE;
-            ptr++;
-        }else {
-            cmpt = CMP_LT;
-        }
-    }else if(ptr[0] == 'g' && ptr[1] == 't') {
-        ptr += 2;
-        if(*ptr == 'e') {
-            cmpt = CMP_GTE;
-            ptr++;
-        }else {
-            cmpt = CMP_GT;
-        }
-    }
-
-    if(!isspaceW(*ptr++))
-        return FALSE;
-    while(isspaceW(*ptr))
-        ptr++;
-
-    if(ptr[0] != 'I' || ptr[1] != 'E')
-        return FALSE;
-
-    ptr +=2;
-    if(!isspaceW(*ptr++))
-        return FALSE;
-    while(isspaceW(*ptr))
-        ptr++;
-
-    if(!isdigitW(*ptr))
-        return FALSE;
-    while(isdigitW(*ptr))
-        majorv = majorv*10 + (*ptr++ - '0');
-
-    if(*ptr == '.') {
-        if(!isdigitW(*ptr))
-            return FALSE;
-        while(isdigitW(*ptr))
-            minorv = minorv*10 + (*ptr++ - '0');
-    }
-
-    while(isspaceW(*ptr))
-        ptr++;
-    if(ptr[0] != ']' || ptr[1] != '>')
-        return FALSE;
-    ptr += 2;
-
-    len = strlenW(ptr);
-    if(len < sizeof(endifW)/sizeof(WCHAR))
-        return FALSE;
-
-    end = ptr + len-sizeof(endifW)/sizeof(WCHAR);
-    if(memcmp(end, endifW, sizeof(endifW)))
-        return FALSE;
-
-    switch(cmpt) {
-    case CMP_EQ:
-        if(majorv == IE_MAJOR_VERSION && minorv == IE_MINOR_VERSION)
-            break;
-        return FALSE;
-    case CMP_LT:
-        if(majorv > IE_MAJOR_VERSION)
-            break;
-        if(majorv == IE_MAJOR_VERSION && minorv > IE_MINOR_VERSION)
-            break;
-        return FALSE;
-    case CMP_LTE:
-        if(majorv > IE_MAJOR_VERSION)
-            break;
-        if(majorv == IE_MAJOR_VERSION && minorv >= IE_MINOR_VERSION)
-            break;
-        return FALSE;
-    case CMP_GT:
-        if(majorv < IE_MAJOR_VERSION)
-            break;
-        if(majorv == IE_MAJOR_VERSION && minorv < IE_MINOR_VERSION)
-            break;
-        return FALSE;
-    case CMP_GTE:
-        if(majorv < IE_MAJOR_VERSION)
-            break;
-        if(majorv == IE_MAJOR_VERSION && minorv <= IE_MINOR_VERSION)
-            break;
-        return FALSE;
-    }
-
-    buf = heap_alloc((end-ptr+1)*sizeof(WCHAR));
-    if(!buf)
-        return FALSE;
-
-    memcpy(buf, ptr, (end-ptr)*sizeof(WCHAR));
-    buf[end-ptr] = 0;
-    nsAString_Init(&nsstr, buf);
-    heap_free(buf);
-
-    /* FIXME: Find better way to insert HTML to document. */
-    nsres = nsIDOMHTMLDocument_Write(doc->nsdoc, &nsstr);
-    nsAString_Finish(&nsstr);
-    if(NS_FAILED(nsres)) {
-        ERR("Write failed: %08x\n", nsres);
-        return FALSE;
-    }
-
-    return TRUE;
-}
-
 static nsresult NSAPI handle_htmlevent(nsIDOMEventListener *iface, nsIDOMEvent *event)
 {
     NSContainer *This = NSEVENTLIST_THIS(iface)->This;




More information about the wine-cvs mailing list