Support captions when PLUGIN_PROXY_FOR_VIDEO
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Oct 2012 20:01:04 +0000 (20:01 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Oct 2012 20:01:04 +0000 (20:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=100690

Reviewed by Simon Fraser.

When built with PLUGIN_PROXY_FOR_VIDEO, WebCore uses a plug-in for the media element's
platform media engine. Update this code path so the shadow DOM elements used to display
text tracks are created and configured correctly.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::configureMediaControls): Create media controls if necessary.

* rendering/RenderEmbeddedObject.cpp:
(WebCore::RenderEmbeddedObject::layout): Set the position and size of the shadow DOM when the
    position of the embedded element changes.
* rendering/RenderEmbeddedObject.h:

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

Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/rendering/RenderEmbeddedObject.cpp
Source/WebCore/rendering/RenderEmbeddedObject.h

index c5acbfb..edda927 100644 (file)
@@ -1,3 +1,22 @@
+2012-10-29  Eric Carlson  <eric.carlson@apple.com>
+
+        Support captions when PLUGIN_PROXY_FOR_VIDEO
+        https://bugs.webkit.org/show_bug.cgi?id=100690
+
+        Reviewed by Simon Fraser.
+
+        When built with PLUGIN_PROXY_FOR_VIDEO, WebCore uses a plug-in for the media element's
+        platform media engine. Update this code path so the shadow DOM elements used to display
+        text tracks are created and configured correctly.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::configureMediaControls): Create media controls if necessary.
+
+        * rendering/RenderEmbeddedObject.cpp:
+        (WebCore::RenderEmbeddedObject::layout): Set the position and size of the shadow DOM when the
+            position of the embedded element changes.
+        * rendering/RenderEmbeddedObject.h:
+
 2012-10-29  Justin Novosad  <junov@google.com>
 
         [Chromium] flickering observed when copying 2D canvas to webGL texture
index 97fe95b..458eac6 100644 (file)
@@ -4172,6 +4172,9 @@ void HTMLMediaElement::configureMediaControls()
 
     mediaControls()->show();
 #else
+    if (!hasMediaControls())
+        createMediaControls();
+
     if (m_player)
         m_player->setControls(controls());
 #endif
index 1e12c7c..c826eaa 100644 (file)
 #include "Text.h"
 #include "TextRun.h"
 
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+#include "HTMLMediaElement.h"
+#endif
+
 namespace WebCore {
 
 using namespace HTMLNames;
@@ -231,6 +235,10 @@ void RenderEmbeddedObject::layout()
     StackStats::LayoutCheckPoint layoutCheckPoint;
     ASSERT(needsLayout());
 
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    LayoutSize oldSize = contentBoxRect().size();
+#endif
+
     updateLogicalWidth();
     updateLogicalHeight();
 
@@ -245,6 +253,31 @@ void RenderEmbeddedObject::layout()
         frameView()->addWidgetToUpdate(this);
 
     setNeedsLayout(false);
+
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    // This code copied from RenderMedia::layout().
+    RenderBox* controlsRenderer = toRenderBox(m_children.firstChild());
+    if (!controlsRenderer)
+        return;
+    
+    LayoutSize newSize = contentBoxRect().size();
+    if (newSize == oldSize && !controlsRenderer->needsLayout())
+        return;
+    
+    // When calling layout() on a child node, a parent must either push a LayoutStateMaintainter, or
+    // instantiate LayoutStateDisabler. Since using a LayoutStateMaintainer is slightly more efficient,
+    // and this method will be called many times per second during playback, use a LayoutStateMaintainer:
+    LayoutStateMaintainer statePusher(view(), this, locationOffset(), hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode());
+    
+    controlsRenderer->setLocation(LayoutPoint(borderLeft(), borderTop()) + LayoutSize(paddingLeft(), paddingTop()));
+    controlsRenderer->style()->setHeight(Length(newSize.height(), Fixed));
+    controlsRenderer->style()->setWidth(Length(newSize.width(), Fixed));
+    controlsRenderer->setNeedsLayout(true, MarkOnlyThis);
+    controlsRenderer->layout();
+    setChildNeedsLayout(false);
+    
+    statePusher.pop();
+#endif
 }
 
 void RenderEmbeddedObject::viewCleared()
index 95d1317..5317b4c 100644 (file)
@@ -62,6 +62,11 @@ protected:
 
     virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const;
 
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    const RenderObjectChildList* children() const { return &m_children; }
+    RenderObjectChildList* children() { return &m_children; }
+#endif
+
 private:
     virtual const char* renderName() const { return "RenderEmbeddedObject"; }
     virtual bool isEmbeddedObject() const { return true; }
@@ -83,6 +88,12 @@ private:
     bool isInUnavailablePluginIndicator(const LayoutPoint&) const;
     bool getReplacementTextGeometry(const LayoutPoint& accumulatedOffset, FloatRect& contentRect, Path&, FloatRect& replacementTextRect, Font&, TextRun&, float& textWidth) const;
 
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    virtual bool canHaveChildren() const { return node() && toElement(node())->isMediaElement(); }
+    virtual RenderObjectChildList* virtualChildren() { return children(); }
+    virtual const RenderObjectChildList* virtualChildren() const { return children(); }
+#endif
+
     bool m_hasFallbackContent; // FIXME: This belongs on HTMLObjectElement.
 
     bool m_showsUnavailablePluginIndicator;
@@ -90,6 +101,9 @@ private:
     String m_unavailablePluginReplacementText;
     bool m_unavailablePluginIndicatorIsPressed;
     bool m_mouseDownWasInUnavailablePluginIndicator;
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    RenderObjectChildList m_children;
+#endif
 };
 
 inline RenderEmbeddedObject* toRenderEmbeddedObject(RenderObject* object)