зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1517786 - Implement the getContextAttributes() method for CanvasRenderingContext2D. r=gfx-reviewers,lsalzman,emilio
This has been in the HTML spec for a while now (see https://html.spec.whatwg.org/multipage/canvas.html#2dcontext), so we should probably go ahead and implement it. Differential Revision: https://phabricator.services.mozilla.com/D184499
This commit is contained in:
Родитель
d1525c4575
Коммит
2231ef7c87
|
@ -1136,6 +1136,17 @@ JSObject* CanvasRenderingContext2D::WrapObject(
|
|||
return CanvasRenderingContext2D_Binding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::GetContextAttributes(
|
||||
CanvasRenderingContext2DSettings& aSettings) const {
|
||||
aSettings = CanvasRenderingContext2DSettings();
|
||||
|
||||
aSettings.mAlpha = mContextAttributesHasAlpha;
|
||||
aSettings.mWillReadFrequently = mWillReadFrequently;
|
||||
|
||||
// We don't support the 'desynchronized' and 'colorSpace' attributes, so
|
||||
// those just keep their default values.
|
||||
}
|
||||
|
||||
CanvasRenderingContext2D::ColorStyleCacheEntry
|
||||
CanvasRenderingContext2D::ParseColorSlow(const nsACString& aString) {
|
||||
ColorStyleCacheEntry result{nsCString(aString)};
|
||||
|
@ -1881,7 +1892,7 @@ CanvasRenderingContext2D::SetContextOptions(JSContext* aCx,
|
|||
// drawtarget yet
|
||||
MOZ_ASSERT(!mTarget);
|
||||
|
||||
ContextAttributes2D attributes;
|
||||
CanvasRenderingContext2DSettings attributes;
|
||||
if (!attributes.Init(aCx, aOptions)) {
|
||||
aRvForDictionaryInit.Throw(NS_ERROR_UNEXPECTED);
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
|
|
@ -96,6 +96,8 @@ class CanvasRenderingContext2D : public nsICanvasRenderingContextInternal,
|
|||
return mCanvasElement->GetOriginalCanvas();
|
||||
}
|
||||
|
||||
void GetContextAttributes(CanvasRenderingContext2DSettings& aSettings) const;
|
||||
|
||||
void OnMemoryPressure() override;
|
||||
void OnBeforePaintTransaction() override;
|
||||
void OnDidPaintTransaction() override;
|
||||
|
|
|
@ -24,11 +24,16 @@ enum CanvasFontVariantCaps { "normal", "small-caps", "all-small-caps", "petite-c
|
|||
enum CanvasTextRendering { "auto", "optimizeSpeed", "optimizeLegibility", "geometricPrecision" };
|
||||
|
||||
[GenerateInit]
|
||||
dictionary ContextAttributes2D {
|
||||
// whether or not we're planning to do a lot of readback operations
|
||||
boolean willReadFrequently = false;
|
||||
dictionary CanvasRenderingContext2DSettings {
|
||||
// signal if the canvas contains an alpha channel
|
||||
boolean alpha = true;
|
||||
|
||||
boolean desynchronized = false;
|
||||
|
||||
PredefinedColorSpace colorSpace = "srgb";
|
||||
|
||||
// whether or not we're planning to do a lot of readback operations
|
||||
boolean willReadFrequently = false;
|
||||
};
|
||||
|
||||
dictionary HitRegionOptions {
|
||||
|
@ -54,6 +59,8 @@ interface CanvasRenderingContext2D {
|
|||
// associated with a canvas.
|
||||
readonly attribute HTMLCanvasElement? canvas;
|
||||
|
||||
CanvasRenderingContext2DSettings getContextAttributes();
|
||||
|
||||
// Show the caret if appropriate when drawing
|
||||
[Func="CanvasUtils::HasDrawWindowPrivilege"]
|
||||
const unsigned long DRAWWINDOW_DRAW_CARET = 0x01;
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
[getContextAttributes.html]
|
||||
expected:
|
||||
if (os == "android") and fission: [OK, TIMEOUT]
|
||||
[Test context creation attributes alpha: true]
|
||||
expected: FAIL
|
||||
|
||||
[Test context creation attributes alpha: false]
|
||||
expected: FAIL
|
||||
|
||||
[Test default context creation attributes]
|
||||
expected: FAIL
|
||||
|
||||
[Test context creation attributes desynchronized: false]
|
||||
expected: FAIL
|
||||
|
||||
[Test context creation attributes willReadFrequently: true]
|
||||
expected: FAIL
|
Загрузка…
Ссылка в новой задаче