Commit 7c2be783 authored by akling@apple.com's avatar akling@apple.com
Browse files

<https://webkit.org/b/120118> Frame::animation() should return a reference.

Reviewed by Anders Carlsson.

Frame::m_animationController is never null.
Also changed RenderObject::animation() to return a reference since it's just a wrapper
around RenderObject::frame()->animation() with no null checking of frame().

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154401 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7c818704
2013-08-21 Andreas Kling <akling@apple.com>
<https://webkit.org/b/120118> Frame::animation() should return a reference.
Reviewed by Anders Carlsson.
Frame::m_animationController is never null.
Also changed RenderObject::animation() to return a reference since it's just a wrapper
around RenderObject::frame()->animation() with no null checking of frame().
2013-08-21 Simon Fraser <simon.fraser@apple.com>
 
Allow opacity to apply to custom scrollbars
......@@ -1667,8 +1667,8 @@ static inline PassRefPtr<RenderStyle> computeRenderStyleForProperty(Node* styled
RenderObject* renderer = styledNode->renderer();
if (renderer && renderer->isComposited() && AnimationController::supportsAcceleratedAnimationOfProperty(propertyID)) {
AnimationUpdateBlock animationUpdateBlock(renderer->animation());
RefPtr<RenderStyle> style = renderer->animation()->getAnimatedStyleForRenderer(renderer);
AnimationUpdateBlock animationUpdateBlock(&renderer->animation());
RefPtr<RenderStyle> style = renderer->animation().getAnimatedStyleForRenderer(renderer);
if (pseudoElementSpecifier && !styledNode->isPseudoElement()) {
// FIXME: This cached pseudo style will only exist if the animation has been run at least once.
return style->getCachedPseudoStyle(pseudoElementSpecifier);
......
......@@ -1828,7 +1828,7 @@ void Document::updateStyleIfNeeded()
if ((!m_pendingStyleRecalcShouldForce && !childNeedsStyleRecalc()) || inPageCache())
return;
AnimationUpdateBlock animationUpdateBlock(m_frame ? m_frame->animation() : 0);
AnimationUpdateBlock animationUpdateBlock(m_frame ? &m_frame->animation() : 0);
recalcStyle(Style::NoChange);
}
......@@ -2352,7 +2352,7 @@ void Document::implicitClose()
Frame* f = frame();
if (f) {
f->loader().icon()->startLoader();
f->animation()->startAnimationsIfNotSuspended(this);
f->animation().startAnimationsIfNotSuspended(this);
}
ImageLoader::dispatchPendingBeforeLoadEvents();
......@@ -3158,7 +3158,7 @@ void Document::styleResolverChanged(StyleResolverUpdateFlag updateFlag)
// This recalcStyle initiates a new recalc cycle. We need to bracket it to
// make sure animations get the correct update time
{
AnimationUpdateBlock animationUpdateBlock(m_frame ? m_frame->animation() : 0);
AnimationUpdateBlock animationUpdateBlock(m_frame ? &m_frame->animation() : 0);
recalcStyle(Style::Force);
}
......
......@@ -109,7 +109,7 @@ void CachedFrameBase::restore()
m_document->accessSVGExtensions()->unpauseAnimations();
#endif
frame.animation()->resumeAnimationsForDocument(m_document.get());
frame.animation().resumeAnimationsForDocument(m_document.get());
frame.eventHandler().setMousePressNode(m_mousePressNode.get());
m_document->resumeActiveDOMObjects(ActiveDOMObject::DocumentWillBecomeInactive);
m_document->resumeScriptedAnimationControllerCallbacks();
......
......@@ -630,7 +630,7 @@ void Frame::clearTimers(FrameView *view, Document *document)
{
if (view) {
view->unscheduleRelayout();
view->frame().animation()->suspendAnimationsForDocument(document);
view->frame().animation().suspendAnimationsForDocument(document);
view->frame().eventHandler().stopAutoscrollTimer();
}
}
......@@ -961,7 +961,7 @@ void Frame::suspendActiveDOMObjectsAndAnimations()
// FIXME: Suspend/resume calls will not match if the frame is navigated, and gets a new document.
if (document()) {
document()->suspendScriptedAnimationControllerCallbacks();
animation()->suspendAnimationsForDocument(document());
animation().suspendAnimationsForDocument(document());
document()->suspendActiveDOMObjects(ActiveDOMObject::PageWillBeSuspended);
}
}
......@@ -977,7 +977,7 @@ void Frame::resumeActiveDOMObjectsAndAnimations()
if (document()) {
document()->resumeActiveDOMObjects(ActiveDOMObject::PageWillBeSuspended);
animation()->resumeAnimationsForDocument(document());
animation().resumeAnimationsForDocument(document());
document()->resumeScriptedAnimationControllerCallbacks();
}
......
......@@ -120,7 +120,7 @@ namespace WebCore {
NavigationScheduler* navigationScheduler() const;
FrameSelection& selection() const;
FrameTree* tree() const;
AnimationController* animation() const;
AnimationController& animation() const;
ScriptController& script();
RenderView* contentRenderer() const; // Root of the render tree for the document contained in this frame.
......@@ -219,11 +219,11 @@ namespace WebCore {
RefPtr<FrameView> m_view;
RefPtr<Document> m_doc;
OwnPtr<ScriptController> m_script;
const OwnPtr<ScriptController> m_script;
const OwnPtr<Editor> m_editor;
OwnPtr<FrameSelection> m_selection;
const OwnPtr<FrameSelection> m_selection;
const OwnPtr<EventHandler> m_eventHandler;
OwnPtr<AnimationController> m_animationController;
const OwnPtr<AnimationController> m_animationController;
float m_pageZoomFactor;
float m_textZoomFactor;
......@@ -296,9 +296,9 @@ namespace WebCore {
return *m_editor;
}
inline AnimationController* Frame::animation() const
inline AnimationController& Frame::animation() const
{
return m_animationController.get();
return *m_animationController;
}
inline HTMLFrameOwnerElement* Frame::ownerElement() const
......
......@@ -2508,7 +2508,7 @@ void FrameView::serviceScriptedAnimations(double monotonicAnimationStartTime)
{
for (Frame* frame = m_frame.get(); frame; frame = frame->tree()->traverseNext()) {
frame->view()->serviceScrollAnimations();
frame->animation()->serviceAnimations();
frame->animation().serviceAnimations();
}
Vector<RefPtr<Document> > documents;
......
......@@ -1290,11 +1290,11 @@ void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitia
if (m_pageThrottler->shouldThrottleTimers())
throttleTimers();
if (m_settings->hiddenPageCSSAnimationSuspensionEnabled())
mainFrame()->animation()->suspendAnimations();
mainFrame()->animation().suspendAnimations();
} else {
unthrottleTimers();
if (m_settings->hiddenPageCSSAnimationSuspensionEnabled())
mainFrame()->animation()->resumeAnimations();
mainFrame()->animation().resumeAnimations();
}
#if !ENABLE(PAGE_VISIBILITY_API)
UNUSED_PARAM(isInitialState);
......@@ -1555,9 +1555,9 @@ void Page::hiddenPageCSSAnimationSuspensionStateChanged()
{
if (m_visibilityState == WebCore::PageVisibilityStateHidden) {
if (m_settings->hiddenPageCSSAnimationSuspensionEnabled())
mainFrame()->animation()->suspendAnimations();
mainFrame()->animation().suspendAnimations();
else
mainFrame()->animation()->resumeAnimations();
mainFrame()->animation().resumeAnimations();
}
}
#endif
......
......@@ -270,7 +270,7 @@ void AnimationControllerPrivate::suspendAnimations()
// Traverse subframes
for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling())
child->animation()->suspendAnimations();
child->animation().suspendAnimations();
m_isSuspended = true;
}
......@@ -284,7 +284,7 @@ void AnimationControllerPrivate::resumeAnimations()
// Traverse subframes
for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling())
child->animation()->resumeAnimations();
child->animation().resumeAnimations();
m_isSuspended = false;
}
......
......@@ -894,7 +894,7 @@ TransformationMatrix RenderLayer::currentTransform(RenderStyle::ApplyTransformOr
#if USE(ACCELERATED_COMPOSITING)
if (renderer()->style()->isRunningAcceleratedAnimation()) {
TransformationMatrix currTransform;
RefPtr<RenderStyle> style = renderer()->animation()->getAnimatedStyleForRenderer(renderer());
RefPtr<RenderStyle> style = renderer()->animation().getAnimatedStyleForRenderer(renderer());
style->applyTransform(currTransform, renderBox()->pixelSnappedBorderBoxRect().size(), applyOrigin);
makeMatrixRenderable(currTransform, canRender3DTransforms());
return currTransform;
......
......@@ -608,11 +608,11 @@ void RenderLayerBacking::updateGraphicsLayerGeometry()
// Set transform property, if it is not animating. We have to do this here because the transform
// is affected by the layer dimensions.
if (!renderer()->animation()->isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyWebkitTransform))
if (!renderer()->animation().isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyWebkitTransform))
updateTransform(renderer()->style());
// Set opacity, if it is not animating.
if (!renderer()->animation()->isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyOpacity))
if (!renderer()->animation().isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyOpacity))
updateOpacity(renderer()->style());
#if ENABLE(CSS_FILTERS)
......@@ -2243,7 +2243,7 @@ void RenderLayerBacking::transitionFinished(CSSPropertyID property)
void RenderLayerBacking::notifyAnimationStarted(const GraphicsLayer*, double time)
{
renderer()->animation()->notifyAnimationStarted(renderer(), time);
renderer()->animation().notifyAnimationStarted(renderer(), time);
}
void RenderLayerBacking::notifyFlushRequired(const GraphicsLayer* layer)
......
......@@ -382,7 +382,7 @@ void RenderLayerCompositor::flushPendingLayerChanges(bool isFlushRoot)
return;
}
AnimationUpdateBlock animationUpdateBlock(m_renderView->frameView()->frame().animation());
AnimationUpdateBlock animationUpdateBlock(&m_renderView->frameView()->frame().animation());
ASSERT(!m_flushingLayers);
m_flushingLayers = true;
......@@ -521,7 +521,7 @@ void RenderLayerCompositor::updateCompositingLayers(CompositingUpdateType update
if (!m_reevaluateCompositingAfterLayout && !m_compositing)
return;
AnimationUpdateBlock animationUpdateBlock(m_renderView->frameView()->frame().animation());
AnimationUpdateBlock animationUpdateBlock(&m_renderView->frameView()->frame().animation());
TemporaryChange<bool> postLayoutChange(m_inPostLayoutUpdate, true);
......@@ -2180,18 +2180,16 @@ bool RenderLayerCompositor::requiresCompositingForAnimation(RenderObject* render
if (!(m_compositingTriggers & ChromeClient::AnimationTrigger))
return false;
if (AnimationController* animController = renderer->animation()) {
return (animController->isRunningAnimationOnRenderer(renderer, CSSPropertyOpacity)
&& (inCompositingMode() || (m_compositingTriggers & ChromeClient::AnimatedOpacityTrigger)))
AnimationController& animController = renderer->animation();
return (animController.isRunningAnimationOnRenderer(renderer, CSSPropertyOpacity)
&& (inCompositingMode() || (m_compositingTriggers & ChromeClient::AnimatedOpacityTrigger)))
#if ENABLE(CSS_FILTERS)
#if !PLATFORM(MAC) || (!PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080)
// <rdar://problem/10907251> - WebKit2 doesn't support CA animations of CI filters on Lion and below
|| animController->isRunningAnimationOnRenderer(renderer, CSSPropertyWebkitFilter)
|| animController.isRunningAnimationOnRenderer(renderer, CSSPropertyWebkitFilter)
#endif // !PLATFORM(MAC) || (!PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080)
#endif // CSS_FILTERS
|| animController->isRunningAnimationOnRenderer(renderer, CSSPropertyWebkitTransform);
}
return false;
|| animController.isRunningAnimationOnRenderer(renderer, CSSPropertyWebkitTransform);
}
bool RenderLayerCompositor::requiresCompositingForIndirectReason(RenderObject* renderer, bool hasCompositedDescendants, bool has3DTransformedDescendants, RenderLayer::IndirectCompositingReason& reason) const
......@@ -2341,10 +2339,7 @@ bool RenderLayerCompositor::isRunningAcceleratedTransformAnimation(RenderObject*
if (!(m_compositingTriggers & ChromeClient::AnimationTrigger))
return false;
if (AnimationController* animController = renderer->animation())
return animController->isRunningAnimationOnRenderer(renderer, CSSPropertyWebkitTransform);
return false;
return renderer->animation().isRunningAnimationOnRenderer(renderer, CSSPropertyWebkitTransform);
}
// If an element has negative z-index children, those children render in front of the
......
......@@ -1728,7 +1728,7 @@ void RenderObject::removeAnonymousWrappersForInlinesIfNecessary()
void RenderObject::setAnimatableStyle(PassRefPtr<RenderStyle> style)
{
if (!isText() && style)
setStyle(animation()->updateAnimations(this, style.get()));
setStyle(animation().updateAnimations(this, style.get()));
else
setStyle(style);
}
......@@ -2460,7 +2460,7 @@ void RenderObject::willBeDestroyed()
if (frame() && frame()->eventHandler().autoscrollRenderer() == this)
frame()->eventHandler().stopAutoscrollTimer(true);
animation()->cancelAnimations(this);
animation().cancelAnimations(this);
// For accessibility management, notify the parent of the imminent change to its child set.
// We do it now, before remove(), while the parent pointer is still available.
......@@ -3062,7 +3062,7 @@ void RenderObject::adjustRectForOutlineAndShadow(LayoutRect& rect) const
rect.inflate(outlineSize);
}
AnimationController* RenderObject::animation() const
AnimationController& RenderObject::animation() const
{
return frame()->animation();
}
......
......@@ -954,7 +954,7 @@ public:
void remove() { if (parent()) parent()->removeChild(this); }
AnimationController* animation() const;
AnimationController& animation() const;
bool visibleToHitTesting() const { return style()->visibility() == VISIBLE && style()->pointerEvents() != PE_NONE; }
......
......@@ -403,10 +403,7 @@ unsigned Internals::lastSpatialNavigationCandidateCount(ExceptionCode& ec) const
unsigned Internals::numberOfActiveAnimations() const
{
Frame* contextFrame = frame();
if (AnimationController* controller = contextFrame->animation())
return controller->numberOfActiveAnimations(contextFrame->document());
return 0;
return frame()->animation().numberOfActiveAnimations(frame()->document());
}
bool Internals::animationsAreSuspended(Document* document, ExceptionCode& ec) const
......@@ -416,11 +413,7 @@ bool Internals::animationsAreSuspended(Document* document, ExceptionCode& ec) co
return false;
}
AnimationController* controller = document->frame()->animation();
if (!controller)
return false;
return controller->isSuspended();
return document->frame()->animation().isSuspended();
}
void Internals::suspendAnimations(Document* document, ExceptionCode& ec) const
......@@ -430,11 +423,7 @@ void Internals::suspendAnimations(Document* document, ExceptionCode& ec) const
return;
}
AnimationController* controller = document->frame()->animation();
if (!controller)
return;
controller->suspendAnimations();
document->frame()->animation().suspendAnimations();
}
void Internals::resumeAnimations(Document* document, ExceptionCode& ec) const
......@@ -444,11 +433,7 @@ void Internals::resumeAnimations(Document* document, ExceptionCode& ec) const
return;
}
AnimationController* controller = document->frame()->animation();
if (!controller)
return;
controller->resumeAnimations();
document->frame()->animation().resumeAnimations();
}
bool Internals::pauseAnimationAtTimeOnElement(const String& animationName, double pauseTime, Element* element, ExceptionCode& ec)
......@@ -457,8 +442,7 @@ bool Internals::pauseAnimationAtTimeOnElement(const String& animationName, doubl
ec = INVALID_ACCESS_ERR;
return false;
}
AnimationController* controller = frame()->animation();
return controller->pauseAnimationAtTime(element->renderer(), AtomicString(animationName), pauseTime);
return frame()->animation().pauseAnimationAtTime(element->renderer(), AtomicString(animationName), pauseTime);
}
bool Internals::pauseAnimationAtTimeOnPseudoElement(const String& animationName, double pauseTime, Element* element, const String& pseudoId, ExceptionCode& ec)
......@@ -479,7 +463,7 @@ bool Internals::pauseAnimationAtTimeOnPseudoElement(const String& animationName,
return false;
}
return frame()->animation()->pauseAnimationAtTime(pseudoElement->renderer(), AtomicString(animationName), pauseTime);
return frame()->animation().pauseAnimationAtTime(pseudoElement->renderer(), AtomicString(animationName), pauseTime);
}
bool Internals::pauseTransitionAtTimeOnElement(const String& propertyName, double pauseTime, Element* element, ExceptionCode& ec)
......@@ -488,8 +472,7 @@ bool Internals::pauseTransitionAtTimeOnElement(const String& propertyName, doubl
ec = INVALID_ACCESS_ERR;
return false;
}
AnimationController* controller = frame()->animation();
return controller->pauseTransitionAtTime(element->renderer(), propertyName, pauseTime);
return frame()->animation().pauseTransitionAtTime(element->renderer(), propertyName, pauseTime);
}
bool Internals::pauseTransitionAtTimeOnPseudoElement(const String& property, double pauseTime, Element* element, const String& pseudoId, ExceptionCode& ec)
......@@ -510,7 +493,7 @@ bool Internals::pauseTransitionAtTimeOnPseudoElement(const String& property, dou
return false;
}
return frame()->animation()->pauseTransitionAtTime(pseudoElement->renderer(), property, pauseTime);
return frame()->animation().pauseTransitionAtTime(pseudoElement->renderer(), property, pauseTime);
}
bool Internals::attached(Node* node, ExceptionCode& ec)
......
......@@ -3134,12 +3134,12 @@ void WebPagePrivate::setVisible(bool visible)
if (visible != m_visible) {
if (visible) {
if (m_mainFrame)
m_mainFrame->animation()->resumeAnimations();
m_mainFrame->animation().resumeAnimations();
if (m_page->scriptedAnimationsSuspended())
m_page->resumeScriptedAnimations();
} else {
if (m_mainFrame)
m_mainFrame->animation()->suspendAnimations();
m_mainFrame->animation().suspendAnimations();
if (!m_page->scriptedAnimationsSuspended())
m_page->suspendScriptedAnimations();
......
......@@ -2779,7 +2779,7 @@ static Vector<String> toStringVector(NSArray* patterns)
{
Frame* frame = core([self mainFrame]);
if (frame)
return frame->animation()->allowsNewAnimationsWhileSuspended();
return frame->animation().allowsNewAnimationsWhileSuspended();
return false;
}
......@@ -2788,7 +2788,7 @@ static Vector<String> toStringVector(NSArray* patterns)
{
Frame* frame = core([self mainFrame]);
if (frame)
frame->animation()->setAllowsNewAnimationsWhileSuspended(allowed);
frame->animation().setAllowsNewAnimationsWhileSuspended(allowed);
}
- (BOOL)cssAnimationsSuspended
......@@ -2796,7 +2796,7 @@ static Vector<String> toStringVector(NSArray* patterns)
// should ask the page!
Frame* frame = core([self mainFrame]);
if (frame)
return frame->animation()->isSuspended();
return frame->animation().isSuspended();
return false;
}
......@@ -2804,13 +2804,13 @@ static Vector<String> toStringVector(NSArray* patterns)
- (void)setCSSAnimationsSuspended:(BOOL)suspended
{
Frame* frame = core([self mainFrame]);
if (suspended == frame->animation()->isSuspended())
if (suspended == frame->animation().isSuspended())
return;
if (suspended)
frame->animation()->suspendAnimations();
frame->animation().suspendAnimations();
else
frame->animation()->resumeAnimations();
frame->animation().resumeAnimations();
}
+ (void)_setDomainRelaxationForbidden:(BOOL)forbidden forURLScheme:(NSString *)scheme
......
......@@ -1193,7 +1193,7 @@ HRESULT STDMETHODCALLTYPE WebFrame::resumeAnimations()
if (!frame)
return E_FAIL;
frame->animation()->resumeAnimations();
frame->animation().resumeAnimations();
return S_OK;
}
......@@ -1203,7 +1203,7 @@ HRESULT STDMETHODCALLTYPE WebFrame::suspendAnimations()
if (!frame)
return E_FAIL;
frame->animation()->suspendAnimations();
frame->animation().suspendAnimations();
return S_OK;
}
......@@ -1218,15 +1218,11 @@ HRESULT WebFrame::pauseAnimation(BSTR animationName, IDOMNode* node, double seco
if (!frame)
return E_FAIL;
AnimationController* controller = frame->animation();
if (!controller)
return E_FAIL;
COMPtr<DOMNode> domNode(Query, node);
if (!domNode)
return E_FAIL;
*animationWasRunning = controller->pauseAnimationAtTime(domNode->node()->renderer(), String(animationName, SysStringLen(animationName)), secondsFromNow);
*animationWasRunning = frame->animation().pauseAnimationAtTime(domNode->node()->renderer(), String(animationName, SysStringLen(animationName)), secondsFromNow);
return S_OK;
}
......@@ -1241,15 +1237,11 @@ HRESULT WebFrame::pauseTransition(BSTR propertyName, IDOMNode* node, double seco
if (!frame)
return E_FAIL;
AnimationController* controller = frame->animation();
if (!controller)
return E_FAIL;
COMPtr<DOMNode> domNode(Query, node);
if (!domNode)
return E_FAIL;
*transitionWasRunning = controller->pauseTransitionAtTime(domNode->node()->renderer(), String(propertyName, SysStringLen(propertyName)), secondsFromNow);
*transitionWasRunning = frame->animation().pauseTransitionAtTime(domNode->node()->renderer(), String(propertyName, SysStringLen(propertyName)), secondsFromNow);
return S_OK;
}
......@@ -1282,11 +1274,7 @@ HRESULT WebFrame::numberOfActiveAnimations(UINT* number)
if (!frame)
return E_FAIL;
AnimationController* controller = frame->animation();
if (!controller)
return E_FAIL;
*number = controller->numberOfActiveAnimations(frame->document());
*number = frame->animation().numberOfActiveAnimations(frame->document());
return S_OK;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment