Commit 1657a919 authored by calamity's avatar calamity Committed by Commit Bot

Revert of [cr-action-menu] Use clientWidth for rtl flipping. (patchset #2...

Revert of [cr-action-menu] Use clientWidth for rtl flipping. (patchset #2 id:60001 of https://codereview.chromium.org/2966163004/ )

Reason for revert:
Breaks on https://uberchromegw.corp.google.com/i/chromium.mac/builders/Mac10.11%20Tests/builds/15007

Original issue's description:
> [cr-action-menu] Use clientWidth for rtl flipping.
>
> This CL fixes a bug where the action menu would use the entire body's
> length as the viewport when flipping coordinates in RTL.
>
> It also moves the scroll position saving into showAtPosition so that
> both show methods account for scroll correctly.
>
> BUG=734984
> CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation
>
> Review-Url: https://codereview.chromium.org/2966163004
> Cr-Commit-Position: refs/heads/master@{#485181}
> Committed: https://chromium.googlesource.com/chromium/src/+/87be8f4c1eaef26b7c6d7ddb2c56d84ef504a232

TBR=dpapad@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=734984

Review-Url: https://codereview.chromium.org/2980463002
Cr-Commit-Position: refs/heads/master@{#485189}
parent 2785ae96
......@@ -89,10 +89,10 @@ function getDefaultShowConfig() {
width: 0,
anchorAlignmentX: AnchorAlignment.AFTER_START,
anchorAlignmentY: AnchorAlignment.AFTER_START,
minX: 0,
minY: 0,
maxX: 0,
maxY: 0,
minX: doc.scrollLeft,
minY: doc.scrollTop,
maxX: doc.scrollLeft + window.innerWidth,
maxY: doc.scrollTop + window.innerHeight,
};
}
......@@ -253,8 +253,22 @@ Polymer({
// accurate for where the menu should be shown.
this.anchorElement_.scrollIntoViewIfNeeded();
// Save the scroll position that ensures the anchor element is onscreen.
var doc = document.scrollingElement;
var scrollLeft = doc.scrollLeft;
var scrollTop = doc.scrollTop;
// Reset position so that layout isn't affected by the previous position,
// and so that the dialog is positioned at the top-start corner of the
// document.
this.resetStyle_();
// Show the dialog which will focus the top-start of the body. This makes
// the client rect calculation relative to the top-start of the body.
this.showModal();
var rect = this.anchorElement_.getBoundingClientRect();
this.showAtPosition(/** @type {ShowConfig} */ (Object.assign(
this.positionDialog_(/** @type {ShowConfig} */ (Object.assign(
{
top: rect.top,
left: rect.left,
......@@ -262,8 +276,18 @@ Polymer({
width: rect.width,
// Default to anchoring towards the left.
anchorAlignmentX: AnchorAlignment.BEFORE_END,
minX: scrollLeft,
minY: scrollTop,
maxX: scrollLeft + window.innerWidth,
maxY: scrollTop + window.innerHeight,
},
opt_config)));
// Restore the scroll position.
doc.scrollTop = scrollTop;
doc.scrollLeft = scrollLeft;
this.addCloseListeners_();
},
/**
......@@ -271,8 +295,7 @@ Polymer({
* specified as an X and Y alignment which represents a point in the anchor
* where the menu will align to, which can have the menu either before or
* after the given point in each axis. Center alignment places the center of
* the menu in line with the center of the anchor. Coordinates are relative to
* the top-left of the viewport.
* the menu in line with the center of the anchor.
*
* y-start
* _____________
......@@ -294,32 +317,9 @@ Polymer({
* @param {!ShowConfig} config
*/
showAtPosition: function(config) {
// Save the scroll position of the viewport.
var doc = document.scrollingElement;
var scrollLeft = doc.scrollLeft;
var scrollTop = doc.scrollTop;
// Reset position so that layout isn't affected by the previous position,
// and so that the dialog is positioned at the top-start corner of the
// document.
this.resetStyle_();
this.showModal();
config.top += scrollTop;
config.left += scrollLeft;
this.positionDialog_(/** @type {ShowConfig} */ (Object.assign(
{
minX: scrollLeft,
minY: scrollTop,
maxX: scrollLeft + doc.clientWidth,
maxY: scrollTop + doc.clientHeight,
},
config)));
// Restore the scroll position.
doc.scrollTop = scrollTop;
doc.scrollLeft = scrollLeft;
this.positionDialog_(config);
this.addCloseListeners_();
},
......@@ -331,8 +331,6 @@ Polymer({
},
/**
* Position the dialog using the coordinates in config. Coordinates are
* relative to the top-left of the viewport when scrolled to (0, 0).
* @param {!ShowConfig} config
* @private
*/
......@@ -353,8 +351,7 @@ Polymer({
left, right, this.offsetWidth, c.anchorAlignmentX, c.minX, c.maxX);
if (rtl) {
var menuRight =
document.scrollingElement.clientWidth - menuLeft - this.offsetWidth;
var menuRight = document.body.scrollWidth - menuLeft - this.offsetWidth;
this.style.right = menuRight + 'px';
} else {
this.style.left = menuLeft + 'px';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment