зеркало из https://github.com/mozilla/gecko-dev.git
b=534735; use custom quickstubs for canvas fillStyle and strokeStyle; r=bz
This commit is contained in:
Родитель
83e7a08a06
Коммит
b112d82884
|
@ -0,0 +1,144 @@
|
|||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIDOMCanvasRenderingContext2D.h"
|
||||
|
||||
typedef nsresult (NS_STDCALL nsIDOMCanvasRenderingContext2D::*CanvasStyleSetterType)(const nsAString &, nsISupports *);
|
||||
typedef nsresult (NS_STDCALL nsIDOMCanvasRenderingContext2D::*CanvasStyleGetterType)(nsAString &, nsISupports **, PRInt32 *);
|
||||
|
||||
static JSBool
|
||||
Canvas2D_SetStyleHelper(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
||||
CanvasStyleSetterType setfunc)
|
||||
{
|
||||
XPC_QS_ASSERT_CONTEXT_OK(cx);
|
||||
nsIDOMCanvasRenderingContext2D *self;
|
||||
xpc_qsSelfRef selfref;
|
||||
JSAutoTempValueRooter tvr(cx);
|
||||
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
|
||||
return JS_FALSE;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
if (JSVAL_IS_STRING(*vp)) {
|
||||
xpc_qsDOMString arg0(cx, *vp, vp,
|
||||
xpc_qsDOMString::eDefaultNullBehavior,
|
||||
xpc_qsDOMString::eDefaultUndefinedBehavior);
|
||||
if (!arg0.IsValid())
|
||||
return JS_FALSE;
|
||||
|
||||
rv = (self->*setfunc)(arg0, nsnull);
|
||||
} else {
|
||||
nsISupports *arg0;
|
||||
xpc_qsSelfRef arg0ref;
|
||||
rv = xpc_qsUnwrapArg<nsISupports>(cx, *vp, &arg0, &arg0ref.ptr, vp);
|
||||
if (NS_FAILED(rv)) {
|
||||
xpc_qsThrowBadSetterValue(cx, rv, JSVAL_TO_OBJECT(*tvr.addr()), id);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsString voidStr;
|
||||
voidStr.SetIsVoid(PR_TRUE);
|
||||
|
||||
rv = (self->*setfunc)(voidStr, arg0);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return xpc_qsThrowGetterSetterFailed(cx, rv, JSVAL_TO_OBJECT(*tvr.addr()), id);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
Canvas2D_GetStyleHelper(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
|
||||
CanvasStyleGetterType getfunc)
|
||||
{
|
||||
XPC_QS_ASSERT_CONTEXT_OK(cx);
|
||||
nsIDOMCanvasRenderingContext2D *self;
|
||||
xpc_qsSelfRef selfref;
|
||||
XPCLazyCallContext lccx(JS_CALLER, cx, obj);
|
||||
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, vp, &lccx))
|
||||
return JS_FALSE;
|
||||
nsresult rv;
|
||||
|
||||
nsString resultString;
|
||||
nsCOMPtr<nsISupports> resultInterface;
|
||||
PRInt32 resultType;
|
||||
rv = (self->*getfunc)(resultString, getter_AddRefs(resultInterface), &resultType);
|
||||
if (NS_FAILED(rv))
|
||||
return xpc_qsThrowGetterSetterFailed(cx, rv, JSVAL_TO_OBJECT(*vp), id);
|
||||
|
||||
switch (resultType) {
|
||||
case nsIDOMCanvasRenderingContext2D::CMG_STYLE_STRING:
|
||||
return xpc_qsStringToJsval(cx, resultString, vp);
|
||||
|
||||
case nsIDOMCanvasRenderingContext2D::CMG_STYLE_PATTERN:
|
||||
return xpc_qsXPCOMObjectToJsval(lccx, resultInterface, xpc_qsGetWrapperCache(resultInterface),
|
||||
&NS_GET_IID(nsIDOMCanvasPattern), &interfaces[k_nsIDOMCanvasPattern], vp);
|
||||
|
||||
case nsIDOMCanvasRenderingContext2D::CMG_STYLE_GRADIENT:
|
||||
return xpc_qsXPCOMObjectToJsval(lccx, resultInterface, xpc_qsGetWrapperCache(resultInterface),
|
||||
&NS_GET_IID(nsIDOMCanvasGradient), &interfaces[k_nsIDOMCanvasGradient], vp);
|
||||
|
||||
default:
|
||||
return xpc_qsThrowGetterSetterFailed(cx, NS_ERROR_FAILURE, JSVAL_TO_OBJECT(*vp), id);
|
||||
}
|
||||
}
|
||||
|
||||
static JSBool
|
||||
nsIDOMCanvasRenderingContext2D_SetStrokeStyle(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
return Canvas2D_SetStyleHelper(cx, obj, id, vp, &nsIDOMCanvasRenderingContext2D::SetStrokeStyle_multi);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
nsIDOMCanvasRenderingContext2D_GetStrokeStyle(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
return Canvas2D_GetStyleHelper(cx, obj, id, vp, &nsIDOMCanvasRenderingContext2D::GetStrokeStyle_multi);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
nsIDOMCanvasRenderingContext2D_SetFillStyle(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
return Canvas2D_SetStyleHelper(cx, obj, id, vp, &nsIDOMCanvasRenderingContext2D::SetFillStyle_multi);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
nsIDOMCanvasRenderingContext2D_GetFillStyle(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
return Canvas2D_GetStyleHelper(cx, obj, id, vp, &nsIDOMCanvasRenderingContext2D::GetFillStyle_multi);
|
||||
}
|
|
@ -47,6 +47,7 @@ LIBRARY_NAME = gkconcvs_s
|
|||
LIBXUL_LIBRARY = 1
|
||||
|
||||
EXPORTS = \
|
||||
CustomQS_Canvas2D.h \
|
||||
CustomQS_WebGL.h \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -361,7 +361,9 @@ protected:
|
|||
void Destroy();
|
||||
|
||||
// Some helpers. Doesn't modify acolor on failure.
|
||||
nsresult SetStyleFromVariant(nsIVariant* aStyle, Style aWhichStyle);
|
||||
nsresult SetStyleFromStringOrInterface(const nsAString& aStr, nsISupports *aInterface, Style aWhichStyle);
|
||||
nsresult GetStyleAsStringOrInterface(nsAString& aStr, nsISupports **aInterface, PRInt32 *aType, Style aWhichStyle);
|
||||
|
||||
void StyleColorToString(const nscolor& aColor, nsAString& aStr);
|
||||
|
||||
void DirtyAllStyles();
|
||||
|
@ -709,28 +711,16 @@ nsCanvasRenderingContext2D::Destroy()
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsCanvasRenderingContext2D::SetStyleFromVariant(nsIVariant* aStyle, Style aWhichStyle)
|
||||
nsCanvasRenderingContext2D::SetStyleFromStringOrInterface(const nsAString& aStr,
|
||||
nsISupports *aInterface,
|
||||
Style aWhichStyle)
|
||||
{
|
||||
nsresult rv;
|
||||
nscolor color;
|
||||
|
||||
PRUint16 paramType;
|
||||
rv = aStyle->GetDataType(¶mType);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (paramType == nsIDataType::VTYPE_DOMSTRING ||
|
||||
paramType == nsIDataType::VTYPE_WSTRING_SIZE_IS) {
|
||||
nsAutoString str;
|
||||
|
||||
if (paramType == nsIDataType::VTYPE_DOMSTRING) {
|
||||
rv = aStyle->GetAsDOMString(str);
|
||||
} else {
|
||||
rv = aStyle->GetAsAString(str);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!aStr.IsVoid()) {
|
||||
nsCSSParser parser;
|
||||
rv = parser.ParseColorString(str, nsnull, 0, &color);
|
||||
rv = parser.ParseColorString(aStr, nsnull, 0, &color);
|
||||
if (NS_FAILED(rv)) {
|
||||
// Error reporting happens inside the CSS parser
|
||||
return NS_OK;
|
||||
|
@ -740,21 +730,17 @@ nsCanvasRenderingContext2D::SetStyleFromVariant(nsIVariant* aStyle, Style aWhich
|
|||
|
||||
mDirtyStyle[aWhichStyle] = PR_TRUE;
|
||||
return NS_OK;
|
||||
} else if (paramType == nsIDataType::VTYPE_INTERFACE ||
|
||||
paramType == nsIDataType::VTYPE_INTERFACE_IS)
|
||||
{
|
||||
nsID *iid;
|
||||
nsCOMPtr<nsISupports> iface;
|
||||
rv = aStyle->GetAsInterface(&iid, getter_AddRefs(iface));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsCanvasGradient> grad(do_QueryInterface(iface));
|
||||
if (aInterface) {
|
||||
nsCOMPtr<nsCanvasGradient> grad(do_QueryInterface(aInterface));
|
||||
if (grad) {
|
||||
CurrentState().SetGradientStyle(aWhichStyle, grad);
|
||||
mDirtyStyle[aWhichStyle] = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsCanvasPattern> pattern(do_QueryInterface(iface));
|
||||
nsCOMPtr<nsCanvasPattern> pattern(do_QueryInterface(aInterface));
|
||||
if (pattern) {
|
||||
CurrentState().SetPatternStyle(aWhichStyle, pattern);
|
||||
mDirtyStyle[aWhichStyle] = PR_TRUE;
|
||||
|
@ -774,6 +760,29 @@ nsCanvasRenderingContext2D::SetStyleFromVariant(nsIVariant* aStyle, Style aWhich
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCanvasRenderingContext2D::GetStyleAsStringOrInterface(nsAString& aStr,
|
||||
nsISupports **aInterface,
|
||||
PRInt32 *aType,
|
||||
Style aWhichStyle)
|
||||
{
|
||||
if (CurrentState().patternStyles[aWhichStyle]) {
|
||||
aStr.SetIsVoid(PR_TRUE);
|
||||
NS_ADDREF(*aInterface = CurrentState().patternStyles[aWhichStyle]);
|
||||
*aType = CMG_STYLE_PATTERN;
|
||||
} else if (CurrentState().gradientStyles[aWhichStyle]) {
|
||||
aStr.SetIsVoid(PR_TRUE);
|
||||
NS_ADDREF(*aInterface = CurrentState().gradientStyles[aWhichStyle]);
|
||||
*aType = CMG_STYLE_GRADIENT;
|
||||
} else {
|
||||
StyleColorToString(CurrentState().colorStyles[aWhichStyle], aStr);
|
||||
*aInterface = nsnull;
|
||||
*aType = CMG_STYLE_STRING;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsCanvasRenderingContext2D::StyleColorToString(const nscolor& aColor, nsAString& aStr)
|
||||
{
|
||||
|
@ -1208,75 +1217,148 @@ nsCanvasRenderingContext2D::GetGlobalAlpha(float *aGlobalAlpha)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::SetStrokeStyle(nsIVariant* aStyle)
|
||||
nsCanvasRenderingContext2D::SetStrokeStyle(nsIVariant *aValue)
|
||||
{
|
||||
return SetStyleFromVariant(aStyle, STYLE_STROKE);
|
||||
if (!aValue)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsString str;
|
||||
|
||||
nsresult rv;
|
||||
PRUint16 vtype;
|
||||
rv = aValue->GetDataType(&vtype);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (vtype == nsIDataType::VTYPE_INTERFACE ||
|
||||
vtype == nsIDataType::VTYPE_INTERFACE_IS)
|
||||
{
|
||||
nsIID *iid;
|
||||
nsCOMPtr<nsISupports> sup;
|
||||
rv = aValue->GetAsInterface(&iid, getter_AddRefs(sup));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
str.SetIsVoid(PR_TRUE);
|
||||
return SetStrokeStyle_multi(str, sup);
|
||||
}
|
||||
|
||||
rv = aValue->GetAsAString(str);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return SetStrokeStyle_multi(str, nsnull);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::GetStrokeStyle(nsIVariant** aStyle)
|
||||
nsCanvasRenderingContext2D::GetStrokeStyle(nsIVariant **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIWritableVariant> wv = do_CreateInstance(NS_VARIANT_CONTRACTID);
|
||||
|
||||
nsCOMPtr<nsIWritableVariant> var = do_CreateInstance("@mozilla.org/variant;1");
|
||||
if (!var)
|
||||
return NS_ERROR_FAILURE;
|
||||
rv = var->SetWritable(PR_TRUE);
|
||||
nsCOMPtr<nsISupports> sup;
|
||||
nsString str;
|
||||
PRInt32 t;
|
||||
nsresult rv = GetStrokeStyle_multi(str, getter_AddRefs(sup), &t);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (CurrentState().patternStyles[STYLE_STROKE]) {
|
||||
rv = var->SetAsISupports(CurrentState().patternStyles[STYLE_STROKE]);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else if (CurrentState().gradientStyles[STYLE_STROKE]) {
|
||||
rv = var->SetAsISupports(CurrentState().gradientStyles[STYLE_STROKE]);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (t == CMG_STYLE_STRING) {
|
||||
rv = wv->SetAsAString(str);
|
||||
} else if (t == CMG_STYLE_PATTERN) {
|
||||
rv = wv->SetAsInterface(NS_GET_IID(nsIDOMCanvasPattern),
|
||||
sup);
|
||||
} else if (t == CMG_STYLE_GRADIENT) {
|
||||
rv = wv->SetAsInterface(NS_GET_IID(nsIDOMCanvasGradient),
|
||||
sup);
|
||||
} else {
|
||||
nsString styleStr;
|
||||
StyleColorToString(CurrentState().colorStyles[STYLE_STROKE], styleStr);
|
||||
|
||||
rv = var->SetAsDOMString(styleStr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ERROR("Unknown type from GetStroke/FillStyle_multi!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aStyle = var.forget().get();
|
||||
NS_IF_ADDREF(*aResult = wv.get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::SetFillStyle(nsIVariant* aStyle)
|
||||
nsCanvasRenderingContext2D::SetFillStyle(nsIVariant *aValue)
|
||||
{
|
||||
return SetStyleFromVariant(aStyle, STYLE_FILL);
|
||||
if (!aValue)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsString str;
|
||||
nsresult rv;
|
||||
PRUint16 vtype;
|
||||
rv = aValue->GetDataType(&vtype);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (vtype == nsIDataType::VTYPE_INTERFACE ||
|
||||
vtype == nsIDataType::VTYPE_INTERFACE_IS)
|
||||
{
|
||||
nsIID *iid;
|
||||
nsCOMPtr<nsISupports> sup;
|
||||
rv = aValue->GetAsInterface(&iid, getter_AddRefs(sup));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
str.SetIsVoid(PR_TRUE);
|
||||
return SetFillStyle_multi(str, sup);
|
||||
}
|
||||
|
||||
rv = aValue->GetAsAString(str);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return SetFillStyle_multi(str, nsnull);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::GetFillStyle(nsIVariant** aStyle)
|
||||
nsCanvasRenderingContext2D::GetFillStyle(nsIVariant **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIWritableVariant> wv = do_CreateInstance(NS_VARIANT_CONTRACTID);
|
||||
|
||||
nsCOMPtr<nsIWritableVariant> var = do_CreateInstance("@mozilla.org/variant;1");
|
||||
if (!var)
|
||||
return NS_ERROR_FAILURE;
|
||||
rv = var->SetWritable(PR_TRUE);
|
||||
nsCOMPtr<nsISupports> sup;
|
||||
nsString str;
|
||||
PRInt32 t;
|
||||
nsresult rv = GetFillStyle_multi(str, getter_AddRefs(sup), &t);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (CurrentState().patternStyles[STYLE_FILL]) {
|
||||
rv = var->SetAsISupports(CurrentState().patternStyles[STYLE_FILL]);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else if (CurrentState().gradientStyles[STYLE_FILL]) {
|
||||
rv = var->SetAsISupports(CurrentState().gradientStyles[STYLE_FILL]);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (t == CMG_STYLE_STRING) {
|
||||
rv = wv->SetAsAString(str);
|
||||
} else if (t == CMG_STYLE_PATTERN) {
|
||||
rv = wv->SetAsInterface(NS_GET_IID(nsIDOMCanvasPattern),
|
||||
sup);
|
||||
} else if (t == CMG_STYLE_GRADIENT) {
|
||||
rv = wv->SetAsInterface(NS_GET_IID(nsIDOMCanvasGradient),
|
||||
sup);
|
||||
} else {
|
||||
nsString styleStr;
|
||||
StyleColorToString(CurrentState().colorStyles[STYLE_FILL], styleStr);
|
||||
|
||||
rv = var->SetAsDOMString(styleStr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ERROR("Unknown type from GetStroke/FillStyle_multi!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aStyle = var.forget().get();
|
||||
NS_IF_ADDREF(*aResult = wv.get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::SetStrokeStyle_multi(const nsAString& aStr, nsISupports *aInterface)
|
||||
{
|
||||
return SetStyleFromStringOrInterface(aStr, aInterface, STYLE_STROKE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::GetStrokeStyle_multi(nsAString& aStr, nsISupports **aInterface, PRInt32 *aType)
|
||||
{
|
||||
return GetStyleAsStringOrInterface(aStr, aInterface, aType, STYLE_STROKE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::SetFillStyle_multi(const nsAString& aStr, nsISupports *aInterface)
|
||||
{
|
||||
return SetStyleFromStringOrInterface(aStr, aInterface, STYLE_FILL);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::GetFillStyle_multi(nsAString& aStr, nsISupports **aInterface, PRInt32 *aType)
|
||||
{
|
||||
return GetStyleAsStringOrInterface(aStr, aInterface, aType, STYLE_FILL);
|
||||
}
|
||||
|
||||
//
|
||||
// gradients and patterns
|
||||
//
|
||||
|
|
|
@ -83,13 +83,30 @@ interface nsIDOMCanvasRenderingContext2D : nsISupports
|
|||
attribute float globalAlpha; /* default 1.0 -- opaque */
|
||||
attribute DOMString globalCompositeOperation; /* default "over" */
|
||||
|
||||
// colors and styles
|
||||
// Colors and Styles
|
||||
|
||||
// These attributes work, but are quickstubbed for JS code. Native
|
||||
// code should use the _multi variants below.
|
||||
attribute nsIVariant strokeStyle;
|
||||
attribute nsIVariant fillStyle;
|
||||
|
||||
// These do the actual work. Use these from c++ -- only one of str or iface
|
||||
// should be specified; the one that's not null/void is used. For the getter,
|
||||
// ifaceType is 0 if it's a string, 1 if it's a pattern, or 2 if it's a gradient
|
||||
%{C++
|
||||
enum CanvasMultiGetterType {
|
||||
CMG_STYLE_STRING = 0,
|
||||
CMG_STYLE_PATTERN = 1,
|
||||
CMG_STYLE_GRADIENT = 2
|
||||
};
|
||||
%}
|
||||
[noscript] void setStrokeStyle_multi(in DOMString str, in nsISupports iface);
|
||||
[noscript] void getStrokeStyle_multi(out DOMString str, out nsISupports iface, out long type);
|
||||
[noscript] void setFillStyle_multi(in DOMString str, in nsISupports iface);
|
||||
[noscript] void getFillStyle_multi(out DOMString str, out nsISupports iface, out long type);
|
||||
|
||||
nsIDOMCanvasGradient createLinearGradient (in float x0, in float y0, in float x1, in float y1);
|
||||
nsIDOMCanvasGradient createRadialGradient(in float x0, in float y0, in float r0, in float x1, in float y1, in float r1);
|
||||
//nsIDOMCanvasPattern createPattern(in nsIDOMHTMLImageElement image, in DOMString repetition);
|
||||
nsIDOMCanvasPattern createPattern(in nsIDOMHTMLElement image, in DOMString repetition);
|
||||
attribute float lineWidth; /* default 1 */
|
||||
attribute DOMString lineCap; /* "butt", "round", "square" (default) */
|
||||
|
|
|
@ -87,17 +87,16 @@ members = [
|
|||
|
||||
# dom/interfaces/canvas
|
||||
#
|
||||
# nsIDOMCanvasRenderingContext2D
|
||||
# nsIDOMCanvasRenderingContext2D and friends
|
||||
'nsIDOMCanvasRenderingContext2D.*',
|
||||
# NOTE: attributes strokeStyle and fillStyle are nsIVariant
|
||||
'nsIDOMTextMetrics.*',
|
||||
'nsIDOMCanvasGradient.*',
|
||||
'nsIDOMCanvasPattern.*',
|
||||
# NOTE: createImageDate(), getImageData(), and putImageData() use
|
||||
# GetCurrentNativeCallContext
|
||||
'-nsIDOMCanvasRenderingContext2D.strokeStyle',
|
||||
'-nsIDOMCanvasRenderingContext2D.fillStyle',
|
||||
'-nsIDOMCanvasRenderingContext2D.createImageData',
|
||||
'-nsIDOMCanvasRenderingContext2D.getImageData',
|
||||
'-nsIDOMCanvasRenderingContext2D.putImageData',
|
||||
'nsIDOMTextMetrics.*',
|
||||
|
||||
# dom/interfaces/core
|
||||
'nsIDOMCharacterData.data',
|
||||
|
@ -501,7 +500,13 @@ customIncludes = [
|
|||
]
|
||||
|
||||
customQuickStubs = [
|
||||
'CustomQS_WebGL.h'
|
||||
'CustomQS_WebGL.h',
|
||||
'CustomQS_Canvas2D.h'
|
||||
]
|
||||
|
||||
customReturnInterfaces = [
|
||||
'nsIDOMCanvasPattern',
|
||||
'nsIDOMCanvasGradient',
|
||||
]
|
||||
|
||||
nsIDOMNode_GetChildNodes_customMethodCallCode = """
|
||||
|
@ -594,7 +599,11 @@ customMethodCalls = {
|
|||
},
|
||||
'nsIDOMStorage_Clear': {
|
||||
'code': nsIDOMStorage_Clear_customMethodCallCode
|
||||
},
|
||||
},
|
||||
'nsIDOMCanvasRenderingContext2D_StrokeStyle': { 'skipgen': True },
|
||||
'nsIDOMCanvasRenderingContext2D_StrokeStyle': { 'skipgen': True },
|
||||
'nsIDOMCanvasRenderingContext2D_FillStyle': { 'skipgen': True },
|
||||
'nsIDOMCanvasRenderingContext2D_FillStyle': { 'skipgen': True },
|
||||
'nsIDOMCSS2Properties_': CSS2Properties_,
|
||||
'nsIDOMNSCSS2Properties_': CSS2Properties_,
|
||||
# WebGL
|
||||
|
|
|
@ -231,7 +231,7 @@ def addStubMember(memberId, member, traceable):
|
|||
# Add this member to the list.
|
||||
member.iface.stubMembers.append(member)
|
||||
|
||||
def checkStubMember(member):
|
||||
def checkStubMember(member, isCustom):
|
||||
memberId = member.iface.name + "." + member.name
|
||||
if member.kind not in ('method', 'attribute'):
|
||||
raise UserError("Member %s is %r, not a method or attribute."
|
||||
|
@ -246,7 +246,8 @@ def checkStubMember(member):
|
|||
|
||||
if (member.kind == 'attribute'
|
||||
and not member.readonly
|
||||
and isSpecificInterfaceType(member.realtype, 'nsIVariant')):
|
||||
and isSpecificInterfaceType(member.realtype, 'nsIVariant')
|
||||
and not isCustom):
|
||||
raise UserError(
|
||||
"Attribute %s: Non-readonly attributes of type nsIVariant "
|
||||
"are not supported."
|
||||
|
@ -368,7 +369,9 @@ def readConfigFile(filename, includePath, cachedir, traceable):
|
|||
# Now go through and check all the interfaces' members
|
||||
for iface in stubbedInterfaces:
|
||||
for member in iface.stubMembers:
|
||||
checkStubMember(member)
|
||||
cmc = conf.customMethodCalls.get(iface.name + "_" + header.methodNativeName(member), None)
|
||||
skipgen = cmc is not None and cmc.get('skipgen', False)
|
||||
checkStubMember(member, skipgen)
|
||||
|
||||
for iface in conf.customReturnInterfaces:
|
||||
# just ensure that it exists so that we can grab it later
|
||||
|
@ -735,6 +738,7 @@ def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False):
|
|||
signature += "%s(JSContext *cx, uintN argc,%s jsval *vp)\n"
|
||||
|
||||
customMethodCall = customMethodCalls.get(stubName, None)
|
||||
|
||||
if customMethodCall is None:
|
||||
customMethodCall = customMethodCalls.get(member.iface.name + '_', None)
|
||||
if customMethodCall is not None:
|
||||
|
@ -779,8 +783,6 @@ def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False):
|
|||
code = customMethodCall['setter_code']
|
||||
stubName = templateName
|
||||
else:
|
||||
if customMethodCall.get('skipgen', False):
|
||||
return
|
||||
callTemplate = ""
|
||||
code = customMethodCall['code']
|
||||
|
||||
|
@ -1308,15 +1310,20 @@ def writeTraceableQuickStub(f, customMethodCalls, member, stubName):
|
|||
", ".join(traceInfo["params"])))
|
||||
|
||||
def writeAttrStubs(f, customMethodCalls, attr):
|
||||
cmc = customMethodCalls.get(attr.iface.name + "_" + header.methodNativeName(attr), None)
|
||||
custom = cmc and cmc.get('skipgen', False)
|
||||
|
||||
getterName = (attr.iface.name + '_'
|
||||
+ header.attributeNativeName(attr, True))
|
||||
writeQuickStub(f, customMethodCalls, attr, getterName)
|
||||
if not custom:
|
||||
writeQuickStub(f, customMethodCalls, attr, getterName)
|
||||
if attr.readonly:
|
||||
setterName = 'js_GetterOnlyPropertyStub'
|
||||
else:
|
||||
setterName = (attr.iface.name + '_'
|
||||
+ header.attributeNativeName(attr, False))
|
||||
writeQuickStub(f, customMethodCalls, attr, setterName, isSetter=True)
|
||||
if not custom:
|
||||
writeQuickStub(f, customMethodCalls, attr, setterName, isSetter=True)
|
||||
|
||||
ps = ('{"%s", %s, %s}'
|
||||
% (attr.name, getterName, setterName))
|
||||
|
@ -1324,15 +1331,25 @@ def writeAttrStubs(f, customMethodCalls, attr):
|
|||
|
||||
def writeMethodStub(f, customMethodCalls, method):
|
||||
""" Write a method stub to `f`. Return an xpc_qsFunctionSpec initializer. """
|
||||
|
||||
cmc = customMethodCalls.get(method.iface.name + "_" + header.methodNativeName(method), None)
|
||||
custom = cmc and cmc.get('skipgen', False)
|
||||
|
||||
stubName = method.iface.name + '_' + header.methodNativeName(method)
|
||||
writeQuickStub(f, customMethodCalls, method, stubName)
|
||||
if not custom:
|
||||
writeQuickStub(f, customMethodCalls, method, stubName)
|
||||
fs = '{"%s", %s, %d}' % (method.name, stubName, len(method.params))
|
||||
return fs
|
||||
|
||||
def writeTraceableStub(f, customMethodCalls, method):
|
||||
""" Write a method stub to `f`. Return an xpc_qsTraceableSpec initializer. """
|
||||
|
||||
cmc = customMethodCalls.get(method.iface.name + "_" + header.methodNativeName(method), None)
|
||||
custom = cmc and cmc.get('skipgen', False)
|
||||
|
||||
stubName = method.iface.name + '_' + header.methodNativeName(method)
|
||||
writeTraceableQuickStub(f, customMethodCalls, method, stubName)
|
||||
if not custom:
|
||||
writeTraceableQuickStub(f, customMethodCalls, method, stubName)
|
||||
fs = '{"%s", %s, %d}' % (method.name,
|
||||
"JS_DATA_TO_FUNC_PTR(JSNative, &%s_trcinfo)" % stubName,
|
||||
len(method.params))
|
||||
|
|
Загрузка…
Ссылка в новой задаче