Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: Source/core/svg/SVGElement.cpp

Issue 166163005: [SVG2] Add tabindex handling in svg. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/svg/SVGElement.h ('k') | Source/core/svg/SVGElement.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org> 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org>
3 * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org>
4 * Copyright (C) 2008 Apple Inc. All rights reserved. 4 * Copyright (C) 2008 Apple Inc. All rights reserved.
5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
6 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 6 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 18 matching lines...) Expand all
29 #include "SVGNames.h" 29 #include "SVGNames.h"
30 #include "XLinkNames.h" 30 #include "XLinkNames.h"
31 #include "XMLNames.h" 31 #include "XMLNames.h"
32 #include "bindings/v8/ScriptEventListener.h" 32 #include "bindings/v8/ScriptEventListener.h"
33 #include "core/css/CSSCursorImageValue.h" 33 #include "core/css/CSSCursorImageValue.h"
34 #include "core/css/parser/BisonCSSParser.h" 34 #include "core/css/parser/BisonCSSParser.h"
35 #include "core/dom/Document.h" 35 #include "core/dom/Document.h"
36 #include "core/dom/ElementTraversal.h" 36 #include "core/dom/ElementTraversal.h"
37 #include "core/dom/shadow/ShadowRoot.h" 37 #include "core/dom/shadow/ShadowRoot.h"
38 #include "core/events/Event.h" 38 #include "core/events/Event.h"
39 #include "core/frame/Settings.h"
39 #include "core/html/HTMLElement.h" 40 #include "core/html/HTMLElement.h"
40 #include "core/rendering/RenderObject.h" 41 #include "core/rendering/RenderObject.h"
41 #include "core/rendering/svg/RenderSVGResourceContainer.h" 42 #include "core/rendering/svg/RenderSVGResourceContainer.h"
42 #include "core/svg/SVGCursorElement.h" 43 #include "core/svg/SVGCursorElement.h"
43 #include "core/svg/SVGDocumentExtensions.h" 44 #include "core/svg/SVGDocumentExtensions.h"
44 #include "core/svg/SVGElementInstance.h" 45 #include "core/svg/SVGElementInstance.h"
45 #include "core/svg/SVGElementRareData.h" 46 #include "core/svg/SVGElementRareData.h"
46 #include "core/svg/SVGGraphicsElement.h" 47 #include "core/svg/SVGGraphicsElement.h"
47 #include "core/svg/SVGSVGElement.h" 48 #include "core/svg/SVGSVGElement.h"
48 #include "core/svg/SVGTitleElement.h" 49 #include "core/svg/SVGTitleElement.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 clearHasSVGRareData(); 116 clearHasSVGRareData();
116 } 117 }
117 118
118 // With Oilpan, either removedFrom has been called or the document is dead 119 // With Oilpan, either removedFrom has been called or the document is dead
119 // as well and there is no reason to clear out the extensions. 120 // as well and there is no reason to clear out the extensions.
120 document().accessSVGExtensions().rebuildAllElementReferencesForTarget(this); 121 document().accessSVGExtensions().rebuildAllElementReferencesForTarget(this);
121 document().accessSVGExtensions().removeAllElementReferencesForTarget(this); 122 document().accessSVGExtensions().removeAllElementReferencesForTarget(this);
122 #endif 123 #endif
123 } 124 }
124 125
126 short SVGElement::tabIndex() const
127 {
128 if (supportsFocus())
129 return Element::tabIndex();
130 return -1;
131 }
132
125 void SVGElement::willRecalcStyle(StyleRecalcChange change) 133 void SVGElement::willRecalcStyle(StyleRecalcChange change)
126 { 134 {
127 if (!hasSVGRareData()) 135 if (!hasSVGRareData())
128 return; 136 return;
129 // If the style changes because of a regular property change (not induced by SMIL animations themselves) 137 // If the style changes because of a regular property change (not induced by SMIL animations themselves)
130 // reset the "computed style without SMIL style properties", so the base val ue change gets reflected. 138 // reset the "computed style without SMIL style properties", so the base val ue change gets reflected.
131 if (change > NoChange || needsStyleRecalc()) 139 if (change > NoChange || needsStyleRecalc())
132 svgRareData()->setNeedsOverrideComputedStyleUpdate(); 140 svgRareData()->setNeedsOverrideComputedStyleUpdate();
133 } 141 }
134 142
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 ensureSVGRareData()->setCorrespondingElement(correspondingElement); 618 ensureSVGRareData()->setCorrespondingElement(correspondingElement);
611 } 619 }
612 620
613 bool SVGElement::inUseShadowTree() const 621 bool SVGElement::inUseShadowTree() const
614 { 622 {
615 if (ShadowRoot* root = containingShadowRoot()) 623 if (ShadowRoot* root = containingShadowRoot())
616 return isSVGUseElement(root->host()) && (root->type() == ShadowRoot::Use rAgentShadowRoot); 624 return isSVGUseElement(root->host()) && (root->type() == ShadowRoot::Use rAgentShadowRoot);
617 return false; 625 return false;
618 } 626 }
619 627
628 bool SVGElement::supportsSpatialNavigationFocus() const
629 {
630 // This function checks whether the element satisfies the extended criteria
631 // for the element to be focusable, introduced by spatial navigation feature ,
632 // i.e. checks if click or keyboard event handler is specified.
633 // This is the way to make it possible to navigate to (focus) elements
634 // which web designer meant for being active (made them respond to click eve nts).
635
636 if (!document().settings() || !document().settings()->spatialNavigationEnabl ed())
637 return false;
638 return hasEventListeners(EventTypeNames::click)
639 || hasEventListeners(EventTypeNames::keydown)
640 || hasEventListeners(EventTypeNames::keypress)
641 || hasEventListeners(EventTypeNames::keyup)
642 || hasEventListeners(EventTypeNames::focus)
643 || hasEventListeners(EventTypeNames::blur)
644 || hasEventListeners(EventTypeNames::focusin)
645 || hasEventListeners(EventTypeNames::focusout);
646 }
647
620 void SVGElement::parseAttribute(const QualifiedName& name, const AtomicString& v alue) 648 void SVGElement::parseAttribute(const QualifiedName& name, const AtomicString& v alue)
621 { 649 {
622 if (name == HTMLNames::classAttr) { 650 if (name == HTMLNames::classAttr) {
623 // SVG animation has currently requires special storage of values so we set 651 // SVG animation has currently requires special storage of values so we set
624 // the className here. svgAttributeChanged actually causes the resulting 652 // the className here. svgAttributeChanged actually causes the resulting
625 // style updates (instead of Element::parseAttribute). We don't 653 // style updates (instead of Element::parseAttribute). We don't
626 // tell Element about the change to avoid parsing the class list twice 654 // tell Element about the change to avoid parsing the class list twice
627 SVGParsingError parseError = NoError; 655 SVGParsingError parseError = NoError;
628 m_className->setBaseValueAsString(value, parseError); 656 m_className->setBaseValueAsString(value, parseError);
629 reportAttributeParsingError(parseError, name, value); 657 reportAttributeParsingError(parseError, name, value);
630 } else if (name.matches(XMLNames::langAttr) || name.matches(XMLNames::spaceA ttr)) { 658 } else if (name.matches(XMLNames::langAttr) || name.matches(XMLNames::spaceA ttr)) {
659 } else if (name == tabindexAttr) {
660 Element::parseAttribute(name, value);
631 } else { 661 } else {
632 // standard events 662 // standard events
633 const AtomicString& eventName = HTMLElement::eventNameForAttributeName(n ame); 663 const AtomicString& eventName = HTMLElement::eventNameForAttributeName(n ame);
634 if (!eventName.isNull()) 664 if (!eventName.isNull())
635 setAttributeEventListener(eventName, createAttributeEventListener(th is, name, value)); 665 setAttributeEventListener(eventName, createAttributeEventListener(th is, name, value));
636 else 666 else
637 Element::parseAttribute(name, value); 667 Element::parseAttribute(name, value);
638 } 668 }
639 } 669 }
640 670
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 if (Element* parent = parentOrShadowHostElement()) { 1031 if (Element* parent = parentOrShadowHostElement()) {
1002 if (RenderObject* renderer = parent->renderer()) 1032 if (RenderObject* renderer = parent->renderer())
1003 parentStyle = renderer->style(); 1033 parentStyle = renderer->style();
1004 } 1034 }
1005 1035
1006 return svgRareData()->overrideComputedStyle(this, parentStyle); 1036 return svgRareData()->overrideComputedStyle(this, parentStyle);
1007 } 1037 }
1008 1038
1009 bool SVGElement::hasFocusEventListeners() const 1039 bool SVGElement::hasFocusEventListeners() const
1010 { 1040 {
1011 return hasEventListeners(EventTypeNames::focusin) || hasEventListeners(Event TypeNames::focusout); 1041 return hasEventListeners(EventTypeNames::focusin) || hasEventListeners(Event TypeNames::focusout)
1012 } 1042 || hasEventListeners(EventTypeNames::focus) || hasEventListeners(EventTy peNames::blur);
1013
1014 bool SVGElement::isKeyboardFocusable() const
1015 {
1016 return isFocusable();
1017 } 1043 }
1018 1044
1019 #ifndef NDEBUG 1045 #ifndef NDEBUG
1020 bool SVGElement::isAnimatableAttribute(const QualifiedName& name) const 1046 bool SVGElement::isAnimatableAttribute(const QualifiedName& name) const
1021 { 1047 {
1022 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, animatableAttributes, ()); 1048 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, animatableAttributes, ());
1023 1049
1024 if (animatableAttributes.isEmpty()) { 1050 if (animatableAttributes.isEmpty()) {
1025 animatableAttributes.add(XLinkNames::hrefAttr); 1051 animatableAttributes.add(XLinkNames::hrefAttr);
1026 animatableAttributes.add(SVGNames::amplitudeAttr); 1052 animatableAttributes.add(SVGNames::amplitudeAttr);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 animatableAttributes.add(SVGNames::zAttr); 1142 animatableAttributes.add(SVGNames::zAttr);
1117 } 1143 }
1118 1144
1119 if (name == classAttr) 1145 if (name == classAttr)
1120 return true; 1146 return true;
1121 1147
1122 return animatableAttributes.contains(name); 1148 return animatableAttributes.contains(name);
1123 } 1149 }
1124 #endif 1150 #endif
1125 } 1151 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGElement.h ('k') | Source/core/svg/SVGElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698