Commit 6ef994cd authored by Brendan Long's avatar Brendan Long
Browse files

Add TextTrack oncueadd event.

parent f931c1ee
2014-09-23 Brendan Long <b.long@cablelabs.com>
Add TextTrack cueadd event
https://bugs.webkit.org/show_bug.cgi?id=136550
Reviewed by NOBODY (OOPS!).
* media/track/text-track-oncueadd-expected.txt: Added.
* media/track/text-track-oncueadd.html: Added.
2014-09-23 Eduardo Lima Mitev <elima@igalia.com>
 
[GTK] Adds implementation of Subtle Crypto digest algorithms
Tests TextTrack's cueadd event
* Saw cueadd event *
EXPECTED (cue.text == 'Lorem') OK
* Saw cueadd event *
EXPECTED (cue.text == 'ipsum') OK
* Saw cueadd event *
EXPECTED (cue.text == 'dolor') OK
* Saw cueadd event *
EXPECTED (cue.text == 'sit') OK
* Adding cue to track manually *
* Saw cueadd event *
EXPECTED (cue.text == 'Added cue') OK
END OF TEST
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src=../media-file.js></script>
<script src=../video-test.js></script>
<script>
var cue;
var cueNumber = 0;
var expectedCues = [
"Lorem",
"ipsum",
"dolor",
"sit",
"Added cue"
]
function cueAdded(e)
{
consoleWrite("* Saw cueadd event *");
cue = e.cue;
testExpected("cue.text", expectedCues[cueNumber]);
consoleWrite("");
++cueNumber;
if (cueNumber >= expectedCues.length)
endTest();
}
function trackLoaded()
{
consoleWrite("* Adding cue to track manually *");
var testTrack = document.getElementById("testTrack");
var cue = new VTTCue(4, 5, "Added cue");
testTrack.track.addCue(cue);
consoleWrite("");
}
onload = function() {
var video = document.getElementById("testVideo");
video.textTracks.addEventListener("addtrack", function(e) {
e.track.addEventListener("cueadd", cueAdded);
});
};
setCaptionDisplayMode('Automatic');
</script>
</head>
<body>
<p>Tests TextTrack's cueadd event</p>
<video id="testVideo">
<track id="testTrack" src="captions-webvtt/captions.vtt" kind="captions" onload="trackLoaded()" default>
</video>
</body>
</html>
......@@ -2900,6 +2900,7 @@ if (ENABLE_VIDEO_TRACK)
list(APPEND WebCore_IDL_FILES
html/track/AudioTrack.idl
html/track/AudioTrackList.idl
html/track/CueEvent.idl
html/track/DataCue.idl
html/track/TextTrack.idl
html/track/TextTrackCue.idl
......@@ -2915,6 +2916,7 @@ if (ENABLE_VIDEO_TRACK)
html/track/AudioTrack.cpp
html/track/AudioTrackList.cpp
html/track/BufferedLineReader.cpp
html/track/CueEvent.cpp
html/track/DataCue.cpp
html/track/InbandDataTextTrack.cpp
html/track/InbandGenericTextTrack.cpp
......
2014-09-23 Brendan Long <b.long@cablelabs.com>
Add TextTrack cueadd event
https://bugs.webkit.org/show_bug.cgi?id=136550
Reviewed by NOBODY (OOPS!).
Test: media/track/text-track-oncueadd.html
* CMakeLists.txt:
* DerivedSources.cpp:
* bindings/js/JSDictionary.cpp:
(WebCore::JSDictionary::convertValue):
* bindings/js/JSDictionary.h:
* dom/EventNames.h:
* dom/EventNames.in:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::parseAttribute):
* html/track/CueEvent.cpp: Added.
(WebCore::CueEventInit::CueEventInit):
(WebCore::CueEvent::CueEvent):
(WebCore::CueEvent::~CueEvent):
(WebCore::CueEvent::eventInterface):
* html/track/CueEvent.h: Added.
(WebCore::CueEvent::create):
(WebCore::CueEvent::cue):
* html/track/CueEvent.idl: Added.
* html/track/TextTrack.h:
* html/track/TextTrack.idl:
2014-09-23 Eduardo Lima Mitev <elima@igalia.com>
 
[GTK] Adds implementation of Subtle Crypto digest algorithms
......@@ -469,6 +469,7 @@
#if ENABLE(VIDEO_TRACK)
#include "JSAudioTrack.cpp"
#include "JSAudioTrackList.cpp"
#include "JSCueEvent.cpp"
#include "JSDataCue.cpp"
#include "JSHTMLTrackElement.cpp"
#include "JSTextTrack.cpp"
......
......@@ -453,6 +453,7 @@ NON_SVG_BINDING_IDLS = \
$(WebCore)/html/canvas/WebGLVertexArrayObjectOES.idl \
$(WebCore)/html/track/AudioTrack.idl \
$(WebCore)/html/track/AudioTrackList.idl \
$(WebCore)/html/track/CueEvent.idl \
$(WebCore)/html/track/DataCue.idl \
$(WebCore)/html/track/TextTrack.idl \
$(WebCore)/html/track/TextTrackCue.idl \
......
......@@ -16095,6 +16095,7 @@
<ClCompile Include="..\html\shadow\SpinButtonElement.cpp" />
<ClCompile Include="..\html\shadow\TextControlInnerElements.cpp" />
<ClCompile Include="..\html\track\BufferedLineReader.cpp" />
<ClCompile Include="..\html\track\CueEvent.cpp" />
<ClCompile Include="..\html\track\DataCue.cpp" />
<ClCompile Include="..\html\track\InbandDataTextTrack.cpp" />
<ClCompile Include="..\html\track\InbandGenericTextTrack.cpp" />
......@@ -20885,6 +20886,7 @@
<ClInclude Include="..\html\shadow\SpinButtonElement.h" />
<ClInclude Include="..\html\shadow\TextControlInnerElements.h" />
<ClInclude Include="..\html\track\BufferedLineReader.h" />
<ClInclude Include="..\html\track\CueEvent.h" />
<ClInclude Include="..\html\track\DataCue.h" />
<ClInclude Include="..\html\track\InbandDataTextTrack.h" />
<ClInclude Include="..\html\track\InbandGenericTextTrack.h" />
......@@ -4197,6 +4197,9 @@
<ClCompile Include="..\html\track\BufferedLineReader.cpp">
<Filter>html\track</Filter>
</ClCompile>
<ClCompile Include="..\html\track\CueEvent.cpp">
<Filter>html\track</Filter>
</ClCompile>
<ClCompile Include="..\html\track\DataCue.cpp">
<Filter>html\track</Filter>
</ClCompile>
......@@ -11382,6 +11385,9 @@
<ClInclude Include="..\html\track\BufferedLineReader.h">
<Filter>html\track</Filter>
</ClInclude>
<ClInclude Include="..\html\track\CueEvent.h">
<Filter>html\track</Filter>
</ClInclude>
<ClInclude Include="..\html\track\DataCue.h">
<Filter>html\track</Filter>
</ClInclude>
......
......@@ -56,6 +56,10 @@
#include "JSGamepad.h"
#endif
#if ENABLE(VIDEO_TRACK)
#include "JSTextTrackCue.h"
#endif
using namespace JSC;
namespace WebCore {
......@@ -180,6 +184,11 @@ void JSDictionary::convertValue(ExecState* exec, JSValue value, MessagePortArray
}
#if ENABLE(VIDEO_TRACK)
void JSDictionary::convertValue(ExecState*, JSValue value, RefPtr<TextTrackCue>& result)
{
result = JSTextTrackCue::toWrapped(value);
}
void JSDictionary::convertValue(ExecState*, JSValue value, RefPtr<TrackBase>& result)
{
result = toTrack(value);
......
......@@ -53,6 +53,7 @@ class MediaStreamTrack;
class Node;
class SerializedScriptValue;
class Storage;
class TextTrackCue;
class TrackBase;
class VoidCallback;
......@@ -117,6 +118,7 @@ private:
static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<Storage>& result);
static void convertValue(JSC::ExecState*, JSC::JSValue, MessagePortArray& result);
#if ENABLE(VIDEO_TRACK)
static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<TextTrackCue>& result);
static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<TrackBase>& result);
#endif
static void convertValue(JSC::ExecState*, JSC::JSValue, HashSet<AtomicString>& result);
......
......@@ -166,6 +166,7 @@ namespace WebCore {
macro(active) \
macro(inactive) \
macro(addtrack) \
macro(cueadd) \
macro(cuechange) \
macro(enter) \
macro(exit) \
......
......@@ -52,6 +52,7 @@ OrientationEvent interfaceName=Event, conditional=ORIENTATION_EVENTS
MediaKeyEvent conditional=ENCRYPTED_MEDIA
MediaKeyMessageEvent conditional=ENCRYPTED_MEDIA_V2
MediaKeyNeededEvent conditional=ENCRYPTED_MEDIA_V2
CueEvent conditional=VIDEO_TRACK
TrackEvent conditional=VIDEO_TRACK
AutocompleteErrorEvent conditional=REQUEST_AUTOCOMPLETE
CSSFontFaceLoadEvent conditional=FONT_LOAD_EVENTS
......
......@@ -87,6 +87,7 @@
#if ENABLE(VIDEO_TRACK)
#include "AudioTrackList.h"
#include "CueEvent.h"
#include "HTMLTrackElement.h"
#include "InbandGenericTextTrack.h"
#include "InbandTextTrackPrivate.h"
......@@ -1631,6 +1632,15 @@ void HTMLMediaElement::textTrackAddCue(TextTrack* track, PassRefPtr<TextTrackCue
if (!m_cueTree.contains(interval))
m_cueTree.add(interval);
updateActiveTextTrackCues(currentMediaTime());
CueEventInit init;
init.bubbles = false;
init.cancelable = false;
init.cue = cue.release();
RefPtr<CueEvent> cueEvent = CueEvent::create(eventNames().cueaddEvent, init);
cueEvent->setTarget(track);
m_asyncEventQueue.enqueueEvent(cueEvent.release());
}
void HTMLMediaElement::textTrackRemoveCue(TextTrack*, PassRefPtr<TextTrackCue> prpCue)
......
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
* Copyright (C) 2014 Cable Television Labs 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. ``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
* 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 "CueEvent.h"
#include "EventNames.h"
namespace WebCore {
CueEventInit::CueEventInit()
{
}
CueEvent::CueEvent()
{
}
CueEvent::CueEvent(const AtomicString& type, const CueEventInit& initializer)
: Event(type, initializer)
, m_cue(initializer.cue)
{
}
CueEvent::~CueEvent()
{
}
EventInterface CueEvent::eventInterface() const
{
return CueEventInterfaceType;
}
} // namespace WebCore
#endif
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
* Copyright (C) 2014 Cable Television Labs 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. ``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
* 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 CueEvent_h
#define CueEvent_h
#if ENABLE(VIDEO_TRACK)
#include "Event.h"
#include "TextTrackCue.h"
#include <wtf/Vector.h>
namespace WebCore {
struct CueEventInit : public EventInit {
CueEventInit();
RefPtr<TextTrackCue> cue;
};
class CueEvent : public Event {
public:
virtual ~CueEvent();
static PassRefPtr<CueEvent> create()
{
return adoptRef(new CueEvent);
}
static PassRefPtr<CueEvent> create(const AtomicString& type, const CueEventInit& initializer)
{
return adoptRef(new CueEvent(type, initializer));
}
virtual EventInterface eventInterface() const override;
TextTrackCue* cue() const { return m_cue.get(); }
private:
CueEvent();
CueEvent(const AtomicString& type, const CueEventInit& initializer);
RefPtr<TextTrackCue> m_cue;
};
} // namespace WebCore
#endif
#endif
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
* Copyright (C) 2014 Cable Television Labs 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. ``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
* 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.
*/
[
Conditional=VIDEO_TRACK,
ConstructorTemplate=Event
] interface CueEvent : Event {
[InitializedByEventConstructor] readonly attribute TextTrackCue cue;
};
......@@ -123,6 +123,7 @@ public:
void cueWillChange(TextTrackCue*);
void cueDidChange(TextTrackCue*);
DEFINE_ATTRIBUTE_EVENT_LISTENER(cueadd);
DEFINE_ATTRIBUTE_EVENT_LISTENER(cuechange);
enum TextTrackType { TrackElement, AddTrack, InBand };
......
......@@ -47,6 +47,7 @@ enum TextTrackKind { "subtitles", "captions", "descriptions", "chapters", "me
[RaisesException] void addCue(TextTrackCue cue);
[RaisesException] void removeCue(TextTrackCue cue);
attribute EventListener oncueadd;
attribute EventListener oncuechange;
#if defined(ENABLE_WEBVTT_REGIONS) && ENABLE_WEBVTT_REGIONS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment