summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources
diff options
context:
space:
mode:
authorarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-15 00:27:47 +0000
committerarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-15 00:27:47 +0000
commitdc0aaeaa225eecc6f51db34df00ebcf6cff1783c (patch)
tree9c9203219dedcaa8febb0fc3d430eab551c6d215 /chrome/browser/resources
parent5ac8b8fb88572ac5f0a910057d8e9baa4054c3c5 (diff)
downloadchromium_src-dc0aaeaa225eecc6f51db34df00ebcf6cff1783c.zip
chromium_src-dc0aaeaa225eecc6f51db34df00ebcf6cff1783c.tar.gz
chromium_src-dc0aaeaa225eecc6f51db34df00ebcf6cff1783c.tar.bz2
NTP: Add work around for layout bug that some users are hitting.
In some rare cases the reported window.innerWidth and the media query reports different widths. This is most likely due to some timing issues. This work around keeps track of what layout mode we are using (wasSmallGrid) and when we get the data as well as on DOMContentLoaded we double check to ensure that the mode is correct and if not we do another layout. So in worst case we do one more layout in the case where the layout was wrong. BUG=25329 TEST=I haven't been able to repro so when testing this I introduced the *wrong* case manually in code. Review URL: http://codereview.chromium.org/1650008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44590 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources')
-rw-r--r--chrome/browser/resources/new_new_tab.html5
-rw-r--r--chrome/browser/resources/new_new_tab.js18
2 files changed, 16 insertions, 7 deletions
diff --git a/chrome/browser/resources/new_new_tab.html b/chrome/browser/resources/new_new_tab.html
index 79d0c0d..ce5cbeb 100644
--- a/chrome/browser/resources/new_new_tab.html
+++ b/chrome/browser/resources/new_new_tab.html
@@ -89,8 +89,13 @@ function isRtl() {
return templateData['textdirection'] == 'rtl';
}
+// Keep track of the last small state so we can ensure that we are using the
+// right mode. This is a workaround for http://crbug.com/25329
+var wasSmallGrid;
+
function getMostVisitedLayoutRects() {
var small = useSmallGrid();
+ wasSmallGrid = small;
var cols = 4;
var rows = 2;
diff --git a/chrome/browser/resources/new_new_tab.js b/chrome/browser/resources/new_new_tab.js
index 9932cf2..e3da308 100644
--- a/chrome/browser/resources/new_new_tab.js
+++ b/chrome/browser/resources/new_new_tab.js
@@ -714,6 +714,7 @@ function onDataLoaded() {
// Remove class name in a timeout so that changes done in this JS thread are
// not animated.
window.setTimeout(function() {
+ ensureSmallGridCorrect();
removeClass(document.body, 'loading');
}, 1);
}
@@ -1262,7 +1263,8 @@ $('list-checkbox').addEventListener('change',
$('list-checkbox').addEventListener('keydown',
getCheckboxHandler(Section.LIST));
-window.addEventListener('load', bind(logEvent, global, 'Tab.NewTabOnload', true));
+window.addEventListener('load', bind(logEvent, global, 'Tab.NewTabOnload',
+ true));
window.addEventListener('load', onDataLoaded);
window.addEventListener('resize', handleWindowResize);
@@ -1280,6 +1282,14 @@ document.addEventListener('DOMContentLoaded',
// Set up links and text-decoration for promotional message.
document.addEventListener('DOMContentLoaded', setUpPromoMessage);
+// Work around for http://crbug.com/25329
+function ensureSmallGridCorrect() {
+ if (wasSmallGrid != useSmallGrid()) {
+ applyMostVisitedRects();
+ }
+}
+document.addEventListener('DOMContentLoaded', ensureSmallGridCorrect);
+
/**
* The sync code is not yet built by default on all platforms so we have to
* make sure we don't send the initial sync message to the backend unless the
@@ -1336,12 +1346,6 @@ document.addEventListener('mouseover', function(e) {
// DnD
var dnd = {
- /**
- * Windows and Linux only support copy drag and drop.
- * @see http://crbug.com/14654/
- * @type {string}
- */
- DND_EFFECT: IS_MAC ? 'move' : 'copy',
currentOverItem_: null,
get currentOverItem() {
return this.currentOverItem_;