2006-07-27 Eric Seidel <eric@eseidel.com>
authoreseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Jul 2006 05:26:00 +0000 (05:26 +0000)
committereseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Jul 2006 05:26:00 +0000 (05:26 +0000)
        Reviewed by ap.

        Enables getSVGDocument() support for HTMLObjectElement and HTMLEmbedElement
        This patch does not try to autogenerate anything, but enables the SVG functionality.
        Also fix HTMLObjectElement vspace and hspace to be numbers instead of strings to match IE & Firefox.

        * bindings/js/kjs_dom.cpp:
        (KJS::toJS):
        * bindings/js/kjs_html.cpp:
        (KJS::JSHTMLElement::objectGetter):
        (KJS::HTMLElementFunction::callAsFunction):
        (KJS::JSHTMLElement::objectSetter):
        * bindings/js/kjs_html.h:
        (KJS::JSHTMLElement::):
        * dom/Document.h:
        (WebCore::Document::isSVGDocument):
        * html/HTMLEmbedElement.cpp:
        (WebCore::HTMLEmbedElement::contentDocument):
        (WebCore::HTMLEmbedElement::getSVGDocument):
        * html/HTMLEmbedElement.h:
        * html/HTMLObjectElement.cpp:
        (WebCore::HTMLObjectElement::HTMLObjectElement):
        (WebCore::HTMLObjectElement::getInstance):
        (WebCore::HTMLObjectElement::parseMappedAttribute):
        (WebCore::HTMLObjectElement::contentDocument):
        (WebCore::HTMLObjectElement::rendererIsNeeded):
        (WebCore::HTMLObjectElement::createRenderer):
        (WebCore::HTMLObjectElement::setCode):
        (WebCore::HTMLObjectElement::setArchive):
        (WebCore::HTMLObjectElement::setBorder):
        (WebCore::HTMLObjectElement::setCodeBase):
        (WebCore::HTMLObjectElement::setCodeType):
        (WebCore::HTMLObjectElement::setData):
        (WebCore::HTMLObjectElement::hspace):
        (WebCore::HTMLObjectElement::setHspace):
        (WebCore::HTMLObjectElement::setStandby):
        (WebCore::HTMLObjectElement::setType):
        (WebCore::HTMLObjectElement::setUseMap):
        (WebCore::HTMLObjectElement::vspace):
        (WebCore::HTMLObjectElement::setVspace):
        (WebCore::HTMLObjectElement::getSVGDocument):
        * html/HTMLObjectElement.h:
        * ksvg2/svg/SVGDocument.h:
        (WebCore::SVGDocument::isSVGDocument):
        * rendering/RenderWidget.h:
        (WebCore::RenderWidget::frameView):

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

23 files changed:
LayoutTests/ChangeLog
LayoutTests/dom/svg/level3/xpath/Conformance_ID-expected.checksum [new file with mode: 0644]
LayoutTests/dom/svg/level3/xpath/Conformance_ID-expected.png [new file with mode: 0644]
LayoutTests/fast/dom/HTMLObjectElement/vspace-hspace-as-number-expected.checksum [new file with mode: 0644]
LayoutTests/fast/dom/HTMLObjectElement/vspace-hspace-as-number-expected.png [new file with mode: 0644]
LayoutTests/fast/dom/HTMLObjectElement/vspace-hspace-as-number-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/HTMLObjectElement/vspace-hspace-as-number.html [new file with mode: 0644]
LayoutTests/fast/dynamic/move-node-with-selection-expected.png [new file with mode: 0644]
LayoutTests/svg/custom/getsvgdocument-expected.checksum [new file with mode: 0644]
LayoutTests/svg/custom/getsvgdocument-expected.png [new file with mode: 0644]
LayoutTests/svg/custom/getsvgdocument-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/getsvgdocument.html [new file with mode: 0644]
LayoutTests/svg/custom/resources/getsvgdocument.svg [new file with mode: 0644]
WebCore/ChangeLog
WebCore/bindings/js/kjs_dom.cpp
WebCore/bindings/js/kjs_html.cpp
WebCore/bindings/js/kjs_html.h
WebCore/dom/Document.h
WebCore/html/HTMLEmbedElement.cpp
WebCore/html/HTMLEmbedElement.h
WebCore/html/HTMLObjectElement.cpp
WebCore/html/HTMLObjectElement.h
WebCore/ksvg2/svg/SVGDocument.h

