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

Side by Side Diff: chrome/browser/resources/local_ntp/most_visited_util.js

Issue 544293002: [New Tab Page] Change which elements get focused during tab ordering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: navigateContentWindow on keyDown Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/resources/local_ntp/local_ntp.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 /** 6 /**
7 * @fileoverview Utilities for rendering most visited thumbnails and titles. 7 * @fileoverview Utilities for rendering most visited thumbnails and titles.
8 */ 8 */
9 9
10 <include src="instant_iframe_validation.js"> 10 <include src="instant_iframe_validation.js">
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // The fading length in pixels is passed by the caller. 116 // The fading length in pixels is passed by the caller.
117 var mask = 'linear-gradient(' + dir + ', rgba(0,0,0,1), rgba(0,0,0,1) ' + 117 var mask = 'linear-gradient(' + dir + ', rgba(0,0,0,1), rgba(0,0,0,1) ' +
118 styles.textFadePos + 'px, rgba(0,0,0,0))'; 118 styles.textFadePos + 'px, rgba(0,0,0,0))';
119 link.style.textOverflow = 'clip'; 119 link.style.textOverflow = 'clip';
120 link.style.webkitMask = mask; 120 link.style.webkitMask = mask;
121 } 121 }
122 122
123 link.href = href; 123 link.href = href;
124 link.title = title; 124 link.title = title;
125 link.target = '_top'; 125 link.target = '_top';
126 // Exclude links from the tab order. The tabIndex is added to the thumbnail 126 // Include links in the tab order. The tabIndex is necessary for
127 // parent container instead. 127 // accessibility.
128 link.tabIndex = '-1'; 128 link.tabIndex = '0';
129 if (text) 129 if (text)
130 link.textContent = text; 130 link.textContent = text;
131 link.addEventListener('mouseover', function() { 131 link.addEventListener('mouseover', function() {
132 var ntpApiHandle = chrome.embeddedSearch.newTabPage; 132 var ntpApiHandle = chrome.embeddedSearch.newTabPage;
133 ntpApiHandle.logEvent(NTP_LOGGING_EVENT_TYPE.NTP_MOUSEOVER); 133 ntpApiHandle.logEvent(NTP_LOGGING_EVENT_TYPE.NTP_MOUSEOVER);
134 }); 134 });
135 link.addEventListener('focus', function() {
136 window.parent.postMessage('linkFocused', DOMAIN_ORIGIN);
137 });
138 link.addEventListener('blur', function() {
139 window.parent.postMessage('linkBlurred', DOMAIN_ORIGIN);
140 });
135 141
136 // Webkit's security policy prevents some Most Visited thumbnails from 142 // Webkit's security policy prevents some Most Visited thumbnails from
137 // working (those with schemes different from http and https). Therefore, 143 // working (those with schemes different from http and https). Therefore,
138 // navigateContentWindow is being used in order to get all schemes working. 144 // navigateContentWindow is being used in order to get all schemes working.
139 link.addEventListener('click', function handleNavigation(e) { 145 var navigateFunction = function handleNavigation(e) {
140 var isServerSuggestion = 'url' in params; 146 var isServerSuggestion = 'url' in params;
141 147
142 // Ping are only populated for server-side suggestions, never for MV. 148 // Ping are only populated for server-side suggestions, never for MV.
143 if (isServerSuggestion && params.ping) { 149 if (isServerSuggestion && params.ping) {
144 generatePing(DOMAIN_ORIGIN + params.ping); 150 generatePing(DOMAIN_ORIGIN + params.ping);
145 } 151 }
146 152
147 var ntpApiHandle = chrome.embeddedSearch.newTabPage; 153 var ntpApiHandle = chrome.embeddedSearch.newTabPage;
148 if ('pos' in params && isFinite(params.pos)) { 154 if ('pos' in params && isFinite(params.pos)) {
149 ntpApiHandle.logMostVisitedNavigation(parseInt(params.pos, 10), 155 ntpApiHandle.logMostVisitedNavigation(parseInt(params.pos, 10),
150 provider || ''); 156 provider || '');
151 } 157 }
152 158
153 if (!isServerSuggestion) { 159 if (!isServerSuggestion) {
154 e.preventDefault(); 160 e.preventDefault();
155 ntpApiHandle.navigateContentWindow(href, getDispositionFromEvent(e)); 161 ntpApiHandle.navigateContentWindow(href, getDispositionFromEvent(e));
156 } 162 }
157 // Else follow <a> normally, so transition type would be LINK. 163 // Else follow <a> normally, so transition type would be LINK.
164 };
165
166 link.addEventListener('click', navigateFunction);
167 link.addEventListener('keydown', function(event) {
168 if (event.keyCode == 46 /* DELETE */ ||
169 event.keyCode == 8 /* BACKSPACE */) {
170 event.preventDefault();
171 window.parent.postMessage('tileBlacklisted,' + params.pos, DOMAIN_ORIGIN);
172 } else if (event.keyCode == 13 /* ENTER */) {
dmazzoni 2014/09/11 20:33:14 Handle both space and enter here?
Mathieu 2014/09/11 20:54:10 Done.
173 navigateFunction(event);
174 }
158 }); 175 });
159 176
160 return link; 177 return link;
161 } 178 }
162 179
163 180
164 /** 181 /**
165 * Returns the color to display string with, depending on whether title is 182 * Returns the color to display string with, depending on whether title is
166 * displayed, the current theme, and URL parameters. 183 * displayed, the current theme, and URL parameters.
167 * @param {Object.<string, string>} params URL parameters specifying style. 184 * @param {Object.<string, string>} params URL parameters specifying style.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 if (navigator.sendBeacon) { 295 if (navigator.sendBeacon) {
279 navigator.sendBeacon(url); 296 navigator.sendBeacon(url);
280 } else { 297 } else {
281 // if sendBeacon is not enabled, we fallback for "a ping". 298 // if sendBeacon is not enabled, we fallback for "a ping".
282 var a = document.createElement('a'); 299 var a = document.createElement('a');
283 a.href = '#'; 300 a.href = '#';
284 a.ping = url; 301 a.ping = url;
285 a.click(); 302 a.click();
286 } 303 }
287 } 304 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/local_ntp/local_ntp.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698