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

Unified Diff: third_party/WebKit/Source/modules/offscreencanvas/OffscreenCanvas.cpp

Issue 1862033002: Make OffscreenCanvas Transferable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no need to register, taking the same approach as extractTransferables Created 4 years, 8 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
Index: third_party/WebKit/Source/modules/offscreencanvas/OffscreenCanvas.cpp
diff --git a/third_party/WebKit/Source/modules/offscreencanvas/OffscreenCanvas.cpp b/third_party/WebKit/Source/modules/offscreencanvas/OffscreenCanvas.cpp
index 0aedca56e420feed6780983a749a355e6a8f3cd2..435ba369368b3d0818c20fdaa42659c5d45bef5d 100644
--- a/third_party/WebKit/Source/modules/offscreencanvas/OffscreenCanvas.cpp
+++ b/third_party/WebKit/Source/modules/offscreencanvas/OffscreenCanvas.cpp
@@ -35,8 +35,21 @@ void OffscreenCanvas::setHeight(unsigned height)
m_size.setHeight(clampTo<int>(height));
}
-OffscreenCanvasRenderingContext2D* OffscreenCanvas::getContext(const String& id, const CanvasContextCreationAttributes& attributes)
+void OffscreenCanvas::setNeutered()
{
+ ASSERT(!m_context);
+ m_isNeutered = true;
+ m_size.setWidth(0);
+ m_size.setHeight(0);
+}
+
+OffscreenCanvasRenderingContext2D* OffscreenCanvas::getContext(const String& id, const CanvasContextCreationAttributes& attributes, ExceptionState& exceptionState)
+{
+ if (m_isNeutered) {
+ exceptionState.throwDOMException(InvalidStateError, "Cannot get context of a neutered OffscreenCanvas");
+ return nullptr;
+ }
+
OffscreenCanvasRenderingContext::ContextType contextType = OffscreenCanvasRenderingContext::contextTypeFromId(id);
// Unknown type.
@@ -64,6 +77,10 @@ OffscreenCanvasRenderingContext2D* OffscreenCanvas::getContext(const String& id,
ImageBitmap* OffscreenCanvas::transferToImageBitmap(ExceptionState& exceptionState)
{
+ if (m_isNeutered) {
+ exceptionState.throwDOMException(InvalidStateError, "Cannot transfer an ImageBitmap from a neutered OffscreenCanvas");
+ return nullptr;
+ }
if (!m_context) {
exceptionState.throwDOMException(InvalidStateError, "Cannot transfer an ImageBitmap from an OffscreenCanvas with no context");
return nullptr;
@@ -78,6 +95,7 @@ ImageBitmap* OffscreenCanvas::transferToImageBitmap(ExceptionState& exceptionSta
OffscreenCanvasRenderingContext2D* OffscreenCanvas::renderingContext() const
{
+ ASSERT(!m_isNeutered);
// TODO: When there're more than one context type implemented in the future,
// the return type here should be changed to base class of all Offscreen
// context types.
@@ -107,7 +125,6 @@ void OffscreenCanvas::registerRenderingContextFactory(PassOwnPtr<OffscreenCanvas
DEFINE_TRACE(OffscreenCanvas)
{
visitor->trace(m_context);
- visitor->trace(m_canvas);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698