diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-27 19:47:49 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-27 19:47:49 +0000 |
commit | 47b541d98397df0e1e608fec34ec10e427d6255c (patch) | |
tree | 44580893ef7aede51fdc946719410337561699ea | |
parent | 1f0d6ba7a5244d569a7dc9778d2b80e891dc072b (diff) | |
download | chromium_src-47b541d98397df0e1e608fec34ec10e427d6255c.zip chromium_src-47b541d98397df0e1e608fec34ec10e427d6255c.tar.gz chromium_src-47b541d98397df0e1e608fec34ec10e427d6255c.tar.bz2 |
[webui] get rid of EnablePlatformSpecificCss
touch-optimized is the only attribute still being used. For shared css, I changed the mechanism so that pages will transparently get the correct CSS rather than needing to make a js call. For individual pages (i.e. the options page), I left the js call because a page author who includes special CSS can reasonably be expected to realize this call is necessary.
I deleted some touch CSS that looked stale and/or unused.
BUG=none
TEST=manual
Review URL: http://codereview.chromium.org/9836095
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129247 0039d316-1c4b-4281-b951-d872f2087c98
17 files changed, 41 insertions, 57 deletions
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index 6ff6bb2..26ca190 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd @@ -102,7 +102,6 @@ <include name="IDR_POLICY_HTML" file="resources\policy.html" flattenhtml="true" allowexternalscript="true" type="BINDATA"/> <include name="IDR_POLICY_JS" file="resources\policy.js" type="BINDATA"/> <include name="IDR_PRINT_PREVIEW_DUMMY_HTML" file="resources\print_preview\print_preview_dummy.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> - <include name="IDR_PRINT_PREVIEW_DUMMY_JS" file="resources\print_preview\print_preview_dummy.js" flattenhtml="true" type="BINDATA" /> <include name="IDR_PRINT_PREVIEW_HTML" file="resources\print_preview\print_preview.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> <include name="IDR_PRINT_PREVIEW_JS" file="resources\print_preview\print_preview.js" flattenhtml="true" type="BINDATA" /> <include name="IDR_PROFILER_HTML" file="resources\profiler\profiler.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> diff --git a/chrome/browser/resources/bookmark_manager/js/bookmark_all_tabs.js b/chrome/browser/resources/bookmark_manager/js/bookmark_all_tabs.js index 886daec..f264ed6 100644 --- a/chrome/browser/resources/bookmark_manager/js/bookmark_all_tabs.js +++ b/chrome/browser/resources/bookmark_manager/js/bookmark_all_tabs.js @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -14,8 +14,6 @@ const NEWFOLDER_SELECTION_DELAY = 50; if (!chrome.bookmarks) console.error('Bookmarks extension API is not available'); -cr.enablePlatformSpecificCSSRules(); - /** * The local strings object which is used to do the translation. * @type {!LocalStrings} diff --git a/chrome/browser/resources/bookmark_manager/js/main.js b/chrome/browser/resources/bookmark_manager/js/main.js index 63d2676..de76843 100644 --- a/chrome/browser/resources/bookmark_manager/js/main.js +++ b/chrome/browser/resources/bookmark_manager/js/main.js @@ -17,8 +17,6 @@ const Promise = cr.Promise; if (!chrome.bookmarks) console.error('Bookmarks extension API is not available'); -cr.enablePlatformSpecificCSSRules(); - /** * The local strings object which is used to do the translation. * @type {!LocalStrings} diff --git a/chrome/browser/resources/extensions/extensions.js b/chrome/browser/resources/extensions/extensions.js index ccea98e5..27bc697 100644 --- a/chrome/browser/resources/extensions/extensions.js +++ b/chrome/browser/resources/extensions/extensions.js @@ -30,7 +30,6 @@ cr.define('extensions', function() { * Perform initial setup. */ initialize: function() { - cr.enablePlatformSpecificCSSRules(); uber.onContentFrameLoaded(); // Set the title. diff --git a/chrome/browser/resources/history/history.js b/chrome/browser/resources/history/history.js index 21ac3b2..e79b12c 100644 --- a/chrome/browser/resources/history/history.js +++ b/chrome/browser/resources/history/history.js @@ -864,7 +864,6 @@ PageState.getHashString = function(term, page) { * Window onload handler, sets up the page. */ function load() { - cr.enablePlatformSpecificCSSRules(); uber.onContentFrameLoaded(); var searchField = $('search-field'); diff --git a/chrome/browser/resources/ntp4/new_tab.js b/chrome/browser/resources/ntp4/new_tab.js index 75fe97a..6d938b0 100644 --- a/chrome/browser/resources/ntp4/new_tab.js +++ b/chrome/browser/resources/ntp4/new_tab.js @@ -97,8 +97,6 @@ cr.define('ntp', function() { * Invoked at startup once the DOM is available to initialize the app. */ function onLoad() { - cr.enablePlatformSpecificCSSRules(); - sectionsToWaitFor = templateData.showApps ? 2 : 1; measureNavDots(); diff --git a/chrome/browser/resources/options2/options.js b/chrome/browser/resources/options2/options.js index bc78a91..35441e4 100644 --- a/chrome/browser/resources/options2/options.js +++ b/chrome/browser/resources/options2/options.js @@ -214,9 +214,6 @@ function load() { }; } - // Allow platform specific CSS rules. - cr.enablePlatformSpecificCSSRules(); - if (navigator.plugins['Shockwave Flash']) document.documentElement.setAttribute('hasFlashPlugin', ''); diff --git a/chrome/browser/resources/options2/options_page.css b/chrome/browser/resources/options2/options_page.css index f3a08ad..9755832 100644 --- a/chrome/browser/resources/options2/options_page.css +++ b/chrome/browser/resources/options2/options_page.css @@ -69,8 +69,7 @@ div.disabled { position: fixed; } -/* - * For touch-optimized UI, make the radio/checkbox input boxes in +/* For touch-optimized UI, make the radio/checkbox input boxes in * options/preference pages easier to touch. * TODO(rbyers): We need to solve this more generally for all web pages * (crbug.com/99981), and perhaps temporarily for all WebUI (crbug.com/102482). @@ -85,13 +84,11 @@ html[touch-optimized] label > input[type=radio] { -webkit-transform: scale(1.4); } -/* - * Override the font-size rule in shared_options.css file. +/* Override the font-size rule in shared_options.css file. * 16 px font-size proved to be more touch friendly. It increases the touchable - * area for buttons and input boxes. - */ + * area for buttons and input boxes. */ html[touch-optimized] body { - font-size: 16px; + font-size: 100%; } #overlay-container-1 { diff --git a/chrome/browser/resources/print_preview/print_preview.js b/chrome/browser/resources/print_preview/print_preview.js index d5d239d..8aab8b3 100644 --- a/chrome/browser/resources/print_preview/print_preview.js +++ b/chrome/browser/resources/print_preview/print_preview.js @@ -143,7 +143,6 @@ var customEvents = { * the printer list. */ function onLoad() { - cr.enablePlatformSpecificCSSRules(); initialPreviewRequestID = randomInteger(MIN_REQUEST_ID, MAX_REQUEST_ID); lastPreviewRequestID = initialPreviewRequestID; diff --git a/chrome/browser/resources/print_preview/print_preview_dummy.html b/chrome/browser/resources/print_preview/print_preview_dummy.html index 40cee7b..52af404 100644 --- a/chrome/browser/resources/print_preview/print_preview_dummy.html +++ b/chrome/browser/resources/print_preview/print_preview_dummy.html @@ -13,7 +13,6 @@ <script src="chrome://resources/js/cr.js"></script> <script src="chrome://resources/js/local_strings.js"></script> -<script src="chrome://print/print_preview_dummy.js"></script> <script src="chrome://print/strings.js"></script> </head> <body i18n-values=".style.fontFamily:fontfamily"> diff --git a/chrome/browser/resources/print_preview/print_preview_dummy.js b/chrome/browser/resources/print_preview/print_preview_dummy.js deleted file mode 100644 index fd282e6..0000000 --- a/chrome/browser/resources/print_preview/print_preview_dummy.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -cr.enablePlatformSpecificCSSRules(); diff --git a/chrome/browser/resources/shared/css/chrome_shared2.css b/chrome/browser/resources/shared/css/chrome_shared2.css index 23fd7d2..c5faaf1 100644 --- a/chrome/browser/resources/shared/css/chrome_shared2.css +++ b/chrome/browser/resources/shared/css/chrome_shared2.css @@ -60,19 +60,6 @@ a:active { color: rgb(5, 37, 119); } -/* - * Add padding to increase the touchable area of search box. Use original font - * size to avoid the width of search box exceeding the width of navbar. - */ -html[touch-optimized] input[type='search'] { - font-size: 13px; - padding: 5px; -} - -html[touch-optimized] input[type='search']::-webkit-search-cancel-button { - -webkit-transform: scale(1.5); -} - /* Elements that need to be LTR even in an RTL context, but should align * right. (Namely, URLs, search engine names, etc.) */ diff --git a/chrome/browser/resources/shared/css/chrome_shared2_touch.css b/chrome/browser/resources/shared/css/chrome_shared2_touch.css new file mode 100644 index 0000000..b0239be --- /dev/null +++ b/chrome/browser/resources/shared/css/chrome_shared2_touch.css @@ -0,0 +1,17 @@ +/* Copyright (c) 2012 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ + +/* NB: do not include this file directly. Include chrome_shared2.css. If touch + * optimization is enabled, these rules will be automatically loaded by the + * SharedResourceDataSource. */ + +<include src="chrome_shared2.css"> + +html input[type='search'] { + font-size: 1.1em; +} + +input[type='search']::-webkit-search-cancel-button { + -webkit-transform: scale(1.5); +} diff --git a/chrome/browser/resources/shared/js/cr.js b/chrome/browser/resources/shared/js/cr.js index d4cddee..6c213f3 100644 --- a/chrome/browser/resources/shared/js/cr.js +++ b/chrome/browser/resources/shared/js/cr.js @@ -54,22 +54,11 @@ var cr = (function() { var isTouchOptimized = !!chrome.touchOptimized; /** - * Sets the os and toolkit attributes in the <html> element so that platform - * specific css rules can be applied. + * Tags the html element with an attribute that allows touch-specific css + * rules. + * TODO(rbyers): make Chrome always touch-optimized. http://crbug.com/105380 */ - function enablePlatformSpecificCSSRules() { - if (isMac) - doc.documentElement.setAttribute('os', 'mac'); - if (isWindows) - doc.documentElement.setAttribute('os', 'windows'); - if (isChromeOS) - doc.documentElement.setAttribute('os', 'chromeos'); - if (isLinux) - doc.documentElement.setAttribute('os', 'linux'); - if (isGTK) - doc.documentElement.setAttribute('toolkit', 'gtk'); - if (isViews) - doc.documentElement.setAttribute('toolkit', 'views'); + function enableTouchOptimizedCss() { if (isTouchOptimized) doc.documentElement.setAttribute('touch-optimized', ''); } @@ -397,7 +386,7 @@ var cr = (function() { isLinux: isLinux, isViews: isViews, isTouchOptimized: isTouchOptimized, - enablePlatformSpecificCSSRules: enablePlatformSpecificCSSRules, + enableTouchOptimizedCss: enableTouchOptimizedCss, define: define, defineProperty: defineProperty, PropertyKind: PropertyKind, @@ -417,3 +406,5 @@ var cr = (function() { Event: CrEvent }; })(); + +cr.enableTouchOptimizedCss(); diff --git a/chrome/browser/resources/shared_resources.grd b/chrome/browser/resources/shared_resources.grd index fd77eff..7d554fb 100644 --- a/chrome/browser/resources/shared_resources.grd +++ b/chrome/browser/resources/shared_resources.grd @@ -26,6 +26,9 @@ without changes to the corresponding grd file. --> file="shared/css/chrome_shared.css" type="BINDATA" /> <include name="IDR_SHARED_CSS_CHROME2" file="shared/css/chrome_shared2.css" type="BINDATA" /> + <include name="IDR_SHARED_CSS_CHROME2_TOUCH" + file="shared/css/chrome_shared2_touch.css" type="BINDATA" + flattenhtml="true" /> <include name="IDR_SHARED_CSS_OVERLAY" file="shared/css/overlay.css" type="BINDATA" /> <include name="IDR_SHARED_CSS_SPINNER" diff --git a/chrome/browser/ui/webui/print_preview/print_preview_data_source.cc b/chrome/browser/ui/webui/print_preview/print_preview_data_source.cc index 808231b..2cc993f 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_data_source.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_data_source.cc @@ -139,7 +139,6 @@ void PrintPreviewDataSource::Init(bool is_dummy) { set_json_path("strings.js"); if (is_dummy) { - add_resource_path("print_preview_dummy.js", IDR_PRINT_PREVIEW_DUMMY_JS); set_default_resource(IDR_PRINT_PREVIEW_DUMMY_HTML); } else { add_resource_path("print_preview.js", IDR_PRINT_PREVIEW_JS); diff --git a/chrome/browser/ui/webui/shared_resources_data_source.cc b/chrome/browser/ui/webui/shared_resources_data_source.cc index 63d2ceb..66639ab 100644 --- a/chrome/browser/ui/webui/shared_resources_data_source.cc +++ b/chrome/browser/ui/webui/shared_resources_data_source.cc @@ -6,6 +6,7 @@ #include <string> +#include "base/command_line.h" #include "base/memory/singleton.h" #include "base/threading/thread_restrictions.h" #include "chrome/browser/io_thread.h" @@ -18,6 +19,7 @@ #include "grit/ui_resources.h" #include "net/base/mime_util.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/base/ui_base_switches.h" namespace { @@ -45,6 +47,12 @@ int PathToIDR(const std::string& path) { break; } } + + if (idr == IDR_SHARED_CSS_CHROME2 && + CommandLine::ForCurrentProcess()->HasSwitch( + switches::kTouchOptimizedUI)) { + idr = IDR_SHARED_CSS_CHROME2_TOUCH; + } } return idr; @@ -66,6 +74,7 @@ void SharedResourcesDataSource::StartDataRequest(const std::string& path, DCHECK_NE(-1, idr) << " path: " << path; const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); scoped_refptr<RefCountedStaticMemory> bytes(rb.LoadDataResourceBytes(idr)); + SendResponse(request_id, bytes); } |