jenkins-bot has submitted this change and it was merged.
Change subject: Add ve.now utility function
......................................................................
Add ve.now utility function
On browsers that implement the Navigation Timing API, performance.now()
provides values with microsecond precision that are guaranteed to be monotonic
(i.e., they are not subject to skew due to changes to the system clock).
This patch adds a `ve.now` utility function that will use this API when it is
available and fall back gracefully to `Date.now` when it is not.
Change-Id: I377025fcb23cb26399b9e437e33c8afa138916af
---
M modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js
M modules/ve/ve.js
2 files changed, 17 insertions(+), 0 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js
b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js
index 1b03afb..7d03609 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js
@@ -70,6 +70,7 @@
Array.prototype.filter &&
Array.prototype.indexOf &&
Array.prototype.map &&
+ Date.now &&
Date.prototype.toJSON &&
Function.prototype.bind &&
Object.create &&
diff --git a/modules/ve/ve.js b/modules/ve/ve.js
index 21391f8..4faaa7b 100644
--- a/modules/ve/ve.js
+++ b/modules/ve/ve.js
@@ -989,6 +989,22 @@
return $element.get( 0 );
};
+ /**
+ * Get the current time, measured in milliseconds since January 1, 1970
(UTC).
+ *
+ * On browsers that implement the Navigation Timing API, this function
will produce floating-point
+ * values with microsecond precision that are guaranteed to be
monotonic. On all other browsers,
+ * it will fall back to using `Date.now`.
+ *
+ * @returns {number} Current time
+ */
+ ve.now = ( function () {
+ var perf = window.performance,
+ navStart = perf && perf.timing &&
perf.timing.navigationStart;
+ return navStart && typeof perf.now === 'function' ?
+ function () { return navStart + perf.now(); } :
Date.now;
+ }() );
+
// Add more as you need
ve.Keys = {
'UNDEFINED': 0,
--
To view, visit https://gerrit.wikimedia.org/r/77036
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I377025fcb23cb26399b9e437e33c8afa138916af
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits