Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/LayoutMedia.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/LayoutMedia.cpp b/third_party/WebKit/Source/core/layout/LayoutMedia.cpp |
| index 374c4b1889cb25e1e8043d9c099085f857c5906d..4d7740e9711694e47f555bef52e71af1825defba 100644 |
| --- a/third_party/WebKit/Source/core/layout/LayoutMedia.cpp |
| +++ b/third_party/WebKit/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); |
|
esprehn
2015/10/01 07:04:14
inline the remove case here
liberato (no reviews please)
2015/10/01 22:49:02
Done.
|
| + 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); |
|
esprehn
2015/10/01 07:04:14
remove this, you don't need to hook inserted at al
liberato (no reviews please)
2015/10/01 22:49:02
inserted is needed to catch cases where an element
|
| +} |
| + |
| +void LayoutMedia::willBeRemovedFromTree() |
|
esprehn
2015/10/01 07:04:14
why do you hook removal? I don't think you need th
liberato (no reviews please)
2015/10/01 22:49:02
Done.
|
| +{ |
| + // 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()) |
|
ojan
2015/10/01 06:14:26
Pretty sure this isn't possible.
liberato (no reviews please)
2015/10/01 22:49:02
it does happen during the test:
#0 0x000000463b2b
|
| + return; |
| + |
| + // If our registration state matches the incoming state, then no work |
| + // is needed. |
| + if (doRegister == m_registeredForPositionChangeNotifications) |
| + return; |
| + |
| + if (doRegister) |
|
esprehn
2015/10/01 07:04:14
Remove this method
liberato (no reviews please)
2015/10/01 22:49:03
Done.
|
| + view()->registerMediaForPositionChangeNotification(this); |
| + else |
| + view()->unregisterMediaForPositionChangeNotification(this); |
| + |
| + m_registeredForPositionChangeNotifications = doRegister; |
| +} |
| + |
| +void LayoutMedia::setRequestPositionUpdates(bool want) |
| +{ |
| + m_wantPositionChangeNotifications = want; |
| + updatePositionChangeRegistration(m_wantPositionChangeNotifications); |
|
esprehn
2015/10/01 07:04:14
inline the positive case here
liberato (no reviews please)
2015/10/01 22:49:02
Done, though both cases are used.
|
| +} |
| + |
| } // namespace blink |