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 if (shouldDisplayPosterImage()) { | 89 if (shouldDisplayPosterImage()) { |
90 if (!m_imageLoader) | 90 if (!m_imageLoader) |
91 m_imageLoader = HTMLImageLoader::create(this); | 91 m_imageLoader = HTMLImageLoader::create(this); |
92 m_imageLoader->updateFromElement(); | 92 m_imageLoader->updateFromElement(); |
93 if (layoutObject()) | 93 if (layoutObject()) |
94 toLayoutImage(layoutObject())->imageResource()->setImageResource(m_i
mageLoader->image()); | 94 toLayoutImage(layoutObject())->imageResource()->setImageResource(m_i
mageLoader->image()); |
95 } | 95 } |
96 } | 96 } |
97 | 97 |
98 void HTMLVideoElement::collectStyleForPresentationAttribute(const QualifiedName&
name, const AtomicString& value, MutableStylePropertySet* style) | 98 void HTMLVideoElement::collectStyleForPresentationAttribute(const QualifiedName&
name, const AtomicString& value, MutableStylePropertySet* style) |
99 { | 99 { |
100 if (name == widthAttr) | 100 if (name == widthAttr) |
101 addHTMLLengthToStyle(style, CSSPropertyWidth, value); | 101 addHTMLLengthToStyle(style, CSSPropertyWidth, value); |
102 else if (name == heightAttr) | 102 else if (name == heightAttr) |
103 addHTMLLengthToStyle(style, CSSPropertyHeight, value); | 103 addHTMLLengthToStyle(style, CSSPropertyHeight, value); |
104 else | 104 else |
105 HTMLMediaElement::collectStyleForPresentationAttribute(name, value, styl
e); | 105 HTMLMediaElement::collectStyleForPresentationAttribute(name, value, styl
e); |
106 } | 106 } |
107 | 107 |
108 bool HTMLVideoElement::isPresentationAttribute(const QualifiedName& name) const | 108 bool HTMLVideoElement::isPresentationAttribute(const QualifiedName& name) const |
109 { | 109 { |
110 if (name == widthAttr || name == heightAttr) | 110 if (name == widthAttr || name == heightAttr) |
111 return true; | 111 return true; |
112 return HTMLMediaElement::isPresentationAttribute(name); | 112 return HTMLMediaElement::isPresentationAttribute(name); |
113 } | 113 } |
114 | 114 |
115 void HTMLVideoElement::parseAttribute(const QualifiedName& name, const AtomicStr
ing& value) | 115 void HTMLVideoElement::parseAttribute(const QualifiedName& name, const AtomicStr
ing& value) |
116 { | 116 { |
117 if (name == posterAttr) { | 117 if (name == posterAttr) { |
118 // 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 if (displayMode() < Video || !hasAvailableVideoFrame()) { | |
121 // Force a poster recalc by setting m_displayMode to Unknown directl
y before calling updateDisplayState. | |
122 HTMLMediaElement::setDisplayMode(Unknown); | |
123 updateDisplayState(); | |
124 } | |
125 if (!posterImageURL().isEmpty()) { | 118 if (!posterImageURL().isEmpty()) { |
126 if (!m_imageLoader) | 119 if (!m_imageLoader) |
127 m_imageLoader = HTMLImageLoader::create(this); | 120 m_imageLoader = HTMLImageLoader::create(this); |
128 m_imageLoader->updateFromElement(ImageLoader::UpdateIgnorePreviousEr
ror); | 121 m_imageLoader->updateFromElement(ImageLoader::UpdateIgnorePreviousEr
ror); |
129 } else { | 122 } else { |
130 if (layoutObject()) | 123 if (layoutObject()) |
131 toLayoutImage(layoutObject())->imageResource()->setImageResource
(0); | 124 toLayoutImage(layoutObject())->imageResource()->setImageResource
(0); |
132 } | 125 } |
133 // Notify the player when the poster image URL changes. | 126 // Notify the player when the poster image URL changes. |
134 if (webMediaPlayer()) | 127 if (webMediaPlayer()) |
(...skipping 23 matching lines...) Expand all Loading... |
158 } | 151 } |
159 | 152 |
160 const AtomicString HTMLVideoElement::imageSourceURL() const | 153 const AtomicString HTMLVideoElement::imageSourceURL() const |
161 { | 154 { |
162 const AtomicString& url = getAttribute(posterAttr); | 155 const AtomicString& url = getAttribute(posterAttr); |
163 if (!stripLeadingAndTrailingHTMLSpaces(url).isEmpty()) | 156 if (!stripLeadingAndTrailingHTMLSpaces(url).isEmpty()) |
164 return url; | 157 return url; |
165 return m_defaultPosterURL; | 158 return m_defaultPosterURL; |
166 } | 159 } |
167 | 160 |
168 void HTMLVideoElement::setDisplayMode(DisplayMode mode) | 161 void HTMLVideoElement::setShowPoster(bool showPoster) |
169 { | 162 { |
170 DisplayMode oldMode = displayMode(); | |
171 KURL poster = posterImageURL(); | 163 KURL poster = posterImageURL(); |
172 | 164 |
173 if (!poster.isEmpty()) { | 165 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 | 166 // 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. | 167 // media engine has something to display. |
176 // Don't show the poster if there is a seek operation or | 168 // Don't show the poster if there is a seek operation or |
177 // the video has restarted because of loop attribute | 169 // the video has restarted because of loop attribute |
178 if (mode == Video && oldMode == Poster && !hasAvailableVideoFrame()) | 170 if (!showPoster && m_showPoster && !hasAvailableVideoFrame()) |
179 return; | 171 return; |
180 } | 172 } |
181 | 173 |
182 HTMLMediaElement::setDisplayMode(mode); | 174 if (showPoster != m_showPoster) { |
183 | 175 m_showPoster = showPoster; |
184 if (layoutObject() && displayMode() != oldMode) | 176 if (layoutObject()) |
185 layoutObject()->updateFromElement(); | 177 layoutObject()->updateFromElement(); |
186 } | 178 } |
187 | |
188 void HTMLVideoElement::updateDisplayState() | |
189 { | |
190 if (posterImageURL().isEmpty()) | |
191 setDisplayMode(Video); | |
192 else if (displayMode() < Poster) | |
193 setDisplayMode(Poster); | |
194 } | 179 } |
195 | 180 |
196 void HTMLVideoElement::paintCurrentFrame(SkCanvas* canvas, const IntRect& destRe
ct, const SkPaint* paint) const | 181 void HTMLVideoElement::paintCurrentFrame(SkCanvas* canvas, const IntRect& destRe
ct, const SkPaint* paint) const |
197 { | 182 { |
198 if (!webMediaPlayer()) | 183 if (!webMediaPlayer()) |
199 return; | 184 return; |
200 | 185 |
201 SkXfermode::Mode mode; | 186 SkXfermode::Mode mode; |
202 if (!paint || !SkXfermode::AsMode(paint->getXfermode(), &mode)) | 187 if (!paint || !SkXfermode::AsMode(paint->getXfermode(), &mode)) |
203 mode = SkXfermode::kSrcOver_Mode; | 188 mode = SkXfermode::kSrcOver_Mode; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 { | 299 { |
315 return !isMediaDataCORSSameOrigin(destinationSecurityOrigin); | 300 return !isMediaDataCORSSameOrigin(destinationSecurityOrigin); |
316 } | 301 } |
317 | 302 |
318 FloatSize HTMLVideoElement::elementSize() const | 303 FloatSize HTMLVideoElement::elementSize() const |
319 { | 304 { |
320 return FloatSize(videoWidth(), videoHeight()); | 305 return FloatSize(videoWidth(), videoHeight()); |
321 } | 306 } |
322 | 307 |
323 } // namespace blink | 308 } // namespace blink |
OLD | NEW |