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

Unified Diff: chrome/browser/resources/ntp_android/ntp_android.js

Issue 11155022: Fix accessibility issues on most visited page for android's NTP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/ntp_android/ntp_android.js
diff --git a/chrome/browser/resources/ntp_android/ntp_android.js b/chrome/browser/resources/ntp_android/ntp_android.js
index 34b954dfb5c2cb9e4d779ebdff188b533e4f6c8c..9e223696282480d633746f0eea5ab2c5504aa9b1 100644
--- a/chrome/browser/resources/ntp_android/ntp_android.js
+++ b/chrome/browser/resources/ntp_android/ntp_android.js
@@ -325,6 +325,12 @@ cr.define('ntp', function() {
var syncEnabled = undefined;
/**
+ * The current most visited data being displayed.
+ * @type {Array.<Object>}
+ */
+ var mostVisitedData_ = [];
+
+ /**
* The current bookmark data being displayed. Keep a reference to this data
* in case the sync enabled state changes. In this case, the bookmark data
* will need to be refiltered.
@@ -655,10 +661,11 @@ cr.define('ntp', function() {
var title = createDiv('title');
title.textContent = item.title;
var spacerImg = createElement('img', 'title-spacer');
+ spacerImg.alt = '';
title.insertBefore(spacerImg, title.firstChild);
thumbnailCell.appendChild(title);
- wrapClickHandler(thumbnailContainer, item, opt_clickCallback);
+ wrapClickHandler(thumbnailCell, item, opt_clickCallback);
thumbnailCell.setAttribute(CONTEXT_MENU_URL_KEY, item.url);
thumbnailCell.contextMenuItem = item;
@@ -910,6 +917,9 @@ cr.define('ntp', function() {
data.splice(8, data.length - 8);
}
+ if (equals(data, mostVisitedData_))
+ return;
+
var clickFunction = function(item) {
chrome.send('metricsHandler:recordAction', ['MobileNTPMostVisited']);
window.location = item.url;
@@ -917,6 +927,8 @@ cr.define('ntp', function() {
populateData(findList('most_visited'), SectionType.MOST_VISITED, data,
makeMostVisitedItem, clickFunction);
computeDynamicLayout();
+
+ mostVisitedData_ = data;
}
/**
@@ -2490,6 +2502,31 @@ cr.define('ntp', function() {
/////////////////////////////////////////////////////////////////////////////
/**
+ * A best effort approach for checking simple data object equality.
+ * @param {?} val1 The first value to check equality for.
+ * @param {?} val2 The second value to check equality for.
+ * @return {boolean} Whether the two objects are equal(ish).
+ */
+function equals(val1, val2) {
+ if (typeof val1 != 'object' || typeof val2 != 'object')
+ return val1 === val2;
+
+ // Object and array equality checks.
+ var keyCountVal1 = 0;
+ for (var key in val1) {
+ if (!(key in val2) || !equals(val1[key], val2[key]))
+ return false;
+ keyCountVal1++;
+ }
+ var keyCountVal2 = 0;
+ for (var key in val2)
+ keyCountVal2++;
+ if (keyCountVal1 != keyCountVal2)
+ return false;
+ return true;
+}
+
+/**
* Alias for document.getElementById.
* @param {string} id The ID of the element to find.
* @return {HTMLElement} The found element or null if not found.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698