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

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 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 FloatSize HTMLCanvasElement::elementSize(const FloatSize&) const 1099 FloatSize HTMLCanvasElement::elementSize(const FloatSize&) const
1100 { 1100 {
1101 return FloatSize(width(), height()); 1101 return FloatSize(width(), height());
1102 } 1102 }
1103 1103
1104 IntSize HTMLCanvasElement::bitmapSourceSize() const 1104 IntSize HTMLCanvasElement::bitmapSourceSize() const
1105 { 1105 {
1106 return IntSize(width(), height()); 1106 return IntSize(width(), height());
1107 } 1107 }
1108 1108
1109 ScriptPromise HTMLCanvasElement::createImageBitmap(ScriptState* scriptState, Eve ntTarget& eventTarget, int sx, int sy, int sw, int sh, const ImageBitmapOptions& options, ExceptionState& exceptionState) 1109 ScriptPromise HTMLCanvasElement::createImageBitmap(ScriptState* scriptState, Eve ntTarget& eventTarget, Optional<IntRect> cropRect, const ImageBitmapOptions& opt ions, ExceptionState& exceptionState)
1110 { 1110 {
1111 DCHECK(eventTarget.toLocalDOMWindow()); 1111 DCHECK(eventTarget.toLocalDOMWindow());
1112 if (!sw || !sh) { 1112 if ((cropRect && !ImageBitmap::isSourceSizeValid(cropRect->width(), cropRect ->height(), exceptionState))
1113 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width")); 1113 || !ImageBitmap::isSourceSizeValid(bitmapSourceSize().width(), bitmapSou rceSize().height(), exceptionState))
1114 return ScriptPromise(); 1114 return ScriptPromise();
1115 } 1115 if (!ImageBitmap::isResizeOptionValid(options, exceptionState))
1116 return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? Im ageBitmap::create(this, IntRect(sx, sy, sw, sh), options) : nullptr); 1116 return ScriptPromise();
1117 return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? Im ageBitmap::create(this, cropRect, options) : nullptr);
1117 } 1118 }
1118 1119
1119 bool HTMLCanvasElement::isOpaque() const 1120 bool HTMLCanvasElement::isOpaque() const
1120 { 1121 {
1121 return m_context && !m_context->hasAlpha(); 1122 return m_context && !m_context->hasAlpha();
1122 } 1123 }
1123 1124
1124 bool HTMLCanvasElement::isSupportedInteractiveCanvasFallback(const Element& elem ent) 1125 bool HTMLCanvasElement::isSupportedInteractiveCanvasFallback(const Element& elem ent)
1125 { 1126 {
1126 if (!element.isDescendantOf(this)) 1127 if (!element.isDescendantOf(this))
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 1196
1196 bool HTMLCanvasElement::createSurfaceLayer() 1197 bool HTMLCanvasElement::createSurfaceLayer()
1197 { 1198 {
1198 DCHECK(!m_surfaceLayerBridge); 1199 DCHECK(!m_surfaceLayerBridge);
1199 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne w CanvasSurfaceLayerBridgeClientImpl()); 1200 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne w CanvasSurfaceLayerBridgeClientImpl());
1200 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri dgeClient))); 1201 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri dgeClient)));
1201 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height( )); 1202 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height( ));
1202 } 1203 }
1203 1204
1204 } // namespace blink 1205 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLCanvasElement.h ('k') | third_party/WebKit/Source/core/html/HTMLImageElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698