htmlinput.c 63.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * Copyright 2006 Jacek Caban for CodeWeavers
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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 <stdarg.h>
20
#include <assert.h>
21
#include <limits.h>
22 23 24 25 26 27 28 29 30 31 32

#define COBJMACROS

#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"

#include "wine/debug.h"

#include "mshtml_private.h"
33
#include "htmlevent.h"
34 35 36

WINE_DEFAULT_DEBUG_CHANNEL(mshtml);

37
struct HTMLInputElement {
38 39
    HTMLElement element;

40
    IHTMLInputElement IHTMLInputElement_iface;
41
    IHTMLInputTextElement IHTMLInputTextElement_iface;
42
    IHTMLInputTextElement2 IHTMLInputTextElement2_iface;
43 44

    nsIDOMHTMLInputElement *nsinput;
45
};
46

47 48
static const WCHAR forW[] = {'f','o','r',0};

49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
static HRESULT return_nsform(HTMLElement *elem, nsIDOMHTMLFormElement *nsform, IHTMLFormElement **p)
{
    nsIDOMNode *form_node;
    HTMLDOMNode *node;
    nsresult nsres;
    HRESULT hres;

    if(!nsform) {
        *p = NULL;
        return S_OK;
    }

    nsres = nsIDOMHTMLFormElement_QueryInterface(nsform, &IID_nsIDOMNode, (void**)&form_node);
    nsIDOMHTMLFormElement_Release(nsform);
    assert(nsres == NS_OK);

    hres = get_node(elem->node.doc, form_node, TRUE, &node);
    nsIDOMNode_Release(form_node);
    if (FAILED(hres))
        return hres;

    hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
    node_release(node);
    return hres;
}

75 76 77 78
static inline HTMLInputElement *impl_from_IHTMLInputElement(IHTMLInputElement *iface)
{
    return CONTAINING_RECORD(iface, HTMLInputElement, IHTMLInputElement_iface);
}
79 80 81 82 83

static inline HTMLInputElement *impl_from_IHTMLInputTextElement(IHTMLInputTextElement *iface)
{
    return CONTAINING_RECORD(iface, HTMLInputElement, IHTMLInputTextElement_iface);
}
84 85 86 87

static HRESULT WINAPI HTMLInputElement_QueryInterface(IHTMLInputElement *iface,
                                                         REFIID riid, void **ppv)
{
88
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
89

90
    return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
91 92 93 94
}

static ULONG WINAPI HTMLInputElement_AddRef(IHTMLInputElement *iface)
{
95
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
96

97
    return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
98 99 100 101
}

static ULONG WINAPI HTMLInputElement_Release(IHTMLInputElement *iface)
{
102
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
103

104
    return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
105 106 107 108
}

static HRESULT WINAPI HTMLInputElement_GetTypeInfoCount(IHTMLInputElement *iface, UINT *pctinfo)
{
109
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
110

111
    return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
112 113 114 115 116
}

static HRESULT WINAPI HTMLInputElement_GetTypeInfo(IHTMLInputElement *iface, UINT iTInfo,
                                              LCID lcid, ITypeInfo **ppTInfo)
{
117
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
118

119
    return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
120
            ppTInfo);
121 122 123 124 125 126
}

static HRESULT WINAPI HTMLInputElement_GetIDsOfNames(IHTMLInputElement *iface, REFIID riid,
                                                LPOLESTR *rgszNames, UINT cNames,
                                                LCID lcid, DISPID *rgDispId)
{
127
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
128

129
    return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
130
            cNames, lcid, rgDispId);
131 132 133 134 135 136
}

static HRESULT WINAPI HTMLInputElement_Invoke(IHTMLInputElement *iface, DISPID dispIdMember,
                            REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
                            VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
137
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
138

139
    return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
140
            lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
141 142 143 144
}

static HRESULT WINAPI HTMLInputElement_put_type(IHTMLInputElement *iface, BSTR v)
{
145
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
    nsAString type_str;
    nsresult nsres;

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    /*
     * FIXME:
     * On IE setting type works only on dynamically created elements before adding them to DOM tree.
     */
    nsAString_InitDepend(&type_str, v);
    nsres = nsIDOMHTMLInputElement_SetType(This->nsinput, &type_str);
    nsAString_Finish(&type_str);
    if(NS_FAILED(nsres)) {
        ERR("SetType failed: %08x\n", nsres);
        return E_FAIL;
    }

    return S_OK;
164 165 166 167
}

static HRESULT WINAPI HTMLInputElement_get_type(IHTMLInputElement *iface, BSTR *p)
{
168
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
169 170 171 172 173 174 175
    nsAString type_str;
    nsresult nsres;

    TRACE("(%p)->(%p)\n", This, p);

    nsAString_Init(&type_str, NULL);
    nsres = nsIDOMHTMLInputElement_GetType(This->nsinput, &type_str);
176
    return return_nsstr(nsres, &type_str, p);
177 178 179 180
}

static HRESULT WINAPI HTMLInputElement_put_value(IHTMLInputElement *iface, BSTR v)
{
181
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
182 183 184 185 186
    nsAString val_str;
    nsresult nsres;

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

187
    nsAString_InitDepend(&val_str, v);
188 189 190 191 192 193
    nsres = nsIDOMHTMLInputElement_SetValue(This->nsinput, &val_str);
    nsAString_Finish(&val_str);
    if(NS_FAILED(nsres))
        ERR("SetValue failed: %08x\n", nsres);

    return S_OK;
194 195 196 197
}

static HRESULT WINAPI HTMLInputElement_get_value(IHTMLInputElement *iface, BSTR *p)
{
198
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
199 200 201 202 203 204 205
    nsAString value_str;
    nsresult nsres;

    TRACE("(%p)->(%p)\n", This, p);

    nsAString_Init(&value_str, NULL);
    nsres = nsIDOMHTMLInputElement_GetValue(This->nsinput, &value_str);
206
    return return_nsstr(nsres, &value_str, p);
207 208 209 210
}

static HRESULT WINAPI HTMLInputElement_put_name(IHTMLInputElement *iface, BSTR v)
{
211
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
212 213 214 215 216 217 218 219 220 221 222 223 224 225
    nsAString name_str;
    nsresult nsres;

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    nsAString_InitDepend(&name_str, v);
    nsres = nsIDOMHTMLInputElement_SetName(This->nsinput, &name_str);
    nsAString_Finish(&name_str);
    if(NS_FAILED(nsres)) {
        ERR("SetName failed: %08x\n", nsres);
        return E_FAIL;
    }

    return S_OK;
226 227 228 229
}

static HRESULT WINAPI HTMLInputElement_get_name(IHTMLInputElement *iface, BSTR *p)
{
230
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
231 232 233 234 235 236 237
    nsAString name_str;
    nsresult nsres;

    TRACE("(%p)->(%p)\n", This, p);

    nsAString_Init(&name_str, NULL);
    nsres = nsIDOMHTMLInputElement_GetName(This->nsinput, &name_str);
238
    return return_nsstr(nsres, &name_str, p);
239 240 241 242
}

