| 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 Intel Corporation. All rights reserved. | 8 * Copyright (C) 2012 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 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 drawImage(bitmap, x, y, bitmap->width(), bitmap->height(), es); | 1248 drawImage(bitmap, x, y, bitmap->width(), bitmap->height(), es); |
| 1249 } | 1249 } |
| 1250 | 1250 |
| 1251 void CanvasRenderingContext2D::drawImage(ImageBitmap* bitmap, | 1251 void CanvasRenderingContext2D::drawImage(ImageBitmap* bitmap, |
| 1252 float x, float y, float width, float height, ExceptionState& es) | 1252 float x, float y, float width, float height, ExceptionState& es) |
| 1253 { | 1253 { |
| 1254 if (!bitmap) { | 1254 if (!bitmap) { |
| 1255 es.throwDOMException(TypeMismatchError); | 1255 es.throwDOMException(TypeMismatchError); |
| 1256 return; | 1256 return; |
| 1257 } | 1257 } |
| 1258 if (!bitmap->bitmapWidth() || !bitmap->bitmapHeight()) | 1258 if (!bitmap->bitmapRect().width() || !bitmap->bitmapRect().height()) |
| 1259 return; | 1259 return; |
| 1260 | 1260 |
| 1261 drawImage(bitmap, 0, 0, bitmap->bitmapWidth(), bitmap->bitmapHeight(), x, y,
width, height, es); | 1261 drawImage(bitmap, 0, 0, bitmap->width(), bitmap->height(), x, y, width, heig
ht, es); |
| 1262 } | 1262 } |
| 1263 | 1263 |
| 1264 void CanvasRenderingContext2D::drawImage(ImageBitmap* bitmap, | 1264 void CanvasRenderingContext2D::drawImage(ImageBitmap* bitmap, |
| 1265 float sx, float sy, float sw, float sh, | 1265 float sx, float sy, float sw, float sh, |
| 1266 float dx, float dy, float dw, float dh, ExceptionState& es) | 1266 float dx, float dy, float dw, float dh, ExceptionState& es) |
| 1267 { | 1267 { |
| 1268 if (!bitmap) { | 1268 if (!bitmap) { |
| 1269 es.throwDOMException(TypeMismatchError); | 1269 es.throwDOMException(TypeMismatchError); |
| 1270 return; | 1270 return; |
| 1271 } | 1271 } |
| 1272 | 1272 |
| 1273 FloatRect srcRect(sx, sy, sw, sh); | 1273 FloatRect srcRect(sx, sy, sw, sh); |
| 1274 FloatRect dstRect(dx, dy, dw, dh); | 1274 FloatRect dstRect(dx, dy, dw, dh); |
| 1275 FloatRect bitmapRect = bitmap->bitmapRect(); |
| 1275 | 1276 |
| 1276 if (!std::isfinite(dstRect.x()) || !std::isfinite(dstRect.y()) || !std::isfi
nite(dstRect.width()) || !std::isfinite(dstRect.height()) | 1277 if (!std::isfinite(dstRect.x()) || !std::isfinite(dstRect.y()) || !std::isfi
nite(dstRect.width()) || !std::isfinite(dstRect.height()) |
| 1277 || !std::isfinite(srcRect.x()) || !std::isfinite(srcRect.y()) || !std::i
sfinite(srcRect.width()) || !std::isfinite(srcRect.height())) | 1278 || !std::isfinite(srcRect.x()) || !std::isfinite(srcRect.y()) || !std::i
sfinite(srcRect.width()) || !std::isfinite(srcRect.height())) |
| 1278 return; | 1279 return; |
| 1279 | 1280 |
| 1280 if (!dstRect.width() || !dstRect.height()) | 1281 if (!dstRect.width() || !dstRect.height()) |
| 1281 return; | 1282 return; |
| 1282 | |
| 1283 ASSERT(bitmap->height() && bitmap->width()); | |
| 1284 | |
| 1285 FloatRect normalizedSrcRect = normalizeRect(srcRect); | |
| 1286 FloatRect normalizedDstRect = normalizeRect(dstRect); | |
| 1287 FloatRect actualDstRect(FloatPoint(bitmap->bitmapOffset()), bitmap->bitmapSi
ze()); | |
| 1288 actualDstRect.scale(normalizedDstRect.width() / bitmap->width(), normalizedD
stRect.height() / bitmap->height()); | |
| 1289 actualDstRect.moveBy(normalizedDstRect.location()); | |
| 1290 | |
| 1291 FloatRect imageRect = FloatRect(FloatPoint(), bitmap->bitmapSize()); | |
| 1292 if (!srcRect.width() || !srcRect.height()) { | 1283 if (!srcRect.width() || !srcRect.height()) { |
| 1293 es.throwDOMException(IndexSizeError); | 1284 es.throwDOMException(IndexSizeError); |
| 1294 return; | 1285 return; |
| 1295 } | 1286 } |
| 1296 if (!imageRect.intersects(normalizedSrcRect)) | 1287 |
| 1288 ASSERT(bitmap->height() && bitmap->width()); |
| 1289 FloatRect normalizedSrcRect = normalizeRect(srcRect); |
| 1290 FloatRect normalizedDstRect = normalizeRect(dstRect); |
| 1291 |
| 1292 // Clip the rects to where the user thinks that the image is situated. |
| 1293 clipRectsToImageRect(IntRect(IntPoint(), bitmap->size()), &normalizedSrcRect
, &normalizedDstRect); |
| 1294 |
| 1295 FloatRect intersectRect = intersection(bitmapRect, normalizedSrcRect); |
| 1296 FloatRect actualSrcRect(intersectRect); |
| 1297 actualSrcRect.move(-bitmapRect.x(), -bitmapRect.y()); |
| 1298 |
| 1299 FloatRect imageRect = FloatRect(FloatPoint(), bitmapRect.size()); |
| 1300 |
| 1301 FloatRect actualDstRect(FloatPoint(intersectRect.location() - normalizedSrcR
ect.location()), bitmapRect.size()); |
| 1302 actualDstRect.scale(normalizedDstRect.width() / normalizedSrcRect.width() *
intersectRect.width() / bitmapRect.width(), |
| 1303 normalizedDstRect.height() / normalizedSrcRect.height() * intersectRect.
height() / bitmapRect.height()); |
| 1304 actualDstRect.moveBy(normalizedDstRect.location()); |
| 1305 |
| 1306 if (!imageRect.intersects(actualSrcRect)) |
| 1297 return; | 1307 return; |
| 1298 | 1308 |
| 1299 clipRectsToImageRect(imageRect, &normalizedSrcRect, &actualDstRect); | 1309 RefPtr<Image> imageForRendering = bitmap->bitmapImage(); |
| 1300 | 1310 drawImageInternal(imageForRendering.get(), actualSrcRect, actualDstRect, sta
te().m_globalComposite, state().m_globalBlend); |
| 1301 Image* imageForRendering = bitmap->bitmapImage(); | |
| 1302 | |
| 1303 drawImageInternal(imageForRendering, normalizedSrcRect, actualDstRect, state
().m_globalComposite, state().m_globalBlend); | |
| 1304 } | 1311 } |
| 1305 | 1312 |
| 1306 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, float x, float
y, ExceptionState& es) | 1313 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, float x, float
y, ExceptionState& es) |
| 1307 { | 1314 { |
| 1308 if (!image) { | 1315 if (!image) { |
| 1309 es.throwDOMException(TypeMismatchError); | 1316 es.throwDOMException(TypeMismatchError); |
| 1310 return; | 1317 return; |
| 1311 } | 1318 } |
| 1312 LayoutSize s = size(image); | 1319 LayoutSize s = size(image); |
| 1313 drawImage(image, x, y, s.width(), s.height(), es); | 1320 drawImage(image, x, y, s.width(), s.height(), es); |
| (...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2401 | 2408 |
| 2402 RefPtr<RenderStyle> style(RenderStyle::createDefaultStyle()); | 2409 RefPtr<RenderStyle> style(RenderStyle::createDefaultStyle()); |
| 2403 Color focusRingColor = RenderTheme::focusRingColor(); | 2410 Color focusRingColor = RenderTheme::focusRingColor(); |
| 2404 c->drawFocusRing(path, style->outlineWidth(), style->outlineOffset(), focusR
ingColor); | 2411 c->drawFocusRing(path, style->outlineWidth(), style->outlineOffset(), focusR
ingColor); |
| 2405 didDraw(path.boundingRect()); | 2412 didDraw(path.boundingRect()); |
| 2406 | 2413 |
| 2407 c->restore(); | 2414 c->restore(); |
| 2408 } | 2415 } |
| 2409 | 2416 |
| 2410 } // namespace WebCore | 2417 } // namespace WebCore |
| OLD | NEW |