3cf38b45663ee5e89f499af67712bc39c7c5a639
[WebKit-https.git] / Source / WebKitLegacy / win / DOMHTMLClasses.cpp
1 /*
2  * Copyright (C) 2006-2007, 2009, 2015 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24  */
25
26 #include "WebKitDLL.h"
27 #include "DOMHTMLClasses.h"
28 #include "WebFrame.h"
29
30 #include <WebCore/BString.h>
31 #include <WebCore/COMPtr.h>
32 #include <WebCore/Document.h>
33 #include <WebCore/Element.h>
34 #include <WebCore/FrameView.h>
35 #include <WebCore/HTMLCollection.h>
36 #include <WebCore/HTMLDocument.h>
37 #include <WebCore/HTMLFormElement.h>
38 #include <WebCore/HTMLIFrameElement.h>
39 #include <WebCore/HTMLInputElement.h>
40 #include <WebCore/HTMLNames.h>
41 #include <WebCore/HTMLOptionElement.h>
42 #include <WebCore/HTMLOptionsCollection.h>
43 #include <WebCore/HTMLSelectElement.h>
44 #include <WebCore/HTMLTextAreaElement.h>
45 #include <WebCore/IntRect.h>
46 #include <WebCore/RenderObject.h>
47 #include <WebCore/RenderTextControl.h>
48
49 using namespace WebCore;
50 using namespace HTMLNames;
51
52 // DOMHTMLCollection
53
54 DOMHTMLCollection::DOMHTMLCollection(WebCore::HTMLCollection* c)
55 : m_collection(c)
56 {
57 }
58
59 IDOMHTMLCollection* DOMHTMLCollection::createInstance(WebCore::HTMLCollection* c)
60 {
61     if (!c)
62         return 0;
63
64     IDOMHTMLCollection* htmlCollection = 0;
65     DOMHTMLCollection* newCollection = new DOMHTMLCollection(c);
66     if (FAILED(newCollection->QueryInterface(IID_IDOMHTMLCollection, (void**)&htmlCollection))) {
67         delete newCollection;
68         return 0;
69     }
70
71     return htmlCollection;
72 }
73
74 // DOMHTMLCollection - IUnknown -----------------------------------------------
75
76 HRESULT DOMHTMLCollection::QueryInterface(_In_ REFIID riid, _COM_Outptr_  void** ppvObject)
77 {
78     if (!ppvObject)
79         return E_POINTER;
80     *ppvObject = nullptr;
81     if (IsEqualGUID(riid, IID_IDOMHTMLCollection))
82         *ppvObject = static_cast<IDOMHTMLCollection*>(this);
83     else
84         return DOMObject::QueryInterface(riid, ppvObject);
85
86     AddRef();
87     return S_OK;
88 }
89
90 // DOMHTMLCollection ----------------------------------------------------------
91
92 HRESULT DOMHTMLCollection::length(_Out_ UINT* result)
93 {
94     if (!result)
95         return E_POINTER;
96     *result = 0;
97     if (!m_collection)
98         return E_POINTER;
99
100     *result = m_collection->length();
101     return S_OK;
102 }
103
104 HRESULT DOMHTMLCollection::item(UINT index, _COM_Outptr_opt_ IDOMNode** node)
105 {
106     if (!node)
107         return E_POINTER;
108     *node = nullptr;
109     if (!m_collection)
110         return E_POINTER;
111
112     *node = DOMNode::createInstance(m_collection->item(index));
113     return *node ? S_OK : E_FAIL;
114 }
115
116 HRESULT DOMHTMLCollection::namedItem(_In_ BSTR /*name*/, _COM_Outptr_opt_ IDOMNode** node)
117 {
118     ASSERT_NOT_REACHED();
119     if (!node)
120         return E_POINTER;
121     *node = nullptr;
122     return E_NOTIMPL;
123 }
124
125 // DOMHTMLOptionsCollection - IUnknown ----------------------------------------
126
127 HRESULT DOMHTMLOptionsCollection::QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject)
128 {
129     if (!ppvObject)
130         return E_POINTER;
131     *ppvObject = nullptr;
132     if (IsEqualGUID(riid, IID_IDOMHTMLOptionsCollection))
133         *ppvObject = static_cast<IDOMHTMLOptionsCollection*>(this);
134     else
135         return DOMObject::QueryInterface(riid, ppvObject);
136
137     AddRef();
138     return S_OK;
139 }
140
141 // DOMHTMLOptionsCollection ---------------------------------------------------
142
143 DOMHTMLOptionsCollection::DOMHTMLOptionsCollection(WebCore::HTMLOptionsCollection* collection)
144     : m_collection(collection)
145 {
146 }
147
148 IDOMHTMLOptionsCollection* DOMHTMLOptionsCollection::createInstance(WebCore::HTMLOptionsCollection* collection)
149 {
150     if (!collection)
151         return nullptr;
152
153     IDOMHTMLOptionsCollection* optionsCollection = nullptr;
154     DOMHTMLOptionsCollection* newCollection = new DOMHTMLOptionsCollection(collection);
155     if (FAILED(newCollection->QueryInterface(IID_IDOMHTMLOptionsCollection, (void**)&optionsCollection))) {
156         delete newCollection;
157         return nullptr;
158     }
159
160     return optionsCollection;
161 }
162
163 HRESULT DOMHTMLOptionsCollection::length(_Out_ unsigned* result)
164 {
165     if (!result)
166         return E_POINTER;
167
168     *result = m_collection->length();
169     return S_OK;
170 }
171
172 HRESULT DOMHTMLOptionsCollection::setLength(unsigned /*length*/)
173 {
174     ASSERT_NOT_REACHED();
175     return E_NOTIMPL;
176 }
177
178 HRESULT DOMHTMLOptionsCollection::item(unsigned index, _COM_Outptr_opt_ IDOMNode** result)
179 {
180     if (!result)
181         return E_POINTER;
182
183     *result = DOMNode::createInstance(m_collection->item(index));
184
185     return *result ? S_OK : E_FAIL;
186 }
187
188 HRESULT DOMHTMLOptionsCollection::namedItem(_In_ BSTR /*name*/, _COM_Outptr_opt_ IDOMNode** result)
189 {
190     ASSERT_NOT_REACHED();
191     if (!result)
192         return E_POINTER;
193     *result = nullptr;
194     return E_NOTIMPL;
195 }
196
197 // DOMHTMLDocument - IUnknown -------------------------------------------------
198
199 HRESULT DOMHTMLDocument::QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject)
200 {
201     if (!ppvObject)
202         return E_POINTER;
203     *ppvObject = nullptr;
204     if (IsEqualGUID(riid, IID_IDOMHTMLDocument))
205         *ppvObject = static_cast<IDOMHTMLDocument*>(this);
206     else
207         return DOMDocument::QueryInterface(riid, ppvObject);
208
209     AddRef();
210     return S_OK;
211 }
212
213 // DOMHTMLDocument ------------------------------------------------------------
214
215 HRESULT DOMHTMLDocument::title(__deref_opt_out BSTR* result)
216 {
217     if (!result)
218         return E_POINTER;
219
220     *result = nullptr;
221
222     if (!m_document || !m_document->isHTMLDocument())
223         return E_FAIL;
224
225     *result = BString(m_document->title()).release();
226     return S_OK;
227 }
228     
229 HRESULT DOMHTMLDocument::setTitle(_In_ BSTR /*title*/)
230 {
231     ASSERT_NOT_REACHED();
232     return E_NOTIMPL;
233 }
234     
235 HRESULT DOMHTMLDocument::referrer(__deref_opt_out BSTR* result)
236 {
237     ASSERT_NOT_REACHED();
238     if (!result)
239         return E_POINTER;
240
241     *result = nullptr;
242     return E_NOTIMPL;
243 }
244     
245 HRESULT DOMHTMLDocument::domain(__deref_opt_out BSTR* result)
246 {
247     ASSERT_NOT_REACHED();
248     if (!result)
249         return E_POINTER;
250
251     *result = nullptr;
252     return E_NOTIMPL;
253 }
254     
255 HRESULT DOMHTMLDocument::URL(__deref_opt_out BSTR* result)
256 {
257     if (!result)
258         return E_POINTER;
259
260     *result = BString(downcast<HTMLDocument>(*m_document).url()).release();
261     return S_OK;
262 }
263     
264 HRESULT DOMHTMLDocument::body(_COM_Outptr_opt_ IDOMHTMLElement** bodyElement)
265 {
266     if (!bodyElement)
267         return E_POINTER;
268
269     *bodyElement = nullptr;
270     if (!is<HTMLDocument>(m_document))
271         return E_FAIL;
272
273     HTMLDocument& htmlDoc = downcast<HTMLDocument>(*m_document);
274     COMPtr<IDOMElement> domElement;
275     domElement.adoptRef(DOMHTMLElement::createInstance(htmlDoc.bodyOrFrameset()));
276     if (domElement)
277         return domElement->QueryInterface(IID_IDOMHTMLElement, (void**) bodyElement);
278     return E_FAIL;
279 }
280     
281 HRESULT DOMHTMLDocument::setBody(_In_opt_ IDOMHTMLElement* /*body*/)
282 {
283     ASSERT_NOT_REACHED();
284     return E_NOTIMPL;
285 }
286     
287 HRESULT DOMHTMLDocument::images(_COM_Outptr_opt_ IDOMHTMLCollection** collection)
288 {
289     ASSERT_NOT_REACHED();
290     if (!collection)
291         return E_POINTER;
292     *collection = nullptr;
293     return E_NOTIMPL;
294 }
295     
296 HRESULT DOMHTMLDocument::applets(_COM_Outptr_opt_ IDOMHTMLCollection** collection)
297 {
298     ASSERT_NOT_REACHED();
299     if (!collection)
300         return E_POINTER;
301     *collection = nullptr;
302     return E_NOTIMPL;
303 }
304     
305 HRESULT DOMHTMLDocument::links(_COM_Outptr_opt_ IDOMHTMLCollection** collection)
306 {
307     ASSERT_NOT_REACHED();
308     if (!collection)
309         return E_POINTER;
310     *collection = nullptr;
311     return E_NOTIMPL;
312 }
313     
314 HRESULT DOMHTMLDocument::forms(_COM_Outptr_opt_ IDOMHTMLCollection** collection)
315 {
316     if (!collection)
317         return E_POINTER;
318     *collection = nullptr;
319     if (!is<HTMLDocument>(m_document))
320         return E_FAIL;
321
322     HTMLDocument& htmlDoc = downcast<HTMLDocument>(*m_document);
323     RefPtr<HTMLCollection> forms = htmlDoc.forms();
324     *collection = DOMHTMLCollection::createInstance(forms.get());
325     return S_OK;
326 }
327     
328 HRESULT DOMHTMLDocument::anchors(_COM_Outptr_opt_ IDOMHTMLCollection** collection)
329 {
330     ASSERT_NOT_REACHED();
331     if (!collection)
332         return E_POINTER;
333     *collection = nullptr;
334     return E_NOTIMPL;
335 }
336     
337 HRESULT DOMHTMLDocument::cookie(__deref_opt_out BSTR* cookie)
338 {
339     ASSERT_NOT_REACHED();
340     if (!cookie)
341         return E_POINTER;
342     *cookie = nullptr;
343     return E_NOTIMPL;
344 }
345     
346 HRESULT DOMHTMLDocument::setCookie(_In_ BSTR /*cookie*/)
347 {
348     ASSERT_NOT_REACHED();
349     return E_NOTIMPL;
350 }
351     
352 HRESULT DOMHTMLDocument::open()
353 {
354     if (!m_document)
355         return E_FAIL;
356
357     m_document->open();
358     return S_OK;
359 }
360     
361 HRESULT DOMHTMLDocument::close()
362 {
363     if (!m_document)
364         return E_FAIL;
365
366     m_document->close();
367     return S_OK;
368 }
369     
370 HRESULT DOMHTMLDocument::write(_In_ BSTR text)
371 {
372     if (!m_document)
373         return E_FAIL;
374
375     m_document->write(nullptr, { String { text } });
376     return S_OK;
377 }
378     
379 HRESULT DOMHTMLDocument::writeln(_In_ BSTR text)
380 {
381     if (!m_document)
382         return E_FAIL;
383
384     m_document->writeln(nullptr, { String { text } });
385     return S_OK;
386 }
387     
388 HRESULT DOMHTMLDocument::getElementById_(_In_ BSTR /*elementId*/, _COM_Outptr_opt_ IDOMElement** element)
389 {
390     ASSERT_NOT_REACHED();
391     if (!element)
392         return E_POINTER;
393     *element = nullptr;
394     return E_NOTIMPL;
395 }
396     
397 HRESULT DOMHTMLDocument::getElementsByName(_In_ BSTR /*elementName*/, _COM_Outptr_opt_ IDOMNodeList** nodeList)
398 {
399     ASSERT_NOT_REACHED();
400     if (!nodeList)
401         return E_POINTER;
402     *nodeList = nullptr;
403     return E_NOTIMPL;
404 }
405
406 // DOMHTMLElement - IUnknown --------------------------------------------------
407
408 HRESULT DOMHTMLElement::QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject)
409 {
410     if (!ppvObject)
411         return E_POINTER;
412     *ppvObject = nullptr;
413     if (IsEqualGUID(riid, IID_IDOMHTMLElement))
414         *ppvObject = static_cast<IDOMHTMLElement*>(this);
415     else
416         return DOMElement::QueryInterface(riid, ppvObject);
417
418     AddRef();
419     return S_OK;
420 }
421
422 // DOMHTMLElement -------------------------------------------------------------
423
424 HRESULT DOMHTMLElement::idName(__deref_opt_out BSTR* result)
425 {
426     if (!result)
427         return E_POINTER;
428
429     ASSERT(is<HTMLElement>(m_element));
430     String idString = downcast<HTMLElement>(m_element)->attributeWithoutSynchronization(idAttr);
431     *result = BString(idString).release();
432     return S_OK;
433 }
434     
435 HRESULT DOMHTMLElement::setIdName(_In_ BSTR /*idName*/)
436 {
437     ASSERT_NOT_REACHED();
438     return E_NOTIMPL;
439 }
440     
441 HRESULT DOMHTMLElement::title(__deref_opt_out BSTR* result)
442 {
443     ASSERT_NOT_REACHED();
444     if (!result)
445         return E_POINTER;
446     *result = nullptr;
447     return E_NOTIMPL;
448 }
449     
450 HRESULT DOMHTMLElement::setTitle(_In_ BSTR /*title*/)
451 {
452     ASSERT_NOT_REACHED();
453     return E_NOTIMPL;
454 }
455     
456 HRESULT DOMHTMLElement::lang(__deref_opt_out BSTR* result)
457 {
458     ASSERT_NOT_REACHED();
459     if (!result)
460         return E_POINTER;
461     *result = nullptr;
462     return E_NOTIMPL;
463 }
464     
465 HRESULT DOMHTMLElement::setLang(_In_ BSTR /*lang*/)
466 {
467     ASSERT_NOT_REACHED();
468     return E_NOTIMPL;
469 }
470     
471 HRESULT DOMHTMLElement::dir(__deref_opt_out BSTR* result)
472 {
473     ASSERT_NOT_REACHED();
474     if (!result)
475         return E_POINTER;
476     *result = nullptr;
477     return E_NOTIMPL;
478 }
479     
480 HRESULT DOMHTMLElement::setDir(_In_ BSTR /*dir*/)
481 {
482     ASSERT_NOT_REACHED();
483     return E_NOTIMPL;
484 }
485     
486 HRESULT DOMHTMLElement::className(__deref_opt_out BSTR* result)
487 {
488     ASSERT_NOT_REACHED();
489     if (!result)
490         return E_POINTER;
491     *result = nullptr;
492     return E_NOTIMPL;
493 }
494     
495 HRESULT DOMHTMLElement::setClassName(_In_ BSTR /*className*/)
496 {
497     ASSERT_NOT_REACHED();
498     return E_NOTIMPL;
499 }
500
501 HRESULT DOMHTMLElement::innerHTML(__deref_opt_out BSTR* result)
502 {
503     if (!result)
504         return E_POINTER;
505     String innerHtmlString = downcast<HTMLElement>(m_element)->innerHTML();
506     *result = BString(innerHtmlString).release();
507     return S_OK;
508 }
509         
510 HRESULT DOMHTMLElement::setInnerHTML(_In_ BSTR html)
511 {
512     ASSERT(is<HTMLElement>(m_element));
513     HTMLElement* htmlElement = downcast<HTMLElement>(m_element);
514     String htmlString(html, SysStringLen(html));
515     htmlElement->setInnerHTML(htmlString);
516     return S_OK;
517 }
518         
519 HRESULT DOMHTMLElement::innerText(__deref_opt_out BSTR* result)
520 {
521     ASSERT(is<HTMLElement>(m_element));
522     if (!result)
523         return E_POINTER;
524     WTF::String innerTextString = downcast<HTMLElement>(m_element)->innerText();
525     *result = BString(innerTextString).release();
526     return S_OK;
527 }
528         
529 HRESULT DOMHTMLElement::setInnerText(_In_ BSTR text)
530 {
531     ASSERT(is<HTMLElement>(m_element));
532     HTMLElement* htmlElement = downcast<HTMLElement>(m_element);
533     WTF::String textString(text, SysStringLen(text));
534     htmlElement->setInnerText(textString);
535     return S_OK;
536 }
537
538 // DOMHTMLFormElement - IUnknown ----------------------------------------------
539
540 HRESULT DOMHTMLFormElement::QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject)
541 {
542     if (!ppvObject)
543         return E_POINTER;
544     *ppvObject = nullptr;
545     if (IsEqualGUID(riid, IID_IDOMHTMLFormElement))
546         *ppvObject = static_cast<IDOMHTMLFormElement*>(this);
547     else
548         return DOMHTMLElement::QueryInterface(riid, ppvObject);
549
550     AddRef();
551     return S_OK;
552 }
553
554 // DOMHTMLFormElement ---------------------------------------------------------
555
556 HRESULT DOMHTMLFormElement::elements(_COM_Outptr_opt_ IDOMHTMLCollection** result)
557 {
558     ASSERT_NOT_REACHED();
559     if (!result)
560         return E_POINTER;
561     *result = nullptr;
562     return E_NOTIMPL;
563 }
564     
565 HRESULT DOMHTMLFormElement::length(_Out_ int* /*result*/)
566 {
567     ASSERT_NOT_REACHED();
568     return E_NOTIMPL;
569 }
570     
571 HRESULT DOMHTMLFormElement::name(__deref_opt_out BSTR* result)
572 {
573     ASSERT_NOT_REACHED();
574     if (!result)
575         return E_POINTER;
576     *result = nullptr;
577     return E_NOTIMPL;
578 }
579     
580 HRESULT DOMHTMLFormElement::setName(_In_ BSTR /*name*/)
581 {
582     ASSERT_NOT_REACHED();
583     return E_NOTIMPL;
584 }
585     
586 HRESULT DOMHTMLFormElement::acceptCharset(__deref_opt_out BSTR* result)
587 {
588     ASSERT_NOT_REACHED();
589     if (!result)
590         return E_POINTER;
591     *result = nullptr;
592     return E_NOTIMPL;
593 }
594     
595 HRESULT DOMHTMLFormElement::setAcceptCharset(_In_ BSTR /*acceptCharset*/)
596 {
597     ASSERT_NOT_REACHED();
598     return E_NOTIMPL;
599 }
600     
601 HRESULT DOMHTMLFormElement::action(__deref_opt_out BSTR* result)
602 {
603     if (!result)
604         return E_POINTER;
605     ASSERT(is<HTMLFormElement>(m_element));
606     WTF::String actionString = downcast<HTMLFormElement>(*m_element).action();
607     *result = BString(actionString).release();
608     return S_OK;
609 }
610     
611 HRESULT DOMHTMLFormElement::setAction(_In_ BSTR /*action*/)
612 {
613     ASSERT_NOT_REACHED();
614     return E_NOTIMPL;
615 }
616     
617 HRESULT DOMHTMLFormElement::encType(__deref_opt_out BSTR* result)
618 {
619     ASSERT_NOT_REACHED();
620     if (!result)
621         return E_POINTER;
622     *result = nullptr;
623     return E_NOTIMPL;
624 }
625     
626 HRESULT DOMHTMLFormElement::setEnctype(_In_opt_ BSTR* /*encType*/)
627 {
628     ASSERT_NOT_REACHED();
629     return E_NOTIMPL;
630 }
631     
632 HRESULT DOMHTMLFormElement::method(__deref_opt_out BSTR* result)
633 {
634     if (!result)
635         return E_POINTER;
636     ASSERT(is<HTMLFormElement>(m_element));
637     WTF::String methodString = downcast<HTMLFormElement>(*m_element).method();
638     *result = BString(methodString).release();
639     return S_OK;
640 }
641     
642 HRESULT DOMHTMLFormElement::setMethod(_In_ BSTR /*method*/)
643 {
644     ASSERT_NOT_REACHED();
645     return E_NOTIMPL;
646 }
647     
648 HRESULT DOMHTMLFormElement::target(__deref_opt_out BSTR* result)
649 {
650     ASSERT_NOT_REACHED();
651     if (!result)
652         return E_POINTER;
653     *result = nullptr;
654     return E_NOTIMPL;
655 }
656     
657 HRESULT DOMHTMLFormElement::setTarget(_In_ BSTR /*target*/)
658 {
659     ASSERT_NOT_REACHED();
660     return E_NOTIMPL;
661 }
662     
663 HRESULT DOMHTMLFormElement::submit()
664 {
665     ASSERT_NOT_REACHED();
666     return E_NOTIMPL;
667 }
668     
669 HRESULT DOMHTMLFormElement::reset()
670 {
671     ASSERT_NOT_REACHED();
672     return E_NOTIMPL;
673 }
674
675 // DOMHTMLSelectElement - IUnknown ----------------------------------------------
676
677 HRESULT DOMHTMLSelectElement::QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject)
678 {
679     if (!ppvObject)
680         return E_POINTER;
681     *ppvObject = nullptr;
682     if (IsEqualGUID(riid, IID_IDOMHTMLSelectElement))
683         *ppvObject = static_cast<IDOMHTMLSelectElement*>(this);
684     else if (IsEqualGUID(riid, IID_IFormsAutoFillTransitionSelect))
685         *ppvObject = static_cast<IFormsAutoFillTransitionSelect*>(this);
686     else
687         return DOMHTMLElement::QueryInterface(riid, ppvObject);
688
689     AddRef();
690     return S_OK;
691 }
692
693 // DOMHTMLSelectElement -------------------------------------------------------
694
695 HRESULT DOMHTMLSelectElement::type(__deref_opt_out BSTR* result)
696 {
697     ASSERT_NOT_REACHED();
698     if (!result)
699         return E_POINTER;
700     *result = nullptr;
701     return E_NOTIMPL;
702 }
703     
704 HRESULT DOMHTMLSelectElement::selectedIndex(_Out_ int* /*result*/)
705 {
706     ASSERT_NOT_REACHED();
707     return E_NOTIMPL;
708 }
709     
710 HRESULT DOMHTMLSelectElement::setSelectedIndx(int /*selectedIndex*/)
711 {
712     ASSERT_NOT_REACHED();
713     return E_NOTIMPL;
714 }
715     
716 HRESULT DOMHTMLSelectElement::value(__deref_opt_out BSTR* result)
717 {
718     ASSERT_NOT_REACHED();
719     if (!result)
720         return E_POINTER;
721     *result = nullptr;
722     return E_NOTIMPL;
723 }
724     
725 HRESULT DOMHTMLSelectElement::setValue(_In_ BSTR /*value*/)
726 {
727     ASSERT_NOT_REACHED();
728     return E_NOTIMPL;
729 }
730     
731 HRESULT DOMHTMLSelectElement::length(_Out_ int* /*result*/)
732 {
733     ASSERT_NOT_REACHED();
734     return E_NOTIMPL;
735 }
736     
737 HRESULT DOMHTMLSelectElement::form(_COM_Outptr_opt_ IDOMHTMLFormElement** result)
738 {
739     ASSERT_NOT_REACHED();
740     if (!result)
741         return E_POINTER;
742     *result = nullptr;
743     return E_NOTIMPL;
744 }
745     
746 HRESULT DOMHTMLSelectElement::options(_COM_Outptr_opt_ IDOMHTMLOptionsCollection** result)
747 {
748     if (!result)
749         return E_POINTER;
750
751     ASSERT(m_element);
752     HTMLSelectElement& selectElement = downcast<HTMLSelectElement>(*m_element);
753
754     *result = nullptr;
755     RefPtr<HTMLOptionsCollection> options = selectElement.options();
756     *result = DOMHTMLOptionsCollection::createInstance(options.get());
757     return S_OK;
758 }
759     
760 HRESULT DOMHTMLSelectElement::disabled(_Out_ BOOL* /*result*/)
761 {
762     ASSERT_NOT_REACHED();
763     return E_NOTIMPL;
764 }
765     
766 HRESULT DOMHTMLSelectElement::setDisabled(BOOL /*disabled*/)
767 {
768     ASSERT_NOT_REACHED();
769     return E_NOTIMPL;
770 }
771     
772 HRESULT DOMHTMLSelectElement::multiple(_Out_ BOOL* /*result*/)
773 {
774     ASSERT_NOT_REACHED();
775     return E_NOTIMPL;
776 }
777     
778 HRESULT DOMHTMLSelectElement::setMultiple(BOOL /*multiple*/)
779 {
780     ASSERT_NOT_REACHED();
781     return E_NOTIMPL;
782 }
783     
784 HRESULT DOMHTMLSelectElement::name(__deref_opt_out BSTR* result)
785 {
786     ASSERT_NOT_REACHED();
787     if (!result)
788         return E_POINTER;
789     *result = nullptr;
790     return E_NOTIMPL;
791 }
792     
793 HRESULT DOMHTMLSelectElement::setName(_In_ BSTR /*name*/)
794 {
795     ASSERT_NOT_REACHED();
796     return E_NOTIMPL;
797 }
798     
799 HRESULT DOMHTMLSelectElement::size(_Out_ int* /*size*/)
800 {
801     ASSERT_NOT_REACHED();
802     return E_NOTIMPL;
803 }
804     
805 HRESULT DOMHTMLSelectElement::setSize(int /*size*/)
806 {
807     ASSERT_NOT_REACHED();
808     return E_NOTIMPL;
809 }
810     
811 HRESULT DOMHTMLSelectElement::tabIndex(_Out_ int* /*result*/)
812 {
813     ASSERT_NOT_REACHED();
814     return E_NOTIMPL;
815 }
816     
817 HRESULT DOMHTMLSelectElement::setTabIndex(int /*tabIndex*/)
818 {
819     ASSERT_NOT_REACHED();
820     return E_NOTIMPL;
821 }
822     
823 HRESULT DOMHTMLSelectElement::add(_In_opt_ IDOMHTMLElement* /*element*/, _In_opt_ IDOMHTMLElement* /*before*/)
824 {
825     ASSERT_NOT_REACHED();
826     return E_NOTIMPL;
827 }
828     
829 HRESULT DOMHTMLSelectElement::remove(int /*index*/)
830 {
831     ASSERT_NOT_REACHED();
832     return E_NOTIMPL;
833 }
834     
835 // DOMHTMLSelectElement - IFormsAutoFillTransitionSelect ----------------------
836
837 HRESULT DOMHTMLSelectElement::activateItemAtIndex(int index)
838 {
839     ASSERT(m_element);
840     HTMLSelectElement& selectElement = downcast<HTMLSelectElement>(*m_element);
841
842     if (index >= selectElement.length())
843         return E_FAIL;
844
845     selectElement.setSelectedIndex(index);
846     return S_OK;
847 }
848
849 // DOMHTMLOptionElement - IUnknown --------------------------------------------
850
851 HRESULT DOMHTMLOptionElement::QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject)
852 {
853     if (!ppvObject)
854         return E_POINTER;
855     *ppvObject = nullptr;
856     if (IsEqualGUID(riid, IID_IDOMHTMLOptionElement))
857         *ppvObject = static_cast<IDOMHTMLOptionElement*>(this);
858     else
859         return DOMHTMLElement::QueryInterface(riid, ppvObject);
860
861     AddRef();
862     return S_OK;
863 }
864
865 // DOMHTMLOptionElement -------------------------------------------------------
866
867 HRESULT DOMHTMLOptionElement::form(_COM_Outptr_opt_ IDOMHTMLFormElement** result)
868 {
869     ASSERT_NOT_REACHED();
870     if (!result)
871         return E_POINTER;
872     *result = nullptr;
873     return E_NOTIMPL;
874 }
875     
876 HRESULT DOMHTMLOptionElement::defaultSelected(_Out_ BOOL* /*result*/)
877 {
878     ASSERT_NOT_REACHED();
879     return E_NOTIMPL;
880 }
881     
882 HRESULT DOMHTMLOptionElement::setDefaultSelected(BOOL /*defaultSelected*/)
883 {
884     ASSERT_NOT_REACHED();
885     return E_NOTIMPL;
886 }
887     
888 HRESULT DOMHTMLOptionElement::text(__deref_opt_out BSTR* result)
889 {
890     if (!result)
891         return E_POINTER;
892
893     *result = nullptr;
894
895     ASSERT(is<HTMLOptionElement>(m_element));
896     HTMLOptionElement& optionElement = downcast<HTMLOptionElement>(*m_element);
897
898     *result = BString(optionElement.text()).release();
899     return S_OK;
900 }
901     
902 HRESULT DOMHTMLOptionElement::index(_Out_ int* /*result*/)
903 {
904     ASSERT_NOT_REACHED();
905     return E_NOTIMPL;
906 }
907     
908 HRESULT DOMHTMLOptionElement::disabled(_Out_ BOOL* /*result*/)
909 {
910     ASSERT_NOT_REACHED();
911     return E_NOTIMPL;
912 }
913     
914 HRESULT DOMHTMLOptionElement::setDisabled(BOOL /*disabled*/)
915 {
916     ASSERT_NOT_REACHED();
917     return E_NOTIMPL;
918 }
919     
920 HRESULT DOMHTMLOptionElement::label(__deref_opt_out BSTR* result)
921 {
922     if (!result)
923         return E_POINTER;
924
925     *result = nullptr;
926
927     ASSERT(is<HTMLOptionElement>(m_element));
928     HTMLOptionElement& optionElement = downcast<HTMLOptionElement>(*m_element);
929
930     *result = BString(optionElement.label()).release();
931     return S_OK;
932 }
933     
934 HRESULT DOMHTMLOptionElement::setLabel(_In_ BSTR /*label*/)
935 {
936     ASSERT_NOT_REACHED();
937     return E_NOTIMPL;
938 }
939     
940 HRESULT DOMHTMLOptionElement::selected(_Out_ BOOL* /*result*/)
941 {
942     ASSERT_NOT_REACHED();
943     return E_NOTIMPL;
944 }
945     
946 HRESULT DOMHTMLOptionElement::setSelected(BOOL /*selected*/)
947 {
948     ASSERT_NOT_REACHED();
949     return E_NOTIMPL;
950 }
951     
952 HRESULT DOMHTMLOptionElement::value(__deref_opt_out BSTR* /*result*/)
953 {
954     ASSERT_NOT_REACHED();
955     return E_NOTIMPL;
956 }
957     
958 HRESULT DOMHTMLOptionElement::setValue(_In_ BSTR /*value*/)
959 {
960     ASSERT_NOT_REACHED();
961     return E_NOTIMPL;
962 }
963
964 // DOMHTMLInputElement - IUnknown ----------------------------------------------
965
966 HRESULT DOMHTMLInputElement::QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject)
967 {
968     if (!ppvObject)
969         return E_POINTER;
970     *ppvObject = nullptr;
971     if (IsEqualGUID(riid, IID_IDOMHTMLInputElement))
972         *ppvObject = static_cast<IDOMHTMLInputElement*>(this);
973     else if (IsEqualGUID(riid, IID_IFormsAutoFillTransition))
974         *ppvObject = static_cast<IFormsAutoFillTransition*>(this);
975     else if (IsEqualGUID(riid, IID_IFormPromptAdditions))
976         *ppvObject = static_cast<IFormPromptAdditions*>(this);    
977     else
978         return DOMHTMLElement::QueryInterface(riid, ppvObject);
979
980     AddRef();
981     return S_OK;
982 }
983
984 // DOMHTMLInputElement --------------------------------------------------------
985
986 HRESULT DOMHTMLInputElement::defaultValue(__deref_opt_out BSTR* /*result*/)
987 {
988     ASSERT_NOT_REACHED();
989     return E_NOTIMPL;
990 }
991     
992 HRESULT DOMHTMLInputElement::setDefaultValue(_In_ BSTR /*val*/)
993 {
994     ASSERT_NOT_REACHED();
995     return E_NOTIMPL;
996 }
997     
998 HRESULT DOMHTMLInputElement::defaultChecked(_Out_ BOOL* /*result*/)
999 {
1000     ASSERT_NOT_REACHED();
1001     return E_NOTIMPL;
1002 }
1003     
1004 HRESULT DOMHTMLInputElement::setDefaultChecked(_In_ BSTR /*checked*/)
1005 {
1006     ASSERT_NOT_REACHED();
1007     return E_NOTIMPL;
1008 }
1009     
1010 HRESULT DOMHTMLInputElement::form(_COM_Outptr_opt_ IDOMHTMLElement** result)
1011 {
1012     if (!result)
1013         return E_POINTER;
1014     *result = nullptr;
1015     ASSERT(is<HTMLInputElement>(m_element));
1016     HTMLInputElement& inputElement = downcast<HTMLInputElement>(*m_element);
1017     COMPtr<IDOMElement> domElement;
1018     domElement.adoptRef(DOMHTMLElement::createInstance(inputElement.form()));
1019     if (domElement)
1020         return domElement->QueryInterface(IID_IDOMHTMLElement, (void**) result);
1021     return E_FAIL;
1022 }
1023     
1024 HRESULT DOMHTMLInputElement::accept(__deref_opt_out BSTR* /*result*/)
1025 {
1026     ASSERT_NOT_REACHED();
1027     return E_NOTIMPL;
1028 }
1029     
1030 HRESULT DOMHTMLInputElement::setAccept(_In_ BSTR /*accept*/)
1031 {
1032     ASSERT_NOT_REACHED();
1033     return E_NOTIMPL;
1034 }
1035     
1036 HRESULT DOMHTMLInputElement::accessKey(__deref_opt_out BSTR* /*result*/)
1037 {
1038     ASSERT_NOT_REACHED();
1039     return E_NOTIMPL;
1040 }
1041     
1042 HRESULT DOMHTMLInputElement::setAccessKey(_In_ BSTR /*key*/)
1043 {
1044     ASSERT_NOT_REACHED();
1045     return E_NOTIMPL;
1046 }
1047     
1048 HRESULT DOMHTMLInputElement::align(__deref_opt_out BSTR* /*result*/)
1049 {
1050     ASSERT_NOT_REACHED();
1051     return E_NOTIMPL;
1052 }
1053     
1054 HRESULT DOMHTMLInputElement::setAlign(_In_ BSTR /*align*/)
1055 {
1056     ASSERT_NOT_REACHED();
1057     return E_NOTIMPL;
1058 }
1059     
1060 HRESULT DOMHTMLInputElement::alt(__deref_opt_out BSTR* /*result*/)
1061 {
1062     ASSERT_NOT_REACHED();
1063     return E_NOTIMPL;
1064 }
1065     
1066 HRESULT DOMHTMLInputElement::setAlt(_In_ BSTR /*alt*/)
1067 {
1068     ASSERT_NOT_REACHED();
1069     return E_NOTIMPL;
1070 }
1071     
1072 HRESULT DOMHTMLInputElement::checked(_Out_ BOOL* /*result*/)
1073 {
1074     ASSERT_NOT_REACHED();
1075     return E_NOTIMPL;
1076 }
1077     
1078 HRESULT DOMHTMLInputElement::setChecked(BOOL /*checked*/)
1079 {
1080     ASSERT_NOT_REACHED();
1081     return E_NOTIMPL;
1082 }
1083     
1084 HRESULT DOMHTMLInputElement::disabled(_Out_ BOOL* result)
1085 {
1086     if (!result)
1087         return E_POINTER;
1088
1089     ASSERT(is<HTMLInputElement>(m_element));
1090     HTMLInputElement& inputElement = downcast<HTMLInputElement>(*m_element);
1091     *result = inputElement.isDisabledFormControl() ? TRUE : FALSE;
1092     return S_OK;
1093 }
1094     
1095 HRESULT DOMHTMLInputElement::setDisabled(BOOL /*disabled*/)
1096 {
1097     ASSERT_NOT_REACHED();
1098     return E_NOTIMPL;
1099 }
1100     
1101 HRESULT DOMHTMLInputElement::maxLength(_Out_ int* /*result*/)
1102 {
1103     ASSERT_NOT_REACHED();
1104     return E_NOTIMPL;
1105 }
1106     
1107 HRESULT DOMHTMLInputElement::setMaxLength(int /*maxLength*/)
1108 {
1109     ASSERT_NOT_REACHED();
1110     return E_NOTIMPL;
1111 }
1112     
1113 HRESULT DOMHTMLInputElement::name(__deref_opt_out BSTR* /*name*/)
1114 {
1115     ASSERT_NOT_REACHED();
1116     return E_NOTIMPL;
1117 }
1118     
1119 HRESULT DOMHTMLInputElement::setName(_In_ BSTR /*name*/)
1120 {
1121     ASSERT_NOT_REACHED();
1122     return E_NOTIMPL;
1123 }
1124     
1125 HRESULT DOMHTMLInputElement::readOnly(_Out_ BOOL* result)
1126 {
1127     if (!result)
1128         return E_POINTER;
1129
1130     ASSERT(is<HTMLInputElement>(m_element));
1131     HTMLInputElement& inputElement = downcast<HTMLInputElement>(*m_element);
1132     *result = inputElement.isReadOnly() ? TRUE : FALSE;
1133     return S_OK;
1134 }
1135     
1136 HRESULT DOMHTMLInputElement::setReadOnly(BOOL /*readOnly*/)
1137 {
1138     ASSERT_NOT_REACHED();
1139     return E_NOTIMPL;
1140 }
1141     
1142 HRESULT DOMHTMLInputElement::size(_Out_ unsigned* /*result*/)
1143 {
1144     ASSERT_NOT_REACHED();
1145     return E_NOTIMPL;
1146 }
1147     
1148 HRESULT DOMHTMLInputElement::setSize(unsigned /*size*/)
1149 {
1150     ASSERT_NOT_REACHED();
1151     return E_NOTIMPL;
1152 }
1153     
1154 HRESULT DOMHTMLInputElement::src(__deref_opt_out BSTR* /*result*/)
1155 {
1156     ASSERT_NOT_REACHED();
1157     return E_NOTIMPL;
1158 }
1159     
1160 HRESULT DOMHTMLInputElement::setSrc(_In_ BSTR /*src*/)
1161 {
1162     ASSERT_NOT_REACHED();
1163     return E_NOTIMPL;
1164 }
1165     
1166 HRESULT DOMHTMLInputElement::tabIndex(_Out_ int* /*result*/)
1167 {
1168     ASSERT_NOT_REACHED();
1169     return E_NOTIMPL;
1170 }
1171     
1172 HRESULT DOMHTMLInputElement::setTabIndex(int /*tabIndex*/)
1173 {
1174     ASSERT_NOT_REACHED();
1175     return E_NOTIMPL;
1176 }
1177     
1178 HRESULT DOMHTMLInputElement::type(__deref_opt_out BSTR* /*result*/)
1179 {
1180     ASSERT_NOT_REACHED();
1181     return E_NOTIMPL;
1182 }
1183     
1184 HRESULT DOMHTMLInputElement::setType(_In_ BSTR type)
1185 {
1186     ASSERT(is<HTMLInputElement>(m_element));
1187     HTMLInputElement& inputElement = downcast<HTMLInputElement>(*m_element);
1188     WTF::String typeString(type, SysStringLen(type));
1189     inputElement.setType(typeString);
1190     return S_OK;
1191 }
1192     
1193 HRESULT DOMHTMLInputElement::useMap(__deref_opt_out BSTR* /*result*/)
1194 {
1195     ASSERT_NOT_REACHED();
1196     return E_NOTIMPL;
1197 }
1198     
1199 HRESULT DOMHTMLInputElement::setUseMap(_In_ BSTR /*useMap*/)
1200 {
1201     ASSERT_NOT_REACHED();
1202     return E_NOTIMPL;
1203 }
1204     
1205 HRESULT DOMHTMLInputElement::value(__deref_opt_out BSTR* result)
1206 {
1207     if (!result)
1208         return E_POINTER;
1209
1210     ASSERT(is<HTMLInputElement>(m_element));
1211     HTMLInputElement& inputElement = downcast<HTMLInputElement>(*m_element);
1212     WTF::String valueString = inputElement.value();
1213     *result = BString(valueString).release();
1214     if (valueString.length() && !*result)
1215         return E_OUTOFMEMORY;
1216     return S_OK;
1217 }
1218     
1219 HRESULT DOMHTMLInputElement::setValue(_In_ BSTR value)
1220 {
1221     ASSERT(is<HTMLInputElement>(m_element));
1222     HTMLInputElement& inputElement = downcast<HTMLInputElement>(*m_element);
1223     inputElement.setValue(String((UChar*) value, SysStringLen(value)));
1224     return S_OK;
1225 }
1226
1227 HRESULT DOMHTMLInputElement::setValueForUser(_In_ BSTR value)
1228 {
1229     ASSERT(is<HTMLInputElement>(m_element));
1230     HTMLInputElement& inputElement = downcast<HTMLInputElement>(*m_element);
1231     inputElement.setValueForUser(String(static_cast<UChar*>(value), SysStringLen(value)));
1232     return S_OK;
1233 }
1234
1235 HRESULT DOMHTMLInputElement::select()
1236 {
1237     ASSERT(is<HTMLInputElement>(m_element));
1238     HTMLInputElement& inputElement = downcast<HTMLInputElement>(*m_element);
1239     inputElement.select();
1240     return S_OK;
1241 }
1242     
1243 HRESULT DOMHTMLInputElement::click()
1244 {
1245     ASSERT_NOT_REACHED();
1246     return E_NOTIMPL;
1247 }
1248
1249 HRESULT DOMHTMLInputElement::setSelectionStart(long start)
1250 {
1251     ASSERT(is<HTMLInputElement>(m_element));
1252     HTMLInputElement& inputElement = downcast<HTMLInputElement>(*m_element);
1253     inputElement.setSelectionStart(start);
1254     return S_OK;
1255 }
1256
1257 HRESULT DOMHTMLInputElement::selectionStart(_Out_ long *start)
1258 {
1259     if (!start)
1260         return E_POINTER;
1261
1262     ASSERT(is<HTMLInputElement>(m_element));
1263     HTMLInputElement& inputElement = downcast<HTMLInputElement>(*m_element);
1264     *start = inputElement.selectionStart();
1265     return S_OK;
1266 }
1267
1268 HRESULT DOMHTMLInputElement::setSelectionEnd(long end)
1269 {
1270     ASSERT(is<HTMLInputElement>(m_element));
1271     HTMLInputElement& inputElement = downcast<HTMLInputElement>(*m_element);
1272     inputElement.setSelectionEnd(end);
1273     return S_OK;
1274 }
1275
1276 HRESULT DOMHTMLInputElement::selectionEnd(_Out_ long *end)
1277 {
1278     if (!end)
1279         return E_POINTER;
1280
1281     ASSERT(is<HTMLInputElement>(m_element));
1282     HTMLInputElement& inputElement = downcast<HTMLInputElement>(*m_element);
1283     *end = inputElement.selectionEnd();
1284     return S_OK;
1285 }
1286
1287 // DOMHTMLInputElement -- IFormsAutoFillTransition ----------------------------
1288
1289 HRESULT DOMHTMLInputElement::isTextField(_Out_ BOOL* result)
1290 {
1291     if (!result)
1292         return E_POINTER;
1293
1294     ASSERT(is<HTMLInputElement>(m_element));
1295     HTMLInputElement& inputElement = downcast<HTMLInputElement>(*m_element);
1296     *result = inputElement.isTextField() ? TRUE : FALSE;
1297     return S_OK;
1298 }
1299
1300 HRESULT DOMHTMLInputElement::rectOnScreen(_Out_ LPRECT rect)
1301 {
1302     if (!rect)
1303         return E_POINTER;
1304     ASSERT(is<HTMLInputElement>(m_element));
1305     rect->left = rect->top = rect->right = rect->bottom = 0;
1306     RenderObject* renderer = m_element->renderer();
1307     FrameView* view = m_element->document().view();
1308     if (!renderer || !view)
1309         return E_FAIL;
1310
1311     IntRect coreRect = view->contentsToScreen(renderer->absoluteBoundingBoxRect());
1312     rect->left = coreRect.x();
1313     rect->top = coreRect.y();
1314     rect->right = coreRect.maxX();
1315     rect->bottom = coreRect.maxY();
1316
1317     return S_OK;
1318 }
1319
1320 HRESULT DOMHTMLInputElement::replaceCharactersInRange(int startTarget, int endTarget, _In_ BSTR replacementString, int index)
1321 {
1322     if (!replacementString)
1323         return E_POINTER;
1324
1325     ASSERT(is<HTMLInputElement>(m_element));
1326     HTMLInputElement& inputElement = downcast<HTMLInputElement>(*m_element);
1327
1328     String newValue = inputElement.value();
1329     String webCoreReplacementString(static_cast<UChar*>(replacementString), SysStringLen(replacementString));
1330     newValue.replace(startTarget, endTarget - startTarget, webCoreReplacementString);
1331     inputElement.setValue(newValue);
1332     inputElement.setSelectionRange(index, newValue.length());
1333
1334     return S_OK;
1335 }
1336
1337 HRESULT DOMHTMLInputElement::selectedRange(_Out_ int* start, _Out_ int* end)
1338 {
1339     if (!start || !end)
1340         return E_POINTER;
1341
1342     ASSERT(is<HTMLInputElement>(m_element));
1343     HTMLInputElement& inputElement = downcast<HTMLInputElement>(*m_element);
1344     *start = inputElement.selectionStart();
1345     *end = inputElement.selectionEnd();
1346     return S_OK;
1347 }
1348
1349 HRESULT DOMHTMLInputElement::setAutofilled(BOOL filled)
1350 {
1351     ASSERT(is<HTMLInputElement>(m_element));
1352     HTMLInputElement& inputElement = downcast<HTMLInputElement>(*m_element);
1353     inputElement.setAutoFilled(!!filled);
1354     return S_OK;
1355 }
1356
1357 HRESULT DOMHTMLInputElement::isAutofilled(_Out_ BOOL* result)
1358 {
1359     if (!result)
1360         return E_POINTER;
1361
1362     ASSERT(is<HTMLInputElement>(m_element));
1363     HTMLInputElement& inputElement = downcast<HTMLInputElement>(*m_element);
1364     *result = inputElement.isAutoFilled() ? TRUE : FALSE;
1365     return S_OK;
1366 }
1367
1368 // DOMHTMLInputElement -- IFormPromptAdditions ------------------------------------
1369
1370 HRESULT DOMHTMLInputElement::isUserEdited(_Out_ BOOL *result)
1371 {
1372     if (!result)
1373         return E_POINTER;
1374
1375     *result = FALSE;
1376     ASSERT(is<HTMLInputElement>(m_element));
1377     BOOL textField = FALSE;
1378     if (FAILED(isTextField(&textField)) || !textField)
1379         return S_OK;
1380     if (downcast<HTMLInputElement>(*m_element).lastChangeWasUserEdit())
1381         *result = TRUE;
1382     return S_OK;
1383 }
1384
1385 // DOMHTMLTextAreaElement - IUnknown ----------------------------------------------
1386
1387 HRESULT DOMHTMLTextAreaElement::QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject)
1388 {
1389     if (!ppvObject)
1390         return E_POINTER;
1391     *ppvObject = nullptr;
1392     if (IsEqualGUID(riid, IID_IDOMHTMLTextAreaElement))
1393         *ppvObject = static_cast<IDOMHTMLTextAreaElement*>(this);
1394     else if (IsEqualGUID(riid, IID_IFormPromptAdditions))
1395         *ppvObject = static_cast<IFormPromptAdditions*>(this);    
1396     else
1397         return DOMHTMLElement::QueryInterface(riid, ppvObject);
1398
1399     AddRef();
1400     return S_OK;
1401 }
1402
1403 // DOMHTMLTextAreaElement -----------------------------------------------------
1404
1405 HRESULT DOMHTMLTextAreaElement::defaultValue(__deref_opt_out BSTR* /*result*/)
1406 {
1407     ASSERT_NOT_REACHED();
1408     return E_NOTIMPL;
1409 }
1410     
1411 HRESULT DOMHTMLTextAreaElement::setDefaultValue(_In_ BSTR /*val*/)
1412 {
1413     ASSERT_NOT_REACHED();
1414     return E_NOTIMPL;
1415 }
1416     
1417 HRESULT DOMHTMLTextAreaElement::form(_COM_Outptr_opt_ IDOMHTMLElement** result)
1418 {
1419     if (!result)
1420         return E_POINTER;
1421     *result = nullptr;
1422     ASSERT(is<HTMLTextAreaElement>(m_element));
1423     HTMLTextAreaElement& textareaElement = downcast<HTMLTextAreaElement>(*m_element);
1424     COMPtr<IDOMElement> domElement;
1425     domElement.adoptRef(DOMHTMLElement::createInstance(textareaElement.form()));
1426     if (domElement)
1427         return domElement->QueryInterface(IID_IDOMHTMLElement, (void**) result);
1428     return E_FAIL;
1429 }
1430     
1431 HRESULT DOMHTMLTextAreaElement::accessKey(__deref_opt_out BSTR* /*result*/)
1432 {
1433     ASSERT_NOT_REACHED();
1434     return E_NOTIMPL;
1435 }
1436     
1437 HRESULT DOMHTMLTextAreaElement::setAccessKey(_In_ BSTR /*key*/)
1438 {
1439     ASSERT_NOT_REACHED();
1440     return E_NOTIMPL;
1441 }
1442     
1443 HRESULT DOMHTMLTextAreaElement::cols(_Out_ int* /*result*/)
1444 {
1445     ASSERT_NOT_REACHED();
1446     return E_NOTIMPL;
1447 }
1448     
1449 HRESULT DOMHTMLTextAreaElement::setCols(int /*cols*/)
1450 {
1451     ASSERT_NOT_REACHED();
1452     return E_NOTIMPL;
1453 }
1454     
1455 HRESULT DOMHTMLTextAreaElement::disabled(_Out_ BOOL* /*result*/)
1456 {
1457     ASSERT_NOT_REACHED();
1458     return E_NOTIMPL;
1459 }
1460     
1461 HRESULT DOMHTMLTextAreaElement::setDisabled(BOOL /*disabled*/)
1462 {
1463     ASSERT_NOT_REACHED();
1464     return E_NOTIMPL;
1465 }
1466     
1467 HRESULT DOMHTMLTextAreaElement::name(__deref_opt_out BSTR* /*name*/)
1468 {
1469     ASSERT_NOT_REACHED();
1470     return E_NOTIMPL;
1471 }
1472     
1473 HRESULT DOMHTMLTextAreaElement::setName(_In_ BSTR /*name*/)
1474 {
1475     ASSERT_NOT_REACHED();
1476     return E_NOTIMPL;
1477 }
1478     
1479 HRESULT DOMHTMLTextAreaElement::readOnly(_Out_ BOOL* /*result*/)
1480 {
1481     ASSERT_NOT_REACHED();
1482     return E_NOTIMPL;
1483 }
1484     
1485 HRESULT DOMHTMLTextAreaElement::setReadOnly(BOOL /*readOnly*/)
1486 {
1487     ASSERT_NOT_REACHED();
1488     return E_NOTIMPL;
1489 }
1490     
1491 HRESULT DOMHTMLTextAreaElement::rows(_Out_ int* /*result*/)
1492 {
1493     ASSERT_NOT_REACHED();
1494     return E_NOTIMPL;
1495 }
1496     
1497 HRESULT DOMHTMLTextAreaElement::setRows(int /*rows*/)
1498 {
1499     ASSERT_NOT_REACHED();
1500     return E_NOTIMPL;
1501 }
1502     
1503 HRESULT DOMHTMLTextAreaElement::tabIndex(_Out_ int* /*result*/)
1504 {
1505     ASSERT_NOT_REACHED();
1506     return E_NOTIMPL;
1507 }
1508     
1509 HRESULT DOMHTMLTextAreaElement::setTabIndex(int /*tabIndex*/)
1510 {
1511     ASSERT_NOT_REACHED();
1512     return E_NOTIMPL;
1513 }
1514     
1515 HRESULT DOMHTMLTextAreaElement::type(__deref_opt_out BSTR* /*result*/)
1516 {
1517     ASSERT_NOT_REACHED();
1518     return E_NOTIMPL;
1519 }
1520     
1521 HRESULT DOMHTMLTextAreaElement::value(__deref_opt_out BSTR* result)
1522 {
1523     if (!result)
1524         return E_POINTER;
1525
1526     ASSERT(is<HTMLTextAreaElement>(m_element));
1527     HTMLTextAreaElement& textareaElement = downcast<HTMLTextAreaElement>(*m_element);
1528     WTF::String valueString = textareaElement.value();
1529     *result = BString(valueString).release();
1530     if (valueString.length() && !*result)
1531         return E_OUTOFMEMORY;
1532     return S_OK;
1533 }
1534     
1535 HRESULT DOMHTMLTextAreaElement::setValue(_In_ BSTR value)
1536 {
1537     ASSERT(is<HTMLTextAreaElement>(m_element));
1538     HTMLTextAreaElement& textareaElement = downcast<HTMLTextAreaElement>(*m_element);
1539     textareaElement.setValue(String((UChar*) value, SysStringLen(value)));
1540     return S_OK;
1541 }
1542     
1543 HRESULT DOMHTMLTextAreaElement::select()
1544 {
1545     ASSERT(is<HTMLTextAreaElement>(m_element));
1546     HTMLTextAreaElement& textareaElement = downcast<HTMLTextAreaElement>(*m_element);
1547     textareaElement.select();
1548     return S_OK;
1549 }
1550
1551 // DOMHTMLTextAreaElement -- IFormPromptAdditions ------------------------------------
1552
1553 HRESULT DOMHTMLTextAreaElement::isUserEdited(_Out_ BOOL *result)
1554 {
1555     if (!result)
1556         return E_POINTER;
1557
1558     *result = FALSE;
1559     ASSERT(is<HTMLTextAreaElement>(m_element));
1560     if (downcast<HTMLTextAreaElement>(*m_element).lastChangeWasUserEdit())
1561         *result = TRUE;
1562     return S_OK;
1563 }
1564
1565 // DOMHTMLIFrameElement - IUnknown --------------------------------------------------
1566
1567 HRESULT DOMHTMLIFrameElement::QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject)
1568 {
1569     if (!ppvObject)
1570         return E_POINTER;
1571     *ppvObject = nullptr;
1572     if (IsEqualGUID(riid, IID_IDOMHTMLIFrameElement))
1573         *ppvObject = static_cast<IDOMHTMLIFrameElement*>(this);
1574     else
1575         return DOMHTMLElement::QueryInterface(riid, ppvObject);
1576
1577     AddRef();
1578     return S_OK;
1579 }
1580
1581 // DOMHTMLIFrameElement -------------------------------------------------------------
1582
1583 HRESULT DOMHTMLIFrameElement::contentFrame(_COM_Outptr_opt_ IWebFrame** result)
1584 {
1585     if (!result)
1586         return E_POINTER;
1587     *result = nullptr;
1588     ASSERT(m_element);
1589     HTMLIFrameElement& iFrameElement = downcast<HTMLIFrameElement>(*m_element);
1590     COMPtr<IWebFrame> webFrame = kit(iFrameElement.contentFrame());
1591     if (!webFrame)
1592         return E_FAIL;
1593     return webFrame.copyRefTo(result);
1594 }