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

Unified Diff: third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp

Issue 1525793002: Fall back to title element text for SVG root text alternatives (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add role=group default for AXSVGRoot Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp
diff --git a/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp b/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp
index 4779e922a80661d2542d87ed64984e55a858fd2c..06fd16150c2db78780ffcbc393f94eda8c3d1f69 100644
--- a/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp
+++ b/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp
@@ -54,6 +54,7 @@
#include "core/html/shadow/MediaControlElements.h"
#include "core/layout/LayoutBlockFlow.h"
#include "core/layout/LayoutObject.h"
+#include "core/svg/SVGElement.h"
#include "modules/accessibility/AXObjectCacheImpl.h"
#include "platform/UserGestureIndicator.h"
#include "platform/text/PlatformLocale.h"
@@ -2377,6 +2378,37 @@ String AXNodeObject::nativeTextAlternative(AXObjectSet& visited, AXNameFrom& nam
return textAlternative;
}
+ // Per SVG AAM 1.0's modifications to 2D of this algorithm.
+ if (node()->isSVGElement()) {
+ nameFrom = AXNameFromRelatedElement;
+ if (nameSources) {
+ nameSources->append(NameSource(*foundTextAlternative));
+ nameSources->last().type = nameFrom;
+ nameSources->last().nativeSource = AXTextFromNativeHTMLTitleElement;
+ }
+ Element* title = nullptr;
+ for (Element& element : ElementTraversal::descendantsOf(*(node()))) {
aboxhall 2016/01/06 17:04:07 Could this be simplified to Element* title = Eleme
Elly Fong-Jones 2016/01/07 18:46:00 Oooh, TIL! Thanks :D
Elly Fong-Jones 2016/01/07 18:46:01 Done.
+ if (element.hasTagName(SVGNames::titleTag)) {
+ title = &element;
+ break;
+ }
+ }
+
+ if (title) {
+ String text = title->innerText();
aboxhall 2016/01/06 17:04:07 This should follow the same pattern used by fields
Elly Fong-Jones 2016/01/07 18:46:00 Done.
+ textAlternative = text;
+ if (nameSources) {
+ NameSource& source = nameSources->last();
+ source.text = textAlternative;
+ *foundTextAlternative = true;
+ } else {
+ return textAlternative;
+ }
+ }
+
+ return textAlternative;
+ }
+
// Fieldset / legend.
if (isHTMLFieldSetElement(node())) {
nameFrom = AXNameFromRelatedElement;

Powered by Google App Engine
This is Rietveld 408576698