Add the default video poster if it doesn't exist in video tag
https://bugs.webkit.org/show_bug.cgi?id=110263
Patch by Tao Bai <michaelbai@chromium.org> on 2013-03-13
Reviewed by Eric Carlson.
Source/WebCore:
Tests: media/video-default-poster.html
media/video-no-default-poster.html
The Android web view application could provide the default poster
for a video that doesn't have the poster attribute.
To provide the default poster, the application must set defaultVideoPosterURL
setting and return the image in the response of that URL.
The way to do this would be:
A) Replace the Element::imageSourceAttributeName function with an
Element::imageSourceURL function that returns the imageSourceURL as a
const AtomicString&. The body will be the same as before, it will just also
include a call to getAttribute. Also will need to revise the four classes
that override that function.
B) Add a new HTMLVideoElement::posterImageURL function that implements the
default poster URL logic.
C) Update the four functions that get the poster attribute to handle poster
loading and display to call posterImageURL.
1) HTMLVideoElement::imageSourceURL.
2) HTMLVideoElement::setDisplayMode.
3) HTMLVideoElement::updateDisplayState.
4) HTMLMediaElement::getPluginProxyParams. Will need to cast to
HTMLVideoElement after checking isVideo.
* dom/Element.cpp:
(WebCore::Element::imageSourceURL): Replace imageSourceAttributeName() with imageSourceURL()
* dom/Element.h: Replace imageSourceAttributeName() with imageSourceURL()
* html/HTMLEmbedElement.cpp:
(WebCore::HTMLEmbedElement::imageSourceURL): Replace imageSourceAttributeName() with imageSourceURL()
* html/HTMLEmbedElement.h: Replace imageSourceAttributeName() with imageSourceURL()
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::getPluginProxyParams): Change to use posterImageURL
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::imageSourceURL): Replace imageSourceAttributeName() with imageSourceURL()
* html/HTMLObjectElement.h: Replace imageSourceAttributeName with imageSourceURL
* html/HTMLVideoElement.cpp:
(WebCore::HTMLVideoElement::HTMLVideoElement): set m_defaultPosterURL if there is such settings
(WebCore::HTMLVideoElement::imageSourceURL): Replace imageSourceAttributeName() with imageSourceURL()
(WebCore::HTMLVideoElement::setDisplayMode): Use imageSourceURL()
(WebCore::HTMLVideoElement::updateDisplayState): Use imageSourceURL()
(WebCore::HTMLVideoElement::posterImageURL): Return image source's KURL
* html/HTMLVideoElement.h: Replace imageSourceAttributeName() with imageSourceURL() and add m_defaultPosterURL
* loader/ImageLoader.cpp:
(WebCore::ImageLoader::updateFromElement): Use imageSourceURL()
* page/Settings.in: Add defaultVideoPosterURL setting.
* platform/chromium/PasteboardChromium.cpp:
(WebCore::Pasteboard::writeImage): use imageSourceURL()
* platform/gtk/PasteboardGtk.cpp:
(WebCore::getURLForImageNode): use imageSourceURL()
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::absoluteImageURL): use imageSourceURL()
* svg/SVGImageElement.cpp:
(WebCore::SVGImageElement::imageSourceURL): Replace imageSourceAttributeName() with imageSourceURL()
* svg/SVGImageElement.h: Replace imageSourceAttributeName() with imageSourceURL()
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::Backup::Backup): support backup defaultVideoPosterURL.
(WebCore::InternalSettings::Backup::restoreTo): support restore defaultVideoPosterURL.
(WebCore::InternalSettings::setDefaultVideoPosterURL): set defaultVideoPosterURL.
* testing/InternalSettings.h:
(Backup): support backup defaultVideoPosterURL.
(InternalSettings): Add setDefaultVidoePosterURL method.
* testing/InternalSettings.idl: Add setDefaultVideoPosterURL for test purpose.
* testing/Internals.cpp:
(WebCore::Internals::getImageSourceURL): Add getImageSourceURL method.
* testing/Internals.h: Add getImageSourceURL method.
* testing/Internals.idl: Add getImageSourceURL method.
LayoutTests:
The Android web view application could provide the default poster
for a video that doesn't have the poster attribute.
To provide the default poster, the application must set defaultVideoPosterURL
setting and return the image in the response of that URL.
The way to do this would be:
A) Replace the Element::imageSourceAttributeName function with an
Element::imageSourceURL function that returns the imageSourceURL as a
const AtomicString&. The body will be the same as before, it will just also
include a call to getAttribute. Also will need to revise the four classes
that override that function.
B) Add a new HTMLVideoElement::posterImageURL function that implements the
default poster URL logic.
C) Update the four functions that get the poster attribute to handle poster
loading and display to call posterImageURL.
1) HTMLVideoElement::imageSourceURL.
2) HTMLVideoElement::setDisplayMode.
3) HTMLVideoElement::updateDisplayState.
4) HTMLMediaElement::getPluginProxyParams. Will need to cast to
HTMLVideoElement after checking isVideo.
* media/video-default-poster-expected.txt: Added.
* media/video-default-poster.html: Added.
* media/video-no-default-poster-expected.txt: Added.
* media/video-no-default-poster.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145750 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/svg/SVGImageElement.cpp b/Source/WebCore/svg/SVGImageElement.cpp
index afb4ddc..0d23be3 100644
--- a/Source/WebCore/svg/SVGImageElement.cpp
+++ b/Source/WebCore/svg/SVGImageElement.cpp
@@ -222,9 +222,9 @@
return InsertionDone;
}
-const QualifiedName& SVGImageElement::imageSourceAttributeName() const
+const AtomicString& SVGImageElement::imageSourceURL() const
{
- return XLinkNames::hrefAttr;
+ return getAttribute(XLinkNames::hrefAttr);
}
void SVGImageElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const