[MediaWiki-commits] [Gerrit] VisualEditor/VisualEditor[master]: ve.ce.FocusableNode: Wrap updateInvisibleIcon in rAF
jenkins-bot has submitted this change and it was merged. Change subject: ve.ce.FocusableNode: Wrap updateInvisibleIcon in rAF .. ve.ce.FocusableNode: Wrap updateInvisibleIcon in rAF The width/height measurements done by hasRendering() cause slow forced reflows. Deferring these calls causes 40% less time to be spent in them, but we still spend ~400ms (down from ~700ms) doing reflows caused by these width/height measurements. I think this is probably a layout thrashing thing, as we modify the DOM (add the icon) for each FocusableNode that turns out to be empty, so that probably invalidates the layout and causes a new reflow to be needed for the next node. Change-Id: I29d64b1940eb8ca9b7e4825c68427f3dbd8d87f5 --- M src/ce/ve.ce.FocusableNode.js 1 file changed, 3 insertions(+), 1 deletion(-) Approvals: Divec: Looks good to me, approved jenkins-bot: Verified diff --git a/src/ce/ve.ce.FocusableNode.js b/src/ce/ve.ce.FocusableNode.js index b40b0c5..451611f 100644 --- a/src/ce/ve.ce.FocusableNode.js +++ b/src/ce/ve.ce.FocusableNode.js @@ -119,6 +119,8 @@ * @method */ ve.ce.FocusableNode.prototype.onFocusableSetup = function () { + var rAF = requestAnimationFrame || setTimeout; + // Exit if already setup or not attached if ( this.isFocusableSetup || !this.root ) { return; @@ -156,7 +158,7 @@ .find( 'img:not([width]),img:not([height])' ) .addBack( 'img:not([width]),img:not([height])' ) .on( 'load', this.updateInvisibleIcon.bind( this ) ); - this.updateInvisibleIcon(); + rAF( this.updateInvisibleIcon.bind( this ) ); } this.isFocusableSetup = true; -- To view, visit https://gerrit.wikimedia.org/r/311220 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I29d64b1940eb8ca9b7e4825c68427f3dbd8d87f5 Gerrit-PatchSet: 2 Gerrit-Project: VisualEditor/VisualEditor Gerrit-Branch: master Gerrit-Owner: CatropeGerrit-Reviewer: Divec Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] VisualEditor/VisualEditor[master]: ve.ce.FocusableNode: Wrap updateInvisibleIcon in rAF
Catrope has uploaded a new change for review. https://gerrit.wikimedia.org/r/311220 Change subject: ve.ce.FocusableNode: Wrap updateInvisibleIcon in rAF .. ve.ce.FocusableNode: Wrap updateInvisibleIcon in rAF The width/height measurements done by hasRendering() cause slow forced reflows. Deferring these calls causes 40% less time to be spent in them, but we still spend ~400ms (down from ~700ms) doing reflows caused by these width/height measurements. I think this is probably a layout thrashing thing, as we modify the DOM (add the icon) for each FocusableNode that turns out to be empty, so that probably invalidates the layout and causes a new reflow to be needed for the next node. Change-Id: I29d64b1940eb8ca9b7e4825c68427f3dbd8d87f5 --- M src/ce/ve.ce.FocusableNode.js 1 file changed, 3 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor refs/changes/20/311220/1 diff --git a/src/ce/ve.ce.FocusableNode.js b/src/ce/ve.ce.FocusableNode.js index b40b0c5..451611f 100644 --- a/src/ce/ve.ce.FocusableNode.js +++ b/src/ce/ve.ce.FocusableNode.js @@ -119,6 +119,8 @@ * @method */ ve.ce.FocusableNode.prototype.onFocusableSetup = function () { + var rAF = requestAnimationFrame || setTimeout; + // Exit if already setup or not attached if ( this.isFocusableSetup || !this.root ) { return; @@ -156,7 +158,7 @@ .find( 'img:not([width]),img:not([height])' ) .addBack( 'img:not([width]),img:not([height])' ) .on( 'load', this.updateInvisibleIcon.bind( this ) ); - this.updateInvisibleIcon(); + rAF( this.updateInvisibleIcon.bind( this ) ); } this.isFocusableSetup = true; -- To view, visit https://gerrit.wikimedia.org/r/311220 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I29d64b1940eb8ca9b7e4825c68427f3dbd8d87f5 Gerrit-PatchSet: 1 Gerrit-Project: VisualEditor/VisualEditor Gerrit-Branch: master Gerrit-Owner: Catrope___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits