Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Unified Diff: third_party/WebKit/Source/core/html/HTMLVideoElement.cpp

Issue 1377353002: Update poster code as per https://html.spec.whatwg.org/#show-poster-flag Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update "show poster" flag as per spec Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLVideoElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1d23185800daf4c826720073df69450ba6c81dce 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,6 @@ void HTMLVideoElement::attach(const AttachContext& context)
{
HTMLMediaElement::attach(context);
- updateDisplayState();
if (shouldDisplayPosterImage()) {
if (!m_imageLoader)
m_imageLoader = HTMLImageLoader::create(this);
@@ -115,13 +115,6 @@ bool HTMLVideoElement::isPresentationAttribute(const QualifiedName& name) const
void HTMLVideoElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
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 (!posterImageURL().isEmpty()) {
if (!m_imageLoader)
m_imageLoader = HTMLImageLoader::create(this);
@@ -165,9 +158,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 +167,15 @@ 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();
-}
-
-void HTMLVideoElement::updateDisplayState()
-{
- if (posterImageURL().isEmpty())
- setDisplayMode(Video);
- else if (displayMode() < Poster)
- setDisplayMode(Poster);
+ if (showPoster != m_showPoster) {
+ m_showPoster = showPoster;
+ if (layoutObject())
+ layoutObject()->updateFromElement();
+ }
}
void HTMLVideoElement::paintCurrentFrame(SkCanvas* canvas, const IntRect& destRect, const SkPaint* paint) const
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLVideoElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698