| Index: Source/core/layout/LayoutMedia.cpp
 | 
| diff --git a/Source/core/layout/LayoutMedia.cpp b/Source/core/layout/LayoutMedia.cpp
 | 
| index 374c4b1889cb25e1e8043d9c099085f857c5906d..4d7740e9711694e47f555bef52e71af1825defba 100644
 | 
| --- a/Source/core/layout/LayoutMedia.cpp
 | 
| +++ b/Source/core/layout/LayoutMedia.cpp
 | 
| @@ -35,6 +35,8 @@ namespace blink {
 | 
|  
 | 
|  LayoutMedia::LayoutMedia(HTMLMediaElement* video)
 | 
|      : LayoutImage(video)
 | 
| +    , m_registeredForPositionChangeNotifications(false)
 | 
| +    , m_wantPositionChangeNotifications(false)
 | 
|  {
 | 
|      setImageResource(LayoutImageResource::create());
 | 
|  }
 | 
| @@ -119,4 +121,60 @@ void LayoutMedia::paintReplaced(const PaintInfo&, const LayoutPoint&)
 | 
|  {
 | 
|  }
 | 
|  
 | 
| +void LayoutMedia::willBeDestroyed()
 | 
| +{
 | 
| +    updatePositionChangeRegistration(false);
 | 
| +    LayoutImage::willBeDestroyed();
 | 
| +}
 | 
| +
 | 
| +void LayoutMedia::insertedIntoTree()
 | 
| +{
 | 
| +    LayoutImage::insertedIntoTree();
 | 
| +
 | 
| +    // Note that if we don't want them and aren't registered, then this
 | 
| +    // will do nothing.
 | 
| +    updatePositionChangeRegistration(m_wantPositionChangeNotifications);
 | 
| +}
 | 
| +
 | 
| +void LayoutMedia::willBeRemovedFromTree()
 | 
| +{
 | 
| +    // Note that if we don't want them and/or aren't registered, then this
 | 
| +    // will do nothing.
 | 
| +    updatePositionChangeRegistration(false);
 | 
| +
 | 
| +    LayoutImage::willBeRemovedFromTree();
 | 
| +}
 | 
| +
 | 
| +void LayoutMedia::notifyPositionMayHaveChanged()
 | 
| +{
 | 
| +    // Tell our element about it.
 | 
| +    if (HTMLMediaElement* element = mediaElement())
 | 
| +        element->notifyPositionMayHaveChanged();
 | 
| +}
 | 
| +
 | 
| +void LayoutMedia::updatePositionChangeRegistration(bool doRegister)
 | 
| +{
 | 
| +    // If we don't have a view, then take no action.
 | 
| +    if (!view())
 | 
| +        return;
 | 
| +
 | 
| +    // If our registration state matches the incoming state, then no work
 | 
| +    // is needed.
 | 
| +    if (doRegister == m_registeredForPositionChangeNotifications)
 | 
| +        return;
 | 
| +
 | 
| +    if (doRegister)
 | 
| +        view()->registerMediaForPositionChangeNotification(this);
 | 
| +    else
 | 
| +        view()->unregisterMediaForPositionChangeNotification(this);
 | 
| +
 | 
| +    m_registeredForPositionChangeNotifications = doRegister;
 | 
| +}
 | 
| +
 | 
| +void LayoutMedia::setRequestPositionUpdates(bool want)
 | 
| +{
 | 
| +    m_wantPositionChangeNotifications = want;
 | 
| +    updatePositionChangeRegistration(m_wantPositionChangeNotifications);
 | 
| +}
 | 
| +
 | 
|  } // namespace blink
 | 
| 
 |