Index: Source/core/html/HTMLCanvasElement.cpp |
diff --git a/Source/core/html/HTMLCanvasElement.cpp b/Source/core/html/HTMLCanvasElement.cpp |
index 05e2a22819dca4e956262e159244bbb40eaf5844..7688ee8cc97607cdd032339b498e3b21d7dc2086 100644 |
--- a/Source/core/html/HTMLCanvasElement.cpp |
+++ b/Source/core/html/HTMLCanvasElement.cpp |
@@ -170,7 +170,7 @@ void HTMLCanvasElement::setWidth(int value) |
setIntegralAttribute(widthAttr, value); |
} |
-CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type, CanvasContextAttributes* attrs) |
+void HTMLCanvasElement::getContext(const String& type, const CanvasContextCreationAttributes& attributes, CanvasRenderingContext2DOrWebGLRenderingContext& result) |
{ |
// A Canvas can either be "2D" or "webgl" but never both. If you request a 2D canvas and the existing |
// context is already 2D, just return that. If the existing context is WebGL, then destroy it |
@@ -189,14 +189,15 @@ CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type, Canvas |
// once it is created. |
if (type == "2d") { |
if (m_context && !m_context->is2d()) |
- return nullptr; |
+ return; |
if (!m_context) { |
blink::Platform::current()->histogramEnumeration("Canvas.ContextType", Context2d, ContextTypeCount); |
- m_context = CanvasRenderingContext2D::create(this, static_cast<Canvas2DContextAttributes*>(attrs), document()); |
+ m_context = CanvasRenderingContext2D::create(this, attributes, document()); |
setNeedsCompositingUpdate(); |
} |
- return m_context.get(); |
+ result.setCanvasRenderingContext2D(static_cast<CanvasRenderingContext2D*>(m_context.get())); |
+ return; |
} |
// Accept the the provisional "experimental-webgl" or official "webgl" context ID. |
@@ -204,17 +205,17 @@ CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type, Canvas |
ContextType contextType = (type == "webgl") ? ContextWebgl : ContextExperimentalWebgl; |
if (!m_context) { |
blink::Platform::current()->histogramEnumeration("Canvas.ContextType", contextType, ContextTypeCount); |
- m_context = WebGLRenderingContext::create(this, static_cast<WebGLContextAttributes*>(attrs)); |
+ m_context = WebGLRenderingContext::create(this, attributes); |
setNeedsCompositingUpdate(); |
updateExternallyAllocatedMemory(); |
} else if (!m_context->is3d()) { |
dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontextcreationerror, false, true, "Canvas has an existing, non-WebGL context")); |
- return nullptr; |
+ return; |
} |
- return m_context.get(); |
+ result.setWebGLRenderingContext(static_cast<WebGLRenderingContext*>(m_context.get())); |
} |
- return nullptr; |
+ return; |
} |
bool HTMLCanvasElement::isPaintable() const |