Commit 8192b622 authored by eseidel's avatar eseidel
Browse files

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:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@16575 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent de9f5ab7
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.
8d142988c8c534f3ac6bb5b2a0e1555a
\ No newline at end of file
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"]
<?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.
......@@ -27,12 +27,14 @@
#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)
{
}
......@@ -40,33 +42,36 @@ SVGDocument::~SVGDocument()
{
}
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);
}
}
......
......@@ -20,8 +20,8 @@
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"
......@@ -39,7 +39,9 @@ namespace WebCore {
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();
......@@ -48,6 +50,6 @@ namespace WebCore {
} // namespace WebCore
#endif // SVG_SUPPORT
#endif // KSVG_SVGDocumentImpl_H
#endif // SVGDocument_H
// vim:ts=4:noet
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment