[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    Adding <video> and <audio>
From:       Michael Howell <mhowell123 () gmail ! com>
Date:       2009-06-04 3:32:07
Message-ID: 200906032032.13039.mhowell123 () gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


KHTML currently includes a small amount of boilerplate code, imported from 
WebKit, for HTML5 media elements. This patch finishes the job, backing it with 
Phonon and native KDE widgets for controls.

I'd like it to be reviewed, please, before commiting.

-- 
Please do not send HTML mail. Please, if you forward email, clean off the 
garbage. Thanks for making everyone's email experience more enjoyable. 

Michael Howell 
mhowell123@gmail.com


["patch.diff" (text/x-patch)]

Index: khtml/html/HTMLVideoElement.cpp
===================================================================
--- khtml/html/HTMLVideoElement.cpp	(revision 977361)
+++ khtml/html/HTMLVideoElement.cpp	(working copy)
@@ -27,6 +27,7 @@
 
 #include "HTMLDocument.h"
 #include <misc/htmlhashes.h>
+#include <rendering/RenderMedia.h>
 
 namespace khtml {
 
@@ -44,14 +45,20 @@
 {
     if (!m_player)
         return 0;
-    return m_player->naturalSize().width();
+    if (m_player->mediaObject()->hasVideo())
+        return m_player->videoWidget()->sizeHint().width();
+    else
+        return 0;
 }
 
 int HTMLVideoElement::videoHeight() const
 {
     if (!m_player)
         return 0;
-    return m_player->naturalSize().height();
+    if (m_player->mediaObject()->hasVideo())
+        return m_player->videoWidget()->sizeHint().height();
+    else
+        return 0;
 }
 
 int HTMLVideoElement::width() const
Index: khtml/html/HTMLMediaElement.cpp
===================================================================
--- khtml/html/HTMLMediaElement.cpp	(revision 977361)
+++ khtml/html/HTMLMediaElement.cpp	(working copy)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2009 Michael Howell <mhowell123@gmail.com>.
+ * Parts copyright (C) 2007, 2008 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -28,9 +29,14 @@
 #include "HTMLMediaElement.h"
 #include "HTMLDocument.h"
 #include <misc/htmlhashes.h>
-#include <rendering/render_object.h>
 #include "MediaError.h"
 #include "TimeRanges.h"
+#include "css/cssstyleselector.h"
+#include "css/cssproperties.h"
+#include "css/cssvalues.h"
+#include "css/csshelper.h"
+#include <phonon/mediaobject.h>
+#include <rendering/RenderMedia.h>
 
 const double doubleMax = 999999999.8; // ### numeric_limits<double>::max()
 const double doubleInf = 999999999.0; // ### numeric_limits<double>::infinity()
@@ -57,12 +63,37 @@
     , m_previousProgressTime(doubleMax)
     , m_sentStalledEvent(false)
     , m_bufferingRate(0)
-    , m_player(0)
+    , m_player(new MediaPlayer())
 {
 }
 
+void HTMLMediaElement::attach()
+{
+    assert(!attached());
+    assert(!m_render);
+    assert(parentNode());
+
+    RenderStyle* _style = document()->styleSelector()->styleForElement(this);
+    _style->ref();
+    if (parentNode()->renderer() && parentNode()->renderer()->childAllowed() &&
+        _style->display() != NONE)
+    {
+        m_render = new (document()->renderArena()) RenderMedia(this);
+        static_cast<RenderMedia*>(m_render)->setPlayer(m_player.data());
+        m_render->setStyle(_style);
+        parentNode()->renderer()->addChild(m_render, nextRenderer());
+    }
+    _style->deref();
+
+    NodeBaseImpl::attach();
+    if (m_render)
+        m_render->updateFromElement();
+    setRenderer(m_render);
+}
+
 HTMLMediaElement::~HTMLMediaElement()
 {
+    if (m_player) m_player->deleteLater();
 }
 
 void HTMLMediaElement::attributeChanged(NodeImpl::Id attrId)
@@ -75,10 +106,10 @@
         if (inDocument() && m_networkState == EMPTY)
             scheduleLoad();
     } if (attrId == ATTR_CONTROLS) {
-        if (!isVideo() && attached() && (controls() != (renderer() != 0))) {
+        /*if (!isVideo() && attached() && (controls() != (renderer() != 0))) {
             detach();
             attach();
-        }
+        }*/
         if (renderer())
             renderer()->updateFromElement();
     }
@@ -86,7 +117,7 @@
 
 void HTMLMediaElement::scheduleLoad()
 {
-    // ###
+    kDebug() << "not implemented";
 }
 
 String serializeTimeOffset(float time)
@@ -204,7 +235,7 @@
 
 float HTMLMediaElement::duration() const
 {
-    return m_player ? m_player->duration() : 0;
+    return m_player ? m_player->totalTime() : 0;
 }
 
 bool HTMLMediaElement::paused() const
@@ -231,11 +262,13 @@
 
 float HTMLMediaElement::playbackRate() const
 {
-    return m_player ? m_player->rate() : 0;
+    return 0; // stub...
 }
 
 void HTMLMediaElement::setPlaybackRate(float rate, ExceptionCode& ec)
 {
+    // stub
+    #if 0
     if (rate == 0.0f) {
         ec = DOMException::NOT_SUPPORTED_ERR;
         return;
@@ -244,6 +277,7 @@
         m_player->setRate(rate);
         // ### dispatchEventAsync(ratechangeEvent);
     }
+    #endif
 }
 
 bool HTMLMediaElement::ended() const
@@ -430,9 +464,12 @@
 PassRefPtr<TimeRanges> HTMLMediaElement::buffered() const
 {
     // FIXME real ranges support
+    #if 0
     if (!m_player || !m_player->maxTimeBuffered())
         return new TimeRanges;
     return new TimeRanges(0, m_player->maxTimeBuffered());
+    #endif
+    return new TimeRanges(0, 0.0f); // stub
 }
 
 PassRefPtr<TimeRanges> HTMLMediaElement::played() const
@@ -443,10 +480,13 @@
 
 PassRefPtr<TimeRanges> HTMLMediaElement::seekable() const
 {
+    #if 0
     // FIXME real ranges support
     if (!m_player || !m_player->maxTimeSeekable())
         return new TimeRanges;
     return new TimeRanges(0, m_player->maxTimeSeekable());
+    #endif
+    return new TimeRanges(0, 0.0f); // stub
 }
 
 bool HTMLMediaElement::endedPlayback() const
@@ -454,7 +494,7 @@
 #if 0
     return networkState() >= LOADED_METADATA && currentTime() >= effectiveEnd() && \
currentLoop() == playCount() - 1;  #endif
-    return false;
+    return m_player->mediaObject()->remainingTime() == 0;
 }
 
 void HTMLMediaElement::updateVolume()
Index: khtml/html/HTMLVideoElement.h
===================================================================
--- khtml/html/HTMLVideoElement.h	(revision 977361)
+++ khtml/html/HTMLVideoElement.h	(working copy)
@@ -26,6 +26,8 @@
 #ifndef HTMLVideoElement_h
 #define HTMLVideoElement_h
 
+#include <phonon/mediaobject.h>
+#include <phonon/videowidget.h>
 #include "HTMLMediaElement.h"
 
 namespace khtml {
Index: khtml/html/HTMLMediaElement.h
===================================================================
--- khtml/html/HTMLMediaElement.h	(revision 977361)
+++ khtml/html/HTMLMediaElement.h	(working copy)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2009 Michael Howell <mhowell123@gmail.com>.
+ * Parts copyright (C) 2007, 2008 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -28,37 +29,28 @@
 
 #include "HTMLElement.h"
 #include "ExceptionCode.h"
-#include <wtf/OwnPtr.h>
 #include <wtf/PassRefPtr.h>
+#include <QPointer>
 
 namespace khtml {
 
 class MediaError;
 class TimeRanges;
+class RenderMedia;
+class MediaPlayer;
 
-// dummy
-class MediaPlayer
-{
-public:
-    QRect naturalSize() const { return QRect(); }
-    float duration() const { return 0; }
-    float rate() const { return 0; }
-    void setRate(float) { }
-    void setVolume(float) { }
-    float currentTime() const { return 0; }
-    float maxTimeSeekable() {  return 0; }
-    float maxTimeBuffered() {  return 0; }
-};
-
 class HTMLMediaElement : public HTMLElement {
 public:
     HTMLMediaElement(Document*);
     virtual ~HTMLMediaElement();
 
+    virtual void attach();
+
+//    virtual void parseAttribute(AttributeImpl *token);
     virtual void attributeChanged(NodeImpl::Id attrId);
 
     virtual bool isVideo() const { return false; }
-    
+
     void scheduleLoad();
 
 // DOM API
@@ -160,7 +152,7 @@
     
     float m_bufferingRate;
 
-    OwnPtr<MediaPlayer> m_player;
+    QPointer<MediaPlayer> m_player;
 };
 
 } //namespace
Index: khtml/rendering/MediaControls.h
===================================================================
--- khtml/rendering/MediaControls.h	(revision 0)
+++ khtml/rendering/MediaControls.h	(revision 0)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2009 Michael Howell <mhowell123@gmail.com>.
+ * Parts copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef MediaControls_h
+#define MediaControls_h
+
+#include <phonon/mediaobject.h>
+#include <QWidget>
+#include <QtGui/QPushButton>
+
+namespace khtml {
+
+class MediaControls : public QWidget {
+Q_OBJECT
+public:
+    MediaControls(Phonon::MediaObject* mobject, QWidget* parent = 0);
+
+private Q_SLOTS:
+    void slotStateChanged(Phonon::State state);
+
+private:
+    QPushButton* m_play;
+    QPushButton* m_pause;
+};
+
+} //namespace
+
+#endif
Index: khtml/rendering/RenderMedia.h
===================================================================
--- khtml/rendering/RenderMedia.h	(revision 0)
+++ khtml/rendering/RenderMedia.h	(revision 0)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2009 Michael Howell <mhowell123@gmail.com>.
+ * Parts copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef RenderMedia_h
+#define RenderMedia_h
+
+#include <phonon/videoplayer.h>
+#include <rendering/render_replaced.h>
+#include <html/HTMLMediaElement.h>
+
+namespace khtml {
+
+class MediaPlayer : public Phonon::VideoPlayer, public KHTMLWidget {
+Q_OBJECT
+public:
+    inline MediaPlayer(Phonon::Category category, QWidget *parent = 0) : \
Phonon::VideoPlayer(category, parent) +    {
+        m_kwp->setIsRedirected(true);
+    }
+    inline explicit MediaPlayer(QWidget* parent = 0) : Phonon::VideoPlayer(parent) \
{}; +};
+
+class RenderMedia : public RenderWidget {
+Q_OBJECT
+public:
+    virtual const char *renderName() const { return "RenderMedia"; }
+    virtual bool isMedia() const { return true; }
+
+    void setPlayer(MediaPlayer* player);
+    MediaPlayer* player() { return m_player; }
+    const MediaPlayer* player() const { return m_player; }
+    HTMLMediaElement* mediaElement() { return \
static_cast<HTMLMediaElement*>(RenderWidget::element()); } +    const \
HTMLMediaElement* mediaElement() const { return static_cast<const \
HTMLMediaElement*>(RenderWidget::element()); } +
+protected:
+    bool eventFilter(QObject*, QEvent*);
+
+private Q_SLOTS:
+    void slotMetaDataChanged();
+
+private:
+    RenderMedia(HTMLMediaElement* element);
+    void layout();
+    void updateFromElement();
+    MediaPlayer* m_player;
+    friend class HTMLMediaElement;
+};
+
+} //namespace
+
+#endif
Index: khtml/rendering/MediaControls.cpp
===================================================================
--- khtml/rendering/MediaControls.cpp	(revision 0)
+++ khtml/rendering/MediaControls.cpp	(revision 0)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2009 Michael Howell <mhowell123@gmail.com>.
+ * Parts copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "MediaControls.h"
+#include <QtGui/QHBoxLayout>
+#include <phonon/seekslider.h>
+#include <KDE/KIcon>
+
+namespace khtml {
+
+MediaControls::MediaControls(Phonon::MediaObject* mediaObject, QWidget* parent) : \
QWidget(parent) +{
+    setLayout(new QHBoxLayout(this));
+    m_play = new QPushButton(KIcon("media-playback-start"), "Play", this);
+    connect(m_play, SIGNAL(clicked()), mediaObject, SLOT(play()));
+    layout()->addWidget(m_play);
+    m_pause = new QPushButton(KIcon("media-playback-pause"), "Pause", this);
+    connect(m_pause, SIGNAL(clicked()), mediaObject, SLOT(pause()));
+    layout()->addWidget(m_pause);
+    layout()->addWidget(new Phonon::SeekSlider(mediaObject, this));
+
+    slotStateChanged(mediaObject->state());
+    connect(mediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), \
SLOT(slotStateChanged(Phonon::State))); +}
+
+void MediaControls::slotStateChanged(Phonon::State state)
+{
+    if (state == Phonon::PlayingState) {
+        m_play->hide();
+	m_pause->show();
+    } else {
+        m_pause->hide();
+	m_play->show();
+    }
+}
+
+}
+
Index: khtml/rendering/render_object.h
===================================================================
--- khtml/rendering/render_object.h	(revision 977361)
+++ khtml/rendering/render_object.h	(working copy)
@@ -294,6 +294,7 @@
     virtual bool isFormElement() const { return false; }
     virtual bool isFrameSet() const { return false; }
     virtual bool isApplet() const { return false; }
+    virtual bool isMedia() const { return false; }
 
     virtual bool isEditable() const;
 
Index: khtml/rendering/RenderMedia.cpp
===================================================================
--- khtml/rendering/RenderMedia.cpp	(revision 0)
+++ khtml/rendering/RenderMedia.cpp	(revision 0)
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2009 Michael Howell <mhowell123@gmail.com>.
+ * Parts copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "RenderMedia.h"
+#include "MediaControls.h"
+#include <phonon/mediaobject.h>
+#include <phonon/videowidget.h>
+#include <QtGui/QVBoxLayout>
+
+const double doubleMax = 999999999.8; // ### numeric_limits<double>::max()
+const double doubleInf = 999999999.0; // ### numeric_limits<double>::infinity()
+
+using namespace DOM;
+
+namespace khtml {
+
+RenderMedia::RenderMedia(HTMLMediaElement* element) : RenderWidget(element), \
m_player(0) +{
+    setInline(true); // <video> is an inline element.
+    QWidget* container = new QWidget();
+    container->setLayout(new QVBoxLayout(container));
+    setQWidget(container);
+}
+
+void RenderMedia::setPlayer(MediaPlayer* player)
+{
+    if (m_player == player) return;
+    if (m_player) m_player->deleteLater();
+    m_player = player;
+    connect(player->mediaObject(), SIGNAL(metaDataChanged()), \
SLOT(slotMetaDataChanged())); +    player->setParent(widget());
+    widget()->layout()->addWidget(player);
+}
+
+void RenderMedia::layout()
+{
+    RenderWidget::layout();
+
+    if (mediaElement()->controls() && widget()->layout()->count() == 1) {
+        MediaControls* toolbox = new MediaControls(player()->mediaObject(), \
widget()); +	widget()->layout()->addWidget(toolbox);
+	if ((!widget()->underMouse()) && mediaElement()->isVideo())
+	    toolbox->hide();
+	else
+	    toolbox->show();
+    }
+
+    QApplication::processEvents();
+
+    if (mediaElement()->isVideo()) {
+	setIntrinsicWidth(player()->videoWidget()->sizeHint().width());
+	setIntrinsicHeight(player()->videoWidget()->sizeHint().height());
+    } else {
+	setIntrinsicWidth(widget()->sizeHint().width());
+	setIntrinsicHeight(widget()->sizeHint().height());
+	player()->hide();
+    }
+    if (intrinsicWidth() != 1) widget()->resize(intrinsicWidth(), \
intrinsicHeight()); +}
+
+bool RenderMedia::eventFilter(QObject* o, QEvent* e)
+{
+    if (widget()->layout()->count() != 1 && mediaElement()->isVideo()) {
+        switch(e->type()) {
+        case QEvent::Enter:
+	case QEvent::FocusIn:
+	    widget()->layout()->itemAt(1)->widget()->show();
+	    break;
+	case QEvent::Leave:
+	case QEvent::FocusOut:
+	    widget()->layout()->itemAt(1)->widget()->hide();
+	    break;
+	default: ;
+        }
+    }
+
+    return RenderWidget::eventFilter(o, e);
+}
+
+void RenderMedia::updateFromElement()
+{
+    RenderWidget::updateFromElement();
+
+    QUrl url = mediaElement()->src().string();
+    if (player()->mediaObject()->currentSource().url() != url) {
+        player()->stop();
+	player()->mediaObject()->setCurrentSource(url);
+        if (mediaElement()->autoplay()) player()->play(url);
+    }
+}
+
+void RenderMedia::slotMetaDataChanged()
+{
+    setNeedsLayout(true);
+    layout();
+}
+
+}
+
Index: khtml/CMakeLists.txt
===================================================================
--- khtml/CMakeLists.txt	(revision 977361)
+++ khtml/CMakeLists.txt	(working copy)
@@ -339,6 +339,8 @@
   ${CMAKE_SOURCE_DIR}/khtml/rendering/enumerate.cpp
   ${CMAKE_SOURCE_DIR}/khtml/rendering/counter_tree.cpp
   ${CMAKE_SOURCE_DIR}/khtml/rendering/render_canvasimage.cpp
+  ${CMAKE_SOURCE_DIR}/khtml/rendering/RenderMedia.cpp
+  ${CMAKE_SOURCE_DIR}/khtml/rendering/MediaControls.cpp
 )
 
 # khtml/css/Makefile.am: khtmlcss


["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic