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

Unified Diff: components/dom_distiller/content/resources/dom_distiller_viewer.js

Issue 430473007: Font Family Preferences for Distilled Pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
Index: components/dom_distiller/content/resources/dom_distiller_viewer.js
diff --git a/components/dom_distiller/content/resources/dom_distiller_viewer.js b/components/dom_distiller/content/resources/dom_distiller_viewer.js
index 94299467ef3df0b6ffa129f1ee149d008e58eec8..1c8b081725a7d81810f0ff9f8c1fb07bb5c36481 100644
--- a/components/dom_distiller/content/resources/dom_distiller_viewer.js
+++ b/components/dom_distiller/content/resources/dom_distiller_viewer.js
@@ -13,6 +13,24 @@ function showLoadingIndicator(isLastPage) {
isLastPage ? 'hidden' : 'visible';
}
+// Maps JS Font Family to CSS class and then changes body class name.
+// CSS classes must agree with distilledpage.css.
+function useFontFamily(fontFamily){
robliao 2014/08/10 02:43:45 Space between ) and {
sunangel 2014/08/11 21:51:33 Done.
sunangel 2014/08/11 21:51:33 Done.
+ var cssClass;
+ if (fontFamily == "serif") {
+ cssClass = "serif";
+ } else if (fontFamily == "monospace") {
+ cssClass = "monospace";
+ } else {
+ cssClass = "sans-serif";
+ }
+ // Relies on the classname order of the body being Theme class, then Font
+ // Family class.
+ var themeClass = document.body.className.split(" ")[0];
+ cssClass = themeClass + " " + cssClass;
+ document.body.className = cssClass;
+}
+
// Maps JS theme to CSS class and then changes body class name.
// CSS classes must agree with distilledpage.css.
function useTheme(theme) {
@@ -24,5 +42,9 @@ function useTheme(theme) {
} else {
cssClass = "light";
}
+ // Relies on the classname order of the body being Theme class, then Font
robliao 2014/08/10 02:43:45 Any way to do these where we don't rely on order?
sunangel 2014/08/11 21:51:33 explored other options with nyquist@ conclusion: l
+ // Family class.
+ var fontFamilyClass = document.body.className.split(" ")[1];
+ cssClass = cssClass + " " + fontFamilyClass;
document.body.className = cssClass;
}

Powered by Google App Engine
This is Rietveld 408576698