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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 { | 151 { |
151 // Skip the supportsFocus check in SVGElement. | 152 // Skip the supportsFocus check in SVGElement. |
152 return Element::tabIndex(); | 153 return Element::tabIndex(); |
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() || SVGGraphicsElement::supportsFocus(); |
| 162 } |
| 163 |
| 164 bool SVGAElement::shouldHaveFocusAppearance() const |
| 165 { |
| 166 return !m_wasFocusedByMouse || SVGGraphicsElement::supportsFocus(); |
| 167 } |
| 168 |
| 169 bool SVGAElement::wasFocusedByMouse() const |
| 170 { |
| 171 return m_wasFocusedByMouse; |
| 172 } |
| 173 |
| 174 void SVGAElement::setWasFocusedByMouse(bool wasFocusedByMouse) |
| 175 { |
| 176 m_wasFocusedByMouse = wasFocusedByMouse; |
161 } | 177 } |
162 | 178 |
163 bool SVGAElement::isURLAttribute(const Attribute& attribute) const | 179 bool SVGAElement::isURLAttribute(const Attribute& attribute) const |
164 { | 180 { |
165 return attribute.name().localName() == hrefAttr || SVGGraphicsElement::isURL
Attribute(attribute); | 181 return attribute.name().localName() == hrefAttr || SVGGraphicsElement::isURL
Attribute(attribute); |
166 } | 182 } |
167 | 183 |
168 bool SVGAElement::isMouseFocusable() const | 184 bool SVGAElement::isMouseFocusable() const |
169 { | 185 { |
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()) | 186 if (isLink()) |
173 return Element::supportsFocus(); | 187 return supportsFocus(); |
174 | 188 |
175 return SVGElement::isMouseFocusable(); | 189 return SVGElement::isMouseFocusable(); |
176 } | 190 } |
177 | 191 |
178 bool SVGAElement::isKeyboardFocusable() const | 192 bool SVGAElement::isKeyboardFocusable() const |
179 { | 193 { |
180 if (isFocusable() && Element::supportsFocus()) | 194 if (isFocusable() && Element::supportsFocus()) |
181 return SVGElement::isKeyboardFocusable(); | 195 return SVGElement::isKeyboardFocusable(); |
182 | 196 |
183 if (isLink()) | 197 if (isLink()) |
184 return document().frameHost()->chrome().client().tabsToLinks(); | 198 return document().frameHost()->chrome().client().tabsToLinks(); |
185 return SVGElement::isKeyboardFocusable(); | 199 return SVGElement::isKeyboardFocusable(); |
186 } | 200 } |
187 | 201 |
188 bool SVGAElement::canStartSelection() const | 202 bool SVGAElement::canStartSelection() const |
189 { | 203 { |
190 if (!isLink()) | 204 if (!isLink()) |
191 return SVGElement::canStartSelection(); | 205 return SVGElement::canStartSelection(); |
192 return hasEditableStyle(); | 206 return hasEditableStyle(); |
193 } | 207 } |
194 | 208 |
195 bool SVGAElement::willRespondToMouseClickEvents() | 209 bool SVGAElement::willRespondToMouseClickEvents() |
196 { | 210 { |
197 return isLink() || SVGGraphicsElement::willRespondToMouseClickEvents(); | 211 return isLink() || SVGGraphicsElement::willRespondToMouseClickEvents(); |
198 } | 212 } |
199 | 213 |
200 } // namespace blink | 214 } // namespace blink |
OLD | NEW |