Changeset 145750 in webkit
- Timestamp:
- Mar 13, 2013 2:16:50 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r145749 r145750 1 2013-03-13 Tao Bai <michaelbai@chromium.org> 2 3 Add the default video poster if it doesn't exist in video tag 4 https://bugs.webkit.org/show_bug.cgi?id=110263 5 6 Reviewed by Eric Carlson. 7 8 The Android web view application could provide the default poster 9 for a video that doesn't have the poster attribute. 10 11 To provide the default poster, the application must set defaultVideoPosterURL 12 setting and return the image in the response of that URL. 13 14 The way to do this would be: 15 16 A) Replace the Element::imageSourceAttributeName function with an 17 Element::imageSourceURL function that returns the imageSourceURL as a 18 const AtomicString&. The body will be the same as before, it will just also 19 include a call to getAttribute. Also will need to revise the four classes 20 that override that function. 21 22 B) Add a new HTMLVideoElement::posterImageURL function that implements the 23 default poster URL logic. 24 25 C) Update the four functions that get the poster attribute to handle poster 26 loading and display to call posterImageURL. 27 28 1) HTMLVideoElement::imageSourceURL. 29 2) HTMLVideoElement::setDisplayMode. 30 3) HTMLVideoElement::updateDisplayState. 31 4) HTMLMediaElement::getPluginProxyParams. Will need to cast to 32 HTMLVideoElement after checking isVideo. 33 34 * media/video-default-poster-expected.txt: Added. 35 * media/video-default-poster.html: Added. 36 * media/video-no-default-poster-expected.txt: Added. 37 * media/video-no-default-poster.html: Added. 38 1 39 2013-03-13 James Robinson <jamesr@chromium.org> 2 40 -
trunk/Source/WebCore/ChangeLog
r145745 r145750 1 2013-03-13 Tao Bai <michaelbai@chromium.org> 2 3 Add the default video poster if it doesn't exist in video tag 4 https://bugs.webkit.org/show_bug.cgi?id=110263 5 6 Reviewed by Eric Carlson. 7 8 Tests: media/video-default-poster.html 9 media/video-no-default-poster.html 10 11 The Android web view application could provide the default poster 12 for a video that doesn't have the poster attribute. 13 14 To provide the default poster, the application must set defaultVideoPosterURL 15 setting and return the image in the response of that URL. 16 17 The way to do this would be: 18 19 A) Replace the Element::imageSourceAttributeName function with an 20 Element::imageSourceURL function that returns the imageSourceURL as a 21 const AtomicString&. The body will be the same as before, it will just also 22 include a call to getAttribute. Also will need to revise the four classes 23 that override that function. 24 25 B) Add a new HTMLVideoElement::posterImageURL function that implements the 26 default poster URL logic. 27 28 C) Update the four functions that get the poster attribute to handle poster 29 loading and display to call posterImageURL. 30 31 1) HTMLVideoElement::imageSourceURL. 32 2) HTMLVideoElement::setDisplayMode. 33 3) HTMLVideoElement::updateDisplayState. 34 4) HTMLMediaElement::getPluginProxyParams. Will need to cast to 35 HTMLVideoElement after checking isVideo. 36 37 * dom/Element.cpp: 38 (WebCore::Element::imageSourceURL): Replace imageSourceAttributeName() with imageSourceURL() 39 * dom/Element.h: Replace imageSourceAttributeName() with imageSourceURL() 40 * html/HTMLEmbedElement.cpp: 41 (WebCore::HTMLEmbedElement::imageSourceURL): Replace imageSourceAttributeName() with imageSourceURL() 42 * html/HTMLEmbedElement.h: Replace imageSourceAttributeName() with imageSourceURL() 43 * html/HTMLMediaElement.cpp: 44 (WebCore::HTMLMediaElement::getPluginProxyParams): Change to use posterImageURL 45 * html/HTMLObjectElement.cpp: 46 (WebCore::HTMLObjectElement::imageSourceURL): Replace imageSourceAttributeName() with imageSourceURL() 47 * html/HTMLObjectElement.h: Replace imageSourceAttributeName with imageSourceURL 48 * html/HTMLVideoElement.cpp: 49 (WebCore::HTMLVideoElement::HTMLVideoElement): set m_defaultPosterURL if there is such settings 50 (WebCore::HTMLVideoElement::imageSourceURL): Replace imageSourceAttributeName() with imageSourceURL() 51 (WebCore::HTMLVideoElement::setDisplayMode): Use imageSourceURL() 52 (WebCore::HTMLVideoElement::updateDisplayState): Use imageSourceURL() 53 (WebCore::HTMLVideoElement::posterImageURL): Return image source's KURL 54 * html/HTMLVideoElement.h: Replace imageSourceAttributeName() with imageSourceURL() and add m_defaultPosterURL 55 * loader/ImageLoader.cpp: 56 (WebCore::ImageLoader::updateFromElement): Use imageSourceURL() 57 * page/Settings.in: Add defaultVideoPosterURL setting. 58 * platform/chromium/PasteboardChromium.cpp: 59 (WebCore::Pasteboard::writeImage): use imageSourceURL() 60 * platform/gtk/PasteboardGtk.cpp: 61 (WebCore::getURLForImageNode): use imageSourceURL() 62 * rendering/HitTestResult.cpp: 63 (WebCore::HitTestResult::absoluteImageURL): use imageSourceURL() 64 * svg/SVGImageElement.cpp: 65 (WebCore::SVGImageElement::imageSourceURL): Replace imageSourceAttributeName() with imageSourceURL() 66 * svg/SVGImageElement.h: Replace imageSourceAttributeName() with imageSourceURL() 67 * testing/InternalSettings.cpp: 68 (WebCore::InternalSettings::Backup::Backup): support backup defaultVideoPosterURL. 69 (WebCore::InternalSettings::Backup::restoreTo): support restore defaultVideoPosterURL. 70 (WebCore::InternalSettings::setDefaultVideoPosterURL): set defaultVideoPosterURL. 71 * testing/InternalSettings.h: 72 (Backup): support backup defaultVideoPosterURL. 73 (InternalSettings): Add setDefaultVidoePosterURL method. 74 * testing/InternalSettings.idl: Add setDefaultVideoPosterURL for test purpose. 75 * testing/Internals.cpp: 76 (WebCore::Internals::getImageSourceURL): Add getImageSourceURL method. 77 * testing/Internals.h: Add getImageSourceURL method. 78 * testing/Internals.idl: Add getImageSourceURL method. 79 1 80 2013-03-13 Abhishek Arya <inferno@chromium.org> 2 81 -
trunk/Source/WebCore/dom/Element.cpp
r145745 r145750 1122 1122 } 1123 1123 1124 const QualifiedName& Element::imageSourceAttributeName() const1125 { 1126 return srcAttr;1124 const AtomicString& Element::imageSourceURL() const 1125 { 1126 return getAttribute(srcAttr); 1127 1127 } 1128 1128 -
trunk/Source/WebCore/dom/Element.h
r145524 r145750 452 452 KURL getNonEmptyURLAttribute(const QualifiedName&) const; 453 453 454 virtual const QualifiedName& imageSourceAttributeName() const;454 virtual const AtomicString& imageSourceURL() const; 455 455 virtual String target() const { return String(); } 456 456 -
trunk/Source/WebCore/html/HTMLEmbedElement.cpp
r144568 r145750 211 211 } 212 212 213 const QualifiedName& HTMLEmbedElement::imageSourceAttributeName() const214 { 215 return srcAttr;213 const AtomicString& HTMLEmbedElement::imageSourceURL() const 214 { 215 return getAttribute(srcAttr); 216 216 } 217 217 -
trunk/Source/WebCore/html/HTMLEmbedElement.h
r143843 r145750 42 42 43 43 virtual bool isURLAttribute(const Attribute&) const OVERRIDE; 44 virtual const QualifiedName& imageSourceAttributeName() const;44 virtual const AtomicString& imageSourceURL() const OVERRIDE; 45 45 46 46 virtual RenderWidget* renderWidgetForJSBindings() const; -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r145745 r145750 4141 4141 4142 4142 if (isVideo()) { 4143 KURL posterURL = getNonEmptyURLAttribute(posterAttr); 4143 HTMLVideoElement* video = static_cast<HTMLVideoElement*>(this); 4144 KURL posterURL = video->posterImageURL(); 4144 4145 if (!posterURL.isEmpty() && frame && frame->loader()->willLoadMediaElementURL(posterURL)) { 4145 4146 names.append(ASCIILiteral("_media_element_poster_")); -
trunk/Source/WebCore/html/HTMLObjectElement.cpp
r145745 r145750 365 365 } 366 366 367 const QualifiedName& HTMLObjectElement::imageSourceAttributeName() const368 { 369 return dataAttr;367 const AtomicString& HTMLObjectElement::imageSourceURL() const 368 { 369 return getAttribute(dataAttr); 370 370 } 371 371 -
trunk/Source/WebCore/html/HTMLObjectElement.h
r143843 r145750 80 80 81 81 virtual bool isURLAttribute(const Attribute&) const OVERRIDE; 82 virtual const QualifiedName& imageSourceAttributeName() const;82 virtual const AtomicString& imageSourceURL() const OVERRIDE; 83 83 84 84 virtual RenderWidget* renderWidgetForJSBindings() const; -
trunk/Source/WebCore/html/HTMLVideoElement.cpp
r145669 r145750 37 37 #include "HTMLImageLoader.h" 38 38 #include "HTMLNames.h" 39 #include "HTMLParserIdioms.h" 39 40 #include "Page.h" 40 41 #include "RenderImage.h" 41 42 #include "RenderVideo.h" 42 43 #include "ScriptController.h" 44 #include "Settings.h" 43 45 44 46 namespace WebCore { … … 50 52 { 51 53 ASSERT(hasTagName(videoTag)); 54 if (document->settings()) 55 m_defaultPosterURL = document->settings()->defaultVideoPosterURL(); 52 56 } 53 57 … … 179 183 } 180 184 181 const QualifiedName& HTMLVideoElement::imageSourceAttributeName() const 182 { 183 return posterAttr; 185 const AtomicString& HTMLVideoElement::imageSourceURL() const 186 { 187 const AtomicString& url = getAttribute(posterAttr); 188 if (!stripLeadingAndTrailingHTMLSpaces(url).isEmpty()) 189 return url; 190 return m_defaultPosterURL; 184 191 } 185 192 … … 187 194 { 188 195 DisplayMode oldMode = displayMode(); 189 KURL poster = getNonEmptyURLAttribute(posterAttr);196 KURL poster = posterImageURL(); 190 197 191 198 if (!poster.isEmpty()) { … … 222 229 void HTMLVideoElement::updateDisplayState() 223 230 { 224 if ( getNonEmptyURLAttribute(posterAttr).isEmpty())231 if (posterImageURL().isEmpty()) 225 232 setDisplayMode(Video); 226 233 else if (displayMode() < Poster) … … 309 316 #endif 310 317 311 } 312 313 #endif 318 KURL HTMLVideoElement::posterImageURL() const 319 { 320 const AtomicString& url = stripLeadingAndTrailingHTMLSpaces(imageSourceURL()); 321 if (url.isEmpty()) 322 return KURL(); 323 return document()->completeURL(url); 324 } 325 326 } 327 328 #endif -
trunk/Source/WebCore/html/HTMLVideoElement.h
r145669 r145750 70 70 bool shouldDisplayPosterImage() const { return displayMode() == Poster || displayMode() == PosterWaitingForVideo; } 71 71 72 KURL posterImageURL() const; 73 72 74 private: 73 75 HTMLVideoElement(const QualifiedName&, Document*, bool); … … 85 87 virtual bool supportsFullscreen() const; 86 88 virtual bool isURLAttribute(const Attribute&) const OVERRIDE; 87 virtual const QualifiedName& imageSourceAttributeName() const;89 virtual const AtomicString& imageSourceURL() const OVERRIDE; 88 90 89 91 virtual bool hasAvailableVideoFrame() const; … … 94 96 OwnPtr<HTMLImageLoader> m_imageLoader; 95 97 98 AtomicString m_defaultPosterURL; 96 99 }; 97 100 -
trunk/Source/WebCore/loader/ImageLoader.cpp
r145501 r145750 173 173 return; 174 174 175 AtomicString attr = m_element-> getAttribute(m_element->imageSourceAttributeName());175 AtomicString attr = m_element->imageSourceURL(); 176 176 177 177 if (attr == m_failedLoadURL) -
trunk/Source/WebCore/page/Settings.in
r144221 r145750 196 196 logsPageMessagesToSystemConsoleEnabled initial=false 197 197 198 # Some apps could have a default video poster if it is not set. 199 defaultVideoPosterURL type=String 200 198 201 smartInsertDeleteEnabled initial=true -
trunk/Source/WebCore/platform/chromium/PasteboardChromium.cpp
r145444 r145750 154 154 else if (node->hasTagName(HTMLNames::embedTag) || node->hasTagName(HTMLNames::objectTag)) { 155 155 Element* element = toElement(node); 156 urlString = element-> getAttribute(element->imageSourceAttributeName());156 urlString = element->imageSourceURL(); 157 157 } 158 158 KURL url = urlString.isEmpty() ? KURL() : node->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(urlString)); -
trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp
r145596 r145750 108 108 else if (node->hasTagName(HTMLNames::embedTag) || node->hasTagName(HTMLNames::objectTag)) { 109 109 Element* element = toElement(node); 110 urlString = element-> getAttribute(element->imageSourceAttributeName());110 urlString = element->imageSourceURL(); 111 111 } 112 112 return urlString.isEmpty() ? KURL() : node->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(urlString)); -
trunk/Source/WebCore/rendering/HitTestResult.cpp
r145596 r145750 321 321 ) { 322 322 Element* element = toElement(m_innerNonSharedNode.get()); 323 urlString = element-> getAttribute(element->imageSourceAttributeName());323 urlString = element->imageSourceURL(); 324 324 } else 325 325 return KURL(); -
trunk/Source/WebCore/svg/SVGImageElement.cpp
r143843 r145750 223 223 } 224 224 225 const QualifiedName& SVGImageElement::imageSourceAttributeName() const226 { 227 return XLinkNames::hrefAttr;225 const AtomicString& SVGImageElement::imageSourceURL() const 226 { 227 return getAttribute(XLinkNames::hrefAttr); 228 228 } 229 229 -
trunk/Source/WebCore/svg/SVGImageElement.h
r143843 r145750 59 59 60 60 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); 61 62 virtual const QualifiedName& imageSourceAttributeName() const;61 62 virtual const AtomicString& imageSourceURL() const OVERRIDE; 63 63 virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const; 64 64 -
trunk/Source/WebCore/testing/InternalSettings.cpp
r145003 r145750 95 95 , m_shouldDisplayTextDescriptions(settings->shouldDisplayTextDescriptions()) 96 96 #endif 97 , m_defaultVideoPosterURL(settings->defaultVideoPosterURL()) 97 98 , m_originalTimeWithoutMouseMovementBeforeHidingControls(settings->timeWithoutMouseMovementBeforeHidingControls()) 98 99 { … … 131 132 settings->setShouldDisplayTextDescriptions(m_shouldDisplayTextDescriptions); 132 133 #endif 134 settings->setDefaultVideoPosterURL(m_defaultVideoPosterURL); 133 135 settings->setTimeWithoutMouseMovementBeforeHidingControls(m_originalTimeWithoutMouseMovementBeforeHidingControls); 134 136 } … … 490 492 } 491 493 494 void InternalSettings::setDefaultVideoPosterURL(const String& url, ExceptionCode& ec) 495 { 496 InternalSettingsGuardForSettings(); 497 settings()->setDefaultVideoPosterURL(url); 498 } 499 492 500 void InternalSettings::setTimeWithoutMouseMovementBeforeHidingControls(double time, ExceptionCode& ec) 493 501 { -
trunk/Source/WebCore/testing/InternalSettings.h
r145003 r145750 83 83 bool m_shouldDisplayTextDescriptions; 84 84 #endif 85 String m_defaultVideoPosterURL; 85 86 bool m_originalTimeWithoutMouseMovementBeforeHidingControls; 86 87 }; … … 128 129 void setImagesEnabled(bool enabled, ExceptionCode&); 129 130 void setMinimumTimerInterval(double intervalInSeconds, ExceptionCode&); 131 void setDefaultVideoPosterURL(const String& url, ExceptionCode&); 130 132 void setTimeWithoutMouseMovementBeforeHidingControls(double time, ExceptionCode&); 131 133 -
trunk/Source/WebCore/testing/InternalSettings.idl
r145003 r145750 60 60 void setImagesEnabled(in boolean enabled) raises(DOMException); 61 61 void setMinimumTimerInterval(in double intervalInSeconds) raises(DOMException); 62 void setDefaultVideoPosterURL(in DOMString poster) raises(DOMException); 62 63 void setTimeWithoutMouseMovementBeforeHidingControls(in double time) raises(DOMException); 63 64 }; -
trunk/Source/WebCore/testing/Internals.cpp
r145745 r145750 2063 2063 } 2064 2064 2065 } 2065 String Internals::getImageSourceURL(Element* element, ExceptionCode& ec) 2066 { 2067 if (!element) { 2068 ec = INVALID_ACCESS_ERR; 2069 return String(); 2070 } 2071 return element->imageSourceURL(); 2072 } 2073 2074 } -
trunk/Source/WebCore/testing/Internals.h
r145735 r145750 298 298 void enableMockSpeechSynthesizer(); 299 299 #endif 300 301 String getImageSourceURL(Element*, ExceptionCode&); 300 302 301 303 private: -
trunk/Source/WebCore/testing/Internals.idl
r145735 r145750 263 263 264 264 [Conditional=SPEECH_SYNTHESIS] void enableMockSpeechSynthesizer(); 265 266 DOMString getImageSourceURL(in Element element) raises(DOMException); 265 267 };
Note: See TracChangeset
for help on using the changeset viewer.