Skip to content

Commit

Permalink
Don't use role="math" for non-MathML math tags
Browse files Browse the repository at this point in the history
AXNodeObject::NativeRoleIgnoringAria() currently uses role "math" for
elements whose tag name is "math", even when they are not in the MathML
namespace e.g. elements constructed by JavaScript calls like
document.createElementNS("https://example.com/namespace", "math"). The
specification is not really explicit about namespaces [1] but it seems
that the intention is to handle the normal case (math tag in the
MathML namespace). This CL restricts default "math" role accordingly
and adds a test for this and similar cases with the svg tag name.

[1] w3c/html-aam#344

AX-Relnotes: <math> tags in non-MathML namespaces no longer have role
"math" by default. Users should use an explicit attribute instead.

Bug: 6606, 1038895, 1051115
Change-Id: Ifee04f4bbbd96b86686422bc0b0f99bf4cbaf54b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3168497
Reviewed-by: Nektarios Paisios <[email protected]>
Commit-Queue: Frédéric Wang <[email protected]>
Cr-Commit-Position: refs/heads/main@{#923328}
NOKEYCHECK=True
GitOrigin-RevId: e929ccd6402c234b3456692a2a05d76edf72bb3a
  • Loading branch information
fred-wang authored and copybara-github committed Sep 21, 2021
1 parent bdfec98 commit 935f67c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion blink/renderer/modules/accessibility/ax_node_object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
#include "third_party/blink/renderer/core/layout/ng/inline/ng_inline_node.h"
#include "third_party/blink/renderer/core/layout/ng/inline/ng_offset_mapping.h"
#include "third_party/blink/renderer/core/loader/progress_tracker.h"
#include "third_party/blink/renderer/core/mathml/mathml_element.h"
#include "third_party/blink/renderer/core/mathml_names.h"
#include "third_party/blink/renderer/core/page/focus_controller.h"
#include "third_party/blink/renderer/core/page/page.h"
Expand Down Expand Up @@ -1002,7 +1003,7 @@ ax::mojom::blink::Role AXNodeObject::NativeRoleIgnoringAria() const {
if (GetNode()->HasTagName(html_names::kDtTag))
return ax::mojom::blink::Role::kDescriptionListTerm;

if (GetNode()->nodeName() == mathml_names::kMathTag.LocalName())
if (GetNode()->HasTagName(mathml_names::kMathTag))
return ax::mojom::blink::Role::kMath;

if (GetNode()->HasTagName(html_names::kRpTag) ||
Expand Down

0 comments on commit 935f67c

Please sign in to comment.