#include "config.h"
#if SVG_SUPPORT
#include "SVGAElement.h"
#include "Attr.h"
#include "Document.h"
#include "Event.h"
#include "EventNames.h"
#include "Frame.h"
#include "MouseEvent.h"
#include "MouseEvent.h"
#include "SVGAnimatedString.h"
#include "SVGHelper.h"
#include "SVGNames.h"
#include "csshelper.h"
#include <kcanvas/RenderSVGContainer.h>
#include <kcanvas/KCanvasCreator.h>
#include <kcanvas/device/KRenderingDevice.h>
namespace WebCore {
SVGAElement::SVGAElement(const QualifiedName& tagName, Document *doc)
: SVGStyledTransformableElement(tagName, doc), SVGURIReference(), SVGTests(), SVGLangSpace(), SVGExternalResourcesRequired()
{
}
SVGAElement::~SVGAElement()
{
}
SVGAnimatedString *SVGAElement::target() const
{
return lazy_create<SVGAnimatedString>(m_target, this);
}
void SVGAElement::parseMappedAttribute(MappedAttribute *attr)
{
const AtomicString& value(attr->value());
if (attr->name() == SVGNames::targetAttr) {
target()->setBaseVal(value.impl());
} else {
if(SVGURIReference::parseMappedAttribute(attr))
{
m_isLink = attr->value() != 0;
return;
}
if(SVGTests::parseMappedAttribute(attr)) return;
if(SVGLangSpace::parseMappedAttribute(attr)) return;
if(SVGExternalResourcesRequired::parseMappedAttribute(attr)) return;
SVGStyledTransformableElement::parseMappedAttribute(attr);
}
}
RenderObject* SVGAElement::createRenderer(RenderArena* arena, RenderStyle* style)
{
return new (arena) RenderSVGContainer(this);
}
void SVGAElement::defaultEventHandler(Event *evt)
{
if((evt->type() == EventNames::mouseupEvent && m_isLink))
{
MouseEvent *e = static_cast<MouseEvent*>(evt);
DeprecatedString url;
DeprecatedString utarget;
if(e && e->button() == 2)
{
SVGStyledTransformableElement::defaultEventHandler(evt);
return;
}
url = parseURL(href()->baseVal()).deprecatedString();
utarget = getAttribute(SVGNames::targetAttr).deprecatedString();
if(e && e->button() == 1)
utarget = "_blank";
if (!evt->defaultPrevented()) {
if(ownerDocument() && ownerDocument()->view() && ownerDocument()->frame())
{
document()->frame()->urlSelected(url, utarget);
}
}
evt->setDefaultHandled();
}
SVGStyledTransformableElement::defaultEventHandler(evt);
}
}
#endif // SVG_SUPPORT