зеркало из https://github.com/mozilla/gecko-dev.git
Bug 704171 part 1. Stop using the no-argument form of mozRequestAnimationFrame in our chrome. r=roc,gavin
This commit is contained in:
Родитель
604a126fcf
Коммит
81790fcb60
|
@ -7,15 +7,6 @@
|
|||
|
||||
var report = false;
|
||||
|
||||
function f() {
|
||||
if (report) {
|
||||
opener.postMessage("eventHappened", "*");
|
||||
}
|
||||
window.mozRequestAnimationFrame();
|
||||
}
|
||||
document.addEventListener("MozBeforePaint", f, false);
|
||||
f();
|
||||
|
||||
function g() {
|
||||
if (report) {
|
||||
opener.postMessage("callbackHappened", "*");
|
||||
|
|
|
@ -25,9 +25,8 @@ var start = window.mozAnimationStartTime;
|
|||
var firstListenerTime;
|
||||
var secondListenerTime;
|
||||
|
||||
function secondListener(ev) {
|
||||
secondListenerTime = ev.timeStamp;
|
||||
window.removeEventListener("MozBeforePaint", secondListener, false);
|
||||
function secondListener(t) {
|
||||
secondListenerTime = t;
|
||||
|
||||
// They really shouldn't be more than 100ms apart, but we can get weird
|
||||
// effects on slow machines. 5 minutes is our test timeout, though.
|
||||
|
@ -40,17 +39,14 @@ function secondListener(ev) {
|
|||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function firstListener(ev) {
|
||||
firstListenerTime = ev.timeStamp;
|
||||
window.removeEventListener("MozBeforePaint", firstListener, false);
|
||||
window.addEventListener("MozBeforePaint", secondListener, false);
|
||||
mozRequestAnimationFrame();
|
||||
function firstListener(t) {
|
||||
firstListenerTime = t;
|
||||
mozRequestAnimationFrame(secondListener);
|
||||
}
|
||||
|
||||
addLoadEvent(function() {
|
||||
setTimeout(function() {
|
||||
window.addEventListener("MozBeforePaint", firstListener, false);
|
||||
mozRequestAnimationFrame();
|
||||
mozRequestAnimationFrame(firstListener);
|
||||
}, 100);
|
||||
});
|
||||
|
||||
|
|
|
@ -24,16 +24,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=607529
|
|||
|
||||
var doneOneLoad = false;
|
||||
|
||||
var eventsHappening = false;
|
||||
var callbacksHappening = false;
|
||||
|
||||
function tryFinishTest() {
|
||||
if (eventsHappening && callbacksHappening) {
|
||||
w.close();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
/** Test for Bug 607529 **/
|
||||
window.onmessage = function(e) {
|
||||
isnot(e.data, "notcached", "Should never end up not being cached");
|
||||
|
@ -48,13 +38,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=607529
|
|||
else if (e.data == "revived") {
|
||||
w.postMessage("report", "*");
|
||||
}
|
||||
else if (e.data == "eventHappened") {
|
||||
eventsHappening = true;
|
||||
tryFinishTest();
|
||||
}
|
||||
else if (e.data == "callbackHappened") {
|
||||
callbacksHappening = true;
|
||||
tryFinishTest();
|
||||
w.close();
|
||||
SimpleTest.finish();
|
||||
} else {
|
||||
var msg = JSON.parse(e.data);
|
||||
if (msg.error) {
|
||||
|
|
|
@ -88,6 +88,10 @@ function startAnimatedScrollBy(dx, dy) {
|
|||
|
||||
var sentScrollBy = false;
|
||||
function nudgeScroll(now) {
|
||||
if (!scrolling) {
|
||||
// we've been canceled
|
||||
return;
|
||||
}
|
||||
var ddx = dx * (now - prevNow) / kDurationMs;
|
||||
var ddy = dy * (now - prevNow) / kDurationMs;
|
||||
|
||||
|
@ -110,18 +114,14 @@ function startAnimatedScrollBy(dx, dy) {
|
|||
rootView().scrollBy(fixupDx, fixupDy);
|
||||
|
||||
scrolling = false;
|
||||
removeEventListener("MozBeforePaint", nudgeScroll, false);
|
||||
}
|
||||
else {
|
||||
mozRequestAnimationFrame();
|
||||
mozRequestAnimationFrame(nudgeScroll);
|
||||
}
|
||||
|
||||
prevNow = now;
|
||||
}
|
||||
|
||||
nudgeScroll(start);
|
||||
addEventListener("MozBeforePaint",
|
||||
function (e) { nudgeScroll(e.timeStamp); },
|
||||
false);
|
||||
mozRequestAnimationFrame();
|
||||
mozRequestAnimationFrame(nudgeScroll);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ function test()
|
|||
var skipFrames = 1;
|
||||
var checkScroll = function () {
|
||||
if (skipFrames--) {
|
||||
window.mozRequestAnimationFrame();
|
||||
window.mozRequestAnimationFrame(checkScroll);
|
||||
return;
|
||||
}
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {}, gBrowser.contentWindow);
|
||||
|
@ -46,7 +46,6 @@ function test()
|
|||
ok((scrollHori && elem.scrollLeft > 0) ||
|
||||
(!scrollHori && elem.scrollLeft == 0),
|
||||
test.elem+' should'+(scrollHori ? '' : ' not')+' have scrolled horizontally');
|
||||
window.removeEventListener("MozBeforePaint", checkScroll, false);
|
||||
nextTest();
|
||||
};
|
||||
EventUtils.synthesizeMouse(elem, 50, 50, { button: 1 },
|
||||
|
@ -61,13 +60,12 @@ function test()
|
|||
EventUtils.synthesizeMouse(elem, 100, 100,
|
||||
{ type: "mousemove", clickCount: "0" },
|
||||
gBrowser.contentWindow);
|
||||
window.addEventListener("MozBeforePaint", checkScroll, false);
|
||||
/*
|
||||
* if scrolling didn’t work, we wouldn’t do any redraws and thus time out.
|
||||
* so request and force redraws to get the chance to check for scrolling at
|
||||
* all.
|
||||
*/
|
||||
window.mozRequestAnimationFrame();
|
||||
window.mozRequestAnimationFrame(checkScroll);
|
||||
}
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
<content clickthrough="never">
|
||||
<children/>
|
||||
</content>
|
||||
<implementation type="application/javascript" implements="nsIAccessibleProvider, nsIObserver, nsIDOMEventListener">
|
||||
<implementation type="application/javascript" implements="nsIAccessibleProvider, nsIObserver, nsIDOMEventListener, nsIFrameRequestCallback">
|
||||
<property name="accessibleType" readonly="true">
|
||||
<getter>
|
||||
<![CDATA[
|
||||
|
@ -870,7 +870,6 @@
|
|||
window.removeEventListener("keydown", this, true);
|
||||
window.removeEventListener("keypress", this, true);
|
||||
window.removeEventListener("keyup", this, true);
|
||||
window.removeEventListener("MozBeforePaint", this, true);
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
|
@ -994,9 +993,8 @@
|
|||
window.addEventListener("keydown", this, true);
|
||||
window.addEventListener("keypress", this, true);
|
||||
window.addEventListener("keyup", this, true);
|
||||
window.addEventListener("MozBeforePaint", this, true);
|
||||
|
||||
window.mozRequestAnimationFrame();
|
||||
window.mozRequestAnimationFrame(this);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
@ -1033,6 +1031,11 @@
|
|||
<parameter name="timestamp"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (!this._scrollable) {
|
||||
// Scrolling has been canceled
|
||||
return;
|
||||
}
|
||||
|
||||
// avoid long jumps when the browser hangs for more than
|
||||
// |maxTimeDelta| ms
|
||||
const maxTimeDelta = 100;
|
||||
|
@ -1065,7 +1068,7 @@
|
|||
this._scrollable.scrollLeft += actualScrollX;
|
||||
this._scrollable.scrollTop += actualScrollY;
|
||||
}
|
||||
window.mozRequestAnimationFrame();
|
||||
window.mozRequestAnimationFrame(this);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
@ -1106,15 +1109,22 @@
|
|||
</body>
|
||||
</method>
|
||||
|
||||
<!-- nsIFrameRequestCallback implementation -->
|
||||
<method name="sample">
|
||||
<parameter name="timeStamp"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
this.autoScrollLoop(timeStamp);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="handleEvent">
|
||||
<parameter name="aEvent"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (this._scrollable) {
|
||||
switch(aEvent.type) {
|
||||
case "MozBeforePaint":
|
||||
this.autoScrollLoop(aEvent.timeStamp);
|
||||
break;
|
||||
case "mousemove": {
|
||||
this._screenX = aEvent.screenX;
|
||||
this._screenY = aEvent.screenY;
|
||||
|
|
|
@ -81,19 +81,17 @@
|
|||
var startTime = window.mozAnimationStartTime;
|
||||
var self = this;
|
||||
|
||||
function nextStep(event) {
|
||||
function nextStep(t) {
|
||||
try {
|
||||
var width = stack.boxObject.width;
|
||||
if (!width) {
|
||||
// Maybe we've been removed from the document.
|
||||
if (self._alive)
|
||||
mozRequestAnimationFrame();
|
||||
else
|
||||
window.removeEventListener("MozBeforePaint", nextStep, false);
|
||||
mozRequestAnimationFrame(nextStep);
|
||||
return;
|
||||
}
|
||||
|
||||
var elapsedTime = event.timeStamp - startTime;
|
||||
var elapsedTime = t - startTime;
|
||||
|
||||
// Width of chunk is 1/5 (determined by the ratio 2000:400) of the
|
||||
// total width of the progress bar. The left edge of the chunk
|
||||
|
@ -107,13 +105,11 @@
|
|||
spacer.width = width;
|
||||
spacer.left = width * position;
|
||||
|
||||
mozRequestAnimationFrame();
|
||||
mozRequestAnimationFrame(nextStep);
|
||||
} catch (e) {
|
||||
window.removeEventListener("MozBeforePaint", nextStep, false);
|
||||
}
|
||||
}
|
||||
window.addEventListener("MozBeforePaint", nextStep, false);
|
||||
mozRequestAnimationFrame();
|
||||
mozRequestAnimationFrame(nextStep);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
|
|
|
@ -272,19 +272,26 @@
|
|||
|
||||
<field name="_scrollAnim"><![CDATA[({
|
||||
scrollbox: this,
|
||||
started: false,
|
||||
start: function scrollAnim_start(distance) {
|
||||
this.distance = distance;
|
||||
this.startPos = this.scrollbox.scrollPosition;
|
||||
this.duration = Math.min(1000, Math.round(50 * Math.sqrt(Math.abs(distance))));
|
||||
this.startTime = window.mozAnimationStartTime;
|
||||
|
||||
window.addEventListener("MozBeforePaint", this, false);
|
||||
window.mozRequestAnimationFrame();
|
||||
if (!this.started) {
|
||||
this.started = true;
|
||||
window.mozRequestAnimationFrame(this);
|
||||
}
|
||||
},
|
||||
stop: function scrollAnim_stop() {
|
||||
window.removeEventListener("MozBeforePaint", this, false);
|
||||
this.started = false;
|
||||
},
|
||||
handleEvent: function scrollAnim_handleEvent(event) {
|
||||
sample: function scrollAnim_handleEvent(event) {
|
||||
if (!this.started) {
|
||||
// We've been stopped
|
||||
return;
|
||||
}
|
||||
const timePassed = event.timeStamp - this.startTime;
|
||||
const pos = timePassed >= this.duration ? 1 :
|
||||
1 - Math.pow(1 - timePassed / this.duration, 4);
|
||||
|
@ -294,7 +301,7 @@
|
|||
if (pos == 1)
|
||||
this.scrollbox._stopSmoothScroll();
|
||||
else
|
||||
window.mozRequestAnimationFrame();
|
||||
window.mozRequestAnimationFrame(this);
|
||||
}
|
||||
})]]></field>
|
||||
|
||||
|
@ -638,15 +645,22 @@
|
|||
|
||||
<field name="_arrowScrollAnim"><![CDATA[({
|
||||
scrollbox: this,
|
||||
started: false,
|
||||
start: function arrowSmoothScroll_start() {
|
||||
this.lastFrameTime = window.mozAnimationStartTime;
|
||||
window.addEventListener("MozBeforePaint", this, false);
|
||||
window.mozRequestAnimationFrame();
|
||||
if (!this.started) {
|
||||
this.started = true;
|
||||
window.mozRequestAnimationFrame(this);
|
||||
}
|
||||
},
|
||||
stop: function arrowSmoothScroll_stop() {
|
||||
window.removeEventListener("MozBeforePaint", this, false);
|
||||
this.started = false;
|
||||
},
|
||||
handleEvent: function arrowSmoothScroll_handleEvent(event) {
|
||||
sample: function arrowSmoothScroll_handleEvent(event) {
|
||||
if (!this.started) {
|
||||
// We've been stopped
|
||||
return;
|
||||
}
|
||||
const scrollIndex = this.scrollbox._scrollIndex;
|
||||
const timePassed = event.timeStamp - this.lastFrameTime;
|
||||
this.lastFrameTime = event.timeStamp;
|
||||
|
@ -654,7 +668,7 @@
|
|||
const scrollDelta = 0.5 * timePassed * scrollIndex;
|
||||
this.scrollbox.scrollPosition += scrollDelta;
|
||||
|
||||
window.mozRequestAnimationFrame();
|
||||
window.mozRequestAnimationFrame(this);
|
||||
}
|
||||
})]]></field>
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче