mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 521113 Don't allow kinetic scrolling to move sidebars r=mbrubeck
This commit is contained in:
parent
b68c20341b
commit
ccc449f07c
@ -1224,7 +1224,6 @@ Browser.MainDragger.prototype = {
|
||||
let bcr = browser.getBoundingClientRect();
|
||||
this._contentView = browser.getViewAt(clientX - bcr.left, clientY - bcr.top);
|
||||
this._stopAtSidebar = 0;
|
||||
this._hitSidebar = false;
|
||||
if (this._sidebarTimeout) {
|
||||
clearTimeout(this._sidebarTimeout);
|
||||
this._sidebarTimeout = null;
|
||||
@ -1244,7 +1243,7 @@ Browser.MainDragger.prototype = {
|
||||
|
||||
// If the sidebars are showing, we pan them out of the way before panning the content.
|
||||
// The panning distance that should be used for the sidebars in is stored in sidebarOffset,
|
||||
// and subtracted from doffset
|
||||
// and subtracted from doffset.
|
||||
let sidebarOffset = this._getSidebarOffset(doffset);
|
||||
|
||||
// If we started with one sidebar open, stop when we get to the other.
|
||||
@ -1254,13 +1253,10 @@ Browser.MainDragger.prototype = {
|
||||
if (!this.contentMouseCapture)
|
||||
this._panContent(doffset);
|
||||
|
||||
if (this._hitSidebar && aIsKinetic)
|
||||
return false; // No kinetic panning after we've stopped at the sidebar.
|
||||
if (aIsKinetic && doffset.x != 0)
|
||||
return false;
|
||||
|
||||
// allow panning the sidebars if the page hasn't prevented it, or if any of the sidebars are showing
|
||||
// (i.e. we always allow panning sidebars off screen but not necessarily panning them back on)
|
||||
if (!this.contentMouseCapture || sidebarOffset.x != 0 || sidebarOffset.y > 0)
|
||||
this._panChrome(doffset, sidebarOffset);
|
||||
this._panChrome(doffset, sidebarOffset);
|
||||
|
||||
this._updateScrollbars();
|
||||
|
||||
@ -1318,17 +1314,21 @@ Browser.MainDragger.prototype = {
|
||||
this._panContentView(getBrowser().getRootView(), aOffset);
|
||||
},
|
||||
|
||||
_panChrome: function md_panSidebars(aOffset, aSidebarOffset) {
|
||||
// Any panning aOffset would bring controls into view. Add to aSidebarOffset
|
||||
_panChrome: function md_panChrome(aOffset, aSidebarOffset) {
|
||||
// In order to prevent users from hiding one sidebar and followed by immediately bringing
|
||||
// out the other one, we absorb sidebar pans here for a fixed time.
|
||||
//
|
||||
// Also, if users are panning a website then we allow them to pan away sidebars, but
|
||||
// nothing more.
|
||||
//
|
||||
let offsetX = aOffset.x;
|
||||
if ((this._stopAtSidebar > 0 && offsetX > 0) ||
|
||||
(this._stopAtSidebar < 0 && offsetX < 0)) {
|
||||
if (offsetX != aSidebarOffset.x)
|
||||
this._hitSidebar = true;
|
||||
if (this.contentMouseCapture)
|
||||
aOffset.set(aSidebarOffset);
|
||||
else if ((this._stopAtSidebar > 0 && offsetX > 0) ||
|
||||
(this._stopAtSidebar < 0 && offsetX < 0))
|
||||
aOffset.x = aSidebarOffset.x;
|
||||
} else {
|
||||
else
|
||||
aOffset.add(aSidebarOffset);
|
||||
}
|
||||
|
||||
Browser.tryFloatToolbar(aOffset.x, 0);
|
||||
|
||||
|
@ -67,6 +67,7 @@ _BROWSER_FILES = \
|
||||
browser_click_content.html \
|
||||
browser_click_content.js \
|
||||
browser_contacts.js \
|
||||
browser_dragger.js \
|
||||
browser_find.js \
|
||||
browser_forms.html \
|
||||
$(warning browser_forms.js disabled due to failures) \
|
||||
|
89
mobile/chrome/tests/browser_dragger.js
Normal file
89
mobile/chrome/tests/browser_dragger.js
Normal file
@ -0,0 +1,89 @@
|
||||
"use strict";
|
||||
|
||||
const testURL_01 = chromeRoot + "browser_blank_01.html";
|
||||
const testURL_01_Remote = serverRoot + "browser_blank_01.html";
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
runNextTest();
|
||||
}
|
||||
|
||||
gTests.push({
|
||||
desc: "Test that kinetic panning does not open sidebars.",
|
||||
tab: null,
|
||||
|
||||
run: function() {
|
||||
gCurrentTest.tab = Browser.addTab(testURL_01, true);
|
||||
onMessageOnce(gCurrentTest.tab.browser.messageManager, "MozScrolledAreaChanged", gCurrentTest.checkPan);
|
||||
},
|
||||
|
||||
checkPan: function() {
|
||||
let browser = gCurrentTest.tab.browser;
|
||||
let docWidth = browser.contentDocumentWidth * browser.scale;
|
||||
let winWidth = window.innerWidth;
|
||||
info("Browser document width is " + docWidth);
|
||||
info("Window width is " + winWidth);
|
||||
is(docWidth, winWidth,
|
||||
"Sanity check. Blank document cannot be panned left or right.");
|
||||
|
||||
function dragAndCheck(dx) {
|
||||
let dragger = Elements.browsers.customDragger;
|
||||
try {
|
||||
dragger.dragStart(0, 0, null, null);
|
||||
dragger.dragMove(dx, 0, null, true);
|
||||
|
||||
let [leftVis, rightVis] = Browser.computeSidebarVisibility();
|
||||
is(leftVis, 0, "Left sidebar is not visible");
|
||||
is(rightVis, 0, "Right sidebar is not visible");
|
||||
} finally {
|
||||
// Be fail tolerant and hide sidebars in case tests failed.
|
||||
Browser.hideSidebars();
|
||||
dragger.dragStop();
|
||||
}
|
||||
}
|
||||
|
||||
dragAndCheck(-20);
|
||||
dragAndCheck(20);
|
||||
|
||||
Browser._doCloseTab(gCurrentTest.tab);
|
||||
runNextTest();
|
||||
}
|
||||
});
|
||||
|
||||
gTests.push({
|
||||
desc: "Test that urlbar cannot be panned in when content is captured.",
|
||||
tab: null,
|
||||
|
||||
run: function() {
|
||||
gCurrentTest.tab = Browser.addTab(testURL_01_Remote, true);
|
||||
Browser.selectedTab = gCurrentTest.tab;
|
||||
onMessageOnce(gCurrentTest.tab.browser.messageManager, "MozScrolledAreaChanged", gCurrentTest.mouseMove);
|
||||
},
|
||||
|
||||
mouseMove: function(json) {
|
||||
let inputHandler = gCurrentTest.tab.browser.parentNode;
|
||||
function fireMouseEvent(y, type) {
|
||||
EventUtils.synthesizeMouse(inputHandler, 0, y, { type: type });
|
||||
}
|
||||
|
||||
Browser.hideTitlebar();
|
||||
let rect = Elements.browsers.getBoundingClientRect();
|
||||
is(rect.top, 0, "Titlebar begins hidden");
|
||||
|
||||
let dragger = Elements.browsers.customDragger;
|
||||
try {
|
||||
dragger.contentCanCapture = true;
|
||||
dragger.dragStart(0, 0, null, null);
|
||||
dragger.dragMove(0, 20, null, true);
|
||||
dragger.dragStop();
|
||||
} finally {
|
||||
dragger.contentCanCapture = false;
|
||||
}
|
||||
|
||||
rect = Elements.browsers.getBoundingClientRect();
|
||||
is(rect.top, 0, "Titlebar is still hidden");
|
||||
|
||||
Browser._doCloseTab(gCurrentTest.tab);
|
||||
runNextTest();
|
||||
}
|
||||
});
|
@ -218,4 +218,3 @@ gTests.push({
|
||||
runNextTest();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -80,6 +80,23 @@ let AsyncTests = {
|
||||
}
|
||||
};
|
||||
|
||||
let gCurrentTest = null;
|
||||
let gTests = [];
|
||||
|
||||
// Iterating tests by shifting test out one by one as runNextTest is called.
|
||||
function runNextTest() {
|
||||
// Run the next test until all tests completed
|
||||
if (gTests.length > 0) {
|
||||
gCurrentTest = gTests.shift();
|
||||
info(gCurrentTest.desc);
|
||||
gCurrentTest.run();
|
||||
}
|
||||
else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
let serverRoot = "http://example.com/browser/mobile/chrome/tests/";
|
||||
let chromeRoot = getRootDirectory(gTestPath);
|
||||
// For some security reasons (which?), loading remote_head using chromeRoot
|
||||
// instead of baseURI make the browser_formsZoom.js test fails.
|
||||
|
Loading…
Reference in New Issue
Block a user