mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1032848 - Part 1: Implement WebIDL for HTMLCanvasElement::CaptureStream. r=smaug, r=mt
This commit is contained in:
parent
31920c3587
commit
4b2daa2e73
@ -13,6 +13,7 @@
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Base64.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/dom/CanvasCaptureMediaStream.h"
|
||||
#include "mozilla/dom/CanvasRenderingContext2D.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
#include "mozilla/dom/HTMLCanvasElementBinding.h"
|
||||
@ -405,6 +406,14 @@ HTMLCanvasElement::GetMozPrintCallback() const
|
||||
return mPrintCallback;
|
||||
}
|
||||
|
||||
already_AddRefed<CanvasCaptureMediaStream>
|
||||
HTMLCanvasElement::CaptureStream(const Optional<double>& aFrameRate,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsresult
|
||||
HTMLCanvasElement::ExtractData(nsAString& aType,
|
||||
const nsAString& aOptions,
|
||||
|
@ -29,7 +29,7 @@ class SourceSurface;
|
||||
}
|
||||
|
||||
namespace dom {
|
||||
|
||||
class CanvasCaptureMediaStream;
|
||||
class File;
|
||||
class FileCallback;
|
||||
class HTMLCanvasPrintState;
|
||||
@ -126,6 +126,9 @@ public:
|
||||
PrintCallback* GetMozPrintCallback() const;
|
||||
void SetMozPrintCallback(PrintCallback* aCallback);
|
||||
|
||||
already_AddRefed<CanvasCaptureMediaStream>
|
||||
CaptureStream(const Optional<double>& aFrameRate, ErrorResult& aRv);
|
||||
|
||||
/**
|
||||
* Get the size in pixels of this canvas element
|
||||
*/
|
||||
|
76
dom/media/CanvasCaptureMediaStream.cpp
Normal file
76
dom/media/CanvasCaptureMediaStream.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "CanvasCaptureMediaStream.h"
|
||||
#include "DOMMediaStream.h"
|
||||
#include "ImageContainer.h"
|
||||
#include "MediaStreamGraph.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/dom/CanvasCaptureMediaStreamBinding.h"
|
||||
#include "mozilla/dom/HTMLCanvasElement.h"
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
|
||||
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
|
||||
using namespace mozilla::layers;
|
||||
using namespace mozilla::gfx;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(CanvasCaptureMediaStream, DOMMediaStream,
|
||||
mCanvas)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(CanvasCaptureMediaStream, DOMMediaStream)
|
||||
NS_IMPL_RELEASE_INHERITED(CanvasCaptureMediaStream, DOMMediaStream)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(CanvasCaptureMediaStream)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMMediaStream)
|
||||
|
||||
CanvasCaptureMediaStream::CanvasCaptureMediaStream(HTMLCanvasElement* aCanvas)
|
||||
: mCanvas(aCanvas)
|
||||
{
|
||||
}
|
||||
|
||||
CanvasCaptureMediaStream::~CanvasCaptureMediaStream()
|
||||
{
|
||||
}
|
||||
|
||||
JSObject*
|
||||
CanvasCaptureMediaStream::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return dom::CanvasCaptureMediaStreamBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
void
|
||||
CanvasCaptureMediaStream::RequestFrame()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
CanvasCaptureMediaStream::Init(const dom::Optional<double>& aFPS,
|
||||
const TrackID& aTrackId)
|
||||
{
|
||||
if (!aFPS.WasPassed()) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
} else if (aFPS.Value() < 0) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
already_AddRefed<CanvasCaptureMediaStream>
|
||||
CanvasCaptureMediaStream::CreateSourceStream(nsIDOMWindow* aWindow,
|
||||
HTMLCanvasElement* aCanvas)
|
||||
{
|
||||
nsRefPtr<CanvasCaptureMediaStream> stream = new CanvasCaptureMediaStream(aCanvas);
|
||||
stream->InitSourceStream(aWindow);
|
||||
return stream.forget();
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
48
dom/media/CanvasCaptureMediaStream.h
Normal file
48
dom/media/CanvasCaptureMediaStream.h
Normal file
@ -0,0 +1,48 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_CanvasCaptureMediaStream_h_
|
||||
#define mozilla_dom_CanvasCaptureMediaStream_h_
|
||||
|
||||
namespace mozilla {
|
||||
class DOMMediaStream;
|
||||
|
||||
namespace dom {
|
||||
class HTMLCanvasElement;
|
||||
|
||||
class CanvasCaptureMediaStream: public DOMMediaStream
|
||||
{
|
||||
public:
|
||||
explicit CanvasCaptureMediaStream(HTMLCanvasElement* aCanvas);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CanvasCaptureMediaStream, DOMMediaStream)
|
||||
|
||||
nsresult Init(const dom::Optional<double>& aFPS, const TrackID& aTrackId);
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
// WebIDL
|
||||
HTMLCanvasElement* Canvas() const { return mCanvas; }
|
||||
void RequestFrame();
|
||||
|
||||
/**
|
||||
* Create a CanvasCaptureMediaStream whose underlying stream is a SourceMediaStream.
|
||||
*/
|
||||
static already_AddRefed<CanvasCaptureMediaStream>
|
||||
CreateSourceStream(nsIDOMWindow* aWindow,
|
||||
HTMLCanvasElement* aCanvas);
|
||||
|
||||
protected:
|
||||
~CanvasCaptureMediaStream();
|
||||
|
||||
private:
|
||||
nsRefPtr<HTMLCanvasElement> mCanvas;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* mozilla_dom_CanvasCaptureMediaStream_h_ */
|
@ -14,6 +14,7 @@
|
||||
#include "mozilla/dom/AudioTrackList.h"
|
||||
#include "mozilla/dom/VideoTrack.h"
|
||||
#include "mozilla/dom/VideoTrackList.h"
|
||||
#include "mozilla/dom/HTMLCanvasElement.h"
|
||||
#include "MediaStreamGraph.h"
|
||||
#include "AudioStreamTrack.h"
|
||||
#include "VideoStreamTrack.h"
|
||||
@ -666,3 +667,4 @@ DOMAudioNodeMediaStream::CreateTrackUnionStream(nsIDOMWindow* aWindow,
|
||||
stream->InitTrackUnionStream(aWindow, aGraph);
|
||||
return stream.forget();
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ class MediaStreamGraph;
|
||||
|
||||
namespace dom {
|
||||
class AudioNode;
|
||||
class HTMLCanvasElement;
|
||||
class MediaStreamTrack;
|
||||
class AudioStreamTrack;
|
||||
class VideoStreamTrack;
|
||||
|
@ -175,6 +175,7 @@ EXPORTS.mozilla.dom += [
|
||||
'AudioStreamTrack.h',
|
||||
'AudioTrack.h',
|
||||
'AudioTrackList.h',
|
||||
'CanvasCaptureMediaStream.h',
|
||||
'GetUserMediaRequest.h',
|
||||
'MediaDeviceInfo.h',
|
||||
'MediaDevices.h',
|
||||
@ -202,6 +203,7 @@ UNIFIED_SOURCES += [
|
||||
'AudioStreamTrack.cpp',
|
||||
'AudioTrack.cpp',
|
||||
'AudioTrackList.cpp',
|
||||
'CanvasCaptureMediaStream.cpp',
|
||||
'CubebUtils.cpp',
|
||||
'DOMMediaStream.cpp',
|
||||
'EncodedBufferCache.cpp',
|
||||
|
@ -230,6 +230,8 @@ var interfaceNamesInGlobalScope =
|
||||
{name: "CameraRecorderVideoProfile", b2g: true},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "CameraStateChangeEvent", b2g: true},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "CanvasCaptureMediaStream", disabled: true},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"CanvasGradient",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
|
17
dom/webidl/CanvasCaptureMediaStream.webidl
Normal file
17
dom/webidl/CanvasCaptureMediaStream.webidl
Normal file
@ -0,0 +1,17 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* https://w3c.github.io/mediacapture-fromelement/index.html
|
||||
*
|
||||
* Copyright © 2015 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved.
|
||||
* W3C liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
[Pref="canvas.capturestream.enabled"]
|
||||
interface CanvasCaptureMediaStream : MediaStream {
|
||||
readonly attribute HTMLCanvasElement canvas;
|
||||
void requestFrame();
|
||||
};
|
@ -43,6 +43,9 @@ partial interface HTMLCanvasElement {
|
||||
[ChromeOnly]
|
||||
void mozFetchAsStream(nsIInputStreamCallback callback, optional DOMString? type = null);
|
||||
attribute PrintCallback? mozPrintCallback;
|
||||
|
||||
[Throws, UnsafeInPrerendering, Pref="canvas.capturestream.enabled"]
|
||||
CanvasCaptureMediaStream captureStream(optional double frameRate);
|
||||
};
|
||||
|
||||
[ChromeOnly]
|
||||
|
@ -65,6 +65,7 @@ WEBIDL_FILES = [
|
||||
'CameraControl.webidl',
|
||||
'CameraManager.webidl',
|
||||
'CameraUtil.webidl',
|
||||
'CanvasCaptureMediaStream.webidl',
|
||||
'CanvasRenderingContext2D.webidl',
|
||||
'CaretPosition.webidl',
|
||||
'CDATASection.webidl',
|
||||
|
@ -695,6 +695,8 @@ pref("canvas.hitregions.enabled", false);
|
||||
pref("canvas.filters.enabled", false);
|
||||
// Add support for canvas path objects
|
||||
pref("canvas.path.enabled", true);
|
||||
// captureStream() on canvas disabled by default
|
||||
pref("canvas.capturestream.enabled", false);
|
||||
|
||||
// We want the ability to forcibly disable platform a11y, because
|
||||
// some non-a11y-related components attempt to bring it up. See bug
|
||||
|
Loading…
Reference in New Issue
Block a user