Jacek Caban : mshtml: Moved style_tbl lookup to separated function.
Alexandre Julliard
julliard at winehq.org
Mon Apr 16 13:35:46 CDT 2012
Module: wine
Branch: master
Commit: a9c83385b59d510568a0cd73bb9693e7b0d235f4
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a9c83385b59d510568a0cd73bb9693e7b0d235f4
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Apr 16 13:48:55 2012 +0200
mshtml: Moved style_tbl lookup to separated function.
---
dlls/mshtml/htmlstyle.c | 45 +++++++++++++++++++++++++++++----------------
1 files changed, 29 insertions(+), 16 deletions(-)
diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c
index 4f94c5c..1f8947c 100644
--- a/dlls/mshtml/htmlstyle.c
+++ b/dlls/mshtml/htmlstyle.c
@@ -173,10 +173,12 @@ static const WCHAR attrWordWrap[] =
static const WCHAR attrZIndex[] =
{'z','-','i','n','d','e','x',0};
-static const struct{
+typedef struct {
const WCHAR *name;
DISPID dispid;
-} style_tbl[] = {
+} style_tbl_entry_t;
+
+static const style_tbl_entry_t style_tbl[] = {
{attrBackground, DISPID_IHTMLSTYLE_BACKGROUND},
{attrBackgroundColor, DISPID_IHTMLSTYLE_BACKGROUNDCOLOR},
{attrBackgroundImage, DISPID_IHTMLSTYLE_BACKGROUNDIMAGE},
@@ -264,6 +266,26 @@ static const WCHAR valBlink[] =
static const WCHAR px_formatW[] = {'%','d','p','x',0};
static const WCHAR emptyW[] = {0};
+static const style_tbl_entry_t *lookup_style_tbl(const WCHAR *name)
+{
+ int c, i, min = 0, max = sizeof(style_tbl)/sizeof(*style_tbl)-1;
+
+ while(min <= max) {
+ i = (min+max)/2;
+
+ c = strcmpW(style_tbl[i].name, name);
+ if(!c)
+ return style_tbl+i;
+
+ if(c > 0)
+ max = i-1;
+ else
+ min = i+1;
+ }
+
+ return NULL;
+}
+
static LPWSTR fix_px_value(LPCWSTR val)
{
LPCWSTR ptr = val;
@@ -2929,21 +2951,12 @@ static const IHTMLStyleVtbl HTMLStyleVtbl = {
static HRESULT HTMLStyle_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
{
- int c, i, min=0, max = sizeof(style_tbl)/sizeof(*style_tbl)-1;
-
- while(min <= max) {
- i = (min+max)/2;
-
- c = strcmpW(style_tbl[i].name, name);
- if(!c) {
- *dispid = style_tbl[i].dispid;
- return S_OK;
- }
+ const style_tbl_entry_t *style_entry;
- if(c > 0)
- max = i-1;
- else
- min = i+1;
+ style_entry = lookup_style_tbl(name);
+ if(style_entry) {
+ *dispid = style_entry->dispid;
+ return S_OK;
}
return DISP_E_UNKNOWNNAME;
More information about the wine-cvs
mailing list