diff options
Diffstat (limited to 'dom/events')
-rwxr-xr-x[-rw-r--r--] | dom/events/Event.cpp | 7 | ||||
-rwxr-xr-x[-rw-r--r--] | dom/events/Event.h | 1 | ||||
-rw-r--r-- | dom/events/EventStateManager.cpp | 5 | ||||
-rw-r--r-- | dom/events/test/test_eventTimeStamp.html | 26 |
4 files changed, 25 insertions, 14 deletions
diff --git a/dom/events/Event.cpp b/dom/events/Event.cpp index a85a0d66b..2af34136e 100644..100755 --- a/dom/events/Event.cpp +++ b/dom/events/Event.cpp @@ -32,6 +32,7 @@ #include "nsJSEnvironment.h" #include "nsLayoutUtils.h" #include "nsPIWindowRoot.h" +#include "mozilla/TimerClamping.h" #include "WorkerPrivate.h" namespace mozilla { @@ -1085,6 +1086,12 @@ Event::DefaultPrevented(JSContext* aCx) const double Event::TimeStamp() const { + return TimerClamping::ReduceMsTimeValue(TimeStampImpl()); +} + +double +Event::TimeStampImpl() const +{ if (!sReturnHighResTimeStamp) { return static_cast<double>(mEvent->mTime); } diff --git a/dom/events/Event.h b/dom/events/Event.h index 4ac6a68d5..c28226e8a 100644..100755 --- a/dom/events/Event.h +++ b/dom/events/Event.h @@ -62,6 +62,7 @@ private: void ConstructorInit(EventTarget* aOwner, nsPresContext* aPresContext, WidgetEvent* aEvent); + double TimeStampImpl() const; public: static Event* FromSupports(nsISupports* aSupports) diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index 659629066..c23cdb575 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -4151,9 +4151,10 @@ EventStateManager::NotifyMouseOver(WidgetMouseEvent* aMouseEvent, // content associated with our subdocument. EnsureDocument(mPresContext); if (nsIDocument *parentDoc = mDocument->GetParentDocument()) { - if (nsIContent *docContent = parentDoc->FindContentForSubDocument(mDocument)) { + if (nsCOMPtr<nsIContent> docContent = + parentDoc->FindContentForSubDocument(mDocument)) { if (nsIPresShell *parentShell = parentDoc->GetShell()) { - EventStateManager* parentESM = + RefPtr<EventStateManager> parentESM = parentShell->GetPresContext()->EventStateManager(); parentESM->NotifyMouseOver(aMouseEvent, docContent); } diff --git a/dom/events/test/test_eventTimeStamp.html b/dom/events/test/test_eventTimeStamp.html index a3d096432..107a21f87 100644 --- a/dom/events/test/test_eventTimeStamp.html +++ b/dom/events/test/test_eventTimeStamp.html @@ -60,8 +60,8 @@ function testRegularEvents() { var timeBeforeEvent = window.performance.now(); window.addEventListener("load", function(evt) { var timeAfterEvent = window.performance.now(); - ok(evt.timeStamp > timeBeforeEvent && - evt.timeStamp < timeAfterEvent, + ok(evt.timeStamp >= timeBeforeEvent && + evt.timeStamp <= timeAfterEvent, "Event timestamp (" + evt.timeStamp + ") is in expected range: (" + timeBeforeEvent + ", " + timeAfterEvent + ")"); testWorkerEvents(); @@ -74,11 +74,12 @@ function testWorkerEvents() { var worker = new Worker(window.URL.createObjectURL(blob)); worker.onmessage = function(evt) { var timeAfterEvent = window.performance.now(); - ok(evt.data > timeBeforeEvent && - evt.data < timeAfterEvent, - "Event timestamp in dedicated worker (" + evt.data + - ") is in expected range: (" + - timeBeforeEvent + ", " + timeAfterEvent + ")"); + // Comparing times across timelines may break now + // ok(evt.data >= timeBeforeEvent && + // evt.data <= timeAfterEvent, + // "Event timestamp in dedicated worker (" + evt.data + + // ") is in expected range: (" + + // timeBeforeEvent + ", " + timeAfterEvent + ")"); worker.terminate(); testSharedWorkerEvents(); }; @@ -97,11 +98,12 @@ function testSharedWorkerEvents() { var worker = new SharedWorker(window.URL.createObjectURL(blob)); worker.port.onmessage = function(evt) { var timeAfterEvent = window.performance.now(); - ok(evt.data > 0 && - evt.data < timeAfterEvent - timeBeforeWorkerCreation, - "Event timestamp in shared worker (" + evt.data + - ") is in expected range: (0, " + - (timeAfterEvent - timeBeforeWorkerCreation) + ")"); + // Comparing times across timelines may break now + // ok(evt.data >= 0 && + // evt.data <= timeAfterEvent - timeBeforeWorkerCreation, + // "Event timestamp in shared worker (" + evt.data + + // ") is in expected range: (0, " + + // (timeAfterEvent - timeBeforeWorkerCreation) + ")"); worker.port.close(); finishTests(); }; |