2007-07-25 Ada Chan <adachan@apple.com>
authoradachan <adachan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Jul 2007 20:54:03 +0000 (20:54 +0000)
committeradachan <adachan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Jul 2007 20:54:03 +0000 (20:54 +0000)
        Reviewed by Adam and Steve.

        Implemented some DOM methods and other fixes for <rdar://problem/5311601>.

        * DOMCoreClasses.cpp:
        (DOMNode::ownerDocument): implemented
        (DOMDocument::getComputedStyle): get the DOMElement via QueryInterface
        (DOMElement::QueryInterface):
        * DOMHTMLClasses.cpp:
        (DOMHTMLDocument::body): fixed leak
        (DOMHTMLFormElement::action): implemented
        (DOMHTMLFormElement::method): ditto
        (DOMHTMLInputElement::form): ditto
        (DOMHTMLTextAreaElement::form): ditto
        * Interfaces/DOMHTML.idl: IDOMHTMLInputElement should inherit from IDOMHTMLElement

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@24630 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/win/ChangeLog
WebKit/win/DOMCoreClasses.cpp
WebKit/win/DOMHTMLClasses.cpp
WebKit/win/Interfaces/DOMHTML.idl

index be69f91b7824ec64b2d085388ec37f8fa0d4a5f6..99d2c212d67eafad1ceacb5cc559f40399b6e21d 100644 (file)
@@ -1,3 +1,21 @@
+2007-07-25  Ada Chan  <adachan@apple.com>
+
+        Reviewed by Adam and Steve.
+        
+        Implemented some DOM methods and other fixes for <rdar://problem/5311601>.
+        
+        * DOMCoreClasses.cpp:
+        (DOMNode::ownerDocument): implemented
+        (DOMDocument::getComputedStyle): get the DOMElement via QueryInterface
+        (DOMElement::QueryInterface):
+        * DOMHTMLClasses.cpp:
+        (DOMHTMLDocument::body): fixed leak
+        (DOMHTMLFormElement::action): implemented
+        (DOMHTMLFormElement::method): ditto
+        (DOMHTMLInputElement::form): ditto
+        (DOMHTMLTextAreaElement::form): ditto
+        * Interfaces/DOMHTML.idl: IDOMHTMLInputElement should inherit from IDOMHTMLElement
+
 2007-07-24  Steve Falkenburg  <sfalken@apple.com>
 
         Removed touch of WebKit.rc to prevent rebuilds of the rc file.
index 1815171c2b24fcc5c5b8e6daf8dd37ab32f600f0..67030fa4ef1a7fab5f94e66507ac3f70abd4f433 100644 (file)
@@ -49,6 +49,8 @@
 #include <initguid.h>
 // {79A193A5-D783-4c73-9AD9-D10678B943DE}
 DEFINE_GUID(IID_DOMNode, 0x79a193a5, 0xd783, 0x4c73, 0x9a, 0xd9, 0xd1, 0x6, 0x78, 0xb9, 0x43, 0xde);
+// {3B0C0EFF-478B-4b0b-8290-D2321E08E23E}
+DEFINE_GUID(IID_DOMElement, 0x3b0c0eff, 0x478b, 0x4b0b, 0x82, 0x90, 0xd2, 0x32, 0x1e, 0x8, 0xe2, 0x3e);
 
 using namespace WebCore;
 using namespace HTMLNames;
@@ -171,10 +173,15 @@ HRESULT STDMETHODCALLTYPE DOMNode::attributes(
 }
 
 HRESULT STDMETHODCALLTYPE DOMNode::ownerDocument( 
-    /* [retval][out] */ IDOMDocument** /*result*/)
+    /* [retval][out] */ IDOMDocument** result)
 {
-    ASSERT_NOT_REACHED();
-    return E_NOTIMPL;
+    if (!result)
+        return E_POINTER;
+    *result = 0;
+    if (!m_node)
+        return E_FAIL;
+    *result = DOMDocument::createInstance(m_node->ownerDocument());
+    return S_OK;
 }
 
 HRESULT STDMETHODCALLTYPE DOMNode::insertBefore( 
@@ -688,7 +695,10 @@ HRESULT STDMETHODCALLTYPE DOMDocument::getComputedStyle(
     if (!elt || !result)
         return E_POINTER;
 
-    DOMElement* domEle = static_cast<DOMElement*>(elt);
+    COMPtr<DOMElement> domEle;
+    HRESULT hr = elt->QueryInterface(IID_DOMElement, (void**)&domEle);
+    if (FAILED(hr))
+        return hr;
     Element* element = domEle->element();
 
     WebCore::DOMWindow* dv = m_document->defaultView();
@@ -754,6 +764,8 @@ HRESULT STDMETHODCALLTYPE DOMElement::QueryInterface(REFIID riid, void** ppvObje
     *ppvObject = 0;
     if (IsEqualGUID(riid, IID_IDOMElement))
         *ppvObject = static_cast<IDOMElement*>(this);
+    else if (IsEqualGUID(riid, IID_DOMElement))
+        *ppvObject = static_cast<DOMElement*>(this);
     else if (IsEqualGUID(riid, IID_IDOMElementPrivate))
         *ppvObject = static_cast<IDOMElementPrivate*>(this);
     else if (IsEqualGUID(riid, IID_IDOMNodeExtensions))
index 2728267cdeef6e3acaf0fb472e15d69ce3a2c17d..f7a0d2b125b724d5a95d412500e76d2216e9953c 100644 (file)
@@ -221,9 +221,10 @@ HRESULT STDMETHODCALLTYPE DOMHTMLDocument::body(
         return E_FAIL;
 
     HTMLDocument* htmlDoc = static_cast<HTMLDocument*>(m_document);
-    COMPtr<IDOMElement> domEle = DOMHTMLElement::createInstance(htmlDoc->body());
-    if (domEle)
-        return domEle->QueryInterface(IID_IDOMHTMLElement, (void**) bodyElement);
+    COMPtr<IDOMElement> domElement;
+    domElement.adoptRef(DOMHTMLElement::createInstance(htmlDoc->body()));
+    if (domElement)
+        return domElement->QueryInterface(IID_IDOMHTMLElement, (void**) bodyElement);
     return E_FAIL;
 }
     
@@ -509,10 +510,12 @@ HRESULT STDMETHODCALLTYPE DOMHTMLFormElement::setAcceptCharset(
 }
     
 HRESULT STDMETHODCALLTYPE DOMHTMLFormElement::action( 
-        /* [retval][out] */ BSTR* /*result*/)
+        /* [retval][out] */ BSTR* result)
 {
-    ASSERT_NOT_REACHED();
-    return E_NOTIMPL;
+    ASSERT(m_element && m_element->hasTagName(formTag));
+    WebCore::String actionString = static_cast<HTMLFormElement*>(m_element)->action();
+    *result = BString(actionString.characters(), actionString.length()).release();
+    return S_OK;
 }
     
 HRESULT STDMETHODCALLTYPE DOMHTMLFormElement::setAction( 
@@ -537,10 +540,12 @@ HRESULT STDMETHODCALLTYPE DOMHTMLFormElement::setEnctype(
 }
     
 HRESULT STDMETHODCALLTYPE DOMHTMLFormElement::method( 
-        /* [retval][out] */ BSTR* /*method*/)
+        /* [retval][out] */ BSTR* result)
 {
-    ASSERT_NOT_REACHED();
-    return E_NOTIMPL;
+    ASSERT(m_element && m_element->hasTagName(formTag));
+    WebCore::String methodString = static_cast<HTMLFormElement*>(m_element)->method();
+    *result = BString(methodString.characters(), methodString.length()).release();
+    return S_OK;
 }
     
 HRESULT STDMETHODCALLTYPE DOMHTMLFormElement::setMethod( 
@@ -898,10 +903,18 @@ HRESULT STDMETHODCALLTYPE DOMHTMLInputElement::setDefaultChecked(
 }
     
 HRESULT STDMETHODCALLTYPE DOMHTMLInputElement::form( 
-        /* [retval][out] */ IDOMHTMLElement** /*result*/)
+        /* [retval][out] */ IDOMHTMLElement** result)
 {
-    ASSERT_NOT_REACHED();
-    return E_NOTIMPL;
+    if (!result)
+        return E_POINTER;
+    *result = 0;
+    ASSERT(m_element && m_element->hasTagName(inputTag));
+    HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(m_element);
+    COMPtr<IDOMElement> domElement;
+    domElement.adoptRef(DOMHTMLElement::createInstance(inputElement->form()));
+    if (domElement)
+        return domElement->QueryInterface(IID_IDOMHTMLElement, (void**) result);
+    return E_FAIL;
 }
     
 HRESULT STDMETHODCALLTYPE DOMHTMLInputElement::accept( 
@@ -1268,10 +1281,18 @@ HRESULT STDMETHODCALLTYPE DOMHTMLTextAreaElement::setDefaultValue(
 }
     
 HRESULT STDMETHODCALLTYPE DOMHTMLTextAreaElement::form( 
-        /* [retval][out] */ IDOMHTMLElement** /*result*/)
+        /* [retval][out] */ IDOMHTMLElement** result)
 {
-    ASSERT_NOT_REACHED();
-    return E_NOTIMPL;
+    if (!result)
+        return E_POINTER;
+    *result = 0;
+    ASSERT(m_element && m_element->hasTagName(textareaTag));
+    HTMLTextAreaElement* textareaElement = static_cast<HTMLTextAreaElement*>(m_element);
+    COMPtr<IDOMElement> domElement;
+    domElement.adoptRef(DOMHTMLElement::createInstance(textareaElement->form()));
+    if (domElement)
+        return domElement->QueryInterface(IID_IDOMHTMLElement, (void**) result);
+    return E_FAIL;
 }
     
 HRESULT STDMETHODCALLTYPE DOMHTMLTextAreaElement::accessKey( 
index ce50b09d4dd2f32567f91c20c6c5b20d8d66fca3..2d7dd0336cf15187006a6d43ac2d131b8d8c06c5 100644 (file)
@@ -611,7 +611,7 @@ interface IDOMHTMLOptionElement : IDOMHTMLElement
     uuid(80C40AC5-1755-4894-812F-479269C262A2),
     pointer_default(unique)
 ]
-interface IDOMHTMLInputElement : IDOMElement
+interface IDOMHTMLInputElement : IDOMHTMLElement
 {
     /*
         - (NSString *)defaultValue;