Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1172)

Unified Diff: Source/core/html/canvas/CanvasRenderingContext2D.cpp

Issue 795833004: Use dictionaries for context creation attributes. Eliminate custom bindings. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/html/canvas/CanvasRenderingContext2D.cpp
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
index c98b4a4759a096245ce17b716a1df0a8aa002901..92795cecba1e77eaf184ac50d74b1fcb20fb2c6b 100644
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
@@ -90,14 +90,27 @@ static bool contextLostRestoredEventsEnabled()
return RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled();
}
-CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, const Canvas2DContextAttributes* attrs, Document& document)
+static Canvas2DContextStorage storageFromAttributes(const CanvasContextCreationAttributes& attrs)
+{
+ if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled())
+ return PersistentStorage;
+
+ // The other valid option is "persistent" -- but since the default
+ // is Persistent, it isn't necessary to test for it explicitly.
+ if (attrs.hasStorage() && attrs.storage() == "discardable") {
+ return DiscardableStorage;
+ }
+ return PersistentStorage;
+}
+
+CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, const CanvasContextCreationAttributes& attrs, Document& document)
: CanvasRenderingContext(canvas)
, m_usesCSSCompatibilityParseMode(document.inQuirksMode())
, m_clipAntialiasing(NotAntiAliased)
- , m_hasAlpha(!attrs || attrs->alpha())
+ , m_hasAlpha(attrs.alpha())
, m_isContextLost(false)
, m_contextRestorable(true)
- , m_storageMode(!attrs ? PersistentStorage : attrs->parsedStorage())
+ , m_storageMode(storageFromAttributes(attrs))
, m_tryRestoreContextAttemptCount(0)
, m_dispatchContextLostEventTimer(this, &CanvasRenderingContext2D::dispatchContextLostEvent)
, m_dispatchContextRestoredEventTimer(this, &CanvasRenderingContext2D::dispatchContextRestoredEvent)
@@ -2227,11 +2240,12 @@ void CanvasRenderingContext2D::setImageSmoothingEnabled(bool enabled)
c->setImageInterpolationQuality(enabled ? CanvasDefaultInterpolationQuality : InterpolationNone);
}
-PassRefPtrWillBeRawPtr<Canvas2DContextAttributes> CanvasRenderingContext2D::getContextAttributes() const
+void CanvasRenderingContext2D::getContextAttributes(Canvas2DContextAttributes& attrs) const
{
- RefPtrWillBeRawPtr<Canvas2DContextAttributes> attributes = Canvas2DContextAttributes::create();
- attributes->setAlpha(m_hasAlpha);
- return attributes.release();
+ attrs.setAlpha(m_hasAlpha);
+ if (RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled()) {
+ attrs.setStorage(m_storageMode == PersistentStorage ? "persistent" : "discardable");
+ }
}
void CanvasRenderingContext2D::drawFocusIfNeeded(Element* element)

Powered by Google App Engine
This is Rietveld 408576698