Patch by Anders Carlsson <andersca@mac.com>
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Jun 2005 17:50:24 +0000 (17:50 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Jun 2005 17:50:24 +0000 (17:50 +0000)
        - Fixes <http://bugzilla.opendarwin.org/show_bug.cgi?id=3715>
        An HTMLObjectElement's form property was always null.

        Reviewed by Darin

        Test cases added:
        * layout-tests/fast/dom/htmlobject-form-expected.txt: Added.
        * layout-tests/fast/dom/htmlobject-form.html: Added.

        * khtml/html/html_objectimpl.cpp:
        (DOM::HTMLObjectElementImpl::form):
        Implement this function by traversing the parent nodes looking
        for a form element.

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

LayoutTests/fast/dom/htmlobject-form-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/htmlobject-form.html [new file with mode: 0644]
WebCore/ChangeLog-2005-08-23
WebCore/khtml/html/html_objectimpl.cpp

diff --git a/LayoutTests/fast/dom/htmlobject-form-expected.txt b/LayoutTests/fast/dom/htmlobject-form-expected.txt
new file mode 100644 (file)
index 0000000..2e49960
--- /dev/null
@@ -0,0 +1,22 @@
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x18
+        RenderText {TEXT} at (0,0) size 433x18
+          text run at (0,0) width 433: "This test attempts to access an HTMLObjectElements form property."
+      RenderBlock {DIV} at (0,34) size 784x52
+        RenderBlock {P} at (0,0) size 784x18
+          RenderText {TEXT} at (0,0) size 86x18
+            text run at (0,0) width 86: "Passed Test 1"
+        RenderBlock {P} at (0,34) size 784x18
+          RenderText {TEXT} at (0,0) size 86x18
+            text run at (0,0) width 86: "Passed Test 2"
+      RenderBlock {FORM} at (0,102) size 784x150
+        RenderPartObject {OBJECT} at (0,0) size 300x150
+        RenderText {TEXT} at (0,0) size 0x0
+      RenderBlock (anonymous) at (0,268) size 784x150
+        RenderPartObject {OBJECT} at (0,0) size 300x150
+        RenderText {TEXT} at (0,0) size 0x0
+        RenderText {TEXT} at (0,0) size 0x0
diff --git a/LayoutTests/fast/dom/htmlobject-form.html b/LayoutTests/fast/dom/htmlobject-form.html
new file mode 100644 (file)
index 0000000..a15a445
--- /dev/null
@@ -0,0 +1,45 @@
+<html>
+
+    <head>
+        <script language="javascript">
+        function print(message)
+        {
+            var paragraph = document.createElement("p");
+            paragraph.appendChild(document.createTextNode(message));
+            document.getElementById("console").appendChild(paragraph);
+        }
+        function test() 
+        {
+            objectInsideForm = document.getElementById("objectInsideForm");
+            objectNotInsideForm = document.getElementById("objectNotInsideForm");
+        
+            form = document.getElementById("form");
+            
+            if(objectInsideForm.form == form)
+                print("Passed Test 1");
+            else
+                print("Failed Test 1");
+                
+            if(objectNotInsideForm.form == null)
+                print("Passed Test 2");
+            else
+                print("Failed Test 2");
+        }
+        </script>
+    </head>
+
+    <body onload="test();">
+        <p>This test attempts to access an HTMLObjectElements form property.</p>
+        
+        <div id="console">
+        </div>  
+              
+        <form id="form">
+            <object id="objectInsideForm">
+            </object>
+        </form>
+        
+        <object id="objectNotInsideForm">
+        </object>
+    </body>   
+</html>
index 9418af220d800007197372be1e17097be97135b3..2cf8d0681124449b42424e4204cf3b4fa8bcc80d 100644 (file)
@@ -1,3 +1,21 @@
+2005-06-29  Justin Garcia  <justin.garcia@apple.com>
+
+        Patch by Anders Carlsson  <andersca@mac.com>
+
+        - Fixes <http://bugzilla.opendarwin.org/show_bug.cgi?id=3715>
+        An HTMLObjectElement's form property was always null.
+
+        Reviewed by Darin
+
+        Test cases added:
+        * layout-tests/fast/dom/htmlobject-form-expected.txt: Added.
+        * layout-tests/fast/dom/htmlobject-form.html: Added.
+
+        * khtml/html/html_objectimpl.cpp:
+        (DOM::HTMLObjectElementImpl::form):
+        Implement this function by traversing the parent nodes looking
+        for a form element.
+
 2005-06-29  Geoffrey Garen  <ggaren@apple.com>
 
        Patch by Antoine Quint <ml@graougraou.com>
index f817c9ff31b56a58ec3cbbaa2d6279e6dee741c8..ffc67b0b83dca3d1d9dd3f75547e21b35b4d641f 100644 (file)
@@ -36,6 +36,7 @@
 #include "css/csshelper.h"
 #include "css/cssproperties.h"
 #include "css/cssvalues.h"
+#include "html/html_formimpl.h"
 #include "rendering/render_applet.h"
 #include "rendering/render_frames.h"
 #include "rendering/render_image.h"
@@ -553,7 +554,12 @@ KJS::Bindings::Instance *HTMLObjectElementImpl::getObjectInstance() const
 
 HTMLFormElementImpl *HTMLObjectElementImpl::form() const
 {
-  return 0;
+    for (NodeImpl *p = parentNode(); p != 0; p = p->parentNode()) {
+        if (p->id() == ID_FORM)
+            return static_cast<HTMLFormElementImpl *>(p);
+    }
+    
+    return 0;
 }
 
 bool HTMLObjectElementImpl::mapToEntry(NodeImpl::Id attr, MappedAttributeEntry& result) const