Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(837)

Unified Diff: Source/core/html/canvas/CanvasRenderingContext2D.cpp

Issue 232313004: Add StrictTypeChecking to CRC2D.{drawImage,createPattern} (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/html/canvas/CanvasRenderingContext2D.cpp
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
index a0807a878501ba7dbf78ad80b7d9f2cee8a31d97..b7d04652b7b7194ab8ac9fbe8a6d3dc20ba6dea6 100644
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
@@ -1468,20 +1468,8 @@ static inline void clipRectsToImageRect(const FloatRect& imageRect, FloatRect* s
dstRect->move(offset);
}
-static bool checkImageSource(CanvasImageSource* imageSource, ExceptionState& exceptionState)
-{
- if (!imageSource) {
- // FIXME: Message should mention ImageBitmap once that feature ships.
- exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrectType(1, String("HTMLImageElement, HTMLCanvasElement or HTMLVideoElement")));
- return false;
- }
- return true;
-}
-
void CanvasRenderingContext2D::drawImage(CanvasImageSource* imageSource, float x, float y, ExceptionState& exceptionState)
{
- if (!checkImageSource(imageSource, exceptionState))
- return;
FloatSize destRectSize = imageSource->defaultDestinationSize();
drawImage(imageSource, x, y, destRectSize.width(), destRectSize.height(), exceptionState);
}
@@ -1489,8 +1477,6 @@ void CanvasRenderingContext2D::drawImage(CanvasImageSource* imageSource, float x
void CanvasRenderingContext2D::drawImage(CanvasImageSource* imageSource,
float x, float y, float width, float height, ExceptionState& exceptionState)
{
- if (!checkImageSource(imageSource, exceptionState))
- return;
FloatSize sourceRectSize = imageSource->sourceSize();
drawImage(imageSource, 0, 0, sourceRectSize.width(), sourceRectSize.height(), x, y, width, height, exceptionState);
}
@@ -1510,9 +1496,6 @@ void CanvasRenderingContext2D::drawImageInternal(CanvasImageSource* imageSource,
float dx, float dy, float dw, float dh, ExceptionState& exceptionState,
CompositeOperator op, blink::WebBlendMode blendMode)
{
- if (!checkImageSource(imageSource, exceptionState))
- return;
-
RefPtr<Image> image;
SourceImageStatus sourceImageStatus;
if (!imageSource->isVideoElement()) {
@@ -1595,6 +1578,8 @@ void CanvasRenderingContext2D::drawImageFromRect(HTMLImageElement* image,
float dx, float dy, float dw, float dh,
const String& compositeOperation)
{
+ if (!image)
+ return;
CompositeOperator op;
blink::WebBlendMode blendOp = blink::WebBlendModeNormal;
if (!parseCompositeAndBlendOperator(compositeOperation, op, blendOp) || blendOp != blink::WebBlendModeNormal)
@@ -1716,8 +1701,6 @@ PassRefPtr<CanvasGradient> CanvasRenderingContext2D::createRadialGradient(float
PassRefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(CanvasImageSource* imageSource,
const String& repetitionType, ExceptionState& exceptionState)
{
- if (!checkImageSource(imageSource, exceptionState))
- return nullptr;
bool repeatX, repeatY;
CanvasPattern::parseRepetitionType(repetitionType, repeatX, repeatY, exceptionState);
if (exceptionState.hadException())

Powered by Google App Engine
This is Rietveld 408576698