2009-07-14 Albert J. Wong <ajwong@chromium.org>
authorbfulgham@webkit.org <bfulgham@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Jul 2009 22:20:19 +0000 (22:20 +0000)
committerbfulgham@webkit.org <bfulgham@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Jul 2009 22:20:19 +0000 (22:20 +0000)
        Reviewed by Darin Adler.

        Add HTMLMediaElement::supportSave() and a
        HitTestResult::absoluteMediaURL() functions
        https://bugs.webkit.org/show_bug.cgi?id=27246

        Added an implementation of supportsSave() into HTMLMediaElement
        that delegates to MediaPlayerPrivateImpl so that the media engine
        is able to signal whether or not a media source supports saving.

        Also added a function to HitTestResult that allows for retrieval
        of the currentSrc associated with the "hit" media element.

        These functions are just pipeing with no visible UI change so there
        are no related layout test changes.

        * html/HTMLMediaElement.cpp:
        (WebCore::HTMLMediaElement::supportsFullscreen):
        (WebCore::HTMLMediaElement::supportsSave):
        * html/HTMLMediaElement.h:
        * platform/graphics/MediaPlayer.cpp:
        (WebCore::MediaPlayer::supportsSave):
        * platform/graphics/MediaPlayer.h:
        * platform/graphics/MediaPlayerPrivate.h:
        (WebCore::MediaPlayerPrivateInterface::supportsFullscreen):
        (WebCore::MediaPlayerPrivateInterface::supportsSave):
        * rendering/HitTestResult.cpp:
        (WebCore::HitTestResult::altDisplayString):
        (WebCore::HitTestResult::absoluteMediaURL):
        * rendering/HitTestResult.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@45875 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/html/HTMLMediaElement.cpp
WebCore/html/HTMLMediaElement.h
WebCore/platform/graphics/MediaPlayer.cpp
WebCore/platform/graphics/MediaPlayer.h
WebCore/platform/graphics/MediaPlayerPrivate.h
WebCore/rendering/HitTestResult.cpp
WebCore/rendering/HitTestResult.h

index 188f300..7944b84 100644 (file)
@@ -1,3 +1,36 @@
+2009-07-14  Albert J. Wong  <ajwong@chromium.org>
+
+        Reviewed by Darin Adler.
+
+        Add HTMLMediaElement::supportSave() and a
+        HitTestResult::absoluteMediaURL() functions
+        https://bugs.webkit.org/show_bug.cgi?id=27246
+
+        Added an implementation of supportsSave() into HTMLMediaElement
+        that delegates to MediaPlayerPrivateImpl so that the media engine
+        is able to signal whether or not a media source supports saving.
+
+        Also added a function to HitTestResult that allows for retrieval
+        of the currentSrc associated with the "hit" media element. 
+        
+        These functions are just pipeing with no visible UI change so there
+        are no related layout test changes.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::supportsFullscreen): 
+        (WebCore::HTMLMediaElement::supportsSave):
+        * html/HTMLMediaElement.h:
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::supportsSave):
+        * platform/graphics/MediaPlayer.h:
+        * platform/graphics/MediaPlayerPrivate.h:
+        (WebCore::MediaPlayerPrivateInterface::supportsFullscreen):
+        (WebCore::MediaPlayerPrivateInterface::supportsSave):
+        * rendering/HitTestResult.cpp:
+        (WebCore::HitTestResult::altDisplayString):
+        (WebCore::HitTestResult::absoluteMediaURL):
+        * rendering/HitTestResult.h:
+
 2009-07-14  Dimitri Glazkov  <dglazkov@chromium.org>
 
         Reviewed by Adam Barth.
index 716a592..24ce6b1 100644 (file)
@@ -848,6 +848,16 @@ void HTMLMediaElement::returnToRealtime()
     ExceptionCode e;
     setCurrentTime(maxTimeSeekable(), e);
 }  
+
+bool HTMLMediaElement::supportsFullscreen() const
+{
+    return m_player->supportsFullscreen();
+}
+
+bool HTMLMediaElement::supportsSave() const
+{
+    return m_player->supportsSave();
+}
     
 void HTMLMediaElement::seek(float time, ExceptionCode& ec)
 {
index 486574b..3cd4c40 100644 (file)
@@ -69,7 +69,8 @@ public:
     void rewind(float timeDelta);
     void returnToRealtime();
     
-    virtual bool supportsFullscreen() const { return false; }
+    virtual bool supportsFullscreen() const;
+    virtual bool supportsSave() const;
 
     void scheduleLoad();
     
index 21ce22d..b47a3d5 100644 (file)
@@ -306,6 +306,11 @@ bool MediaPlayer::supportsFullscreen() const
     return m_private->supportsFullscreen();
 }
 
+bool MediaPlayer::supportsSave() const
+{
+    return m_private->supportsSave();
+}
+
 IntSize MediaPlayer::naturalSize()
 {
     return m_private->naturalSize();
index 9d9370b..dae1a92 100644 (file)
@@ -108,6 +108,7 @@ public:
     static bool isAvailable();
 
     bool supportsFullscreen() const;
+    bool supportsSave() const;
     IntSize naturalSize();
     bool hasVideo();
     
index 753ccd2..6d1359b 100644 (file)
@@ -46,7 +46,8 @@ public:
     virtual void play() = 0;
     virtual void pause() = 0;    
 
-    virtual bool supportsFullscreen() const { return false; };
+    virtual bool supportsFullscreen() const { return false; }
+    virtual bool supportsSave() const { return false; }
 
     virtual IntSize naturalSize() const = 0;
 
index f2ed7db..4ec39d3 100644 (file)
@@ -26,6 +26,7 @@
 #include "HTMLAnchorElement.h"
 #include "HTMLImageElement.h"
 #include "HTMLInputElement.h"
+#include "HTMLMediaElement.h"
 #include "HTMLNames.h"
 #include "RenderImage.h"
 #include "Scrollbar.h"
@@ -208,7 +209,7 @@ String HitTestResult::altDisplayString() const
         HTMLInputElement* input = static_cast<HTMLInputElement*>(m_innerNonSharedNode.get());
         return displayString(input->alt(), m_innerNonSharedNode.get());
     }
-    
+
 #if ENABLE(WML)
     if (m_innerNonSharedNode->hasTagName(WMLNames::imgTag)) {
         WMLImageElement* image = static_cast<WMLImageElement*>(m_innerNonSharedNode.get());
@@ -269,6 +270,24 @@ KURL HitTestResult::absoluteImageURL() const
     return m_innerNonSharedNode->document()->completeURL(parseURL(urlString));
 }
 
+KURL HitTestResult::absoluteMediaURL() const
+{
+    if (!(m_innerNonSharedNode && m_innerNonSharedNode->document()))
+        return KURL();
+
+    if (!(m_innerNonSharedNode->renderer() && m_innerNonSharedNode->renderer()->isMedia()))
+        return KURL();
+
+    AtomicString urlString;
+    if (m_innerNonSharedNode->hasTagName(HTMLNames::videoTag) || m_innerNonSharedNode->hasTagName(HTMLNames::audioTag)) {
+        HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(m_innerNonSharedNode.get());
+        urlString = mediaElement->currentSrc();
+    } else
+        return KURL();
+
+    return m_innerNonSharedNode->document()->completeURL(parseURL(urlString));
+}
+
 KURL HitTestResult::absoluteLinkURL() const
 {
     if (!(m_innerURLElement && m_innerURLElement->document()))
index 4f0383f..dbf472d 100644 (file)
@@ -30,8 +30,8 @@ namespace WebCore {
 class Element;
 class Frame;
 class Image;
-class KURL;
 class IntRect;
+class KURL;
 class Node;
 class Scrollbar;
 class String;
@@ -72,6 +72,7 @@ public:
     Image* image() const;
     IntRect imageRect() const;
     KURL absoluteImageURL() const;
+    KURL absoluteMediaURL() const;
     KURL absoluteLinkURL() const;
     String textContent() const;
     bool isLiveLink() const;