Index: Source/bindings/v8/custom/V8TextTrackCueCustom.cpp |
diff --git a/Source/bindings/v8/custom/V8TextTrackCueCustom.cpp b/Source/bindings/v8/custom/V8TextTrackCueCustom.cpp |
index 0ccc04e67607f955b3c68b25add624aa3cb50d8f..905b2f3c91744cc98ad62bb1481e169110beee7e 100644 |
--- a/Source/bindings/v8/custom/V8TextTrackCueCustom.cpp |
+++ b/Source/bindings/v8/custom/V8TextTrackCueCustom.cpp |
@@ -40,4 +40,23 @@ v8::Handle<v8::Value> toV8(TextTrackCue* impl, v8::Handle<v8::Object> creationCo |
return toV8(toVTTCue(impl), creationContext, isolate); |
} |
+// Custom constructor to make new TextTrackCue(...) return a VTTCue. This is legacy |
+// compat, not per spec, and should be removed at the earliest opportunity. |
+void V8TextTrackCue::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info) |
+{ |
+ if (UNLIKELY(info.Length() < 3)) { |
+ throwTypeError(ExceptionMessages::failedToExecute("Constructor", "TextTrackCue", ExceptionMessages::notEnoughArguments(3, info.Length())), info.GetIsolate()); |
+ return; |
+ } |
+ V8TRYCATCH_VOID(double, startTime, static_cast<double>(info[0]->NumberValue())); |
+ V8TRYCATCH_VOID(double, endTime, static_cast<double>(info[1]->NumberValue())); |
+ V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, text, info[2]); |
+ |
+ Document& document = *toDocument(getExecutionContext()); |
+ UseCounter::count(document, UseCounter::TextTrackCueConstructor); |
+ VTTCue* impl = VTTCue::create(document, startTime, endTime, text).leakRef(); |
+ v8::Handle<v8::Object> wrapper = wrap(impl, info.Holder(), info.GetIsolate()); |
+ info.GetReturnValue().Set(wrapper); |
+} |
+ |
} // namespace WebCore |