OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
5 * Copyright (C) 2010 Apple Inc. All rights reserved. | 5 * Copyright (C) 2010 Apple Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 using namespace HTMLNames; | 55 using namespace HTMLNames; |
56 | 56 |
57 // Animated property definitions | 57 // Animated property definitions |
58 | 58 |
59 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGAElement) | 59 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGAElement) |
60 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) | 60 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) |
61 END_REGISTER_ANIMATED_PROPERTIES | 61 END_REGISTER_ANIMATED_PROPERTIES |
62 | 62 |
63 inline SVGAElement::SVGAElement(Document& document) | 63 inline SVGAElement::SVGAElement(Document& document) |
64 : SVGGraphicsElement(SVGNames::aTag, document) | 64 : SVGGraphicsElement(SVGNames::aTag, document) |
| 65 , SVGURIReference(this) |
65 , m_svgTarget(SVGAnimatedString::create(this, SVGNames::targetAttr, SVGStrin
g::create())) | 66 , m_svgTarget(SVGAnimatedString::create(this, SVGNames::targetAttr, SVGStrin
g::create())) |
66 , m_href(SVGAnimatedString::create(this, XLinkNames::hrefAttr, SVGString::cr
eate())) | |
67 { | 67 { |
68 ScriptWrappable::init(this); | 68 ScriptWrappable::init(this); |
69 addToPropertyMap(m_svgTarget); | 69 addToPropertyMap(m_svgTarget); |
70 addToPropertyMap(m_href); | |
71 registerAnimatedPropertiesForSVGAElement(); | 70 registerAnimatedPropertiesForSVGAElement(); |
72 } | 71 } |
73 | 72 |
74 PassRefPtr<SVGAElement> SVGAElement::create(Document& document) | 73 PassRefPtr<SVGAElement> SVGAElement::create(Document& document) |
75 { | 74 { |
76 return adoptRef(new SVGAElement(document)); | 75 return adoptRef(new SVGAElement(document)); |
77 } | 76 } |
78 | 77 |
79 String SVGAElement::title() const | 78 String SVGAElement::title() const |
80 { | 79 { |
(...skipping 18 matching lines...) Expand all Loading... |
99 | 98 |
100 void SVGAElement::parseAttribute(const QualifiedName& name, const AtomicString&
value) | 99 void SVGAElement::parseAttribute(const QualifiedName& name, const AtomicString&
value) |
101 { | 100 { |
102 if (!isSupportedAttribute(name)) { | 101 if (!isSupportedAttribute(name)) { |
103 SVGGraphicsElement::parseAttribute(name, value); | 102 SVGGraphicsElement::parseAttribute(name, value); |
104 return; | 103 return; |
105 } | 104 } |
106 | 105 |
107 SVGParsingError parseError = NoError; | 106 SVGParsingError parseError = NoError; |
108 | 107 |
109 if (name == SVGNames::targetAttr) | 108 if (name == SVGNames::targetAttr) { |
110 m_svgTarget->setBaseValueAsString(value, parseError); | 109 m_svgTarget->setBaseValueAsString(value, parseError); |
111 else if (name.matches(XLinkNames::hrefAttr)) | 110 } else if (SVGURIReference::parseAttribute(name, value, parseError)) { |
112 m_href->setBaseValueAsString(value, parseError); | 111 } else { |
113 else | |
114 ASSERT_NOT_REACHED(); | 112 ASSERT_NOT_REACHED(); |
| 113 } |
115 | 114 |
116 reportAttributeParsingError(parseError, name, value); | 115 reportAttributeParsingError(parseError, name, value); |
117 } | 116 } |
118 | 117 |
119 void SVGAElement::svgAttributeChanged(const QualifiedName& attrName) | 118 void SVGAElement::svgAttributeChanged(const QualifiedName& attrName) |
120 { | 119 { |
121 if (!isSupportedAttribute(attrName)) { | 120 if (!isSupportedAttribute(attrName)) { |
122 SVGGraphicsElement::svgAttributeChanged(attrName); | 121 SVGGraphicsElement::svgAttributeChanged(attrName); |
123 return; | 122 return; |
124 } | 123 } |
125 | 124 |
126 SVGElementInstance::InvalidationGuard invalidationGuard(this); | 125 SVGElementInstance::InvalidationGuard invalidationGuard(this); |
127 | 126 |
128 // Unlike other SVG*Element classes, SVGAElement only listens to SVGURIRefer
ence changes | 127 // Unlike other SVG*Element classes, SVGAElement only listens to SVGURIRefer
ence changes |
129 // as none of the other properties changes the linking behaviour for our <a>
element. | 128 // as none of the other properties changes the linking behaviour for our <a>
element. |
130 if (SVGURIReference::isKnownAttribute(attrName)) { | 129 if (SVGURIReference::isKnownAttribute(attrName)) { |
131 bool wasLink = isLink(); | 130 bool wasLink = isLink(); |
132 setIsLink(!m_href->currentValue()->value().isNull()); | 131 setIsLink(!hrefString().isNull()); |
133 | 132 |
134 if (wasLink != isLink()) | 133 if (wasLink != isLink()) |
135 setNeedsStyleRecalc(SubtreeStyleChange); | 134 setNeedsStyleRecalc(SubtreeStyleChange); |
136 } | 135 } |
137 } | 136 } |
138 | 137 |
139 RenderObject* SVGAElement::createRenderer(RenderStyle*) | 138 RenderObject* SVGAElement::createRenderer(RenderStyle*) |
140 { | 139 { |
141 if (parentNode() && parentNode()->isSVGElement() && toSVGElement(parentNode(
))->isTextContent()) | 140 if (parentNode() && parentNode()->isSVGElement() && toSVGElement(parentNode(
))->isTextContent()) |
142 return new RenderSVGInline(this); | 141 return new RenderSVGInline(this); |
143 | 142 |
144 return new RenderSVGTransformableContainer(this); | 143 return new RenderSVGTransformableContainer(this); |
145 } | 144 } |
146 | 145 |
147 void SVGAElement::defaultEventHandler(Event* event) | 146 void SVGAElement::defaultEventHandler(Event* event) |
148 { | 147 { |
149 if (isLink()) { | 148 if (isLink()) { |
150 if (focused() && isEnterKeyKeydownEvent(event)) { | 149 if (focused() && isEnterKeyKeydownEvent(event)) { |
151 event->setDefaultHandled(); | 150 event->setDefaultHandled(); |
152 dispatchSimulatedClick(event); | 151 dispatchSimulatedClick(event); |
153 return; | 152 return; |
154 } | 153 } |
155 | 154 |
156 if (isLinkClick(event)) { | 155 if (isLinkClick(event)) { |
157 String url = stripLeadingAndTrailingHTMLSpaces(m_href->currentValue(
)->value()); | 156 String url = stripLeadingAndTrailingHTMLSpaces(hrefString()); |
158 | 157 |
159 if (url[0] == '#') { | 158 if (url[0] == '#') { |
160 Element* targetElement = treeScope().getElementById(AtomicString
(url.substring(1))); | 159 Element* targetElement = treeScope().getElementById(AtomicString
(url.substring(1))); |
161 if (targetElement && isSVGSMILElement(*targetElement)) { | 160 if (targetElement && isSVGSMILElement(*targetElement)) { |
162 toSVGSMILElement(targetElement)->beginByLinkActivation(); | 161 toSVGSMILElement(targetElement)->beginByLinkActivation(); |
163 event->setDefaultHandled(); | 162 event->setDefaultHandled(); |
164 return; | 163 return; |
165 } | 164 } |
166 // Only allow navigation to internal <view> anchors. | 165 // Only allow navigation to internal <view> anchors. |
167 if (targetElement && !targetElement->hasTagName(SVGNames::viewTa
g)) | 166 if (targetElement && !targetElement->hasTagName(SVGNames::viewTa
g)) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 return page->chrome().client().tabsToLinks(); | 211 return page->chrome().client().tabsToLinks(); |
213 return false; | 212 return false; |
214 } | 213 } |
215 | 214 |
216 bool SVGAElement::willRespondToMouseClickEvents() | 215 bool SVGAElement::willRespondToMouseClickEvents() |
217 { | 216 { |
218 return isLink() || SVGGraphicsElement::willRespondToMouseClickEvents(); | 217 return isLink() || SVGGraphicsElement::willRespondToMouseClickEvents(); |
219 } | 218 } |
220 | 219 |
221 } // namespace WebCore | 220 } // namespace WebCore |
OLD | NEW |