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 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1200 } else { | 1200 } else { |
1201 c->clearShadow(); | 1201 c->clearShadow(); |
1202 } | 1202 } |
1203 } | 1203 } |
1204 | 1204 |
1205 bool CanvasRenderingContext2D::shouldDrawShadows() const | 1205 bool CanvasRenderingContext2D::shouldDrawShadows() const |
1206 { | 1206 { |
1207 return alphaChannel(state().m_shadowColor) && (state().m_shadowBlur || !stat e().m_shadowOffset.isZero()); | 1207 return alphaChannel(state().m_shadowColor) && (state().m_shadowBlur || !stat e().m_shadowOffset.isZero()); |
1208 } | 1208 } |
1209 | 1209 |
1210 static LayoutSize sizeFor(HTMLImageElement* image) | 1210 enum ImageSizeType { |
1211 ScaledSize, | |
1212 UnscaledSize | |
1213 }; | |
1214 | |
1215 static LayoutSize sizeFor(HTMLImageElement* image, ImageSizeType sizeType) | |
pdr.
2013/10/11 05:17:33
Can you help me understand why this is needed?
I
Yoav Weiss
2013/10/11 07:22:32
For what I've seen, drawImage calls sizeFor 3 time
| |
1211 { | 1216 { |
1212 if (ImageResource* cachedImage = image->cachedImage()) | 1217 LayoutSize size; |
1213 return cachedImage->imageSizeForRenderer(image->renderer(), 1.0f); // FI XME: Not sure about this. | 1218 ImageResource* cachedImage = image->cachedImage(); |
1214 return IntSize(); | 1219 if (cachedImage) { |
1220 size = cachedImage->imageSizeForRenderer(image->renderer(), 1.0f); // FI XME: Not sure about this. | |
1221 | |
1222 if (sizeType == ScaledSize && image->renderer() && cachedImage->image() && !cachedImage->image()->hasRelativeWidth()) | |
1223 size.scale(image->renderer()->intrinsicSizeFactor()); | |
1224 } | |
1225 return size; | |
1215 } | 1226 } |
1216 | 1227 |
1217 static IntSize sizeFor(HTMLVideoElement* video) | 1228 static IntSize sizeFor(HTMLVideoElement* video) |
1218 { | 1229 { |
1219 if (MediaPlayer* player = video->player()) | 1230 if (MediaPlayer* player = video->player()) |
1220 return player->naturalSize(); | 1231 return player->naturalSize(); |
1221 return IntSize(); | 1232 return IntSize(); |
1222 } | 1233 } |
1223 | 1234 |
1224 static inline FloatRect normalizeRect(const FloatRect& rect) | 1235 static inline FloatRect normalizeRect(const FloatRect& rect) |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1355 | 1366 |
1356 drawImageInternal(imageForRendering.get(), actualSrcRect, actualDstRect, sta te().m_globalComposite, state().m_globalBlend); | 1367 drawImageInternal(imageForRendering.get(), actualSrcRect, actualDstRect, sta te().m_globalComposite, state().m_globalBlend); |
1357 } | 1368 } |
1358 | 1369 |
1359 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, float x, float y, ExceptionState& es) | 1370 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, float x, float y, ExceptionState& es) |
1360 { | 1371 { |
1361 if (!image) { | 1372 if (!image) { |
1362 es.throwUninformativeAndGenericDOMException(TypeMismatchError); | 1373 es.throwUninformativeAndGenericDOMException(TypeMismatchError); |
1363 return; | 1374 return; |
1364 } | 1375 } |
1365 LayoutSize size = sizeFor(image); | 1376 LayoutSize size = sizeFor(image, ScaledSize); |
1366 drawImage(image, x, y, size.width(), size.height(), es); | 1377 drawImage(image, x, y, size.width(), size.height(), es); |
1367 } | 1378 } |
1368 | 1379 |
1369 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, | 1380 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, |
1370 float x, float y, float width, float height, ExceptionState& es) | 1381 float x, float y, float width, float height, ExceptionState& es) |
1371 { | 1382 { |
1372 if (!image) { | 1383 if (!image) { |
1373 es.throwUninformativeAndGenericDOMException(TypeMismatchError); | 1384 es.throwUninformativeAndGenericDOMException(TypeMismatchError); |
1374 return; | 1385 return; |
1375 } | 1386 } |
1376 LayoutSize size = sizeFor(image); | 1387 LayoutSize size = sizeFor(image, UnscaledSize); |
1377 drawImage(image, FloatRect(0, 0, size.width(), size.height()), FloatRect(x, y, width, height), es); | 1388 drawImage(image, FloatRect(0, 0, size.width(), size.height()), FloatRect(x, y, width, height), es); |
1378 } | 1389 } |
1379 | 1390 |
1380 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, | 1391 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, |
1381 float sx, float sy, float sw, float sh, | 1392 float sx, float sy, float sw, float sh, |
1382 float dx, float dy, float dw, float dh, ExceptionState& es) | 1393 float dx, float dy, float dw, float dh, ExceptionState& es) |
1383 { | 1394 { |
1384 drawImage(image, FloatRect(sx, sy, sw, sh), FloatRect(dx, dy, dw, dh), es); | 1395 drawImage(image, FloatRect(sx, sy, sw, sh), FloatRect(dx, dy, dw, dh), es); |
1385 } | 1396 } |
1386 | 1397 |
(...skipping 10 matching lines...) Expand all Loading... | |
1397 } | 1408 } |
1398 | 1409 |
1399 if (!std::isfinite(dstRect.x()) || !std::isfinite(dstRect.y()) || !std::isfi nite(dstRect.width()) || !std::isfinite(dstRect.height()) | 1410 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())) | 1411 || !std::isfinite(srcRect.x()) || !std::isfinite(srcRect.y()) || !std::i sfinite(srcRect.width()) || !std::isfinite(srcRect.height())) |
1401 return; | 1412 return; |
1402 | 1413 |
1403 ImageResource* cachedImage = image->cachedImage(); | 1414 ImageResource* cachedImage = image->cachedImage(); |
1404 if (!cachedImage || !image->complete()) | 1415 if (!cachedImage || !image->complete()) |
1405 return; | 1416 return; |
1406 | 1417 |
1407 LayoutSize size = sizeFor(image); | 1418 LayoutSize size = sizeFor(image, UnscaledSize); |
1408 if (!size.width() || !size.height()) { | 1419 if (!size.width() || !size.height()) { |
1409 es.throwUninformativeAndGenericDOMException(InvalidStateError); | 1420 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
1410 return; | 1421 return; |
1411 } | 1422 } |
1412 | 1423 |
1413 if (!dstRect.width() || !dstRect.height()) | 1424 if (!dstRect.width() || !dstRect.height()) |
1414 return; | 1425 return; |
1415 | 1426 |
1416 FloatRect normalizedSrcRect = normalizeRect(srcRect); | 1427 FloatRect normalizedSrcRect = normalizeRect(srcRect); |
1417 FloatRect normalizedDstRect = normalizeRect(dstRect); | 1428 FloatRect normalizedDstRect = normalizeRect(dstRect); |
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2414 const int focusRingWidth = 5; | 2425 const int focusRingWidth = 5; |
2415 const int focusRingOutline = 0; | 2426 const int focusRingOutline = 0; |
2416 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); | 2427 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); |
2417 | 2428 |
2418 c->restore(); | 2429 c->restore(); |
2419 | 2430 |
2420 didDraw(dirtyRect); | 2431 didDraw(dirtyRect); |
2421 } | 2432 } |
2422 | 2433 |
2423 } // namespace WebCore | 2434 } // namespace WebCore |
OLD | NEW |