static HRESULT WINAPI HTMLInputElement_put_status(IHTMLInputElement *iface, VARIANT_BOOL v)
{
243
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
244 245 246 247 248 249
    FIXME("(%p)->(%x)\n", This, v);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_status(IHTMLInputElement *iface, VARIANT_BOOL *p)
{
250
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
251 252 253 254 255 256
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_disabled(IHTMLInputElement *iface, VARIANT_BOOL v)
{
257
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
258 259 260 261 262 263 264 265 266
    nsresult nsres;

    TRACE("(%p)->(%x)\n", This, v);

    nsres = nsIDOMHTMLInputElement_SetDisabled(This->nsinput, v != VARIANT_FALSE);
    if(NS_FAILED(nsres))
        ERR("SetDisabled failed: %08x\n", nsres);

    return S_OK;
267 268 269 270
}

static HRESULT WINAPI HTMLInputElement_get_disabled(IHTMLInputElement *iface, VARIANT_BOOL *p)
{
271
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
272
    cpp_bool disabled = FALSE;
273 274 275 276 277

    TRACE("(%p)->(%p)\n", This, p);

    nsIDOMHTMLInputElement_GetDisabled(This->nsinput, &disabled);

278
    *p = variant_bool(disabled);
279
    return S_OK;
280 281 282 283
}

static HRESULT WINAPI HTMLInputElement_get_form(IHTMLInputElement *iface, IHTMLFormElement **p)
{
284
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
285 286 287 288 289 290
    nsIDOMHTMLFormElement *nsform;
    nsresult nsres;

    TRACE("(%p)->(%p)\n", This, p);

    nsres = nsIDOMHTMLInputElement_GetForm(This->nsinput, &nsform);
291
    if (NS_FAILED(nsres)) {
292 293 294 295
        ERR("GetForm failed: %08x, nsform: %p\n", nsres, nsform);
        return E_FAIL;
    }

296
    return return_nsform(&This->element, nsform, p);
297 298
}

299
static HRESULT WINAPI HTMLInputElement_put_size(IHTMLInputElement *iface, LONG v)
300
{
301
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
302 303 304 305 306 307 308 309 310 311 312 313 314
    UINT32 val = v;
    nsresult nsres;

    TRACE("(%p)->(%d)\n", This, v);
    if (v <= 0)
        return CTL_E_INVALIDPROPERTYVALUE;

    nsres = nsIDOMHTMLInputElement_SetSize(This->nsinput, val);
    if (NS_FAILED(nsres)) {
        ERR("Set Size(%u) failed: %08x\n", val, nsres);
        return E_FAIL;
    }
    return S_OK;
315 316
}

317
static HRESULT WINAPI HTMLInputElement_get_size(IHTMLInputElement *iface, LONG *p)
318
{
319
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
320 321 322 323 324 325 326 327 328 329 330 331 332 333
    UINT32 val;
    nsresult nsres;

    TRACE("(%p)->(%p)\n", This, p);
    if (p == NULL)
        return E_INVALIDARG;

    nsres = nsIDOMHTMLInputElement_GetSize(This->nsinput, &val);
    if (NS_FAILED(nsres)) {
        ERR("Get Size failed: %08x\n", nsres);
        return E_FAIL;
    }
    *p = val;
    return S_OK;
334 335
}

336
static HRESULT WINAPI HTMLInputElement_put_maxLength(IHTMLInputElement *iface, LONG v)
337
{
338
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
339 340 341 342 343 344 345 346 347 348 349 350
    nsresult nsres;

    TRACE("(%p)->(%d)\n", This, v);

    nsres = nsIDOMHTMLInputElement_SetMaxLength(This->nsinput, v);
    if(NS_FAILED(nsres)) {
        /* FIXME: Gecko throws an error on negative values, while MSHTML should accept them */
        FIXME("SetMaxLength failed\n");
        return E_FAIL;
    }

    return S_OK;
351 352
}

353
static HRESULT WINAPI HTMLInputElement_get_maxLength(IHTMLInputElement *iface, LONG *p)
354
{
355
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
356
    LONG max_length;
357 358 359 360 361 362 363 364 365 366
    nsresult nsres;

    TRACE("(%p)->(%p)\n", This, p);

    nsres = nsIDOMHTMLInputElement_GetMaxLength(This->nsinput, &max_length);
    assert(nsres == NS_OK);

    /* Gecko reports -1 as default value, while MSHTML uses INT_MAX */
    *p = max_length == -1 ? INT_MAX : max_length;
    return S_OK;
367 368 369 370
}

static HRESULT WINAPI HTMLInputElement_select(IHTMLInputElement *iface)
{
371
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
372 373 374 375 376 377 378 379 380 381 382
    nsresult nsres;

    TRACE("(%p)\n", This);

    nsres = nsIDOMHTMLInputElement_Select(This->nsinput);
    if(NS_FAILED(nsres)) {
        ERR("Select failed: %08x\n", nsres);
        return E_FAIL;
    }

    return S_OK;
383 384 385 386
}

static HRESULT WINAPI HTMLInputElement_put_onchange(IHTMLInputElement *iface, VARIANT v)
{
387
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
388 389 390 391

    TRACE("(%p)->()\n", This);

    return set_node_event(&This->element.node, EVENTID_CHANGE, &v);
392 393 394 395
}

static HRESULT WINAPI HTMLInputElement_get_onchange(IHTMLInputElement *iface, VARIANT *p)
{
396
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
397 398 399 400

    TRACE("(%p)->(%p)\n", This, p);

    return get_node_event(&This->element.node, EVENTID_CHANGE, p);
401 402 403 404
}

static HRESULT WINAPI HTMLInputElement_put_onselect(IHTMLInputElement *iface, VARIANT v)
{
405
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
406 407 408 409 410 411
    FIXME("(%p)->()\n", This);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_onselect(IHTMLInputElement *iface, VARIANT *p)
{
412
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
413 414 415 416 417 418
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_defaultValue(IHTMLInputElement *iface, BSTR v)
{
419
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
420 421 422 423 424 425 426 427 428 429 430 431 432 433
    nsAString nsstr;
    nsresult nsres;

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    nsAString_InitDepend(&nsstr, v);
    nsres = nsIDOMHTMLInputElement_SetDefaultValue(This->nsinput, &nsstr);
    nsAString_Finish(&nsstr);
    if(NS_FAILED(nsres)) {
        ERR("SetValue failed: %08x\n", nsres);
        return E_FAIL;
    }

    return S_OK;
434 435 436 437
}

static HRESULT WINAPI HTMLInputElement_get_defaultValue(IHTMLInputElement *iface, BSTR *p)
{
438
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
439 440 441 442 443 444 445 446
    nsAString nsstr;
    nsresult nsres;

    TRACE("(%p)->(%p)\n", This, p);

    nsAString_Init(&nsstr, NULL);
    nsres = nsIDOMHTMLInputElement_GetDefaultValue(This->nsinput, &nsstr);
    return return_nsstr(nsres, &nsstr, p);
447 448 449 450
}

static HRESULT WINAPI HTMLInputElement_put_readOnly(IHTMLInputElement *iface, VARIANT_BOOL v)
{
451
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
452 453 454 455 456 457 458 459 460 461
    nsresult nsres;

    TRACE("(%p)->(%x)\n", This, v);

    nsres = nsIDOMHTMLInputElement_SetReadOnly(This->nsinput, v != VARIANT_FALSE);
    if (NS_FAILED(nsres)) {
        ERR("Set ReadOnly Failed: %08x\n", nsres);
        return E_FAIL;
    }
    return S_OK;
462 463 464 465
}

static HRESULT WINAPI HTMLInputElement_get_readOnly(IHTMLInputElement *iface, VARIANT_BOOL *p)
{
466
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
467 468 469 470 471 472 473 474 475 476
    nsresult nsres;
    cpp_bool b;

    TRACE("(%p)->(%p)\n", This, p);

    nsres = nsIDOMHTMLInputElement_GetReadOnly(This->nsinput, &b);
    if (NS_FAILED(nsres)) {
        ERR("Get ReadOnly Failed: %08x\n", nsres);
        return E_FAIL;
    }
477 478

    *p = variant_bool(b);
479
    return S_OK;
480 481 482 483
}

static HRESULT WINAPI HTMLInputElement_createTextRange(IHTMLInputElement *iface, IHTMLTxtRange **range)
{
484
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
485 486 487 488 489 490
    FIXME("(%p)->(%p)\n", This, range);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_indeterminate(IHTMLInputElement *iface, VARIANT_BOOL v)
{
491
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
492 493 494 495 496 497
    FIXME("(%p)->(%x)\n", This, v);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_indeterminate(IHTMLInputElement *iface, VARIANT_BOOL *p)
{
498
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
499 500 501 502 503 504
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_defaultChecked(IHTMLInputElement *iface, VARIANT_BOOL v)
{
505
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
506 507 508 509 510 511 512 513 514 515 516
    nsresult nsres;

    TRACE("(%p)->(%x)\n", This, v);

    nsres = nsIDOMHTMLInputElement_SetDefaultChecked(This->nsinput, v != VARIANT_FALSE);
    if(NS_FAILED(nsres)) {
        ERR("SetDefaultChecked failed: %08x\n", nsres);
        return E_FAIL;
    }

    return S_OK;
517 518 519 520
}

static HRESULT WINAPI HTMLInputElement_get_defaultChecked(IHTMLInputElement *iface, VARIANT_BOOL *p)
{
521
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
522
    cpp_bool default_checked = FALSE;
523 524 525 526 527 528 529 530 531 532
    nsresult nsres;

    TRACE("(%p)->(%p)\n", This, p);

    nsres = nsIDOMHTMLInputElement_GetDefaultChecked(This->nsinput, &default_checked);
    if(NS_FAILED(nsres)) {
        ERR("GetDefaultChecked failed: %08x\n", nsres);
        return E_FAIL;
    }

533
    *p = variant_bool(default_checked);
534
    return S_OK;
535 536 537 538
}

static HRESULT WINAPI HTMLInputElement_put_checked(IHTMLInputElement *iface, VARIANT_BOOL v)
{
539
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
540 541 542 543 544 545 546 547 548 549 550
    nsresult nsres;

    TRACE("(%p)->(%x)\n", This, v);

    nsres = nsIDOMHTMLInputElement_SetChecked(This->nsinput, v != VARIANT_FALSE);
    if(NS_FAILED(nsres)) {
        ERR("SetChecked failed: %08x\n", nsres);
        return E_FAIL;
    }

    return S_OK;
551 552 553 554
}

static HRESULT WINAPI HTMLInputElement_get_checked(IHTMLInputElement *iface, VARIANT_BOOL *p)
{
555
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
556
    cpp_bool checked;
557 558 559 560 561 562
    nsresult nsres;

    TRACE("(%p)->(%p)\n", This, p);

    nsres = nsIDOMHTMLInputElement_GetChecked(This->nsinput, &checked);
    if(NS_FAILED(nsres)) {
563
        ERR("GetChecked failed: %08x\n", nsres);
564 565 566
        return E_FAIL;
    }

567
    *p = variant_bool(checked);
568 569
    TRACE("checked=%x\n", *p);
    return S_OK;
570 571 572 573
}

static HRESULT WINAPI HTMLInputElement_put_border(IHTMLInputElement *iface, VARIANT v)
{
574
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
575 576 577 578 579 580
    FIXME("(%p)->()\n", This);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_border(IHTMLInputElement *iface, VARIANT *p)
{
581
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
582 583 584 585
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

586
static HRESULT WINAPI HTMLInputElement_put_vspace(IHTMLInputElement *iface, LONG v)
587
{
588
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
589
    FIXME("(%p)->(%d)\n", This, v);
590 591 592
    return E_NOTIMPL;
}

593
static HRESULT WINAPI HTMLInputElement_get_vspace(IHTMLInputElement *iface, LONG *p)
594
{
595
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
596 597 598 599
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

600
static HRESULT WINAPI HTMLInputElement_put_hspace(IHTMLInputElement *iface, LONG v)
601
{
602
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
603
    FIXME("(%p)->(%d)\n", This, v);
604 605 606
    return E_NOTIMPL;
}

607
static HRESULT WINAPI HTMLInputElement_get_hspace(IHTMLInputElement *iface, LONG *p)
608
{
609
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
610 611 612 613 614 615
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_alt(IHTMLInputElement *iface, BSTR v)
{
616
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
617 618 619 620 621 622
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_alt(IHTMLInputElement *iface, BSTR *p)
{
623
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
624 625 626 627 628 629
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_src(IHTMLInputElement *iface, BSTR v)
{
630
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
631 632 633 634 635
    nsAString nsstr;
    nsresult nsres;

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

636
    nsAString_InitDepend(&nsstr, v);
637 638 639 640 641 642
    nsres = nsIDOMHTMLInputElement_SetSrc(This->nsinput, &nsstr);
    nsAString_Finish(&nsstr);
    if(NS_FAILED(nsres))
        ERR("SetSrc failed: %08x\n", nsres);

    return S_OK;
643 644 645 646
}

static HRESULT WINAPI HTMLInputElement_get_src(IHTMLInputElement *iface, BSTR *p)
{
647
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666
    const PRUnichar *src;
    nsAString src_str;
    nsresult nsres;
    HRESULT hres;

    TRACE("(%p)->(%p)\n", This, p);

    nsAString_Init(&src_str, NULL);
    nsres = nsIDOMHTMLInputElement_GetSrc(This->nsinput, &src_str);
    if(NS_FAILED(nsres)) {
        ERR("GetSrc failed: %08x\n", nsres);
        return E_FAIL;
    }

    nsAString_GetData(&src_str, &src);
    hres = nsuri_to_url(src, FALSE, p);
    nsAString_Finish(&src_str);

    return hres;
667 668 669 670
}

static HRESULT WINAPI HTMLInputElement_put_lowsrc(IHTMLInputElement *iface, BSTR v)
{
671
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
672 673 674 675 676 677
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_lowsrc(IHTMLInputElement *iface, BSTR *p)
{
678
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
679 680 681 682 683 684
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_vrml(IHTMLInputElement *iface, BSTR v)
{
685
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
686 687 688 689 690 691
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_vrml(IHTMLInputElement *iface, BSTR *p)
{
692
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
693 694 695 696 697 698
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_dynsrc(IHTMLInputElement *iface, BSTR v)
{
699
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
700 701 702 703 704 705
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_dynsrc(IHTMLInputElement *iface, BSTR *p)
{
706
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
707 708 709 710 711 712
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_readyState(IHTMLInputElement *iface, BSTR *p)
{
713
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
714 715 716 717 718 719
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_complete(IHTMLInputElement *iface, VARIANT_BOOL *p)
{
720
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
721 722 723 724 725 726
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_loop(IHTMLInputElement *iface, VARIANT v)
{
727
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
728 729 730 731 732 733
    FIXME("(%p)->()\n", This);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_loop(IHTMLInputElement *iface, VARIANT *p)
{
734
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
735 736 737 738 739 740
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_align(IHTMLInputElement *iface, BSTR v)
{
741
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
742 743 744 745 746 747
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_align(IHTMLInputElement *iface, BSTR *p)
{
748
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
749 750 751 752 753 754
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_onload(IHTMLInputElement *iface, VARIANT v)
{
755
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
756 757 758 759 760 761
    FIXME("(%p)->()\n", This);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_onload(IHTMLInputElement *iface, VARIANT *p)
{
762
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
763 764 765 766 767 768
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_onerror(IHTMLInputElement *iface, VARIANT v)
{
769
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
770 771 772 773 774 775
    FIXME("(%p)->()\n", This);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_onerror(IHTMLInputElement *iface, VARIANT *p)
{
776
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
777 778 779 780 781 782
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_onabort(IHTMLInputElement *iface, VARIANT v)
{
783
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
784 785 786 787 788 789
    FIXME("(%p)->()\n", This);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_onabort(IHTMLInputElement *iface, VARIANT *p)
{
790
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
791 792 793 794
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

795
static HRESULT WINAPI HTMLInputElement_put_width(IHTMLInputElement *iface, LONG v)
796
{
797
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
798
    FIXME("(%p)->(%d)\n", This, v);
799 800 801
    return E_NOTIMPL;
}

802
static HRESULT WINAPI HTMLInputElement_get_width(IHTMLInputElement *iface, LONG *p)
803
{
804
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
805 806 807 808
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

809
static HRESULT WINAPI HTMLInputElement_put_height(IHTMLInputElement *iface, LONG v)
810
{
811
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
812
    FIXME("(%p)->(%d)\n", This, v);
813 814 815
    return E_NOTIMPL;
}

816
static HRESULT WINAPI HTMLInputElement_get_height(IHTMLInputElement *iface, LONG *p)
817
{
818
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
819 820 821 822 823 824
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_start(IHTMLInputElement *iface, BSTR v)
{
825
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
826 827 828 829 830 831
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_start(IHTMLInputElement *iface, BSTR *p)
{
832
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static const IHTMLInputElementVtbl HTMLInputElementVtbl = {
    HTMLInputElement_QueryInterface,
    HTMLInputElement_AddRef,
    HTMLInputElement_Release,
    HTMLInputElement_GetTypeInfoCount,
    HTMLInputElement_GetTypeInfo,
    HTMLInputElement_GetIDsOfNames,
    HTMLInputElement_Invoke,
    HTMLInputElement_put_type,
    HTMLInputElement_get_type,
    HTMLInputElement_put_value,
    HTMLInputElement_get_value,
    HTMLInputElement_put_name,
    HTMLInputElement_get_name,
    HTMLInputElement_put_status,
    HTMLInputElement_get_status,
    HTMLInputElement_put_disabled,
    HTMLInputElement_get_disabled,
    HTMLInputElement_get_form,
    HTMLInputElement_put_size,
    HTMLInputElement_get_size,
    HTMLInputElement_put_maxLength,
    HTMLInputElement_get_maxLength,
    HTMLInputElement_select,
    HTMLInputElement_put_onchange,
    HTMLInputElement_get_onchange,
    HTMLInputElement_put_onselect,
    HTMLInputElement_get_onselect,
    HTMLInputElement_put_defaultValue,
    HTMLInputElement_get_defaultValue,
    HTMLInputElement_put_readOnly,
    HTMLInputElement_get_readOnly,
    HTMLInputElement_createTextRange,
    HTMLInputElement_put_indeterminate,
    HTMLInputElement_get_indeterminate,
    HTMLInputElement_put_defaultChecked,
    HTMLInputElement_get_defaultChecked,
    HTMLInputElement_put_checked,
    HTMLInputElement_get_checked,
    HTMLInputElement_put_border,
    HTMLInputElement_get_border,
    HTMLInputElement_put_vspace,
    HTMLInputElement_get_vspace,
    HTMLInputElement_put_hspace,
    HTMLInputElement_get_hspace,
    HTMLInputElement_put_alt,
    HTMLInputElement_get_alt,
    HTMLInputElement_put_src,
    HTMLInputElement_get_src,
    HTMLInputElement_put_lowsrc,
    HTMLInputElement_get_lowsrc,
    HTMLInputElement_put_vrml,
    HTMLInputElement_get_vrml,
    HTMLInputElement_put_dynsrc,
    HTMLInputElement_get_dynsrc,
    HTMLInputElement_get_readyState,
    HTMLInputElement_get_complete,
    HTMLInputElement_put_loop,
    HTMLInputElement_get_loop,
    HTMLInputElement_put_align,
    HTMLInputElement_get_align,
    HTMLInputElement_put_onload,
    HTMLInputElement_get_onload,
    HTMLInputElement_put_onerror,
    HTMLInputElement_get_onerror,
    HTMLInputElement_put_onabort,
    HTMLInputElement_get_onabort,
    HTMLInputElement_put_width,
    HTMLInputElement_get_width,
    HTMLInputElement_put_height,
    HTMLInputElement_get_height,
    HTMLInputElement_put_start,
    HTMLInputElement_get_start
};

912 913 914
static HRESULT WINAPI HTMLInputTextElement_QueryInterface(IHTMLInputTextElement *iface,
        REFIID riid, void **ppv)
{
915
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
916

917
    return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
918 919 920 921
}

static ULONG WINAPI HTMLInputTextElement_AddRef(IHTMLInputTextElement *iface)
{
922
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
923

924
    return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
925 926 927 928
}

static ULONG WINAPI HTMLInputTextElement_Release(IHTMLInputTextElement *iface)
{
929
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
930

931
    return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
932 933 934 935
}

static HRESULT WINAPI HTMLInputTextElement_GetTypeInfoCount(IHTMLInputTextElement *iface, UINT *pctinfo)
{
936
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
937
    return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
938 939 940 941 942
}

static HRESULT WINAPI HTMLInputTextElement_GetTypeInfo(IHTMLInputTextElement *iface, UINT iTInfo,
        LCID lcid, ITypeInfo **ppTInfo)
{
943
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
944
    return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
945
            ppTInfo);
946 947 948 949 950
}

static HRESULT WINAPI HTMLInputTextElement_GetIDsOfNames(IHTMLInputTextElement *iface, REFIID riid,
        LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
{
951
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
952
    return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
953
            cNames, lcid, rgDispId);
954 955 956 957 958 959
}

static HRESULT WINAPI HTMLInputTextElement_Invoke(IHTMLInputTextElement *iface, DISPID dispIdMember,
                            REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
                            VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
960
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
961
    return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
962
            lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
963 964 965 966
}

static HRESULT WINAPI HTMLInputTextElement_get_type(IHTMLInputTextElement *iface, BSTR *p)
{
967
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
968 969 970

    TRACE("(%p)->(%p)\n", This, p);

971
    return IHTMLInputElement_get_type(&This->IHTMLInputElement_iface, p);
972 973 974 975
}

static HRESULT WINAPI HTMLInputTextElement_put_value(IHTMLInputTextElement *iface, BSTR v)
{
976
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
977 978 979

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

980
    return IHTMLInputElement_put_value(&This->IHTMLInputElement_iface, v);
981 982 983 984
}

static HRESULT WINAPI HTMLInputTextElement_get_value(IHTMLInputTextElement *iface, BSTR *p)
{
985
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
986 987 988

    TRACE("(%p)->(%p)\n", This, p);

989
    return IHTMLInputElement_get_value(&This->IHTMLInputElement_iface, p);
990 991 992 993
}

static HRESULT WINAPI HTMLInputTextElement_put_name(IHTMLInputTextElement *iface, BSTR v)
{
994
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
995 996 997

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

998
    return IHTMLInputElement_put_name(&This->IHTMLInputElement_iface, v);
999 1000 1001 1002
}

static HRESULT WINAPI HTMLInputTextElement_get_name(IHTMLInputTextElement *iface, BSTR *p)
{
1003
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1004 1005 1006

    TRACE("(%p)->(%p)\n", This, p);

1007
    return IHTMLInputElement_get_name(&This->IHTMLInputElement_iface, p);
1008 1009 1010 1011
}

static HRESULT WINAPI HTMLInputTextElement_put_status(IHTMLInputTextElement *iface, VARIANT v)
{
1012
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1013
    FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1014 1015 1016 1017 1018
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputTextElement_get_status(IHTMLInputTextElement *iface, VARIANT *p)
{
1019
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1020
    TRACE("(%p)->(%p)\n", This, p);
1021 1022 1023 1024 1025
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputTextElement_put_disabled(IHTMLInputTextElement *iface, VARIANT_BOOL v)
{
1026
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1027 1028 1029

    TRACE("(%p)->(%x)\n", This, v);

1030
    return IHTMLInputElement_put_disabled(&This->IHTMLInputElement_iface, v);
1031 1032 1033 1034
}

static HRESULT WINAPI HTMLInputTextElement_get_disabled(IHTMLInputTextElement *iface, VARIANT_BOOL *p)
{
1035
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1036 1037 1038

    TRACE("(%p)->(%p)\n", This, p);

1039
    return IHTMLInputElement_get_disabled(&This->IHTMLInputElement_iface, p);
1040 1041 1042 1043
}

static HRESULT WINAPI HTMLInputTextElement_get_form(IHTMLInputTextElement *iface, IHTMLFormElement **p)
{
1044
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1045 1046 1047

    TRACE("(%p)->(%p)\n", This, p);

1048
    return IHTMLInputElement_get_form(&This->IHTMLInputElement_iface, p);
1049 1050 1051 1052
}

static HRESULT WINAPI HTMLInputTextElement_put_defaultValue(IHTMLInputTextElement *iface, BSTR v)
{
1053
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1054 1055 1056

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

1057
    return IHTMLInputElement_put_defaultValue(&This->IHTMLInputElement_iface, v);
1058 1059 1060 1061
}

static HRESULT WINAPI HTMLInputTextElement_get_defaultValue(IHTMLInputTextElement *iface, BSTR *p)
{
1062
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1063 1064 1065

    TRACE("(%p)->(%p)\n", This, p);

1066
    return IHTMLInputElement_get_defaultValue(&This->IHTMLInputElement_iface, p);
1067 1068
}

1069
static HRESULT WINAPI HTMLInputTextElement_put_size(IHTMLInputTextElement *iface, LONG v)
1070
{
1071
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1072

1073
    TRACE("(%p)->(%d)\n", This, v);
1074

1075
    return IHTMLInputElement_put_size(&This->IHTMLInputElement_iface, v);
1076 1077
}

1078
static HRESULT WINAPI HTMLInputTextElement_get_size(IHTMLInputTextElement *iface, LONG *p)
1079
{
1080
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1081 1082 1083

    TRACE("(%p)->(%p)\n", This, p);

1084
    return IHTMLInputElement_get_size(&This->IHTMLInputElement_iface, p);
1085 1086
}

1087
static HRESULT WINAPI HTMLInputTextElement_put_maxLength(IHTMLInputTextElement *iface, LONG v)
1088
{
1089
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1090

1091
    TRACE("(%p)->(%d)\n", This, v);
1092

1093
    return IHTMLInputElement_put_maxLength(&This->IHTMLInputElement_iface, v);
1094 1095
}

1096
static HRESULT WINAPI HTMLInputTextElement_get_maxLength(IHTMLInputTextElement *iface, LONG *p)
1097
{
1098
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1099 1100 1101

    TRACE("(%p)->(%p)\n", This, p);

1102
    return IHTMLInputElement_get_maxLength(&This->IHTMLInputElement_iface, p);
1103 1104 1105 1106
}

static HRESULT WINAPI HTMLInputTextElement_select(IHTMLInputTextElement *iface)
{
1107
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1108 1109 1110

    TRACE("(%p)\n", This);

1111
    return IHTMLInputElement_select(&This->IHTMLInputElement_iface);
1112 1113 1114 1115
}

static HRESULT WINAPI HTMLInputTextElement_put_onchange(IHTMLInputTextElement *iface, VARIANT v)
{
1116
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1117 1118 1119

    TRACE("(%p)->()\n", This);

1120
    return IHTMLInputElement_put_onchange(&This->IHTMLInputElement_iface, v);
1121 1122 1123 1124
}

static HRESULT WINAPI HTMLInputTextElement_get_onchange(IHTMLInputTextElement *iface, VARIANT *p)
{
1125
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1126 1127 1128

    TRACE("(%p)->(%p)\n", This, p);

1129
    return IHTMLInputElement_get_onchange(&This->IHTMLInputElement_iface, p);
1130 1131 1132 1133
}

static HRESULT WINAPI HTMLInputTextElement_put_onselect(IHTMLInputTextElement *iface, VARIANT v)
{
1134
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1135 1136 1137

    TRACE("(%p)->()\n", This);

1138
    return IHTMLInputElement_put_onselect(&This->IHTMLInputElement_iface, v);
1139 1140 1141 1142
}

static HRESULT WINAPI HTMLInputTextElement_get_onselect(IHTMLInputTextElement *iface, VARIANT *p)
{
1143
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1144 1145 1146

    TRACE("(%p)->(%p)\n", This, p);

1147
    return IHTMLInputElement_get_onselect(&This->IHTMLInputElement_iface, p);
1148 1149 1150 1151
}

static HRESULT WINAPI HTMLInputTextElement_put_readOnly(IHTMLInputTextElement *iface, VARIANT_BOOL v)
{
1152
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1153 1154 1155

    TRACE("(%p)->(%x)\n", This, v);

1156
    return IHTMLInputElement_put_readOnly(&This->IHTMLInputElement_iface, v);
1157 1158 1159 1160
}

static HRESULT WINAPI HTMLInputTextElement_get_readOnly(IHTMLInputTextElement *iface, VARIANT_BOOL *p)
{
1161
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1162 1163 1164

    TRACE("(%p)->(%p)\n", This, p);

1165
    return IHTMLInputElement_get_readOnly(&This->IHTMLInputElement_iface, p);
1166 1167 1168 1169
}

static HRESULT WINAPI HTMLInputTextElement_createTextRange(IHTMLInputTextElement *iface, IHTMLTxtRange **range)
{
1170
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1171 1172 1173

    TRACE("(%p)->(%p)\n", This, range);

1174
    return IHTMLInputElement_createTextRange(&This->IHTMLInputElement_iface, range);
1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210
}

static const IHTMLInputTextElementVtbl HTMLInputTextElementVtbl = {
    HTMLInputTextElement_QueryInterface,
    HTMLInputTextElement_AddRef,
    HTMLInputTextElement_Release,
    HTMLInputTextElement_GetTypeInfoCount,
    HTMLInputTextElement_GetTypeInfo,
    HTMLInputTextElement_GetIDsOfNames,
    HTMLInputTextElement_Invoke,
    HTMLInputTextElement_get_type,
    HTMLInputTextElement_put_value,
    HTMLInputTextElement_get_value,
    HTMLInputTextElement_put_name,
    HTMLInputTextElement_get_name,
    HTMLInputTextElement_put_status,
    HTMLInputTextElement_get_status,
    HTMLInputTextElement_put_disabled,
    HTMLInputTextElement_get_disabled,
    HTMLInputTextElement_get_form,
    HTMLInputTextElement_put_defaultValue,
    HTMLInputTextElement_get_defaultValue,
    HTMLInputTextElement_put_size,
    HTMLInputTextElement_get_size,
    HTMLInputTextElement_put_maxLength,
    HTMLInputTextElement_get_maxLength,
    HTMLInputTextElement_select,
    HTMLInputTextElement_put_onchange,
    HTMLInputTextElement_get_onchange,
    HTMLInputTextElement_put_onselect,
    HTMLInputTextElement_get_onselect,
    HTMLInputTextElement_put_readOnly,
    HTMLInputTextElement_get_readOnly,
    HTMLInputTextElement_createTextRange
};

1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266
static inline HTMLInputElement *impl_from_IHTMLInputTextElement2(IHTMLInputTextElement2 *iface)
{
    return CONTAINING_RECORD(iface, HTMLInputElement, IHTMLInputTextElement2_iface);
}

static HRESULT WINAPI HTMLInputTextElement2_QueryInterface(IHTMLInputTextElement2 *iface, REFIID riid, void **ppv)
{
    HTMLInputElement *This = impl_from_IHTMLInputTextElement2(iface);
    return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
}

static ULONG WINAPI HTMLInputTextElement2_AddRef(IHTMLInputTextElement2 *iface)
{
    HTMLInputElement *This = impl_from_IHTMLInputTextElement2(iface);
    return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
}

static ULONG WINAPI HTMLInputTextElement2_Release(IHTMLInputTextElement2 *iface)
{
    HTMLInputElement *This = impl_from_IHTMLInputTextElement2(iface);
    return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
}

static HRESULT WINAPI HTMLInputTextElement2_GetTypeInfoCount(IHTMLInputTextElement2 *iface, UINT *pctinfo)
{
    HTMLInputElement *This = impl_from_IHTMLInputTextElement2(iface);
    return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
}

static HRESULT WINAPI HTMLInputTextElement2_GetTypeInfo(IHTMLInputTextElement2 *iface, UINT iTInfo,
        LCID lcid, ITypeInfo **ppTInfo)
{
    HTMLInputElement *This = impl_from_IHTMLInputTextElement2(iface);
    return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
}

static HRESULT WINAPI HTMLInputTextElement2_GetIDsOfNames(IHTMLInputTextElement2 *iface, REFIID riid,
        LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
{
    HTMLInputElement *This = impl_from_IHTMLInputTextElement2(iface);
    return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
            cNames, lcid, rgDispId);
}

static HRESULT WINAPI HTMLInputTextElement2_Invoke(IHTMLInputTextElement2 *iface, DISPID dispIdMember,
                            REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
                            VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
    HTMLInputElement *This = impl_from_IHTMLInputTextElement2(iface);
    return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
            lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
}

static HRESULT WINAPI HTMLInputTextElement2_put_selectionStart(IHTMLInputTextElement2 *iface, LONG v)
{
    HTMLInputElement *This = impl_from_IHTMLInputTextElement2(iface);
1267 1268 1269 1270 1271 1272 1273 1274 1275 1276
    nsresult nsres;

    TRACE("(%p)->(%d)\n", This, v);

    nsres = nsIDOMHTMLInputElement_SetSelectionStart(This->nsinput, v);
    if(NS_FAILED(nsres)) {
        ERR("SetSelectionStart failed: %08x\n", nsres);
        return E_FAIL;
    }
    return S_OK;
1277 1278 1279 1280 1281
}

static HRESULT WINAPI HTMLInputTextElement2_get_selectionStart(IHTMLInputTextElement2 *iface, LONG *p)
{
    HTMLInputElement *This = impl_from_IHTMLInputTextElement2(iface);
1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294
    INT32 selection_start;
    nsresult nsres;

    TRACE("(%p)->(%p)\n", This, p);

    nsres = nsIDOMHTMLInputElement_GetSelectionStart(This->nsinput, &selection_start);
    if(NS_FAILED(nsres)) {
        ERR("GetSelectionStart failed: %08x\n", nsres);
        return E_FAIL;
    }

    *p = selection_start;
    return S_OK;
1295 1296 1297 1298 1299
}

static HRESULT WINAPI HTMLInputTextElement2_put_selectionEnd(IHTMLInputTextElement2 *iface, LONG v)
{
    HTMLInputElement *This = impl_from_IHTMLInputTextElement2(iface);
1300 1301 1302 1303 1304 1305 1306 1307 1308 1309
    nsresult nsres;

    TRACE("(%p)->(%d)\n", This, v);

    nsres = nsIDOMHTMLInputElement_SetSelectionEnd(This->nsinput, v);
    if(NS_FAILED(nsres)) {
        ERR("SetSelectionEnd failed: %08x\n", nsres);
        return E_FAIL;
    }
    return S_OK;
1310 1311 1312 1313 1314
}

static HRESULT WINAPI HTMLInputTextElement2_get_selectionEnd(IHTMLInputTextElement2 *iface, LONG *p)
{
    HTMLInputElement *This = impl_from_IHTMLInputTextElement2(iface);
1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327
    INT32 selection_end;
    nsresult nsres;

    TRACE("(%p)->(%p)\n", This, p);

    nsres = nsIDOMHTMLInputElement_GetSelectionEnd(This->nsinput, &selection_end);
    if(NS_FAILED(nsres)) {
        ERR("GetSelectionEnd failed: %08x\n", nsres);
        return E_FAIL;
    }

    *p = selection_end;
    return S_OK;
1328 1329 1330 1331 1332
}

static HRESULT WINAPI HTMLInputTextElement2_setSelectionRange(IHTMLInputTextElement2 *iface, LONG start, LONG end)
{
    HTMLInputElement *This = impl_from_IHTMLInputTextElement2(iface);
1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347
    nsAString none_str;
    nsresult nsres;

    static const WCHAR noneW[] = {'n','o','n','e',0};

    TRACE("(%p)->(%d %d)\n", This, start, end);

    nsAString_InitDepend(&none_str, noneW);
    nsres = nsIDOMHTMLInputElement_SetSelectionRange(This->nsinput, start, end, &none_str);
    nsAString_Finish(&none_str);
    if(NS_FAILED(nsres)) {
        ERR("SetSelectionRange failed: %08x\n", nsres);
        return E_FAIL;
    }
    return S_OK;
1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364
}

static const IHTMLInputTextElement2Vtbl HTMLInputTextElement2Vtbl = {
    HTMLInputTextElement2_QueryInterface,
    HTMLInputTextElement2_AddRef,
    HTMLInputTextElement2_Release,
    HTMLInputTextElement2_GetTypeInfoCount,
    HTMLInputTextElement2_GetTypeInfo,
    HTMLInputTextElement2_GetIDsOfNames,
    HTMLInputTextElement2_Invoke,
    HTMLInputTextElement2_put_selectionStart,
    HTMLInputTextElement2_get_selectionStart,
    HTMLInputTextElement2_put_selectionEnd,
    HTMLInputTextElement2_get_selectionEnd,
    HTMLInputTextElement2_setSelectionRange
};

1365 1366 1367 1368
static inline HTMLInputElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
{
    return CONTAINING_RECORD(iface, HTMLInputElement, element.node);
}
1369

1370 1371
static HRESULT HTMLInputElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
{
1372
    HTMLInputElement *This = impl_from_HTMLDOMNode(iface);
1373 1374 1375 1376 1377

    *ppv = NULL;

    if(IsEqualGUID(&IID_IUnknown, riid)) {
        TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1378
        *ppv = &This->IHTMLInputElement_iface;
1379 1380
    }else if(IsEqualGUID(&IID_IDispatch, riid)) {
        TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1381
        *ppv = &This->IHTMLInputElement_iface;
1382 1383
    }else if(IsEqualGUID(&IID_IHTMLInputElement, riid)) {
        TRACE("(%p)->(IID_IHTMLInputElement %p)\n", This, ppv);
1384
        *ppv = &This->IHTMLInputElement_iface;
1385 1386
    }else if(IsEqualGUID(&IID_IHTMLInputTextElement, riid)) {
        TRACE("(%p)->(IID_IHTMLInputTextElement %p)\n", This, ppv);
1387
        *ppv = &This->IHTMLInputTextElement_iface;
1388 1389 1390
    }else if(IsEqualGUID(&IID_IHTMLInputTextElement2, riid)) {
        TRACE("(%p)->(IID_IHTMLInputTextElement2 %p)\n", This, ppv);
        *ppv = &This->IHTMLInputTextElement2_iface;
1391 1392 1393 1394 1395 1396 1397 1398 1399 1400
    }

    if(*ppv) {
        IUnknown_AddRef((IUnknown*)*ppv);
        return S_OK;
    }

    return HTMLElement_QI(&This->element.node, riid, ppv);
}

1401 1402
static HRESULT HTMLInputElementImpl_put_disabled(HTMLDOMNode *iface, VARIANT_BOOL v)
{
1403
    HTMLInputElement *This = impl_from_HTMLDOMNode(iface);
1404
    return IHTMLInputElement_put_disabled(&This->IHTMLInputElement_iface, v);
1405 1406 1407 1408
}

static HRESULT HTMLInputElementImpl_get_disabled(HTMLDOMNode *iface, VARIANT_BOOL *p)
{
1409
    HTMLInputElement *This = impl_from_HTMLDOMNode(iface);
1410
    return IHTMLInputElement_get_disabled(&This->IHTMLInputElement_iface, p);
1411 1412
}

1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438
static BOOL HTMLInputElement_is_text_edit(HTMLDOMNode *iface)
{
    HTMLInputElement *This = impl_from_HTMLDOMNode(iface);
    const PRUnichar *type;
    nsAString nsstr;
    nsresult nsres;
    BOOL ret = FALSE;

    static const WCHAR buttonW[] = {'b','u','t','t','o','n',0};
    static const WCHAR hiddenW[] = {'h','i','d','d','e','n',0};
    static const WCHAR passwordW[] = {'p','a','s','s','w','o','r','d',0};
    static const WCHAR resetW[] = {'r','e','s','e','t',0};
    static const WCHAR submitW[] = {'s','u','b','m','i','t',0};
    static const WCHAR textW[] = {'t','e','x','t',0};

    nsAString_Init(&nsstr, NULL);
    nsres = nsIDOMHTMLInputElement_GetType(This->nsinput, &nsstr);
    if(NS_SUCCEEDED(nsres)) {
        nsAString_GetData(&nsstr, &type);
        ret = !strcmpW(type, buttonW) || !strcmpW(type, hiddenW) || !strcmpW(type, passwordW)
            || !strcmpW(type, resetW) || !strcmpW(type, submitW) || !strcmpW(type, textW);
    }
    nsAString_Finish(&nsstr);
    return ret;
}

1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458
static void HTMLInputElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
{
    HTMLInputElement *This = impl_from_HTMLDOMNode(iface);

    if(This->nsinput)
        note_cc_edge((nsISupports*)This->nsinput, "This->nsinput", cb);
}

static void HTMLInputElement_unlink(HTMLDOMNode *iface)
{
    HTMLInputElement *This = impl_from_HTMLDOMNode(iface);

    if(This->nsinput) {
        nsIDOMHTMLInputElement *nsinput = This->nsinput;

        This->nsinput = NULL;
        nsIDOMHTMLInputElement_Release(nsinput);
    }
}

1459
static const NodeImplVtbl HTMLInputElementImplVtbl = {
1460
    &CLSID_HTMLInputElement,
1461
    HTMLInputElement_QI,
1462
    HTMLElement_destructor,
1463
    HTMLElement_cpc,
1464
    HTMLElement_clone,
1465
    HTMLElement_handle_event,
1466
    HTMLElement_get_attr_col,
1467
    NULL,
1468 1469
    HTMLInputElementImpl_put_disabled,
    HTMLInputElementImpl_get_disabled,
1470 1471 1472 1473 1474 1475
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    HTMLInputElement_traverse,
1476 1477
    HTMLInputElement_unlink,
    HTMLInputElement_is_text_edit
1478 1479
};

1480
static const tid_t HTMLInputElement_iface_tids[] = {
1481
    HTMLELEMENT_TIDS,
1482
    IHTMLInputElement_tid,
1483
    IHTMLInputTextElement2_tid,
1484 1485
    0
};
1486 1487 1488
static dispex_static_data_t HTMLInputElement_dispex = {
    NULL,
    DispHTMLInputElement_tid,
1489 1490
    HTMLInputElement_iface_tids,
    HTMLElement_init_dispex_info
1491 1492
};

1493
HRESULT HTMLInputElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
1494
{
1495
    HTMLInputElement *ret;
1496 1497
    nsresult nsres;

1498 1499 1500 1501
    ret = heap_alloc_zero(sizeof(HTMLInputElement));
    if(!ret)
        return E_OUTOFMEMORY;

1502
    ret->IHTMLInputElement_iface.lpVtbl = &HTMLInputElementVtbl;
1503
    ret->IHTMLInputTextElement_iface.lpVtbl = &HTMLInputTextElementVtbl;
1504
    ret->IHTMLInputTextElement2_iface.lpVtbl = &HTMLInputTextElement2Vtbl;
1505
    ret->element.node.vtbl = &HTMLInputElementImplVtbl;
1506

1507 1508
    HTMLElement_Init(&ret->element, doc, nselem, &HTMLInputElement_dispex);

1509
    nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLInputElement, (void**)&ret->nsinput);
1510
    assert(nsres == NS_OK);
1511 1512 1513

    *elem = &ret->element;
    return S_OK;
1514
}
1515

1516
struct HTMLLabelElement {
1517 1518 1519
    HTMLElement element;

    IHTMLLabelElement IHTMLLabelElement_iface;
1520
};
1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552

static inline HTMLLabelElement *impl_from_IHTMLLabelElement(IHTMLLabelElement *iface)
{
    return CONTAINING_RECORD(iface, HTMLLabelElement, IHTMLLabelElement_iface);
}

static HRESULT WINAPI HTMLLabelElement_QueryInterface(IHTMLLabelElement *iface,
                                                         REFIID riid, void **ppv)
{
    HTMLLabelElement *This = impl_from_IHTMLLabelElement(iface);

    return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
}

static ULONG WINAPI HTMLLabelElement_AddRef(IHTMLLabelElement *iface)
{
    HTMLLabelElement *This = impl_from_IHTMLLabelElement(iface);

    return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
}

static ULONG WINAPI HTMLLabelElement_Release(IHTMLLabelElement *iface)
{
    HTMLLabelElement *This = impl_from_IHTMLLabelElement(iface);

    return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
}

static HRESULT WINAPI HTMLLabelElement_GetTypeInfoCount(IHTMLLabelElement *iface, UINT *pctinfo)
{
    HTMLLabelElement *This = impl_from_IHTMLLabelElement(iface);

1553
    return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
1554 1555 1556 1557 1558 1559 1560
}

static HRESULT WINAPI HTMLLabelElement_GetTypeInfo(IHTMLLabelElement *iface, UINT iTInfo,
        LCID lcid, ITypeInfo **ppTInfo)
{
    HTMLLabelElement *This = impl_from_IHTMLLabelElement(iface);

1561
    return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1562 1563 1564 1565 1566 1567 1568
}

static HRESULT WINAPI HTMLLabelElement_GetIDsOfNames(IHTMLLabelElement *iface, REFIID riid,
        LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
{
    HTMLLabelElement *This = impl_from_IHTMLLabelElement(iface);

1569
    return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
1570 1571 1572 1573 1574 1575 1576 1577 1578
            cNames, lcid, rgDispId);
}

static HRESULT WINAPI HTMLLabelElement_Invoke(IHTMLLabelElement *iface, DISPID dispIdMember,
                            REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
                            VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
    HTMLLabelElement *This = impl_from_IHTMLLabelElement(iface);

1579
    return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
1580 1581 1582 1583 1584 1585
            lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
}

static HRESULT WINAPI HTMLLabelElement_put_htmlFor(IHTMLLabelElement *iface, BSTR v)
{
    HTMLLabelElement *This = impl_from_IHTMLLabelElement(iface);
1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601
    nsAString for_str, val_str;
    nsresult nsres;

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    nsAString_InitDepend(&for_str, forW);
    nsAString_InitDepend(&val_str, v);
    nsres = nsIDOMHTMLElement_SetAttribute(This->element.nselem, &for_str, &val_str);
    nsAString_Finish(&for_str);
    nsAString_Finish(&val_str);
    if(NS_FAILED(nsres)) {
        ERR("SetAttribute failed: %08x\n", nsres);
        return E_FAIL;
    }

    return S_OK;
1602 1603 1604 1605 1606
}

static HRESULT WINAPI HTMLLabelElement_get_htmlFor(IHTMLLabelElement *iface, BSTR *p)
{
    HTMLLabelElement *This = impl_from_IHTMLLabelElement(iface);
1607 1608 1609

    TRACE("(%p)->(%p)\n", This, p);

1610
    return elem_string_attr_getter(&This->element, forW, FALSE, p);
1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666
}

static HRESULT WINAPI HTMLLabelElement_put_accessKey(IHTMLLabelElement *iface, BSTR v)
{
    HTMLLabelElement *This = impl_from_IHTMLLabelElement(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLLabelElement_get_accessKey(IHTMLLabelElement *iface, BSTR *p)
{
    HTMLLabelElement *This = impl_from_IHTMLLabelElement(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static const IHTMLLabelElementVtbl HTMLLabelElementVtbl = {
    HTMLLabelElement_QueryInterface,
    HTMLLabelElement_AddRef,
    HTMLLabelElement_Release,
    HTMLLabelElement_GetTypeInfoCount,
    HTMLLabelElement_GetTypeInfo,
    HTMLLabelElement_GetIDsOfNames,
    HTMLLabelElement_Invoke,
    HTMLLabelElement_put_htmlFor,
    HTMLLabelElement_get_htmlFor,
    HTMLLabelElement_put_accessKey,
    HTMLLabelElement_get_accessKey
};

static inline HTMLLabelElement *label_from_HTMLDOMNode(HTMLDOMNode *iface)
{
    return CONTAINING_RECORD(iface, HTMLLabelElement, element.node);
}

static HRESULT HTMLLabelElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
{
    HTMLLabelElement *This = label_from_HTMLDOMNode(iface);

    *ppv = NULL;

    if(IsEqualGUID(&IID_IUnknown, riid)) {
        TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
        *ppv = &This->IHTMLLabelElement_iface;
    }else if(IsEqualGUID(&IID_IHTMLLabelElement, riid)) {
        TRACE("(%p)->(IID_IHTMLLabelElement %p)\n", This, ppv);
        *ppv = &This->IHTMLLabelElement_iface;
    }else {
        return HTMLElement_QI(&This->element.node, riid, ppv);
    }

    IUnknown_AddRef((IUnknown*)*ppv);
    return S_OK;
}

static const NodeImplVtbl HTMLLabelElementImplVtbl = {
1667
    &CLSID_HTMLLabelElement,
1668 1669
    HTMLLabelElement_QI,
    HTMLElement_destructor,
1670
    HTMLElement_cpc,
1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684
    HTMLElement_clone,
    HTMLElement_handle_event,
    HTMLElement_get_attr_col,
};

static const tid_t HTMLLabelElement_iface_tids[] = {
    HTMLELEMENT_TIDS,
    IHTMLLabelElement_tid,
    0
};

static dispex_static_data_t HTMLLabelElement_dispex = {
    NULL,
    DispHTMLLabelElement_tid,
1685 1686
    HTMLLabelElement_iface_tids,
    HTMLElement_init_dispex_info
1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703
};

HRESULT HTMLLabelElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
{
    HTMLLabelElement *ret;

    ret = heap_alloc_zero(sizeof(*ret));
    if(!ret)
        return E_OUTOFMEMORY;

    ret->IHTMLLabelElement_iface.lpVtbl = &HTMLLabelElementVtbl;
    ret->element.node.vtbl = &HTMLLabelElementImplVtbl;

    HTMLElement_Init(&ret->element, doc, nselem, &HTMLLabelElement_dispex);
    *elem = &ret->element;
    return S_OK;
}
1704

1705
struct HTMLButtonElement {
1706 1707 1708
    HTMLElement element;

    IHTMLButtonElement IHTMLButtonElement_iface;
1709 1710

    nsIDOMHTMLButtonElement *nsbutton;
1711
};
1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743

static inline HTMLButtonElement *impl_from_IHTMLButtonElement(IHTMLButtonElement *iface)
{
    return CONTAINING_RECORD(iface, HTMLButtonElement, IHTMLButtonElement_iface);
}

static HRESULT WINAPI HTMLButtonElement_QueryInterface(IHTMLButtonElement *iface,
                                                         REFIID riid, void **ppv)
{
    HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface);

    return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
}

static ULONG WINAPI HTMLButtonElement_AddRef(IHTMLButtonElement *iface)
{
    HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface);

    return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
}

static ULONG WINAPI HTMLButtonElement_Release(IHTMLButtonElement *iface)
{
    HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface);

    return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
}

static HRESULT WINAPI HTMLButtonElement_GetTypeInfoCount(IHTMLButtonElement *iface, UINT *pctinfo)
{
    HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface);

1744
    return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
1745 1746 1747 1748 1749 1750 1751
}

static HRESULT WINAPI HTMLButtonElement_GetTypeInfo(IHTMLButtonElement *iface, UINT iTInfo,
        LCID lcid, ITypeInfo **ppTInfo)
{
    HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface);

1752
    return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1753 1754 1755 1756 1757 1758 1759
}

static HRESULT WINAPI HTMLButtonElement_GetIDsOfNames(IHTMLButtonElement *iface, REFIID riid,
        LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
{
    HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface);

1760
    return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
1761 1762 1763 1764 1765 1766 1767 1768 1769
            cNames, lcid, rgDispId);
}

static HRESULT WINAPI HTMLButtonElement_Invoke(IHTMLButtonElement *iface, DISPID dispIdMember,
                            REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
                            VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
    HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface);

1770
    return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
1771 1772 1773 1774 1775 1776
            lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
}

static HRESULT WINAPI HTMLButtonElement_get_type(IHTMLButtonElement *iface, BSTR *p)
{
    HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface);
1777 1778 1779 1780 1781 1782 1783 1784
    nsAString type_str;
    nsresult nsres;

    TRACE("(%p)->(%p)\n", This, p);

    nsAString_Init(&type_str, NULL);
    nsres = nsIDOMHTMLButtonElement_GetType(This->nsbutton, &type_str);
    return return_nsstr(nsres, &type_str, p);
1785 1786 1787 1788 1789
}

static HRESULT WINAPI HTMLButtonElement_put_value(IHTMLButtonElement *iface, BSTR v)
{
    HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface);
1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803
    nsAString nsstr;
    nsresult nsres;

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    nsAString_InitDepend(&nsstr, v);
    nsres = nsIDOMHTMLButtonElement_SetValue(This->nsbutton, &nsstr);
    nsAString_Finish(&nsstr);
    if(NS_FAILED(nsres)) {
        ERR("SetValue failed: %08x\n", nsres);
        return E_FAIL;
    }

    return S_OK;
1804 1805 1806 1807 1808
}

static HRESULT WINAPI HTMLButtonElement_get_value(IHTMLButtonElement *iface, BSTR *p)
{
    HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface);
1809 1810 1811 1812 1813 1814 1815 1816
    nsAString value_str;
    nsresult nsres;

    TRACE("(%p)->(%p)\n", This, p);

    nsAString_Init(&value_str, NULL);
    nsres = nsIDOMHTMLButtonElement_GetValue(This->nsbutton, &value_str);
    return return_nsstr(nsres, &value_str, p);
1817 1818 1819 1820 1821
}

static HRESULT WINAPI HTMLButtonElement_put_name(IHTMLButtonElement *iface, BSTR v)
{
    HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface);
1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835
    nsAString name_str;
    nsresult nsres;

    TRACE("(%p)->(%s)\n", This, debugstr_w(v));

    nsAString_InitDepend(&name_str, v);
    nsres = nsIDOMHTMLButtonElement_SetName(This->nsbutton, &name_str);
    nsAString_Finish(&name_str);
    if(NS_FAILED(nsres)) {
        ERR("SetName failed: %08x\n", nsres);
        return E_FAIL;
    }

    return S_OK;
1836 1837 1838 1839 1840
}

static HRESULT WINAPI HTMLButtonElement_get_name(IHTMLButtonElement *iface, BSTR *p)
{
    HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface);
1841 1842 1843 1844 1845 1846 1847 1848
    nsAString name_str;
    nsresult nsres;

    TRACE("(%p)->(%p)\n", This, p);

    nsAString_Init(&name_str, NULL);
    nsres = nsIDOMHTMLButtonElement_GetName(This->nsbutton, &name_str);
    return return_nsstr(nsres, &name_str, p);
1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867
}

static HRESULT WINAPI HTMLButtonElement_put_status(IHTMLButtonElement *iface, VARIANT v)
{
    HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface);
    FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLButtonElement_get_status(IHTMLButtonElement *iface, VARIANT *p)
{
    HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface);
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLButtonElement_put_disabled(IHTMLButtonElement *iface, VARIANT_BOOL v)
{
    HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface);
1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878
    nsresult nsres;

    TRACE("(%p)->(%x)\n", This, v);

    nsres = nsIDOMHTMLButtonElement_SetDisabled(This->nsbutton, !!v);
    if(NS_FAILED(nsres)) {
        ERR("SetDisabled failed: %08x\n", nsres);
        return E_FAIL;
    }

    return S_OK;
1879 1880 1881 1882 1883
}

static HRESULT WINAPI HTMLButtonElement_get_disabled(IHTMLButtonElement *iface, VARIANT_BOOL *p)
{
    HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface);
1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894
    cpp_bool disabled;
    nsresult nsres;

    TRACE("(%p)->(%p)\n", This, p);

    nsres = nsIDOMHTMLButtonElement_GetDisabled(This->nsbutton, &disabled);
    if(NS_FAILED(nsres)) {
        ERR("GetDisabled failed: %08x\n", nsres);
        return E_FAIL;
    }

1895
    *p = variant_bool(disabled);
1896
    return S_OK;
1897 1898 1899 1900 1901
}

static HRESULT WINAPI HTMLButtonElement_get_form(IHTMLButtonElement *iface, IHTMLFormElement **p)
{
    HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface);
1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913
    nsIDOMHTMLFormElement *nsform;
    nsresult nsres;

    TRACE("(%p)->(%p)\n", This, p);

    nsres = nsIDOMHTMLButtonElement_GetForm(This->nsbutton, &nsform);
    if (NS_FAILED(nsres)) {
        ERR("GetForm failed: %08x, nsform: %p\n", nsres, nsform);
        return E_FAIL;
    }

    return return_nsform(&This->element, nsform, p);
1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968
}

static HRESULT WINAPI HTMLButtonElement_createTextRange(IHTMLButtonElement *iface, IHTMLTxtRange **range)
{
    HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface);
    FIXME("(%p)->(%p)\n", This, range);
    return E_NOTIMPL;
}

static const IHTMLButtonElementVtbl HTMLButtonElementVtbl = {
    HTMLButtonElement_QueryInterface,
    HTMLButtonElement_AddRef,
    HTMLButtonElement_Release,
    HTMLButtonElement_GetTypeInfoCount,
    HTMLButtonElement_GetTypeInfo,
    HTMLButtonElement_GetIDsOfNames,
    HTMLButtonElement_Invoke,
    HTMLButtonElement_get_type,
    HTMLButtonElement_put_value,
    HTMLButtonElement_get_value,
    HTMLButtonElement_put_name,
    HTMLButtonElement_get_name,
    HTMLButtonElement_put_status,
    HTMLButtonElement_get_status,
    HTMLButtonElement_put_disabled,
    HTMLButtonElement_get_disabled,
    HTMLButtonElement_get_form,
    HTMLButtonElement_createTextRange
};

static inline HTMLButtonElement *button_from_HTMLDOMNode(HTMLDOMNode *iface)
{
    return CONTAINING_RECORD(iface, HTMLButtonElement, element.node);
}

static HRESULT HTMLButtonElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
{
    HTMLButtonElement *This = button_from_HTMLDOMNode(iface);

    *ppv = NULL;

    if(IsEqualGUID(&IID_IUnknown, riid)) {
        TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
        *ppv = &This->IHTMLButtonElement_iface;
    }else if(IsEqualGUID(&IID_IHTMLButtonElement, riid)) {
        TRACE("(%p)->(IID_IHTMLButtonElement %p)\n", This, ppv);
        *ppv = &This->IHTMLButtonElement_iface;
    }else {
        return HTMLElement_QI(&This->element.node, riid, ppv);
    }

    IUnknown_AddRef((IUnknown*)*ppv);
    return S_OK;
}

1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980
static HRESULT HTMLButtonElementImpl_put_disabled(HTMLDOMNode *iface, VARIANT_BOOL v)
{
    HTMLButtonElement *This = button_from_HTMLDOMNode(iface);
    return IHTMLButtonElement_put_disabled(&This->IHTMLButtonElement_iface, v);
}

static HRESULT HTMLButtonElementImpl_get_disabled(HTMLDOMNode *iface, VARIANT_BOOL *p)
{
    HTMLButtonElement *This = button_from_HTMLDOMNode(iface);
    return IHTMLButtonElement_get_disabled(&This->IHTMLButtonElement_iface, p);
}

1981 1982 1983 1984 1985
static BOOL HTMLButtonElement_is_text_edit(HTMLDOMNode *iface)
{
    return TRUE;
}

1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005
static void HTMLButtonElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
{
    HTMLButtonElement *This = button_from_HTMLDOMNode(iface);

    if(This->nsbutton)
        note_cc_edge((nsISupports*)This->nsbutton, "This->nsbutton", cb);
}

static void HTMLButtonElement_unlink(HTMLDOMNode *iface)
{
    HTMLButtonElement *This = button_from_HTMLDOMNode(iface);

    if(This->nsbutton) {
        nsIDOMHTMLButtonElement *nsbutton = This->nsbutton;

        This->nsbutton = NULL;
        nsIDOMHTMLButtonElement_Release(nsbutton);
    }
}

2006
static const NodeImplVtbl HTMLButtonElementImplVtbl = {
2007
    &CLSID_HTMLButtonElement,
2008 2009
    HTMLButtonElement_QI,
    HTMLElement_destructor,
2010
    HTMLElement_cpc,
2011 2012 2013
    HTMLElement_clone,
    HTMLElement_handle_event,
    HTMLElement_get_attr_col,
2014 2015
    NULL,
    HTMLButtonElementImpl_put_disabled,
2016 2017 2018 2019 2020 2021 2022
    HTMLButtonElementImpl_get_disabled,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    HTMLButtonElement_traverse,
2023 2024
    HTMLButtonElement_unlink,
    HTMLButtonElement_is_text_edit
2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035
};

static const tid_t HTMLButtonElement_iface_tids[] = {
    HTMLELEMENT_TIDS,
    IHTMLButtonElement_tid,
    0
};

static dispex_static_data_t HTMLButtonElement_dispex = {
    NULL,
    DispHTMLButtonElement_tid,
2036 2037
    HTMLButtonElement_iface_tids,
    HTMLElement_init_dispex_info
2038 2039 2040 2041 2042
};

HRESULT HTMLButtonElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
{
    HTMLButtonElement *ret;
2043
    nsresult nsres;
2044 2045 2046 2047 2048 2049 2050 2051 2052

    ret = heap_alloc_zero(sizeof(*ret));
    if(!ret)
        return E_OUTOFMEMORY;

    ret->IHTMLButtonElement_iface.lpVtbl = &HTMLButtonElementVtbl;
    ret->element.node.vtbl = &HTMLButtonElementImplVtbl;

    HTMLElement_Init(&ret->element, doc, nselem, &HTMLButtonElement_dispex);
2053 2054

    nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLButtonElement, (void**)&ret->nsbutton);
2055
    assert(nsres == NS_OK);
2056

2057 2058 2059
    *elem = &ret->element;
    return S_OK;
}