diff options
author | jstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-13 16:35:18 +0000 |
---|---|---|
committer | jstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-13 16:35:18 +0000 |
commit | 83765b8ca9266b02c9e2cebd29887098ae856b5d (patch) | |
tree | 14284550d5535676756d4e35ab00ce3c140b1bda /chrome | |
parent | 4db67943718c58094fc7e1a9e6ab8182d74badd6 (diff) | |
download | chromium_src-83765b8ca9266b02c9e2cebd29887098ae856b5d.zip chromium_src-83765b8ca9266b02c9e2cebd29887098ae856b5d.tar.gz chromium_src-83765b8ca9266b02c9e2cebd29887098ae856b5d.tar.bz2 |
Reset NTP document height when sections are minimized/hidden. Update position_util to properly handle 'fixed' positioned elements.
BUG=62747
TEST=See bug.
Review URL: http://codereview.chromium.org/5445002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69005 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/resources/new_new_tab.js | 6 | ||||
-rw-r--r-- | chrome/browser/resources/shared/js/cr/ui/position_util.js | 28 |
2 files changed, 25 insertions, 9 deletions
diff --git a/chrome/browser/resources/new_new_tab.js b/chrome/browser/resources/new_new_tab.js index 8aeb4a8..9b1befd 100644 --- a/chrome/browser/resources/new_new_tab.js +++ b/chrome/browser/resources/new_new_tab.js @@ -276,7 +276,7 @@ function handleWindowResize() { var oldLayoutMode = layoutMode; var b = useSmallGrid(); - layoutMode = b ? LayoutMode.SMALL : LayoutMode.NORMAL + layoutMode = b ? LayoutMode.SMALL : LayoutMode.NORMAL; if (layoutMode != oldLayoutMode){ mostVisited.useSmallGrid = b; @@ -421,6 +421,10 @@ function layoutSections() { expandedSectionHeight = expandedSection.scrollingHeight; document.body.style.height = ''; } + } else { + // We only set the document height when a section is expanded. If + // all sections are minimized, then get rid of the previous height. + document.body.style.height = ''; } // Now position all the elements. diff --git a/chrome/browser/resources/shared/js/cr/ui/position_util.js b/chrome/browser/resources/shared/js/cr/ui/position_util.js index 380e9e1..cdb7c73 100644 --- a/chrome/browser/resources/shared/js/cr/ui/position_util.js +++ b/chrome/browser/resources/shared/js/cr/ui/position_util.js @@ -57,14 +57,26 @@ cr.define('cr.ui', function() { */ function positionPopupAroundRect(anchorRect, popupElement, type) { var popupRect = popupElement.getBoundingClientRect(); - var popupContainer; - var cs = popupElement.ownerDocument.defaultView. - getComputedStyle(popupElement); - if (cs.position == 'fixed') - popupContainer = popupElement.ownerDocument.body; - else - popupContainer = popupElement.offsetParent; - var availRect = popupContainer.getBoundingClientRect(); + var availRect; + var ownerDoc = popupElement.ownerDocument; + var cs = ownerDoc.defaultView.getComputedStyle(popupElement); + var docElement = ownerDoc.documentElement; + + if (cs.position == 'fixed') { + // For 'fixed' positioned popups, the available rectangle should be based + // on the viewport rather than the document. + availRect = { + height: docElement.clientHeight, + width: docElement.clientWidth, + top: 0, + bottom: docElement.clientHeight, + left: 0, + right: docElement.clientWidth + }; + } else { + availRect = popupElement.offsetParent.getBoundingClientRect(); + } + var rtl = cs.direction == 'rtl'; // Flip BEFORE, AFTER based on RTL. |