From: Gabriel Ivăncescu gabrielopcode@gmail.com
And likewise from the window, so we know when to detach it.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com ---
Needed by performance.timing (and in future patches as well). --- dlls/mshtml/htmlwindow.c | 17 +++++++++-------- dlls/mshtml/mshtml_private.h | 7 +++++-- dlls/mshtml/omnavigator.c | 14 ++++++++++++-- 3 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index baaedb6b6d4..1d3c71d83bf 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -308,6 +308,10 @@ static void release_inner_window(HTMLInnerWindow *This) IHTMLStorage_Release(This->local_storage); }
+ if(This->performance_obj && This->performance_obj != NO_PERFORMANCE_OBJ) + detach_performance(This->performance_obj); + VariantClear(&This->performance); + if(This->mon) IMoniker_Release(This->mon);
@@ -2414,9 +2418,9 @@ static HRESULT WINAPI HTMLWindow7_put_performance(IHTMLWindow7 *iface, VARIANT v
TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
- if(!This->performance_initialized) { + if(!This->performance_obj) { V_VT(&This->performance) = VT_EMPTY; - This->performance_initialized = TRUE; + This->performance_obj = NO_PERFORMANCE_OBJ; }
return VariantCopy(&This->performance, &v); @@ -2429,16 +2433,13 @@ static HRESULT WINAPI HTMLWindow7_get_performance(IHTMLWindow7 *iface, VARIANT *
TRACE("(%p)->(%p)\n", This, p);
- if(!This->performance_initialized) { - IHTMLPerformance *performance; - - hres = create_performance(dispex_compat_mode(&This->event_target.dispex), &performance); + if(!This->performance_obj) { + hres = create_performance(This, &This->performance_obj); if(FAILED(hres)) return hres;
V_VT(&This->performance) = VT_DISPATCH; - V_DISPATCH(&This->performance) = (IDispatch*)performance; - This->performance_initialized = TRUE; + V_DISPATCH(&This->performance) = (IDispatch*)This->performance_obj; }
V_VT(p) = VT_NULL; diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index d9e2d93d220..e8dd0997639 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -577,7 +577,7 @@ struct HTMLInnerWindow { IHTMLStorage *session_storage; IHTMLStorage *local_storage;
- BOOL performance_initialized; + IHTMLPerformance *performance_obj; VARIANT performance;
unsigned parser_callback_cnt; @@ -596,6 +596,8 @@ struct HTMLInnerWindow { struct list bindings; };
+#define NO_PERFORMANCE_OBJ ((IHTMLPerformance*)IntToPtr(-1)) + typedef enum { UNKNOWN_USERMODE, BROWSEMODE, @@ -966,7 +968,8 @@ HRESULT HTMLXMLHttpRequestFactory_Create(HTMLInnerWindow*,HTMLXMLHttpRequestFact HRESULT HTMLLocation_Create(HTMLInnerWindow*,HTMLLocation**) DECLSPEC_HIDDEN; HRESULT create_navigator(compat_mode_t,IOmNavigator**) DECLSPEC_HIDDEN; HRESULT create_html_screen(compat_mode_t,IHTMLScreen**) DECLSPEC_HIDDEN; -HRESULT create_performance(compat_mode_t,IHTMLPerformance**) DECLSPEC_HIDDEN; +HRESULT create_performance(HTMLInnerWindow*,IHTMLPerformance**) DECLSPEC_HIDDEN; +void detach_performance(IHTMLPerformance*) DECLSPEC_HIDDEN; HRESULT create_history(HTMLInnerWindow*,OmHistory**) DECLSPEC_HIDDEN; HRESULT create_namespace_collection(compat_mode_t,IHTMLNamespaceCollection**) DECLSPEC_HIDDEN; HRESULT create_dom_implementation(HTMLDocumentNode*,IHTMLDOMImplementation**) DECLSPEC_HIDDEN; diff --git a/dlls/mshtml/omnavigator.c b/dlls/mshtml/omnavigator.c index db48cc6213b..f25cce2c105 100644 --- a/dlls/mshtml/omnavigator.c +++ b/dlls/mshtml/omnavigator.c @@ -2023,6 +2023,7 @@ typedef struct {
IHTMLPerformanceNavigation *navigation; IHTMLPerformanceTiming *timing; + HTMLInnerWindow *window; } HTMLPerformance;
static inline HTMLPerformance *impl_from_IHTMLPerformance(IHTMLPerformance *iface) @@ -2070,6 +2071,8 @@ static ULONG WINAPI HTMLPerformance_Release(IHTMLPerformance *iface) TRACE("(%p) ref=%ld\n", This, ref);
if(!ref) { + if(This->window) + This->window->performance_obj = NO_PERFORMANCE_OBJ; if(This->timing) IHTMLPerformanceTiming_Release(This->timing); if(This->navigation) @@ -2208,7 +2211,7 @@ static dispex_static_data_t HTMLPerformance_dispex = { HTMLPerformance_iface_tids };
-HRESULT create_performance(compat_mode_t compat_mode, IHTMLPerformance **ret) +HRESULT create_performance(HTMLInnerWindow *window, IHTMLPerformance **ret) { HTMLPerformance *performance;
@@ -2218,14 +2221,21 @@ HRESULT create_performance(compat_mode_t compat_mode, IHTMLPerformance **ret)
performance->IHTMLPerformance_iface.lpVtbl = &HTMLPerformanceVtbl; performance->ref = 1; + performance->window = window;
init_dispatch(&performance->dispex, (IUnknown*)&performance->IHTMLPerformance_iface, - &HTMLPerformance_dispex, compat_mode); + &HTMLPerformance_dispex, dispex_compat_mode(&window->event_target.dispex));
*ret = &performance->IHTMLPerformance_iface; return S_OK; }
+void detach_performance(IHTMLPerformance *iface) +{ + HTMLPerformance *performance = impl_from_IHTMLPerformance(iface); + performance->window = NULL; +} + typedef struct { DispatchEx dispex; IHTMLNamespaceCollection IHTMLNamespaceCollection_iface;