| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "platform/graphics/gpu/Extensions3DUtil.h" | 45 #include "platform/graphics/gpu/Extensions3DUtil.h" |
| 46 #include "public/platform/WebCanvas.h" | 46 #include "public/platform/WebCanvas.h" |
| 47 #include "public/platform/WebGraphicsContext3D.h" | 47 #include "public/platform/WebGraphicsContext3D.h" |
| 48 | 48 |
| 49 namespace blink { | 49 namespace blink { |
| 50 | 50 |
| 51 using namespace HTMLNames; | 51 using namespace HTMLNames; |
| 52 | 52 |
| 53 inline HTMLVideoElement::HTMLVideoElement(Document& document) | 53 inline HTMLVideoElement::HTMLVideoElement(Document& document) |
| 54 : HTMLMediaElement(videoTag, document) | 54 : HTMLMediaElement(videoTag, document) |
| 55 , m_showPoster(true) |
| 55 { | 56 { |
| 56 if (document.settings()) | 57 if (document.settings()) |
| 57 m_defaultPosterURL = AtomicString(document.settings()->defaultVideoPoste
rURL()); | 58 m_defaultPosterURL = AtomicString(document.settings()->defaultVideoPoste
rURL()); |
| 58 } | 59 } |
| 59 | 60 |
| 60 PassRefPtrWillBeRawPtr<HTMLVideoElement> HTMLVideoElement::create(Document& docu
ment) | 61 PassRefPtrWillBeRawPtr<HTMLVideoElement> HTMLVideoElement::create(Document& docu
ment) |
| 61 { | 62 { |
| 62 RefPtrWillBeRawPtr<HTMLVideoElement> video = adoptRefWillBeNoop(new HTMLVide
oElement(document)); | 63 RefPtrWillBeRawPtr<HTMLVideoElement> video = adoptRefWillBeNoop(new HTMLVide
oElement(document)); |
| 63 video->ensureUserAgentShadowRoot(); | 64 video->ensureUserAgentShadowRoot(); |
| 64 video->suspendIfNeeded(); | 65 video->suspendIfNeeded(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 78 | 79 |
| 79 LayoutObject* HTMLVideoElement::createLayoutObject(const ComputedStyle&) | 80 LayoutObject* HTMLVideoElement::createLayoutObject(const ComputedStyle&) |
| 80 { | 81 { |
| 81 return new LayoutVideo(this); | 82 return new LayoutVideo(this); |
| 82 } | 83 } |
| 83 | 84 |
| 84 void HTMLVideoElement::attach(const AttachContext& context) | 85 void HTMLVideoElement::attach(const AttachContext& context) |
| 85 { | 86 { |
| 86 HTMLMediaElement::attach(context); | 87 HTMLMediaElement::attach(context); |
| 87 | 88 |
| 88 updateDisplayState(); | 89 updateDisplayState(true); |
| 89 if (shouldDisplayPosterImage()) { | 90 if (shouldDisplayPosterImage()) { |
| 90 if (!m_imageLoader) | 91 if (!m_imageLoader) |
| 91 m_imageLoader = HTMLImageLoader::create(this); | 92 m_imageLoader = HTMLImageLoader::create(this); |
| 92 m_imageLoader->updateFromElement(); | 93 m_imageLoader->updateFromElement(); |
| 93 if (layoutObject()) | 94 if (layoutObject()) |
| 94 toLayoutImage(layoutObject())->imageResource()->setImageResource(m_i
mageLoader->image()); | 95 toLayoutImage(layoutObject())->imageResource()->setImageResource(m_i
mageLoader->image()); |
| 95 } | 96 } |
| 96 } | 97 } |
| 97 | 98 |
| 98 void HTMLVideoElement::collectStyleForPresentationAttribute(const QualifiedName&
name, const AtomicString& value, MutableStylePropertySet* style) | 99 void HTMLVideoElement::collectStyleForPresentationAttribute(const QualifiedName&
name, const AtomicString& value, MutableStylePropertySet* style) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 110 if (name == widthAttr || name == heightAttr) | 111 if (name == widthAttr || name == heightAttr) |
| 111 return true; | 112 return true; |
| 112 return HTMLMediaElement::isPresentationAttribute(name); | 113 return HTMLMediaElement::isPresentationAttribute(name); |
| 113 } | 114 } |
| 114 | 115 |
| 115 void HTMLVideoElement::parseAttribute(const QualifiedName& name, const AtomicStr
ing& value) | 116 void HTMLVideoElement::parseAttribute(const QualifiedName& name, const AtomicStr
ing& value) |
| 116 { | 117 { |
| 117 if (name == posterAttr) { | 118 if (name == posterAttr) { |
| 118 // In case the poster attribute is set after playback, don't update the | 119 // In case the poster attribute is set after playback, don't update the |
| 119 // display state, post playback the correct state will be picked up. | 120 // display state, post playback the correct state will be picked up. |
| 120 if (displayMode() < Video || !hasAvailableVideoFrame()) { | 121 if (m_showPoster || !hasAvailableVideoFrame()) { |
| 121 // Force a poster recalc by setting m_displayMode to Unknown directl
y before calling updateDisplayState. | 122 m_showPoster = true; |
| 122 HTMLMediaElement::setDisplayMode(Unknown); | 123 updateDisplayState(true); |
| 123 updateDisplayState(); | |
| 124 } | 124 } |
| 125 if (!posterImageURL().isEmpty()) { | 125 if (!posterImageURL().isEmpty()) { |
| 126 if (!m_imageLoader) | 126 if (!m_imageLoader) |
| 127 m_imageLoader = HTMLImageLoader::create(this); | 127 m_imageLoader = HTMLImageLoader::create(this); |
| 128 m_imageLoader->updateFromElement(ImageLoader::UpdateIgnorePreviousEr
ror); | 128 m_imageLoader->updateFromElement(ImageLoader::UpdateIgnorePreviousEr
ror); |
| 129 } else { | 129 } else { |
| 130 if (layoutObject()) | 130 if (layoutObject()) |
| 131 toLayoutImage(layoutObject())->imageResource()->setImageResource
(0); | 131 toLayoutImage(layoutObject())->imageResource()->setImageResource
(0); |
| 132 } | 132 } |
| 133 // Notify the player when the poster image URL changes. | 133 // Notify the player when the poster image URL changes. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 158 } | 158 } |
| 159 | 159 |
| 160 const AtomicString HTMLVideoElement::imageSourceURL() const | 160 const AtomicString HTMLVideoElement::imageSourceURL() const |
| 161 { | 161 { |
| 162 const AtomicString& url = getAttribute(posterAttr); | 162 const AtomicString& url = getAttribute(posterAttr); |
| 163 if (!stripLeadingAndTrailingHTMLSpaces(url).isEmpty()) | 163 if (!stripLeadingAndTrailingHTMLSpaces(url).isEmpty()) |
| 164 return url; | 164 return url; |
| 165 return m_defaultPosterURL; | 165 return m_defaultPosterURL; |
| 166 } | 166 } |
| 167 | 167 |
| 168 void HTMLVideoElement::setDisplayMode(DisplayMode mode) | 168 void HTMLVideoElement::setShowPoster(bool showPoster) |
| 169 { | 169 { |
| 170 DisplayMode oldMode = displayMode(); | |
| 171 KURL poster = posterImageURL(); | 170 KURL poster = posterImageURL(); |
| 172 | 171 |
| 173 if (!poster.isEmpty()) { | 172 if (!poster.isEmpty()) { |
| 174 // We have a poster path, but only show it until the user triggers displ
ay by playing or seeking and the | 173 // We have a poster path, but only show it until the user triggers displ
ay by playing or seeking and the |
| 175 // media engine has something to display. | 174 // media engine has something to display. |
| 176 // Don't show the poster if there is a seek operation or | 175 // Don't show the poster if there is a seek operation or |
| 177 // the video has restarted because of loop attribute | 176 // the video has restarted because of loop attribute |
| 178 if (mode == Video && oldMode == Poster && !hasAvailableVideoFrame()) | 177 if (!showPoster && m_showPoster && !hasAvailableVideoFrame()) |
| 179 return; | 178 return; |
| 180 } | 179 } |
| 181 | 180 |
| 182 HTMLMediaElement::setDisplayMode(mode); | 181 if (showPoster != m_showPoster) { |
| 183 | 182 m_showPoster = showPoster; |
| 184 if (layoutObject() && displayMode() != oldMode) | 183 if (layoutObject()) |
| 185 layoutObject()->updateFromElement(); | 184 layoutObject()->updateFromElement(); |
| 185 } |
| 186 } | 186 } |
| 187 | 187 |
| 188 void HTMLVideoElement::updateDisplayState() | 188 void HTMLVideoElement::updateDisplayState(bool forceUpdate) |
| 189 { | 189 { |
| 190 if (posterImageURL().isEmpty()) | 190 if (posterImageURL().isEmpty()) { |
| 191 setDisplayMode(Video); | 191 setShowPoster(false); |
| 192 else if (displayMode() < Poster) | 192 } else if (m_showPoster) { |
| 193 setDisplayMode(Poster); | 193 if (forceUpdate) |
| 194 m_showPoster = false; |
| 195 setShowPoster(true); |
| 196 } |
| 194 } | 197 } |
| 195 | 198 |
| 196 void HTMLVideoElement::paintCurrentFrame(SkCanvas* canvas, const IntRect& destRe
ct, const SkPaint* paint) const | 199 void HTMLVideoElement::paintCurrentFrame(SkCanvas* canvas, const IntRect& destRe
ct, const SkPaint* paint) const |
| 197 { | 200 { |
| 198 if (!webMediaPlayer()) | 201 if (!webMediaPlayer()) |
| 199 return; | 202 return; |
| 200 | 203 |
| 201 SkXfermode::Mode mode; | 204 SkXfermode::Mode mode; |
| 202 if (!paint || !SkXfermode::AsMode(paint->getXfermode(), &mode)) | 205 if (!paint || !SkXfermode::AsMode(paint->getXfermode(), &mode)) |
| 203 mode = SkXfermode::kSrcOver_Mode; | 206 mode = SkXfermode::kSrcOver_Mode; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 { | 316 { |
| 314 return !isMediaDataCORSSameOrigin(destinationSecurityOrigin); | 317 return !isMediaDataCORSSameOrigin(destinationSecurityOrigin); |
| 315 } | 318 } |
| 316 | 319 |
| 317 FloatSize HTMLVideoElement::elementSize() const | 320 FloatSize HTMLVideoElement::elementSize() const |
| 318 { | 321 { |
| 319 return FloatSize(videoWidth(), videoHeight()); | 322 return FloatSize(videoWidth(), videoHeight()); |
| 320 } | 323 } |
| 321 | 324 |
| 322 } // namespace blink | 325 } // namespace blink |
| OLD | NEW |