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

Side by Side Diff: third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.cpp

Issue 2330553002: Disallow resizing on OffscreenCanvas that has been transferred control from canvas (Closed)
Patch Set: test Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/offscreencanvas/OffscreenCanvas.h" 5 #include "core/offscreencanvas/OffscreenCanvas.h"
6 6
7 #include "core/dom/ExceptionCode.h" 7 #include "core/dom/ExceptionCode.h"
8 #include "core/html/canvas/CanvasContextCreationAttributes.h" 8 #include "core/html/canvas/CanvasContextCreationAttributes.h"
9 #include "core/html/canvas/CanvasRenderingContext.h" 9 #include "core/html/canvas/CanvasRenderingContext.h"
10 #include "core/html/canvas/CanvasRenderingContextFactory.h" 10 #include "core/html/canvas/CanvasRenderingContextFactory.h"
11 #include "platform/graphics/Image.h" 11 #include "platform/graphics/Image.h"
12 #include "platform/graphics/ImageBuffer.h" 12 #include "platform/graphics/ImageBuffer.h"
13 #include "platform/graphics/OffscreenCanvasFrameDispatcherImpl.h" 13 #include "platform/graphics/OffscreenCanvasFrameDispatcherImpl.h"
14 #include "wtf/MathExtras.h" 14 #include "wtf/MathExtras.h"
15 #include <memory> 15 #include <memory>
16 16
17 namespace blink { 17 namespace blink {
18 18
19 OffscreenCanvas::OffscreenCanvas(const IntSize& size) 19 OffscreenCanvas::OffscreenCanvas(const IntSize& size)
20 : m_size(size) 20 : m_size(size)
21 , m_originClean(true) 21 , m_originClean(true)
22 { 22 {
23 } 23 }
24 24
25 OffscreenCanvas* OffscreenCanvas::create(unsigned width, unsigned height) 25 OffscreenCanvas* OffscreenCanvas::create(unsigned width, unsigned height)
26 { 26 {
27 return new OffscreenCanvas(IntSize(clampTo<int>(width), clampTo<int>(height) )); 27 return new OffscreenCanvas(IntSize(clampTo<int>(width), clampTo<int>(height) ));
28 } 28 }
29 29
30 void OffscreenCanvas::setWidth(unsigned width) 30 void OffscreenCanvas::setWidth(unsigned width, ExceptionState& exceptionState)
31 { 31 {
32 // If this OffscreenCanvas is transferred control by an html canvas, 32 // If this OffscreenCanvas is transferred control by an html canvas,
33 // its size is determined by html canvas's size and cannot be resized. 33 // its size is determined by html canvas's size and cannot be resized.
34 if (m_canvasId >= 0) 34 if (m_canvasId >= 0) {
35 exceptionState.throwDOMException(InvalidStateError, "Resizing is not all owed on an OffscreenCanvas that has been transferred control from a canvas.");
35 return; 36 return;
37 }
36 m_size.setWidth(clampTo<int>(width)); 38 m_size.setWidth(clampTo<int>(width));
37 } 39 }
38 40
39 void OffscreenCanvas::setHeight(unsigned height) 41 void OffscreenCanvas::setHeight(unsigned height, ExceptionState& exceptionState)
40 { 42 {
41 // Same comment as above. 43 // Same comment as above.
42 if (m_canvasId >= 0) 44 if (m_canvasId >= 0) {
45 exceptionState.throwDOMException(InvalidStateError, "Resizing is not all owed on an OffscreenCanvas that has been transferred control from a canvas.");
43 return; 46 return;
47 }
44 m_size.setHeight(clampTo<int>(height)); 48 m_size.setHeight(clampTo<int>(height));
45 } 49 }
46 50
47 void OffscreenCanvas::setNeutered() 51 void OffscreenCanvas::setNeutered()
48 { 52 {
49 ASSERT(!m_context); 53 ASSERT(!m_context);
50 m_isNeutered = true; 54 m_isNeutered = true;
51 m_size.setWidth(0); 55 m_size.setWidth(0);
52 m_size.setHeight(0); 56 m_size.setHeight(0);
53 } 57 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 157 }
154 return m_frameDispatcher.get(); 158 return m_frameDispatcher.get();
155 } 159 }
156 160
157 DEFINE_TRACE(OffscreenCanvas) 161 DEFINE_TRACE(OffscreenCanvas)
158 { 162 {
159 visitor->trace(m_context); 163 visitor->trace(m_context);
160 } 164 }
161 165
162 } // namespace blink 166 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698