Bug 916643 - ImageCaptureErrorEvent webidl. r=smaug

This commit is contained in:
Alfredo Yang 2014-09-04 02:07:00 +02:00
Родитель 856ee1953a
Коммит 05822696e0
7 изменённых файлов: 157 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,59 @@
/* -*- 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 "mozilla/dom/ImageCaptureError.h"
#include "mozilla/dom/ImageCaptureErrorEventBinding.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(ImageCaptureError, mParent)
NS_IMPL_CYCLE_COLLECTING_ADDREF(ImageCaptureError)
NS_IMPL_CYCLE_COLLECTING_RELEASE(ImageCaptureError)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ImageCaptureError)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
ImageCaptureError::ImageCaptureError(nsISupports* aParent,
uint16_t aCode,
const nsAString& aMessage)
: mParent(aParent)
, mMessage(aMessage)
, mCode(aCode)
{
SetIsDOMBinding();
}
ImageCaptureError::~ImageCaptureError()
{
}
nsISupports*
ImageCaptureError::GetParentObject() const
{
return mParent;
}
JSObject*
ImageCaptureError::WrapObject(JSContext* aCx)
{
return ImageCaptureErrorBinding::Wrap(aCx, this);
}
uint16_t
ImageCaptureError::Code() const
{
return mCode;
}
void
ImageCaptureError::GetMessage(nsAString& retval) const
{
retval = mMessage;
}
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -0,0 +1,58 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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_ImageCaptureError_h
#define mozilla_dom_ImageCaptureError_h
#include "mozilla/Attributes.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsWrapperCache.h"
namespace mozilla {
namespace dom {
/**
* This is the implementation of ImageCaptureError on W3C specification
* https://dvcs.w3.org/hg/dap/raw-file/default/media-stream-capture/ImageCapture.html#idl-def-ImageCaptureError.
* This object should be generated by ImageCapture object only.
*/
class ImageCaptureError MOZ_FINAL : public nsISupports,
public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ImageCaptureError)
ImageCaptureError(nsISupports* aParent, uint16_t aCode, const nsAString& aMessage);
nsISupports* GetParentObject() const;
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
uint16_t Code() const;
enum {
FRAME_GRAB_ERROR = 1,
SETTINGS_ERROR = 2,
PHOTO_ERROR = 3,
ERROR_UNKNOWN = 4,
};
void GetMessage(nsAString& retval) const;
private:
~ImageCaptureError();
nsCOMPtr<nsISupports> mParent;
nsString mMessage;
uint16_t mCode;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_ImageCaptureError_h

Просмотреть файл

@ -44,6 +44,7 @@ EXPORTS.mozilla.dom += [
'Event.h',
'EventTarget.h',
'FocusEvent.h',
'ImageCaptureError.h',
'InputEvent.h',
'KeyboardEvent.h',
'MessageEvent.h',
@ -86,6 +87,7 @@ UNIFIED_SOURCES += [
'EventListenerService.cpp',
'EventTarget.cpp',
'FocusEvent.cpp',
'ImageCaptureError.cpp',
'IMEContentObserver.cpp',
'IMEStateManager.cpp',
'InputEvent.cpp',

Просмотреть файл

@ -195,6 +195,10 @@ const kEventConstructors = {
return new IDBVersionChangeEvent(aName, aProps);
},
},
ImageCaptureErrorEvent: { create: function (aName, aProps) {
return new ImageCaptureErrorEvent(aName, aProps);
},
},
InputEvent: { create: function (aName, aProps) {
return new InputEvent(aName, aProps);
},

Просмотреть файл

@ -595,6 +595,8 @@ var interfaceNamesInGlobalScope =
"IDBVersionChangeEvent",
// IMPORTANT: Do not change this list without review from a DOM peer!
"Image",
// IMPORTANT: Do not change this list without review from a DOM peer!
"ImageCaptureErrorEvent",
// IMPORTANT: Do not change this list without review from a DOM peer!
"ImageData",
// IMPORTANT: Do not change this list without review from a DOM peer!

Просмотреть файл

@ -0,0 +1,31 @@
/* -*- 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://dvcs.w3.org/hg/dap/raw-file/default/media-stream-capture/ImageCapture.html
*
* Copyright © 2012-2014 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved.
* W3C liability, trademark and document use rules apply.
*/
[Constructor(DOMString type, optional ImageCaptureErrorEventInit imageCaptureErrorInitDict)]
interface ImageCaptureErrorEvent : Event {
readonly attribute ImageCaptureError? imageCaptureError;
};
dictionary ImageCaptureErrorEventInit : EventInit {
ImageCaptureError? imageCaptureError = null;
};
[NoInterfaceObject]
interface ImageCaptureError {
const unsigned short FRAME_GRAB_ERROR = 1;
const unsigned short SETTINGS_ERROR = 2;
const unsigned short PHOTO_ERROR = 3;
const unsigned short ERROR_UNKNOWN = 4;
readonly attribute unsigned short code;
readonly attribute DOMString message;
};

Просмотреть файл

@ -652,6 +652,7 @@ GENERATED_EVENTS_WEBIDL_FILES = [
'ErrorEvent.webidl',
'HashChangeEvent.webidl',
'IccChangeEvent.webidl',
'ImageCaptureErrorEvent.webidl',
'MediaStreamEvent.webidl',
'MediaStreamTrackEvent.webidl',
'MozApplicationEvent.webidl',