htmlinput.c 56.9 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 37

WINE_DEFAULT_DEBUG_CHANNEL(mshtml);

typedef struct {
38 39
    HTMLElement element;

40
    IHTMLInputElement IHTMLInputElement_iface;
41
    IHTMLInputTextElement IHTMLInputTextElement_iface;
42 43 44 45

    nsIDOMHTMLInputElement *nsinput;
} HTMLInputElement;

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

48 49 50 51
static inline HTMLInputElement *impl_from_IHTMLInputElement(IHTMLInputElement *iface)
{
    return CONTAINING_RECORD(iface, HTMLInputElement, IHTMLInputElement_iface);
}
52 53 54 55 56

static inline HTMLInputElement *impl_from_IHTMLInputTextElement(IHTMLInputTextElement *iface)
{
    return CONTAINING_RECORD(iface, HTMLInputElement, IHTMLInputTextElement_iface);
}
57 58 59 60

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

63
    return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
64 65 66 67
}

static ULONG WINAPI HTMLInputElement_AddRef(IHTMLInputElement *iface)
{
68
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
69

70
    return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
71 72 73 74
}

static ULONG WINAPI HTMLInputElement_Release(IHTMLInputElement *iface)
{
75
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
76

77
    return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
78 79 80 81
}

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

84
    return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo);
85 86 87 88 89
}

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

92 93
    return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid,
            ppTInfo);
94 95 96 97 98 99
}

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

102
    return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
103
            cNames, lcid, rgDispId);
104 105 106 107 108 109
}

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

112 113
    return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid,
            lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
114 115 116 117
}

static HRESULT WINAPI HTMLInputElement_put_type(IHTMLInputElement *iface, BSTR v)
{
118
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
    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;
137 138 139 140
}

static HRESULT WINAPI HTMLInputElement_get_type(IHTMLInputElement *iface, BSTR *p)
{
141
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
142 143 144 145 146 147 148
    nsAString type_str;
    nsresult nsres;

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

    nsAString_Init(&type_str, NULL);
    nsres = nsIDOMHTMLInputElement_GetType(This->nsinput, &type_str);
149
    return return_nsstr(nsres, &type_str, p);
150 151 152 153
}

static HRESULT WINAPI HTMLInputElement_put_value(IHTMLInputElement *iface, BSTR v)
{
154
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
155 156 157 158 159
    nsAString val_str;
    nsresult nsres;

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

160
    nsAString_InitDepend(&val_str, v);
161 162 163 164 165 166
    nsres = nsIDOMHTMLInputElement_SetValue(This->nsinput, &val_str);
    nsAString_Finish(&val_str);
    if(NS_FAILED(nsres))
        ERR("SetValue failed: %08x\n", nsres);

    return S_OK;
167 168 169 170
}

static HRESULT WINAPI HTMLInputElement_get_value(IHTMLInputElement *iface, BSTR *p)
{
171
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
172 173 174 175 176 177 178
    nsAString value_str;
    nsresult nsres;

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

    nsAString_Init(&value_str, NULL);
    nsres = nsIDOMHTMLInputElement_GetValue(This->nsinput, &value_str);
179
    return return_nsstr(nsres, &value_str, p);
180 181 182 183
}

static HRESULT WINAPI HTMLInputElement_put_name(IHTMLInputElement *iface, BSTR v)
{
184
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
185 186 187 188 189 190 191 192 193 194 195 196 197 198
    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;
199 200 201 202
}

static HRESULT WINAPI HTMLInputElement_get_name(IHTMLInputElement *iface, BSTR *p)
{
203
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
204 205 206 207 208 209 210
    nsAString name_str;
    nsresult nsres;

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

    nsAString_Init(&name_str, NULL);
    nsres = nsIDOMHTMLInputElement_GetName(This->nsinput, &name_str);
211
    return return_nsstr(nsres, &name_str, p);
212 213 214 215
}

