Bug 1316459 - play range outline animations after its properties have been set as the result of a scheduled repaint of the modal highlighter. r=Gijs

MozReview-Commit-ID: 4xLHwB0l4ja

--HG--
extra : rebase_source : 34e045fb3264ad86e819bd341dab57cd820f77ed
This commit is contained in:
Mike de Boer 2017-01-23 20:13:07 +01:00
Родитель 55aa51e408
Коммит 0ca886f4ee
2 изменённых файлов: 31 добавлений и 21 удалений

Просмотреть файл

@ -431,6 +431,10 @@ FinderHighlighter.prototype = {
return;
}
dict.animateOutline = true;
// Immediately finish running animations, if any.
this._finishOutlineAnimations(dict);
if (foundRange !== dict.currentFoundRange || data.findAgain) {
dict.previousFoundRange = dict.currentFoundRange;
dict.currentFoundRange = foundRange;
@ -441,22 +445,6 @@ FinderHighlighter.prototype = {
this._maybeCreateModalHighlightNodes(window);
}
let outlineNode = dict.modalHighlightOutline;
if (outlineNode && !this._isPageTooBig(dict)) {
let animation;
if (dict.animations) {
for (animation of dict.animations)
animation.finish();
}
dict.animations = [];
for (let i = dict.previousRangeRectsAndTexts.rectList.length - 1; i >= 0; --i) {
animation = outlineNode.setAnimationForElement(kModalOutlineId + i,
Cu.cloneInto(kModalOutlineAnim.keyframes, window), kModalOutlineAnim.duration);
animation.onfinish = function(idx) { dict.animations.splice(idx, 1); }.bind(null, i);
dict.animations.push(animation);
}
}
if (this._highlightAll)
this.highlight(true, data.searchString, data.linksOnly);
},
@ -476,10 +464,7 @@ FinderHighlighter.prototype = {
}
let dict = this.getForWindow(window.top);
if (dict.animations) {
for (let animation of dict.animations)
animation.finish();
}
this._finishOutlineAnimations(dict);
dict.dynamicRangesSet.clear();
dict.frames.clear();
dict.modalHighlightRectsMap.clear();
@ -1006,9 +991,34 @@ FinderHighlighter.prototype = {
document.insertAnonymousContent(outlineBox);
}
if (dict.animateOutline && !this._isPageTooBig(dict)) {
let animation;
dict.animations = new Set();
for (let i = rectsAndTexts.rectList.length - 1; i >= 0; --i) {
animation = dict.modalHighlightOutline.setAnimationForElement(kModalOutlineId + i,
Cu.cloneInto(kModalOutlineAnim.keyframes, window), kModalOutlineAnim.duration);
animation.onfinish = function() { dict.animations.delete(this); };
dict.animations.add(animation);
}
}
dict.animateOutline = false;
dict.previousUpdatedRange = range;
},
/**
* Finish any currently playing animations on the found range outline node.
*
* @param {Object} dict Dictionary of properties belonging to the currently
* active window
*/
_finishOutlineAnimations(dict) {
if (!dict.animations)
return;
for (let animation of dict.animations)
animation.finish();
},
/**
* Safely remove the outline AnoymousContent node from the CanvasFrame.
*

Просмотреть файл

@ -199,7 +199,7 @@ add_task(function* testModalResults() {
rectCount: 2,
insertCalls: [2, 4],
removeCalls: [0, 1],
animationCalls: [5, 6]
animationCalls: [1, 2]
}],
["their law might propagate their kind", {
rectCount: 2,