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