From f19304d593c79737b6fb7da338f12f5725a438d7 Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Fri, 4 Sep 2015 10:04:19 -0700 Subject: [PATCH] Bug 1201146 - Introduce "Section" traversal rule. r=yzen --- accessible/jsat/Traversal.jsm | 22 +++++++++++++++++ .../tests/mochitest/jsat/doc_traversal.html | 24 +++++++++++-------- .../mochitest/jsat/test_traversal_helper.html | 4 +++- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/accessible/jsat/Traversal.jsm b/accessible/jsat/Traversal.jsm index 1c4cd82a3bb..cdf5bb6e997 100644 --- a/accessible/jsat/Traversal.jsm +++ b/accessible/jsat/Traversal.jsm @@ -224,6 +224,28 @@ this.TraversalRules = { // jshint ignore:line Filters.IGNORE; }, null, true), + /* A rule for Android's section navigation, lands on landmarks, regions, and + on headings to aid navigation of traditionally structured documents */ + Section: new BaseTraversalRule( + [], + function Section_match(aAccessible) { + if (aAccessible.role === Roles.HEADING) { + return Filters.MATCH; + } + + let matchedRole = Utils.matchRoles(aAccessible, [ + 'banner', + 'complementary', + 'contentinfo', + 'main', + 'navigation', + 'search', + 'region' + ]); + + return matchedRole ? Filters.MATCH : Filters.IGNORE; + }, null, true), + Entry: new BaseTraversalRule( [Roles.ENTRY, Roles.PASSWORD_TEXT]), diff --git a/accessible/tests/mochitest/jsat/doc_traversal.html b/accessible/tests/mochitest/jsat/doc_traversal.html index 3a01cdd1ea3..4c104b6b785 100644 --- a/accessible/tests/mochitest/jsat/doc_traversal.html +++ b/accessible/tests/mochitest/jsat/doc_traversal.html @@ -82,16 +82,20 @@
  • JavaScript
  • -
    The last (visible) one!
    - - stuff - - - Link - Words - Link the second - Sentences - Link the third +
    +
    The last (visible) one!
    + + stuff + +
    +
    + + Link + Words + Link the second + Sentences + Link the third +

    diff --git a/accessible/tests/mochitest/jsat/test_traversal_helper.html b/accessible/tests/mochitest/jsat/test_traversal_helper.html index 4c1ca38ba49..f6a347ed0d6 100644 --- a/accessible/tests/mochitest/jsat/test_traversal_helper.html +++ b/accessible/tests/mochitest/jsat/test_traversal_helper.html @@ -83,7 +83,9 @@ testTraversalHelper('List', ['Programming Language', 'listitem-2-1', 'listitem-3-1']); - vc.position = null; + testTraversalHelper('Section', + ['heading-1', 'heading-2', 'heading-3', + 'heading-5', 'link-1', 'statusbar-1']); SimpleTest.finish(); }