Closed Bug 1182981 Opened 9 years ago Closed 9 years ago

Use nsTHashTable::Iterator in dom/{animation,indexedDB}/

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla42
Tracking Status
firefox42 --- fixed

People

(Reporter: n.nethercote, Assigned: birtles)

References

Details

Attachments

(4 files, 2 obsolete files)

Because iterators are so much nicer than enumerate functions.

There are ten occurrences of EnumerateEntries() in dom/{animation,indexedDB}/ to be dealt with.
I'll take care of PendingAnimationTracker and AnimationTimeline which accounts for 5 occurrences.
Assignee: nobody → bbirtles
(In reply to Brian Birtles (:birtles) from comment #1)
> I'll take care of PendingAnimationTracker and AnimationTimeline which
> accounts for 5 occurrences.

Want to do the indexedDB ones as well? They're pretty mechanical and easy :)  If not, can you please file a spin-off bug for indexedDB and rename this one? Thank you.
(In reply to Nicholas Nethercote [:njn] from comment #2)
> Want to do the indexedDB ones as well? 

Sure, no problem.
Status: NEW → ASSIGNED
Comment on attachment 8633272 [details] [diff] [review]
part 1 - Use nsTHashtable::Iterator in PendingAnimationTracker

Review of attachment 8633272 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/animation/PendingAnimationTracker.h
@@ +75,5 @@
>                   const AnimationSet& aSet) const;
>  
> +  static void TriggerAnimationsAtTime(AnimationSet& aAnimationSet,
> +                                      const TimeStamp& aReadyTime);
> +  static void TriggerAndClearAnimations(AnimationSet& aSet);

Do these need to be class methods? If not, I'd be inclined to put them entirely within PendingAnimationTracker.cpp, like TriggerAnimationAtTime() and TriggerAnimationNow() were, just to avoid exposing unnecessary details in the header file. (Note that the old functions should have been marked as |static|.)
Attachment #8633272 - Flags: review+
Attachment #8633273 - Flags: review+
(In reply to Nicholas Nethercote [:njn] from comment #9)
> Comment on attachment 8633272 [details] [diff] [review]
> part 1 - Use nsTHashtable::Iterator in PendingAnimationTracker
> 
> Review of attachment 8633272 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: dom/animation/PendingAnimationTracker.h
> @@ +75,5 @@
> >                   const AnimationSet& aSet) const;
> >  
> > +  static void TriggerAnimationsAtTime(AnimationSet& aAnimationSet,
> > +                                      const TimeStamp& aReadyTime);
> > +  static void TriggerAndClearAnimations(AnimationSet& aSet);
> 
> Do these need to be class methods? If not, I'd be inclined to put them
> entirely within PendingAnimationTracker.cpp, like TriggerAnimationAtTime()
> and TriggerAnimationNow() were, just to avoid exposing unnecessary details
> in the header file. (Note that the old functions should have been marked as
> |static|.)

Initially I did that, but the AnimationSet typedef is defined within the scope of PendingAnimationTracker so it was just easier to make them class scope. I suppose I could just redefine that inside PendingAnimationTracker.cpp
Attachment #8633275 - Flags: review+
Comment on attachment 8633274 [details] [diff] [review]
part 3 - Use nsTHashtable::Iterator in ActorsParent

Review of attachment 8633274 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good to me except that I'm not sure about the AssertIsOnBackgroundThread() call in NoteFinishedTransaction(). The obvious thing to do it to put it just before the iterator loop, but as we discussed on IRC it's not clear if that's necessary given that there is a AssertIsOnOwningThread() call at the start of that function. I'll let someone who knows this code better decide.
Attachment #8633274 - Flags: feedback+
Comment on attachment 8633274 [details] [diff] [review]
part 3 - Use nsTHashtable::Iterator in ActorsParent

Ben, do you mind looking at this? The main part I'm not sure about is what to do with the AssertIsOnBackgroundThread(). Do we need it in addition to the AssertIsOnOwningThread() at the start of the method? Or is one of the two enough?
Attachment #8633274 - Flags: review?(bent.mozilla)
(In reply to Brian Birtles (:birtles) from comment #10)
> Initially I did that, but the AnimationSet typedef is defined within the
> scope of PendingAnimationTracker so it was just easier to make them class
> scope. I suppose I could just redefine that inside
> PendingAnimationTracker.cpp

Another option would be to use lamda functions. E.g.:

  void
  PendingAnimationTracker::TriggerPendingAnimationsOnNextTick(...)
  {
    auto triggerAnimationAtTime = [](...) {
    };

    triggerAnimationAtTime(...);
  }
(In reply to Birunthan Mohanathas [:poiru] from comment #13)
> Another option would be to use lamda functions. E.g.:
> 
>   void
>   PendingAnimationTracker::TriggerPendingAnimationsOnNextTick(...)
>   {
>     auto triggerAnimationAtTime = [](...) {
>     };
> 
>     triggerAnimationAtTime(...);
>   }

Oh, neat. I didn't even think of that.
Hi Nicholas, care to have a quick look at this again? I replaced the class scope static methods with lambda functions as suggested by Birunthan. Other than that it should be identical to the previous patch.
Attachment #8633301 - Flags: review?(n.nethercote)
Attachment #8633272 - Attachment is obsolete: true
Sorry, slight simplification. Still new to lambdas.
Attachment #8633303 - Flags: review?(n.nethercote)
Attachment #8633301 - Attachment is obsolete: true
Attachment #8633301 - Flags: review?(n.nethercote)
Comment on attachment 8633303 [details] [diff] [review]
part 1 - Use nsTHashtable::Iterator in PendingAnimationTracker

Review of attachment 8633303 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/animation/PendingAnimationTracker.cpp
@@ +51,5 @@
>  void
>  PendingAnimationTracker::TriggerPendingAnimationsOnNextTick(const TimeStamp&
>                                                          aReadyTime)
>  {
> +  auto triggerAnimationsAtTime = [aReadyTime](AnimationSet& aAnimationSet) {

Call this triggerAnimationsAtReadyTime?
Attachment #8633303 - Flags: review?(n.nethercote) → review+
birtles: bent just stopped working for Mozilla and I'm not sure what his reviewing status is right now.
Comment on attachment 8633274 [details] [diff] [review]
part 3 - Use nsTHashtable::Iterator in ActorsParent

I think janv should review this.
Attachment #8633274 - Flags: review?(bent.mozilla) → review?(Jan.Varga)
Pushed parts 1, 2, and 4.
Keywords: leave-open
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: