From 2b0013128f065e466d1e373afdb3fac75ae36ec9 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 9 Oct 2008 15:36:01 -0500 Subject: [PATCH] mshtml: Moved events declaration to separated file. --- dlls/mshtml/htmlelem.c | 1 + dlls/mshtml/htmlevent.c | 15 ++++++++++++--- dlls/mshtml/htmlevent.h | 31 +++++++++++++++++++++++++++++++ dlls/mshtml/htmlnode.c | 1 + dlls/mshtml/htmlselect.c | 1 + dlls/mshtml/mshtml_private.h | 16 +--------------- dlls/mshtml/nsembed.c | 1 + dlls/mshtml/nsevents.c | 1 + 8 files changed, 49 insertions(+), 18 deletions(-) create mode 100644 dlls/mshtml/htmlevent.h diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index 1216838d47c..60fd574b454 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -32,6 +32,7 @@ #include "wine/unicode.h" #include "mshtml_private.h" +#include "htmlevent.h" WINE_DEFAULT_DEBUG_CHANNEL(mshtml); diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c index 3c56e871546..d72b936102b 100644 --- a/dlls/mshtml/htmlevent.c +++ b/dlls/mshtml/htmlevent.c @@ -26,6 +26,7 @@ #include "ole2.h" #include "mshtml_private.h" +#include "htmlevent.h" #include "wine/debug.h" @@ -435,9 +436,17 @@ static HRESULT set_node_event_disp(HTMLDOMNode *node, eventid_t eid, IDispatch * IDispatch_AddRef(disp); node->event_target->event_table[eid] = disp; - if((event_info[eid].flags & EVENT_DEFAULTLISTENER) && !node->doc->nscontainer->event_vector[eid]) { - node->doc->nscontainer->event_vector[eid] = TRUE; - add_nsevent_listener(node->doc->nscontainer, event_info[eid].name); + if(event_info[eid].flags & EVENT_DEFAULTLISTENER) { + if(!node->doc->nscontainer->event_vector) { + node->doc->nscontainer->event_vector = heap_alloc_zero(EVENTID_LAST*sizeof(BOOL)); + if(!node->doc->nscontainer->event_vector) + return E_OUTOFMEMORY; + } + + if(!node->doc->nscontainer->event_vector[eid]) { + node->doc->nscontainer->event_vector[eid] = TRUE; + add_nsevent_listener(node->doc->nscontainer, event_info[eid].name); + } } return S_OK; diff --git a/dlls/mshtml/htmlevent.h b/dlls/mshtml/htmlevent.h new file mode 100644 index 00000000000..adc769265cd --- /dev/null +++ b/dlls/mshtml/htmlevent.h @@ -0,0 +1,31 @@ +/* + * Copyright 2008 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +typedef enum { + EVENTID_CHANGE, + EVENTID_CLICK, + EVENTID_KEYUP, + EVENTID_LOAD, + EVENTID_LAST +} eventid_t; + +eventid_t str_to_eid(LPCWSTR); +void check_event_attr(HTMLDocument*,nsIDOMElement*); +void release_event_target(event_target_t*); +void fire_event(HTMLDocument*,eventid_t,nsIDOMNode*); +HRESULT set_node_event(HTMLDOMNode*,eventid_t,VARIANT*); diff --git a/dlls/mshtml/htmlnode.c b/dlls/mshtml/htmlnode.c index e9237950985..a3eaaaf395e 100644 --- a/dlls/mshtml/htmlnode.c +++ b/dlls/mshtml/htmlnode.c @@ -28,6 +28,7 @@ #include "wine/debug.h" #include "mshtml_private.h" +#include "htmlevent.h" WINE_DEFAULT_DEBUG_CHANNEL(mshtml); diff --git a/dlls/mshtml/htmlselect.c b/dlls/mshtml/htmlselect.c index ca24954c348..3a414cfcbcf 100644 --- a/dlls/mshtml/htmlselect.c +++ b/dlls/mshtml/htmlselect.c @@ -28,6 +28,7 @@ #include "wine/debug.h" #include "mshtml_private.h" +#include "htmlevent.h" WINE_DEFAULT_DEBUG_CHANNEL(mshtml); diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index cfbe8f2ded4..a58cfef32a3 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -116,14 +116,6 @@ typedef enum { LAST_tid } tid_t; -typedef enum { - EVENTID_CHANGE, - EVENTID_CLICK, - EVENTID_KEYUP, - EVENTID_LOAD, - EVENTID_LAST -} eventid_t; - typedef struct dispex_data_t dispex_data_t; typedef struct dispex_dynamic_data_t dispex_dynamic_data_t; @@ -340,7 +332,7 @@ struct NSContainer { nsChannelBSC *bscallback; /* hack */ HWND reset_focus; /* hack */ - BOOL event_vector[EVENTID_LAST]; + BOOL *event_vector; }; typedef struct { @@ -537,12 +529,6 @@ void add_nsevent_listener(NSContainer*,LPCWSTR); nsresult get_nsinterface(nsISupports*,REFIID,void**); void update_nsdocument(HTMLDocument*); -void check_event_attr(HTMLDocument*,nsIDOMElement*); -void release_event_target(event_target_t*); -void fire_event(HTMLDocument*,eventid_t,nsIDOMNode*); -HRESULT set_node_event(HTMLDOMNode*,eventid_t,VARIANT*); -eventid_t str_to_eid(LPCWSTR); - void set_document_bscallback(HTMLDocument*,nsChannelBSC*); void set_current_mon(HTMLDocument*,IMoniker*); HRESULT start_binding(HTMLDocument*,BSCallback*,IBindCtx*); diff --git a/dlls/mshtml/nsembed.c b/dlls/mshtml/nsembed.c index 94707c2649d..45386beaee3 100644 --- a/dlls/mshtml/nsembed.c +++ b/dlls/mshtml/nsembed.c @@ -984,6 +984,7 @@ static nsrefcnt NSAPI nsWebBrowserChrome_Release(nsIWebBrowserChrome *iface) TRACE("(%p) ref=%d\n", This, ref); if(!ref) { + heap_free(This->event_vector); if(This->parent) nsIWebBrowserChrome_Release(NSWBCHROME(This->parent)); heap_free(This); diff --git a/dlls/mshtml/nsevents.c b/dlls/mshtml/nsevents.c index b6cc0f83f6b..dc54322393a 100644 --- a/dlls/mshtml/nsevents.c +++ b/dlls/mshtml/nsevents.c @@ -31,6 +31,7 @@ #include "wine/unicode.h" #include "mshtml_private.h" +#include "htmlevent.h" WINE_DEFAULT_DEBUG_CHANNEL(mshtml); -- 2.11.4.GIT