| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "core/dom/Element.h" | 48 #include "core/dom/Element.h" |
| 49 #include "core/dom/EventListener.h" | 49 #include "core/dom/EventListener.h" |
| 50 #include "core/dom/EventNames.h" | 50 #include "core/dom/EventNames.h" |
| 51 #include "core/dom/ExceptionCode.h" | 51 #include "core/dom/ExceptionCode.h" |
| 52 #include "core/dom/ExceptionCodePlaceholder.h" | 52 #include "core/dom/ExceptionCodePlaceholder.h" |
| 53 #include "core/dom/MessageEvent.h" | 53 #include "core/dom/MessageEvent.h" |
| 54 #include "core/dom/PageTransitionEvent.h" | 54 #include "core/dom/PageTransitionEvent.h" |
| 55 #include "core/dom/RequestAnimationFrameCallback.h" | 55 #include "core/dom/RequestAnimationFrameCallback.h" |
| 56 #include "core/dom/ScriptExecutionContext.h" | 56 #include "core/dom/ScriptExecutionContext.h" |
| 57 #include "core/editing/Editor.h" | 57 #include "core/editing/Editor.h" |
| 58 #include "core/fileapi/Blob.h" |
| 58 #include "core/history/BackForwardController.h" | 59 #include "core/history/BackForwardController.h" |
| 59 #include "core/html/HTMLCanvasElement.h" | 60 #include "core/html/HTMLCanvasElement.h" |
| 60 #include "core/html/HTMLFrameOwnerElement.h" | 61 #include "core/html/HTMLFrameOwnerElement.h" |
| 61 #include "core/html/HTMLImageElement.h" | 62 #include "core/html/HTMLImageElement.h" |
| 62 #include "core/html/HTMLVideoElement.h" | 63 #include "core/html/HTMLVideoElement.h" |
| 63 #include "core/html/ImageData.h" | 64 #include "core/html/ImageData.h" |
| 64 #include "core/html/canvas/CanvasRenderingContext2D.h" | 65 #include "core/html/canvas/CanvasRenderingContext2D.h" |
| 65 #include "core/inspector/InspectorInstrumentation.h" | 66 #include "core/inspector/InspectorInstrumentation.h" |
| 66 #include "core/inspector/ScriptCallStack.h" | 67 #include "core/inspector/ScriptCallStack.h" |
| 67 #include "core/loader/DocumentLoader.h" | 68 #include "core/loader/DocumentLoader.h" |
| (...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1368 return IntSize(); | 1369 return IntSize(); |
| 1369 } | 1370 } |
| 1370 | 1371 |
| 1371 static IntSize size(HTMLVideoElement* video) | 1372 static IntSize size(HTMLVideoElement* video) |
| 1372 { | 1373 { |
| 1373 if (MediaPlayer* player = video->player()) | 1374 if (MediaPlayer* player = video->player()) |
| 1374 return player->naturalSize(); | 1375 return player->naturalSize(); |
| 1375 return IntSize(); | 1376 return IntSize(); |
| 1376 } | 1377 } |
| 1377 | 1378 |
| 1378 void DOMWindow::createImageBitmap(HTMLImageElement* image, PassRefPtr<ImageBitma
pCallback> callback, ExceptionCode& ec) | 1379 void DOMWindow::createImageBitmap(HTMLImageElement* image, PassRefPtr<ImageBitma
pCallback> callback, ExceptionCode& ec) const |
| 1379 { | 1380 { |
| 1380 LayoutSize s = size(image); | 1381 LayoutSize s = size(image); |
| 1381 createImageBitmap(image, callback, 0, 0, s.width(), s.height(), ec); | 1382 createImageBitmap(image, callback, 0, 0, s.width(), s.height(), ec); |
| 1382 } | 1383 } |
| 1383 | 1384 |
| 1384 void DOMWindow::createImageBitmap(HTMLImageElement* image, PassRefPtr<ImageBitma
pCallback> callback, int sx, int sy, int sw, int sh, ExceptionCode& ec) | 1385 void DOMWindow::createImageBitmap(HTMLImageElement* image, PassRefPtr<ImageBitma
pCallback> callback, int sx, int sy, int sw, int sh, ExceptionCode& ec) const |
| 1385 { | 1386 { |
| 1386 if (!image) { | 1387 if (!image) { |
| 1387 ec = TypeError; | 1388 ec = TypeError; |
| 1388 return; | 1389 return; |
| 1389 } | 1390 } |
| 1390 if (!image->cachedImage()) { | 1391 if (!image->cachedImage()) { |
| 1391 ec = InvalidStateError; | 1392 ec = InvalidStateError; |
| 1392 return; | 1393 return; |
| 1393 } | 1394 } |
| 1394 if (image->cachedImage()->image()->isSVGImage()) { | 1395 if (image->cachedImage()->image()->isSVGImage()) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1409 } | 1410 } |
| 1410 | 1411 |
| 1411 ec = 0; | 1412 ec = 0; |
| 1412 | 1413 |
| 1413 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 | 1414 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 |
| 1414 RefPtr<ImageBitmap> imageBitmap = ImageBitmap::create(image, IntRect(sx, sy,
sw, sh)); | 1415 RefPtr<ImageBitmap> imageBitmap = ImageBitmap::create(image, IntRect(sx, sy,
sw, sh)); |
| 1415 RefPtr<ImageBitmapCallback> callbackLocal = callback; | 1416 RefPtr<ImageBitmapCallback> callbackLocal = callback; |
| 1416 scriptExecutionContext()->postTask(ImageBitmapCallback::CallbackTask::create
(imageBitmap.release(), callbackLocal)); | 1417 scriptExecutionContext()->postTask(ImageBitmapCallback::CallbackTask::create
(imageBitmap.release(), callbackLocal)); |
| 1417 } | 1418 } |
| 1418 | 1419 |
| 1419 void DOMWindow::createImageBitmap(HTMLVideoElement* video, PassRefPtr<ImageBitma
pCallback> callback, ExceptionCode& ec) | 1420 void DOMWindow::createImageBitmap(HTMLVideoElement* video, PassRefPtr<ImageBitma
pCallback> callback, ExceptionCode& ec) const |
| 1420 { | 1421 { |
| 1421 IntSize s = size(video); | 1422 IntSize s = size(video); |
| 1422 createImageBitmap(video, callback, 0, 0, s.width(), s.height(), ec); | 1423 createImageBitmap(video, callback, 0, 0, s.width(), s.height(), ec); |
| 1423 } | 1424 } |
| 1424 | 1425 |
| 1425 void DOMWindow::createImageBitmap(HTMLVideoElement* video, PassRefPtr<ImageBitma
pCallback> callback, int sx, int sy, int sw, int sh, ExceptionCode& ec) | 1426 void DOMWindow::createImageBitmap(HTMLVideoElement* video, PassRefPtr<ImageBitma
pCallback> callback, int sx, int sy, int sw, int sh, ExceptionCode& ec) const |
| 1426 { | 1427 { |
| 1427 if (!video) { | 1428 if (!video) { |
| 1428 ec = TypeError; | 1429 ec = TypeError; |
| 1429 return; | 1430 return; |
| 1430 } | 1431 } |
| 1431 if (!video->player()) { | 1432 if (!video->player()) { |
| 1432 ec = InvalidStateError; | 1433 ec = InvalidStateError; |
| 1433 return; | 1434 return; |
| 1434 } | 1435 } |
| 1435 if (video->networkState() == HTMLMediaElement::NETWORK_EMPTY) { | 1436 if (video->networkState() == HTMLMediaElement::NETWORK_EMPTY) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1454 } | 1455 } |
| 1455 | 1456 |
| 1456 ec = 0; | 1457 ec = 0; |
| 1457 | 1458 |
| 1458 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 | 1459 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 |
| 1459 RefPtr<ImageBitmap> imageBitmap = ImageBitmap::create(video, IntRect(sx, sy,
sw, sh)); | 1460 RefPtr<ImageBitmap> imageBitmap = ImageBitmap::create(video, IntRect(sx, sy,
sw, sh)); |
| 1460 RefPtr<ImageBitmapCallback> callbackLocal = callback; | 1461 RefPtr<ImageBitmapCallback> callbackLocal = callback; |
| 1461 scriptExecutionContext()->postTask(ImageBitmapCallback::CallbackTask::create
(imageBitmap.release(), callbackLocal)); | 1462 scriptExecutionContext()->postTask(ImageBitmapCallback::CallbackTask::create
(imageBitmap.release(), callbackLocal)); |
| 1462 } | 1463 } |
| 1463 | 1464 |
| 1464 void DOMWindow::createImageBitmap(CanvasRenderingContext2D* context, PassRefPtr<
ImageBitmapCallback> callback, ExceptionCode& ec) | 1465 void DOMWindow::createImageBitmap(CanvasRenderingContext2D* context, PassRefPtr<
ImageBitmapCallback> callback, ExceptionCode& ec) const |
| 1465 { | 1466 { |
| 1466 createImageBitmap(context->canvas(), callback, ec); | 1467 createImageBitmap(context->canvas(), callback, ec); |
| 1467 } | 1468 } |
| 1468 | 1469 |
| 1469 void DOMWindow::createImageBitmap(CanvasRenderingContext2D* context, PassRefPtr<
ImageBitmapCallback> callback, int sx, int sy, int sw, int sh, ExceptionCode& ec
) | 1470 void DOMWindow::createImageBitmap(CanvasRenderingContext2D* context, PassRefPtr<
ImageBitmapCallback> callback, int sx, int sy, int sw, int sh, ExceptionCode& ec
) const |
| 1470 { | 1471 { |
| 1471 createImageBitmap(context->canvas(), callback, sx, sy, sw, sh, ec); | 1472 createImageBitmap(context->canvas(), callback, sx, sy, sw, sh, ec); |
| 1472 } | 1473 } |
| 1473 | 1474 |
| 1474 void DOMWindow::createImageBitmap(HTMLCanvasElement* canvas, PassRefPtr<ImageBit
mapCallback> callback, ExceptionCode& ec) | 1475 void DOMWindow::createImageBitmap(HTMLCanvasElement* canvas, PassRefPtr<ImageBit
mapCallback> callback, ExceptionCode& ec) const |
| 1475 { | 1476 { |
| 1476 createImageBitmap(canvas, callback, 0, 0, canvas->width(), canvas->height(),
ec); | 1477 createImageBitmap(canvas, callback, 0, 0, canvas->width(), canvas->height(),
ec); |
| 1477 } | 1478 } |
| 1478 | 1479 |
| 1479 void DOMWindow::createImageBitmap(HTMLCanvasElement* canvas, PassRefPtr<ImageBit
mapCallback> callback, int sx, int sy, int sw, int sh, ExceptionCode& ec) | 1480 void DOMWindow::createImageBitmap(HTMLCanvasElement* canvas, PassRefPtr<ImageBit
mapCallback> callback, int sx, int sy, int sw, int sh, ExceptionCode& ec) const |
| 1480 { | 1481 { |
| 1481 if (!canvas) { | 1482 if (!canvas) { |
| 1482 ec = TypeError; | 1483 ec = TypeError; |
| 1483 return; | 1484 return; |
| 1484 } | 1485 } |
| 1485 if (!canvas->originClean()) { | 1486 if (!canvas->originClean()) { |
| 1486 ec = InvalidStateError; | 1487 ec = InvalidStateError; |
| 1487 return; | 1488 return; |
| 1488 } | 1489 } |
| 1489 if (!sw || !sh) { | 1490 if (!sw || !sh) { |
| 1490 ec = IndexSizeError; | 1491 ec = IndexSizeError; |
| 1491 return; | 1492 return; |
| 1492 } | 1493 } |
| 1493 | 1494 |
| 1494 ec = 0; | 1495 ec = 0; |
| 1495 | 1496 |
| 1496 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 | 1497 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 |
| 1497 RefPtr<ImageBitmap> imageBitmap = ImageBitmap::create(canvas, IntRect(sx, sy
, sw, sh)); | 1498 RefPtr<ImageBitmap> imageBitmap = ImageBitmap::create(canvas, IntRect(sx, sy
, sw, sh)); |
| 1498 RefPtr<ImageBitmapCallback> callbackLocal = callback; | 1499 RefPtr<ImageBitmapCallback> callbackLocal = callback; |
| 1499 scriptExecutionContext()->postTask(ImageBitmapCallback::CallbackTask::create
(imageBitmap.release(), callbackLocal)); | 1500 scriptExecutionContext()->postTask(ImageBitmapCallback::CallbackTask::create
(imageBitmap.release(), callbackLocal)); |
| 1500 } | 1501 } |
| 1501 | 1502 |
| 1502 void DOMWindow::createImageBitmap(ImageData* data, PassRefPtr<ImageBitmapCallbac
k> callback, ExceptionCode& ec) | 1503 void DOMWindow::createImageBitmap(Blob* blob, PassRefPtr<ImageBitmapCallback> ca
llback, ExceptionCode& ec) |
| 1504 { |
| 1505 if (!blob) { |
| 1506 ec = TypeError; |
| 1507 return; |
| 1508 } |
| 1509 // We pass 0 as width and height to indicate that there should be no croppin
g. |
| 1510 RefPtr<ImageBitmap> bitmap = ImageBitmap::create(this, callback, blob, IntRe
ct(IntPoint(), IntSize())); |
| 1511 m_pendingImageBitmaps.add(bitmap); |
| 1512 } |
| 1513 |
| 1514 void DOMWindow::createImageBitmap(Blob* blob, PassRefPtr<ImageBitmapCallback> ca
llback, int sx, int sy, int sw, int sh, ExceptionCode& ec) |
| 1515 { |
| 1516 if (!blob) { |
| 1517 ec = TypeError; |
| 1518 return; |
| 1519 } |
| 1520 if (!sw || !sh) { |
| 1521 ec = IndexSizeError; |
| 1522 return; |
| 1523 } |
| 1524 RefPtr<ImageBitmap> bitmap = ImageBitmap::create(this, callback, blob, IntRe
ct(sx, sy, sw, sh)); |
| 1525 m_pendingImageBitmaps.add(bitmap); |
| 1526 } |
| 1527 |
| 1528 void DOMWindow::createImageBitmap(ImageData* data, PassRefPtr<ImageBitmapCallbac
k> callback, ExceptionCode& ec) const |
| 1503 { | 1529 { |
| 1504 createImageBitmap(data, callback, 0, 0, data->width(), data->height(), ec); | 1530 createImageBitmap(data, callback, 0, 0, data->width(), data->height(), ec); |
| 1505 } | 1531 } |
| 1506 | 1532 |
| 1507 void DOMWindow::createImageBitmap(ImageData* data, PassRefPtr<ImageBitmapCallbac
k> callback, int sx, int sy, int sw, int sh, ExceptionCode& ec) | 1533 void DOMWindow::createImageBitmap(ImageData* data, PassRefPtr<ImageBitmapCallbac
k> callback, int sx, int sy, int sw, int sh, ExceptionCode& ec) const |
| 1508 { | 1534 { |
| 1509 if (!data) { | 1535 if (!data) { |
| 1510 ec = TypeError; | 1536 ec = TypeError; |
| 1511 return; | 1537 return; |
| 1512 } | 1538 } |
| 1513 if (!sw || !sh) { | 1539 if (!sw || !sh) { |
| 1514 ec = IndexSizeError; | 1540 ec = IndexSizeError; |
| 1515 return; | 1541 return; |
| 1516 } | 1542 } |
| 1517 | 1543 |
| 1518 ec = 0; | 1544 ec = 0; |
| 1519 | 1545 |
| 1520 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 | 1546 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 |
| 1521 RefPtr<ImageBitmap> imageBitmap = ImageBitmap::create(data, IntRect(sx, sy,
sw, sh)); | 1547 RefPtr<ImageBitmap> imageBitmap = ImageBitmap::create(data, IntRect(sx, sy,
sw, sh)); |
| 1522 RefPtr<ImageBitmapCallback> callbackLocal = callback; | 1548 RefPtr<ImageBitmapCallback> callbackLocal = callback; |
| 1523 scriptExecutionContext()->postTask(ImageBitmapCallback::CallbackTask::create
(imageBitmap.release(), callbackLocal)); | 1549 scriptExecutionContext()->postTask(ImageBitmapCallback::CallbackTask::create
(imageBitmap.release(), callbackLocal)); |
| 1524 } | 1550 } |
| 1525 | 1551 |
| 1526 void DOMWindow::createImageBitmap(ImageBitmap* bitmap, PassRefPtr<ImageBitmapCal
lback> callback, ExceptionCode& ec) | 1552 void DOMWindow::createImageBitmap(ImageBitmap* bitmap, PassRefPtr<ImageBitmapCal
lback> callback, ExceptionCode& ec) const |
| 1527 { | 1553 { |
| 1528 createImageBitmap(bitmap, callback, 0, 0, bitmap->width(), bitmap->height(),
ec); | 1554 createImageBitmap(bitmap, callback, 0, 0, bitmap->width(), bitmap->height(),
ec); |
| 1529 } | 1555 } |
| 1530 | 1556 |
| 1531 void DOMWindow::createImageBitmap(ImageBitmap* bitmap, PassRefPtr<ImageBitmapCal
lback> callback, int sx, int sy, int sw, int sh, ExceptionCode& ec) | 1557 void DOMWindow::createImageBitmap(ImageBitmap* bitmap, PassRefPtr<ImageBitmapCal
lback> callback, int sx, int sy, int sw, int sh, ExceptionCode& ec) const |
| 1532 { | 1558 { |
| 1533 if (!bitmap) { | 1559 if (!bitmap) { |
| 1534 ec = TypeError; | 1560 ec = TypeError; |
| 1535 return; | 1561 return; |
| 1536 } | 1562 } |
| 1537 if (!sw || !sh) { | 1563 if (!sw || !sh) { |
| 1538 ec = IndexSizeError; | 1564 ec = IndexSizeError; |
| 1539 return; | 1565 return; |
| 1540 } | 1566 } |
| 1541 | 1567 |
| 1542 ec = 0; | 1568 ec = 0; |
| 1543 | 1569 |
| 1544 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 | 1570 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 |
| 1545 RefPtr<ImageBitmap> imageBitmap = ImageBitmap::create(bitmap, IntRect(sx, sy
, sw, sh)); | 1571 RefPtr<ImageBitmap> imageBitmap = ImageBitmap::create(bitmap, IntRect(sx, sy
, sw, sh)); |
| 1546 RefPtr<ImageBitmapCallback> callbackLocal = callback; | 1572 RefPtr<ImageBitmapCallback> callbackLocal = callback; |
| 1547 scriptExecutionContext()->postTask(ImageBitmapCallback::CallbackTask::create
(imageBitmap.release(), callbackLocal)); | 1573 scriptExecutionContext()->postTask(ImageBitmapCallback::CallbackTask::create
(imageBitmap.release(), callbackLocal)); |
| 1548 } | 1574 } |
| 1549 | 1575 |
| 1576 void DOMWindow::imageBitmapFinishedLoading(ImageBitmap* bitmap) |
| 1577 { |
| 1578 m_pendingImageBitmaps.remove(bitmap); |
| 1579 } |
| 1580 |
| 1550 int DOMWindow::requestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> c
allback) | 1581 int DOMWindow::requestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> c
allback) |
| 1551 { | 1582 { |
| 1552 callback->m_useLegacyTimeBase = false; | 1583 callback->m_useLegacyTimeBase = false; |
| 1553 if (Document* d = document()) | 1584 if (Document* d = document()) |
| 1554 return d->requestAnimationFrame(callback); | 1585 return d->requestAnimationFrame(callback); |
| 1555 return 0; | 1586 return 0; |
| 1556 } | 1587 } |
| 1557 | 1588 |
| 1558 int DOMWindow::webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallb
ack> callback) | 1589 int DOMWindow::webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallb
ack> callback) |
| 1559 { | 1590 { |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1910 | 1941 |
| 1911 Frame* child = frame->tree()->scopedChild(index); | 1942 Frame* child = frame->tree()->scopedChild(index); |
| 1912 if (child) | 1943 if (child) |
| 1913 return child->domWindow(); | 1944 return child->domWindow(); |
| 1914 | 1945 |
| 1915 return 0; | 1946 return 0; |
| 1916 } | 1947 } |
| 1917 | 1948 |
| 1918 | 1949 |
| 1919 } // namespace WebCore | 1950 } // namespace WebCore |
| OLD | NEW |