Title: [145750] trunk
Revision
145750
Author
commit-qu...@webkit.org
Date
2013-03-13 14:16:50 -0700 (Wed, 13 Mar 2013)

Log Message

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 <michael...@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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (145749 => 145750)


--- trunk/LayoutTests/ChangeLog	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/LayoutTests/ChangeLog	2013-03-13 21:16:50 UTC (rev 145750)
@@ -1,3 +1,41 @@
+2013-03-13  Tao Bai  <michael...@chromium.org>
+
+        Add the default video poster if it doesn't exist in video tag
+        https://bugs.webkit.org/show_bug.cgi?id=110263
+
+        Reviewed by Eric Carlson.
+
+        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.
+
 2013-03-13  James Robinson  <jam...@chromium.org>
 
         Force clip in fast/regions/autoheight-break-after-expected.html to match test

Added: trunk/LayoutTests/media/video-default-poster-expected.txt (0 => 145750)


--- trunk/LayoutTests/media/video-default-poster-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/video-default-poster-expected.txt	2013-03-13 21:16:50 UTC (rev 145750)
@@ -0,0 +1,4 @@
+PASS
+PASS
+PASS
+

Added: trunk/LayoutTests/media/video-default-poster.html (0 => 145750)


--- trunk/LayoutTests/media/video-default-poster.html	                        (rev 0)
+++ trunk/LayoutTests/media/video-default-poster.html	2013-03-13 21:16:50 UTC (rev 145750)
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+  if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+  }
+  if (window.internals) {
+    var default_poster = 'content/greenbox.png';
+    window.internals.settings.setDefaultVideoPosterURL(default_poster);
+    addEventListener("load", function() {
+      var poster = window.internals.getImageSourceURL(document.getElementById("video-no-poster"));
+      if (poster) {
+        if (poster == default_poster)
+          document.getElementById("result-no-poster").innerText = "PASS";
+        else
+          document.getElementById("result-no-poster").innerText = "FAIL";
+      } else
+        document.getElementById("result-no-poster").innerText = "FAIL: image source is null";
+
+      poster =  window.internals.getImageSourceURL(document.getElementById("video-has-poster"));
+      if (poster) {
+        if (poster == "content/abe.png")
+          document.getElementById("result-has-poster").innerText = "PASS";
+        else
+          document.getElementById("result-has-poster").innerText = "FAIL: poster was changed";
+      } else
+        document.getElementById("result-has-poster").innerText = "FAIL: image source is null";
+
+      poster =  window.internals.getImageSourceURL(document.getElementById("video-has-empty-poster"));
+      if (poster) {
+        if (poster == default_poster)
+          document.getElementById("result-has-empty-poster").innerText = "PASS";
+        else
+          document.getElementById("result-has-empty-poster").innerText = "FAIL";
+      } else
+        document.getElementById("result-has-empty-poster").innerText = "FAIL: image source is null";
+
+      testRunner.notifyDone();
+    }, false);
+  }
+
+</script>
+</head>
+<body>
+<pre id="result-no-poster"></pre>
+<pre id="result-has-poster"></pre>
+<pre id="result-has-empty-poster"></pre>
+<video id="video-no-poster" src="" preload="none" />
+<video id="video-has-poster" src="" poster="content/abe.png" preload="none" />
+<video id="video-has-empty-poster" src="" poster="" preload="none" />
+</body>
+</html>

Added: trunk/LayoutTests/media/video-no-default-poster-expected.txt (0 => 145750)


--- trunk/LayoutTests/media/video-no-default-poster-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/video-no-default-poster-expected.txt	2013-03-13 21:16:50 UTC (rev 145750)
@@ -0,0 +1,3 @@
+PASS
+PASS
+

Added: trunk/LayoutTests/media/video-no-default-poster.html (0 => 145750)


--- trunk/LayoutTests/media/video-no-default-poster.html	                        (rev 0)
+++ trunk/LayoutTests/media/video-no-default-poster.html	2013-03-13 21:16:50 UTC (rev 145750)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+  if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+  }
+
+  if (window.internals) {
+    addEventListener("load", function() {
+      var poster = window.internals.getImageSourceURL(document.getElementById("video-no-poster"));
+      if (poster)
+        document.getElementById("result-no-poster").innerText = "FAIL : poster was added.";
+      else
+        document.getElementById("result-no-poster").innerText = "PASS";
+
+      poster = window.internals.getImageSourceURL(document.getElementById("video-has-poster"));
+      if (poster) {
+        if (poster == "content/abe.png")
+          document.getElementById("result-has-poster").innerText = "PASS";
+        else
+          document.getElementById("result-has-poster").innerText = "FAIL: poster was changed";
+      } else
+        document.getElementById("result-has-poster").innerText = "FAIL: Image source is null";
+
+      testRunner.notifyDone();
+    }, false);
+  }
+
+</script>
+</head>
+<body>
+<pre id="result-no-poster"></pre>
+<pre id="result-has-poster"></pre>
+<video id="video-no-poster" src="" preload="none" />
+<video id="video-has-poster" src="" poster="content/abe.png" preload="none" />
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (145749 => 145750)


--- trunk/Source/WebCore/ChangeLog	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/ChangeLog	2013-03-13 21:16:50 UTC (rev 145750)
@@ -1,3 +1,82 @@
+2013-03-13  Tao Bai  <michael...@chromium.org>
+
+        Add the default video poster if it doesn't exist in video tag
+        https://bugs.webkit.org/show_bug.cgi?id=110263
+
+        Reviewed by Eric Carlson.
+
+        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.
+
 2013-03-13  Abhishek Arya  <infe...@chromium.org>
 
         Replace static_casts with to* functions for document types.

Modified: trunk/Source/WebCore/dom/Element.cpp (145749 => 145750)


--- trunk/Source/WebCore/dom/Element.cpp	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/dom/Element.cpp	2013-03-13 21:16:50 UTC (rev 145750)
@@ -1121,9 +1121,9 @@
     return KURL(parentBase, baseAttribute);
 }
 
-const QualifiedName& Element::imageSourceAttributeName() const
+const AtomicString& Element::imageSourceURL() const
 {
-    return srcAttr;
+    return getAttribute(srcAttr);
 }
 
 bool Element::rendererIsNeeded(const NodeRenderingContext& context)

Modified: trunk/Source/WebCore/dom/Element.h (145749 => 145750)


--- trunk/Source/WebCore/dom/Element.h	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/dom/Element.h	2013-03-13 21:16:50 UTC (rev 145750)
@@ -451,7 +451,7 @@
     KURL getURLAttribute(const QualifiedName&) const;
     KURL getNonEmptyURLAttribute(const QualifiedName&) const;
 
-    virtual const QualifiedName& imageSourceAttributeName() const;
+    virtual const AtomicString& imageSourceURL() const;
     virtual String target() const { return String(); }
 
     virtual void focus(bool restorePreviousSelection = true, FocusDirection = FocusDirectionNone);

Modified: trunk/Source/WebCore/html/HTMLEmbedElement.cpp (145749 => 145750)


--- trunk/Source/WebCore/html/HTMLEmbedElement.cpp	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/html/HTMLEmbedElement.cpp	2013-03-13 21:16:50 UTC (rev 145750)
@@ -210,9 +210,9 @@
     return attribute.name() == srcAttr || HTMLPlugInImageElement::isURLAttribute(attribute);
 }
 
-const QualifiedName& HTMLEmbedElement::imageSourceAttributeName() const
+const AtomicString& HTMLEmbedElement::imageSourceURL() const
 {
-    return srcAttr;
+    return getAttribute(srcAttr);
 }
 
 void HTMLEmbedElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const

Modified: trunk/Source/WebCore/html/HTMLEmbedElement.h (145749 => 145750)


--- trunk/Source/WebCore/html/HTMLEmbedElement.h	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/html/HTMLEmbedElement.h	2013-03-13 21:16:50 UTC (rev 145750)
@@ -41,7 +41,7 @@
     virtual bool rendererIsNeeded(const NodeRenderingContext&);
 
     virtual bool isURLAttribute(const Attribute&) const OVERRIDE;
-    virtual const QualifiedName& imageSourceAttributeName() const;
+    virtual const AtomicString& imageSourceURL() const OVERRIDE;
 
     virtual RenderWidget* renderWidgetForJSBindings() const;
 

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (145749 => 145750)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2013-03-13 21:16:50 UTC (rev 145750)
@@ -4140,7 +4140,8 @@
     Frame* frame = document()->frame();
 
     if (isVideo()) {
-        KURL posterURL = getNonEmptyURLAttribute(posterAttr);
+        HTMLVideoElement* video = static_cast<HTMLVideoElement*>(this);
+        KURL posterURL = video->posterImageURL();
         if (!posterURL.isEmpty() && frame && frame->loader()->willLoadMediaElementURL(posterURL)) {
             names.append(ASCIILiteral("_media_element_poster_"));
             values.append(posterURL.string());

Modified: trunk/Source/WebCore/html/HTMLObjectElement.cpp (145749 => 145750)


--- trunk/Source/WebCore/html/HTMLObjectElement.cpp	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/html/HTMLObjectElement.cpp	2013-03-13 21:16:50 UTC (rev 145750)
@@ -364,9 +364,9 @@
     return attribute.name() == dataAttr || (attribute.name() == usemapAttr && attribute.value().string()[0] != '#') || HTMLPlugInImageElement::isURLAttribute(attribute);
 }
 
-const QualifiedName& HTMLObjectElement::imageSourceAttributeName() const
+const AtomicString& HTMLObjectElement::imageSourceURL() const
 {
-    return dataAttr;
+    return getAttribute(dataAttr);
 }
 
 void HTMLObjectElement::renderFallbackContent()

Modified: trunk/Source/WebCore/html/HTMLObjectElement.h (145749 => 145750)


--- trunk/Source/WebCore/html/HTMLObjectElement.h	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/html/HTMLObjectElement.h	2013-03-13 21:16:50 UTC (rev 145750)
@@ -79,7 +79,7 @@
     virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
 
     virtual bool isURLAttribute(const Attribute&) const OVERRIDE;
-    virtual const QualifiedName& imageSourceAttributeName() const;
+    virtual const AtomicString& imageSourceURL() const OVERRIDE;
 
     virtual RenderWidget* renderWidgetForJSBindings() const;
 

Modified: trunk/Source/WebCore/html/HTMLVideoElement.cpp (145749 => 145750)


--- trunk/Source/WebCore/html/HTMLVideoElement.cpp	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/html/HTMLVideoElement.cpp	2013-03-13 21:16:50 UTC (rev 145750)
@@ -36,10 +36,12 @@
 #include "Frame.h"
 #include "HTMLImageLoader.h"
 #include "HTMLNames.h"
+#include "HTMLParserIdioms.h"
 #include "Page.h"
 #include "RenderImage.h"
 #include "RenderVideo.h"
 #include "ScriptController.h"
+#include "Settings.h"
 
 namespace WebCore {
 
@@ -49,6 +51,8 @@
     : HTMLMediaElement(tagName, document, createdByParser)
 {
     ASSERT(hasTagName(videoTag));
+    if (document->settings())
+        m_defaultPosterURL = document->settings()->defaultVideoPosterURL();
 }
 
 PassRefPtr<HTMLVideoElement> HTMLVideoElement::create(const QualifiedName& tagName, Document* document, bool createdByParser)
@@ -178,15 +182,18 @@
     return attribute.name() == posterAttr || HTMLMediaElement::isURLAttribute(attribute);
 }
 
-const QualifiedName& HTMLVideoElement::imageSourceAttributeName() const
+const AtomicString& HTMLVideoElement::imageSourceURL() const
 {
-    return posterAttr;
+    const AtomicString& url = ""
+    if (!stripLeadingAndTrailingHTMLSpaces(url).isEmpty())
+        return url;
+    return m_defaultPosterURL;
 }
 
 void HTMLVideoElement::setDisplayMode(DisplayMode mode)
 {
     DisplayMode oldMode = displayMode();
-    KURL poster = getNonEmptyURLAttribute(posterAttr);
+    KURL poster = posterImageURL();
 
     if (!poster.isEmpty()) {
         // We have a poster path, but only show it until the user triggers display by playing or seeking and the
@@ -221,7 +228,7 @@
 
 void HTMLVideoElement::updateDisplayState()
 {
-    if (getNonEmptyURLAttribute(posterAttr).isEmpty())
+    if (posterImageURL().isEmpty())
         setDisplayMode(Video);
     else if (displayMode() < Poster)
         setDisplayMode(Poster);
@@ -308,6 +315,14 @@
 }
 #endif
 
+KURL HTMLVideoElement::posterImageURL() const
+{
+    const AtomicString& url = ""
+    if (url.isEmpty())
+        return KURL();
+    return document()->completeURL(url);
 }
 
+}
+
 #endif

Modified: trunk/Source/WebCore/html/HTMLVideoElement.h (145749 => 145750)


--- trunk/Source/WebCore/html/HTMLVideoElement.h	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/html/HTMLVideoElement.h	2013-03-13 21:16:50 UTC (rev 145750)
@@ -69,6 +69,8 @@
 
     bool shouldDisplayPosterImage() const { return displayMode() == Poster || displayMode() == PosterWaitingForVideo; }
 
+    KURL posterImageURL() const;
+
 private:
     HTMLVideoElement(const QualifiedName&, Document*, bool);
 
@@ -84,7 +86,7 @@
     virtual bool hasVideo() const { return player() && player()->hasVideo(); }
     virtual bool supportsFullscreen() const;
     virtual bool isURLAttribute(const Attribute&) const OVERRIDE;
-    virtual const QualifiedName& imageSourceAttributeName() const;
+    virtual const AtomicString& imageSourceURL() const OVERRIDE;
 
     virtual bool hasAvailableVideoFrame() const;
     virtual void updateDisplayState();
@@ -93,6 +95,7 @@
 
     OwnPtr<HTMLImageLoader> m_imageLoader;
 
+    AtomicString m_defaultPosterURL;
 };
 
 } //namespace

Modified: trunk/Source/WebCore/loader/ImageLoader.cpp (145749 => 145750)


--- trunk/Source/WebCore/loader/ImageLoader.cpp	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/loader/ImageLoader.cpp	2013-03-13 21:16:50 UTC (rev 145750)
@@ -172,7 +172,7 @@
     if (!document->renderer())
         return;
 
-    AtomicString attr = m_element->getAttribute(m_element->imageSourceAttributeName());
+    AtomicString attr = m_element->imageSourceURL();
 
     if (attr == m_failedLoadURL)
         return;

Modified: trunk/Source/WebCore/page/Settings.in (145749 => 145750)


--- trunk/Source/WebCore/page/Settings.in	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/page/Settings.in	2013-03-13 21:16:50 UTC (rev 145750)
@@ -195,4 +195,7 @@
 
 logsPageMessagesToSystemConsoleEnabled initial=false
 
+# Some apps could have a default video poster if it is not set.
+defaultVideoPosterURL type=String
+
 smartInsertDeleteEnabled initial=true

Modified: trunk/Source/WebCore/platform/chromium/PasteboardChromium.cpp (145749 => 145750)


--- trunk/Source/WebCore/platform/chromium/PasteboardChromium.cpp	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/platform/chromium/PasteboardChromium.cpp	2013-03-13 21:16:50 UTC (rev 145750)
@@ -153,7 +153,7 @@
 #endif
     else if (node->hasTagName(HTMLNames::embedTag) || node->hasTagName(HTMLNames::objectTag)) {
         Element* element = toElement(node);
-        urlString = element->getAttribute(element->imageSourceAttributeName());
+        urlString = element->imageSourceURL();
     }
     KURL url = "" ? KURL() : node->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(urlString));
     WebKit::WebImage webImage = bitmap->bitmap();

Modified: trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp (145749 => 145750)


--- trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp	2013-03-13 21:16:50 UTC (rev 145750)
@@ -107,7 +107,7 @@
 #endif
     else if (node->hasTagName(HTMLNames::embedTag) || node->hasTagName(HTMLNames::objectTag)) {
         Element* element = toElement(node);
-        urlString = element->getAttribute(element->imageSourceAttributeName());
+        urlString = element->imageSourceURL();
     }
     return urlString.isEmpty() ? KURL() : node->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(urlString));
 }

Modified: trunk/Source/WebCore/rendering/HitTestResult.cpp (145749 => 145750)


--- trunk/Source/WebCore/rendering/HitTestResult.cpp	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/rendering/HitTestResult.cpp	2013-03-13 21:16:50 UTC (rev 145750)
@@ -320,7 +320,7 @@
 #endif
        ) {
         Element* element = toElement(m_innerNonSharedNode.get());
-        urlString = element->getAttribute(element->imageSourceAttributeName());
+        urlString = element->imageSourceURL();
     } else
         return KURL();
 

Modified: trunk/Source/WebCore/svg/SVGImageElement.cpp (145749 => 145750)


--- trunk/Source/WebCore/svg/SVGImageElement.cpp	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/svg/SVGImageElement.cpp	2013-03-13 21:16:50 UTC (rev 145750)
@@ -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

Modified: trunk/Source/WebCore/svg/SVGImageElement.h (145749 => 145750)


--- trunk/Source/WebCore/svg/SVGImageElement.h	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/svg/SVGImageElement.h	2013-03-13 21:16:50 UTC (rev 145750)
@@ -58,8 +58,8 @@
     virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
 
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
- 
-    virtual const QualifiedName& imageSourceAttributeName() const;       
+
+    virtual const AtomicString& imageSourceURL() const OVERRIDE;
     virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
 
     virtual bool haveLoadedRequiredResources();

Modified: trunk/Source/WebCore/testing/InternalSettings.cpp (145749 => 145750)


--- trunk/Source/WebCore/testing/InternalSettings.cpp	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/testing/InternalSettings.cpp	2013-03-13 21:16:50 UTC (rev 145750)
@@ -94,6 +94,7 @@
     , m_shouldDisplayCaptions(settings->shouldDisplayCaptions())
     , m_shouldDisplayTextDescriptions(settings->shouldDisplayTextDescriptions())
 #endif
+    , m_defaultVideoPosterURL(settings->defaultVideoPosterURL())
     , m_originalTimeWithoutMouseMovementBeforeHidingControls(settings->timeWithoutMouseMovementBeforeHidingControls())
 {
 }
@@ -130,6 +131,7 @@
     settings->setShouldDisplayCaptions(m_shouldDisplayCaptions);
     settings->setShouldDisplayTextDescriptions(m_shouldDisplayTextDescriptions);
 #endif
+    settings->setDefaultVideoPosterURL(m_defaultVideoPosterURL);
     settings->setTimeWithoutMouseMovementBeforeHidingControls(m_originalTimeWithoutMouseMovementBeforeHidingControls);
 }
 
@@ -489,6 +491,12 @@
     settings()->setMinDOMTimerInterval(intervalInSeconds);
 }
 
+void InternalSettings::setDefaultVideoPosterURL(const String& url, ExceptionCode& ec)
+{
+    InternalSettingsGuardForSettings();
+    settings()->setDefaultVideoPosterURL(url);
+}
+
 void InternalSettings::setTimeWithoutMouseMovementBeforeHidingControls(double time, ExceptionCode& ec)
 {
     InternalSettingsGuardForSettings();

Modified: trunk/Source/WebCore/testing/InternalSettings.h (145749 => 145750)


--- trunk/Source/WebCore/testing/InternalSettings.h	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/testing/InternalSettings.h	2013-03-13 21:16:50 UTC (rev 145750)
@@ -82,6 +82,7 @@
         bool m_shouldDisplayCaptions;
         bool m_shouldDisplayTextDescriptions;
 #endif
+        String m_defaultVideoPosterURL;
         bool m_originalTimeWithoutMouseMovementBeforeHidingControls;
     };
 
@@ -127,6 +128,7 @@
     void setLangAttributeAwareFormControlUIEnabled(bool);
     void setImagesEnabled(bool enabled, ExceptionCode&);
     void setMinimumTimerInterval(double intervalInSeconds, ExceptionCode&);
+    void setDefaultVideoPosterURL(const String& url, ExceptionCode&);
     void setTimeWithoutMouseMovementBeforeHidingControls(double time, ExceptionCode&);
 
 private:

Modified: trunk/Source/WebCore/testing/InternalSettings.idl (145749 => 145750)


--- trunk/Source/WebCore/testing/InternalSettings.idl	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/testing/InternalSettings.idl	2013-03-13 21:16:50 UTC (rev 145750)
@@ -59,5 +59,6 @@
     void setStorageBlockingPolicy(in DOMString policy) raises(DOMException);
     void setImagesEnabled(in boolean enabled) raises(DOMException);
     void setMinimumTimerInterval(in double intervalInSeconds) raises(DOMException);
+    void setDefaultVideoPosterURL(in DOMString poster) raises(DOMException);
     void setTimeWithoutMouseMovementBeforeHidingControls(in double time) raises(DOMException);
 };

Modified: trunk/Source/WebCore/testing/Internals.cpp (145749 => 145750)


--- trunk/Source/WebCore/testing/Internals.cpp	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/testing/Internals.cpp	2013-03-13 21:16:50 UTC (rev 145750)
@@ -2062,4 +2062,13 @@
     return WebCore::markerTextForListItem(element);
 }
 
+String Internals::getImageSourceURL(Element* element, ExceptionCode& ec)
+{
+    if (!element) {
+        ec = INVALID_ACCESS_ERR;
+        return String();
+    }
+    return element->imageSourceURL();
 }
+
+}

Modified: trunk/Source/WebCore/testing/Internals.h (145749 => 145750)


--- trunk/Source/WebCore/testing/Internals.h	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/testing/Internals.h	2013-03-13 21:16:50 UTC (rev 145750)
@@ -297,6 +297,8 @@
 #if ENABLE(SPEECH_SYNTHESIS)
     void enableMockSpeechSynthesizer();
 #endif
+
+    String getImageSourceURL(Element*, ExceptionCode&);
                     
 private:
     explicit Internals(Document*);

Modified: trunk/Source/WebCore/testing/Internals.idl (145749 => 145750)


--- trunk/Source/WebCore/testing/Internals.idl	2013-03-13 20:55:22 UTC (rev 145749)
+++ trunk/Source/WebCore/testing/Internals.idl	2013-03-13 21:16:50 UTC (rev 145750)
@@ -262,4 +262,6 @@
     [Conditional=ENCRYPTED_MEDIA_V2] void initializeMockCDM();
 
     [Conditional=SPEECH_SYNTHESIS] void enableMockSpeechSynthesizer();
+
+    DOMString getImageSourceURL(in Element element) raises(DOMException);
 };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to