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

Side by Side Diff: chrome/browser/resources/options/options_page.js

Issue 68723003: Make chrome/ be documentElement/body agnostic with regards to scrollTop/Left (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_305800
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('options', function() { 5 cr.define('options', function() {
6 /** @const */ var FocusOutlineManager = cr.ui.FocusOutlineManager; 6 /** @const */ var FocusOutlineManager = cr.ui.FocusOutlineManager;
7 7
8 ///////////////////////////////////////////////////////////////////////////// 8 /////////////////////////////////////////////////////////////////////////////
9 // OptionsPage class: 9 // OptionsPage class:
10 10
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 /** 198 /**
199 * Scrolls the page to the correct position (the top when opening an overlay, 199 * Scrolls the page to the correct position (the top when opening an overlay,
200 * or the old scroll position a previously hidden overlay becomes visible). 200 * or the old scroll position a previously hidden overlay becomes visible).
201 * @private 201 * @private
202 */ 202 */
203 OptionsPage.updateScrollPosition_ = function() { 203 OptionsPage.updateScrollPosition_ = function() {
204 var container = $('page-container'); 204 var container = $('page-container');
205 var scrollTop = container.oldScrollTop || 0; 205 var scrollTop = container.oldScrollTop || 0;
206 container.oldScrollTop = undefined; 206 container.oldScrollTop = undefined;
207 window.scroll(document.documentElement.scrollLeft, scrollTop); 207 window.scroll(scrollLeftForDocument(document), scrollTop);
208 }; 208 };
209 209
210 /** 210 /**
211 * Pushes the current page onto the history stack, overriding the last page 211 * Pushes the current page onto the history stack, overriding the last page
212 * if it is the generic chrome://settings/. 212 * if it is the generic chrome://settings/.
213 * @param {boolean} replace If true, allow no history events to be created. 213 * @param {boolean} replace If true, allow no history events to be created.
214 * @param {object=} opt_params A bag of optional params, including: 214 * @param {object=} opt_params A bag of optional params, including:
215 * {boolean} ignoreHash Whether to include the hash or not. 215 * {boolean} ignoreHash Whether to include the hash or not.
216 * @private 216 * @private
217 */ 217 */
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 * @private 604 * @private
605 */ 605 */
606 OptionsPage.setRootPageFrozen_ = function(freeze) { 606 OptionsPage.setRootPageFrozen_ = function(freeze) {
607 var container = $('page-container'); 607 var container = $('page-container');
608 if (container.classList.contains('frozen') == freeze) 608 if (container.classList.contains('frozen') == freeze)
609 return; 609 return;
610 610
611 if (freeze) { 611 if (freeze) {
612 // Lock the width, since auto width computation may change. 612 // Lock the width, since auto width computation may change.
613 container.style.width = window.getComputedStyle(container).width; 613 container.style.width = window.getComputedStyle(container).width;
614 container.oldScrollTop = document.documentElement.scrollTop; 614 container.oldScrollTop = scrollTopForDocument(document);
615 container.classList.add('frozen'); 615 container.classList.add('frozen');
616 var verticalPosition = 616 var verticalPosition =
617 container.getBoundingClientRect().top - container.oldScrollTop; 617 container.getBoundingClientRect().top - container.oldScrollTop;
618 container.style.top = verticalPosition + 'px'; 618 container.style.top = verticalPosition + 'px';
619 this.updateFrozenElementHorizontalPosition_(container); 619 this.updateFrozenElementHorizontalPosition_(container);
620 } else { 620 } else {
621 container.classList.remove('frozen'); 621 container.classList.remove('frozen');
622 container.style.top = ''; 622 container.style.top = '';
623 container.style.left = ''; 623 container.style.left = '';
624 container.style.right = ''; 624 container.style.right = '';
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 696
697 /** 697 /**
698 * Updates the given frozen element to match the horizontal scroll position. 698 * Updates the given frozen element to match the horizontal scroll position.
699 * @param {HTMLElement} e The frozen element to update. 699 * @param {HTMLElement} e The frozen element to update.
700 * @private 700 * @private
701 */ 701 */
702 OptionsPage.updateFrozenElementHorizontalPosition_ = function(e) { 702 OptionsPage.updateFrozenElementHorizontalPosition_ = function(e) {
703 if (isRTL()) { 703 if (isRTL()) {
704 e.style.right = OptionsPage.horizontalOffset + 'px'; 704 e.style.right = OptionsPage.horizontalOffset + 'px';
705 } else { 705 } else {
706 e.style.left = OptionsPage.horizontalOffset - 706 var scrollLeft = scrollLeftForDocument(document);
707 document.documentElement.scrollLeft + 'px'; 707 e.style.left = OptionsPage.horizontalOffset - scrollLeft + 'px';
708 } 708 }
709 }; 709 };
710 710
711 /** 711 /**
712 * Change the horizontal offset used to reposition elements while showing an 712 * Change the horizontal offset used to reposition elements while showing an
713 * overlay from the default. 713 * overlay from the default.
714 */ 714 */
715 OptionsPage.setHorizontalOffset = function(value) { 715 OptionsPage.setHorizontalOffset = function(value) {
716 OptionsPage.horizontalOffset = value; 716 OptionsPage.horizontalOffset = value;
717 }; 717 };
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 canShowPage: function() { 997 canShowPage: function() {
998 return true; 998 return true;
999 }, 999 },
1000 }; 1000 };
1001 1001
1002 // Export 1002 // Export
1003 return { 1003 return {
1004 OptionsPage: OptionsPage 1004 OptionsPage: OptionsPage
1005 }; 1005 };
1006 }); 1006 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/ntp_android/ntp_android.js ('k') | chrome/browser/resources/uber/uber_utils.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698