mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 251903 - autoscroll does not function as expected when in an iframe. r=neil
This commit is contained in:
parent
d439cd381c
commit
a2fe4d6f7e
@ -53,13 +53,13 @@ let ClickEventHandler = {
|
||||
return false;
|
||||
},
|
||||
|
||||
startScroll: function(event) {
|
||||
findNearestScrollableElement: function(aNode) {
|
||||
// this is a list of overflow property values that allow scrolling
|
||||
const scrollingAllowed = ['scroll', 'auto'];
|
||||
|
||||
// go upward in the DOM and find any parent element that has a overflow
|
||||
// area and can therefore be scrolled
|
||||
for (this._scrollable = event.originalTarget; this._scrollable;
|
||||
for (this._scrollable = aNode; this._scrollable;
|
||||
this._scrollable = this._scrollable.parentNode) {
|
||||
// do not use overflow based autoscroll for <html> and <body>
|
||||
// Elements or non-html elements such as svg or Document nodes
|
||||
@ -96,16 +96,25 @@ let ClickEventHandler = {
|
||||
}
|
||||
|
||||
if (!this._scrollable) {
|
||||
this._scrollable = event.originalTarget.ownerDocument.defaultView;
|
||||
this._scrollable = aNode.ownerDocument.defaultView;
|
||||
if (this._scrollable.scrollMaxX > 0) {
|
||||
this._scrolldir = this._scrollable.scrollMaxY > 0 ? "NSEW" : "EW";
|
||||
} else if (this._scrollable.scrollMaxY > 0) {
|
||||
this._scrolldir = "NS";
|
||||
} else if (this._scrollable.frameElement) {
|
||||
this.findNearestScrollableElement(this._scrollable.frameElement);
|
||||
} else {
|
||||
this._scrollable = null; // abort scrolling
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
startScroll: function(event) {
|
||||
|
||||
this.findNearestScrollableElement(event.originalTarget);
|
||||
|
||||
if (!this._scrollable)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let [enabled] = sendSyncMessage("Autoscroll:Start",
|
||||
{scrolldir: this._scrolldir,
|
||||
|
@ -40,7 +40,21 @@ function test()
|
||||
<body id="j"><div style="height: 2000px"></div>\
|
||||
<iframe id="iframe" style="display: none;"></iframe>\
|
||||
</body></html>'},
|
||||
{elem: 'j', expected: expectScrollVert} // bug 914251
|
||||
{elem: 'j', expected: expectScrollVert}, // bug 914251
|
||||
{dataUri: 'data:text/html,<html><head></head><body>\
|
||||
<div id="k" style="height: 150px; width: 200px; overflow: scroll; border: 1px solid black;">\
|
||||
<iframe style="height: 200px; width: 300px;"></iframe>\
|
||||
</div>\
|
||||
<div id="l" style="height: 150px; width: 300px; overflow: scroll; border: 1px dashed black;">\
|
||||
<iframe style="height: 200px; width: 200px;" src="data:text/html,<div style=\'border: 5px solid blue; height: 200%; width: 200%;\'></div>"></iframe>\
|
||||
</div>\
|
||||
<iframe id="m"></iframe>\
|
||||
<div style="height: 200%; border: 5px dashed black;">filler to make document overflow: scroll;</div>\
|
||||
</body></html>'},
|
||||
{elem: 'k', expected: expectScrollBoth},
|
||||
{elem: 'k', expected: expectScrollNone, testwindow: true},
|
||||
{elem: 'l', expected: expectScrollNone},
|
||||
{elem: 'm', expected: expectScrollVert, testwindow: true}
|
||||
];
|
||||
|
||||
var doc;
|
||||
@ -89,13 +103,24 @@ function test()
|
||||
// Close the autoscroll popup by synthesizing Esc.
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {}, gBrowser.contentWindow);
|
||||
var scrollVert = test.expected & expectScrollVert;
|
||||
var scrollHori = test.expected & expectScrollHori;
|
||||
|
||||
if (test.testwindow) {
|
||||
ok((scrollVert && gBrowser.contentWindow.scrollY > 0) ||
|
||||
(!scrollVert && gBrowser.contentWindow.scrollY == 0),
|
||||
'Window for '+test.elem+' should'+(scrollVert ? '' : ' not')+' have scrolled vertically');
|
||||
ok((scrollHori && gBrowser.contentWindow.scrollX > 0) ||
|
||||
(!scrollHori && gBrowser.contentWindow.scrollX == 0),
|
||||
'Window for '+test.elem+' should'+(scrollHori ? '' : ' not')+' have scrolled horizontally');
|
||||
gBrowser.contentWindow.scroll(0, 0);
|
||||
} else {
|
||||
ok((scrollVert && elem.scrollTop > 0) ||
|
||||
(!scrollVert && elem.scrollTop == 0),
|
||||
test.elem+' should'+(scrollVert ? '' : ' not')+' have scrolled vertically');
|
||||
var scrollHori = test.expected & expectScrollHori;
|
||||
ok((scrollHori && elem.scrollLeft > 0) ||
|
||||
(!scrollHori && elem.scrollLeft == 0),
|
||||
test.elem+' should'+(scrollHori ? '' : ' not')+' have scrolled horizontally');
|
||||
}
|
||||
|
||||
// Before continuing the test, we need to ensure that the IPC
|
||||
// message that stops autoscrolling has had time to arrive.
|
||||
@ -107,12 +132,15 @@ function test()
|
||||
// This ensures bug 605127 is fixed: pagehide in an unrelated document
|
||||
// should not cancel the autoscroll.
|
||||
var iframe = gBrowser.contentDocument.getElementById("iframe");
|
||||
|
||||
if (iframe) {
|
||||
var e = new iframe.contentWindow.PageTransitionEvent("pagehide",
|
||||
{ bubbles: true,
|
||||
cancelable: true,
|
||||
persisted: false });
|
||||
iframe.contentDocument.dispatchEvent(e);
|
||||
iframe.contentDocument.documentElement.dispatchEvent(e);
|
||||
}
|
||||
|
||||
EventUtils.synthesizeMouse(elem, 100, 100,
|
||||
{ type: "mousemove", clickCount: "0" },
|
||||
|
Loading…
Reference in New Issue
Block a user