зеркало из https://github.com/mozilla/gecko-dev.git
Bug 539095 - Expose high-res timers to web content (performance.now()). r=bz, sr=smaug
--HG-- extra : transplant_source : o%9F%061%D4%B5%7D%5C%FB%95%5D%16%27%DEKU%EC%21%3AR
This commit is contained in:
Родитель
347c7b2ab7
Коммит
b2fd1edcc9
|
@ -95,6 +95,12 @@ public:
|
|||
nsresult TimeStampToDOMOrFetchStart(mozilla::TimeStamp aStamp,
|
||||
DOMTimeMilliSec* aResult);
|
||||
|
||||
inline DOMHighResTimeStamp TimeStampToDOMHighRes(mozilla::TimeStamp aStamp)
|
||||
{
|
||||
mozilla::TimeDuration duration = aStamp - mNavigationStartTimeStamp;
|
||||
return duration.ToMilliseconds();
|
||||
}
|
||||
|
||||
private:
|
||||
nsDOMNavigationTiming(const nsDOMNavigationTiming &){};
|
||||
~nsDOMNavigationTiming();
|
||||
|
|
|
@ -319,3 +319,11 @@ nsPerformance::GetNavigation(nsIDOMPerformanceNavigation** aNavigation)
|
|||
NS_IF_ADDREF(*aNavigation = mNavigation);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPerformance::Now(DOMHighResTimeStamp* aNow)
|
||||
{
|
||||
*aNow = mDOMTiming->TimeStampToDOMHighRes(mozilla::TimeStamp::Now());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ class nsWrapperCache;
|
|||
|
||||
typedef unsigned long long DOMTimeStamp;
|
||||
typedef unsigned long long DOMTimeMilliSec;
|
||||
typedef double DOMHighResTimeStamp;
|
||||
|
||||
// Core
|
||||
interface nsIDOMAttr;
|
||||
|
|
|
@ -37,14 +37,16 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "domstubs.idl"
|
||||
interface nsIDOMPerformanceTiming;
|
||||
interface nsIDOMPerformanceNavigation;
|
||||
|
||||
[scriptable, uuid(446faf26-000b-4e66-a5fd-ae37c5ed6beb)]
|
||||
[scriptable, uuid(ac274ec8-ee9f-44ef-b2f0-b13c22225a98)]
|
||||
interface nsIDOMPerformance : nsISupports
|
||||
{
|
||||
readonly attribute nsIDOMPerformanceTiming timing;
|
||||
readonly attribute nsIDOMPerformanceNavigation navigation;
|
||||
|
||||
DOMHighResTimeStamp now();
|
||||
};
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ _TEST_FILES = \
|
|||
test_focus_legend_noparent.html \
|
||||
file_clonewrapper.html \
|
||||
file_moving_nodeList.html \
|
||||
test_performance_now.html \
|
||||
$(NULL)
|
||||
|
||||
_CHROME_FILES = \
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for High Resolution Timer</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
ok(window.performance);
|
||||
ok(typeof window.performance.now == 'function');
|
||||
var n = window.performance.now();
|
||||
ok(n >= 0);
|
||||
ok(window.performance.now() >= n);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
setTimeout(function() {
|
||||
ok(window.performance.now() > n);
|
||||
SimpleTest.finish();
|
||||
}, 20);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -468,6 +468,11 @@ members = [
|
|||
'nsIIndexedDatabaseUsageCallback.*',
|
||||
'nsIIndexedDatabaseManager.*',
|
||||
|
||||
# Performance
|
||||
'nsIDOMPerformance.*',
|
||||
'nsIDOMPerformanceTiming.*',
|
||||
'nsIDOMPerformanceNavigation.*',
|
||||
|
||||
'nsIDOMDOMError.*',
|
||||
]
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче