• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • sources
  • kde-4.12
  • kdelibs
  • khtml
  • svg
SVGAElement.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3  2004, 2005, 2007 Rob Buis <buis@kde.org>
4  2007 Eric Seidel <eric@webkit.org>
5 
6  This file is part of the KDE project
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public
10  License as published by the Free Software Foundation; either
11  version 2 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU Library General Public License
19  along with this library; see the file COPYING.LIB. If not, write to
20  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  Boston, MA 02110-1301, USA.
22 */
23 
24 #include "config.h"
25 #include "wtf/Platform.h"
26 
27 #if ENABLE(SVG)
28 #include "SVGAElement.h"
29 
30 /*#include "Attr.h"
31 #include "CSSHelper.h"*/
32 #include "Document.h"
33 /*#include "EventHandler.h"
34 #include "EventNames.h"
35 #include "Frame.h"
36 #include "FrameLoader.h"
37 #include "KeyboardEvent.h"
38 #include "MouseEvent.h"
39 #include "PlatformMouseEvent.h"*/
40 #include "RenderSVGTransformableContainer.h"
41 #include "RenderSVGInline.h"
42 /*#include "ResourceRequest.h"
43 #include "SVGSMILElement.h"*/
44 #include "SVGNames.h"
45 #include "XLinkNames.h"
46 
47 namespace WebCore {
48 
49 //using namespace EventNames;
50 
51 SVGAElement::SVGAElement(const QualifiedName& tagName, Document *doc)
52  : SVGStyledTransformableElement(tagName, doc)
53  , SVGURIReference()
54  , SVGTests()
55  , SVGLangSpace()
56  , SVGExternalResourcesRequired()
57 {
58 }
59 
60 SVGAElement::~SVGAElement()
61 {
62 }
63 
64 String SVGAElement::title() const
65 {
66  return getAttribute(XLinkNames::titleAttr);
67 }
68 
69 ANIMATED_PROPERTY_DEFINITIONS(SVGAElement, String, String, string, Target, target, SVGNames::targetAttr, m_target)
70 
71 void SVGAElement::parseMappedAttribute(MappedAttribute* attr)
72 {
73  if (attr->name() == SVGNames::targetAttr)
74  setTargetBaseValue(attr->value());
75  else {
76  if (SVGURIReference::parseMappedAttribute(attr))
77  return;
78  if (SVGTests::parseMappedAttribute(attr))
79  return;
80  if (SVGLangSpace::parseMappedAttribute(attr))
81  return;
82  if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
83  return;
84  SVGStyledTransformableElement::parseMappedAttribute(attr);
85  }
86 }
87 
88 void SVGAElement::svgAttributeChanged(const QualifiedName& attrName)
89 {
90  SVGStyledTransformableElement::svgAttributeChanged(attrName);
91 
92  // Unlike other SVG*Element classes, SVGAElement only listens to SVGURIReference changes
93  // as none of the other properties changes the linking behaviour for our <a> element.
94  if (SVGURIReference::isKnownAttribute(attrName)) {
95  /*khtml FIXME bool wasLink = m_isLink;
96  m_isLink = !href().isNull();
97 
98  if (wasLink != m_isLink)
99  setChanged();*/
100  }
101 }
102 
103 RenderObject* SVGAElement::createRenderer(RenderArena* arena, RenderStyle* style)
104 {
105  Q_UNUSED(style);
106  if (static_cast<SVGElement*>(parent())->isTextContent())
107  return new (arena) RenderSVGInline(this);
108 
109  return new (arena) RenderSVGTransformableContainer(this);
110 }
111 
112 void SVGAElement::defaultEventHandler(Event* evt)
113 {
114  /*if (m_isLink && (evt->type() == clickEvent || (evt->type() == keydownEvent && m_focused))) {
115  MouseEvent* e = 0;
116  if (evt->type() == clickEvent && evt->isMouseEvent())
117  e = static_cast<MouseEvent*>(evt);
118 
119  KeyboardEvent* k = 0;
120  if (evt->type() == keydownEvent && evt->isKeyboardEvent())
121  k = static_cast<KeyboardEvent*>(evt);
122 
123  if (e && e->button() == RightButton) {
124  SVGStyledTransformableElement::defaultEventHandler(evt);
125  return;
126  }
127 
128  if (k) {
129  if (k->keyIdentifier() != "Enter") {
130  SVGStyledTransformableElement::defaultEventHandler(evt);
131  return;
132  }
133  evt->setDefaultHandled();
134  dispatchSimulatedClick(evt);
135  return;
136  }
137 
138  String target = this->target();
139  if (e && e->button() == MiddleButton)
140  target = "_blank";
141  else if (target.isEmpty()) // if target is empty, default to "_self" or use xlink:target if set
142  target = (getAttribute(XLinkNames::showAttr) == "new") ? "_blank" : "_self";
143 
144  if (!evt->defaultPrevented()) {
145  String url = parseURL(href());
146 #if ENABLE(SVG_ANIMATION)
147  if (url.startsWith("#")) {
148  Element* targetElement = document()->getElementById(url.substring(1));
149  if (SVGSMILElement::isSMILElement(targetElement)) {
150  SVGSMILElement* timed = static_cast<SVGSMILElement*>(targetElement);
151  timed->beginByLinkActivation();
152  evt->setDefaultHandled();
153  SVGStyledTransformableElement::defaultEventHandler(evt);
154  return;
155  }
156  }
157 #endif
158  if (document()->frame())
159  document()->frame()->loader()->urlSelected(document()->completeURL(url), target, evt, false, true);
160  }
161 
162  evt->setDefaultHandled();
163  }*/
164 
165  SVGStyledTransformableElement::defaultEventHandler(evt);
166 }
167 
168 bool SVGAElement::supportsFocus() const
169 {
170  /*if (isContentEditable())
171  return SVGStyledTransformableElement::supportsFocus();*/
172  return isFocusable() || (document() && !document()->haveStylesheetsLoaded());
173 }
174 
175 bool SVGAElement::isFocusableImpl(FocusType ft) const
176 {
177  if (ft == FT_Mouse)
178  return false;
179 
180  if (isContentEditable())
181  return SVGStyledTransformableElement::isFocusableImpl(ft);
182 
183  // TODO: implement focus rules for SVG
184  return false;
185 }
186 
187 bool SVGAElement::childShouldCreateRenderer(Node* child) const
188 {
189  // http://www.w3.org/2003/01/REC-SVG11-20030114-errata#linking-text-environment
190  // The 'a' element may contain any element that its parent may contain, except itself.
191  if (child->hasTagName(SVGNames::aTag))
192  return false;
193  if (parent() && parent()->isSVGElement())
194  return static_cast<SVGElement*>(parent())->childShouldCreateRenderer(child);
195 
196  return SVGElement::childShouldCreateRenderer(child);
197 }
198 
199 } // namespace WebCore
200 
201 #endif // ENABLE(SVG)
SVGAElement.h
WebCore::XLinkNames::titleAttr
DOM::QualifiedName titleAttr
Definition: SVGNames.cpp:16
WebCore::SVGNames::aTag
DOM::QualifiedName aTag
Definition: SVGNames.cpp:21
WebCore::SVGNames::targetAttr
DOM::QualifiedName targetAttr
Definition: SVGNames.cpp:303
SVGNames.h
XLinkNames.h
WebCore::String
DOM::DOMString String
Definition: PlatformString.h:8
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:22 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal