+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
, 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)
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)
}
if (calledSetChanged)
- m_frame->document()->updateStyleIfNeeded();
+ m_frame.document()->updateStyleIfNeeded();
return timeToNextService;
}
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();
m_nodeChangesToDispatch.clear();
- if (updateStyle && m_frame)
- m_frame->document()->updateStyleIfNeeded();
+ if (updateStyle)
+ m_frame.document()->updateStyleIfNeeded();
}
void AnimationControllerPrivate::startUpdateStyleIfNeededDispatcher()
double timeToNextService = updateAnimations(CallSetChanged);
if (timeToNextService >= 0)
- m_frame->document()->view()->scheduleAnimation();
+ m_frame.document()->view()->scheduleAnimation();
}
#endif
if (isSuspended())
return;
- suspendAnimationsForDocument(m_frame->document());
+ suspendAnimationsForDocument(m_frame.document());
// 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;
if (!isSuspended())
return;
- resumeAnimationsForDocument(m_frame->document());
+ resumeAnimationsForDocument(m_frame.document());
// 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;
removeFromAnimationsWaitingForStartTimeResponse(animation);
}
-AnimationController::AnimationController(Frame* frame)
- : m_data(adoptPtr(new AnimationControllerPrivate(frame)))
+AnimationController::AnimationController(Frame& frame)
+ : m_data(createOwned<AnimationControllerPrivate>(frame))
, m_beginAnimationUpdateCount(0)
{
}
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.
RenderObjectAnimationMap m_compositeAnimations;
Timer<AnimationControllerPrivate> m_animationTimer;
Timer<AnimationControllerPrivate> m_updateStyleIfNeededDispatcher;
- Frame* m_frame;
+ Frame& m_frame;
class EventToDispatch {
public: