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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp

Issue 2035113002: Implement ImageBitmapOptions resize (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 5 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 /* 1 /*
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 } 1101 }
1102 1102
1103 IntSize HTMLCanvasElement::bitmapSourceSize() const 1103 IntSize HTMLCanvasElement::bitmapSourceSize() const
1104 { 1104 {
1105 return IntSize(width(), height()); 1105 return IntSize(width(), height());
1106 } 1106 }
1107 1107
1108 ScriptPromise HTMLCanvasElement::createImageBitmap(ScriptState* scriptState, Eve ntTarget& eventTarget, int sx, int sy, int sw, int sh, const ImageBitmapOptions& options, ExceptionState& exceptionState) 1108 ScriptPromise HTMLCanvasElement::createImageBitmap(ScriptState* scriptState, Eve ntTarget& eventTarget, int sx, int sy, int sw, int sh, const ImageBitmapOptions& options, ExceptionState& exceptionState)
1109 { 1109 {
1110 DCHECK(eventTarget.toLocalDOMWindow()); 1110 DCHECK(eventTarget.toLocalDOMWindow());
1111 if (!sw || !sh) { 1111 if (!ImageBitmap::isSWSHValid(sw, sh, exceptionState))
1112 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width"));
1113 return ScriptPromise(); 1112 return ScriptPromise();
1114 } 1113 if (!ImageBitmap::isResizeOptionValid(options, exceptionState))
1114 return ScriptPromise();
1115 return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? Im ageBitmap::create(this, IntRect(sx, sy, sw, sh), options) : nullptr); 1115 return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? Im ageBitmap::create(this, IntRect(sx, sy, sw, sh), options) : nullptr);
1116 } 1116 }
1117 1117
1118 bool HTMLCanvasElement::isOpaque() const 1118 bool HTMLCanvasElement::isOpaque() const
1119 { 1119 {
1120 return m_context && !m_context->hasAlpha(); 1120 return m_context && !m_context->hasAlpha();
1121 } 1121 }
1122 1122
1123 bool HTMLCanvasElement::isSupportedInteractiveCanvasFallback(const Element& elem ent) 1123 bool HTMLCanvasElement::isSupportedInteractiveCanvasFallback(const Element& elem ent)
1124 { 1124 {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 1194
1195 bool HTMLCanvasElement::createSurfaceLayer() 1195 bool HTMLCanvasElement::createSurfaceLayer()
1196 { 1196 {
1197 DCHECK(!m_surfaceLayerBridge); 1197 DCHECK(!m_surfaceLayerBridge);
1198 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne w CanvasSurfaceLayerBridgeClientImpl()); 1198 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne w CanvasSurfaceLayerBridgeClientImpl());
1199 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri dgeClient))); 1199 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri dgeClient)));
1200 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height( )); 1200 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height( ));
1201 } 1201 }
1202 1202
1203 } // namespace blink 1203 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698