Commit 0e90425c authored by tsergeant's avatar tsergeant Committed by Commit bot

MD History: Announce search results for screen-reader users

This adds a screen reader announcement of "Found X search results for
'Y'" when the user performs a search.

BUG=425625,606527
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2388413002
Cr-Commit-Position: refs/heads/master@{#423062}
parent 3bf22912
......@@ -289,18 +289,16 @@ cr.define('md_history', function() {
},
/**
* Generates the title for this history card.
* @param {number} numberOfItems The number of items in the card.
* @param {string} historyDate Date of the current result.
* @param {string} search The search term associated with these results.
* @return {string} The title for this history card.
* @private
*/
cardTitle_: function(numberOfItems, historyDate, search) {
if (!search)
return this.item.dateRelativeDay;
var resultId = numberOfItems == 1 ? 'searchResult' : 'searchResults';
return loadTimeData.getStringF('foundSearchResults', numberOfItems,
loadTimeData.getString(resultId), search);
return HistoryItem.searchResultsTitle(numberOfItems, search);
},
});
......@@ -311,7 +309,6 @@ cr.define('md_history', function() {
* @param {number} currentIndex
* @param {string} searchedTerm
* @return {boolean} Whether or not time gap separator is required.
* @private
*/
HistoryItem.needsTimeGap = function(visits, currentIndex, searchedTerm) {
if (currentIndex >= visits.length - 1 || visits.length == 0)
......@@ -327,5 +324,16 @@ cr.define('md_history', function() {
currentItem.dateRelativeDay == nextItem.dateRelativeDay;
};
/**
* @param {number} numberOfResults
* @param {string} searchTerm
* @return {string} The title for a page of search results.
*/
HistoryItem.searchResultsTitle = function(numberOfResults, searchTerm) {
var resultId = numberOfResults == 1 ? 'searchResult' : 'searchResults';
return loadTimeData.getStringF('foundSearchResults', numberOfResults,
loadTimeData.getString(resultId), searchTerm);
};
return { HistoryItem: HistoryItem };
});
......@@ -41,6 +41,11 @@ Polymer({
this.initializeResults_(info, results);
this.closeMenu_();
if (info.term && !this.queryState.incremental) {
announceAccessibleMessage(
md_history.HistoryItem.searchResultsTitle(results.length, info.term));
}
if (this.selectedPage_ == 'grouped-list') {
this.$$('#grouped-list').historyData = results;
return;
......
......@@ -35,7 +35,7 @@ function getSVGElement(id) {
function announceAccessibleMessage(msg) {
var element = document.createElement('div');
element.setAttribute('aria-live', 'polite');
element.style.position = 'relative';
element.style.position = 'fixed';
element.style.left = '-9999px';
element.style.height = '0px';
element.innerText = msg;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment