Diff
Modified: trunk/LayoutTests/ChangeLog (102470 => 102471)
--- trunk/LayoutTests/ChangeLog 2011-12-09 21:25:50 UTC (rev 102470)
+++ trunk/LayoutTests/ChangeLog 2011-12-09 21:32:02 UTC (rev 102471)
@@ -1,3 +1,16 @@
+2011-12-09 Eric Carlson <[email protected]>
+
+ JSC wrappers for TextTrack and TextTrackCue should not be collected during event dispatch or when owner is reachable
+ https://bugs.webkit.org/show_bug.cgi?id=72179
+
+ Reviewed by Geoff Garen.
+
+ * media/track/text-track-cue-is-reachable-expected.txt: Added.
+ * media/track/text-track-cue-is-reachable.html: Added.
+ * media/track/text-track-is-reachable-expected.txt: Added.
+ * media/track/text-track-is-reachable.html: Added.
+ * platform/chromium/test_expectations.txt:
+
2011-12-09 Chris Fleizach <[email protected]>
WebKit should ignore images with @alt matching only whitespace
Added: trunk/LayoutTests/media/track/text-track-cue-is-reachable-expected.txt (0 => 102471)
--- trunk/LayoutTests/media/track/text-track-cue-is-reachable-expected.txt (rev 0)
+++ trunk/LayoutTests/media/track/text-track-cue-is-reachable-expected.txt 2011-12-09 21:32:02 UTC (rev 102471)
@@ -0,0 +1,16 @@
+Ensure that a TextTrackCue won't be collected if it has a custom property.
+
+** Validate.
+EXPECTED (video.textTracks[0].cues.length == '4') OK
+EXPECTED (video.textTracks[0].cues[1].startTime == '31') OK
+
+** Add a custom property to a cue.
+RUN(video.textTracks[0].cues[1].myProperty = 'tuna salad?')
+EXPECTED (video.textTracks[0].cues[1].myProperty == 'tuna salad?') OK
+
+** Force garbage collection.
+EXPECTED (video.textTracks[0].cues.length == '4') OK
+EXPECTED (video.textTracks[0].cues[1].myProperty == 'tuna salad?') OK
+
+END OF TEST
+
Added: trunk/LayoutTests/media/track/text-track-cue-is-reachable.html (0 => 102471)
--- trunk/LayoutTests/media/track/text-track-cue-is-reachable.html (rev 0)
+++ trunk/LayoutTests/media/track/text-track-cue-is-reachable.html 2011-12-09 21:32:02 UTC (rev 102471)
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+ <script src=""
+ <script>
+
+ function forceGC()
+ {
+ if (window.GCController)
+ return GCController.collect();
+
+ // Force garbage collection
+ for (var ndx = 0; ndx < 99000; ndx++)
+ var str = new String("1234");
+ }
+
+ function trackLoaded()
+ {
+ findMediaElement();
+
+ consoleWrite("** Validate.");
+ testExpected("video.textTracks[0].cues.length", 4);
+ testExpected("video.textTracks[0].cues[1].startTime", 31);
+
+ consoleWrite("<br>** Add a custom property to a cue.");
+ run("video.textTracks[0].cues[1].myProperty = 'tuna salad?'");
+ testExpected("video.textTracks[0].cues[1].myProperty", "tuna salad?");
+
+ consoleWrite("<br>** Force garbage collection.");
+ forceGC();
+ testExpected("video.textTracks[0].cues.length", 4);
+ testExpected("video.textTracks[0].cues[1].myProperty", "tuna salad?");
+
+ consoleWrite("");
+ endTest();
+ }
+
+ </script>
+ </head>
+ <body>
+ <p>Ensure that a TextTrackCue won't be collected if it has a custom property.</p>
+ <video>
+ <track src="" kind="captions" _onload_="trackLoaded()" default>
+ </video>
+ </body>
+</html>
Added: trunk/LayoutTests/media/track/text-track-is-reachable-expected.txt (0 => 102471)
--- trunk/LayoutTests/media/track/text-track-is-reachable-expected.txt (rev 0)
+++ trunk/LayoutTests/media/track/text-track-is-reachable-expected.txt 2011-12-09 21:32:02 UTC (rev 102471)
@@ -0,0 +1,16 @@
+Ensure that a TextTrack won't be collected if it has a custom property.
+
+** Validate.
+EXPECTED (video.textTracks.length == '1') OK
+EXPECTED (video.textTracks[0].kind == 'captions') OK
+
+** Add a custom property to the track.
+RUN(video.textTracks[0].myProperty = 'egg salad!?')
+EXPECTED (video.textTracks[0].myProperty == 'egg salad!?') OK
+
+** Force garbage collection.
+EXPECTED (video.textTracks[0].cues.length == '4') OK
+EXPECTED (video.textTracks[0].myProperty == 'egg salad!?') OK
+
+END OF TEST
+
Added: trunk/LayoutTests/media/track/text-track-is-reachable.html (0 => 102471)
--- trunk/LayoutTests/media/track/text-track-is-reachable.html (rev 0)
+++ trunk/LayoutTests/media/track/text-track-is-reachable.html 2011-12-09 21:32:02 UTC (rev 102471)
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+ <script src=""
+ <script src=""
+ <script>
+
+ function forceGC()
+ {
+ if (window.GCController)
+ return GCController.collect();
+
+ // Force garbage collection
+ for (var ndx = 0; ndx < 99000; ndx++)
+ var str = new String("1234");
+ }
+
+ function trackLoaded()
+ {
+ findMediaElement();
+
+ consoleWrite("** Validate.");
+ testExpected("video.textTracks.length", 1);
+ testExpected("video.textTracks[0].kind", "captions");
+
+ consoleWrite("<br>** Add a custom property to the track.");
+ run("video.textTracks[0].myProperty = 'egg salad!?'");
+ testExpected("video.textTracks[0].myProperty", "egg salad!?");
+
+ consoleWrite("<br>** Force garbage collection.");
+ forceGC();
+ testExpected("video.textTracks[0].cues.length", 4);
+ testExpected("video.textTracks[0].myProperty", "egg salad!?");
+
+ consoleWrite("");
+ endTest();
+ }
+
+ </script>
+ </head>
+ <body>
+ <p>Ensure that a TextTrack won't be collected if it has a custom property.</p>
+ <video>
+ <track src="" kind="captions" _onload_="trackLoaded()" default>
+ </video>
+ </body>
+</html>
Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (102470 => 102471)
--- trunk/LayoutTests/platform/chromium/test_expectations.txt 2011-12-09 21:25:50 UTC (rev 102470)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt 2011-12-09 21:32:02 UTC (rev 102471)
@@ -3676,7 +3676,9 @@
BUG_TONY MAC : css3/flexbox/repaint.html = PASS FAIL
BUG_TONY MAC : css3/flexbox/repaint-rtl-column.html = PASS FAIL
-BUGWK72149 : media/track/tracklist-is-reachable.html = TEXT
+BUGWK73865 : media/track/tracklist-is-reachable.html = TEXT
+BUGWK73865 : media/track/text-track-cue-is-reachable.html = TEXT
+BUGWK73865 : media/track/text-track-is-reachable.html = TEXT
BUGWK72133 SKIP MAC : http/tests/inspector-enabled/dedicated-workers-list.html = PASS TIMEOUT
Modified: trunk/Source/WebCore/ChangeLog (102470 => 102471)
--- trunk/Source/WebCore/ChangeLog 2011-12-09 21:25:50 UTC (rev 102470)
+++ trunk/Source/WebCore/ChangeLog 2011-12-09 21:32:02 UTC (rev 102471)
@@ -1,3 +1,54 @@
+2011-12-09 Eric Carlson <[email protected]>
+
+ JSC wrappers for TextTrack and TextTrackCue should not be collected during event dispatch or when owner is reachable
+ https://bugs.webkit.org/show_bug.cgi?id=72179
+
+ Reviewed by Geoff Garen.
+
+ Tests: media/track/text-track-cue-is-reachable.html
+ media/track/text-track-is-reachable.html
+
+ * GNUmakefile.list.am: Add JSTextTrackCueCustom.cpp and JSTextTrackCustom.cpp.
+ * Target.pri: Ditto.
+ * WebCore.gypi: Ditto.
+ * WebCore.xcodeproj/project.pbxproj: Ditto
+ * bindings/js/JSBindingsAllInOne.cpp: Ditto.
+
+ * bindings/js/JSTextTrackCueCustom.cpp: Added.
+ (WebCore::JSTextTrackCueOwner::isReachableFromOpaqueRoots): New.
+ (WebCore::JSTextTrackCueOwner::visitChildren): New.
+
+ * bindings/js/JSTextTrackCustom.cpp: Added.
+ (WebCore::JSTextTrackOwner::isReachableFromOpaqueRoots): New.
+ (WebCore::JSTextTrack::visitChildren): New, mark all cues.
+ * bindings/js/JSTextTrackCustom.h: Added.
+ (WebCore::root): New.
+
+ * bindings/js/JSTextTrackListCustom.cpp:
+ (WebCore::JSTextTrackList::visitChildren): New, mark all tracks.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::trackWillBeRemoved): TextTracks::remove now takes a TextTrack*.
+
+ * html/LoadableTextTrack.h:
+ (WebCore::LoadableTextTrack::trackElement): New, return the <track>.
+
+ * html/TextTrack.cpp:
+ (WebCore::TextTrack::TextTrack): Initialize m_mediaElement.
+ * html/TextTrack.h:
+ (WebCore::TextTrack::setMediaElement): New.
+ (WebCore::TextTrack::mediaElement): Ditto.
+
+ * html/TextTrack.idl: Add CustomIsReachable and CustomMarkFunction.
+
+ * html/TextTrackCue.idl: Add CustomIsReachable.
+
+ * html/track/TextTrackList.cpp:
+ (TextTrackList::append): Set track's media element.
+ (TextTrackList::remove): Clear track's media element. Take a raw ptr, not a PassRefPtr.
+ * html/track/TextTrackList.h:
+ * html/track/TextTrackList.idl: Add CustomMarkFunction
+
2011-12-09 Chris Fleizach <[email protected]>
WebKit should ignore images with @alt matching only whitespace
Modified: trunk/Source/WebCore/GNUmakefile.list.am (102470 => 102471)
--- trunk/Source/WebCore/GNUmakefile.list.am 2011-12-09 21:25:50 UTC (rev 102470)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2011-12-09 21:32:02 UTC (rev 102471)
@@ -853,6 +853,9 @@
Source/WebCore/bindings/js/JSStyleSheetCustom.cpp \
Source/WebCore/bindings/js/JSStyleSheetListCustom.cpp \
Source/WebCore/bindings/js/JSTextCustom.cpp \
+ Source/WebCore/bindings/js/JSTextTrackCueCustom.cpp \
+ Source/WebCore/bindings/js/JSTextTrackCustom.cpp \
+ Source/WebCore/bindings/js/JSTextTrackCustom.h \
Source/WebCore/bindings/js/JSTextTrackListCustom.cpp \
Source/WebCore/bindings/js/JSTouchCustom.cpp \
Source/WebCore/bindings/js/JSTouchListCustom.cpp \
Modified: trunk/Source/WebCore/Target.pri (102470 => 102471)
--- trunk/Source/WebCore/Target.pri 2011-12-09 21:25:50 UTC (rev 102470)
+++ trunk/Source/WebCore/Target.pri 2011-12-09 21:32:02 UTC (rev 102471)
@@ -3574,9 +3574,12 @@
bindings/v8/custom/V8TrackEventCustom.cpp
} else {
SOURCES += \
+ bindings/js/JSTextTrackCueCustom.cpp \
+ bindings/js/JSTextTrackCustom.cpp \
+ bindings/js/JSTextTrackCustom.h \
bindings/js/JSTrackCustom.cpp \
bindings/js/JSTrackCustom.h \
- bindings/js/JSTrackEventCustom.cpp
+ bindings/js/JSTrackEventCustom.cpp \
bindings/js/JSTextTrackListCustom.cpp
}
}
Modified: trunk/Source/WebCore/WebCore.gypi (102470 => 102471)
--- trunk/Source/WebCore/WebCore.gypi 2011-12-09 21:25:50 UTC (rev 102470)
+++ trunk/Source/WebCore/WebCore.gypi 2011-12-09 21:32:02 UTC (rev 102471)
@@ -1954,6 +1954,9 @@
'bindings/js/JSStyleSheetCustom.cpp',
'bindings/js/JSStyleSheetListCustom.cpp',
'bindings/js/JSTextCustom.cpp',
+ 'bindings/js/JSTextTrackCueCustom.cpp',
+ 'bindings/js/JSTextTrackCustom.cpp',
+ 'bindings/js/JSTextTrackCustom.h',
'bindings/js/JSTextTrackListCustom.cpp',
'bindings/js/JSTouchCustom.cpp',
'bindings/js/JSTouchListCustom.cpp',
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (102470 => 102471)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-12-09 21:25:50 UTC (rev 102470)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-12-09 21:32:02 UTC (rev 102471)
@@ -116,6 +116,8 @@
07B5A2DC1464320A00A81ECE /* JSTextTrackList.h in Headers */ = {isa = PBXBuildFile; fileRef = 07B5A2DA1464320A00A81ECE /* JSTextTrackList.h */; };
07B5A30D14687D7100A81ECE /* JSTextTrackListCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07B5A30C14687D7100A81ECE /* JSTextTrackListCustom.cpp */; };
07BDD6EC1469B4C2009C9F85 /* JSTrackEventCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07B5A30A14687B8400A81ECE /* JSTrackEventCustom.cpp */; };
+ 07E116B11489C9A100EC5ACE /* JSTextTrackCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07E116B01489C9A100EC5ACE /* JSTextTrackCustom.cpp */; };
+ 07E117071489EBEB00EC5ACE /* JSTextTrackCueCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07E117061489EBEB00EC5ACE /* JSTextTrackCueCustom.cpp */; };
0806E57A12893045007CED32 /* SVGMatrix.h in Headers */ = {isa = PBXBuildFile; fileRef = 0806E57912893045007CED32 /* SVGMatrix.h */; settings = {ATTRIBUTES = (Private, ); }; };
080E49261255F3BD00EFCA27 /* SVGTextLayoutEngineBaseline.h in Headers */ = {isa = PBXBuildFile; fileRef = 080E49221255F3BD00EFCA27 /* SVGTextLayoutEngineBaseline.h */; };
080E49281255F3BD00EFCA27 /* SVGTextLayoutEngineSpacing.h in Headers */ = {isa = PBXBuildFile; fileRef = 080E49241255F3BD00EFCA27 /* SVGTextLayoutEngineSpacing.h */; };
@@ -7169,6 +7171,9 @@
07B5A3061468537100A81ECE /* TextTrackList.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TextTrackList.idl; sourceTree = "<group>"; };
07B5A30A14687B8400A81ECE /* JSTrackEventCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTrackEventCustom.cpp; sourceTree = "<group>"; };
07B5A30C14687D7100A81ECE /* JSTextTrackListCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTextTrackListCustom.cpp; sourceTree = "<group>"; };
+ 07E116B01489C9A100EC5ACE /* JSTextTrackCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTextTrackCustom.cpp; sourceTree = "<group>"; };
+ 07E117061489EBEB00EC5ACE /* JSTextTrackCueCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTextTrackCueCustom.cpp; sourceTree = "<group>"; };
+ 07E38A0B148FCF0C006E1ECC /* JSTextTrackCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTextTrackCustom.h; sourceTree = "<group>"; };
0806E57912893045007CED32 /* SVGMatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGMatrix.h; sourceTree = "<group>"; };
080E49211255F3BD00EFCA27 /* SVGTextLayoutEngineBaseline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGTextLayoutEngineBaseline.cpp; sourceTree = "<group>"; };
080E49221255F3BD00EFCA27 /* SVGTextLayoutEngineBaseline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTextLayoutEngineBaseline.h; sourceTree = "<group>"; };
@@ -19676,6 +19681,7 @@
BC4EDEF70C08F414007EDD49 /* Custom */ = {
isa = PBXGroup;
children = (
+ 07E38A0B148FCF0C006E1ECC /* JSTextTrackCustom.h */,
BC275CB211C5E85C00C9206C /* JSArrayBufferCustom.cpp */,
86243D0011BC31F700CC006A /* JSArrayBufferViewHelper.h */,
BC2ED6BB0C6BD2F000920BFF /* JSAttrCustom.cpp */,
@@ -19786,6 +19792,8 @@
08E4FE450E2BD41400F4CAE0 /* JSSVGLengthCustom.cpp */,
B2C96D8C0B3AF2B7005E80EC /* JSSVGPathSegCustom.cpp */,
1A2C40AA0DEB55AA005AF19E /* JSTextCustom.cpp */,
+ 07E116B01489C9A100EC5ACE /* JSTextTrackCustom.cpp */,
+ 07E117061489EBEB00EC5ACE /* JSTextTrackCueCustom.cpp */,
07B5A30C14687D7100A81ECE /* JSTextTrackListCustom.cpp */,
070334E8145A1F35008D8D45 /* JSTrackCustom.cpp */,
07846384145B1B8E00A58DF1 /* JSTrackCustom.h */,
@@ -27655,6 +27663,8 @@
7AA51DD5148506A900AD2752 /* InspectorMemoryAgent.cpp in Sources */,
5038BF2A14750F190095E0D1 /* FilterOperations.cpp in Sources */,
6E3FAD3814733F4000E42306 /* JSWebGLCompressedTextures.cpp in Sources */,
+ 07E116B11489C9A100EC5ACE /* JSTextTrackCustom.cpp in Sources */,
+ 07E117071489EBEB00EC5ACE /* JSTextTrackCueCustom.cpp in Sources */,
6E3FAE8E14733FDB00E42306 /* WebGLCompressedTextures.cpp in Sources */,
2655413A1489811C000DFC5D /* KeyEventIOS.mm in Sources */,
26F40D4A14904A6300CA67C4 /* EventLoopIOS.mm in Sources */,
Modified: trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp (102470 => 102471)
--- trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp 2011-12-09 21:25:50 UTC (rev 102470)
+++ trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp 2011-12-09 21:32:02 UTC (rev 102471)
@@ -136,6 +136,8 @@
#include "JSStyleSheetCustom.cpp"
#include "JSStyleSheetListCustom.cpp"
#include "JSTextCustom.cpp"
+#include "JSTextTrackCueCustom.cpp"
+#include "JSTextTrackCustom.cpp"
#include "JSTextTrackListCustom.cpp"
#include "JSTouchCustom.cpp"
#include "JSTouchListCustom.cpp"
Added: trunk/Source/WebCore/bindings/js/JSTextTrackCueCustom.cpp (0 => 102471)
--- trunk/Source/WebCore/bindings/js/JSTextTrackCueCustom.cpp (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSTextTrackCueCustom.cpp 2011-12-09 21:32:02 UTC (rev 102471)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2011 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 "config.h"
+
+#if ENABLE(VIDEO_TRACK)
+
+#include "JSTextTrackCue.h"
+#include "JSTextTrackCustom.h"
+
+using namespace JSC;
+
+namespace WebCore {
+
+bool JSTextTrackCueOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
+{
+ JSTextTrackCue* jsTextTrackCue = static_cast<JSTextTrackCue*>(handle.get().asCell());
+ TextTrackCue* textTrackCue = static_cast<TextTrackCue*>(jsTextTrackCue->impl());
+
+ // If the cue is firing event listeners, its wrapper is reachable because
+ // the wrapper is responsible for marking those event listeners.
+ if (textTrackCue->isFiringEventListeners())
+ return true;
+
+ // If the cue has no event listeners and has no custom properties, it is not reachable.
+ if (!textTrackCue->hasEventListeners() && !jsTextTrackCue->hasCustomProperties())
+ return false;
+
+ // If the cue is not associated with a track, it is not reachable.
+ if (!textTrackCue->track())
+ return false;
+
+ return visitor.containsOpaqueRoot(root(textTrackCue->track()));
+}
+
+void JSTextTrackCue::visitChildren(JSCell* cell, SlotVisitor& visitor)
+{
+ JSTextTrackCue* jsTextTrackCue = jsCast<JSTextTrackCue*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(jsTextTrackCue, &s_info);
+ COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
+ ASSERT(jsTextTrackCue->structure()->typeInfo().overridesVisitChildren());
+ Base::visitChildren(jsTextTrackCue, visitor);
+
+ // Mark the cue's track root if it has one.
+ TextTrackCue* textTrackCue = static_cast<TextTrackCue*>(jsTextTrackCue->impl());
+ if (TextTrack* textTrack = textTrackCue->track())
+ visitor.addOpaqueRoot(root(textTrack));
+
+ textTrackCue->visitJSEventListeners(visitor);
+}
+
+} // namespace WebCore
+
+#endif
Added: trunk/Source/WebCore/bindings/js/JSTextTrackCustom.cpp (0 => 102471)
--- trunk/Source/WebCore/bindings/js/JSTextTrackCustom.cpp (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSTextTrackCustom.cpp 2011-12-09 21:32:02 UTC (rev 102471)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2011 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 "config.h"
+
+#if ENABLE(VIDEO_TRACK)
+#include "JSTextTrackCustom.h"
+
+#include "JSTextTrack.h"
+#include "JSTextTrackCueList.h"
+
+using namespace JSC;
+
+namespace WebCore {
+
+bool JSTextTrackOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
+{
+ JSTextTrack* jsTextTrack = static_cast<JSTextTrack*>(handle.get().asCell());
+ TextTrack* textTrack = static_cast<TextTrack*>(jsTextTrack->impl());
+
+ // If the cue is firing event listeners, its wrapper is reachable because
+ // the wrapper is responsible for marking those event listeners.
+ if (textTrack->isFiringEventListeners())
+ return true;
+
+ // If the cue has no event listeners and has no custom properties, it is not reachable.
+ if (!textTrack->hasEventListeners() && !jsTextTrack->hasCustomProperties())
+ return false;
+
+ return visitor.containsOpaqueRoot(root(textTrack));
+}
+
+void JSTextTrack::visitChildren(JSCell* cell, SlotVisitor& visitor)
+{
+ JSTextTrack* jsTextTrack = jsCast<JSTextTrack*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(jsTextTrack, &s_info);
+ COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
+ ASSERT(jsTextTrack->structure()->typeInfo().overridesVisitChildren());
+ Base::visitChildren(jsTextTrack, visitor);
+
+ TextTrack* textTrack = static_cast<TextTrack*>(jsTextTrack->impl());
+ visitor.addOpaqueRoot(root(textTrack));
+
+ textTrack->visitJSEventListeners(visitor);
+}
+
+} // namespace WebCore
+
+#endif
Added: trunk/Source/WebCore/bindings/js/JSTextTrackCustom.h (0 => 102471)
--- trunk/Source/WebCore/bindings/js/JSTextTrackCustom.h (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSTextTrackCustom.h 2011-12-09 21:32:02 UTC (rev 102471)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2011 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 JSTextTrackCustom_h
+#define JSTextTrackCustom_h
+
+#if ENABLE(VIDEO_TRACK)
+#include "JSTextTrack.h"
+
+#include "HTMLMediaElement.h"
+#include "HTMLTrackElement.h"
+#include "LoadableTextTrack.h"
+
+using namespace JSC;
+
+namespace WebCore {
+
+inline void* root(TextTrack* track)
+{
+ // If this track corresponds to a <track> element, return that element's root.
+ if (track->trackType() == TextTrack::TrackElement) {
+ if (HTMLTrackElement* trackElement = static_cast<LoadableTextTrack*>(track)->trackElement())
+ return root(trackElement);
+ }
+
+ // No, return the media element's root if it has one.
+ if (track->mediaElement())
+ return root(track->mediaElement());
+
+ // No track element and no media element, return the text track.
+ return track;
+}
+
+}
+
+#endif
+#endif
Modified: trunk/Source/WebCore/bindings/js/JSTextTrackListCustom.cpp (102470 => 102471)
--- trunk/Source/WebCore/bindings/js/JSTextTrackListCustom.cpp 2011-12-09 21:25:50 UTC (rev 102470)
+++ trunk/Source/WebCore/bindings/js/JSTextTrackListCustom.cpp 2011-12-09 21:32:02 UTC (rev 102471)
@@ -52,6 +52,19 @@
return visitor.containsOpaqueRoot(root(textTrackList->owner()));
}
+void JSTextTrackList::visitChildren(JSCell* cell, SlotVisitor& visitor)
+{
+ JSTextTrackList* jsTextTrackList = jsCast<JSTextTrackList*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(jsTextTrackList, &s_info);
+ COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
+ ASSERT(jsTextTrackList->structure()->typeInfo().overridesVisitChildren());
+ Base::visitChildren(jsTextTrackList, visitor);
+
+ TextTrackList* textTrackList = static_cast<TextTrackList*>(jsTextTrackList->impl());
+ visitor.addOpaqueRoot(root(textTrackList->owner()));
+ textTrackList->visitJSEventListeners(visitor);
+}
+
} // namespace WebCore
#endif
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (102470 => 102471)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2011-12-09 21:25:50 UTC (rev 102470)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2011-12-09 21:32:02 UTC (rev 102471)
@@ -2208,7 +2208,7 @@
// When a track element's parent element changes and the old parent was a media element,
// then the user agent must remove the track element's corresponding text track from the
// media element's list of text tracks.
- m_textTracks->remove(textTrack);
+ m_textTracks->remove(textTrack.get());
}
#endif
Modified: trunk/Source/WebCore/html/LoadableTextTrack.h (102470 => 102471)
--- trunk/Source/WebCore/html/LoadableTextTrack.h 2011-12-09 21:25:50 UTC (rev 102470)
+++ trunk/Source/WebCore/html/LoadableTextTrack.h 2011-12-09 21:32:02 UTC (rev 102471)
@@ -59,6 +59,7 @@
virtual void clearClient();
size_t trackElementIndex();
+ HTMLTrackElement* trackElement() { return m_trackElement; }
private:
// TextTrackLoaderClient
Modified: trunk/Source/WebCore/html/TextTrack.cpp (102470 => 102471)
--- trunk/Source/WebCore/html/TextTrack.cpp 2011-12-09 21:25:50 UTC (rev 102470)
+++ trunk/Source/WebCore/html/TextTrack.cpp 2011-12-09 21:32:02 UTC (rev 102471)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2011 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
@@ -73,6 +74,7 @@
TextTrack::TextTrack(ScriptExecutionContext* context, TextTrackClient* client, const String& kind, const String& label, const String& language, TextTrackType type)
: TrackBase(context, TrackBase::TextTrack)
+ , m_mediaElement(0)
, m_label(label)
, m_language(language)
, m_mode(TextTrack::HIDDEN)
Modified: trunk/Source/WebCore/html/TextTrack.h (102470 => 102471)
--- trunk/Source/WebCore/html/TextTrack.h 2011-12-09 21:25:50 UTC (rev 102470)
+++ trunk/Source/WebCore/html/TextTrack.h 2011-12-09 21:32:02 UTC (rev 102471)
@@ -36,6 +36,7 @@
namespace WebCore {
+class HTMLMediaElement;
class TextTrack;
class TextTrackCue;
class TextTrackCueList;
@@ -58,6 +59,9 @@
return adoptRef(new TextTrack(context, client, kind, label, language, AddTrack));
}
virtual ~TextTrack();
+
+ void setMediaElement(HTMLMediaElement* element) { m_mediaElement = element; }
+ HTMLMediaElement* mediaElement() { return m_mediaElement; }
String kind() const { return m_kind; }
void setKind(const String&);
@@ -104,6 +108,7 @@
RefPtr<TextTrackCueList> m_cues;
private:
+ HTMLMediaElement* m_mediaElement;
String m_kind;
String m_label;
String m_language;
Modified: trunk/Source/WebCore/html/TextTrack.idl (102470 => 102471)
--- trunk/Source/WebCore/html/TextTrack.idl 2011-12-09 21:25:50 UTC (rev 102470)
+++ trunk/Source/WebCore/html/TextTrack.idl 2011-12-09 21:32:02 UTC (rev 102471)
@@ -28,7 +28,9 @@
interface [
Conditional=VIDEO_TRACK,
EnabledAtRuntime=webkitVideoTrack,
- EventTarget
+ EventTarget,
+ CustomMarkFunction,
+ CustomIsReachable
] TextTrack {
readonly attribute DOMString kind;
readonly attribute DOMString label;
Modified: trunk/Source/WebCore/html/TextTrackCue.idl (102470 => 102471)
--- trunk/Source/WebCore/html/TextTrackCue.idl 2011-12-09 21:25:50 UTC (rev 102470)
+++ trunk/Source/WebCore/html/TextTrackCue.idl 2011-12-09 21:32:02 UTC (rev 102471)
@@ -31,7 +31,9 @@
GenerateNativeConverter,
Constructor(in DOMString id, in double startTime, in double endTime, in DOMString text, in [Optional=CallWithDefaultValue] DOMString settings, in [Optional=CallWithDefaultValue] boolean pauseOnExit),
CallWith=ScriptExecutionContext,
- EventTarget
+ EventTarget,
+ CustomMarkFunction,
+ CustomIsReachable
] TextTrackCue {
readonly attribute TextTrack track;
readonly attribute DOMString id;
Modified: trunk/Source/WebCore/html/track/TextTrackList.cpp (102470 => 102471)
--- trunk/Source/WebCore/html/track/TextTrackList.cpp 2011-12-09 21:25:50 UTC (rev 102470)
+++ trunk/Source/WebCore/html/track/TextTrackList.cpp 2011-12-09 21:32:02 UTC (rev 102471)
@@ -74,23 +74,26 @@
return 0;
}
-void TextTrackList::append(PassRefPtr<TextTrack> track)
+void TextTrackList::append(PassRefPtr<TextTrack> prpTrack)
{
- RefPtr<TextTrack> trackRef = track;
+ RefPtr<TextTrack> track = prpTrack;
- if (trackRef->trackType() == TextTrack::AddTrack)
- m_addTrackTracks.append(trackRef);
- else if (trackRef->trackType() == TextTrack::TrackElement) {
+ if (track->trackType() == TextTrack::AddTrack)
+ m_addTrackTracks.append(track);
+ else if (track->trackType() == TextTrack::TrackElement) {
// Insert tracks added for <track> element in tree order.
- size_t index = static_cast<LoadableTextTrack*>(trackRef.get())->trackElementIndex();
- m_elementTracks.insert(index, trackRef);
+ size_t index = static_cast<LoadableTextTrack*>(track.get())->trackElementIndex();
+ m_elementTracks.insert(index, track);
} else
ASSERT_NOT_REACHED();
- scheduleAddTrackEvent(trackRef);
+ ASSERT(!track->mediaElement() || track->mediaElement() == owner());
+ track->setMediaElement(owner());
+
+ scheduleAddTrackEvent(track.release());
}
-void TextTrackList::remove(PassRefPtr<TextTrack> track)
+void TextTrackList::remove(TextTrack* track)
{
Vector<RefPtr<TextTrack> >* tracks = 0;
@@ -104,8 +107,11 @@
size_t index = tracks->find(track);
if (index == notFound)
return;
+
+ ASSERT(track->mediaElement() == owner());
+ track->setMediaElement(0);
+
tracks->remove(index);
-
}
const AtomicString& TextTrackList::interfaceName() const
Modified: trunk/Source/WebCore/html/track/TextTrackList.h (102470 => 102471)
--- trunk/Source/WebCore/html/track/TextTrackList.h 2011-12-09 21:25:50 UTC (rev 102470)
+++ trunk/Source/WebCore/html/track/TextTrackList.h 2011-12-09 21:32:02 UTC (rev 102471)
@@ -53,7 +53,7 @@
unsigned length() const;
TextTrack* item(unsigned index);
void append(PassRefPtr<TextTrack>);
- void remove(PassRefPtr<TextTrack>);
+ void remove(TextTrack*);
// EventTarget
virtual const AtomicString& interfaceName() const;
Modified: trunk/Source/WebCore/html/track/TextTrackList.idl (102470 => 102471)
--- trunk/Source/WebCore/html/track/TextTrackList.idl 2011-12-09 21:25:50 UTC (rev 102470)
+++ trunk/Source/WebCore/html/track/TextTrackList.idl 2011-12-09 21:32:02 UTC (rev 102471)
@@ -30,6 +30,7 @@
EnabledAtRuntime=webkitVideoTrack,
HasIndexGetter,
EventTarget,
+ CustomMarkFunction,
CustomIsReachable
] TextTrackList {
readonly attribute unsigned long length;