static HRESULT WINAPI HTMLInputElement_put_status(IHTMLInputElement *iface, VARIANT_BOOL v)
{
216
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
217 218 219 220 221 222
    FIXME("(%p)->(%x)\n", This, v);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_status(IHTMLInputElement *iface, VARIANT_BOOL *p)
{
223
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
224 225 226 227 228 229
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_disabled(IHTMLInputElement *iface, VARIANT_BOOL v)
{
230
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
231 232 233 234 235 236 237 238 239
    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;
240 241 242 243
}

static HRESULT WINAPI HTMLInputElement_get_disabled(IHTMLInputElement *iface, VARIANT_BOOL *p)
{
244
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
245
    cpp_bool disabled = FALSE;
246 247 248 249 250 251 252

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

    nsIDOMHTMLInputElement_GetDisabled(This->nsinput, &disabled);

    *p = disabled ? VARIANT_TRUE : VARIANT_FALSE;
    return S_OK;
253 254 255 256
}

static HRESULT WINAPI HTMLInputElement_get_form(IHTMLInputElement *iface, IHTMLFormElement **p)
{
257
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
258
    nsIDOMHTMLFormElement *nsform;
259
    nsIDOMNode *form_node;
260 261 262 263 264 265 266 267 268 269 270 271 272
    HTMLDOMNode *node;
    HRESULT hres;
    nsresult nsres;

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

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

273
    nsres = nsIDOMHTMLFormElement_QueryInterface(nsform, &IID_nsIDOMNode, (void**)&form_node);
274
    nsIDOMHTMLFormElement_Release(nsform);
275 276 277 278
    assert(nsres == NS_OK);

    hres = get_node(This->element.node.doc, form_node, TRUE, &node);
    nsIDOMNode_Release(form_node);
279 280 281 282 283 284 285
    if (FAILED(hres))
        return hres;

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

    node_release(node);
    return hres;
286 287
}

288
static HRESULT WINAPI HTMLInputElement_put_size(IHTMLInputElement *iface, LONG v)
289
{
290
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
291 292 293 294 295 296 297 298 299 300 301 302 303
    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;
304 305
}

306
static HRESULT WINAPI HTMLInputElement_get_size(IHTMLInputElement *iface, LONG *p)
307
{
308
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
309 310 311 312 313 314 315 316 317 318 319 320 321 322
    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;
323 324
}

325
static HRESULT WINAPI HTMLInputElement_put_maxLength(IHTMLInputElement *iface, LONG v)
326
{
327
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
328 329 330 331 332 333 334 335 336 337 338 339
    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;
340 341
}

342
static HRESULT WINAPI HTMLInputElement_get_maxLength(IHTMLInputElement *iface, LONG *p)
343
{
344
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
345
    LONG max_length;
346 347 348 349 350 351 352 353 354 355
    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;
356 357 358 359
}

static HRESULT WINAPI HTMLInputElement_select(IHTMLInputElement *iface)
{
360
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
361 362 363 364 365 366 367 368 369 370 371
    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;
372 373 374 375
}

static HRESULT WINAPI HTMLInputElement_put_onchange(IHTMLInputElement *iface, VARIANT v)
{
376
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
377 378 379 380

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

    return set_node_event(&This->element.node, EVENTID_CHANGE, &v);
381 382 383 384
}

static HRESULT WINAPI HTMLInputElement_get_onchange(IHTMLInputElement *iface, VARIANT *p)
{
385
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
386 387 388 389

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

    return get_node_event(&This->element.node, EVENTID_CHANGE, p);
390 391 392 393
}

static HRESULT WINAPI HTMLInputElement_put_onselect(IHTMLInputElement *iface, VARIANT v)
{
394
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
395 396 397 398 399 400
    FIXME("(%p)->()\n", This);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_onselect(IHTMLInputElement *iface, VARIANT *p)
{
401
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
402 403 404 405 406 407
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_defaultValue(IHTMLInputElement *iface, BSTR v)
{
408
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
409 410 411 412 413 414 415 416 417 418 419 420 421 422
    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;
423 424 425 426
}

static HRESULT WINAPI HTMLInputElement_get_defaultValue(IHTMLInputElement *iface, BSTR *p)
{
427
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
428 429 430 431 432 433 434 435
    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);
436 437 438 439
}

static HRESULT WINAPI HTMLInputElement_put_readOnly(IHTMLInputElement *iface, VARIANT_BOOL v)
{
440
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
441 442 443 444 445 446 447 448 449 450
    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;
451 452 453 454
}

static HRESULT WINAPI HTMLInputElement_get_readOnly(IHTMLInputElement *iface, VARIANT_BOOL *p)
{
455
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
456 457 458 459 460 461 462 463 464 465 466 467
    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;
    }
    *p = b ? VARIANT_TRUE : VARIANT_FALSE;
    return S_OK;
468 469 470 471
}

static HRESULT WINAPI HTMLInputElement_createTextRange(IHTMLInputElement *iface, IHTMLTxtRange **range)
{
472
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
473 474 475 476 477 478
    FIXME("(%p)->(%p)\n", This, range);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_indeterminate(IHTMLInputElement *iface, VARIANT_BOOL v)
{
479
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
480 481 482 483 484 485
    FIXME("(%p)->(%x)\n", This, v);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_indeterminate(IHTMLInputElement *iface, VARIANT_BOOL *p)
{
486
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
487 488 489 490 491 492
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_defaultChecked(IHTMLInputElement *iface, VARIANT_BOOL v)
{
493
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
494 495 496 497 498 499 500 501 502 503 504
    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;
505 506 507 508
}

static HRESULT WINAPI HTMLInputElement_get_defaultChecked(IHTMLInputElement *iface, VARIANT_BOOL *p)
{
509
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
510
    cpp_bool default_checked = FALSE;
511 512 513 514 515 516 517 518 519 520 521 522
    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;
    }

    *p = default_checked ? VARIANT_TRUE : VARIANT_FALSE;
    return S_OK;
523 524 525 526
}

static HRESULT WINAPI HTMLInputElement_put_checked(IHTMLInputElement *iface, VARIANT_BOOL v)
{
527
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
528 529 530 531 532 533 534 535 536 537 538
    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;
539 540 541 542
}

static HRESULT WINAPI HTMLInputElement_get_checked(IHTMLInputElement *iface, VARIANT_BOOL *p)
{
543
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
544
    cpp_bool checked;
545 546 547 548 549 550
    nsresult nsres;

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

    nsres = nsIDOMHTMLInputElement_GetChecked(This->nsinput, &checked);
    if(NS_FAILED(nsres)) {
551
        ERR("GetChecked failed: %08x\n", nsres);
552 553 554 555 556 557
        return E_FAIL;
    }

    *p = checked ? VARIANT_TRUE : VARIANT_FALSE;
    TRACE("checked=%x\n", *p);
    return S_OK;
558 559 560 561
}

static HRESULT WINAPI HTMLInputElement_put_border(IHTMLInputElement *iface, VARIANT v)
{
562
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
563 564 565 566 567 568
    FIXME("(%p)->()\n", This);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_border(IHTMLInputElement *iface, VARIANT *p)
{
569
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
570 571 572 573
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

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

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

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

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

static HRESULT WINAPI HTMLInputElement_put_alt(IHTMLInputElement *iface, BSTR v)
{
604
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
605 606 607 608 609 610
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_alt(IHTMLInputElement *iface, BSTR *p)
{
611
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
612 613 614 615 616 617
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_src(IHTMLInputElement *iface, BSTR v)
{
618
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
619 620 621 622 623
    nsAString nsstr;
    nsresult nsres;

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

624
    nsAString_InitDepend(&nsstr, v);
625 626 627 628 629 630
    nsres = nsIDOMHTMLInputElement_SetSrc(This->nsinput, &nsstr);
    nsAString_Finish(&nsstr);
    if(NS_FAILED(nsres))
        ERR("SetSrc failed: %08x\n", nsres);

    return S_OK;
631 632 633 634
}

static HRESULT WINAPI HTMLInputElement_get_src(IHTMLInputElement *iface, BSTR *p)
{
635
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654
    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;
655 656 657 658
}

static HRESULT WINAPI HTMLInputElement_put_lowsrc(IHTMLInputElement *iface, BSTR v)
{
659
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
660 661 662 663 664 665
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_lowsrc(IHTMLInputElement *iface, BSTR *p)
{
666
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
667 668 669 670 671 672
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

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

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

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

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

static HRESULT WINAPI HTMLInputElement_get_readyState(IHTMLInputElement *iface, BSTR *p)
{
701
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
702 703 704 705 706 707
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_complete(IHTMLInputElement *iface, VARIANT_BOOL *p)
{
708
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
709 710 711 712 713 714
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_loop(IHTMLInputElement *iface, VARIANT v)
{
715
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
716 717 718 719 720 721
    FIXME("(%p)->()\n", This);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_loop(IHTMLInputElement *iface, VARIANT *p)
{
722
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
723 724 725 726 727 728
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_align(IHTMLInputElement *iface, BSTR v)
{
729
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
730 731 732 733 734 735
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_align(IHTMLInputElement *iface, BSTR *p)
{
736
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
737 738 739 740 741 742
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_put_onload(IHTMLInputElement *iface, VARIANT v)
{
743
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
744 745 746 747 748 749
    FIXME("(%p)->()\n", This);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_onload(IHTMLInputElement *iface, VARIANT *p)
{
750
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
751 752 753 754 755 756
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

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

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

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

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

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

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

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

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

static HRESULT WINAPI HTMLInputElement_put_start(IHTMLInputElement *iface, BSTR v)
{
813
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
814 815 816 817 818 819
    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputElement_get_start(IHTMLInputElement *iface, BSTR *p)
{
820
    HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
821 822 823 824 825 826 827 828 829 830 831 832 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
    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
};

900 901 902
static HRESULT WINAPI HTMLInputTextElement_QueryInterface(IHTMLInputTextElement *iface,
        REFIID riid, void **ppv)
{
903
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
904

905
    return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
906 907 908 909
}

static ULONG WINAPI HTMLInputTextElement_AddRef(IHTMLInputTextElement *iface)
{
910
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
911

912
    return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
913 914 915 916
}

static ULONG WINAPI HTMLInputTextElement_Release(IHTMLInputTextElement *iface)
{
917
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
918

919
    return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
920 921 922 923
}

static HRESULT WINAPI HTMLInputTextElement_GetTypeInfoCount(IHTMLInputTextElement *iface, UINT *pctinfo)
{
924
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
925
    return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo);
926 927 928 929 930
}

static HRESULT WINAPI HTMLInputTextElement_GetTypeInfo(IHTMLInputTextElement *iface, UINT iTInfo,
        LCID lcid, ITypeInfo **ppTInfo)
{
931
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
932 933
    return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid,
            ppTInfo);
934 935 936 937 938
}

static HRESULT WINAPI HTMLInputTextElement_GetIDsOfNames(IHTMLInputTextElement *iface, REFIID riid,
        LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
{
939
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
940 941
    return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
            cNames, lcid, rgDispId);
942 943 944 945 946 947
}

static HRESULT WINAPI HTMLInputTextElement_Invoke(IHTMLInputTextElement *iface, DISPID dispIdMember,
                            REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
                            VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
948
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
949 950
    return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid,
            lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
951 952 953 954
}

static HRESULT WINAPI HTMLInputTextElement_get_type(IHTMLInputTextElement *iface, BSTR *p)
{
955
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
956 957 958

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

959
    return IHTMLInputElement_get_type(&This->IHTMLInputElement_iface, p);
960 961 962 963
}

static HRESULT WINAPI HTMLInputTextElement_put_value(IHTMLInputTextElement *iface, BSTR v)
{
964
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
965 966 967

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

968
    return IHTMLInputElement_put_value(&This->IHTMLInputElement_iface, v);
969 970 971 972
}

static HRESULT WINAPI HTMLInputTextElement_get_value(IHTMLInputTextElement *iface, BSTR *p)
{
973
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
974 975 976

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

977
    return IHTMLInputElement_get_value(&This->IHTMLInputElement_iface, p);
978 979 980 981
}

static HRESULT WINAPI HTMLInputTextElement_put_name(IHTMLInputTextElement *iface, BSTR v)
{
982
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
983 984 985

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

986
    return IHTMLInputElement_put_name(&This->IHTMLInputElement_iface, v);
987 988 989 990
}

static HRESULT WINAPI HTMLInputTextElement_get_name(IHTMLInputTextElement *iface, BSTR *p)
{
991
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
992 993 994

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

995
    return IHTMLInputElement_get_name(&This->IHTMLInputElement_iface, p);
996 997 998 999
}

static HRESULT WINAPI HTMLInputTextElement_put_status(IHTMLInputTextElement *iface, VARIANT v)
{
1000
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1001
    FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1002 1003 1004 1005 1006
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputTextElement_get_status(IHTMLInputTextElement *iface, VARIANT *p)
{
1007
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1008
    TRACE("(%p)->(%p)\n", This, p);
1009 1010 1011 1012 1013
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLInputTextElement_put_disabled(IHTMLInputTextElement *iface, VARIANT_BOOL v)
{
1014
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1015 1016 1017

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

1018
    return IHTMLInputElement_put_disabled(&This->IHTMLInputElement_iface, v);
1019 1020 1021 1022
}

static HRESULT WINAPI HTMLInputTextElement_get_disabled(IHTMLInputTextElement *iface, VARIANT_BOOL *p)
{
1023
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1024 1025 1026

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

1027
    return IHTMLInputElement_get_disabled(&This->IHTMLInputElement_iface, p);
1028 1029 1030 1031
}

static HRESULT WINAPI HTMLInputTextElement_get_form(IHTMLInputTextElement *iface, IHTMLFormElement **p)
{
1032
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1033 1034 1035

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

1036
    return IHTMLInputElement_get_form(&This->IHTMLInputElement_iface, p);
1037 1038 1039 1040
}

static HRESULT WINAPI HTMLInputTextElement_put_defaultValue(IHTMLInputTextElement *iface, BSTR v)
{
1041
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1042 1043 1044

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

1045
    return IHTMLInputElement_put_defaultValue(&This->IHTMLInputElement_iface, v);
1046 1047 1048 1049
}

static HRESULT WINAPI HTMLInputTextElement_get_defaultValue(IHTMLInputTextElement *iface, BSTR *p)
{
1050
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1051 1052 1053

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

1054
    return IHTMLInputElement_get_defaultValue(&This->IHTMLInputElement_iface, p);
1055 1056
}

1057
static HRESULT WINAPI HTMLInputTextElement_put_size(IHTMLInputTextElement *iface, LONG v)
1058
{
1059
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1060

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

1063
    return IHTMLInputElement_put_size(&This->IHTMLInputElement_iface, v);
1064 1065
}

1066
static HRESULT WINAPI HTMLInputTextElement_get_size(IHTMLInputTextElement *iface, LONG *p)
1067
{
1068
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1069 1070 1071

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

1072
    return IHTMLInputElement_get_size(&This->IHTMLInputElement_iface, p);
1073 1074
}

1075
static HRESULT WINAPI HTMLInputTextElement_put_maxLength(IHTMLInputTextElement *iface, LONG v)
1076
{
1077
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1078

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

1081
    return IHTMLInputElement_put_maxLength(&This->IHTMLInputElement_iface, v);
1082 1083
}

1084
static HRESULT WINAPI HTMLInputTextElement_get_maxLength(IHTMLInputTextElement *iface, LONG *p)
1085
{
1086
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1087 1088 1089

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

1090
    return IHTMLInputElement_get_maxLength(&This->IHTMLInputElement_iface, p);
1091 1092 1093 1094
}

static HRESULT WINAPI HTMLInputTextElement_select(IHTMLInputTextElement *iface)
{
1095
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1096 1097 1098

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

1099
    return IHTMLInputElement_select(&This->IHTMLInputElement_iface);
1100 1101 1102 1103
}

static HRESULT WINAPI HTMLInputTextElement_put_onchange(IHTMLInputTextElement *iface, VARIANT v)
{
1104
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1105 1106 1107

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

1108
    return IHTMLInputElement_put_onchange(&This->IHTMLInputElement_iface, v);
1109 1110 1111 1112
}

static HRESULT WINAPI HTMLInputTextElement_get_onchange(IHTMLInputTextElement *iface, VARIANT *p)
{
1113
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1114 1115 1116

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

1117
    return IHTMLInputElement_get_onchange(&This->IHTMLInputElement_iface, p);
1118 1119 1120 1121
}

static HRESULT WINAPI HTMLInputTextElement_put_onselect(IHTMLInputTextElement *iface, VARIANT v)
{
1122
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1123 1124 1125

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

1126
    return IHTMLInputElement_put_onselect(&This->IHTMLInputElement_iface, v);
1127 1128 1129 1130
}

static HRESULT WINAPI HTMLInputTextElement_get_onselect(IHTMLInputTextElement *iface, VARIANT *p)
{
1131
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1132 1133 1134

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

1135
    return IHTMLInputElement_get_onselect(&This->IHTMLInputElement_iface, p);
1136 1137 1138 1139
}

static HRESULT WINAPI HTMLInputTextElement_put_readOnly(IHTMLInputTextElement *iface, VARIANT_BOOL v)
{
1140
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1141 1142 1143

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

1144
    return IHTMLInputElement_put_readOnly(&This->IHTMLInputElement_iface, v);
1145 1146 1147 1148
}

static HRESULT WINAPI HTMLInputTextElement_get_readOnly(IHTMLInputTextElement *iface, VARIANT_BOOL *p)
{
1149
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1150 1151 1152

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

1153
    return IHTMLInputElement_get_readOnly(&This->IHTMLInputElement_iface, p);
1154 1155 1156 1157
}

static HRESULT WINAPI HTMLInputTextElement_createTextRange(IHTMLInputTextElement *iface, IHTMLTxtRange **range)
{
1158
    HTMLInputElement *This = impl_from_IHTMLInputTextElement(iface);
1159 1160 1161

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

1162
    return IHTMLInputElement_createTextRange(&This->IHTMLInputElement_iface, range);
1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198
}

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
};

1199 1200 1201 1202
static inline HTMLInputElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
{
    return CONTAINING_RECORD(iface, HTMLInputElement, element.node);
}
1203

1204 1205
static HRESULT HTMLInputElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
{
1206
    HTMLInputElement *This = impl_from_HTMLDOMNode(iface);
1207 1208 1209 1210 1211

    *ppv = NULL;

    if(IsEqualGUID(&IID_IUnknown, riid)) {
        TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1212
        *ppv = &This->IHTMLInputElement_iface;
1213 1214
    }else if(IsEqualGUID(&IID_IDispatch, riid)) {
        TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1215
        *ppv = &This->IHTMLInputElement_iface;
1216 1217
    }else if(IsEqualGUID(&IID_IHTMLInputElement, riid)) {
        TRACE("(%p)->(IID_IHTMLInputElement %p)\n", This, ppv);
1218
        *ppv = &This->IHTMLInputElement_iface;
1219 1220
    }else if(IsEqualGUID(&IID_IHTMLInputTextElement, riid)) {
        TRACE("(%p)->(IID_IHTMLInputTextElement %p)\n", This, ppv);
1221
        *ppv = &This->IHTMLInputTextElement_iface;
1222 1223 1224 1225 1226 1227 1228 1229 1230 1231
    }

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

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

1232
static HRESULT HTMLInputElementImpl_fire_event(HTMLDOMNode *iface, eventid_t eid, BOOL *handled)
1233
{
1234
    HTMLInputElement *This = impl_from_HTMLDOMNode(iface);
1235 1236 1237 1238 1239 1240

    if(eid == EVENTID_CLICK) {
        nsresult nsres;

        *handled = TRUE;

1241
        nsres = nsIDOMHTMLElement_Click(This->element.nselem);
1242 1243 1244 1245 1246 1247 1248 1249 1250
        if(NS_FAILED(nsres)) {
            ERR("Click failed: %08x\n", nsres);
            return E_FAIL;
        }
    }

    return S_OK;
}

1251 1252
static HRESULT HTMLInputElementImpl_put_disabled(HTMLDOMNode *iface, VARIANT_BOOL v)
{
1253
    HTMLInputElement *This = impl_from_HTMLDOMNode(iface);
1254
    return IHTMLInputElement_put_disabled(&This->IHTMLInputElement_iface, v);
1255 1256 1257 1258
}

static HRESULT HTMLInputElementImpl_get_disabled(HTMLDOMNode *iface, VARIANT_BOOL *p)
{
1259
    HTMLInputElement *This = impl_from_HTMLDOMNode(iface);
1260
    return IHTMLInputElement_get_disabled(&This->IHTMLInputElement_iface, p);
1261 1262
}

1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288
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;
}

1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308
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);
    }
}

1309
static const NodeImplVtbl HTMLInputElementImplVtbl = {
1310
    HTMLInputElement_QI,
1311
    HTMLElement_destructor,
1312
    HTMLElement_cpc,
1313
    HTMLElement_clone,
1314
    HTMLElement_handle_event,
1315
    HTMLElement_get_attr_col,
1316
    NULL,
1317
    HTMLInputElementImpl_fire_event,
1318 1319
    HTMLInputElementImpl_put_disabled,
    HTMLInputElementImpl_get_disabled,
1320 1321 1322 1323 1324 1325
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    HTMLInputElement_traverse,
1326 1327
    HTMLInputElement_unlink,
    HTMLInputElement_is_text_edit
1328 1329
};

1330
static const tid_t HTMLInputElement_iface_tids[] = {
1331
    HTMLELEMENT_TIDS,
1332 1333 1334
    IHTMLInputElement_tid,
    0
};
1335 1336 1337 1338
static dispex_static_data_t HTMLInputElement_dispex = {
    NULL,
    DispHTMLInputElement_tid,
    NULL,
1339
    HTMLInputElement_iface_tids
1340 1341
};

1342
HRESULT HTMLInputElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
1343
{
1344
    HTMLInputElement *ret;
1345 1346
    nsresult nsres;

1347 1348 1349 1350
    ret = heap_alloc_zero(sizeof(HTMLInputElement));
    if(!ret)
        return E_OUTOFMEMORY;

1351
    ret->IHTMLInputElement_iface.lpVtbl = &HTMLInputElementVtbl;
1352
    ret->IHTMLInputTextElement_iface.lpVtbl = &HTMLInputTextElementVtbl;
1353
    ret->element.node.vtbl = &HTMLInputElementImplVtbl;
1354

1355 1356
    HTMLElement_Init(&ret->element, doc, nselem, &HTMLInputElement_dispex);

1357
    nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLInputElement, (void**)&ret->nsinput);
1358
    assert(nsres == NS_OK);
1359 1360 1361

    *elem = &ret->element;
    return S_OK;
1362
}
1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433

typedef struct {
    HTMLElement element;

    IHTMLLabelElement IHTMLLabelElement_iface;
} HTMLLabelElement;

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);

    return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo);
}

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

    return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
}

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

    return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
            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);

    return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid,
            lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
}

static HRESULT WINAPI HTMLLabelElement_put_htmlFor(IHTMLLabelElement *iface, BSTR v)
{
    HTMLLabelElement *This = impl_from_IHTMLLabelElement(iface);
1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449
    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;
1450 1451 1452 1453 1454
}

static HRESULT WINAPI HTMLLabelElement_get_htmlFor(IHTMLLabelElement *iface, BSTR *p)
{
    HTMLLabelElement *This = impl_from_IHTMLLabelElement(iface);
1455 1456 1457

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

1458
    return elem_string_attr_getter(&This->element, forW, FALSE, p);
1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516
}

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 = {
    HTMLLabelElement_QI,
    HTMLElement_destructor,
1517
    HTMLElement_cpc,
1518 1519 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
    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,
    NULL,
    HTMLLabelElement_iface_tids
};

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;
}
1551 1552 1553 1554 1555

typedef struct {
    HTMLElement element;

    IHTMLButtonElement IHTMLButtonElement_iface;
1556 1557

    nsIDOMHTMLButtonElement *nsbutton;
1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 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
} HTMLButtonElement;

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);

    return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo);
}

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

    return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
}

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

    return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
            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);

    return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid,
            lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
}

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

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

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

static HRESULT WINAPI HTMLButtonElement_put_name(IHTMLButtonElement *iface, BSTR v)
{
    HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface);
1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658
    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;
1659 1660 1661 1662 1663
}

static HRESULT WINAPI HTMLButtonElement_get_name(IHTMLButtonElement *iface, BSTR *p)
{
    HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface);
1664 1665 1666 1667 1668 1669 1670 1671
    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);
1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690
}

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);
1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701
    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;
1702 1703 1704 1705 1706
}

static HRESULT WINAPI HTMLButtonElement_get_disabled(IHTMLButtonElement *iface, VARIANT_BOOL *p)
{
    HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface);
1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719
    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;
    }

    *p = disabled ? VARIANT_TRUE : VARIANT_FALSE;
    return S_OK;
1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781
}

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

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;
}

1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793
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);
}

1794 1795 1796 1797 1798
static BOOL HTMLButtonElement_is_text_edit(HTMLDOMNode *iface)
{
    return TRUE;
}

1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818
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);
    }
}

1819 1820 1821
static const NodeImplVtbl HTMLButtonElementImplVtbl = {
    HTMLButtonElement_QI,
    HTMLElement_destructor,
1822
    HTMLElement_cpc,
1823 1824 1825
    HTMLElement_clone,
    HTMLElement_handle_event,
    HTMLElement_get_attr_col,
1826 1827 1828
    NULL,
    NULL,
    HTMLButtonElementImpl_put_disabled,
1829 1830 1831 1832 1833 1834 1835
    HTMLButtonElementImpl_get_disabled,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    HTMLButtonElement_traverse,
1836 1837
    HTMLButtonElement_unlink,
    HTMLButtonElement_is_text_edit
1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855
};

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

static dispex_static_data_t HTMLButtonElement_dispex = {
    NULL,
    DispHTMLButtonElement_tid,
    NULL,
    HTMLButtonElement_iface_tids
};

HRESULT HTMLButtonElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
{
    HTMLButtonElement *ret;
1856
    nsresult nsres;
1857 1858 1859 1860 1861 1862 1863 1864 1865

    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);
1866 1867

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

1870 1871 1872
    *elem = &ret->element;
    return S_OK;
}