Allow the text track contents to be displayed externally to WebCore.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Dec 2012 23:23:25 +0000 (23:23 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Dec 2012 23:23:25 +0000 (23:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=105052

Reviewed by Eric Carlson.

Support scenarios where the text track contents must be rendered outside of WebCore, such as to an external
display or window.  Add an abstract base class which encapsulates the external representation to which the
text tracks will be rendered.

Add a new abstract base class and client to wrap the external rendering of a TextTrack.
* platform/graphics/TextTrackRepresentation.h: Added.
(WebCore::TextTrackRepresentationClient::~TextTrackRepresentationClient):
(WebCore::TextTrackRepresentation::~TextTrackRepresentation):

Add an empty concrete implementation for those ports who do not yet support external display of subtitles.
* platform/graphics/TextTrackRepresentation.cpp: Added.
(NullTextTrackRepresentation):
(WebCore::NullTextTrackRepresentation::~NullTextTrackRepresentation):
(WebCore::NullTextTrackRepresentation::update):
(WebCore::NullTextTrackRepresentation::platformLayer):
(WebCore::NullTextTrackRepresentation::setContentScale):
(WebCore::NullTextTrackRepresentation::bounds):
(WebCore::TextTrackRepresentation::create):

Add methods to MediaPlayerPrivateIOS to handle the TextTrackRepresentation.
* platform/graphics/ios/MediaPlayerPrivateIOS.h:
* platform/graphics/ios/MediaPlayerPrivateIOS.mm:
(WebCore::MediaPlayerPrivateIOS::deliverNotification): Remove the representation when exiting full screen.
(WebCore::MediaPlayerPrivateIOS::requiresTextTrackRepresentation): Return YES if in full screen mode.
(WebCore::MediaPlayerPrivateIOS::setTextTrackRepresentation): Pass the representation's layer to the player plug-in.

Expose those methods via HTMLMediaElement:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::requiresTextTrackRepresentation):
(WebCore::HTMLMediaElement::setTextTrackRepresentation):
* html/HTMLMediaElement.h:
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::requiresTextTrackRepresentation):
(WebCore::MediaPlayer::setTextTrackRepresentation):
* platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayerClient::textTrackRepresentationBoundsChanged):
(WebCore::MediaPlayerClient::paintTextTrackRepresentation):
* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::requiresTextTrackRepresentation):
(WebCore::MediaPlayerPrivateInterface::setTextTrackRepresentation):

* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlTextTrackContainerElement::updateDisplay): Create the representation, if necessary.
(WebCore::MediaControlTextTrackContainerElement::updateSizes): Use the representation to determine the font size.
(WebCore::MediaControlTextTrackContainerElement::paintTextTrackRepresentation): Added. Paint the TextTrack into the provided graphics context.
(WebCore::MediaControlTextTrackContainerElement::textTrackRepresentationBoundsChanged): Added. Call updateSizes().
* html/shadow/MediaControlElements.h:

Add the new files to the project.
* WebCore.xcodeproj/project.pbxproj:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:

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

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/shadow/MediaControlElements.cpp
Source/WebCore/html/shadow/MediaControlElements.h
Source/WebCore/platform/graphics/MediaPlayer.cpp
Source/WebCore/platform/graphics/MediaPlayer.h
Source/WebCore/platform/graphics/MediaPlayerPrivate.h
Source/WebCore/platform/graphics/TextTrackRepresentation.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/TextTrackRepresentation.h [new file with mode: 0644]

index f34570f..2c8ba84 100644 (file)
@@ -1,3 +1,65 @@
+2012-12-14  Jer Noble  <jer.noble@apple.com>
+
+        Allow the text track contents to be displayed externally to WebCore.
+        https://bugs.webkit.org/show_bug.cgi?id=105052
+
+        Reviewed by Eric Carlson.
+
+        Support scenarios where the text track contents must be rendered outside of WebCore, such as to an external
+        display or window.  Add an abstract base class which encapsulates the external representation to which the
+        text tracks will be rendered.
+
+        Add a new abstract base class and client to wrap the external rendering of a TextTrack.
+        * platform/graphics/TextTrackRepresentation.h: Added.
+        (WebCore::TextTrackRepresentationClient::~TextTrackRepresentationClient):
+        (WebCore::TextTrackRepresentation::~TextTrackRepresentation):
+
+        Add an empty concrete implementation for those ports who do not yet support external display of subtitles.
+        * platform/graphics/TextTrackRepresentation.cpp: Added.
+        (NullTextTrackRepresentation):
+        (WebCore::NullTextTrackRepresentation::~NullTextTrackRepresentation):
+        (WebCore::NullTextTrackRepresentation::update):
+        (WebCore::NullTextTrackRepresentation::platformLayer):
+        (WebCore::NullTextTrackRepresentation::setContentScale):
+        (WebCore::NullTextTrackRepresentation::bounds):
+        (WebCore::TextTrackRepresentation::create):
+
+        Add methods to MediaPlayerPrivateIOS to handle the TextTrackRepresentation.
+        * platform/graphics/ios/MediaPlayerPrivateIOS.h:
+        * platform/graphics/ios/MediaPlayerPrivateIOS.mm:
+        (WebCore::MediaPlayerPrivateIOS::deliverNotification): Remove the representation when exiting full screen.
+        (WebCore::MediaPlayerPrivateIOS::requiresTextTrackRepresentation): Return YES if in full screen mode.
+        (WebCore::MediaPlayerPrivateIOS::setTextTrackRepresentation): Pass the representation's layer to the player plug-in.
+
+        Expose those methods via HTMLMediaElement:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::requiresTextTrackRepresentation):
+        (WebCore::HTMLMediaElement::setTextTrackRepresentation):
+        * html/HTMLMediaElement.h:
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::requiresTextTrackRepresentation):
+        (WebCore::MediaPlayer::setTextTrackRepresentation):
+        * platform/graphics/MediaPlayer.h:
+        (WebCore::MediaPlayerClient::textTrackRepresentationBoundsChanged):
+        (WebCore::MediaPlayerClient::paintTextTrackRepresentation):
+        * platform/graphics/MediaPlayerPrivate.h:
+        (WebCore::MediaPlayerPrivateInterface::requiresTextTrackRepresentation):
+        (WebCore::MediaPlayerPrivateInterface::setTextTrackRepresentation):
+
+        * html/shadow/MediaControlElements.cpp:
+        (WebCore::MediaControlTextTrackContainerElement::updateDisplay): Create the representation, if necessary.
+        (WebCore::MediaControlTextTrackContainerElement::updateSizes): Use the representation to determine the font size.
+        (WebCore::MediaControlTextTrackContainerElement::paintTextTrackRepresentation): Added. Paint the TextTrack into the provided graphics context.
+        (WebCore::MediaControlTextTrackContainerElement::textTrackRepresentationBoundsChanged): Added. Call updateSizes().
+        * html/shadow/MediaControlElements.h:
+
+        Add the new files to the project.
+        * WebCore.xcodeproj/project.pbxproj:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+
 2012-12-14  Fady Samuel  <fsamuel@chromium.org>
 
         Allow embedder to observe changes to frame names
index 000f36b..705f72c 100644 (file)
@@ -5583,6 +5583,8 @@ webcore_platform_sources += \
        Source/WebCore/platform/graphics/TextRenderingMode.h \
        Source/WebCore/platform/graphics/TextRun.cpp \
        Source/WebCore/platform/graphics/TextRun.h \
+       Source/WebCore/platform/graphics/TextTrackRepresentation.cpp \
+       Source/WebCore/platform/graphics/TextTrackRepresentation.h \
        Source/WebCore/platform/graphics/TiledBacking.h \
        Source/WebCore/platform/graphics/transforms/AffineTransform.cpp \
        Source/WebCore/platform/graphics/transforms/AffineTransform.h \
index e32d75f..dbe8497 100644 (file)
@@ -1007,6 +1007,7 @@ SOURCES += \
     platform/graphics/surfaces/qt/GraphicsSurfaceQt.cpp \
     platform/graphics/SurrogatePairAwareTextIterator.cpp \
     platform/graphics/TextRun.cpp \
+    platform/graphics/TextTrackRepresentation.cpp \
     platform/graphics/TiledBackingStore.cpp \
     platform/graphics/transforms/AffineTransform.cpp \
     platform/graphics/transforms/TransformationMatrix.cpp \
index f6f97a8..ab87bee 100644 (file)
             'platform/graphics/SurrogatePairAwareTextIterator.cpp',
             'platform/graphics/SurrogatePairAwareTextIterator.h',
             'platform/graphics/TextRun.cpp',
+            'platform/graphics/TextTrackRepresentation.cpp',
+            'platform/graphics/TextTrackRepresentation.h',
             'platform/graphics/Tile.h',
             'platform/graphics/TiledBackingStore.cpp',
             'platform/graphics/TiledBackingStore.h',
index f322c89..ca20493 100755 (executable)
                                        >
                                </File>
                                <File
+                                       RelativePath="..\platform\graphics\TextTrackRepresentation.cpp"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\platform\graphics\TextTrackRepresentation.h"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\platform\graphics\UnitBezier.h"
                                        >
                                </File>
index 5fb53ab..745217c 100644 (file)
                CCC2B51615F613060048CDD6 /* DeviceController.h in Headers */ = {isa = PBXBuildFile; fileRef = CCC2B51215F613060048CDD6 /* DeviceController.h */; settings = {ATTRIBUTES = (Private, ); }; };
                CD127DED14F3097D00E84779 /* WebCoreFullScreenWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD127DEB14F3097900E84779 /* WebCoreFullScreenWindow.mm */; };
                CD127DEE14F3098400E84779 /* WebCoreFullScreenWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = CD127DEA14F3097900E84779 /* WebCoreFullScreenWindow.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               CD1E7347167BC78E009A885D /* TextTrackRepresentation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD1E7346167BC78E009A885D /* TextTrackRepresentation.cpp */; };
                CD27F6E51457685A0078207D /* JSMediaController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD27F6E2145767580078207D /* JSMediaController.cpp */; };
                CD27F6E7145770D30078207D /* MediaController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD27F6E6145770D30078207D /* MediaController.cpp */; };
                CD37B39815C1B971006DC898 /* DiagnosticLoggingKeys.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD37B37415C1A7E1006DC898 /* DiagnosticLoggingKeys.cpp */; };
                CCC2B51215F613060048CDD6 /* DeviceController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceController.h; sourceTree = "<group>"; };
                CD127DEA14F3097900E84779 /* WebCoreFullScreenWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreFullScreenWindow.h; sourceTree = "<group>"; };
                CD127DEB14F3097900E84779 /* WebCoreFullScreenWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreFullScreenWindow.mm; sourceTree = "<group>"; };
+               CD1E7346167BC78E009A885D /* TextTrackRepresentation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextTrackRepresentation.cpp; sourceTree = "<group>"; };
                CD27F6E014575C1B0078207D /* MediaController.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MediaController.idl; sourceTree = "<group>"; };
                CD27F6E2145767580078207D /* JSMediaController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaController.cpp; sourceTree = "<group>"; };
                CD27F6E3145767580078207D /* JSMediaController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaController.h; sourceTree = "<group>"; };
                CDC69DD816371FD3007C38DF /* WebCoreFullScreenPlaceholderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreFullScreenPlaceholderView.h; sourceTree = "<group>"; };
                CDC69DD916371FD3007C38DF /* WebCoreFullScreenPlaceholderView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreFullScreenPlaceholderView.mm; sourceTree = "<group>"; };
                CDCE5CD014633BC900D47CCA /* EventTargetFactory.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EventTargetFactory.in; sourceTree = "<group>"; };
+               CDD1E525167BA56400CE820B /* TextTrackRepresentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextTrackRepresentation.h; sourceTree = "<group>"; };
                CDEA762C14608224008B31F1 /* Clock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Clock.h; sourceTree = "<group>"; };
                CDEA762E146084DE008B31F1 /* PlatformClockCA.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformClockCA.cpp; sourceTree = "<group>"; };
                CDEA762F146084EE008B31F1 /* PlatformClockCA.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformClockCA.h; sourceTree = "<group>"; };
                                087E0AF413606D0B00FA4BA8 /* SVGGlyph.cpp */,
                                087E0AF513606D0B00FA4BA8 /* SVGGlyph.h */,
                                930FC6891072B9280045293E /* TextRenderingMode.h */,
+                               CDD1E525167BA56400CE820B /* TextTrackRepresentation.h */,
+                               CD1E7346167BC78E009A885D /* TextTrackRepresentation.cpp */,
                                376DCCE013B4F966002EBEFC /* TextRun.cpp */,
                                A824B4640E2EF2EA0081A7B7 /* TextRun.h */,
                                1AF89A411518FDEA00E547B5 /* TiledBacking.h */,
                                FE456F181677D74E005EDDF9 /* DatabaseManager.cpp in Sources */,
                                FEDEF84116797108000E444A /* DatabaseStrategy.cpp in Sources */,
                                F37A56221679CF7B00C57046 /* HeapGraphSerializer.cpp in Sources */,
+                               CD1E7347167BC78E009A885D /* TextTrackRepresentation.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 5668779..730d295 100644 (file)
@@ -3897,6 +3897,19 @@ bool HTMLMediaElement::willRespondToMouseClickEvents()
 #endif
 }
 
+#if ENABLE(VIDEO_TRACK)
+bool HTMLMediaElement::requiresTextTrackRepresentation() const
+{
+    return m_player ? m_player->requiresTextTrackRepresentation() : 0;
+}
+
+void HTMLMediaElement::setTextTrackRepresentation(TextTrackRepresentation* representation)
+{
+    if (m_player)
+        m_player->setTextTrackRepresentation(representation);
+}
+#endif // ENABLE(VIDEO_TRACK)
+
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
 
 void HTMLMediaElement::ensureMediaPlayer()
index a9db047..4616756 100644 (file)
@@ -264,6 +264,9 @@ public:
     virtual void textTrackRemoveCues(TextTrack*, const TextTrackCueList*);
     virtual void textTrackAddCue(TextTrack*, PassRefPtr<TextTrackCue>);
     virtual void textTrackRemoveCue(TextTrack*, PassRefPtr<TextTrackCue>);
+
+    bool requiresTextTrackRepresentation() const;
+    void setTextTrackRepresentation(TextTrackRepresentation*);
 #endif
 
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
index 82d2b16..cd94ab4 100644 (file)
@@ -37,6 +37,7 @@
 #include "EventTarget.h"
 #include "FloatConversion.h"
 #include "Frame.h"
+#include "GraphicsContext.h"
 #include "HTMLVideoElement.h"
 #include "Language.h"
 #include "LocalizedStrings.h"
 #include "MouseEvent.h"
 #include "Page.h"
 #include "PageGroup.h"
+#include "RenderLayer.h"
 #include "RenderMediaControlElements.h"
 #include "RenderSlider.h"
 #include "RenderTheme.h"
 #include "RenderVideo.h"
+#include "RenderView.h"
 #include "Settings.h"
 #if ENABLE(VIDEO_TRACK)
 #include "TextTrack.h"
@@ -1282,27 +1285,100 @@ void MediaControlTextTrackContainerElement::updateDisplay()
     }
 
     // 11. Return output.
-    hasChildNodes() ? show() : hide();
+    if (hasChildNodes()) {
+        show();
+        if (mediaElement->requiresTextTrackRepresentation()) {
+            if (!m_textTrackRepresentation)
+                m_textTrackRepresentation = TextTrackRepresentation::create(this);
+            mediaElement->setTextTrackRepresentation(m_textTrackRepresentation.get());
+
+            if (Page* page = document()->page())
+                m_textTrackRepresentation->setContentScale(page->deviceScaleFactor());
+
+            m_textTrackRepresentation->update();
+            setInlineStyleProperty(CSSPropertyWidth, String::number(m_videoDisplaySize.size().width()) + "px");
+            setInlineStyleProperty(CSSPropertyHeight, String::number(m_videoDisplaySize.size().height()) + "px");
+        }
+    } else {
+        hide();
+        m_textTrackRepresentation = nullptr;
+        mediaElement->setTextTrackRepresentation(0);
+        removeInlineStyleProperty(CSSPropertyWidth);
+        removeInlineStyleProperty(CSSPropertyHeight);
+    }
 }
 
 void MediaControlTextTrackContainerElement::updateSizes()
 {
     HTMLMediaElement* mediaElement = toParentMediaElement(this);
-    if (!mediaElement || !mediaElement->renderer() || !mediaElement->renderer()->isVideo())
+    if (!mediaElement)
         return;
 
     if (!document()->page())
         return;
 
-    IntRect videoBox = toRenderVideo(mediaElement->renderer())->videoBox();
+    IntRect videoBox;
 
-    float fontSize = videoBox.size().height() * (document()->page()->group().captionFontSizeScale());
+    if (m_textTrackRepresentation)
+        videoBox = m_textTrackRepresentation->bounds();
+    else {
+        if (!mediaElement->renderer() || !mediaElement->renderer()->isVideo())
+            return;
+        videoBox = toRenderVideo(mediaElement->renderer())->videoBox();
+    }
+
+    if (m_videoDisplaySize == videoBox)
+        return;
+    m_videoDisplaySize = videoBox;
+
+    if (m_textTrackRepresentation) {
+        setInlineStyleProperty(CSSPropertyWidth, String::number(m_videoDisplaySize.size().width()) + "px");
+        setInlineStyleProperty(CSSPropertyHeight, String::number(m_videoDisplaySize.size().height()) + "px");
+    }
+
+    float smallestDimension = std::min(m_videoDisplaySize.size().height(), m_videoDisplaySize.size().width());
+
+    float fontSize = smallestDimension * (document()->page()->group().captionFontSizeScale());
     if (fontSize != m_fontSize) {
         m_fontSize = fontSize;
         setInlineStyleProperty(CSSPropertyFontSize, String::number(fontSize) + "px");
     }
 }
 
+void MediaControlTextTrackContainerElement::paintTextTrackRepresentation(GraphicsContext* context, const IntRect& contextRect)
+{
+    if (!hasChildNodes())
+        return;
+
+    RenderObject* renderer = this->renderer();
+    if (!renderer)
+        return;
+
+    Frame* frame = document()->frame();
+    if (!frame)
+        return;
+
+    document()->updateLayout();
+
+    LayoutRect topLevelRect;
+    IntRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLevelRect));
+
+    // Translate the renderer painting rect into graphics context coordinates.
+    FloatSize translation(-paintingRect.x(), -paintingRect.y());
+
+    // But anchor to the bottom of the graphics context rect.
+    translation.expand(max(0, contextRect.width() - paintingRect.width()), max(0, contextRect.height() - paintingRect.height()));
+
+    context->translate(translation);
+
+    RenderLayer* layer = frame->contentRenderer()->layer();
+    layer->paint(context, paintingRect, PaintBehaviorFlattenCompositingLayers, renderer, 0, RenderLayer::PaintLayerPaintingCompositingAllPhases);
+}
+
+void MediaControlTextTrackContainerElement::textTrackRepresentationBoundsChanged(const IntRect&)
+{
+    updateSizes();
+}
 #endif // ENABLE(VIDEO_TRACK)
 
 // ----------------------------
index cb59627..e89f246 100644 (file)
@@ -32,6 +32,7 @@
 
 #if ENABLE(VIDEO)
 #include "MediaControlElementTypes.h"
+#include "TextTrackRepresentation.h"
 
 namespace WebCore {
 
@@ -432,7 +433,7 @@ private:
 
 #if ENABLE(VIDEO_TRACK)
 
-class MediaControlTextTrackContainerElement : public MediaControlDivElement {
+class MediaControlTextTrackContainerElement : public MediaControlDivElement, public TextTrackRepresentationClient {
 public:
     static PassRefPtr<MediaControlTextTrackContainerElement> create(Document*);
 
@@ -446,6 +447,10 @@ private:
 
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
 
+    virtual void paintTextTrackRepresentation(GraphicsContext*, const IntRect&) OVERRIDE;
+    virtual void textTrackRepresentationBoundsChanged(const IntRect&) OVERRIDE;
+    OwnPtr<TextTrackRepresentation> m_textTrackRepresentation;
+
     IntRect m_videoDisplaySize;
     float m_fontSize;
     RefPtr<HTMLElement> m_cueContainer;
index 46cc57e..659a81a 100644 (file)
@@ -1129,6 +1129,16 @@ void MediaPlayer::removeTextTrack(PassRefPtr<InbandTextTrackPrivate> track)
 
     m_mediaPlayerClient->mediaPlayerDidRemoveTrack(track);
 }
+
+bool MediaPlayer::requiresTextTrackRepresentation() const
+{
+    return m_private->requiresTextTrackRepresentation();
+}
+
+void MediaPlayer::setTextTrackRepresentation(TextTrackRepresentation* representation)
+{
+    m_private->setTextTrackRepresentation(representation);
+}
 #endif
 
 }
index b24a848..f8c6183 100644 (file)
@@ -62,6 +62,7 @@ class Document;
 class GStreamerGWorld;
 class MediaPlayerPrivateInterface;
 class MediaSource;
+class TextTrackRepresentation;
 
 // Structure that will hold every native
 // types supported by the current media player.
@@ -213,6 +214,9 @@ public:
 #if ENABLE(VIDEO_TRACK)
     virtual void mediaPlayerDidAddTrack(PassRefPtr<InbandTextTrackPrivate>) { }
     virtual void mediaPlayerDidRemoveTrack(PassRefPtr<InbandTextTrackPrivate>) { }
+
+    virtual void textTrackRepresentationBoundsChanged(const IntRect&) { }
+    virtual void paintTextTrackRepresentation(GraphicsContext*, const IntRect&) { }
 #endif
 };
 
@@ -436,6 +440,9 @@ public:
 #if ENABLE(VIDEO_TRACK)
     void addTextTrack(PassRefPtr<InbandTextTrackPrivate>);
     void removeTextTrack(PassRefPtr<InbandTextTrackPrivate>);
+
+    bool requiresTextTrackRepresentation() const;
+    void setTextTrackRepresentation(TextTrackRepresentation*);
 #endif
 
 private:
index d360149..5c6674d 100644 (file)
@@ -184,6 +184,10 @@ public:
     virtual MediaPlayer::MediaKeyException cancelKeyRequest(const String&, const String&) { return MediaPlayer::KeySystemNotSupported; }
 #endif
 
+#if ENABLE(VIDEO_TRACK)
+    virtual bool requiresTextTrackRepresentation() const { return false; }
+    virtual void setTextTrackRepresentation(TextTrackRepresentation*) { }
+#endif
 };
 
 }
diff --git a/Source/WebCore/platform/graphics/TextTrackRepresentation.cpp b/Source/WebCore/platform/graphics/TextTrackRepresentation.cpp
new file mode 100644 (file)
index 0000000..3c3423b
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2012 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 "config.h"
+
+#if ENABLE(VIDEO_TRACK)
+
+#include "TextTrackRepresentation.h"
+
+namespace WebCore {
+
+class NullTextTrackRepresentation : public TextTrackRepresentation {
+public:
+    virtual ~NullTextTrackRepresentation() { }
+    virtual void update() { }
+    virtual PlatformLayer* platformLayer() { return 0; }
+    virtual void setContentScale(float) { }
+    virtual IntRect bounds() const { return IntRect(); }
+};
+
+PassOwnPtr<TextTrackRepresentation> TextTrackRepresentation::create(TextTrackRepresentationClient*)
+{
+    return WTF::adoptPtr(new NullTextTrackRepresentation());
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/platform/graphics/TextTrackRepresentation.h b/Source/WebCore/platform/graphics/TextTrackRepresentation.h
new file mode 100644 (file)
index 0000000..2a4f527
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2012 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 TextTrackRepresentation_h
+#define TextTrackRepresentation_h
+
+#if ENABLE(VIDEO_TRACK)
+
+#include "IntRect.h"
+#include "PlatformLayer.h"
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+
+class GraphicsContext;
+class IntRect;
+
+class TextTrackRepresentationClient {
+public:
+    virtual ~TextTrackRepresentationClient() { }
+
+    virtual void paintTextTrackRepresentation(GraphicsContext*, const IntRect&) = 0;
+    virtual void textTrackRepresentationBoundsChanged(const IntRect&) = 0;
+};
+
+class TextTrackRepresentation {
+public:
+    static PassOwnPtr<TextTrackRepresentation> create(TextTrackRepresentationClient*);
+
+    virtual ~TextTrackRepresentation() { }
+
+    virtual void update() = 0;
+    virtual PlatformLayer* platformLayer() = 0;
+    virtual void setContentScale(float) = 0;
+    virtual IntRect bounds() const = 0;
+};
+
+}
+
+#endif
+
+#endif // TextTrackRepresentation_h