| Index: third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp
|
| diff --git a/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp b/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp
|
| index 7072ec0678cc326f28819648969157fa2994574a..4ea3018bc700527940311ac9b4093ab1982377cf 100644
|
| --- a/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp
|
| +++ b/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp
|
| @@ -856,8 +856,9 @@ static inline CanvasImageSource* toImageSourceInternal(const CanvasImageSourceUn
|
| void BaseRenderingContext2D::drawImage(const CanvasImageSourceUnion& imageSource, double x, double y, ExceptionState& exceptionState)
|
| {
|
| CanvasImageSource* imageSourceInternal = toImageSourceInternal(imageSource);
|
| - FloatSize sourceRectSize = imageSourceInternal->elementSize();
|
| - FloatSize destRectSize = imageSourceInternal->defaultDestinationSize();
|
| + FloatSize canvasSize(width(), height());
|
| + FloatSize sourceRectSize = imageSourceInternal->elementSize(canvasSize);
|
| + FloatSize destRectSize = imageSourceInternal->defaultDestinationSize(canvasSize);
|
| drawImage(imageSourceInternal, 0, 0, sourceRectSize.width(), sourceRectSize.height(), x, y, destRectSize.width(), destRectSize.height(), exceptionState);
|
| }
|
|
|
| @@ -865,7 +866,8 @@ void BaseRenderingContext2D::drawImage(const CanvasImageSourceUnion& imageSource
|
| double x, double y, double width, double height, ExceptionState& exceptionState)
|
| {
|
| CanvasImageSource* imageSourceInternal = toImageSourceInternal(imageSource);
|
| - FloatSize sourceRectSize = imageSourceInternal->elementSize();
|
| + FloatSize canvasSize(this->width(), this->height());
|
| + FloatSize sourceRectSize = imageSourceInternal->elementSize(canvasSize);
|
| drawImage(imageSourceInternal, 0, 0, sourceRectSize.width(), sourceRectSize.height(), x, y, width, height, exceptionState);
|
| }
|
|
|
| @@ -977,7 +979,7 @@ void BaseRenderingContext2D::drawImage(CanvasImageSource* imageSource,
|
| image = imageSource->getSourceImageForCanvas(&sourceImageStatus, hint, SnapshotReasonDrawImage);
|
| if (sourceImageStatus == UndecodableSourceImageStatus)
|
| exceptionState.throwDOMException(InvalidStateError, "The HTMLImageElement provided is in the 'broken' state.");
|
| - if (!image || !image->width() || !image->height())
|
| + if (!image || !image->defaultConcreteObjectSizeWidth() || !image->defaultConcreteObjectSizeHeight())
|
| return;
|
| } else {
|
| if (!static_cast<HTMLVideoElement*>(imageSource)->hasAvailableVideoFrame())
|
| @@ -992,7 +994,9 @@ void BaseRenderingContext2D::drawImage(CanvasImageSource* imageSource,
|
| FloatRect srcRect = normalizeRect(FloatRect(sx, sy, sw, sh));
|
| FloatRect dstRect = normalizeRect(FloatRect(dx, dy, dw, dh));
|
|
|
| - clipRectsToImageRect(FloatRect(FloatPoint(), imageSource->elementSize()), &srcRect, &dstRect);
|
| + FloatSize canvasSize(width(), height());
|
| + FloatSize elementSize(imageSource->elementSize(canvasSize));
|
| + clipRectsToImageRect(FloatRect(FloatPoint(), elementSize), &srcRect, &dstRect);
|
|
|
| imageSource->adjustDrawRects(&srcRect, &dstRect);
|
|
|
| @@ -1023,7 +1027,7 @@ void BaseRenderingContext2D::drawImage(CanvasImageSource* imageSource,
|
| if (ExpensiveCanvasHeuristicParameters::SVGImageSourcesAreExpensive && imageSource->isSVGSource())
|
| isExpensive = true;
|
|
|
| - if (imageSource->elementSize().width() * imageSource->elementSize().height() > width() * height() * ExpensiveCanvasHeuristicParameters::ExpensiveImageSizeRatio)
|
| + if (elementSize.width() * elementSize.height() > width() * height() * ExpensiveCanvasHeuristicParameters::ExpensiveImageSizeRatio)
|
| isExpensive = true;
|
|
|
| if (isExpensive) {
|
| @@ -1089,7 +1093,7 @@ CanvasPattern* BaseRenderingContext2D::createPattern(const CanvasImageSourceUnio
|
| case NormalSourceImageStatus:
|
| break;
|
| case ZeroSizeCanvasSourceImageStatus:
|
| - exceptionState.throwDOMException(InvalidStateError, String::format("The canvas %s is 0.", imageSourceInternal->elementSize().width() ? "height" : "width"));
|
| + exceptionState.throwDOMException(InvalidStateError, String::format("The canvas %s is 0.", imageSourceInternal->elementSize(FloatSize(width(), height())).width() ? "height" : "width"));
|
| return nullptr;
|
| case UndecodableSourceImageStatus:
|
| exceptionState.throwDOMException(InvalidStateError, "Source image is in the 'broken' state.");
|
|
|