| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
| 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
| 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
| 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> |
| 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
| 8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. | 8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. |
| 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
| 10 * | 10 * |
| (...skipping 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 if (computeDirtyRect(dstRect, &dirtyRect)) { | 1277 if (computeDirtyRect(dstRect, &dirtyRect)) { |
| 1278 c->drawImage(image, dstRect, srcRect, op, blendMode); | 1278 c->drawImage(image, dstRect, srcRect, op, blendMode); |
| 1279 didDraw(dirtyRect); | 1279 didDraw(dirtyRect); |
| 1280 } | 1280 } |
| 1281 } | 1281 } |
| 1282 } | 1282 } |
| 1283 | 1283 |
| 1284 void CanvasRenderingContext2D::drawImage(ImageBitmap* bitmap, float x, float y,
ExceptionState& es) | 1284 void CanvasRenderingContext2D::drawImage(ImageBitmap* bitmap, float x, float y,
ExceptionState& es) |
| 1285 { | 1285 { |
| 1286 if (!bitmap) { | 1286 if (!bitmap) { |
| 1287 es.throwDOMException(TypeMismatchError); | 1287 es.throwUninformativeAndGenericDOMException(TypeMismatchError); |
| 1288 return; | 1288 return; |
| 1289 } | 1289 } |
| 1290 drawImage(bitmap, x, y, bitmap->width(), bitmap->height(), es); | 1290 drawImage(bitmap, x, y, bitmap->width(), bitmap->height(), es); |
| 1291 } | 1291 } |
| 1292 | 1292 |
| 1293 void CanvasRenderingContext2D::drawImage(ImageBitmap* bitmap, | 1293 void CanvasRenderingContext2D::drawImage(ImageBitmap* bitmap, |
| 1294 float x, float y, float width, float height, ExceptionState& es) | 1294 float x, float y, float width, float height, ExceptionState& es) |
| 1295 { | 1295 { |
| 1296 if (!bitmap) { | 1296 if (!bitmap) { |
| 1297 es.throwDOMException(TypeMismatchError); | 1297 es.throwUninformativeAndGenericDOMException(TypeMismatchError); |
| 1298 return; | 1298 return; |
| 1299 } | 1299 } |
| 1300 if (!bitmap->bitmapRect().width() || !bitmap->bitmapRect().height()) | 1300 if (!bitmap->bitmapRect().width() || !bitmap->bitmapRect().height()) |
| 1301 return; | 1301 return; |
| 1302 | 1302 |
| 1303 drawImage(bitmap, 0, 0, bitmap->width(), bitmap->height(), x, y, width, heig
ht, es); | 1303 drawImage(bitmap, 0, 0, bitmap->width(), bitmap->height(), x, y, width, heig
ht, es); |
| 1304 } | 1304 } |
| 1305 | 1305 |
| 1306 void CanvasRenderingContext2D::drawImage(ImageBitmap* bitmap, | 1306 void CanvasRenderingContext2D::drawImage(ImageBitmap* bitmap, |
| 1307 float sx, float sy, float sw, float sh, | 1307 float sx, float sy, float sw, float sh, |
| 1308 float dx, float dy, float dw, float dh, ExceptionState& es) | 1308 float dx, float dy, float dw, float dh, ExceptionState& es) |
| 1309 { | 1309 { |
| 1310 if (!bitmap) { | 1310 if (!bitmap) { |
| 1311 es.throwDOMException(TypeMismatchError); | 1311 es.throwUninformativeAndGenericDOMException(TypeMismatchError); |
| 1312 return; | 1312 return; |
| 1313 } | 1313 } |
| 1314 | 1314 |
| 1315 FloatRect srcRect(sx, sy, sw, sh); | 1315 FloatRect srcRect(sx, sy, sw, sh); |
| 1316 FloatRect dstRect(dx, dy, dw, dh); | 1316 FloatRect dstRect(dx, dy, dw, dh); |
| 1317 FloatRect bitmapRect = bitmap->bitmapRect(); | 1317 FloatRect bitmapRect = bitmap->bitmapRect(); |
| 1318 | 1318 |
| 1319 if (!std::isfinite(dstRect.x()) || !std::isfinite(dstRect.y()) || !std::isfi
nite(dstRect.width()) || !std::isfinite(dstRect.height()) | 1319 if (!std::isfinite(dstRect.x()) || !std::isfinite(dstRect.y()) || !std::isfi
nite(dstRect.width()) || !std::isfinite(dstRect.height()) |
| 1320 || !std::isfinite(srcRect.x()) || !std::isfinite(srcRect.y()) || !std::i
sfinite(srcRect.width()) || !std::isfinite(srcRect.height())) | 1320 || !std::isfinite(srcRect.x()) || !std::isfinite(srcRect.y()) || !std::i
sfinite(srcRect.width()) || !std::isfinite(srcRect.height())) |
| 1321 return; | 1321 return; |
| 1322 | 1322 |
| 1323 if (!dstRect.width() || !dstRect.height()) | 1323 if (!dstRect.width() || !dstRect.height()) |
| 1324 return; | 1324 return; |
| 1325 if (!srcRect.width() || !srcRect.height()) { | 1325 if (!srcRect.width() || !srcRect.height()) { |
| 1326 es.throwDOMException(IndexSizeError); | 1326 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 1327 return; | 1327 return; |
| 1328 } | 1328 } |
| 1329 | 1329 |
| 1330 ASSERT(bitmap->height() && bitmap->width()); | 1330 ASSERT(bitmap->height() && bitmap->width()); |
| 1331 FloatRect normalizedSrcRect = normalizeRect(srcRect); | 1331 FloatRect normalizedSrcRect = normalizeRect(srcRect); |
| 1332 FloatRect normalizedDstRect = normalizeRect(dstRect); | 1332 FloatRect normalizedDstRect = normalizeRect(dstRect); |
| 1333 | 1333 |
| 1334 // Clip the rects to where the user thinks that the image is situated. | 1334 // Clip the rects to where the user thinks that the image is situated. |
| 1335 clipRectsToImageRect(IntRect(IntPoint(), bitmap->size()), &normalizedSrcRect
, &normalizedDstRect); | 1335 clipRectsToImageRect(IntRect(IntPoint(), bitmap->size()), &normalizedSrcRect
, &normalizedDstRect); |
| 1336 | 1336 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1352 RefPtr<Image> imageForRendering = bitmap->bitmapImage(); | 1352 RefPtr<Image> imageForRendering = bitmap->bitmapImage(); |
| 1353 if (!imageForRendering) | 1353 if (!imageForRendering) |
| 1354 return; | 1354 return; |
| 1355 | 1355 |
| 1356 drawImageInternal(imageForRendering.get(), actualSrcRect, actualDstRect, sta
te().m_globalComposite, state().m_globalBlend); | 1356 drawImageInternal(imageForRendering.get(), actualSrcRect, actualDstRect, sta
te().m_globalComposite, state().m_globalBlend); |
| 1357 } | 1357 } |
| 1358 | 1358 |
| 1359 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, float x, float
y, ExceptionState& es) | 1359 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, float x, float
y, ExceptionState& es) |
| 1360 { | 1360 { |
| 1361 if (!image) { | 1361 if (!image) { |
| 1362 es.throwDOMException(TypeMismatchError); | 1362 es.throwUninformativeAndGenericDOMException(TypeMismatchError); |
| 1363 return; | 1363 return; |
| 1364 } | 1364 } |
| 1365 LayoutSize size = sizeFor(image); | 1365 LayoutSize size = sizeFor(image); |
| 1366 drawImage(image, x, y, size.width(), size.height(), es); | 1366 drawImage(image, x, y, size.width(), size.height(), es); |
| 1367 } | 1367 } |
| 1368 | 1368 |
| 1369 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, | 1369 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, |
| 1370 float x, float y, float width, float height, ExceptionState& es) | 1370 float x, float y, float width, float height, ExceptionState& es) |
| 1371 { | 1371 { |
| 1372 if (!image) { | 1372 if (!image) { |
| 1373 es.throwDOMException(TypeMismatchError); | 1373 es.throwUninformativeAndGenericDOMException(TypeMismatchError); |
| 1374 return; | 1374 return; |
| 1375 } | 1375 } |
| 1376 LayoutSize size = sizeFor(image); | 1376 LayoutSize size = sizeFor(image); |
| 1377 drawImage(image, FloatRect(0, 0, size.width(), size.height()), FloatRect(x,
y, width, height), es); | 1377 drawImage(image, FloatRect(0, 0, size.width(), size.height()), FloatRect(x,
y, width, height), es); |
| 1378 } | 1378 } |
| 1379 | 1379 |
| 1380 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, | 1380 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, |
| 1381 float sx, float sy, float sw, float sh, | 1381 float sx, float sy, float sw, float sh, |
| 1382 float dx, float dy, float dw, float dh, ExceptionState& es) | 1382 float dx, float dy, float dw, float dh, ExceptionState& es) |
| 1383 { | 1383 { |
| 1384 drawImage(image, FloatRect(sx, sy, sw, sh), FloatRect(dx, dy, dw, dh), es); | 1384 drawImage(image, FloatRect(sx, sy, sw, sh), FloatRect(dx, dy, dw, dh), es); |
| 1385 } | 1385 } |
| 1386 | 1386 |
| 1387 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, const FloatRec
t& srcRect, const FloatRect& dstRect, ExceptionState& es) | 1387 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, const FloatRec
t& srcRect, const FloatRect& dstRect, ExceptionState& es) |
| 1388 { | 1388 { |
| 1389 drawImage(image, srcRect, dstRect, state().m_globalComposite, state().m_glob
alBlend, es); | 1389 drawImage(image, srcRect, dstRect, state().m_globalComposite, state().m_glob
alBlend, es); |
| 1390 } | 1390 } |
| 1391 | 1391 |
| 1392 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, const FloatRec
t& srcRect, const FloatRect& dstRect, const CompositeOperator& op, const BlendMo
de& blendMode, ExceptionState& es) | 1392 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, const FloatRec
t& srcRect, const FloatRect& dstRect, const CompositeOperator& op, const BlendMo
de& blendMode, ExceptionState& es) |
| 1393 { | 1393 { |
| 1394 if (!image) { | 1394 if (!image) { |
| 1395 es.throwDOMException(TypeMismatchError); | 1395 es.throwUninformativeAndGenericDOMException(TypeMismatchError); |
| 1396 return; | 1396 return; |
| 1397 } | 1397 } |
| 1398 | 1398 |
| 1399 if (!std::isfinite(dstRect.x()) || !std::isfinite(dstRect.y()) || !std::isfi
nite(dstRect.width()) || !std::isfinite(dstRect.height()) | 1399 if (!std::isfinite(dstRect.x()) || !std::isfinite(dstRect.y()) || !std::isfi
nite(dstRect.width()) || !std::isfinite(dstRect.height()) |
| 1400 || !std::isfinite(srcRect.x()) || !std::isfinite(srcRect.y()) || !std::i
sfinite(srcRect.width()) || !std::isfinite(srcRect.height())) | 1400 || !std::isfinite(srcRect.x()) || !std::isfinite(srcRect.y()) || !std::i
sfinite(srcRect.width()) || !std::isfinite(srcRect.height())) |
| 1401 return; | 1401 return; |
| 1402 | 1402 |
| 1403 ImageResource* cachedImage = image->cachedImage(); | 1403 ImageResource* cachedImage = image->cachedImage(); |
| 1404 if (!cachedImage || !image->complete()) | 1404 if (!cachedImage || !image->complete()) |
| 1405 return; | 1405 return; |
| 1406 | 1406 |
| 1407 LayoutSize size = sizeFor(image); | 1407 LayoutSize size = sizeFor(image); |
| 1408 if (!size.width() || !size.height()) { | 1408 if (!size.width() || !size.height()) { |
| 1409 es.throwDOMException(InvalidStateError); | 1409 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
| 1410 return; | 1410 return; |
| 1411 } | 1411 } |
| 1412 | 1412 |
| 1413 if (!dstRect.width() || !dstRect.height()) | 1413 if (!dstRect.width() || !dstRect.height()) |
| 1414 return; | 1414 return; |
| 1415 | 1415 |
| 1416 FloatRect normalizedSrcRect = normalizeRect(srcRect); | 1416 FloatRect normalizedSrcRect = normalizeRect(srcRect); |
| 1417 FloatRect normalizedDstRect = normalizeRect(dstRect); | 1417 FloatRect normalizedDstRect = normalizeRect(dstRect); |
| 1418 | 1418 |
| 1419 FloatRect imageRect = FloatRect(FloatPoint(), size); | 1419 FloatRect imageRect = FloatRect(FloatPoint(), size); |
| 1420 if (!srcRect.width() || !srcRect.height()) { | 1420 if (!srcRect.width() || !srcRect.height()) { |
| 1421 es.throwDOMException(IndexSizeError); | 1421 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 1422 return; | 1422 return; |
| 1423 } | 1423 } |
| 1424 if (!imageRect.intersects(normalizedSrcRect)) | 1424 if (!imageRect.intersects(normalizedSrcRect)) |
| 1425 return; | 1425 return; |
| 1426 | 1426 |
| 1427 clipRectsToImageRect(imageRect, &normalizedSrcRect, &normalizedDstRect); | 1427 clipRectsToImageRect(imageRect, &normalizedSrcRect, &normalizedDstRect); |
| 1428 | 1428 |
| 1429 checkOrigin(image); | 1429 checkOrigin(image); |
| 1430 | 1430 |
| 1431 Image* imageForRendering = cachedImage->imageForRenderer(image->renderer()); | 1431 Image* imageForRendering = cachedImage->imageForRenderer(image->renderer()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1454 float sx, float sy, float sw, float sh, | 1454 float sx, float sy, float sw, float sh, |
| 1455 float dx, float dy, float dw, float dh, ExceptionState& es) | 1455 float dx, float dy, float dw, float dh, ExceptionState& es) |
| 1456 { | 1456 { |
| 1457 drawImage(sourceCanvas, FloatRect(sx, sy, sw, sh), FloatRect(dx, dy, dw, dh)
, es); | 1457 drawImage(sourceCanvas, FloatRect(sx, sy, sw, sh), FloatRect(dx, dy, dw, dh)
, es); |
| 1458 } | 1458 } |
| 1459 | 1459 |
| 1460 void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* sourceCanvas, const
FloatRect& srcRect, | 1460 void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* sourceCanvas, const
FloatRect& srcRect, |
| 1461 const FloatRect& dstRect, ExceptionState& es) | 1461 const FloatRect& dstRect, ExceptionState& es) |
| 1462 { | 1462 { |
| 1463 if (!sourceCanvas) { | 1463 if (!sourceCanvas) { |
| 1464 es.throwDOMException(TypeMismatchError); | 1464 es.throwUninformativeAndGenericDOMException(TypeMismatchError); |
| 1465 return; | 1465 return; |
| 1466 } | 1466 } |
| 1467 | 1467 |
| 1468 FloatRect srcCanvasRect = FloatRect(FloatPoint(), sourceCanvas->size()); | 1468 FloatRect srcCanvasRect = FloatRect(FloatPoint(), sourceCanvas->size()); |
| 1469 | 1469 |
| 1470 if (!srcCanvasRect.width() || !srcCanvasRect.height()) { | 1470 if (!srcCanvasRect.width() || !srcCanvasRect.height()) { |
| 1471 es.throwDOMException(InvalidStateError); | 1471 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
| 1472 return; | 1472 return; |
| 1473 } | 1473 } |
| 1474 | 1474 |
| 1475 if (!srcRect.width() || !srcRect.height()) { | 1475 if (!srcRect.width() || !srcRect.height()) { |
| 1476 es.throwDOMException(IndexSizeError); | 1476 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 1477 return; | 1477 return; |
| 1478 } | 1478 } |
| 1479 | 1479 |
| 1480 FloatRect normalizedSrcRect = normalizeRect(srcRect); | 1480 FloatRect normalizedSrcRect = normalizeRect(srcRect); |
| 1481 FloatRect normalizedDstRect = normalizeRect(dstRect); | 1481 FloatRect normalizedDstRect = normalizeRect(dstRect); |
| 1482 | 1482 |
| 1483 if (!srcCanvasRect.intersects(normalizedSrcRect) || !normalizedDstRect.width
() || !normalizedDstRect.height()) | 1483 if (!srcCanvasRect.intersects(normalizedSrcRect) || !normalizedDstRect.width
() || !normalizedDstRect.height()) |
| 1484 return; | 1484 return; |
| 1485 | 1485 |
| 1486 clipRectsToImageRect(srcCanvasRect, &normalizedSrcRect, &normalizedDstRect); | 1486 clipRectsToImageRect(srcCanvasRect, &normalizedSrcRect, &normalizedDstRect); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1524 if (computeDirtyRect(normalizedDstRect, clipBounds, &dirtyRect)) { | 1524 if (computeDirtyRect(normalizedDstRect, clipBounds, &dirtyRect)) { |
| 1525 c->drawImageBuffer(buffer, normalizedDstRect, normalizedSrcRect, sta
te().m_globalComposite, state().m_globalBlend); | 1525 c->drawImageBuffer(buffer, normalizedDstRect, normalizedSrcRect, sta
te().m_globalComposite, state().m_globalBlend); |
| 1526 didDraw(dirtyRect); | 1526 didDraw(dirtyRect); |
| 1527 } | 1527 } |
| 1528 } | 1528 } |
| 1529 } | 1529 } |
| 1530 | 1530 |
| 1531 void CanvasRenderingContext2D::drawImage(HTMLVideoElement* video, float x, float
y, ExceptionState& es) | 1531 void CanvasRenderingContext2D::drawImage(HTMLVideoElement* video, float x, float
y, ExceptionState& es) |
| 1532 { | 1532 { |
| 1533 if (!video) { | 1533 if (!video) { |
| 1534 es.throwDOMException(TypeMismatchError); | 1534 es.throwUninformativeAndGenericDOMException(TypeMismatchError); |
| 1535 return; | 1535 return; |
| 1536 } | 1536 } |
| 1537 IntSize size = sizeFor(video); | 1537 IntSize size = sizeFor(video); |
| 1538 drawImage(video, x, y, size.width(), size.height(), es); | 1538 drawImage(video, x, y, size.width(), size.height(), es); |
| 1539 } | 1539 } |
| 1540 | 1540 |
| 1541 void CanvasRenderingContext2D::drawImage(HTMLVideoElement* video, | 1541 void CanvasRenderingContext2D::drawImage(HTMLVideoElement* video, |
| 1542 float x, float y, float width, float height, ExceptionState& es) | 1542 float x, float y, float width, float height, ExceptionState& es) |
| 1543 { | 1543 { |
| 1544 if (!video) { | 1544 if (!video) { |
| 1545 es.throwDOMException(TypeMismatchError); | 1545 es.throwUninformativeAndGenericDOMException(TypeMismatchError); |
| 1546 return; | 1546 return; |
| 1547 } | 1547 } |
| 1548 IntSize size = sizeFor(video); | 1548 IntSize size = sizeFor(video); |
| 1549 drawImage(video, FloatRect(0, 0, size.width(), size.height()), FloatRect(x,
y, width, height), es); | 1549 drawImage(video, FloatRect(0, 0, size.width(), size.height()), FloatRect(x,
y, width, height), es); |
| 1550 } | 1550 } |
| 1551 | 1551 |
| 1552 void CanvasRenderingContext2D::drawImage(HTMLVideoElement* video, | 1552 void CanvasRenderingContext2D::drawImage(HTMLVideoElement* video, |
| 1553 float sx, float sy, float sw, float sh, | 1553 float sx, float sy, float sw, float sh, |
| 1554 float dx, float dy, float dw, float dh, ExceptionState& es) | 1554 float dx, float dy, float dw, float dh, ExceptionState& es) |
| 1555 { | 1555 { |
| 1556 drawImage(video, FloatRect(sx, sy, sw, sh), FloatRect(dx, dy, dw, dh), es); | 1556 drawImage(video, FloatRect(sx, sy, sw, sh), FloatRect(dx, dy, dw, dh), es); |
| 1557 } | 1557 } |
| 1558 | 1558 |
| 1559 void CanvasRenderingContext2D::drawImage(HTMLVideoElement* video, const FloatRec
t& srcRect, const FloatRect& dstRect, ExceptionState& es) | 1559 void CanvasRenderingContext2D::drawImage(HTMLVideoElement* video, const FloatRec
t& srcRect, const FloatRect& dstRect, ExceptionState& es) |
| 1560 { | 1560 { |
| 1561 if (!video) { | 1561 if (!video) { |
| 1562 es.throwDOMException(TypeMismatchError); | 1562 es.throwUninformativeAndGenericDOMException(TypeMismatchError); |
| 1563 return; | 1563 return; |
| 1564 } | 1564 } |
| 1565 | 1565 |
| 1566 if (video->readyState() == HTMLMediaElement::HAVE_NOTHING || video->readySta
te() == HTMLMediaElement::HAVE_METADATA) | 1566 if (video->readyState() == HTMLMediaElement::HAVE_NOTHING || video->readySta
te() == HTMLMediaElement::HAVE_METADATA) |
| 1567 return; | 1567 return; |
| 1568 | 1568 |
| 1569 FloatRect videoRect = FloatRect(FloatPoint(), sizeFor(video)); | 1569 FloatRect videoRect = FloatRect(FloatPoint(), sizeFor(video)); |
| 1570 if (!srcRect.width() || !srcRect.height()) { | 1570 if (!srcRect.width() || !srcRect.height()) { |
| 1571 es.throwDOMException(IndexSizeError); | 1571 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 1572 return; | 1572 return; |
| 1573 } | 1573 } |
| 1574 | 1574 |
| 1575 FloatRect normalizedSrcRect = normalizeRect(srcRect); | 1575 FloatRect normalizedSrcRect = normalizeRect(srcRect); |
| 1576 FloatRect normalizedDstRect = normalizeRect(dstRect); | 1576 FloatRect normalizedDstRect = normalizeRect(dstRect); |
| 1577 | 1577 |
| 1578 if (!videoRect.intersects(normalizedSrcRect) || !normalizedDstRect.width() |
| !normalizedDstRect.height()) | 1578 if (!videoRect.intersects(normalizedSrcRect) || !normalizedDstRect.width() |
| !normalizedDstRect.height()) |
| 1579 return; | 1579 return; |
| 1580 | 1580 |
| 1581 clipRectsToImageRect(videoRect, &normalizedSrcRect, &normalizedDstRect); | 1581 clipRectsToImageRect(videoRect, &normalizedSrcRect, &normalizedDstRect); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1685 CompositeOperator previousOperator = c->compositeOperation(); | 1685 CompositeOperator previousOperator = c->compositeOperation(); |
| 1686 c->setCompositeOperation(CompositeSourceOver); | 1686 c->setCompositeOperation(CompositeSourceOver); |
| 1687 fillPrimitive(area, c); | 1687 fillPrimitive(area, c); |
| 1688 c->setCompositeOperation(previousOperator); | 1688 c->setCompositeOperation(previousOperator); |
| 1689 c->endLayer(); | 1689 c->endLayer(); |
| 1690 } | 1690 } |
| 1691 | 1691 |
| 1692 PassRefPtr<CanvasGradient> CanvasRenderingContext2D::createLinearGradient(float
x0, float y0, float x1, float y1, ExceptionState& es) | 1692 PassRefPtr<CanvasGradient> CanvasRenderingContext2D::createLinearGradient(float
x0, float y0, float x1, float y1, ExceptionState& es) |
| 1693 { | 1693 { |
| 1694 if (!std::isfinite(x0) || !std::isfinite(y0) || !std::isfinite(x1) || !std::
isfinite(y1)) { | 1694 if (!std::isfinite(x0) || !std::isfinite(y0) || !std::isfinite(x1) || !std::
isfinite(y1)) { |
| 1695 es.throwDOMException(NotSupportedError); | 1695 es.throwUninformativeAndGenericDOMException(NotSupportedError); |
| 1696 return 0; | 1696 return 0; |
| 1697 } | 1697 } |
| 1698 | 1698 |
| 1699 RefPtr<CanvasGradient> gradient = CanvasGradient::create(FloatPoint(x0, y0),
FloatPoint(x1, y1)); | 1699 RefPtr<CanvasGradient> gradient = CanvasGradient::create(FloatPoint(x0, y0),
FloatPoint(x1, y1)); |
| 1700 return gradient.release(); | 1700 return gradient.release(); |
| 1701 } | 1701 } |
| 1702 | 1702 |
| 1703 PassRefPtr<CanvasGradient> CanvasRenderingContext2D::createRadialGradient(float
x0, float y0, float r0, float x1, float y1, float r1, ExceptionState& es) | 1703 PassRefPtr<CanvasGradient> CanvasRenderingContext2D::createRadialGradient(float
x0, float y0, float r0, float x1, float y1, float r1, ExceptionState& es) |
| 1704 { | 1704 { |
| 1705 if (!std::isfinite(x0) || !std::isfinite(y0) || !std::isfinite(r0) || !std::
isfinite(x1) || !std::isfinite(y1) || !std::isfinite(r1)) { | 1705 if (!std::isfinite(x0) || !std::isfinite(y0) || !std::isfinite(r0) || !std::
isfinite(x1) || !std::isfinite(y1) || !std::isfinite(r1)) { |
| 1706 es.throwDOMException(NotSupportedError); | 1706 es.throwUninformativeAndGenericDOMException(NotSupportedError); |
| 1707 return 0; | 1707 return 0; |
| 1708 } | 1708 } |
| 1709 | 1709 |
| 1710 if (r0 < 0 || r1 < 0) { | 1710 if (r0 < 0 || r1 < 0) { |
| 1711 es.throwDOMException(IndexSizeError); | 1711 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 1712 return 0; | 1712 return 0; |
| 1713 } | 1713 } |
| 1714 | 1714 |
| 1715 RefPtr<CanvasGradient> gradient = CanvasGradient::create(FloatPoint(x0, y0),
r0, FloatPoint(x1, y1), r1); | 1715 RefPtr<CanvasGradient> gradient = CanvasGradient::create(FloatPoint(x0, y0),
r0, FloatPoint(x1, y1), r1); |
| 1716 return gradient.release(); | 1716 return gradient.release(); |
| 1717 } | 1717 } |
| 1718 | 1718 |
| 1719 PassRefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLImageEleme
nt* image, | 1719 PassRefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLImageEleme
nt* image, |
| 1720 const String& repetitionType, ExceptionState& es) | 1720 const String& repetitionType, ExceptionState& es) |
| 1721 { | 1721 { |
| 1722 if (!image) { | 1722 if (!image) { |
| 1723 es.throwDOMException(TypeMismatchError); | 1723 es.throwUninformativeAndGenericDOMException(TypeMismatchError); |
| 1724 return 0; | 1724 return 0; |
| 1725 } | 1725 } |
| 1726 bool repeatX, repeatY; | 1726 bool repeatX, repeatY; |
| 1727 CanvasPattern::parseRepetitionType(repetitionType, repeatX, repeatY, es); | 1727 CanvasPattern::parseRepetitionType(repetitionType, repeatX, repeatY, es); |
| 1728 if (es.hadException()) | 1728 if (es.hadException()) |
| 1729 return 0; | 1729 return 0; |
| 1730 | 1730 |
| 1731 if (!image->complete()) | 1731 if (!image->complete()) |
| 1732 return 0; | 1732 return 0; |
| 1733 | 1733 |
| 1734 ImageResource* cachedImage = image->cachedImage(); | 1734 ImageResource* cachedImage = image->cachedImage(); |
| 1735 Image* imageForRendering = cachedImage ? cachedImage->imageForRenderer(image
->renderer()) : 0; | 1735 Image* imageForRendering = cachedImage ? cachedImage->imageForRenderer(image
->renderer()) : 0; |
| 1736 if (!imageForRendering) | 1736 if (!imageForRendering) |
| 1737 return CanvasPattern::create(Image::nullImage(), repeatX, repeatY, true)
; | 1737 return CanvasPattern::create(Image::nullImage(), repeatX, repeatY, true)
; |
| 1738 | 1738 |
| 1739 // We need to synthesize a container size if a renderer is not available to
provide one. | 1739 // We need to synthesize a container size if a renderer is not available to
provide one. |
| 1740 if (!image->renderer() && imageForRendering->usesContainerSize()) | 1740 if (!image->renderer() && imageForRendering->usesContainerSize()) |
| 1741 imageForRendering->setContainerSize(imageForRendering->size()); | 1741 imageForRendering->setContainerSize(imageForRendering->size()); |
| 1742 | 1742 |
| 1743 bool originClean = isOriginClean(cachedImage, canvas()->securityOrigin()); | 1743 bool originClean = isOriginClean(cachedImage, canvas()->securityOrigin()); |
| 1744 return CanvasPattern::create(imageForRendering, repeatX, repeatY, originClea
n); | 1744 return CanvasPattern::create(imageForRendering, repeatX, repeatY, originClea
n); |
| 1745 } | 1745 } |
| 1746 | 1746 |
| 1747 PassRefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLCanvasElem
ent* canvas, | 1747 PassRefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLCanvasElem
ent* canvas, |
| 1748 const String& repetitionType, ExceptionState& es) | 1748 const String& repetitionType, ExceptionState& es) |
| 1749 { | 1749 { |
| 1750 if (!canvas) { | 1750 if (!canvas) { |
| 1751 es.throwDOMException(TypeMismatchError); | 1751 es.throwUninformativeAndGenericDOMException(TypeMismatchError); |
| 1752 return 0; | 1752 return 0; |
| 1753 } | 1753 } |
| 1754 if (!canvas->width() || !canvas->height()) { | 1754 if (!canvas->width() || !canvas->height()) { |
| 1755 es.throwDOMException(InvalidStateError); | 1755 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
| 1756 return 0; | 1756 return 0; |
| 1757 } | 1757 } |
| 1758 | 1758 |
| 1759 bool repeatX, repeatY; | 1759 bool repeatX, repeatY; |
| 1760 CanvasPattern::parseRepetitionType(repetitionType, repeatX, repeatY, es); | 1760 CanvasPattern::parseRepetitionType(repetitionType, repeatX, repeatY, es); |
| 1761 if (es.hadException()) | 1761 if (es.hadException()) |
| 1762 return 0; | 1762 return 0; |
| 1763 return CanvasPattern::create(canvas->copiedImage(), repeatX, repeatY, canvas
->originClean()); | 1763 return CanvasPattern::create(canvas->copiedImage(), repeatX, repeatY, canvas
->originClean()); |
| 1764 } | 1764 } |
| 1765 | 1765 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1825 return 0; | 1825 return 0; |
| 1826 | 1826 |
| 1827 RefPtr<ImageData> data = ImageData::create(size); | 1827 RefPtr<ImageData> data = ImageData::create(size); |
| 1828 data->data()->zeroFill(); | 1828 data->data()->zeroFill(); |
| 1829 return data.release(); | 1829 return data.release(); |
| 1830 } | 1830 } |
| 1831 | 1831 |
| 1832 PassRefPtr<ImageData> CanvasRenderingContext2D::createImageData(PassRefPtr<Image
Data> imageData, ExceptionState& es) const | 1832 PassRefPtr<ImageData> CanvasRenderingContext2D::createImageData(PassRefPtr<Image
Data> imageData, ExceptionState& es) const |
| 1833 { | 1833 { |
| 1834 if (!imageData) { | 1834 if (!imageData) { |
| 1835 es.throwDOMException(NotSupportedError); | 1835 es.throwUninformativeAndGenericDOMException(NotSupportedError); |
| 1836 return 0; | 1836 return 0; |
| 1837 } | 1837 } |
| 1838 | 1838 |
| 1839 return createEmptyImageData(imageData->size()); | 1839 return createEmptyImageData(imageData->size()); |
| 1840 } | 1840 } |
| 1841 | 1841 |
| 1842 PassRefPtr<ImageData> CanvasRenderingContext2D::createImageData(float sw, float
sh, ExceptionState& es) const | 1842 PassRefPtr<ImageData> CanvasRenderingContext2D::createImageData(float sw, float
sh, ExceptionState& es) const |
| 1843 { | 1843 { |
| 1844 if (!sw || !sh) { | 1844 if (!sw || !sh) { |
| 1845 es.throwDOMException(IndexSizeError); | 1845 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 1846 return 0; | 1846 return 0; |
| 1847 } | 1847 } |
| 1848 if (!std::isfinite(sw) || !std::isfinite(sh)) { | 1848 if (!std::isfinite(sw) || !std::isfinite(sh)) { |
| 1849 es.throwDOMException(NotSupportedError); | 1849 es.throwUninformativeAndGenericDOMException(NotSupportedError); |
| 1850 return 0; | 1850 return 0; |
| 1851 } | 1851 } |
| 1852 | 1852 |
| 1853 FloatSize logicalSize(fabs(sw), fabs(sh)); | 1853 FloatSize logicalSize(fabs(sw), fabs(sh)); |
| 1854 if (!logicalSize.isExpressibleAsIntSize()) | 1854 if (!logicalSize.isExpressibleAsIntSize()) |
| 1855 return 0; | 1855 return 0; |
| 1856 | 1856 |
| 1857 IntSize size = expandedIntSize(logicalSize); | 1857 IntSize size = expandedIntSize(logicalSize); |
| 1858 if (size.width() < 1) | 1858 if (size.width() < 1) |
| 1859 size.setWidth(1); | 1859 size.setWidth(1); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1874 } | 1874 } |
| 1875 | 1875 |
| 1876 PassRefPtr<ImageData> CanvasRenderingContext2D::getImageData(ImageBuffer::Coordi
nateSystem coordinateSystem, float sx, float sy, float sw, float sh, ExceptionSt
ate& es) const | 1876 PassRefPtr<ImageData> CanvasRenderingContext2D::getImageData(ImageBuffer::Coordi
nateSystem coordinateSystem, float sx, float sy, float sw, float sh, ExceptionSt
ate& es) const |
| 1877 { | 1877 { |
| 1878 if (!canvas()->originClean()) { | 1878 if (!canvas()->originClean()) { |
| 1879 es.throwSecurityError(ExceptionMessages::failedToExecute("getImageData",
"CanvasRenderingContext2D", "the canvas has been tainted by cross-origin data."
)); | 1879 es.throwSecurityError(ExceptionMessages::failedToExecute("getImageData",
"CanvasRenderingContext2D", "the canvas has been tainted by cross-origin data."
)); |
| 1880 return 0; | 1880 return 0; |
| 1881 } | 1881 } |
| 1882 | 1882 |
| 1883 if (!sw || !sh) { | 1883 if (!sw || !sh) { |
| 1884 es.throwDOMException(IndexSizeError); | 1884 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 1885 return 0; | 1885 return 0; |
| 1886 } | 1886 } |
| 1887 if (!std::isfinite(sx) || !std::isfinite(sy) || !std::isfinite(sw) || !std::
isfinite(sh)) { | 1887 if (!std::isfinite(sx) || !std::isfinite(sy) || !std::isfinite(sw) || !std::
isfinite(sh)) { |
| 1888 es.throwDOMException(NotSupportedError); | 1888 es.throwUninformativeAndGenericDOMException(NotSupportedError); |
| 1889 return 0; | 1889 return 0; |
| 1890 } | 1890 } |
| 1891 | 1891 |
| 1892 if (sw < 0) { | 1892 if (sw < 0) { |
| 1893 sx += sw; | 1893 sx += sw; |
| 1894 sw = -sw; | 1894 sw = -sw; |
| 1895 } | 1895 } |
| 1896 if (sh < 0) { | 1896 if (sh < 0) { |
| 1897 sy += sh; | 1897 sy += sh; |
| 1898 sh = -sh; | 1898 sh = -sh; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1914 RefPtr<Uint8ClampedArray> byteArray = buffer->getUnmultipliedImageData(image
DataRect, coordinateSystem); | 1914 RefPtr<Uint8ClampedArray> byteArray = buffer->getUnmultipliedImageData(image
DataRect, coordinateSystem); |
| 1915 if (!byteArray) | 1915 if (!byteArray) |
| 1916 return 0; | 1916 return 0; |
| 1917 | 1917 |
| 1918 return ImageData::create(imageDataRect.size(), byteArray.release()); | 1918 return ImageData::create(imageDataRect.size(), byteArray.release()); |
| 1919 } | 1919 } |
| 1920 | 1920 |
| 1921 void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy,
ExceptionState& es) | 1921 void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy,
ExceptionState& es) |
| 1922 { | 1922 { |
| 1923 if (!data) { | 1923 if (!data) { |
| 1924 es.throwDOMException(TypeMismatchError); | 1924 es.throwUninformativeAndGenericDOMException(TypeMismatchError); |
| 1925 return; | 1925 return; |
| 1926 } | 1926 } |
| 1927 putImageData(data, dx, dy, 0, 0, data->width(), data->height(), es); | 1927 putImageData(data, dx, dy, 0, 0, data->width(), data->height(), es); |
| 1928 } | 1928 } |
| 1929 | 1929 |
| 1930 void CanvasRenderingContext2D::webkitPutImageDataHD(ImageData* data, float dx, f
loat dy, ExceptionState& es) | 1930 void CanvasRenderingContext2D::webkitPutImageDataHD(ImageData* data, float dx, f
loat dy, ExceptionState& es) |
| 1931 { | 1931 { |
| 1932 if (!data) { | 1932 if (!data) { |
| 1933 es.throwDOMException(TypeMismatchError); | 1933 es.throwUninformativeAndGenericDOMException(TypeMismatchError); |
| 1934 return; | 1934 return; |
| 1935 } | 1935 } |
| 1936 webkitPutImageDataHD(data, dx, dy, 0, 0, data->width(), data->height(), es); | 1936 webkitPutImageDataHD(data, dx, dy, 0, 0, data->width(), data->height(), es); |
| 1937 } | 1937 } |
| 1938 | 1938 |
| 1939 void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy,
float dirtyX, float dirtyY, | 1939 void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy,
float dirtyX, float dirtyY, |
| 1940 float dirtyWidth, float dirtyHeight, ExceptionState& es) | 1940 float dirtyWidth, float dirtyHeight, ExceptionState& es) |
| 1941 { | 1941 { |
| 1942 putImageData(data, ImageBuffer::LogicalCoordinateSystem, dx, dy, dirtyX, dir
tyY, dirtyWidth, dirtyHeight, es); | 1942 putImageData(data, ImageBuffer::LogicalCoordinateSystem, dx, dy, dirtyX, dir
tyY, dirtyWidth, dirtyHeight, es); |
| 1943 } | 1943 } |
| 1944 | 1944 |
| 1945 void CanvasRenderingContext2D::webkitPutImageDataHD(ImageData* data, float dx, f
loat dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, Except
ionState& es) | 1945 void CanvasRenderingContext2D::webkitPutImageDataHD(ImageData* data, float dx, f
loat dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, Except
ionState& es) |
| 1946 { | 1946 { |
| 1947 putImageData(data, ImageBuffer::BackingStoreCoordinateSystem, dx, dy, dirtyX
, dirtyY, dirtyWidth, dirtyHeight, es); | 1947 putImageData(data, ImageBuffer::BackingStoreCoordinateSystem, dx, dy, dirtyX
, dirtyY, dirtyWidth, dirtyHeight, es); |
| 1948 } | 1948 } |
| 1949 | 1949 |
| 1950 void CanvasRenderingContext2D::putImageData(ImageData* data, ImageBuffer::Coordi
nateSystem coordinateSystem, float dx, float dy, float dirtyX, float dirtyY, | 1950 void CanvasRenderingContext2D::putImageData(ImageData* data, ImageBuffer::Coordi
nateSystem coordinateSystem, float dx, float dy, float dirtyX, float dirtyY, |
| 1951 float dirtyWidth, float dirtyHeight, ExceptionState& es) | 1951 float dirtyWidth, float dirtyHeight, ExceptionState& es) |
| 1952 { | 1952 { |
| 1953 if (!data) { | 1953 if (!data) { |
| 1954 es.throwDOMException(TypeMismatchError); | 1954 es.throwUninformativeAndGenericDOMException(TypeMismatchError); |
| 1955 return; | 1955 return; |
| 1956 } | 1956 } |
| 1957 if (!std::isfinite(dx) || !std::isfinite(dy) || !std::isfinite(dirtyX) || !s
td::isfinite(dirtyY) || !std::isfinite(dirtyWidth) || !std::isfinite(dirtyHeight
)) { | 1957 if (!std::isfinite(dx) || !std::isfinite(dy) || !std::isfinite(dirtyX) || !s
td::isfinite(dirtyY) || !std::isfinite(dirtyWidth) || !std::isfinite(dirtyHeight
)) { |
| 1958 es.throwDOMException(NotSupportedError); | 1958 es.throwUninformativeAndGenericDOMException(NotSupportedError); |
| 1959 return; | 1959 return; |
| 1960 } | 1960 } |
| 1961 | 1961 |
| 1962 ImageBuffer* buffer = canvas()->buffer(); | 1962 ImageBuffer* buffer = canvas()->buffer(); |
| 1963 if (!buffer) | 1963 if (!buffer) |
| 1964 return; | 1964 return; |
| 1965 | 1965 |
| 1966 if (dirtyWidth < 0) { | 1966 if (dirtyWidth < 0) { |
| 1967 dirtyX += dirtyWidth; | 1967 dirtyX += dirtyWidth; |
| 1968 dirtyWidth = -dirtyWidth; | 1968 dirtyWidth = -dirtyWidth; |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2414 const int focusRingWidth = 5; | 2414 const int focusRingWidth = 5; |
| 2415 const int focusRingOutline = 0; | 2415 const int focusRingOutline = 0; |
| 2416 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); | 2416 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); |
| 2417 | 2417 |
| 2418 c->restore(); | 2418 c->restore(); |
| 2419 | 2419 |
| 2420 didDraw(dirtyRect); | 2420 didDraw(dirtyRect); |
| 2421 } | 2421 } |
| 2422 | 2422 |
| 2423 } // namespace WebCore | 2423 } // namespace WebCore |
| OLD | NEW |