[MSHTML]
authorChristoph von Wittich <christoph_vw@reactos.org>
Sun, 21 Mar 2010 15:12:30 +0000 (15:12 +0000)
committerChristoph von Wittich <christoph_vw@reactos.org>
Sun, 21 Mar 2010 15:12:30 +0000 (15:12 +0000)
sync mshtml with wine 1.1.41

svn path=/trunk/; revision=46303

21 files changed:
reactos/dll/win32/mshtml/De.rc
reactos/dll/win32/mshtml/Fr.rc
reactos/dll/win32/mshtml/It.rc
reactos/dll/win32/mshtml/Ja.rc
reactos/dll/win32/mshtml/Lt.rc
reactos/dll/win32/mshtml/No.rc
reactos/dll/win32/mshtml/Si.rc
reactos/dll/win32/mshtml/htmldoc.c
reactos/dll/win32/mshtml/htmldoc3.c
reactos/dll/win32/mshtml/htmlelem2.c
reactos/dll/win32/mshtml/htmlevent.c
reactos/dll/win32/mshtml/htmlevent.h
reactos/dll/win32/mshtml/htmlimg.c
reactos/dll/win32/mshtml/htmlwindow.c
reactos/dll/win32/mshtml/mshtml_private.h
reactos/dll/win32/mshtml/mutation.c
reactos/dll/win32/mshtml/navigate.c
reactos/dll/win32/mshtml/nsevents.c
reactos/dll/win32/mshtml/nsio.c
reactos/dll/win32/mshtml/omnavigator.c
reactos/dll/win32/mshtml/persist.c

index 43e0cfe..50d519d 100644 (file)
@@ -72,4 +72,3 @@ FONT 8, "MS Shell Dlg"
     PUSHBUTTON "OK", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
     PUSHBUTTON "Abbrechen", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP
 }
-#pragma code_page(default)
index 84ee453..0d14f45 100644 (file)
@@ -72,4 +72,3 @@ FONT 8, "MS Shell Dlg"
     PUSHBUTTON "OK", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
     PUSHBUTTON "Annuler", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP
 }
-#pragma code_page(default)
index 4b262c5..36660cc 100644 (file)
@@ -69,4 +69,3 @@ FONT 8, "MS Shell Dlg"
     PUSHBUTTON "OK", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
     PUSHBUTTON "Annulla", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP
 }
-#pragma code_page(default)
index 40db7b5..04fc32e 100644 (file)
@@ -69,4 +69,3 @@ FONT 8, "MS Shell Dlg"
     PUSHBUTTON "OK", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
     PUSHBUTTON "キャンセル", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP
 }
-#pragma code_page(default)
index 560cc08..8f7e772 100644 (file)
@@ -69,4 +69,3 @@ FONT 8, "MS Shell Dlg"
     PUSHBUTTON "Gerai", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
     PUSHBUTTON "Atsisakyti", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP
 }
-#pragma code_page(default)
index 3a3b45d..4592599 100644 (file)
@@ -70,4 +70,3 @@ FONT 8, "MS Shell Dlg"
     PUSHBUTTON "OK", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
     PUSHBUTTON "Avbryt", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP
 }
-#pragma code_page(default)
index 500081b..6881add 100644 (file)
@@ -68,4 +68,3 @@ FONT 8, "MS Shell Dlg"
     PUSHBUTTON "V redu", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
     PUSHBUTTON "Prekliči", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP
 }
-#pragma code_page(default)
index 8adfdb1..12aa8c0 100644 (file)
@@ -554,9 +554,12 @@ static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT
 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
 {
     HTMLDocument *This = HTMLDOC_THIS(iface);
+
     FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
-}
+
+    *p = NULL;
+    return S_OK;
+ }
 
 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
 {
@@ -1474,7 +1477,7 @@ static void HTMLDocument_on_advise(IUnknown *iface, cp_static_data_t *cp)
     HTMLDocument *This = HTMLDOC_THIS(iface);
 
     if(This->window)
-        update_cp_events(This->window, cp);
+        update_cp_events(This->window, &This->doc_node->node.event_target, cp, This->doc_node->node.nsnode);
 }
 
 #undef HTMLDOC_THIS