index 903917ca80ff77e0181228a1453b4f1d86af9a60..78d32ab8ab490968c54d873981169bf6d90c4130 100644 (file)
@@ -1,3 +1,20 @@
+2006-07-27  Eric Seidel  <eric@eseidel.com>
+
+        Reviewed by ap.
+        
+        Add testcases for getSVGDocument() function.
+        Also test HTMLObjectElement.vspace and hspace as numbers (while I'm at it).
+
+        * fast/dom/HTMLObjectElement/vspace-hspace-as-number-expected.checksum: Added.
+        * fast/dom/HTMLObjectElement/vspace-hspace-as-number-expected.png: Added.
+        * fast/dom/HTMLObjectElement/vspace-hspace-as-number-expected.txt: Added.
+        * fast/dom/HTMLObjectElement/vspace-hspace-as-number.html: Added.
+        * svg/custom/getsvgdocument-expected.checksum: Added.
+        * svg/custom/getsvgdocument-expected.png: Added.
+        * svg/custom/getsvgdocument-expected.txt: Added.
+        * svg/custom/getsvgdocument.html: Added.
+        * svg/custom/resources/getsvgdocument.svg: Added.
+
 2006-07-26  Alexey Proskuryakov  <ap@nypop.com>
 
         Reviewed by Darin.
diff --git a/LayoutTests/dom/svg/level3/xpath/Conformance_ID-expected.checksum b/LayoutTests/dom/svg/level3/xpath/Conformance_ID-expected.checksum
new file mode 100644 (file)
index 0000000..a0d02ff
--- /dev/null
@@ -0,0 +1 @@
+9db0fadc37dcfe0a0a16207e78f3eddd
\ No newline at end of file
diff --git a/LayoutTests/dom/svg/level3/xpath/Conformance_ID-expected.png b/LayoutTests/dom/svg/level3/xpath/Conformance_ID-expected.png
new file mode 100644 (file)
index 0000000..698a2f6
Binary files /dev/null and b/LayoutTests/dom/svg/level3/xpath/Conformance_ID-expected.png differ
diff --git a/LayoutTests/fast/dom/HTMLObjectElement/vspace-hspace-as-number-expected.checksum b/LayoutTests/fast/dom/HTMLObjectElement/vspace-hspace-as-number-expected.checksum
new file mode 100644 (file)
index 0000000..6938d3d
--- /dev/null
@@ -0,0 +1 @@
+23d4fe2852121ad7d23516ec9ca4f811
\ No newline at end of file
diff --git a/LayoutTests/fast/dom/HTMLObjectElement/vspace-hspace-as-number-expected.png b/LayoutTests/fast/dom/HTMLObjectElement/vspace-hspace-as-number-expected.png
new file mode 100644 (file)
index 0000000..7fe15b9
Binary files /dev/null and b/LayoutTests/fast/dom/HTMLObjectElement/vspace-hspace-as-number-expected.png differ
diff --git a/LayoutTests/fast/dom/HTMLObjectElement/vspace-hspace-as-number-expected.txt b/LayoutTests/fast/dom/HTMLObjectElement/vspace-hspace-as-number-expected.txt
new file mode 100644 (file)
index 0000000..7671c5e
--- /dev/null
@@ -0,0 +1,15 @@
+layer at (0,0) size 800x600
+  RenderView 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 784x36
+        RenderText {#text} at (0,0) size 782x36
+          text run at (0,0) width 782: "This test makes sure that HTMLObjectElement.vspace and HTMLObjectElement.hspace are exposed as numbers instead of"
+          text run at (0,18) width 719: "strings, per the DOM Level 2 HTML spec: http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-9893177"
+      RenderBlock (anonymous) at (0,52) size 784x170
+        RenderPartObject {OBJECT} at (20,10) size 300x150
+        RenderText {#text} at (0,0) size 0x0
+      RenderBlock {DIV} at (0,222) size 784x18
+        RenderText {#text} at (0,0) size 76x18
+          text run at (0,0) width 76: "SUCCESS!"
diff --git a/LayoutTests/fast/dom/HTMLObjectElement/vspace-hspace-as-number.html b/LayoutTests/fast/dom/HTMLObjectElement/vspace-hspace-as-number.html
new file mode 100644 (file)
index 0000000..a5f57cd
--- /dev/null
@@ -0,0 +1,17 @@
+<p>This test makes sure that HTMLObjectElement.vspace and HTMLObjectElement.hspace are exposed as numbers instead of strings, per the DOM Level 2 HTML spec: http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-9893177</p>
+
+<object id="object" data="" vspace="10" hspace="20"></object>
+
+<div id="results">FAILURE</div>
+
+<script type="text/javascript">
+var object = document.getElementById("object");
+var resultsDiv = document.getElementById("results");
+if (typeof(object.vspace) != "number") {
+  resultsDiv.innerHTML += "FAILURE HTMLObjectElement.vspace is not a number, rather: " + typeof(object.vspace)
+} else if (typeof(object.hspace) != "number") {
+  resultsDiv.innerHTML += "FAILURE HTMLObjectElement.hspace is not a number, rather: " + typeof(object.hspace)
+} else {
+  resultsDiv.innerHTML = "SUCCESS!";
+}
+</script>
\ No newline at end of file
diff --git a/LayoutTests/fast/dynamic/move-node-with-selection-expected.png b/LayoutTests/fast/dynamic/move-node-with-selection-expected.png
new file mode 100644 (file)
index 0000000..25d63a3
Binary files /dev/null and b/LayoutTests/fast/dynamic/move-node-with-selection-expected.png differ
diff --git a/LayoutTests/svg/custom/getsvgdocument-expected.checksum b/LayoutTests/svg/custom/getsvgdocument-expected.checksum
new file mode 100644 (file)
index 0000000..5300623
--- /dev/null
@@ -0,0 +1 @@
+a6d937d7f4269838ab4fd9cae8b046fb
\ No newline at end of file
diff --git a/LayoutTests/svg/custom/getsvgdocument-expected.png b/LayoutTests/svg/custom/getsvgdocument-expected.png
new file mode 100644 (file)
index 0000000..3ce14c1
Binary files /dev/null and b/LayoutTests/svg/custom/getsvgdocument-expected.png differ
diff --git a/LayoutTests/svg/custom/getsvgdocument-expected.txt b/LayoutTests/svg/custom/getsvgdocument-expected.txt
new file mode 100644 (file)
index 0000000..0a4b6e4
--- /dev/null
@@ -0,0 +1,30 @@
+layer at (0,0) size 800x600
+  RenderView 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 784x36
+        RenderText {#text} at (0,0) size 767x36
+          text run at (0,0) width 767: "This tests to see if HTMLEmbedElement.getSVGDocument() and HTMLObjectElement.getSVGDocument() work. You"
+          text run at (0,18) width 300: "should see SUCCESS printed twice below this:"
+      RenderBlock (anonymous) at (0,52) size 784x58
+        RenderPartObject {EMBED} at (0,0) size 85x20
+          layer at (0,0) size 85x20
+            RenderView at (0,0) size 85x20
+              KCanvasContainer {svg} at (0,0) size 85x20
+                KCanvasItem {rect} at (0,0) size 85x20 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L85.00,0.00L85.00,20.00L0.00,20.00"]
+                RenderSVGText {text} at (0,0) size 85x18
+                  RenderText {#text} at (0,0) size 71x18
+                    text run at (0,0) width 71: "SUCCESS"
+        RenderBR {BR} at (85,20) size 0x0
+        RenderBR {BR} at (0,20) size 0x18
+        RenderPartObject {OBJECT} at (0,38) size 85x20
+          layer at (0,0) size 85x20
+            RenderView at (0,0) size 85x20
+              KCanvasContainer {svg} at (0,0) size 85x20
+                KCanvasItem {rect} at (0,0) size 85x20 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L85.00,0.00L85.00,20.00L0.00,20.00"]
+                RenderSVGText {text} at (0,0) size 85x18
+                  RenderText {#text} at (0,0) size 71x18
+                    text run at (0,0) width 71: "SUCCESS"
+        RenderText {#text} at (0,0) size 0x0
+        RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/svg/custom/getsvgdocument.html b/LayoutTests/svg/custom/getsvgdocument.html
new file mode 100644 (file)
index 0000000..3a04f39
--- /dev/null
@@ -0,0 +1,28 @@
+<script>
+function changeToSuccess(svgDocument) {
+  var text = svgDocument.getElementById("text");
+  var rect = svgDocument.getElementById("rect");
+  
+  // Due to limitations in the current SVG JS Bindings, we're changing the text in this roundabout way:
+  text.removeChild(text.firstChild);
+  text.appendChild(document.createTextNode("SUCCESS"));
+  
+  rect.style.fill = "green";
+}
+
+function didLoad() {
+  var object = document.getElementById("object");
+  var embed = document.getElementById("embed");
+
+  changeToSuccess(object.getSVGDocument());
+  changeToSuccess(embed.getSVGDocument());
+}
+</script>
+
+<body onload="didLoad()">
+<p>This tests to see if HTMLEmbedElement.getSVGDocument() and HTMLObjectElement.getSVGDocument() work. You should see SUCCESS printed twice below this:</p>
+
+<EMBED id="embed" SRC="resources/getsvgdocument.svg" WIDTH="85" HEIGHT="20" /><br><br>
+  
+<OBJECT id="object" DATA="resources/getsvgdocument.svg" WIDTH="85" HEIGHT="20">FAILURE (no SVG support!)</OBJECT>
+</body>
diff --git a/LayoutTests/svg/custom/resources/getsvgdocument.svg b/LayoutTests/svg/custom/resources/getsvgdocument.svg
new file mode 100644 (file)
index 0000000..7491b73
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+  <rect id="rect" x="0" y="0" width="100%" height="100%" fill="red"/>
+  <text id="text" x="5" y="16">FAILURE</text>
+</svg>
\ No newline at end of file
index 70dc3fab2a740fa6967c06afaef3d7742e42bf08..43c0c4228df491f1a6824514c5e523a45505b049 100644 (file)
@@ -1,3 +1,52 @@
+2006-07-27  Eric Seidel  <eric@eseidel.com>
+
+        Reviewed by ap.
+
+        Enables getSVGDocument() support for HTMLObjectElement and HTMLEmbedElement
+        This patch does not try to autogenerate anything, but enables the SVG functionality.
+        Also fix HTMLObjectElement vspace and hspace to be numbers instead of strings to match IE & Firefox.
+
+        * bindings/js/kjs_dom.cpp:
+        (KJS::toJS):
+        * bindings/js/kjs_html.cpp:
+        (KJS::JSHTMLElement::objectGetter):
+        (KJS::HTMLElementFunction::callAsFunction):
+        (KJS::JSHTMLElement::objectSetter):
+        * bindings/js/kjs_html.h:
+        (KJS::JSHTMLElement::):
+        * dom/Document.h:
+        (WebCore::Document::isSVGDocument):
+        * html/HTMLEmbedElement.cpp:
+        (WebCore::HTMLEmbedElement::contentDocument):
+        (WebCore::HTMLEmbedElement::getSVGDocument):
+        * html/HTMLEmbedElement.h:
+        * html/HTMLObjectElement.cpp:
+        (WebCore::HTMLObjectElement::HTMLObjectElement):
+        (WebCore::HTMLObjectElement::getInstance):
+        (WebCore::HTMLObjectElement::parseMappedAttribute):
+        (WebCore::HTMLObjectElement::contentDocument):
+        (WebCore::HTMLObjectElement::rendererIsNeeded):
+        (WebCore::HTMLObjectElement::createRenderer):
+        (WebCore::HTMLObjectElement::setCode):
+        (WebCore::HTMLObjectElement::setArchive):
+        (WebCore::HTMLObjectElement::setBorder):
+        (WebCore::HTMLObjectElement::setCodeBase):
+        (WebCore::HTMLObjectElement::setCodeType):
+        (WebCore::HTMLObjectElement::setData):
+        (WebCore::HTMLObjectElement::hspace):
+        (WebCore::HTMLObjectElement::setHspace):
+        (WebCore::HTMLObjectElement::setStandby):
+        (WebCore::HTMLObjectElement::setType):
+        (WebCore::HTMLObjectElement::setUseMap):
+        (WebCore::HTMLObjectElement::vspace):
+        (WebCore::HTMLObjectElement::setVspace):
+        (WebCore::HTMLObjectElement::getSVGDocument):
+        * html/HTMLObjectElement.h:
+        * ksvg2/svg/SVGDocument.h:
+        (WebCore::SVGDocument::isSVGDocument):
+        * rendering/RenderWidget.h:
+        (WebCore::RenderWidget::frameView):
+
 2006-07-26  Alexey Proskuryakov  <ap@nypop.com>
 
         Reviewed by Darin.
index 2a760a8016926dc5aaf8cc82a46676f81e1c3690..7b59f83355ec38782fcf8384499b33f2c8ccbf4e 100644 (file)
@@ -63,7 +63,9 @@
 #include "kjs_window.h"
 
 #if SVG_SUPPORT
+#include "JSSVGDocument.h"
 #include "JSSVGElementWrapperFactory.h"
+#include "SVGDocument.h"
 #include "SVGElement.h"
 #endif
 
@@ -941,6 +943,10 @@ JSValue* toJS(ExecState* exec, Document *n)
 
   if (n->isHTMLDocument())
     ret = new WebCore::JSHTMLDocument(exec, static_cast<HTMLDocument*>(n));
+#if SVG_SUPPORT
+  else if (n->isSVGDocument())
+    ret = new WebCore::JSSVGDocument(exec, static_cast<SVGDocument*>(n));
+#endif
   else
     ret = new JSDocument(exec, n);
 
index 5e0bf2a69f2d8f61d11982262bffac66f31022bd..617d08c7e6c31a558e24a8121165c3edd0ec806e 100644 (file)
 #include "kjs_window.h"
 #include <math.h>
 
+#if SVG_SUPPORT
+#include "SVGDocument.h"
+#endif
+
 #include "kjs_html.lut.h"
 
 using namespace WebCore;
@@ -573,6 +577,7 @@ const JSHTMLElement::Accessors* JSHTMLElement::accessors() const
   declare         KJS::JSHTMLElement::ObjectDeclare         DontDelete
   height          KJS::JSHTMLElement::ObjectHeight          DontDelete
   hspace          KJS::JSHTMLElement::ObjectHspace          DontDelete
+  getSVGDocument  KJS::JSHTMLElement::ObjectGetSVGDocument  DontDelete|Function 0
   name            KJS::JSHTMLElement::ObjectName            DontDelete
   standby         KJS::JSHTMLElement::ObjectStandby         DontDelete
   tabIndex        KJS::JSHTMLElement::ObjectTabIndex        DontDelete
@@ -584,6 +589,7 @@ const JSHTMLElement::Accessors* JSHTMLElement::accessors() const
 @begin HTMLEmbedElementTable 6
   align         KJS::JSHTMLElement::EmbedAlign           DontDelete
   height        KJS::JSHTMLElement::EmbedHeight          DontDelete
+  getSVGDocument KJS::JSHTMLElement::EmbedGetSVGDocument DontDelete|Function 0
   name          KJS::JSHTMLElement::EmbedName            DontDelete
   src           KJS::JSHTMLElement::EmbedSrc             DontDelete
   type          KJS::JSHTMLElement::EmbedType            DontDelete
@@ -862,13 +868,13 @@ JSValue *JSHTMLElement::objectGetter(ExecState* exec, int token) const
         case ObjectData:            return jsString(object.data());
         case ObjectDeclare:         return jsBoolean(object.declare());
         case ObjectHeight:          return jsString(object.height());
-        case ObjectHspace:          return jsString(object.hspace());
+        case ObjectHspace:          return jsNumber(object.hspace());
         case ObjectName:            return jsString(object.name());
         case ObjectStandby:         return jsString(object.standby());
         case ObjectTabIndex:        return jsNumber(object.tabIndex());
         case ObjectType:            return jsString(object.type());
         case ObjectUseMap:          return jsString(object.useMap());
-        case ObjectVspace:          return jsString(object.vspace());
+        case ObjectVspace:          return jsNumber(object.vspace());
         case ObjectWidth:           return jsString(object.width());
     }
     return jsUndefined();
@@ -1267,6 +1273,17 @@ JSValue *HTMLElementFunction::callAsFunction(ExecState* exec, JSObject* thisObj,
             return jsUndefined();
         }
     }
+#if SVG_SUPPORT
+  else if (element.hasLocalName(objectTag)) {
+      HTMLObjectElement& object = static_cast<HTMLObjectElement&>(element);
+      if (id == JSHTMLElement::ObjectGetSVGDocument)
+          return checkNodeSecurity(exec, object.getSVGDocument(exception)) ? toJS(exec, object.getSVGDocument(exception)) : jsUndefined();
+  } else if (element.hasLocalName(embedTag)) {
+      HTMLEmbedElement& embed = static_cast<HTMLEmbedElement&>(element);
+      if (id == JSHTMLElement::EmbedGetSVGDocument)
+          return checkNodeSecurity(exec, embed.getSVGDocument(exception)) ? toJS(exec, embed.getSVGDocument(exception)) : jsUndefined();
+  }
+#endif
 
     return jsUndefined();
 }
@@ -1345,13 +1362,13 @@ void JSHTMLElement::objectSetter(ExecState* exec, int token, JSValue *value, con
         case ObjectData:            { object.setData(str); return; }
         case ObjectDeclare:         { object.setDeclare(value->toBoolean(exec)); return; }
         case ObjectHeight:          { object.setHeight(str); return; }
-        case ObjectHspace:          { object.setHspace(str); return; }
+        case ObjectHspace:          { object.setHspace(value->toInt32(exec)); return; }
         case ObjectName:            { object.setName(str); return; }
         case ObjectStandby:         { object.setStandby(str); return; }
         case ObjectTabIndex:        { object.setTabIndex(value->toInt32(exec)); return; }
         case ObjectType:            { object.setType(str); return; }
         case ObjectUseMap:          { object.setUseMap(str); return; }
-        case ObjectVspace:          { object.setVspace(str); return; }
+        case ObjectVspace:          { object.setVspace(value->toInt32(exec)); return; }
         case ObjectWidth:           { object.setWidth(str); return; }
     }
 }
index d6d2f197f4be47221148eca5fbd15a803daeb2eb..5258540f1848c5dad76ccbc8a3ea2830564b47d1 100644 (file)
@@ -129,8 +129,8 @@ namespace KJS {
            ObjectHspace, ObjectHeight, ObjectAlign,
            ObjectBorder, ObjectCode, ObjectType, ObjectVspace, ObjectArchive,
            ObjectDeclare, ObjectForm, ObjectCodeBase, ObjectCodeType, ObjectData,
-           ObjectName, ObjectStandby, ObjectTabIndex, ObjectUseMap, ObjectWidth, ObjectContentDocument,
-           EmbedAlign, EmbedHeight, EmbedName, EmbedSrc, EmbedType, EmbedWidth,
+           ObjectName, ObjectStandby, ObjectTabIndex, ObjectUseMap, ObjectWidth, ObjectContentDocument, ObjectGetSVGDocument,
+           EmbedAlign, EmbedHeight, EmbedName, EmbedSrc, EmbedType, EmbedWidth, EmbedGetSVGDocument,
            TableSummary, TableTBodies, TableTHead, TableCellPadding,
            TableDeleteCaption, TableCreateCaption, TableCaption, TableWidth,
            TableCreateTFoot, TableAlign, TableTFoot, TableDeleteRow,
index 4263cfa847622e8965b10705e0426a9a93901ebd..e3bc6458b0d494f88fe32bda523ef3ffe07c57dd 100644 (file)
@@ -222,6 +222,9 @@ public:
     // Other methods (not part of DOM)
     virtual bool isDocumentNode() const { return true; }
     virtual bool isHTMLDocument() const { return false; }
+#if SVG_SUPPORT
+    virtual bool isSVGDocument() const { return false; }
+#endif
     virtual bool isPluginDocument() const { return false; }
     
     CSSStyleSelector* styleSelector() const { return m_styleSelector; }
index 2d3a8d7c1e4b4e1184ca904638217202127c10bc..897ef011f61a9afc9678e815dc2f3951db6d19df 100644 (file)
 #include "csshelper.h"
 #include "RenderPartObject.h"
 
+#if SVG_SUPPORT
+#include "ExceptionCode.h"
+#include "SVGDocument.h"
+#endif
+
 namespace WebCore {
 
 using namespace HTMLNames;
@@ -205,4 +210,36 @@ void HTMLEmbedElement::setType(const String& value)
     setAttribute(typeAttr, value);
 }
 
+#if SVG_SUPPORT
+Document* HTMLEmbedElement::contentDocument() const
+{
+    // FIXME: The frame loading code should be moved out of the render tree
+    // and into the DOM.  Once that happens, this function should look more like
+    // HTMLFrameElement::contentDocument() and not depend on the renderer.
+    RenderObject* object = renderer();
+    if (object && object->isWidget()) {
+        RenderWidget* renderWidget = static_cast<RenderWidget*>(object);
+        if (renderWidget) {
+            Widget* widget = renderWidget->widget();
+            if (widget && widget->isFrameView()) {
+                FrameView* frameView = static_cast<FrameView*>(widget);
+                if (frameView->frame())
+                    return frameView->frame()->document();
+            }
+        }
+    }
+    return 0;
+}
+
+SVGDocument* HTMLEmbedElement::getSVGDocument(ExceptionCode& ec) const
+{
+    Document* doc = contentDocument();
+    if (doc && doc->isSVGDocument())
+        return static_cast<SVGDocument*>(doc);
+    // Spec: http://www.w3.org/TR/SVG/struct.html#InterfaceGetSVGDocument
+    ec = NOT_SUPPORTED_ERR;
+    return 0;
+}
+#endif
+
 }
index e5049e236735a15d166968d2b6da153c33961ba2..f572c2227e2682a36bd246f3e00de873aa0d7032 100644 (file)
@@ -35,6 +35,8 @@ namespace KJS { namespace Bindings { class Instance; } }
 
 namespace WebCore {
 
+class SVGDocument;
+
 class HTMLEmbedElement : public HTMLPlugInElement
 {
 public:
@@ -64,6 +66,11 @@ public:
 
     String type() const;
     void setType(const String&);
+    
+#if SVG_SUPPORT
+    Document* contentDocument() const;
+    SVGDocument* getSVGDocument(ExceptionCode&) const;
+#endif
 
     DeprecatedString url;
     DeprecatedString pluginPage;
index 4245644080d3bb9391e88907ceab79a67702d9a0..84e7cca30eb38bedacc9cf7419af84dd90a7c467 100644 (file)
@@ -25,6 +25,7 @@
 #include "HTMLObjectElement.h"
 
 #include "EventNames.h"
+#include "ExceptionCode.h"
 #include "Frame.h"
 #include "HTMLFormElement.h"
 #include "HTMLDocument.h"
 #include "Text.h"
 #include "csshelper.h"
 
+#if SVG_SUPPORT
+#include "SVGDocument.h"
+#endif
+
 namespace WebCore {
 
 using namespace EventNames;
 using namespace HTMLNames;
 
 HTMLObjectElement::HTMLObjectElement(Document *doc) 
-: HTMLPlugInElement(objectTag, doc)
-, m_imageLoader(0)
+    : HTMLPlugInElement(objectTag, doc)
+    , needWidgetUpdate(false)
+    , m_useFallbackContent(false)
+    , m_imageLoader(0)
+    , m_complete(false)
+    , m_docNamedItem(true)
 {
-    needWidgetUpdate = false;
-    m_useFallbackContent = false;
-    m_complete = false;
-    m_docNamedItem = true;
 }
 
 HTMLObjectElement::~HTMLObjectElement()
@@ -72,7 +77,7 @@ KJS::Bindings::Instance *HTMLObjectElement::getInstance() const
     if (m_instance)
         return m_instance.get();
 
-    if (RenderObject *r = renderer()) {
+    if (RenderObjectr = renderer()) {
         if (r->isWidget()) {
             if (Widget* widget = static_cast<RenderWidget*>(r)->widget()) {
                 // Call into the frame (and over the bridge) to pull the Bindings::Instance
@@ -105,9 +110,9 @@ void HTMLObjectElement::parseMappedAttribute(MappedAttribute *attr)
     int pos;
     if (attr->name() == typeAttr) {
         serviceType = val.deprecatedString().lower();
-        pos = serviceType.find( ";" );
-        if ( pos!=-1 )
-          serviceType = serviceType.left( pos );
+        pos = serviceType.find(";");
+        if (pos != -1)
+          serviceType = serviceType.left(pos);
         if (renderer())
           needWidgetUpdate = true;
         if (!isImageType() && m_imageLoader) {
@@ -155,23 +160,38 @@ void HTMLObjectElement::parseMappedAttribute(MappedAttribute *attr)
 
 Document* HTMLObjectElement::contentDocument() const
 {
-    // ###
+    // FIXME: The frame loading code should be moved out of the render tree
+    // and into the DOM.  Once that happens, this function should look more like
+    // HTMLFrameElement::contentDocument() and not depend on the renderer.
+    RenderObject* object = renderer();
+    if (object && object->isWidget()) {
+        RenderWidget* renderWidget = static_cast<RenderWidget*>(object);
+        if (renderWidget) {
+            Widget* widget = renderWidget->widget();
+            if (widget && widget->isFrameView()) {
+                FrameView* frameView = static_cast<FrameView*>(widget);
+                if (frameView->frame())
+                    return frameView->frame()->document();
+            }
+        }
+    }
     return 0;
 }
 
-bool HTMLObjectElement::rendererIsNeeded(RenderStyle *style)
+bool HTMLObjectElement::rendererIsNeeded(RenderStylestyle)
 {
     if (m_useFallbackContent || isImageType())
         return HTMLPlugInElement::rendererIsNeeded(style);
 
-    Frame *frame = document()->frame();
+    // FIXME: This check is WRONG.  We should check the content before disabling, or do so at a later stage.
+    Frame* frame = document()->frame();
     if (!frame || !frame->pluginsEnabled())
         return false;
     
     return true;
 }
 
-RenderObject *HTMLObjectElement::createRenderer(RenderArena *arena, RenderStyle *style)
+RenderObject *HTMLObjectElement::createRenderer(RenderArena* arena, RenderStyle* style)
 {
     if (m_useFallbackContent)
         return RenderObject::createObject(this, style);
@@ -355,7 +375,7 @@ String HTMLObjectElement::code() const
     return getAttribute(codeAttr);
 }
 
-void HTMLObjectElement::setCode(const String &value)
+void HTMLObjectElement::setCode(const Stringvalue)
 {
     setAttribute(codeAttr, value);
 }
@@ -365,7 +385,7 @@ String HTMLObjectElement::archive() const
     return getAttribute(archiveAttr);
 }
 
-void HTMLObjectElement::setArchive(const String &value)
+void HTMLObjectElement::setArchive(const Stringvalue)
 {
     setAttribute(archiveAttr, value);
 }
@@ -375,7 +395,7 @@ String HTMLObjectElement::border() const
     return getAttribute(borderAttr);
 }
 
-void HTMLObjectElement::setBorder(const String &value)
+void HTMLObjectElement::setBorder(const Stringvalue)
 {
     setAttribute(borderAttr, value);
 }
@@ -385,7 +405,7 @@ String HTMLObjectElement::codeBase() const
     return getAttribute(codebaseAttr);
 }
 
-void HTMLObjectElement::setCodeBase(const String &value)
+void HTMLObjectElement::setCodeBase(const Stringvalue)
 {
     setAttribute(codebaseAttr, value);
 }
@@ -395,7 +415,7 @@ String HTMLObjectElement::codeType() const
     return getAttribute(codetypeAttr);
 }
 
-void HTMLObjectElement::setCodeType(const String &value)
+void HTMLObjectElement::setCodeType(const Stringvalue)
 {
     setAttribute(codetypeAttr, value);
 }
@@ -405,7 +425,7 @@ String HTMLObjectElement::data() const
     return getAttribute(dataAttr);
 }
 
-void HTMLObjectElement::setData(const String &value)
+void HTMLObjectElement::setData(const Stringvalue)
 {
     setAttribute(dataAttr, value);
 }
@@ -420,14 +440,14 @@ void HTMLObjectElement::setDeclare(bool declare)
     setAttribute(declareAttr, declare ? "" : 0);
 }
 
-String HTMLObjectElement::hspace() const
+int HTMLObjectElement::hspace() const
 {
-    return getAttribute(hspaceAttr);
+    return getAttribute(hspaceAttr).toInt();
 }
 
-void HTMLObjectElement::setHspace(const String &value)
+void HTMLObjectElement::setHspace(int value)
 {
-    setAttribute(hspaceAttr, value);
+    setAttribute(hspaceAttr, String::number(value));
 }
 
 String HTMLObjectElement::standby() const
@@ -435,7 +455,7 @@ String HTMLObjectElement::standby() const
     return getAttribute(standbyAttr);
 }
 
-void HTMLObjectElement::setStandby(const String &value)
+void HTMLObjectElement::setStandby(const Stringvalue)
 {
     setAttribute(standbyAttr, value);
 }
@@ -455,7 +475,7 @@ String HTMLObjectElement::type() const
     return getAttribute(typeAttr);
 }
 
-void HTMLObjectElement::setType(const String &value)
+void HTMLObjectElement::setType(const Stringvalue)
 {
     setAttribute(typeAttr, value);
 }
@@ -465,19 +485,31 @@ String HTMLObjectElement::useMap() const
     return getAttribute(usemapAttr);
 }
 
-void HTMLObjectElement::setUseMap(const String &value)
+void HTMLObjectElement::setUseMap(const Stringvalue)
 {
     setAttribute(usemapAttr, value);
 }
 
-String HTMLObjectElement::vspace() const
+int HTMLObjectElement::vspace() const
 {
-    return getAttribute(vspaceAttr);
+    return getAttribute(vspaceAttr).toInt();
 }
 
-void HTMLObjectElement::setVspace(const String &value)
+void HTMLObjectElement::setVspace(int value)
 {
-    setAttribute(vspaceAttr, value);
+    setAttribute(vspaceAttr, String::number(value));
 }
 
+#if SVG_SUPPORT
+SVGDocument* HTMLObjectElement::getSVGDocument(ExceptionCode& ec) const
+{
+    Document* doc = contentDocument();
+    if (doc && doc->isSVGDocument())
+        return static_cast<SVGDocument*>(doc);
+    // Spec: http://www.w3.org/TR/SVG/struct.html#InterfaceGetSVGDocument
+    ec = NOT_SUPPORTED_ERR;
+    return 0;
+}
+#endif
+
 }
index 9dbf9b6f21fdfb35d906178fa62da06ecf0817a8..082e98ad16a075fc71c7c550f8bc040817bddb6d 100644 (file)
@@ -37,6 +37,9 @@ namespace WebCore {
 
 class HTMLFormElement;
 class HTMLImageLoader;
+#if SVG_SUPPORT
+class SVGDocument;
+#endif
 
 class HTMLObjectElement : public HTMLPlugInElement
 {
@@ -56,7 +59,7 @@ public:
     virtual void insertedIntoDocument();
     virtual void removedFromDocument();
     
-    virtual void recalcStyle(StyleChange ch);
+    virtual void recalcStyle(StyleChange);
     virtual void childrenChanged();
 
     virtual bool isURLAttribute(Attribute*) const;
@@ -94,8 +97,8 @@ public:
 
     HTMLFormElement* form() const;
     
-    String hspace() const;
-    void setHspace(const String&);
+    int hspace() const;
+    void setHspace(int);
 
     String standby() const;
     void setStandby(const String&);
@@ -109,14 +112,18 @@ public:
     String useMap() const;
     void setUseMap(const String&);
 
-    String vspace() const;
-    void setVspace(const String&);
+    int vspace() const;
+    void setVspace(int);
 
     bool isComplete() const { return m_complete; }
     void setComplete(bool complete);
     
     bool isDocNamedItem() const { return m_docNamedItem; }
 
+#if SVG_SUPPORT
+    SVGDocument* getSVGDocument(ExceptionCode&) const;
+#endif
+
     DeprecatedString serviceType;
     DeprecatedString url;
     String classId;
index 36979374610e7d6b3e45318391bf114a241b6d1d..991e2478e601b099340db20d5569aec481479929 100644 (file)
@@ -37,6 +37,8 @@ namespace WebCore {
     public:
         SVGDocument(SVGDOMImplementation *i, FrameView *view);
         virtual ~SVGDocument();
+        
+        virtual bool isSVGDocument() const { return true; }
 
         SVGSVGElement *rootElement() const;