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

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

Issue 2520973002: Fix a small error in exception handling in convertToBlob (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/security/cross-origin-OffscreenCanvas2D-convertToBlob.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/fileapi/Blob.h" 8 #include "core/fileapi/Blob.h"
9 #include "core/html/ImageData.h" 9 #include "core/html/ImageData.h"
10 #include "core/html/canvas/CanvasAsyncBlobCreator.h" 10 #include "core/html/canvas/CanvasAsyncBlobCreator.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 "OffscreenCanvas object is detached."); 196 "OffscreenCanvas object is detached.");
197 return exceptionState.reject(scriptState); 197 return exceptionState.reject(scriptState);
198 } 198 }
199 199
200 if (!this->originClean()) { 200 if (!this->originClean()) {
201 exceptionState.throwSecurityError( 201 exceptionState.throwSecurityError(
202 "Tainted OffscreenCanvas may not be exported."); 202 "Tainted OffscreenCanvas may not be exported.");
203 return exceptionState.reject(scriptState); 203 return exceptionState.reject(scriptState);
204 } 204 }
205 205
206 if (!width() || !height()) {
207 exceptionState.throwDOMException(
208 IndexSizeError, "Zero-sized OffscreenCanvas cannot be transferred.");
xlai (Olivia) 2016/11/21 16:34:00 Also, change the error msg. I think it has nothing
xidachen 2016/11/21 16:40:28 Done.
209 return exceptionState.reject(scriptState);
210 }
211
206 if (!this->isPaintable()) { 212 if (!this->isPaintable()) {
207 return ScriptPromise(); 213 return ScriptPromise();
xlai (Olivia) 2016/11/21 16:34:00 Actually, the third case is already handled in thi
xidachen 2016/11/21 16:40:28 Done, makes perfect sense.
208 } 214 }
209 215
210 double startTime = WTF::monotonicallyIncreasingTime(); 216 double startTime = WTF::monotonicallyIncreasingTime();
211 String encodingMimeType = ImageEncoderUtils::toEncodingMimeType( 217 String encodingMimeType = ImageEncoderUtils::toEncodingMimeType(
212 options.type(), ImageEncoderUtils::EncodeReasonConvertToBlobPromise); 218 options.type(), ImageEncoderUtils::EncodeReasonConvertToBlobPromise);
213 219
214 ImageData* imageData = nullptr; 220 ImageData* imageData = nullptr;
215 if (this->renderingContext()) { 221 if (this->renderingContext()) {
216 imageData = this->renderingContext()->toImageData(SnapshotReasonUnknown); 222 imageData = this->renderingContext()->toImageData(SnapshotReasonUnknown);
217 } 223 }
(...skipping 17 matching lines...) Expand all
235 return resolver->promise(); 241 return resolver->promise();
236 } 242 }
237 243
238 DEFINE_TRACE(OffscreenCanvas) { 244 DEFINE_TRACE(OffscreenCanvas) {
239 visitor->trace(m_context); 245 visitor->trace(m_context);
240 visitor->trace(m_executionContext); 246 visitor->trace(m_executionContext);
241 EventTarget::trace(visitor); 247 EventTarget::trace(visitor);
242 } 248 }
243 249
244 } // namespace blink 250 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/security/cross-origin-OffscreenCanvas2D-convertToBlob.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698