Commit Graph

42 Commits

Author SHA1 Message Date
Emilio Cobos Álvarez
d2ed260822 Bug 1517241 - Rename nsIDocument to mozilla::dom::Document. r=smaug
Summary: Really sorry for the size of the patch. It's mostly automatic
s/nsIDocument/Document/ but I had to fix up in a bunch of places manually to
add the right namespacing and such.

Overall it's not a very interesting patch I think.

nsDocument.cpp turns into Document.cpp, nsIDocument.h into Document.h and
nsIDocumentInlines.h into DocumentInlines.h.

I also changed a bunch of nsCOMPtr usage to RefPtr, but not all of it.

While fixing up some of the bits I also removed some unneeded OwnerDoc() null
checks and such, but I didn't do anything riskier than that.
2019-01-03 17:48:33 +01:00
Emilio Cobos Álvarez
006a4ab94a Bug 1516366 - Move nsOnloadBlocker and nsDocumentOnStack to nsDocument.cpp, and shrink nsDocument.h to the minimmum. r=smaug
This needs to add a few of includes in other places which were relying on the
massive (now gone) list in nsDocument.h.

I also needed to move an AnimationTimeline destructor out of line because it
relied on dom::Animation being defined, yet Animation.h includes
AnimationTimeline.h, so include hell.

Differential Revision: https://phabricator.services.mozilla.com/D15366
2018-12-29 20:41:42 +01:00
Brian Birtles
928d88aabb Bug 1433705 - Rename GetCurrentTime to GetCurrentTimeAsDuration; r=hiro
To avoid having to always work around conflicts with winbase.h.

Differential Revision: https://phabricator.services.mozilla.com/D13951

--HG--
extra : moz-landing-system : lando
2018-12-06 22:16:48 +00:00
Sylvestre Ledru
265e672179 Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
# ignore-this-changeset

--HG--
extra : amend_source : 4d301d3b0b8711c4692392aa76088ba7fd7d1022
2018-11-30 11:46:48 +01:00
Hiroyuki Ikezoe
1609fd1ef0 Bug 1472900 - Use timestamp associated with the timeline for animation cancel events. r=birtles
Before this change, the test in this commit fails.  The received events order
is;

 1) cancel
 2) transitioncancel
 3) transitionstart
 4) finish

MozReview-Commit-ID: 8liTFXime6e

--HG--
extra : rebase_source : 3c68ef330b1f263afa2fad9670a30b351b8dbf28
2018-07-05 06:19:12 +09:00
Hiroyuki Ikezoe
8b30a3dc7b Bug 1354501 - Dispatch web animation events at the same time when CSS animations/transitions events are dispatched. r=birtles
MozReview-Commit-ID: u7lWtAF8Ml

--HG--
extra : rebase_source : 6ce807bc253706483960dade2f2c926fa9821460
2018-07-03 11:05:23 +09:00
Mantaroh Yoshinaga
6ef497660b Bug 1277272 - Remove RefreshObserver when removing animation from timeline. r=birtles
MozReview-Commit-ID: DGSHye0lmdm
2016-06-23 13:09:03 +09:00
Jonathan Watt
1c0c9bcf8a Bug 763784 - Make VectorImage::GetAnimated check for CSS animations. r=dholbert 2016-02-22 13:05:20 +00:00
Hiroyuki Ikezoe
c1f10eb765 Bug 1212720 - Part 3: Remove AnimationTimeline.getAnimations. r=heycam, r=smaug
--HG--
extra : histedit_source : 3b036799886ebcc8498d495346eae963a5b5863d
2015-12-21 20:39:00 -05:00
Olli Pettay
f50a8c0983 Bug 1223445 - KeyframeEffectReadOnly objects end up keeping lots of other objects alive too long, r=birtles
--HG--
extra : rebase_source : df6828ce26e22e53b632f25952fd1741a693c36a
2015-11-16 19:44:55 +02:00
Nathan Froyd
01583602a9 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
The bulk of this commit was generated with a script, executed at the top
level of a typical source code checkout.  The only non-machine-generated
part was modifying MFBT's moz.build to reflect the new naming.

CLOSED TREE makes big refactorings like this a piece of cake.

 # The main substitution.
find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \
    xargs perl -p -i -e '
 s/nsRefPtr\.h/RefPtr\.h/g; # handle includes
 s/nsRefPtr ?</RefPtr</g;   # handle declarations and variables
'

 # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h.
perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h

 # Handle nsRefPtr.h itself, a couple places that define constructors
 # from nsRefPtr, and code generators specially.  We do this here, rather
 # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename
 # things like nsRefPtrHashtable.
perl -p -i -e 's/nsRefPtr/RefPtr/g' \
     mfbt/nsRefPtr.h \
     xpcom/glue/nsCOMPtr.h \
     xpcom/base/OwningNonNull.h \
     ipc/ipdl/ipdl/lower.py \
     ipc/ipdl/ipdl/builtin.py \
     dom/bindings/Codegen.py \
     python/lldbutils/lldbutils/utils.py

 # In our indiscriminate substitution above, we renamed
 # nsRefPtrGetterAddRefs, the class behind getter_AddRefs.  Fix that up.
find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \
    xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g'

if [ -d .git ]; then
    git mv mfbt/nsRefPtr.h mfbt/RefPtr.h
else
    hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h
fi

--HG--
rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
2015-10-18 01:24:48 -04:00
Brian Birtles
68cafe83b4 Bug 1195180 part 7 - Store animations in an array; r=heycam
Currently AnimationTimeline stores animations in a hashmap which means that
when we go to iterate over those animations to tick them we will visit them
in an order that is non-deterministic.

Although many of the observable effects of ticking an animation (e.g. CSS
animation/transition events, mutation observer events) are later sorted so that
the result does not depend on the order in which animations are ticked, this is
not true for in all cases. In particular, the order in which Animation.finished
promises are resolved will vary depending on the order in which animations are
ticked. Likewise, for Animation finish events.

Furthermore, it seems generally desirable to have a deterministic order for
visiting animations in order to aid reproducing bugs.

To achieve this, this patch switches the storage of animations in
AnimationTimeline to use an array instead. However, when adding animations
we need to determine if the animation to add already exists. To this end we
also maintain a hashmap of the animations so we can quickly determine if
the animation to add is a duplicate or not.
2015-09-28 12:38:41 +09:00
Brian Birtles
ae189d2746 Bug 1195180 part 6 - Lazily remove animations from timelines; r=heycam
Now that DocumentTimeline observes the refresh driver we can use regular
ticks to remove unnecessary animations.

We do this because in a subsequent patch, in order to provide deterministic
enumeration order when ticking animations, we will store animations in an array.
Removing an arbitrary element from an nsTArray is O(n) since we have to search
for the array index first, or O(log n) if we keep the array sorted. If we
destroy a subtree containing n animations, the operation effectively becomes
O(n^2), or, if we keep the array sorted, O(n log n). By destroying during a
tick when we are already iterating over the array, however, we will be able
to do this much more efficiently.

Whether an animation is newly associated with a timeline, or is disassociated
from a timeline, or if it merely has its timing updated, the behavior
implemented in this patch is to simply make sure we are observing the refresh
driver and deal with the animation on the next tick.

It might seem that we could be a lot more clever about this and, for example, if
an animation reports NeedsTicks() == false, not start observing the refresh
driver. There are various edge cases however that need to be taken into account.
For example, if a CSS animation is finished (IsRelevant() == false so that
animation will have been removed from the timeline), and paused
(NeedsTicks() == false), and we seek it back to the point where it is relevant
again, we actually need to observe the refresh driver so that it can dispatch an
animationstart event on the next tick. A test case in a subsequent patch tests
this specific situation.

We could possibly add logic to detect if we need to fire events on the next tick
but the complexity does not seem warranted given that even if we unnecessarily
start observing the refresh driver, we will stop watching it on the next tick.

This patch removes some rather lengthy comments from
AnimationTiming::UpdateTiming. This is, in part, because of the behavior
described above that makes these comments no longer relevant. Other parts are
removed because the Web Animations specification has been updated such that a
timeline becoming inactive now pauses the animation[1] so that the issue
regarding detecting timelines becoming active/inactive no longer applies
since animations attached to an inactive timeline remain "relevant".

[1] https://w3c.github.io/web-animations/#responding-to-a-newly-inactive-timeline
2015-09-28 12:38:41 +09:00
Brian Birtles
4ba3abb7d3 Bug 1195180 part 5 - Synchronize refresh driver observing with presshell creation/teardown; r=heycam 2015-09-28 12:38:40 +09:00
Ehsan Akhgari
210879a004 Bug 1113086 follow-up: Add a forward declaration to fix build bustage 2015-07-10 20:49:32 -04:00
Carsten "Tomcat" Book
72634f3fbc Backed out changeset 91846db1056c (bug 1113086) 2015-07-11 14:13:36 +02:00
Ehsan Akhgari
3a8e01586f Bug 1113086 follow-up: Add a forward declaration to fix build bustage 2015-07-10 21:09:08 -04:00
Brian Birtles
6434e79a4b Bug 1150810 part 10 - Add AnimationTimeline::GetAnimations; r=jwatt; r=smaug
This patch also removes the (commented-out) play() method from the
AnimationTimeline.webidl since it has been removed from the spec.

--HG--
extra : commitid : 20j8RFhPyP9
extra : rebase_source : 9eb5376f3ad9f4a4a0a214bdbe5593f682316d5b
2015-06-15 11:05:43 +09:00
Brian Birtles
6bb747268e Bug 1150810 part 8 - Add AnimationTimeline::AddAnimations/RemoveAnimations; r=jwatt
--HG--
extra : commitid : 2zvcGrXcqJR
extra : rebase_source : 791f417a3688cbdd9bd4c9cd24c46551b0d775f5
2015-04-28 16:41:09 +09:00
Brian Birtles
1926b13212 Bug 1150810 part 1 - Move DocumentTimeline methods up to AnimationTimeline; r=jwatt
This is not strictly necessary yet but we will want to implement methods
like GetAnimations() on the base class, AnimationTimeline, so we may as well do
that now rather than adding that code to DocumentTimeline and moving it later.

--HG--
extra : commitid : 7GU6Dr9lnPO
extra : rebase_source : d5e788874c72c422b57efbdb81404c79df6d505b
2015-04-28 11:17:10 +09:00
Andrew McCreight
9e8f4b219e Bug 1152551, part 2 - Fix mode lines in dom/. r=jst 2015-05-03 15:32:37 -04:00
Brian Birtles
6b5fcefb36 Bug 1152171 part 2 - Rename AnimationTimeline to DocumentTimeline; r=smaug
And then re-add AnimationTimeline as an abstract super-interface of
DocumentTimeline.

--HG--
rename : dom/animation/AnimationTimeline.cpp => dom/animation/DocumentTimeline.cpp
rename : dom/animation/AnimationTimeline.h => dom/animation/DocumentTimeline.h
rename : dom/animation/test/animation-timeline/test_animation-timeline.html => dom/animation/test/document-timeline/test_document-timeline.html
rename : dom/animation/test/animation-timeline/test_request_animation_frame.html => dom/animation/test/document-timeline/test_request_animation_frame.html
2015-04-10 10:34:22 +09:00
Ehsan Akhgari
883849ee32 Bug 1145631 - Part 1: Replace MOZ_OVERRIDE and MOZ_FINAL with override and final in the tree; r=froydnj
This patch was automatically generated using the following script:

function convert() {
echo "Converting $1 to $2..."
find . \
       ! -wholename "*/.git*" \
       ! -wholename "obj-ff-dbg*" \
         -type f \
      \( -iname "*.cpp" \
         -o -iname "*.h" \
         -o -iname "*.c" \
         -o -iname "*.cc" \
         -o -iname "*.idl" \
         -o -iname "*.ipdl" \
         -o -iname "*.ipdlh" \
         -o -iname "*.mm" \) | \
    xargs -n 1 sed -i -e "s/\b$1\b/$2/g"
}

convert MOZ_OVERRIDE override
convert MOZ_FINAL final
2015-03-21 12:28:04 -04:00
Boris Zbarsky
dc24477d79 Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp.  The
rest of this diff was generated by running the following commands:

  find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'

  find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'

  find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'

  find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'

  find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'

  find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 10:13:33 -04:00
Jonathan Watt
393081114a Bug 1105098 - Make AnimationTimeline always return the same parent object (even after document.open()) and replace the document's timeline if the document is reset. r=smaug,birtles 2015-01-26 17:08:51 +00:00
Brian Birtles
a31477d9b4 Bug 1112480 part 8 - Remove AnimationTimeline::FastForward; r=jwatt
Now that we don't actually start pending animations until the following refresh
driver tick we no longer need to be able to fast-forward the AnimationTimeline
between ticks.
2015-01-09 07:57:58 +09:00
Brian Birtles
9eb65d26c7 Bug 1112480 part 5 - Add AnimationTimeline::IsUnderTestControl; r=jwatt
Earlier in this patch series we added AnimationPlayer::StartOnNextTick which
takes a ready time parameter expressed in timeline time. In order to call this
method when painting finishes we need to convert the TimeStamp recorded when
painting finished to a timeline time. However, when the timeline is driven by
a refresh driver under test control we can no longer meaningfully do this
conversion since there is no correspondence between the notion of time used to
record the time when painting finished (wallclock time) and the notion of time
used by the timeline (which has been arbitrarily adjusted by test code).

We need a way to detect this situation so that we know not to call
ToTimelineTime in that case.

Alternatively, we could make ToTimelineTime automatically return a null value
when its refresh driver is under test control. However, in this situation
ToTimelineTime can still actually be used to convert a TimeStamp to a timeline
time as long as the TimeStamp is from the same refresh driver. Indeed,
GetCurrentTime does exactly that. So if we were to go down that route we would
have to provide a way for GetCurrentTime to work around that restriction.

For now, this patch puts the onus on the caller of ToTimelineTime to check if
the timeline is under test control first (unless they are passing a TimeStamp
from the same refresh driver, in which case there is no need to check).
2015-01-09 07:57:58 +09:00
Brian Birtles
24eaa57ecc Bug 927349 part 19 - Don't add pending animations to layers when their refresh driver is under test control; r=jwatt 2014-12-22 09:35:42 +09:00
Brian Birtles
fb0d9d7187 Bug 927349 part 8 - Fast-forward the timeline before resolving start times; r=jwatt
Normally animation players get times from their timeline which is based on the
refresh driver for their associated document. However, for animations that
we time from when their first frame has been rendered, we want to record the
actual time when painting finished as their start time. If we wait until the
next refresh driver tick then the delay between playing an animation and its
actual start will be too great.

In this patch, we introduce a mechanism for fast-forwarding a timeline to a
time between the current refresh driver time and the next refresh driver tick.
By adjusting the timeline rather than the player we maintain a consistent state
(in fact, if we just naively set the animation player start time to the
timestamp value we recorded when painting finished it will appear to start in
the future and the animation will temporarily jump from playing, to waiting to
start, then back to playing again on the next refresh driver tick).

To be completely consistent, however, when we fast-forward the timeline we
should tell all animation players listening to the timeline to mark their
target element as needing a style flush. Otherwise we may be able to observe an
inconsistency between some animation players' current time and the computed
style of their targets.

We don't, however, currently know which players are observing a given timeline.
We will likely introduce that in the near future (in order to implement
AnimationTimeline.getAnimationPlayers) and fix the inconsistency in timing then.
A test later in the patch series verifies this inconsistency so it is easy to
fix in future.

An alternative approach would be to simply record the time when animation should
start, send that time to the compositor but don't actually update the animation
start time on the main thread until the subsequent refresh driver tick. Such
an approach is complex as it introduces an additional state--"finished pending
but not yet started". We will attempt to switch to that approach in bug 1112480.
2014-12-22 09:35:41 +09:00
Brian Birtles
7f2f1073ca Bug 927349 part 7 - Factor out AnimationTimeline::GetRefreshDriver into a separate method; r=jwatt
This is in preparation for adding AnimationTimeline::FastForward in the next
patch which will reuse this code.
2014-12-18 08:42:41 +09:00
Brian Birtles
4d0e7f2cd7 Bug 1104435 part 1 - Make AnimationTimeline::GetParentObject return an nsIGlobalObject; r=smaug
In order to create a Promise object for AnimationPlayer.ready, we need an
nsIGlobalObject. Currently we can access this through the following chain:

  AnimationPlayer -> AnimationTimeline -> Document -> nsIGlobalObject

Come bug 1096776 (Support AnimationPlayers without a timeline or with an
inactive timeline) we will no longer be able to rely on having an
AnimationTimeline so we will probably have to store the corresponding window
object on the AnimationPlayer. For now, however, we can look up the timeline as
above.

This patch makes this a little more straightforward by changing the return type
and value of AnimationTimeline::GetParentObject to return the nsIGlobalObject of
the document with which it is associated.
2014-12-18 08:42:40 +09:00
Brian Birtles
07c1c4a9cc Bug 1078119 - Rename AnimationTimeline/AnimationPlayer GetCurrentTimeDuration; r=bz
This patch performs the following renaming:

  AnimationPlayer::GetCurrentTime -> GetCurrentTimeAsDouble
  AnimationPlayer::GetCurrentTimeDuration -> GetCurrentTime
  AnimationTimeline::GetCurrentTime -> GetCurrentTimeAsDouble
  AnimationTimeline::GetCurrentTimeDuration -> GetCurrentTime
2014-10-20 13:55:45 +09:00
Peter Van der Beken
dcda2ba9bb Bug 1078744 - Replace SetIsDOMBinding with SetIsNonDOMBinding, remove nsWrapperCache::SetIsDOMBinding. r=bz.
--HG--
extra : rebase_source : 89c476cd9436530b2df5acc903909e34188417a0
2014-10-07 11:44:49 +02:00
David Zbarsky
13da8bae55 Bug 1033114 Part 4: Make mStartTime a nullable TimeDuration r=birtles 2014-08-30 02:11:57 -04:00
David Zbarsky
cbd65c781b Bug 1033114 Part 3: Make mStartTime a nullable TimeDuration r=birtles 2014-08-30 02:11:57 -04:00
Ehsan Akhgari
444cd1c72e Bug 1050611 - Fix more bad implicit constructors in dom and docshell; r=smaug 2014-08-08 09:49:39 -04:00
Brian Birtles
fb9a1a8fb3 Bug 1002332 - Make AnimationTimeline record the last refresh time and use that when there is no refresh driver; r=bz
A document that belongs to an iframe that is display:none as no associated pres
context from which to get a refresh driver. However, in this case
document.timeline.currentTime should still never go backwards (since document
timelines are supposed to be monotonically increasing).

This patch makes AnimationTimeline record the last value returned for the
current time so that if the document becomes display:none we can still return
the most recently used time.
2014-07-24 13:37:38 +09:00
Brian Birtles
728dbd075d Bug 1032573 part 4 - Add AnimationTimeline::ToTimelineTime helper method; r=dbaron
This patch simply factors out the conversion from a TimeStamp value to
a nullable-double value relative to the start of the timeline. This is so that,
in a subsequent patch, this functionality can be reused by ElementAnimation
when it reports its start time (which is currently recorded as a TimeStamp).
2014-07-16 09:02:30 +09:00
Brian Birtles
7bb5ae0ed8 Bug 1032573 part 3 - Add AnimationTimeline::GetCurrentTimeStamp; r=dbaron
AnimationTimeline::GetCurrentTime returns the time value of the timeline as
a double. For internal calculations however it is more useful to get this as
a mozilla::TimeStamp.

This patch splits the calculation of the current time into two stages:
calculation as a timestamp then conversion to a double.
2014-07-16 09:02:30 +09:00
Benoit Jacob
ec742680c8 Bug 1028588 - Fix dangerous public destructors in the rest of dom/ - r=ehsan 2014-06-23 15:56:07 -04:00
Brian Birtles
3312bd13c9 Bug 998246 part 4 - Add currentTime member to AnimationTimeline; r=bz 2014-05-13 16:22:12 +09:00
Brian Birtles
09dc4937eb Bug 998246 part 2 - Add AnimationTimeline interface; r=bz, r=glandium 2014-05-13 16:22:12 +09:00