Bug 826740 - Part f: Move HTMLCanvasElement to Paris bindings; r=khuey

This commit is contained in:
Ms2ger 2013-04-13 09:05:51 +02:00
parent d9c0b6846d
commit ebda306fd2
10 changed files with 80 additions and 20 deletions

View File

@ -1424,7 +1424,7 @@ CanvasRenderingContext2D::CreatePattern(const HTMLImageOrCanvasOrVideoElement& e
Element* htmlElement;
if (element.IsHTMLCanvasElement()) {
HTMLCanvasElement* canvas = element.GetAsHTMLCanvasElement();
HTMLCanvasElement* canvas = &element.GetAsHTMLCanvasElement();
htmlElement = canvas;
nsIntSize size = canvas->GetSize();
@ -2906,7 +2906,7 @@ CanvasRenderingContext2D::DrawImage(const HTMLImageOrCanvasOrVideoElement& image
EnsureTarget();
if (image.IsHTMLCanvasElement()) {
HTMLCanvasElement* canvas = image.GetAsHTMLCanvasElement();
HTMLCanvasElement* canvas = &image.GetAsHTMLCanvasElement();
element = canvas;
nsIntSize size = canvas->GetSize();
if (size.width == 0 || size.height == 0) {

View File

@ -21236,10 +21236,12 @@ window.HTMLCanvasElement.prototype = null;
ok(window.HTMLCanvasElement.prototype, "window.HTMLCanvasElement.prototype");
delete window.HTMLCanvasElement.prototype;
ok(window.HTMLCanvasElement.prototype, "window.HTMLCanvasElement.prototype");
var getContext = window.HTMLCanvasElement.prototype.getContext;
window.HTMLCanvasElement.prototype.getContext = 1;
ok(window.HTMLCanvasElement.prototype.getContext === 1, "window.HTMLCanvasElement.prototype.getContext === 1");
delete window.HTMLCanvasElement.prototype.getContext;
todo(window.HTMLCanvasElement.prototype.getContext === undefined, "window.HTMLCanvasElement.prototype.getContext === undefined");
ok(window.HTMLCanvasElement.prototype.getContext === undefined, "window.HTMLCanvasElement.prototype.getContext === undefined");
window.HTMLCanvasElement.prototype.getContext = getContext;
}
@ -21257,8 +21259,10 @@ function test_type_replace() {
var canvas = document.getElementById('c680');
var ctx = canvas.getContext('2d');
var getContext = window.HTMLCanvasElement.prototype.getContext;
window.HTMLCanvasElement.prototype.getContext = function (name) { return 0; };
ok(canvas.getContext('2d') === 0, "canvas.getContext('2d') === 0");
window.HTMLCanvasElement.prototype.getContext = getContext;
}

View File

@ -101,10 +101,14 @@ public:
aRv = GetContext(aContextId, contextOptions, aCx, getter_AddRefs(context));
return context.forget();
}
void ToDataURL(const nsAString& aType, nsIVariant* aParams,
nsAString& aDataURL, ErrorResult& aRv)
void ToDataURL(JSContext* aCx, const nsAString& aType,
const Optional<JS::Value>& aParams, nsAString& aDataURL,
ErrorResult& aRv)
{
aRv = ToDataURL(aType, aParams, aDataURL);
JS::Value params = aParams.WasPassed()
? aParams.Value()
: JS::UndefinedValue();
aRv = ToDataURL(aType, params, aCx, aDataURL);
}
void ToBlob(nsIFileCallback* aCallback, const nsAString& aType,
ErrorResult& aRv)
@ -224,10 +228,11 @@ public:
nsresult GetContext(const nsAString& aContextId, nsISupports** aContext);
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
protected:
virtual JSObject* WrapNode(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
nsIntSize GetWidthHeight();
nsresult UpdateContext(nsIPropertyBag *aNewContextOptions = nullptr);

View File

@ -12,6 +12,7 @@
#include "mozilla/Base64.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/dom/CanvasRenderingContext2D.h"
#include "mozilla/dom/HTMLCanvasElementBinding.h"
#include "mozilla/gfx/Rect.h"
#include "mozilla/Preferences.h"
#include "mozilla/Telemetry.h"
@ -143,6 +144,7 @@ HTMLCanvasElement::HTMLCanvasElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsGenericHTMLElement(aNodeInfo),
mWriteOnly(false)
{
SetIsDOMBinding();
}
HTMLCanvasElement::~HTMLCanvasElement()
@ -163,10 +165,16 @@ NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(HTMLCanvasElement)
nsICanvasElementExternal)
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(HTMLCanvasElement,
nsGenericHTMLElement)
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLCanvasElement)
NS_HTML_CONTENT_INTERFACE_MAP_END
NS_IMPL_ELEMENT_CLONE(HTMLCanvasElement)
/* virtual */ JSObject*
HTMLCanvasElement::WrapNode(JSContext* aCx, JSObject* aScope)
{
return HTMLCanvasElementBinding::Wrap(aCx, aScope, this);
}
nsIntSize
HTMLCanvasElement::GetWidthHeight()
{
@ -1019,5 +1027,4 @@ HTMLCanvasElement::RenderContextsExternal(gfxContext *aContext, gfxPattern::Grap
} // namespace dom
} // namespace mozilla
DOMCI_NODE_DATA(HTMLCanvasElement, mozilla::dom::HTMLCanvasElement)
DOMCI_DATA(MozCanvasPrintState, mozilla::dom::HTMLCanvasPrintState)

View File

@ -772,8 +772,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(SVGZoomEvent, nsEventSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(HTMLCanvasElement, nsElementSH,
ELEMENT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(CanvasGradient, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(CanvasPattern, nsDOMGenericSH,
@ -2141,11 +2139,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(HTMLCanvasElement, nsIDOMHTMLCanvasElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLCanvasElement)
DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(CanvasGradient, nsIDOMCanvasGradient)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCanvasGradient)
DOM_CLASSINFO_MAP_END

View File

@ -131,7 +131,6 @@ DOMCI_CLASS(SVGStringList)
DOMCI_CLASS(SVGZoomEvent)
// Canvas
DOMCI_CLASS(HTMLCanvasElement)
DOMCI_CLASS(CanvasGradient)
DOMCI_CLASS(CanvasPattern)
DOMCI_CLASS(TextMetrics)

View File

@ -1467,8 +1467,9 @@ addExternalIface('DOMError')
addExternalIface('CSSRuleList')
addExternalIface('DOMStringList')
addExternalIface('File')
addExternalIface('FileCallback', nativeType='nsIFileCallback',
headerFile='nsIDOMHTMLCanvasElement.h')
addExternalIface('HitRegionOptions', nativeType='nsISupports')
addExternalIface('HTMLCanvasElement', nativeType='mozilla::dom::HTMLCanvasElement')
addExternalIface('IDBOpenDBRequest', nativeType='nsIIDBOpenDBRequest')
addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')
addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
@ -1485,6 +1486,8 @@ addExternalIface('MozRDFResource', nativeType='nsIRDFResource', notflattened=Tru
addExternalIface('MozXULTemplateBuilder', nativeType='nsIXULTemplateBuilder')
addExternalIface('MozNamedAttrMap')
addExternalIface('nsIControllers', nativeType='nsIControllers')
addExternalIface('nsIInputStreamCallback', nativeType='nsIInputStreamCallback',
headerFile='nsIAsyncInputStream.h')
addExternalIface('nsIStreamListener', nativeType='nsIStreamListener', notflattened=True)
addExternalIface('nsISupports', nativeType='nsISupports')
addExternalIface('nsIEditor', nativeType='nsIEditor', notflattened=True)
@ -1493,6 +1496,8 @@ addExternalIface('OutputStream', nativeType='nsIOutputStream',
notflattened=True)
addExternalIface('Principal', nativeType='nsIPrincipal',
headerFile='nsIPrincipal.h', notflattened=True)
addExternalIface('PrintCallback', nativeType='nsIPrintCallback',
headerFile='nsIDOMHTMLCanvasElement.h')
addExternalIface('Selection', nativeType='nsISelection')
addExternalIface('StyleSheetList')
addExternalIface('SVGAnimatedEnumeration', headerFile='nsIDOMSVGAnimatedEnum.h')

View File

@ -14,7 +14,6 @@
interface CanvasGradient;
interface CanvasPattern;
interface HitRegionOptions;
interface HTMLCanvasElement;
interface TextMetrics;
interface Window;

View File

@ -0,0 +1,47 @@
/* -*- 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
* http://www.whatwg.org/specs/web-apps/current-work/#the-canvas-element
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
* Opera Software ASA. You are granted a license to use, reproduce
* and create derivative works of this document.
*/
interface Blob;
interface FileCallback;
interface nsIInputStreamCallback;
interface nsISupports;
interface PrintCallback;
interface Variant;
interface HTMLCanvasElement : HTMLElement {
[Pure, SetterThrows]
attribute unsigned long width;
[Pure, SetterThrows]
attribute unsigned long height;
[Throws]
nsISupports? getContext(DOMString contextId, optional any contextOptions);
[Throws]
DOMString toDataURL(optional DOMString type = "",
optional any encoderOptions);
[Throws]
void toBlob(FileCallback _callback, optional DOMString type = "");
};
// Mozilla specific bits
partial interface HTMLCanvasElement {
[Pure, SetterThrows]
attribute boolean mozOpaque;
[Throws]
File mozGetAsFile(DOMString name, optional DOMString? type = null);
[ChromeOnly, Throws]
nsISupports? MozGetIPCContext(DOMString contextId);
[ChromeOnly]
void mozFetchAsStream(nsIInputStreamCallback callback, optional DOMString? type = null);
attribute PrintCallback? mozPrintCallback;
};

View File

@ -81,6 +81,7 @@ webidl_files = \
HTMLBodyElement.webidl \
HTMLBRElement.webidl \
HTMLButtonElement.webidl \
HTMLCanvasElement.webidl \
HTMLCollection.webidl \
HTMLDataElement.webidl \
HTMLDataListElement.webidl \