Index: chrome/browser/resources/local_ntp/most_visited_util.js |
diff --git a/chrome/browser/resources/local_ntp/most_visited_util.js b/chrome/browser/resources/local_ntp/most_visited_util.js |
index 3c5cee72ee7827da01dc479508cc116676376e2f..06f97bce2c27cc5cea36c76fc92d0489c3b35948 100644 |
--- a/chrome/browser/resources/local_ntp/most_visited_util.js |
+++ b/chrome/browser/resources/local_ntp/most_visited_util.js |
@@ -96,18 +96,29 @@ function parseQueryParams(location) { |
* @param {string} href The destination for the link. |
* @param {string} title The title for the link. |
* @param {string|undefined} text The text for the link or none. |
+ * @param {string|undefined} direction The text direction. |
* @param {string|undefined} provider A provider name (max 8 alphanumeric |
* characters) used for logging. Undefined if suggestion is not coming from |
* the server. |
* @return {HTMLAnchorElement} A new link element. |
*/ |
-function createMostVisitedLink(params, href, title, text, provider) { |
+function createMostVisitedLink(params, href, title, text, direction, provider) { |
var styles = getMostVisitedStyles(params, !!text); |
var link = document.createElement('a'); |
link.style.color = styles.color; |
link.style.fontSize = styles.fontSize + 'px'; |
if (styles.fontFamily) |
link.style.fontFamily = styles.fontFamily; |
+ if (styles.textAlign) |
+ link.style.textAlign = styles.textAlign; |
+ if (styles.textFadePos) { |
+ var dir = /^rtl$/i.test(direction) ? 'to left' : 'to right'; |
+ // The fading length in pixels is passed by the caller. |
+ var mask = 'linear-gradient(' + dir + ', rgba(0,0,0,1), rgba(0,0,0,1) ' + |
+ styles.textFadePos + 'px, rgba(0,0,0,0))'; |
+ link.style.textOverflow = 'clip'; |
+ link.style.webkitMask = mask; |
+ } |
link.href = href; |
link.title = title; |
@@ -152,8 +163,10 @@ function createMostVisitedLink(params, href, title, text, provider) { |
/** |
* Decodes most visited styles from URL parameters. |
- * - f: font-family |
+ * - f: font-family. |
* - fs: font-size as a number in pixels. |
+ * - ta: text-align property, as a string. |
+ * - tf: specifying a text fade starting position, in pixels. |
* - c: A hexadecimal number interpreted as a hex color code. |
* @param {Object.<string, string>} params URL parameters specifying style. |
* @param {boolean} isTitle if the style is for the Most Visited Title. |
@@ -177,6 +190,13 @@ function getMostVisitedStyles(params, isTitle) { |
styles.fontFamily = params.f; |
if ('fs' in params && isFinite(parseInt(params.fs, 10))) |
styles.fontSize = parseInt(params.fs, 10); |
+ if ('ta' in params && /^[-0-9a-zA-Z ,]+$/.test(params.ta)) |
+ styles.textAlign = params.ta; |
+ if ('tf' in params) { |
+ var tf = parseInt(params.tf, 10); |
+ if (isFinite(tf)) |
+ styles.textFadePos = tf; |
+ } |
return styles; |
} |