@@ -1596,6 +1599,11 @@ static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID
 {
     HTMLDocument *This = DISPEX_THIS(iface);
 
+    if(This->window && id == DISPID_IHTMLDOCUMENT2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT))
+        return IDispatchEx_InvokeEx(DISPATCHEX(This->window), DISPID_IHTMLWINDOW2_LOCATION, lcid, wFlags,
+                pdp, pvarRes, pei, pspCaller);
+
+
     return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
 }
 
index 9079bbc..e28297f 100644 (file)
@@ -182,7 +182,7 @@ static HRESULT WINAPI HTMLDocument3_attachEvent(IHTMLDocument3 *iface, BSTR even
 
     TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
 
-    return attach_event(&This->doc_node->node.event_target, This, event, pDisp, pfResult);
+    return attach_event(&This->doc_node->node.event_target, This->doc_node->node.nsnode, This, event, pDisp, pfResult);
 }
 
 static HRESULT WINAPI HTMLDocument3_detachEvent(IHTMLDocument3 *iface, BSTR event,
index cd877ce..548bab8 100644 (file)
@@ -649,7 +649,7 @@ static HRESULT WINAPI HTMLElement2_attachEvent(IHTMLElement2 *iface, BSTR event,
 
     TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
 
-    return attach_event(get_node_event_target(&This->node), &This->node.doc->basedoc, event, pDisp, pfResult);
+    return attach_event(get_node_event_target(&This->node), This->node.nsnode, &This->node.doc->basedoc, event, pDisp, pfResult);
 }
 
 static HRESULT WINAPI HTMLElement2_detachEvent(IHTMLElement2 *iface, BSTR event, IDispatch *pDisp)
index 54429c3..eef006c 100644 (file)
@@ -40,6 +40,7 @@ typedef struct {
 } handler_vector_t;
 
 struct event_target_t {
+    DWORD node_handlers_mask;
     handler_vector_t *event_table[EVENTID_LAST];
 };
 
@@ -129,6 +130,7 @@ typedef struct {
 #define EVENT_DEFAULTLISTENER    0x0001
 #define EVENT_BUBBLE             0x0002
 #define EVENT_FORWARDBODY        0x0004
+#define EVENT_NODEHANDLER        0x0008
 
 static const event_info_t event_info[] = {
     {beforeunloadW,      onbeforeunloadW,      EVENTT_NONE,   DISPID_EVMETH_ONBEFOREUNLOAD,
@@ -152,7 +154,7 @@ static const event_info_t event_info[] = {
     {keyupW,             onkeyupW,             EVENTT_KEY,    DISPID_EVMETH_ONKEYUP,
         EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
     {loadW,              onloadW,              EVENTT_HTML,   DISPID_EVMETH_ONLOAD,
-        0},
+        EVENT_NODEHANDLER},
     {mousedownW,         onmousedownW,         EVENTT_MOUSE,  DISPID_EVMETH_ONMOUSEDOWN,
         EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
     {mouseoutW,          onmouseoutW,          EVENTT_MOUSE,  DISPID_EVMETH_ONMOUSEOUT,
@@ -171,6 +173,8 @@ static const event_info_t event_info[] = {
         0}
 };
 
+static const eventid_t node_handled_list[] = { EVENTID_LOAD };
+
 eventid_t str_to_eid(LPCWSTR str)
 {
     int i;
@@ -196,6 +200,19 @@ static eventid_t attr_to_eid(LPCWSTR str)
     return EVENTID_LAST;
 }
 
+static DWORD get_node_handler_mask(eventid_t eid)
+{
+    DWORD i;
+
+    for(i=0; i<sizeof(node_handled_list)/sizeof(*node_handled_list); i++) {
+        if(node_handled_list[i] == eid)
+            return 1 << i;
+    }
+
+    ERR("Invalid eid %d\n", eid);
+    return ~0;
+}
+
 typedef struct {
     DispatchEx dispex;
     const IHTMLEventObjVtbl  *lpIHTMLEventObjVtbl;
@@ -882,7 +899,7 @@ static void call_event_handlers(HTMLDocumentNode *doc, IHTMLEventObj *event_obj,
     }
 }
 
-void fire_event(HTMLDocumentNode *doc, eventid_t eid, nsIDOMNode *target, nsIDOMEvent *nsevent)
+void fire_event(HTMLDocumentNode *doc, eventid_t eid, BOOL set_event, nsIDOMNode *target, nsIDOMEvent *nsevent)
 {
     IHTMLEventObj *prev_event, *event_obj = NULL;
     nsIDOMNode *parent, *nsnode;
@@ -892,7 +909,9 @@ void fire_event(HTMLDocumentNode *doc, eventid_t eid, nsIDOMNode *target, nsIDOM
     TRACE("(%p) %s\n", doc, debugstr_w(event_info[eid].name));
 
     prev_event = doc->basedoc.window->event;
-    event_obj = doc->basedoc.window->event = create_event(get_node(doc, target, TRUE), eid, nsevent);
+    if(set_event)
+        event_obj = create_event(get_node(doc, target, TRUE), eid, nsevent);
+    doc->basedoc.window->event = event_obj;
 
     nsIDOMNode_GetNodeType(target, &node_type);
     nsnode = target;
@@ -949,7 +968,8 @@ void fire_event(HTMLDocumentNode *doc, eventid_t eid, nsIDOMNode *target, nsIDOM
     if(nsnode)
         nsIDOMNode_Release(nsnode);
 
-    IHTMLEventObj_Release(event_obj);
+    if(event_obj)
+        IHTMLEventObj_Release(event_obj);
     doc->basedoc.window->event = prev_event;
 }
 
@@ -971,7 +991,7 @@ HRESULT dispatch_event(HTMLDOMNode *node, const WCHAR *event_name, VARIANT *even
         return E_NOTIMPL;
     }
 
-    fire_event(node->doc, eid, node->nsnode, NULL);
+    fire_event(node->doc, eid, TRUE, node->nsnode, NULL);
 
     *cancelled = VARIANT_TRUE; /* FIXME */
     return S_OK;
@@ -989,7 +1009,7 @@ HRESULT call_event(HTMLDOMNode *node, eventid_t eid)
             return hres;
     }
 
-    fire_event(node->doc, eid, node->nsnode, NULL);
+    fire_event(node->doc, eid, TRUE, node->nsnode, NULL);
     return S_OK;
 }
 
@@ -1021,9 +1041,24 @@ static BOOL alloc_handler_vector(event_target_t *event_target, eventid_t eid, in
     return TRUE;
 }
 
-static HRESULT ensure_nsevent_handler(HTMLDocumentNode *doc, eventid_t eid)
+static HRESULT ensure_nsevent_handler(HTMLDocumentNode *doc, event_target_t *event_target, nsIDOMNode *nsnode, eventid_t eid)
 {
-    if(!doc->nsdoc || !(event_info[eid].flags & EVENT_DEFAULTLISTENER))
+    if(!doc->nsdoc)
+        return S_OK;
+
+    if(event_info[eid].flags & EVENT_NODEHANDLER) {
+        DWORD mask;
+
+        mask = get_node_handler_mask(eid);
+        if(event_target->node_handlers_mask & mask)
+            return S_OK;
+
+        add_nsevent_listener(doc, nsnode, event_info[eid].name);
+        event_target->node_handlers_mask |= mask;
+        return S_OK;
+    }
+
+    if(!(event_info[eid].flags & EVENT_DEFAULTLISTENER))
         return S_OK;
 
     if(!doc->event_vector) {
@@ -1034,17 +1069,30 @@ static HRESULT ensure_nsevent_handler(HTMLDocumentNode *doc, eventid_t eid)
 
     if(!doc->event_vector[eid]) {
         doc->event_vector[eid] = TRUE;
-        add_nsevent_listener(doc, event_info[eid].name);
+        add_nsevent_listener(doc, NULL, event_info[eid].name);
     }
 
     return S_OK;
 }
 
-static HRESULT set_event_handler_disp(event_target_t **event_target_ptr, HTMLDocumentNode *doc,
+static HRESULT remove_event_handler(event_target_t **event_target, eventid_t eid)
+{
+    if(*event_target && (*event_target)->event_table[eid]->handler_prop) {
+        IDispatch_Release((*event_target)->event_table[eid]->handler_prop);
+        (*event_target)->event_table[eid]->handler_prop = NULL;
+    }
+
+    return S_OK;
+}
+
+static HRESULT set_event_handler_disp(event_target_t **event_target_ptr, nsIDOMNode *nsnode, HTMLDocumentNode *doc,
         eventid_t eid, IDispatch *disp)
 {
     event_target_t *event_target;
 
+    if(!disp)
+        return remove_event_handler(event_target_ptr, eid);
+
     event_target = get_event_target(event_target_ptr);
     if(!event_target)
         return E_OUTOFMEMORY;
@@ -1056,25 +1104,19 @@ static HRESULT set_event_handler_disp(event_target_t **event_target_ptr, HTMLDoc
         IDispatch_Release(event_target->event_table[eid]->handler_prop);
 
     event_target->event_table[eid]->handler_prop = disp;
-    if(!disp)
-        return S_OK;
     IDispatch_AddRef(disp);
 
-    return ensure_nsevent_handler(doc, eid);
+    return ensure_nsevent_handler(doc, event_target, nsnode, eid);
 }
 
-HRESULT set_event_handler(event_target_t **event_target, HTMLDocumentNode *doc, eventid_t eid, VARIANT *var)
+HRESULT set_event_handler(event_target_t **event_target, nsIDOMNode *nsnode, HTMLDocumentNode *doc, eventid_t eid, VARIANT *var)
 {
     switch(V_VT(var)) {
     case VT_NULL:
-        if(*event_target && (*event_target)->event_table[eid] && (*event_target)->event_table[eid]->handler_prop) {
-            IDispatch_Release((*event_target)->event_table[eid]->handler_prop);
-            (*event_target)->event_table[eid]->handler_prop = NULL;
-        }
-        break;
+        return remove_event_handler(event_target, eid);
 
     case VT_DISPATCH:
-        return set_event_handler_disp(event_target, doc, eid, V_DISPATCH(var));
+        return set_event_handler_disp(event_target, nsnode, doc, eid, V_DISPATCH(var));
 
     default:
         FIXME("not supported vt=%d\n", V_VT(var));
@@ -1098,7 +1140,8 @@ HRESULT get_event_handler(event_target_t **event_target, eventid_t eid, VARIANT
     return S_OK;
 }
 
-HRESULT attach_event(event_target_t **event_target_ptr, HTMLDocument *doc, BSTR name, IDispatch *disp, VARIANT_BOOL *res)
+HRESULT attach_event(event_target_t **event_target_ptr, nsIDOMNode *nsnode, HTMLDocument *doc, BSTR name,
+        IDispatch *disp, VARIANT_BOOL *res)
 {
     event_target_t *event_target;
     eventid_t eid;
@@ -1128,7 +1171,7 @@ HRESULT attach_event(event_target_t **event_target_ptr, HTMLDocument *doc, BSTR
     event_target->event_table[eid]->handlers[i] = disp;
 
     *res = VARIANT_TRUE;
-    return ensure_nsevent_handler(doc->doc_node, eid);
+    return ensure_nsevent_handler(doc->doc_node, event_target, nsnode, eid);
 }
 
 HRESULT detach_event(event_target_t *event_target, HTMLDocument *doc, BSTR name, IDispatch *disp)
@@ -1159,13 +1202,18 @@ HRESULT detach_event(event_target_t *event_target, HTMLDocument *doc, BSTR name,
     return S_OK;
 }
 
-void update_cp_events(HTMLWindow *window, cp_static_data_t *cp)
+void update_cp_events(HTMLWindow *window, event_target_t **event_target_ptr, cp_static_data_t *cp, nsIDOMNode *nsnode)
 {
+    event_target_t *event_target;
     int i;
 
+    event_target = get_event_target(event_target_ptr);
+    if(!event_target)
+        return; /* FIXME */
+
     for(i=0; i < EVENTID_LAST; i++) {
         if((event_info[i].flags & EVENT_DEFAULTLISTENER) && is_cp_event(cp, event_info[i].dispid))
-            ensure_nsevent_handler(window->doc, i);
+            ensure_nsevent_handler(window->doc, event_target, nsnode, i);
     }
 }
 
@@ -1194,7 +1242,7 @@ void check_event_attr(HTMLDocumentNode *doc, nsIDOMElement *nselem)
             disp = script_parse_event(doc->basedoc.window, attr_value);
             if(disp) {
                 node = get_node(doc, (nsIDOMNode*)nselem, TRUE);
-                set_event_handler_disp(get_node_event_target(node), node->doc, i, disp);
+                set_event_handler_disp(get_node_event_target(node), node->nsnode, node->doc, i, disp);
                 IDispatch_Release(disp);
             }
         }
index 96ff4cd..6ba2fe2 100644 (file)
@@ -42,14 +42,14 @@ typedef enum {
 eventid_t str_to_eid(LPCWSTR);
 void check_event_attr(HTMLDocumentNode*,nsIDOMElement*);
 void release_event_target(event_target_t*);
-void fire_event(HTMLDocumentNode*,eventid_t,nsIDOMNode*,nsIDOMEvent*);
-HRESULT set_event_handler(event_target_t**,HTMLDocumentNode*,eventid_t,VARIANT*);
+void fire_event(HTMLDocumentNode*,eventid_t,BOOL,nsIDOMNode*,nsIDOMEvent*);
+HRESULT set_event_handler(event_target_t**,nsIDOMNode*,HTMLDocumentNode*,eventid_t,VARIANT*);
 HRESULT get_event_handler(event_target_t**,eventid_t,VARIANT*);
-HRESULT attach_event(event_target_t**,HTMLDocument*,BSTR,IDispatch*,VARIANT_BOOL*);
+HRESULT attach_event(event_target_t**,nsIDOMNode*,HTMLDocument*,BSTR,IDispatch*,VARIANT_BOOL*);
 HRESULT detach_event(event_target_t*,HTMLDocument*,BSTR,IDispatch*);
 HRESULT dispatch_event(HTMLDOMNode*,const WCHAR*,VARIANT*,VARIANT_BOOL*);
 HRESULT call_event(HTMLDOMNode*,eventid_t);
-void update_cp_events(HTMLWindow*,cp_static_data_t*);
+void update_cp_events(HTMLWindow*,event_target_t**,cp_static_data_t*,nsIDOMNode*);
 
 static inline event_target_t **get_node_event_target(HTMLDOMNode *node)
 {
@@ -58,7 +58,7 @@ static inline event_target_t **get_node_event_target(HTMLDOMNode *node)
 
 static inline HRESULT set_node_event(HTMLDOMNode *node, eventid_t eid, VARIANT *var)
 {
-    return set_event_handler(get_node_event_target(node), node->doc, eid, var);
+    return set_event_handler(get_node_event_target(node), node->nsnode, node->doc, eid, var);
 }
 
 static inline HRESULT get_node_event(HTMLDOMNode *node, eventid_t eid, VARIANT *var)
index 17b6cce..a4448f9 100644 (file)
@@ -28,6 +28,7 @@
 #include "wine/debug.h"
 
 #include "mshtml_private.h"
+#include "htmlevent.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
 
@@ -388,15 +389,19 @@ static HRESULT WINAPI HTMLImgElement_get_align(IHTMLImgElement *iface, BSTR *p)
 static HRESULT WINAPI HTMLImgElement_put_onload(IHTMLImgElement *iface, VARIANT v)
 {
     HTMLImgElement *This = HTMLIMG_THIS(iface);
-    FIXME("(%p)->()\n", This);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
+
+    return set_node_event(&This->element.node, EVENTID_LOAD, &v);
 }
 
 static HRESULT WINAPI HTMLImgElement_get_onload(IHTMLImgElement *iface, VARIANT *p)
 {
     HTMLImgElement *This = HTMLIMG_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    return get_node_event(&This->element.node, EVENTID_LOAD, p);
 }
 
 static HRESULT WINAPI HTMLImgElement_put_onerror(IHTMLImgElement *iface, VARIANT v)
index 491625e..2aafaa3 100644 (file)
@@ -126,7 +126,7 @@ static inline HRESULT set_window_event(HTMLWindow *window, eventid_t eid, VARIAN
         return E_FAIL;
     }
 
-    return set_event_handler(&window->doc->body_event_target, window->doc, eid, var);
+    return set_event_handler(&window->doc->body_event_target, NULL, window->doc, eid, var);
 }
 
 static inline HRESULT get_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
@@ -1419,7 +1419,7 @@ static HRESULT WINAPI HTMLWindow3_attachEvent(IHTMLWindow3 *iface, BSTR event, I
         return E_FAIL;
     }
 
-    return attach_event(&This->doc->body_event_target, &This->doc->basedoc, event, pDisp, pfResult);
+    return attach_event(&This->doc->body_event_target, NULL, &This->doc->basedoc, event, pDisp, pfResult);
 }
 
 static HRESULT WINAPI HTMLWindow3_detachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp)
index 5a409b3..228be35 100644 (file)
@@ -736,7 +736,7 @@ nsresult get_nsinterface(nsISupports*,REFIID,void**);
 
 void init_nsevents(HTMLDocumentNode*);
 void release_nsevents(HTMLDocumentNode*);
-void add_nsevent_listener(HTMLDocumentNode*,LPCWSTR);
+void add_nsevent_listener(HTMLDocumentNode*,nsIDOMNode*,LPCWSTR);
 
 void set_window_bscallback(HTMLWindow*,nsChannelBSC*);
 void set_current_mon(HTMLWindow*,IMoniker*);
index 61ceca8..a794204 100644 (file)
@@ -338,6 +338,9 @@ static void handle_end_load(HTMLDocumentNode *This)
 
     TRACE("\n");
 
+    if(!This->basedoc.doc_obj)
+        return;
+
     if(This != This->basedoc.doc_obj->basedoc.doc_node) {
         set_ready_state(This->basedoc.window, READYSTATE_INTERACTIVE);
         return;
index a09ea7f..cc2aeb3 100644 (file)
@@ -972,8 +972,11 @@ static HRESULT read_stream_data(nsChannelBSC *This, IStream *stream)
 
             on_start_nsrequest(This);
 
-            if(This->window)
+            if(This->window) {
                 update_window_doc(This->window);
+                if(This->window->readystate != READYSTATE_LOADING)
+                    set_ready_state(This->window, READYSTATE_LOADING);
+            }
         }
 
         This->bsc.readed += This->nsstream->buf_size;
index 65bcae0..c491424 100644 (file)
@@ -216,7 +216,7 @@ static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event
 
     TRACE("(%p)\n", doc);
 
-    if(!doc)
+    if(!doc || !doc->basedoc.window)
         return NS_ERROR_FAILURE;
     doc_obj = doc->basedoc.doc_obj;
 
@@ -254,7 +254,7 @@ static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event
 
     nsIDOMHTMLDocument_GetBody(doc->nsdoc, &nsbody);
     if(nsbody) {
-        fire_event(doc, EVENTID_LOAD, (nsIDOMNode*)nsbody, event);
+        fire_event(doc, EVENTID_LOAD, TRUE, (nsIDOMNode*)nsbody, event);
         nsIDOMHTMLElement_Release(nsbody);
     }
 
@@ -271,6 +271,8 @@ static nsresult NSAPI handle_htmlevent(nsIDOMEventListener *iface, nsIDOMEvent *
     eventid_t eid;
     nsresult nsres;
 
+    TRACE("\n");
+
     nsAString_Init(&type_str, NULL);
     nsIDOMEvent_GetType(event, &type_str);
     nsAString_GetData(&type_str, &type);
@@ -290,7 +292,7 @@ static nsresult NSAPI handle_htmlevent(nsIDOMEventListener *iface, nsIDOMEvent *
         return NS_OK;
     }
 
-    fire_event(doc, eid, nsnode, event);
+    fire_event(doc, eid, TRUE, nsnode, event);
 
     nsIDOMNode_Release(nsnode);
 
@@ -334,12 +336,15 @@ static void init_listener(nsEventListener *This, nsDocumentEventListener *listen
     This->This = listener;
 }
 
-void add_nsevent_listener(HTMLDocumentNode *doc, LPCWSTR type)
+void add_nsevent_listener(HTMLDocumentNode *doc, nsIDOMNode *nsnode, LPCWSTR type)
 {
     nsIDOMEventTarget *target;
     nsresult nsres;
 
-    nsres = nsIDOMWindow_QueryInterface(doc->basedoc.window->nswindow, &IID_nsIDOMEventTarget, (void**)&target);
+    if(nsnode)
+        nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMEventTarget, (void**)&target);
+    else
+        nsres = nsIDOMWindow_QueryInterface(doc->basedoc.window->nswindow, &IID_nsIDOMEventTarget, (void**)&target);
     if(NS_FAILED(nsres)) {
         ERR("Could not get nsIDOMEventTarget interface: %08x\n", nsres);
         return;
index f4e6f4b..88a4e55 100644 (file)
@@ -904,7 +904,7 @@ static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListen
 
             open = FALSE;
         }else {
-            open = before_async_open(This, window->doc_obj->nscontainer);
+            open = !before_async_open(This, window->doc_obj->nscontainer);
             if(!open) {
                 TRACE("canceled\n");
                 nsres = NS_ERROR_UNEXPECTED;
index dc0fb4a..d127eef 100644 (file)
@@ -160,19 +160,28 @@ static HRESULT WINAPI OmNavigator_get_appVersion(IOmNavigator *iface, BSTR *p)
 {
     OmNavigator *This = OMNAVIGATOR_THIS(iface);
 
-    /* FIXME: Should we return something smarter? */
-    static const WCHAR app_verW[] =
-        {'4','.','0',' ','(','c','o','m','p','a','t','i','b','l','e',';',
-         ' ','M','S','I','E',' ','7','.','0',';',
-         ' ','W','i','n','d','o','w','s',' ','N','T',' ','5','.','1',';',
-         ' ','M','o','z','i','l','l','a','/','4','.','0',')',0};
+    char user_agent[512];
+    DWORD size;
+    HRESULT hres;
 
     TRACE("(%p)->(%p)\n", This, p);
 
-    *p = SysAllocString(app_verW);
+    size = sizeof(user_agent);
+    hres = ObtainUserAgentString(0, user_agent, &size);
+    if(FAILED(hres))
+        return hres;
+
+    if(strncmp(user_agent, "Mozilla/", 8)) {
+        FIXME("Unsupported user agent\n");
+        return E_FAIL;
+    }
+
+    size = MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, NULL, 0);
+    *p = SysAllocStringLen(NULL, size-1);
     if(!*p)
         return E_OUTOFMEMORY;
 
+    MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, *p, size);
     return S_OK;
 }
 
index 720a58e..44ccd0f 100644 (file)
@@ -108,6 +108,7 @@ static void set_progress_proc(task_t *_task)
         V_I4(&progress) = 0; /* FIXME */
         IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETPROGRESSPOS, OLECMDEXECOPT_DONTPROMPTUSER,
                                &progress, NULL);
+        IOleCommandTarget_Release(olecmd);
     }
 
     if(doc->usermode == EDITMODE && doc->hostui) {
@@ -282,11 +283,15 @@ HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, nsChannel
 void set_ready_state(HTMLWindow *window, READYSTATE readystate)
 {
     window->readystate = readystate;
+
     if(window->doc_obj && window->doc_obj->basedoc.window == window)
         call_property_onchanged(&window->doc_obj->basedoc.cp_propnotif, DISPID_READYSTATE);
+
+    fire_event(window->doc, EVENTID_READYSTATECHANGE, FALSE, window->doc->node.nsnode, NULL);
+
     if(window->frame_element)
         fire_event(window->frame_element->element.node.doc, EVENTID_READYSTATECHANGE,
-                   window->frame_element->element.node.nsnode, NULL);
+                   TRUE, window->frame_element->element.node.nsnode, NULL);
 }
 
 static HRESULT get_doc_string(HTMLDocumentNode *This, char **str)