+2006-09-26 Eric Seidel <eric@eseidel.com>
+
+ Reviewed by Tim H.
+
+ SVGDocument::createElement does not create elements in the SVG namespace
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=10932
+
+ * svg/custom/createelement-expected.checksum: Added.
+ * svg/custom/createelement-expected.png: Added.
+ * svg/custom/createelement-expected.txt: Added.
+ * svg/custom/createelement.svg: Added.
+
2006-09-26 Eric Seidel <eric@eseidel.com>
Reviewed by Tim H.
--- /dev/null
+8d142988c8c534f3ac6bb5b2a0e1555a
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+ KCanvasContainer {svg} at (0,0) size 100x100
+ KCanvasItem {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#FF0000]}] [data="M0.00,0.00L100.00,0.00L100.00,100.00L0.00,100.00"]
+ RenderSVGText {text} at (0,0) size 800x18
+ RenderText {#text} at (0,0) size 353x18
+ text run at (0,0) width 353: "namespace of created rect: http://www.w3.org/2000/svg"
+ KCanvasItem {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,100.00L0.00,100.00"]
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg">
+ <rect id="red" width="100" height="100" fill="red" />
+ <text id="text" x="10" y="120"></text>
+ <script type="text/javascript">
+ <![CDATA[
+ var red = document.getElementById('red');
+ // Note the use of createElement instead of createElementNS
+ var green = document.createElement("rect");
+ // DOM 3 core says the namespaceURI must be null:
+ // http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/DOM3-Core.html#core-ID-2141741547
+ // but setting it to http://www.w3.org/2000/svg (like html does) is more in line with what web authors will expect.
+ green.setAttribute("width", "100");
+ green.setAttribute("height", "100");
+ green.setAttribute("fill", "green");
+ red.ownerDocument.rootElement.appendChild(green);
+ document.getElementById('text').textContent = "namespace of created rect: " + green.namespaceURI;
+ ]]>
+ </script>
+</svg>
+2006-09-26 Eric Seidel <eric@eseidel.com>
+
+ Reviewed by Tim H.
+
+ SVGDocument::createElement does not create elements in the SVG namespace
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=10932
+
+ Test: svg/custom/createelement.svg
+
+ * ksvg2/svg/SVGDocument.cpp:
+ (WebCore::SVGDocument::createElement):
+ * ksvg2/svg/SVGDocument.h:
+
2006-09-26 Eric Seidel <eric@eseidel.com>
Reviewed by Tim H.
#include "EventNames.h"
#include "ExceptionCode.h"
#include "SVGElement.h"
+#include "SVGNames.h"
#include "SVGSVGElement.h"
#include "SVGZoomEvent.h"
namespace WebCore {
-SVGDocument::SVGDocument(DOMImplementation *i, FrameView *view) : Document(i, view)
+SVGDocument::SVGDocument(DOMImplementation* i, FrameView* view)
+ : Document(i, view)
{
}
{
}
-SVGSVGElement *SVGDocument::rootElement() const
+SVGSVGElement* SVGDocument::rootElement() const
{
- Element *elem = documentElement();
- if(elem && elem->hasTagName(SVGNames::svgTag))
- return static_cast<SVGSVGElement *>(elem);
+ Element* elem = documentElement();
+ if (elem && elem->hasTagName(SVGNames::svgTag))
+ return static_cast<SVGSVGElement*>(elem);
return 0;
}
+PassRefPtr<Element> SVGDocument::createElement(const String& tagName, ExceptionCode& ec)
+{
+ return createElementNS(SVGNames::svgNamespaceURI, tagName, ec);
+}
+
void SVGDocument::dispatchZoomEvent(float prevScale, float newScale)
{
- // dispatch zoom event
ExceptionCode ec = 0;
RefPtr<SVGZoomEvent> event = static_pointer_cast<SVGZoomEvent>(createEvent("SVGZoomEvents", ec));
event->initEvent(EventNames::zoomEvent, true, false);
event->setPreviousScale(prevScale);
event->setNewScale(newScale);
- rootElement()->dispatchEvent(event.get(), ec);
+ rootElement()->dispatchEvent(event.release(), ec);
}
void SVGDocument::dispatchScrollEvent()
{
- // dispatch zoom event
ExceptionCode ec = 0;
RefPtr<Event> event = createEvent("SVGEvents", ec);
event->initEvent(EventNames::scrollEvent, true, false);
- rootElement()->dispatchEvent(event.get(), ec);
+ rootElement()->dispatchEvent(event.release(), ec);
}
}
Boston, MA 02111-1307, USA.
*/
-#ifndef KSVG_SVGDocumentImpl_H
-#define KSVG_SVGDocumentImpl_H
+#ifndef SVGDocument_H
+#define SVGDocument_H
#ifdef SVG_SUPPORT
#include "Document.h"
virtual bool isSVGDocument() const { return true; }
- SVGSVGElement *rootElement() const;
+ SVGSVGElement* rootElement() const;
+
+ virtual PassRefPtr<Element> SVGDocument::createElement(const String& tagName, ExceptionCode&);
void dispatchZoomEvent(float prevScale, float newScale);
void dispatchScrollEvent();
} // namespace WebCore
#endif // SVG_SUPPORT
-#endif // KSVG_SVGDocumentImpl_H
+#endif // SVGDocument_H
// vim:ts=4:noet