mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 856472: Convert CanvasGradient to WebIDL r=bz
This commit is contained in:
parent
22996e681b
commit
57b47b7ab9
@ -8,6 +8,8 @@
|
||||
#include "nsIDOMCanvasRenderingContext2D.h"
|
||||
#include "nsTArray.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/dom/CanvasRenderingContext2DBinding.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
|
||||
#define NS_CANVASGRADIENTAZURE_PRIVATE_IID \
|
||||
{0x28425a6a, 0x90e0, 0x4d42, {0x9c, 0x75, 0xff, 0x60, 0x09, 0xb3, 0x10, 0xa8}}
|
||||
@ -15,7 +17,7 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class CanvasGradient : public nsIDOMCanvasGradient
|
||||
class CanvasGradient : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_CANVASGRADIENTAZURE_PRIVATE_IID)
|
||||
@ -46,8 +48,13 @@ public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/* nsIDOMCanvasGradient */
|
||||
NS_IMETHOD AddColorStop(float offset, const nsAString& colorstr);
|
||||
// WebIDL
|
||||
void AddColorStop(float offset, const nsAString& colorstr, ErrorResult& rv);
|
||||
|
||||
JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
|
||||
{
|
||||
return CanvasGradientBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
protected:
|
||||
CanvasGradient(Type aType) : mType(aType)
|
||||
|
@ -361,22 +361,25 @@ private:
|
||||
mgfx::Rect mTempRect;
|
||||
};
|
||||
|
||||
NS_IMETHODIMP
|
||||
CanvasGradient::AddColorStop(float offset, const nsAString& colorstr)
|
||||
void
|
||||
CanvasGradient::AddColorStop(float offset, const nsAString& colorstr, ErrorResult& rv)
|
||||
{
|
||||
if (!FloatValidate(offset) || offset < 0.0 || offset > 1.0) {
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
if (offset < 0.0 || offset > 1.0) {
|
||||
rv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
nsCSSValue value;
|
||||
nsCSSParser parser;
|
||||
if (!parser.ParseColorString(colorstr, nullptr, 0, value)) {
|
||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
||||
rv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
nscolor color;
|
||||
if (!nsRuleNode::ComputeColor(value, nullptr, nullptr, color)) {
|
||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
||||
rv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
mStops = nullptr;
|
||||
@ -387,8 +390,6 @@ CanvasGradient::AddColorStop(float offset, const nsAString& colorstr)
|
||||
newStop.color = Color::FromABGR(color);
|
||||
|
||||
mRawStops.AppendElement(newStop);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(CanvasGradient, NS_CANVASGRADIENTAZURE_PRIVATE_IID)
|
||||
@ -398,8 +399,6 @@ NS_IMPL_RELEASE(CanvasGradient)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(CanvasGradient)
|
||||
NS_INTERFACE_MAP_ENTRY(mozilla::dom::CanvasGradient)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMCanvasGradient)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CanvasGradient)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
@ -1356,17 +1355,16 @@ CanvasRenderingContext2D::GetFillRule(nsAString& aString)
|
||||
//
|
||||
// gradients and patterns
|
||||
//
|
||||
already_AddRefed<nsIDOMCanvasGradient>
|
||||
CanvasRenderingContext2D::CreateLinearGradient(double x0, double y0, double x1, double y1,
|
||||
ErrorResult& aError)
|
||||
already_AddRefed<CanvasGradient>
|
||||
CanvasRenderingContext2D::CreateLinearGradient(double x0, double y0, double x1, double y1)
|
||||
{
|
||||
nsRefPtr<nsIDOMCanvasGradient> grad =
|
||||
nsRefPtr<CanvasGradient> grad =
|
||||
new CanvasLinearGradient(Point(x0, y0), Point(x1, y1));
|
||||
|
||||
return grad.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMCanvasGradient>
|
||||
already_AddRefed<CanvasGradient>
|
||||
CanvasRenderingContext2D::CreateRadialGradient(double x0, double y0, double r0,
|
||||
double x1, double y1, double r1,
|
||||
ErrorResult& aError)
|
||||
@ -1376,7 +1374,7 @@ CanvasRenderingContext2D::CreateRadialGradient(double x0, double y0, double r0,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<nsIDOMCanvasGradient> grad =
|
||||
nsRefPtr<CanvasGradient> grad =
|
||||
new CanvasRadialGradient(Point(x0, y0), r0, Point(x1, y1), r1);
|
||||
|
||||
return grad.forget();
|
||||
@ -3808,6 +3806,5 @@ CanvasRenderingContext2D::ShouldForceInactiveLayer(LayerManager *aManager)
|
||||
}
|
||||
}
|
||||
|
||||
DOMCI_DATA(CanvasGradient, mozilla::dom::CanvasGradient)
|
||||
DOMCI_DATA(CanvasRenderingContext2D, mozilla::dom::CanvasRenderingContext2D)
|
||||
|
||||
|
@ -104,15 +104,14 @@ public:
|
||||
SetStyleFromJSValue(cx, value, STYLE_FILL);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMCanvasGradient>
|
||||
CreateLinearGradient(double x0, double y0, double x1, double y1,
|
||||
mozilla::ErrorResult& aError);
|
||||
already_AddRefed<nsIDOMCanvasGradient>
|
||||
already_AddRefed<CanvasGradient>
|
||||
CreateLinearGradient(double x0, double y0, double x1, double y1);
|
||||
already_AddRefed<CanvasGradient>
|
||||
CreateRadialGradient(double x0, double y0, double r0, double x1, double y1,
|
||||
double r1, mozilla::ErrorResult& aError);
|
||||
double r1, ErrorResult& aError);
|
||||
already_AddRefed<CanvasPattern>
|
||||
CreatePattern(const HTMLImageOrCanvasOrVideoElement& element,
|
||||
const nsAString& repeat, mozilla::ErrorResult& error);
|
||||
const nsAString& repeat, ErrorResult& error);
|
||||
|
||||
double ShadowOffsetX()
|
||||
{
|
||||
|
@ -6215,13 +6215,13 @@ var _thrown = undefined; try {
|
||||
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "IndexSizeError" && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw IndexSizeError");
|
||||
var _thrown = undefined; try {
|
||||
g.addColorStop(Infinity, '#000');
|
||||
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "IndexSizeError" && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw IndexSizeError");
|
||||
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "TypeError", "should throw TypeError");
|
||||
var _thrown = undefined; try {
|
||||
g.addColorStop(-Infinity, '#000');
|
||||
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "IndexSizeError" && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw IndexSizeError");
|
||||
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "TypeError", "should throw TypeError");
|
||||
var _thrown = undefined; try {
|
||||
g.addColorStop(NaN, '#000');
|
||||
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "IndexSizeError" && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw IndexSizeError");
|
||||
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "TypeError", "should throw TypeError");
|
||||
|
||||
|
||||
}
|
||||
|
@ -716,8 +716,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
NS_DEFINE_CLASSINFO_DATA(SVGZoomEvent, nsEventSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(CanvasGradient, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(MozCanvasPrintState, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
@ -1984,10 +1982,6 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(CanvasGradient, nsIDOMCanvasGradient)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCanvasGradient)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(MozCanvasPrintState, nsIDOMMozCanvasPrintState)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozCanvasPrintState)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
@ -116,7 +116,6 @@ DOMCI_CLASS(SVGRect)
|
||||
DOMCI_CLASS(SVGZoomEvent)
|
||||
|
||||
// Canvas
|
||||
DOMCI_CLASS(CanvasGradient)
|
||||
DOMCI_CLASS(MozCanvasPrintState)
|
||||
|
||||
// WindowUtils
|
||||
|
@ -150,6 +150,10 @@ DOMInterfaces = {
|
||||
'headerFile': 'BatteryManager.h'
|
||||
},
|
||||
|
||||
'CanvasGradient': {
|
||||
'wrapperCache': False,
|
||||
},
|
||||
|
||||
'CanvasRenderingContext2D': {
|
||||
'implicitJSContext': [
|
||||
'createImageData', 'getImageData', 'strokeStyle',
|
||||
@ -1507,7 +1511,6 @@ def addExternalHTMLElement(element):
|
||||
addExternalHTMLElement('HTMLFormElement')
|
||||
addExternalIface('ActivityOptions', nativeType='nsIDOMMozActivityOptions',
|
||||
headerFile='nsIDOMActivityOptions.h')
|
||||
addExternalIface('CanvasGradient', headerFile='nsIDOMCanvasRenderingContext2D.h')
|
||||
addExternalIface('Counter')
|
||||
addExternalIface('CSSRule')
|
||||
addExternalIface('DeviceAcceleration', headerFile='nsIDOMDeviceMotionEvent.h', notflattened=True)
|
||||
|
@ -5,12 +5,6 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(bbb20a59-524e-4662-981e-5e142814b20c)]
|
||||
interface nsIDOMCanvasGradient : nsISupports
|
||||
{
|
||||
void addColorStop(in float offset, in DOMString color);
|
||||
};
|
||||
|
||||
/**
|
||||
* This interface remains only for the constants, for a context, use the
|
||||
* WebIDL/Paris bindings instead (CanvasRenderingContext2D.webidl).
|
||||
|
@ -11,7 +11,6 @@
|
||||
* and create derivative works of this document.
|
||||
*/
|
||||
|
||||
interface CanvasGradient;
|
||||
interface HitRegionOptions;
|
||||
interface Window;
|
||||
|
||||
@ -51,9 +50,9 @@ interface CanvasRenderingContext2D {
|
||||
attribute any strokeStyle; // (default black)
|
||||
[GetterThrows]
|
||||
attribute any fillStyle; // (default black)
|
||||
[Throws]
|
||||
[Creator]
|
||||
CanvasGradient createLinearGradient(double x0, double y0, double x1, double y1);
|
||||
[Throws]
|
||||
[Creator, Throws]
|
||||
CanvasGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1);
|
||||
[Creator, Throws]
|
||||
CanvasPattern createPattern((HTMLImageElement or HTMLCanvasElement or HTMLVideoElement) image, [TreatNullAs=EmptyString] DOMString repetition);
|
||||
@ -263,6 +262,13 @@ interface CanvasPathMethods {
|
||||
// NOT IMPLEMENTED [LenientFloat] void ellipse(double x, double y, double radiusX, double radiusY, double rotation, double startAngle, double endAngle, boolean anticlockwise);
|
||||
};
|
||||
|
||||
interface CanvasGradient {
|
||||
// opaque object
|
||||
[Throws]
|
||||
// addColorStop should take a double
|
||||
void addColorStop(float offset, DOMString color);
|
||||
};
|
||||
|
||||
interface CanvasPattern {
|
||||
// opaque object
|
||||
// void setTransform(SVGMatrix transform);
|
||||
|
@ -50,11 +50,6 @@ members = [
|
||||
#'nsIDOMLocation.hostname',
|
||||
#'nsIDOMLocation.href',
|
||||
|
||||
# dom/interfaces/canvas
|
||||
#
|
||||
# canvas friends
|
||||
'nsIDOMCanvasGradient.*',
|
||||
|
||||
# dom/interfaces/core
|
||||
'nsIDOMDOMStringList.*',
|
||||
|
||||
@ -142,8 +137,6 @@ members = [
|
||||
#
|
||||
irregularFilenames = {
|
||||
# stowaways
|
||||
'nsIDOMCanvasGradient': 'nsIDOMCanvasRenderingContext2D',
|
||||
|
||||
'nsIDOMBlob': 'nsIDOMFile',
|
||||
|
||||
'nsIIndexedDatabaseUsageCallback': 'nsIIndexedDatabaseManager',
|
||||
@ -170,10 +163,6 @@ customIncludes = [
|
||||
'mozilla/dom/UIEventBinding.h',
|
||||
]
|
||||
|
||||
customReturnInterfaces = [
|
||||
'nsIDOMCanvasGradient',
|
||||
]
|
||||
|
||||
nsIDOMStorage_Clear_customMethodCallCode = """
|
||||
rv = self->Clear();
|
||||
if (NS_SUCCEEDED(rv))
|
||||
|
@ -226,7 +226,6 @@ class Configuration:
|
||||
# optional settings
|
||||
self.irregularFilenames = config.get('irregularFilenames', {})
|
||||
self.customIncludes = config.get('customIncludes', [])
|
||||
self.customReturnInterfaces = config.get('customReturnInterfaces', [])
|
||||
self.customMethodCalls = config.get('customMethodCalls', {})
|
||||
self.newBindingProperties = config.get('newBindingProperties', {})
|
||||
|
||||
@ -314,10 +313,6 @@ def readConfigFile(filename, includePath, cachedir):
|
||||
for member in iface.stubMembers:
|
||||
checkStubMember(member)
|
||||
|
||||
for iface in conf.customReturnInterfaces:
|
||||
# just ensure that it exists so that we can grab it later
|
||||
iface = getInterface(iface, errorLoc='looking for %s' % (iface,))
|
||||
|
||||
return conf, interfaces
|
||||
|
||||
|
||||
@ -1271,7 +1266,6 @@ def writeStubFile(filename, headerFilename, conf, interfaces):
|
||||
resulttypes = []
|
||||
for iface in interfaces:
|
||||
resulttypes.extend(writeIncludesForInterface(iface))
|
||||
resulttypes.extend(conf.customReturnInterfaces)
|
||||
for customInclude in conf.customIncludes:
|
||||
f.write('#include "%s"\n' % customInclude)
|
||||
f.write("\n\n")
|
||||
|
Loading…
Reference in New Issue
Block a user