AnimationController should have a Frame& internally.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Sep 2013 22:37:57 +0000 (22:37 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Sep 2013 22:37:57 +0000 (22:37 +0000)
<https://webkit.org/b/121078>

Reviewed by Anders Carlsson.

The AnimationController is owned by the Frame so make the back-pointer
a reference. This knocks off a couple of null checks.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@155485 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/Frame.cpp
Source/WebCore/page/animation/AnimationController.cpp
Source/WebCore/page/animation/AnimationController.h
Source/WebCore/page/animation/AnimationControllerPrivate.h

index 4e44b3c44910c839e5c230636dd4932619efdb04..444e71ca6531df620e49d99e2442e2ab7cdb1a47 100644 (file)
@@ -1,3 +1,13 @@
+2013-09-10  Andreas Kling  <akling@apple.com>
+
+        AnimationController should have a Frame& internally.
+        <https://webkit.org/b/121078>
+
+        Reviewed by Anders Carlsson.
+
+        The AnimationController is owned by the Frame so make the back-pointer
+        a reference. This knocks off a couple of null checks.
+
 2013-09-10  Anders Carlsson  <andersca@apple.com>
 
         More WTF/Alignment.h removal
 2013-09-10  Anders Carlsson  <andersca@apple.com>
 
         More WTF/Alignment.h removal
index 44e0aca32614c3a82354631ace2c86c033d77ba6..0ac44baa0d560b5c903abe8d3da1d62f6c48ddd1 100644 (file)
@@ -161,7 +161,7 @@ inline Frame::Frame(Page* page, HTMLFrameOwnerElement* ownerElement, FrameLoader
     , m_editor(Editor::create(*this))
     , m_selection(adoptPtr(new FrameSelection(this)))
     , m_eventHandler(adoptPtr(new EventHandler(*this)))
     , m_editor(Editor::create(*this))
     , m_selection(adoptPtr(new FrameSelection(this)))
     , m_eventHandler(adoptPtr(new EventHandler(*this)))
-    , m_animationController(adoptPtr(new AnimationController(this)))
+    , m_animationController(createOwned<AnimationController>(*this))
     , m_pageZoomFactor(parentPageZoomFactor(this))
     , m_textZoomFactor(parentTextZoomFactor(this))
 #if ENABLE(ORIENTATION_EVENTS)
     , m_pageZoomFactor(parentPageZoomFactor(this))
     , m_textZoomFactor(parentTextZoomFactor(this))
 #if ENABLE(ORIENTATION_EVENTS)
index 656da7c7bb4ac7173850bc5758a60a924612d395..613bc396c93df3134f3c987ae06898c4b99625c8 100644 (file)
@@ -50,7 +50,7 @@ namespace WebCore {
 static const double cAnimationTimerDelay = 0.025;
 static const double cBeginAnimationUpdateTimeNotSet = -1;
 
 static const double cAnimationTimerDelay = 0.025;
 static const double cBeginAnimationUpdateTimeNotSet = -1;
 
-AnimationControllerPrivate::AnimationControllerPrivate(Frame* frame)
+AnimationControllerPrivate::AnimationControllerPrivate(Frame& frame)
     : m_animationTimer(this, &AnimationControllerPrivate::animationTimerFired)
     , m_updateStyleIfNeededDispatcher(this, &AnimationControllerPrivate::updateStyleIfNeededDispatcherFired)
     , m_frame(frame)
     : m_animationTimer(this, &AnimationControllerPrivate::animationTimerFired)
     , m_updateStyleIfNeededDispatcher(this, &AnimationControllerPrivate::updateStyleIfNeededDispatcherFired)
     , m_frame(frame)
@@ -112,7 +112,7 @@ double AnimationControllerPrivate::updateAnimations(SetChanged callSetChanged/*
     }
 
     if (calledSetChanged)
     }
 
     if (calledSetChanged)
-        m_frame->document()->updateStyleIfNeeded();
+        m_frame.document()->updateStyleIfNeeded();
 
     return timeToNextService;
 }
 
     return timeToNextService;
 }
@@ -163,7 +163,7 @@ void AnimationControllerPrivate::updateStyleIfNeededDispatcherFired(Timer<Animat
 void AnimationControllerPrivate::fireEventsAndUpdateStyle()
 {
     // Protect the frame from getting destroyed in the event handler
 void AnimationControllerPrivate::fireEventsAndUpdateStyle()
 {
     // Protect the frame from getting destroyed in the event handler
-    RefPtr<Frame> protector = m_frame;
+    Ref<Frame> protector(m_frame);
 
     bool updateStyle = !m_eventsToDispatch.isEmpty() || !m_nodeChangesToDispatch.isEmpty();
 
 
     bool updateStyle = !m_eventsToDispatch.isEmpty() || !m_nodeChangesToDispatch.isEmpty();
 
@@ -186,8 +186,8 @@ void AnimationControllerPrivate::fireEventsAndUpdateStyle()
 
     m_nodeChangesToDispatch.clear();
 
 
     m_nodeChangesToDispatch.clear();
 
-    if (updateStyle && m_frame)
-        m_frame->document()->updateStyleIfNeeded();
+    if (updateStyle)
+        m_frame.document()->updateStyleIfNeeded();
 }
 
 void AnimationControllerPrivate::startUpdateStyleIfNeededDispatcher()
 }
 
 void AnimationControllerPrivate::startUpdateStyleIfNeededDispatcher()
@@ -224,7 +224,7 @@ void AnimationControllerPrivate::animationFrameCallbackFired()
     double timeToNextService = updateAnimations(CallSetChanged);
 
     if (timeToNextService >= 0)
     double timeToNextService = updateAnimations(CallSetChanged);
 
     if (timeToNextService >= 0)
-        m_frame->document()->view()->scheduleAnimation();
+        m_frame.document()->view()->scheduleAnimation();
 }
 #endif
 
 }
 #endif
 
@@ -266,10 +266,10 @@ void AnimationControllerPrivate::suspendAnimations()
     if (isSuspended())
         return;
 
     if (isSuspended())
         return;
 
-    suspendAnimationsForDocument(m_frame->document());
+    suspendAnimationsForDocument(m_frame.document());
 
     // Traverse subframes
 
     // Traverse subframes
-    for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling())
+    for (Frame* child = m_frame.tree().firstChild(); child; child = child->tree().nextSibling())
         child->animation().suspendAnimations();
 
     m_isSuspended = true;
         child->animation().suspendAnimations();
 
     m_isSuspended = true;
@@ -280,10 +280,10 @@ void AnimationControllerPrivate::resumeAnimations()
     if (!isSuspended())
         return;
 
     if (!isSuspended())
         return;
 
-    resumeAnimationsForDocument(m_frame->document());
+    resumeAnimationsForDocument(m_frame.document());
 
     // Traverse subframes
 
     // Traverse subframes
-    for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling())
+    for (Frame* child = m_frame.tree().firstChild(); child; child = child->tree().nextSibling())
         child->animation().resumeAnimations();
 
     m_isSuspended = false;
         child->animation().resumeAnimations();
 
     m_isSuspended = false;
@@ -490,8 +490,8 @@ void AnimationControllerPrivate::animationWillBeRemoved(AnimationBase* animation
     removeFromAnimationsWaitingForStartTimeResponse(animation);
 }
 
     removeFromAnimationsWaitingForStartTimeResponse(animation);
 }
 
-AnimationController::AnimationController(Frame* frame)
-    : m_data(adoptPtr(new AnimationControllerPrivate(frame)))
+AnimationController::AnimationController(Frame& frame)
+    : m_data(createOwned<AnimationControllerPrivate>(frame))
     , m_beginAnimationUpdateCount(0)
 {
 }
     , m_beginAnimationUpdateCount(0)
 {
 }
index 23b15735a22475370a9b8e8fb11aa2c9442a70c7..cc6291e3e6a16a54d345f352f2b46c122686317f 100644 (file)
@@ -46,7 +46,7 @@ class RenderStyle;
 
 class AnimationController {
 public:
 
 class AnimationController {
 public:
-    AnimationController(Frame*);
+    explicit AnimationController(Frame&);
     ~AnimationController();
 
     void cancelAnimations(RenderObject*);
     ~AnimationController();
 
     void cancelAnimations(RenderObject*);
@@ -83,7 +83,7 @@ public:
     static bool supportsAcceleratedAnimationOfProperty(CSSPropertyID);
 
 private:
     static bool supportsAcceleratedAnimationOfProperty(CSSPropertyID);
 
 private:
-    OwnPtr<AnimationControllerPrivate> m_data;
+    const OwnPtr<AnimationControllerPrivate> m_data;
     int m_beginAnimationUpdateCount;
 };
 
     int m_beginAnimationUpdateCount;
 };
 
index bb46d7efc185904b16ea470707f5042601f3b1da..269bfdd0f5604303c97d5c377f54a80f92ca1918 100644 (file)
@@ -58,7 +58,7 @@ enum SetChanged {
 class AnimationControllerPrivate {
     WTF_MAKE_NONCOPYABLE(AnimationControllerPrivate); WTF_MAKE_FAST_ALLOCATED;
 public:
 class AnimationControllerPrivate {
     WTF_MAKE_NONCOPYABLE(AnimationControllerPrivate); WTF_MAKE_FAST_ALLOCATED;
 public:
-    AnimationControllerPrivate(Frame*);
+    explicit AnimationControllerPrivate(Frame&);
     ~AnimationControllerPrivate();
 
     // Returns the time until the next animation needs to be serviced, or -1 if there are none.
     ~AnimationControllerPrivate();
 
     // Returns the time until the next animation needs to be serviced, or -1 if there are none.
@@ -125,7 +125,7 @@ private:
     RenderObjectAnimationMap m_compositeAnimations;
     Timer<AnimationControllerPrivate> m_animationTimer;
     Timer<AnimationControllerPrivate> m_updateStyleIfNeededDispatcher;
     RenderObjectAnimationMap m_compositeAnimations;
     Timer<AnimationControllerPrivate> m_animationTimer;
     Timer<AnimationControllerPrivate> m_updateStyleIfNeededDispatcher;
-    Frame* m_frame;
+    Frame& m_frame;
     
     class EventToDispatch {
     public:
     
     class EventToDispatch {
     public: