Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/HTMLVideoElement.cpp |
| diff --git a/third_party/WebKit/Source/core/html/HTMLVideoElement.cpp b/third_party/WebKit/Source/core/html/HTMLVideoElement.cpp |
| index fe5170644016ab7a1e42efe73e22ff1a051996b1..9a38f313b272f7f052f860296963b747fde332ba 100644 |
| --- a/third_party/WebKit/Source/core/html/HTMLVideoElement.cpp |
| +++ b/third_party/WebKit/Source/core/html/HTMLVideoElement.cpp |
| @@ -52,6 +52,7 @@ using namespace HTMLNames; |
| inline HTMLVideoElement::HTMLVideoElement(Document& document) |
| : HTMLMediaElement(videoTag, document) |
| + , m_showPoster(true) |
| { |
| if (document.settings()) |
| m_defaultPosterURL = AtomicString(document.settings()->defaultVideoPosterURL()); |
| @@ -85,7 +86,7 @@ void HTMLVideoElement::attach(const AttachContext& context) |
| { |
| HTMLMediaElement::attach(context); |
| - updateDisplayState(); |
| + updateDisplayState(true); |
| if (shouldDisplayPosterImage()) { |
| if (!m_imageLoader) |
| m_imageLoader = HTMLImageLoader::create(this); |
| @@ -117,10 +118,9 @@ void HTMLVideoElement::parseAttribute(const QualifiedName& name, const AtomicStr |
| if (name == posterAttr) { |
| // In case the poster attribute is set after playback, don't update the |
| // display state, post playback the correct state will be picked up. |
| - if (displayMode() < Video || !hasAvailableVideoFrame()) { |
| - // Force a poster recalc by setting m_displayMode to Unknown directly before calling updateDisplayState. |
| - HTMLMediaElement::setDisplayMode(Unknown); |
| - updateDisplayState(); |
| + if (m_showPoster || !hasAvailableVideoFrame()) { |
| + m_showPoster = true; |
| + updateDisplayState(true); |
| } |
| if (!posterImageURL().isEmpty()) { |
| if (!m_imageLoader) |
| @@ -165,9 +165,8 @@ const AtomicString HTMLVideoElement::imageSourceURL() const |
| return m_defaultPosterURL; |
| } |
| -void HTMLVideoElement::setDisplayMode(DisplayMode mode) |
| +void HTMLVideoElement::setShowPoster(bool showPoster) |
| { |
| - DisplayMode oldMode = displayMode(); |
| KURL poster = posterImageURL(); |
| if (!poster.isEmpty()) { |
| @@ -175,22 +174,26 @@ void HTMLVideoElement::setDisplayMode(DisplayMode mode) |
| // media engine has something to display. |
| // Don't show the poster if there is a seek operation or |
| // the video has restarted because of loop attribute |
| - if (mode == Video && oldMode == Poster && !hasAvailableVideoFrame()) |
| + if (!showPoster && m_showPoster && !hasAvailableVideoFrame()) |
| return; |
| } |
| - HTMLMediaElement::setDisplayMode(mode); |
| - |
| - if (layoutObject() && displayMode() != oldMode) |
| - layoutObject()->updateFromElement(); |
| + if (showPoster != m_showPoster) { |
| + m_showPoster = showPoster; |
| + if (layoutObject()) |
| + layoutObject()->updateFromElement(); |
| + } |
| } |
| -void HTMLVideoElement::updateDisplayState() |
| +void HTMLVideoElement::updateDisplayState(bool forceUpdate) |
|
philipj_slow
2015/10/01 09:45:59
This whole method looks suspicifous to me, it does
|
| { |
| - if (posterImageURL().isEmpty()) |
| - setDisplayMode(Video); |
| - else if (displayMode() < Poster) |
| - setDisplayMode(Poster); |
| + if (posterImageURL().isEmpty()) { |
| + setShowPoster(false); |
| + } else if (m_showPoster) { |
| + if (forceUpdate) |
| + m_showPoster = false; |
| + setShowPoster(true); |
| + } |
| } |
| void HTMLVideoElement::paintCurrentFrame(SkCanvas* canvas, const IntRect& destRect, const SkPaint* paint) const |