Jacek Caban : mshtml: Moved READYSTATE to string conversion to separated function.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Oct 9 13:14:34 CDT 2014


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Oct  9 16:08:15 2014 +0200

mshtml: Moved READYSTATE to string conversion to separated function.

---

 dlls/mshtml/htmldoc.c        | 16 +---------------
 dlls/mshtml/htmlelem.c       | 21 +++++++++++++++++++++
 dlls/mshtml/mshtml_private.h |  1 +
 3 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index a8d6d76..c91298f 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -592,27 +592,13 @@ static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p
 {
     HTMLDocument *This = impl_from_IHTMLDocument2(iface);
 
-    static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
-    static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
-    static const WCHAR wszLoaded[] = {'l','o','a','d','e','d',0};
-    static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
-    static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
-
-    static const LPCWSTR readystate_str[] = {
-        wszUninitialized,
-        wszLoading,
-        wszLoaded,
-        wszInteractive,
-        wszComplete
-    };
 
     TRACE("(%p)->(%p)\n", iface, p);
 
     if(!p)
         return E_POINTER;
 
-    *p = SysAllocString(readystate_str[This->window->readystate]);
-    return S_OK;
+    return get_readystate_string(This->window->readystate, p);
 }
 
 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c
index 3037c10..2906581 100644
--- a/dlls/mshtml/htmlelem.c
+++ b/dlls/mshtml/htmlelem.c
@@ -218,6 +218,27 @@ HRESULT elem_string_attr_setter(HTMLElement *elem, const WCHAR *name, const WCHA
     return S_OK;
 }
 
+HRESULT get_readystate_string(READYSTATE readystate, BSTR *p)
+{
+    static const WCHAR uninitializedW[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
+    static const WCHAR loadingW[] = {'l','o','a','d','i','n','g',0};
+    static const WCHAR loadedW[] = {'l','o','a','d','e','d',0};
+    static const WCHAR interactiveW[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
+    static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
+
+    static const LPCWSTR readystate_strs[] = {
+        uninitializedW,
+        loadingW,
+        loadedW,
+        interactiveW,
+        completeW
+    };
+
+    assert(readystate <= READYSTATE_COMPLETE);
+    *p = SysAllocString(readystate_strs[readystate]);
+    return *p ? S_OK : E_OUTOFMEMORY;
+}
+
 typedef struct
 {
     DispatchEx dispex;
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 78d61f0..31c08ad 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -851,6 +851,7 @@ void set_download_state(HTMLDocumentObj*,int) DECLSPEC_HIDDEN;
 void call_docview_84(HTMLDocumentObj*) DECLSPEC_HIDDEN;
 
 void set_ready_state(HTMLOuterWindow*,READYSTATE) DECLSPEC_HIDDEN;
+HRESULT get_readystate_string(READYSTATE,BSTR*) DECLSPEC_HIDDEN;
 
 HRESULT HTMLSelectionObject_Create(HTMLDocumentNode*,nsISelection*,IHTMLSelectionObject**) DECLSPEC_HIDDEN;
 HRESULT HTMLTxtRange_Create(HTMLDocumentNode*,nsIDOMRange*,IHTMLTxtRange**) DECLSPEC_HIDDEN;




More information about the wine-cvs mailing list