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

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

Issue 2515623003: Stop OffscreenCanvas resize from changing placeholder attributes (Closed)
Patch Set: report correct intrinsic size Created 4 years, 1 month 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 return HTMLElement::createLayoutObject(style); 170 return HTMLElement::createLayoutObject(style);
171 } 171 }
172 172
173 Node::InsertionNotificationRequest HTMLCanvasElement::insertedInto( 173 Node::InsertionNotificationRequest HTMLCanvasElement::insertedInto(
174 ContainerNode* node) { 174 ContainerNode* node) {
175 setIsInCanvasSubtree(true); 175 setIsInCanvasSubtree(true);
176 return HTMLElement::insertedInto(node); 176 return HTMLElement::insertedInto(node);
177 } 177 }
178 178
179 void HTMLCanvasElement::setHeight(int value, ExceptionState& exceptionState) { 179 void HTMLCanvasElement::setHeight(int value, ExceptionState& exceptionState) {
180 if (surfaceLayerBridge()) {
181 // The existence of surfaceLayerBridge indicates that
182 // canvas.transferControlToOffscreen has been called.
183 exceptionState.throwDOMException(InvalidStateError,
184 "Resizing is not allowed for a canvas "
185 "that has transferred its control to "
186 "offscreen.");
187 return;
188 }
189 setIntegralAttribute(heightAttr, value); 180 setIntegralAttribute(heightAttr, value);
190 } 181 }
191 182
192 void HTMLCanvasElement::setWidth(int value, ExceptionState& exceptionState) { 183 void HTMLCanvasElement::setWidth(int value, ExceptionState& exceptionState) {
193 if (surfaceLayerBridge()) {
194 // Same comment as above.
195 exceptionState.throwDOMException(InvalidStateError,
196 "Resizing is not allowed for a canvas "
197 "that has transferred its control to "
198 "offscreen.");
199 return;
200 }
201 setIntegralAttribute(widthAttr, value); 184 setIntegralAttribute(widthAttr, value);
202 } 185 }
203 186
204 void HTMLCanvasElement::setSize(const IntSize& newSize) { 187 void HTMLCanvasElement::setSize(const IntSize& newSize) {
205 if (newSize == size()) 188 if (newSize == size())
206 return; 189 return;
207 m_ignoreReset = true; 190 m_ignoreReset = true;
208 setIntegralAttribute(widthAttr, newSize.width()); 191 setIntegralAttribute(widthAttr, newSize.width());
209 setIntegralAttribute(heightAttr, newSize.height()); 192 setIntegralAttribute(heightAttr, newSize.height());
210 m_ignoreReset = false; 193 m_ignoreReset = false;
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 FloatSize HTMLCanvasElement::elementSize(const FloatSize&) const { 1242 FloatSize HTMLCanvasElement::elementSize(const FloatSize&) const {
1260 if (m_context && 1243 if (m_context &&
1261 m_context->getContextType() == 1244 m_context->getContextType() ==
1262 CanvasRenderingContext::ContextImageBitmap) { 1245 CanvasRenderingContext::ContextImageBitmap) {
1263 RefPtr<Image> image = 1246 RefPtr<Image> image =
1264 m_context->getImage(PreferNoAcceleration, SnapshotReasonDrawImage); 1247 m_context->getImage(PreferNoAcceleration, SnapshotReasonDrawImage);
1265 if (image) 1248 if (image)
1266 return FloatSize(image->width(), image->height()); 1249 return FloatSize(image->width(), image->height());
1267 return FloatSize(0, 0); 1250 return FloatSize(0, 0);
1268 } 1251 }
1252 if (placeholderFrame())
1253 return FloatSize(placeholderFrame()->size());
1269 return FloatSize(width(), height()); 1254 return FloatSize(width(), height());
1270 } 1255 }
1271 1256
1272 IntSize HTMLCanvasElement::bitmapSourceSize() const { 1257 IntSize HTMLCanvasElement::bitmapSourceSize() const {
1273 return IntSize(width(), height()); 1258 return IntSize(width(), height());
1274 } 1259 }
1275 1260
1276 ScriptPromise HTMLCanvasElement::createImageBitmap( 1261 ScriptPromise HTMLCanvasElement::createImageBitmap(
1277 ScriptState* scriptState, 1262 ScriptState* scriptState,
1278 EventTarget& eventTarget, 1263 EventTarget& eventTarget,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 mojom::blink::OffscreenCanvasSurfacePtr service; 1368 mojom::blink::OffscreenCanvasSurfacePtr service;
1384 Platform::current()->interfaceProvider()->getInterface( 1369 Platform::current()->interfaceProvider()->getInterface(
1385 mojo::GetProxy(&service)); 1370 mojo::GetProxy(&service));
1386 m_surfaceLayerBridge = 1371 m_surfaceLayerBridge =
1387 wrapUnique(new CanvasSurfaceLayerBridge(std::move(service))); 1372 wrapUnique(new CanvasSurfaceLayerBridge(std::move(service)));
1388 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), 1373 return m_surfaceLayerBridge->createSurfaceLayer(this->width(),
1389 this->height()); 1374 this->height());
1390 } 1375 }
1391 1376
1392 } // namespace blink 1377 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698