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

Unified Diff: Source/core/html/HTMLCanvasElement.cpp

Issue 214963003: Ensured that any failure to create a WebGL context dispatches a webglcontextcreationerror (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed feeback Created 6 years, 9 months 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
« no previous file with comments | « no previous file | Source/core/html/canvas/WebGLRenderingContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLCanvasElement.cpp
diff --git a/Source/core/html/HTMLCanvasElement.cpp b/Source/core/html/HTMLCanvasElement.cpp
index f25930e0ab604ebb22abf0e8d9afc8f76f360279..8c4fd5d7321a6a2ff7693c07fea230531f2ebea6 100644
--- a/Source/core/html/HTMLCanvasElement.cpp
+++ b/Source/core/html/HTMLCanvasElement.cpp
@@ -42,6 +42,7 @@
#include "core/html/canvas/Canvas2DContextAttributes.h"
#include "core/html/canvas/CanvasRenderingContext2D.h"
#include "core/html/canvas/WebGLContextAttributes.h"
+#include "core/html/canvas/WebGLContextEvent.h"
#include "core/html/canvas/WebGLRenderingContext.h"
#include "core/rendering/RenderHTMLCanvas.h"
#include "platform/MIMETypeRegistry.h"
@@ -174,34 +175,33 @@ CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type, Canvas
return m_context.get();
}
- Settings* settings = document().settings();
- if (settings && settings->webGLEnabled()) {
- // Accept the legacy "webkit-3d" name as well as the provisional "experimental-webgl" name.
- // Now that WebGL is ratified, we will also accept "webgl" as the context name in Chrome.
- ContextType contextType;
- bool is3dContext = true;
- if (type == "webkit-3d")
- contextType = ContextWebkit3d;
- else if (type == "experimental-webgl")
- contextType = ContextExperimentalWebgl;
- else if (type == "webgl")
- contextType = ContextWebgl;
- else
- is3dContext = false;
-
- if (is3dContext) {
- if (m_context && !m_context->is3d())
- return 0;
- if (!m_context) {
- blink::Platform::current()->histogramEnumeration("Canvas.ContextType", contextType, ContextTypeCount);
- m_context = WebGLRenderingContext::create(this, static_cast<WebGLContextAttributes*>(attrs));
- if (m_context) {
- scheduleLayerUpdate();
- updateExternallyAllocatedMemory();
- }
+ // Accept the legacy "webkit-3d" name as well as the provisional "experimental-webgl" name.
+ // Now that WebGL is ratified, we will also accept "webgl" as the context name in Chrome.
+ ContextType contextType;
+ bool is3dContext = true;
+ if (type == "webkit-3d")
+ contextType = ContextWebkit3d;
+ else if (type == "experimental-webgl")
+ contextType = ContextExperimentalWebgl;
+ else if (type == "webgl")
+ contextType = ContextWebgl;
+ else
+ is3dContext = false;
+
+ if (is3dContext) {
+ if (m_context && !m_context->is3d()) {
+ dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontextcreationerror, false, true, "Canvas has an existing, non-WebGL context"));
+ return 0;
+ }
+ if (!m_context) {
+ blink::Platform::current()->histogramEnumeration("Canvas.ContextType", contextType, ContextTypeCount);
+ m_context = WebGLRenderingContext::create(this, static_cast<WebGLContextAttributes*>(attrs));
+ if (m_context) {
+ scheduleLayerUpdate();
+ updateExternallyAllocatedMemory();
}
- return m_context.get();
}
+ return m_context.get();
}
return 0;
}
« no previous file with comments | « no previous file | Source/core/html/canvas/WebGLRenderingContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698