Reactos
at master 765 lines 25 kB view raw
1/* 2 * Copyright 2006 Jacek Caban for CodeWeavers 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 17 */ 18 19#include "mshtml_private.h" 20 21struct HTMLStyleSheet { 22 DispatchEx dispex; 23 IHTMLStyleSheet IHTMLStyleSheet_iface; 24 25 LONG ref; 26 27 nsIDOMCSSStyleSheet *nsstylesheet; 28}; 29 30struct HTMLStyleSheetsCollection { 31 DispatchEx dispex; 32 IHTMLStyleSheetsCollection IHTMLStyleSheetsCollection_iface; 33 34 LONG ref; 35 36 nsIDOMStyleSheetList *nslist; 37}; 38 39struct HTMLStyleSheetRulesCollection { 40 DispatchEx dispex; 41 IHTMLStyleSheetRulesCollection IHTMLStyleSheetRulesCollection_iface; 42 43 LONG ref; 44 45 nsIDOMCSSRuleList *nslist; 46}; 47 48static inline HTMLStyleSheetRulesCollection *impl_from_IHTMLStyleSheetRulesCollection(IHTMLStyleSheetRulesCollection *iface) 49{ 50 return CONTAINING_RECORD(iface, HTMLStyleSheetRulesCollection, IHTMLStyleSheetRulesCollection_iface); 51} 52 53static HRESULT WINAPI HTMLStyleSheetRulesCollection_QueryInterface(IHTMLStyleSheetRulesCollection *iface, 54 REFIID riid, void **ppv) 55{ 56 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface); 57 58 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv); 59 60 if(IsEqualGUID(&IID_IUnknown, riid)) { 61 *ppv = &This->IHTMLStyleSheetRulesCollection_iface; 62 }else if(IsEqualGUID(&IID_IHTMLStyleSheetRulesCollection, riid)) { 63 *ppv = &This->IHTMLStyleSheetRulesCollection_iface; 64 }else if(dispex_query_interface(&This->dispex, riid, ppv)) { 65 return *ppv ? S_OK : E_NOINTERFACE; 66 }else { 67 *ppv = NULL; 68 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv); 69 return E_NOINTERFACE; 70 } 71 72 IUnknown_AddRef((IUnknown*)*ppv); 73 return S_OK; 74} 75 76static ULONG WINAPI HTMLStyleSheetRulesCollection_AddRef(IHTMLStyleSheetRulesCollection *iface) 77{ 78 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface); 79 LONG ref = InterlockedIncrement(&This->ref); 80 81 TRACE("(%p) ref=%d\n", This, ref); 82 83 return ref; 84} 85 86static ULONG WINAPI HTMLStyleSheetRulesCollection_Release(IHTMLStyleSheetRulesCollection *iface) 87{ 88 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface); 89 LONG ref = InterlockedDecrement(&This->ref); 90 91 TRACE("(%p) ref=%d\n", This, ref); 92 93 if(!ref) { 94 release_dispex(&This->dispex); 95 if(This->nslist) 96 nsIDOMCSSRuleList_Release(This->nslist); 97 heap_free(This); 98 } 99 100 return ref; 101} 102 103static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetTypeInfoCount( 104 IHTMLStyleSheetRulesCollection *iface, UINT *pctinfo) 105{ 106 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface); 107 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo); 108} 109 110static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetTypeInfo(IHTMLStyleSheetRulesCollection *iface, 111 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) 112{ 113 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface); 114 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo); 115} 116 117static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetIDsOfNames(IHTMLStyleSheetRulesCollection *iface, 118 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) 119{ 120 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface); 121 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames, 122 lcid, rgDispId); 123} 124 125static HRESULT WINAPI HTMLStyleSheetRulesCollection_Invoke(IHTMLStyleSheetRulesCollection *iface, 126 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, 127 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) 128{ 129 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface); 130 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags, 131 pDispParams, pVarResult, pExcepInfo, puArgErr); 132} 133 134static HRESULT WINAPI HTMLStyleSheetRulesCollection_get_length(IHTMLStyleSheetRulesCollection *iface, 135 LONG *p) 136{ 137 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface); 138 UINT32 len = 0; 139 140 TRACE("(%p)->(%p)\n", This, p); 141 142 if(This->nslist) { 143 nsresult nsres; 144 145 nsres = nsIDOMCSSRuleList_GetLength(This->nslist, &len); 146 if(NS_FAILED(nsres)) 147 ERR("GetLength failed: %08x\n", nsres); 148 } 149 150 *p = len; 151 return S_OK; 152} 153 154static HRESULT WINAPI HTMLStyleSheetRulesCollection_item(IHTMLStyleSheetRulesCollection *iface, 155 LONG index, IHTMLStyleSheetRule **ppHTMLStyleSheetRule) 156{ 157 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface); 158 FIXME("(%p)->(%d %p)\n", This, index, ppHTMLStyleSheetRule); 159 return E_NOTIMPL; 160} 161 162static const IHTMLStyleSheetRulesCollectionVtbl HTMLStyleSheetRulesCollectionVtbl = { 163 HTMLStyleSheetRulesCollection_QueryInterface, 164 HTMLStyleSheetRulesCollection_AddRef, 165 HTMLStyleSheetRulesCollection_Release, 166 HTMLStyleSheetRulesCollection_GetTypeInfoCount, 167 HTMLStyleSheetRulesCollection_GetTypeInfo, 168 HTMLStyleSheetRulesCollection_GetIDsOfNames, 169 HTMLStyleSheetRulesCollection_Invoke, 170 HTMLStyleSheetRulesCollection_get_length, 171 HTMLStyleSheetRulesCollection_item 172}; 173 174static const tid_t HTMLStyleSheetRulesCollection_iface_tids[] = { 175 IHTMLStyleSheetRulesCollection_tid, 176 0 177}; 178static dispex_static_data_t HTMLStyleSheetRulesCollection_dispex = { 179 NULL, 180 DispHTMLStyleSheetRulesCollection_tid, 181 NULL, 182 HTMLStyleSheetRulesCollection_iface_tids 183}; 184 185static IHTMLStyleSheetRulesCollection *HTMLStyleSheetRulesCollection_Create(nsIDOMCSSRuleList *nslist) 186{ 187 HTMLStyleSheetRulesCollection *ret; 188 189 ret = heap_alloc(sizeof(*ret)); 190 ret->IHTMLStyleSheetRulesCollection_iface.lpVtbl = &HTMLStyleSheetRulesCollectionVtbl; 191 ret->ref = 1; 192 ret->nslist = nslist; 193 194 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLStyleSheetRulesCollection_iface, &HTMLStyleSheetRulesCollection_dispex); 195 196 if(nslist) 197 nsIDOMCSSRuleList_AddRef(nslist); 198 199 return &ret->IHTMLStyleSheetRulesCollection_iface; 200} 201 202static inline HTMLStyleSheetsCollection *impl_from_IHTMLStyleSheetsCollection(IHTMLStyleSheetsCollection *iface) 203{ 204 return CONTAINING_RECORD(iface, HTMLStyleSheetsCollection, IHTMLStyleSheetsCollection_iface); 205} 206 207static HRESULT WINAPI HTMLStyleSheetsCollection_QueryInterface(IHTMLStyleSheetsCollection *iface, 208 REFIID riid, void **ppv) 209{ 210 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface); 211 212 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv); 213 214 if(IsEqualGUID(&IID_IUnknown, riid)) { 215 *ppv = &This->IHTMLStyleSheetsCollection_iface; 216 }else if(IsEqualGUID(&IID_IDispatch, riid)) { 217 *ppv = &This->IHTMLStyleSheetsCollection_iface; 218 }else if(IsEqualGUID(&IID_IHTMLStyleSheetsCollection, riid)) { 219 *ppv = &This->IHTMLStyleSheetsCollection_iface; 220 }else if(dispex_query_interface(&This->dispex, riid, ppv)) { 221 return *ppv ? S_OK : E_NOINTERFACE; 222 }else { 223 *ppv = NULL; 224 WARN("unsupported %s\n", debugstr_mshtml_guid(riid)); 225 return E_NOINTERFACE; 226 } 227 228 IUnknown_AddRef((IUnknown*)*ppv); 229 return S_OK; 230} 231 232static ULONG WINAPI HTMLStyleSheetsCollection_AddRef(IHTMLStyleSheetsCollection *iface) 233{ 234 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface); 235 LONG ref = InterlockedIncrement(&This->ref); 236 237 TRACE("(%p) ref=%d\n", This, ref); 238 239 return ref; 240} 241 242static ULONG WINAPI HTMLStyleSheetsCollection_Release(IHTMLStyleSheetsCollection *iface) 243{ 244 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface); 245 LONG ref = InterlockedDecrement(&This->ref); 246 247 TRACE("(%p) ref=%d\n", This, ref); 248 249 if(!ref) { 250 release_dispex(&This->dispex); 251 if(This->nslist) 252 nsIDOMStyleSheetList_Release(This->nslist); 253 heap_free(This); 254 } 255 256 return ref; 257} 258 259static HRESULT WINAPI HTMLStyleSheetsCollection_GetTypeInfoCount(IHTMLStyleSheetsCollection *iface, 260 UINT *pctinfo) 261{ 262 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface); 263 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo); 264} 265 266static HRESULT WINAPI HTMLStyleSheetsCollection_GetTypeInfo(IHTMLStyleSheetsCollection *iface, 267 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) 268{ 269 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface); 270 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo); 271} 272 273static HRESULT WINAPI HTMLStyleSheetsCollection_GetIDsOfNames(IHTMLStyleSheetsCollection *iface, 274 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) 275{ 276 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface); 277 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames, 278 lcid, rgDispId); 279} 280 281static HRESULT WINAPI HTMLStyleSheetsCollection_Invoke(IHTMLStyleSheetsCollection *iface, 282 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, 283 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) 284{ 285 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface); 286 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, 287 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); 288} 289 290static HRESULT WINAPI HTMLStyleSheetsCollection_get_length(IHTMLStyleSheetsCollection *iface, 291 LONG *p) 292{ 293 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface); 294 UINT32 len = 0; 295 296 TRACE("(%p)->(%p)\n", This, p); 297 298 if(This->nslist) 299 nsIDOMStyleSheetList_GetLength(This->nslist, &len); 300 301 *p = len; 302 return S_OK; 303} 304 305static HRESULT WINAPI HTMLStyleSheetsCollection_get__newEnum(IHTMLStyleSheetsCollection *iface, 306 IUnknown **p) 307{ 308 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface); 309 FIXME("(%p)->(%p)\n", This, p); 310 return E_NOTIMPL; 311} 312 313static HRESULT WINAPI HTMLStyleSheetsCollection_item(IHTMLStyleSheetsCollection *iface, 314 VARIANT *pvarIndex, VARIANT *pvarResult) 315{ 316 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface); 317 318 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(pvarIndex), pvarResult); 319 320 switch(V_VT(pvarIndex)) { 321 case VT_I4: { 322 nsIDOMStyleSheet *nsstylesheet; 323 nsresult nsres; 324 325 TRACE("index=%d\n", V_I4(pvarIndex)); 326 327 nsres = nsIDOMStyleSheetList_Item(This->nslist, V_I4(pvarIndex), &nsstylesheet); 328 if(NS_FAILED(nsres) || !nsstylesheet) { 329 WARN("Item failed: %08x\n", nsres); 330 V_VT(pvarResult) = VT_EMPTY; 331 return E_INVALIDARG; 332 } 333 334 V_VT(pvarResult) = VT_DISPATCH; 335 V_DISPATCH(pvarResult) = (IDispatch*)HTMLStyleSheet_Create(nsstylesheet); 336 337 return S_OK; 338 } 339 340 case VT_BSTR: 341 FIXME("id=%s not implemented\n", debugstr_w(V_BSTR(pvarResult))); 342 return E_NOTIMPL; 343 344 default: 345 WARN("Invalid index %s\n", debugstr_variant(pvarIndex)); 346 } 347 348 return E_INVALIDARG; 349} 350 351static const IHTMLStyleSheetsCollectionVtbl HTMLStyleSheetsCollectionVtbl = { 352 HTMLStyleSheetsCollection_QueryInterface, 353 HTMLStyleSheetsCollection_AddRef, 354 HTMLStyleSheetsCollection_Release, 355 HTMLStyleSheetsCollection_GetTypeInfoCount, 356 HTMLStyleSheetsCollection_GetTypeInfo, 357 HTMLStyleSheetsCollection_GetIDsOfNames, 358 HTMLStyleSheetsCollection_Invoke, 359 HTMLStyleSheetsCollection_get_length, 360 HTMLStyleSheetsCollection_get__newEnum, 361 HTMLStyleSheetsCollection_item 362}; 363 364static const tid_t HTMLStyleSheetsCollection_iface_tids[] = { 365 IHTMLStyleSheetsCollection_tid, 366 0 367}; 368static dispex_static_data_t HTMLStyleSheetsCollection_dispex = { 369 NULL, 370 DispHTMLStyleSheetsCollection_tid, 371 NULL, 372 HTMLStyleSheetsCollection_iface_tids 373}; 374 375IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList *nslist) 376{ 377 HTMLStyleSheetsCollection *ret = heap_alloc(sizeof(HTMLStyleSheetsCollection)); 378 379 ret->IHTMLStyleSheetsCollection_iface.lpVtbl = &HTMLStyleSheetsCollectionVtbl; 380 ret->ref = 1; 381 382 if(nslist) 383 nsIDOMStyleSheetList_AddRef(nslist); 384 ret->nslist = nslist; 385 386 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLStyleSheetsCollection_iface, 387 &HTMLStyleSheetsCollection_dispex); 388 389 return &ret->IHTMLStyleSheetsCollection_iface; 390} 391 392static inline HTMLStyleSheet *impl_from_IHTMLStyleSheet(IHTMLStyleSheet *iface) 393{ 394 return CONTAINING_RECORD(iface, HTMLStyleSheet, IHTMLStyleSheet_iface); 395} 396 397static HRESULT WINAPI HTMLStyleSheet_QueryInterface(IHTMLStyleSheet *iface, REFIID riid, void **ppv) 398{ 399 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 400 401 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv); 402 403 if(IsEqualGUID(&IID_IUnknown, riid)) { 404 *ppv = &This->IHTMLStyleSheet_iface; 405 }else if(IsEqualGUID(&IID_IDispatch, riid)) { 406 *ppv = &This->IHTMLStyleSheet_iface; 407 }else if(IsEqualGUID(&IID_IHTMLStyleSheet, riid)) { 408 *ppv = &This->IHTMLStyleSheet_iface; 409 }else if(dispex_query_interface(&This->dispex, riid, ppv)) { 410 return *ppv ? S_OK : E_NOINTERFACE; 411 }else { 412 *ppv = NULL; 413 WARN("unsupported %s\n", debugstr_mshtml_guid(riid)); 414 return E_NOINTERFACE; 415 } 416 417 IUnknown_AddRef((IUnknown*)*ppv); 418 return S_OK; 419} 420 421static ULONG WINAPI HTMLStyleSheet_AddRef(IHTMLStyleSheet *iface) 422{ 423 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 424 LONG ref = InterlockedIncrement(&This->ref); 425 426 TRACE("(%p) ref=%d\n", This, ref); 427 428 return ref; 429} 430 431static ULONG WINAPI HTMLStyleSheet_Release(IHTMLStyleSheet *iface) 432{ 433 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 434 LONG ref = InterlockedDecrement(&This->ref); 435 436 TRACE("(%p) ref=%d\n", This, ref); 437 438 if(!ref) { 439 release_dispex(&This->dispex); 440 if(This->nsstylesheet) 441 nsIDOMCSSStyleSheet_Release(This->nsstylesheet); 442 heap_free(This); 443 } 444 445 return ref; 446} 447 448static HRESULT WINAPI HTMLStyleSheet_GetTypeInfoCount(IHTMLStyleSheet *iface, UINT *pctinfo) 449{ 450 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 451 TRACE("(%p)->(%p)\n", This, pctinfo); 452 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo); 453} 454 455static HRESULT WINAPI HTMLStyleSheet_GetTypeInfo(IHTMLStyleSheet *iface, UINT iTInfo, 456 LCID lcid, ITypeInfo **ppTInfo) 457{ 458 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 459 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo); 460} 461 462static HRESULT WINAPI HTMLStyleSheet_GetIDsOfNames(IHTMLStyleSheet *iface, REFIID riid, 463 LPOLESTR *rgszNames, UINT cNames, 464 LCID lcid, DISPID *rgDispId) 465{ 466 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 467 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId); 468} 469 470static HRESULT WINAPI HTMLStyleSheet_Invoke(IHTMLStyleSheet *iface, DISPID dispIdMember, 471 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, 472 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) 473{ 474 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 475 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags, pDispParams, 476 pVarResult, pExcepInfo, puArgErr); 477} 478 479static HRESULT WINAPI HTMLStyleSheet_put_title(IHTMLStyleSheet *iface, BSTR v) 480{ 481 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 482 FIXME("(%p)->(%s)\n", This, debugstr_w(v)); 483 return E_NOTIMPL; 484} 485 486static HRESULT WINAPI HTMLStyleSheet_get_title(IHTMLStyleSheet *iface, BSTR *p) 487{ 488 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 489 FIXME("(%p)->(%p)\n", This, p); 490 return E_NOTIMPL; 491} 492 493static HRESULT WINAPI HTMLStyleSheet_get_parentStyleSheet(IHTMLStyleSheet *iface, 494 IHTMLStyleSheet **p) 495{ 496 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 497 FIXME("(%p)->(%p)\n", This, p); 498 return E_NOTIMPL; 499} 500 501static HRESULT WINAPI HTMLStyleSheet_get_owningElement(IHTMLStyleSheet *iface, IHTMLElement **p) 502{ 503 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 504 FIXME("(%p)->(%p)\n", This, p); 505 return E_NOTIMPL; 506} 507 508static HRESULT WINAPI HTMLStyleSheet_put_disabled(IHTMLStyleSheet *iface, VARIANT_BOOL v) 509{ 510 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 511 FIXME("(%p)->(%x)\n", This, v); 512 return E_NOTIMPL; 513} 514 515static HRESULT WINAPI HTMLStyleSheet_get_disabled(IHTMLStyleSheet *iface, VARIANT_BOOL *p) 516{ 517 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 518 FIXME("(%p)->(%p)\n", This, p); 519 return E_NOTIMPL; 520} 521 522static HRESULT WINAPI HTMLStyleSheet_get_readOnly(IHTMLStyleSheet *iface, VARIANT_BOOL *p) 523{ 524 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 525 FIXME("(%p)->(%p)\n", This, p); 526 return E_NOTIMPL; 527} 528 529static HRESULT WINAPI HTMLStyleSheet_get_imports(IHTMLStyleSheet *iface, 530 IHTMLStyleSheetsCollection **p) 531{ 532 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 533 FIXME("(%p)->(%p)\n", This, p); 534 return E_NOTIMPL; 535} 536 537static HRESULT WINAPI HTMLStyleSheet_put_href(IHTMLStyleSheet *iface, BSTR v) 538{ 539 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 540 FIXME("(%p)->(%s)\n", This, debugstr_w(v)); 541 return E_NOTIMPL; 542} 543 544static HRESULT WINAPI HTMLStyleSheet_get_href(IHTMLStyleSheet *iface, BSTR *p) 545{ 546 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 547 nsAString href_str; 548 nsresult nsres; 549 550 TRACE("(%p)->(%p)\n", This, p); 551 552 nsAString_Init(&href_str, NULL); 553 nsres = nsIDOMCSSStyleSheet_GetHref(This->nsstylesheet, &href_str); 554 return return_nsstr(nsres, &href_str, p); 555} 556 557static HRESULT WINAPI HTMLStyleSheet_get_type(IHTMLStyleSheet *iface, BSTR *p) 558{ 559 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 560 FIXME("(%p)->(%p)\n", This, p); 561 return E_NOTIMPL; 562} 563 564static HRESULT WINAPI HTMLStyleSheet_get_id(IHTMLStyleSheet *iface, BSTR *p) 565{ 566 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 567 FIXME("(%p)->(%p)\n", This, p); 568 return E_NOTIMPL; 569} 570 571static HRESULT WINAPI HTMLStyleSheet_addImport(IHTMLStyleSheet *iface, BSTR bstrURL, 572 LONG lIndex, LONG *plIndex) 573{ 574 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 575 FIXME("(%p)->(%s %d %p)\n", This, debugstr_w(bstrURL), lIndex, plIndex); 576 return E_NOTIMPL; 577} 578 579static HRESULT WINAPI HTMLStyleSheet_addRule(IHTMLStyleSheet *iface, BSTR bstrSelector, 580 BSTR bstrStyle, LONG lIndex, LONG *plIndex) 581{ 582 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 583 FIXME("(%p)->(%s %s %d %p)\n", This, debugstr_w(bstrSelector), debugstr_w(bstrStyle), 584 lIndex, plIndex); 585 return E_NOTIMPL; 586} 587 588static HRESULT WINAPI HTMLStyleSheet_removeImport(IHTMLStyleSheet *iface, LONG lIndex) 589{ 590 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 591 FIXME("(%p)->(%d)\n", This, lIndex); 592 return E_NOTIMPL; 593} 594 595static HRESULT WINAPI HTMLStyleSheet_removeRule(IHTMLStyleSheet *iface, LONG lIndex) 596{ 597 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 598 FIXME("(%p)->(%d)\n", This, lIndex); 599 return E_NOTIMPL; 600} 601 602static HRESULT WINAPI HTMLStyleSheet_put_media(IHTMLStyleSheet *iface, BSTR v) 603{ 604 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 605 FIXME("(%p)->(%s)\n", This, debugstr_w(v)); 606 return E_NOTIMPL; 607} 608 609static HRESULT WINAPI HTMLStyleSheet_get_media(IHTMLStyleSheet *iface, BSTR *p) 610{ 611 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 612 FIXME("(%p)->(%p)\n", This, p); 613 return E_NOTIMPL; 614} 615 616static HRESULT WINAPI HTMLStyleSheet_put_cssText(IHTMLStyleSheet *iface, BSTR v) 617{ 618 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 619 nsresult nsres; 620 621 TRACE("(%p)->(%s)\n", This, debugstr_w(v)); 622 623 do { 624 nsres = nsIDOMCSSStyleSheet_DeleteRule(This->nsstylesheet, 0); 625 }while(NS_SUCCEEDED(nsres)); 626 627 if(v && *v) { 628 nsAString nsstr; 629 UINT32 idx; 630 631 /* FIXME: This won't work for multiple rules in the string. */ 632 nsAString_InitDepend(&nsstr, v); 633 nsres = nsIDOMCSSStyleSheet_InsertRule(This->nsstylesheet, &nsstr, 0, &idx); 634 nsAString_Finish(&nsstr); 635 if(NS_FAILED(nsres)) { 636 FIXME("InsertRule failed for string %s. Probably multiple rules passed.\n", debugstr_w(v)); 637 return E_FAIL; 638 } 639 } 640 641 return S_OK; 642} 643 644static HRESULT WINAPI HTMLStyleSheet_get_cssText(IHTMLStyleSheet *iface, BSTR *p) 645{ 646 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 647 nsIDOMCSSRuleList *nslist = NULL; 648 nsIDOMCSSRule *nsrule; 649 nsAString nsstr; 650 UINT32 len; 651 nsresult nsres; 652 653 TRACE("(%p)->(%p)\n", This, p); 654 655 nsres = nsIDOMCSSStyleSheet_GetCssRules(This->nsstylesheet, &nslist); 656 if(NS_FAILED(nsres)) { 657 ERR("GetCssRules failed: %08x\n", nsres); 658 return E_FAIL; 659 } 660 661 nsres = nsIDOMCSSRuleList_GetLength(nslist, &len); 662 assert(nsres == NS_OK); 663 664 if(len) { 665 nsres = nsIDOMCSSRuleList_Item(nslist, 0, &nsrule); 666 if(NS_FAILED(nsres)) 667 ERR("Item failed: %08x\n", nsres); 668 } 669 670 nsIDOMCSSRuleList_Release(nslist); 671 if(NS_FAILED(nsres)) 672 return E_FAIL; 673 674 if(!len) { 675 *p = NULL; 676 return S_OK; 677 } 678 679 nsAString_Init(&nsstr, NULL); 680 nsres = nsIDOMCSSRule_GetCssText(nsrule, &nsstr); 681 nsIDOMCSSRule_Release(nsrule); 682 return return_nsstr(nsres, &nsstr, p); 683} 684 685static HRESULT WINAPI HTMLStyleSheet_get_rules(IHTMLStyleSheet *iface, 686 IHTMLStyleSheetRulesCollection **p) 687{ 688 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); 689 nsIDOMCSSRuleList *nslist = NULL; 690 nsresult nsres; 691 692 TRACE("(%p)->(%p)\n", This, p); 693 694 nsres = nsIDOMCSSStyleSheet_GetCssRules(This->nsstylesheet, &nslist); 695 if(NS_FAILED(nsres)) { 696 ERR("GetCssRules failed: %08x\n", nsres); 697 return E_FAIL; 698 } 699 700 *p = HTMLStyleSheetRulesCollection_Create(nslist); 701 return S_OK; 702} 703 704static const IHTMLStyleSheetVtbl HTMLStyleSheetVtbl = { 705 HTMLStyleSheet_QueryInterface, 706 HTMLStyleSheet_AddRef, 707 HTMLStyleSheet_Release, 708 HTMLStyleSheet_GetTypeInfoCount, 709 HTMLStyleSheet_GetTypeInfo, 710 HTMLStyleSheet_GetIDsOfNames, 711 HTMLStyleSheet_Invoke, 712 HTMLStyleSheet_put_title, 713 HTMLStyleSheet_get_title, 714 HTMLStyleSheet_get_parentStyleSheet, 715 HTMLStyleSheet_get_owningElement, 716 HTMLStyleSheet_put_disabled, 717 HTMLStyleSheet_get_disabled, 718 HTMLStyleSheet_get_readOnly, 719 HTMLStyleSheet_get_imports, 720 HTMLStyleSheet_put_href, 721 HTMLStyleSheet_get_href, 722 HTMLStyleSheet_get_type, 723 HTMLStyleSheet_get_id, 724 HTMLStyleSheet_addImport, 725 HTMLStyleSheet_addRule, 726 HTMLStyleSheet_removeImport, 727 HTMLStyleSheet_removeRule, 728 HTMLStyleSheet_put_media, 729 HTMLStyleSheet_get_media, 730 HTMLStyleSheet_put_cssText, 731 HTMLStyleSheet_get_cssText, 732 HTMLStyleSheet_get_rules 733}; 734 735static const tid_t HTMLStyleSheet_iface_tids[] = { 736 IHTMLStyleSheet_tid, 737 0 738}; 739static dispex_static_data_t HTMLStyleSheet_dispex = { 740 NULL, 741 DispHTMLStyleSheet_tid, 742 NULL, 743 HTMLStyleSheet_iface_tids 744}; 745 746IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet *nsstylesheet) 747{ 748 HTMLStyleSheet *ret = heap_alloc(sizeof(HTMLStyleSheet)); 749 nsresult nsres; 750 751 ret->IHTMLStyleSheet_iface.lpVtbl = &HTMLStyleSheetVtbl; 752 ret->ref = 1; 753 ret->nsstylesheet = NULL; 754 755 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLStyleSheet_iface, &HTMLStyleSheet_dispex); 756 757 if(nsstylesheet) { 758 nsres = nsIDOMStyleSheet_QueryInterface(nsstylesheet, &IID_nsIDOMCSSStyleSheet, 759 (void**)&ret->nsstylesheet); 760 if(NS_FAILED(nsres)) 761 ERR("Could not get nsICSSStyleSheet interface: %08x\n", nsres); 762 } 763 764 return &ret->IHTMLStyleSheet_iface; 765}