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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 #include "platform/network/ResourceRequest.h" | 50 #include "platform/network/ResourceRequest.h" |
51 | 51 |
52 namespace blink { | 52 namespace blink { |
53 | 53 |
54 using namespace HTMLNames; | 54 using namespace HTMLNames; |
55 | 55 |
56 inline SVGAElement::SVGAElement(Document& document) | 56 inline SVGAElement::SVGAElement(Document& document) |
57 : SVGGraphicsElement(SVGNames::aTag, document) | 57 : SVGGraphicsElement(SVGNames::aTag, document) |
58 , SVGURIReference(this) | 58 , SVGURIReference(this) |
59 , m_svgTarget(SVGAnimatedString::create(this, SVGNames::targetAttr, SVGStrin g::create())) | 59 , m_svgTarget(SVGAnimatedString::create(this, SVGNames::targetAttr, SVGStrin g::create())) |
60 , m_wasFocusedByMouse(false) | |
60 { | 61 { |
61 ScriptWrappable::init(this); | 62 ScriptWrappable::init(this); |
62 addToPropertyMap(m_svgTarget); | 63 addToPropertyMap(m_svgTarget); |
63 } | 64 } |
64 | 65 |
65 DEFINE_NODE_FACTORY(SVGAElement) | 66 DEFINE_NODE_FACTORY(SVGAElement) |
66 | 67 |
67 String SVGAElement::title() const | 68 String SVGAElement::title() const |
68 { | 69 { |
69 // If the xlink:title is set (non-empty string), use it. | 70 // If the xlink:title is set (non-empty string), use it. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 } | 154 } |
154 | 155 |
155 bool SVGAElement::supportsFocus() const | 156 bool SVGAElement::supportsFocus() const |
156 { | 157 { |
157 if (hasEditableStyle()) | 158 if (hasEditableStyle()) |
158 return SVGGraphicsElement::supportsFocus(); | 159 return SVGGraphicsElement::supportsFocus(); |
159 // If not a link we should still be able to focus the element if it has tabI ndex. | 160 // If not a link we should still be able to focus the element if it has tabI ndex. |
160 return isLink() || Element::supportsFocus(); | 161 return isLink() || Element::supportsFocus(); |
161 } | 162 } |
162 | 163 |
164 bool SVGAElement::shouldHaveFocusAppearance() const | |
165 { | |
166 ASSERT(focused()); | |
167 return !m_wasFocusedByMouse || Element::supportsFocus(); | |
pdr.
2014/08/10 20:21:52
This should be SVGElement::supportsFocus();
robwu
2014/08/10 23:37:19
Neither of the two, it should be SVGGraphicsElemen
| |
168 } | |
169 | |
170 void SVGAElement::dispatchFocusEvent(Element* oldFocusedElement, FocusType type) | |
171 { | |
172 if (type != FocusTypePage) | |
173 m_wasFocusedByMouse = type == FocusTypeMouse; | |
174 Element::dispatchFocusEvent(oldFocusedElement, type); | |
175 } | |
176 | |
177 void SVGAElement::willCallDefaultEventHandler(const Event& event) | |
178 { | |
179 if (!event.isKeyboardEvent() || event.type() != EventTypeNames::keydown) | |
180 return; | |
181 if (!m_wasFocusedByMouse) | |
182 return; | |
183 m_wasFocusedByMouse = false; | |
184 } | |
185 | |
163 bool SVGAElement::isURLAttribute(const Attribute& attribute) const | 186 bool SVGAElement::isURLAttribute(const Attribute& attribute) const |
164 { | 187 { |
165 return attribute.name().localName() == hrefAttr || SVGGraphicsElement::isURL Attribute(attribute); | 188 return attribute.name().localName() == hrefAttr || SVGGraphicsElement::isURL Attribute(attribute); |
166 } | 189 } |
167 | 190 |
168 bool SVGAElement::isMouseFocusable() const | 191 bool SVGAElement::isMouseFocusable() const |
169 { | 192 { |
170 // Links are focusable by default, but only allow links with tabindex or con tenteditable to be mouse focusable. | |
171 // https://bugs.webkit.org/show_bug.cgi?id=26856 | |
172 if (isLink()) | 193 if (isLink()) |
173 return Element::supportsFocus(); | 194 return supportsFocus(); |
174 | 195 |
175 return SVGElement::isMouseFocusable(); | 196 return SVGElement::isMouseFocusable(); |
176 } | 197 } |
177 | 198 |
178 bool SVGAElement::isKeyboardFocusable() const | 199 bool SVGAElement::isKeyboardFocusable() const |
179 { | 200 { |
180 if (isFocusable() && Element::supportsFocus()) | 201 if (isFocusable() && Element::supportsFocus()) |
181 return SVGElement::isKeyboardFocusable(); | 202 return SVGElement::isKeyboardFocusable(); |
182 | 203 |
183 if (isLink()) | 204 if (isLink()) |
184 return document().frameHost()->chrome().client().tabsToLinks(); | 205 return document().frameHost()->chrome().client().tabsToLinks(); |
185 return SVGElement::isKeyboardFocusable(); | 206 return SVGElement::isKeyboardFocusable(); |
186 } | 207 } |
187 | 208 |
188 bool SVGAElement::canStartSelection() const | 209 bool SVGAElement::canStartSelection() const |
189 { | 210 { |
190 if (!isLink()) | 211 if (!isLink()) |
191 return SVGElement::canStartSelection(); | 212 return SVGElement::canStartSelection(); |
192 return hasEditableStyle(); | 213 return hasEditableStyle(); |
193 } | 214 } |
194 | 215 |
195 bool SVGAElement::willRespondToMouseClickEvents() | 216 bool SVGAElement::willRespondToMouseClickEvents() |
196 { | 217 { |
197 return isLink() || SVGGraphicsElement::willRespondToMouseClickEvents(); | 218 return isLink() || SVGGraphicsElement::willRespondToMouseClickEvents(); |
198 } | 219 } |
199 | 220 |
200 } // namespace blink | 221 } // namespace blink |
OLD | NEW |