diff --git a/dlls/mshtml/editor.c b/dlls/mshtml/editor.c
index 6cfd20ba9fa..000299a33f4 100644
--- a/dlls/mshtml/editor.c
+++ b/dlls/mshtml/editor.c
@@ -114,19 +114,9 @@ static void do_ns_editor_command(NSContainer *This, const char *cmd)
static nsresult get_ns_command_state(NSContainer *This, const char *cmd, nsICommandParams *nsparam)
{
nsICommandManager *cmdmgr;
- nsIInterfaceRequestor *iface_req;
nsresult nsres;
- nsres = nsIWebBrowser_QueryInterface(This->webbrowser,
- &IID_nsIInterfaceRequestor, (void**)&iface_req);
- if(NS_FAILED(nsres)) {
- ERR("Could not get nsIInterfaceRequestor: %08x\n", nsres);
- return nsres;
- }
-
- nsres = nsIInterfaceRequestor_GetInterface(iface_req, &IID_nsICommandManager,
- (void**)&cmdmgr);
- nsIInterfaceRequestor_Release(iface_req);
+ nsres = get_nsinterface((nsISupports*)This->webbrowser, &IID_nsICommandManager, (void**)&cmdmgr);
if(NS_FAILED(nsres)) {
ERR("Could not get nsICommandManager: %08x\n", nsres);
return nsres;
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 54eb810cf25..5a547d4a3fa 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -398,6 +398,7 @@ nsIWritableVariant *create_nsvariant(void);
void nsnode_to_nsstring(nsIDOMNode*,nsAString*);
void get_editor_controller(NSContainer*);
void init_nsevents(NSContainer*);
+nsresult get_nsinterface(nsISupports*,REFIID,void**);
BSCallback *create_bscallback(IMoniker*);
HRESULT start_binding(BSCallback*);
diff --git a/dlls/mshtml/nsembed.c b/dlls/mshtml/nsembed.c
index 2a6628b600a..4fcaf7cb48f 100644
--- a/dlls/mshtml/nsembed.c
+++ b/dlls/mshtml/nsembed.c
@@ -523,6 +523,21 @@ nsICommandParams *create_nscommand_params(void)
return ret;
}
+nsresult get_nsinterface(nsISupports *iface, REFIID riid, void **ppv)
+{
+ nsIInterfaceRequestor *iface_req;
+ nsresult nsres;
+
+ nsres = nsISupports_QueryInterface(iface, &IID_nsIInterfaceRequestor, (void**)&iface_req);
+ if(NS_FAILED(nsres))
+ return nsres;
+
+ nsres = nsIInterfaceRequestor_GetInterface(iface_req, riid, ppv);
+ nsIInterfaceRequestor_Release(iface_req);
+
+ return nsres;
+}
+
static void nsnode_to_nsstring_rec(nsIContentSerializer *serializer, nsIDOMNode *nsnode, nsAString *str)
{
nsIDOMNodeList *node_list = NULL;