| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.h" | 5 #include "modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.h" |
| 6 | 6 |
| 7 #include "bindings/modules/v8/OffscreenCanvasRenderingContext2DOrWebGLRenderingC
ontextOrWebGL2RenderingContext.h" | 7 #include "bindings/modules/v8/OffscreenCanvasRenderingContext2DOrWebGLRenderingC
ontextOrWebGL2RenderingContext.h" |
| 8 #include "core/frame/ImageBitmap.h" | 8 #include "core/frame/ImageBitmap.h" |
| 9 #include "core/frame/Settings.h" |
| 10 #include "core/workers/WorkerSettings.h" |
| 9 #include "platform/graphics/ImageBuffer.h" | 11 #include "platform/graphics/ImageBuffer.h" |
| 10 #include "platform/graphics/StaticBitmapImage.h" | 12 #include "platform/graphics/StaticBitmapImage.h" |
| 11 #include "wtf/Assertions.h" | 13 #include "wtf/Assertions.h" |
| 12 | 14 |
| 13 #define UNIMPLEMENTED ASSERT_NOT_REACHED | 15 #define UNIMPLEMENTED ASSERT_NOT_REACHED |
| 14 | 16 |
| 15 namespace blink { | 17 namespace blink { |
| 16 | 18 |
| 17 OffscreenCanvasRenderingContext2D::~OffscreenCanvasRenderingContext2D() | 19 OffscreenCanvasRenderingContext2D::~OffscreenCanvasRenderingContext2D() |
| 18 { | 20 { |
| 19 } | 21 } |
| 20 | 22 |
| 21 OffscreenCanvasRenderingContext2D::OffscreenCanvasRenderingContext2D(OffscreenCa
nvas* canvas, const CanvasContextCreationAttributes& attrs) | 23 OffscreenCanvasRenderingContext2D::OffscreenCanvasRenderingContext2D(ScriptState
* scriptState, OffscreenCanvas* canvas, const CanvasContextCreationAttributes& a
ttrs) |
| 22 : CanvasRenderingContext(nullptr, canvas) | 24 : CanvasRenderingContext(nullptr, canvas) |
| 23 , m_hasAlpha(attrs.alpha()) | 25 , m_hasAlpha(attrs.alpha()) |
| 24 { | 26 { |
| 27 ExecutionContext* executionContext = scriptState->getExecutionContext(); |
| 28 if (executionContext->isDocument()) { |
| 29 m_disableReadingFromCanvas = toDocument(executionContext)->settings()->d
isableReadingFromCanvas(); |
| 30 return; |
| 31 } |
| 32 |
| 33 WorkerSettings* workerSettings = WorkerSettings::from(executionContext); |
| 34 if (workerSettings) |
| 35 m_disableReadingFromCanvas = workerSettings->disableReadingFromCanvas(); |
| 36 else |
| 37 m_disableReadingFromCanvas = false; |
| 25 } | 38 } |
| 26 | 39 |
| 27 DEFINE_TRACE(OffscreenCanvasRenderingContext2D) | 40 DEFINE_TRACE(OffscreenCanvasRenderingContext2D) |
| 28 { | 41 { |
| 29 CanvasRenderingContext::trace(visitor); | 42 CanvasRenderingContext::trace(visitor); |
| 30 BaseRenderingContext2D::trace(visitor); | 43 BaseRenderingContext2D::trace(visitor); |
| 31 } | 44 } |
| 32 | 45 |
| 33 // BaseRenderingContext2D implementation | 46 // BaseRenderingContext2D implementation |
| 34 bool OffscreenCanvasRenderingContext2D::originClean() const | 47 bool OffscreenCanvasRenderingContext2D::originClean() const |
| 35 { | 48 { |
| 36 return getOffscreenCanvas()->originClean(); | 49 return getOffscreenCanvas()->originClean() && !m_disableReadingFromCanvas; |
| 37 } | 50 } |
| 38 | 51 |
| 39 void OffscreenCanvasRenderingContext2D::setOriginTainted() | 52 void OffscreenCanvasRenderingContext2D::setOriginTainted() |
| 40 { | 53 { |
| 41 return getOffscreenCanvas()->setOriginTainted(); | 54 return getOffscreenCanvas()->setOriginTainted(); |
| 42 } | 55 } |
| 43 | 56 |
| 44 bool OffscreenCanvasRenderingContext2D::wouldTaintOrigin(CanvasImageSource* sour
ce, ExecutionContext* executionContext) | 57 bool OffscreenCanvasRenderingContext2D::wouldTaintOrigin(CanvasImageSource* sour
ce, ExecutionContext* executionContext) |
| 45 { | 58 { |
| 46 if (executionContext->isWorkerGlobalScope()) { | 59 if (executionContext->isWorkerGlobalScope()) { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 } | 170 } |
| 158 #endif | 171 #endif |
| 159 } | 172 } |
| 160 | 173 |
| 161 bool OffscreenCanvasRenderingContext2D::isContextLost() const | 174 bool OffscreenCanvasRenderingContext2D::isContextLost() const |
| 162 { | 175 { |
| 163 return false; | 176 return false; |
| 164 } | 177 } |
| 165 | 178 |
| 166 } | 179 } |
| OLD | NEW |