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

Side by Side Diff: Source/core/html/canvas/CanvasRenderingContext2D.cpp

Issue 259773008: Add support for type checking of floating point arguments as [TypeChecking=Unrestricted] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: std::isfinite Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1777 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 return nullptr; 1788 return nullptr;
1789 } 1789 }
1790 1790
1791 PassRefPtrWillBeRawPtr<ImageData> CanvasRenderingContext2D::createImageData(Pass RefPtrWillBeRawPtr<ImageData> imageData) const 1791 PassRefPtrWillBeRawPtr<ImageData> CanvasRenderingContext2D::createImageData(Pass RefPtrWillBeRawPtr<ImageData> imageData) const
1792 { 1792 {
1793 return createEmptyImageData(imageData->size()); 1793 return createEmptyImageData(imageData->size());
1794 } 1794 }
1795 1795
1796 PassRefPtrWillBeRawPtr<ImageData> CanvasRenderingContext2D::createImageData(floa t sw, float sh, ExceptionState& exceptionState) const 1796 PassRefPtrWillBeRawPtr<ImageData> CanvasRenderingContext2D::createImageData(floa t sw, float sh, ExceptionState& exceptionState) const
1797 { 1797 {
1798 if (!sw || !sh) 1798 if (!sw || !sh) {
1799 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s is 0.", sw ? "height" : "width")); 1799 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s is 0.", sw ? "height" : "width"));
1800 else if (!std::isfinite(sw))
1801 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::n otAFiniteNumber(sw, "source width"));
1802 else if (!std::isfinite(sh))
1803 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::n otAFiniteNumber(sh, "source height"));
1804
1805 if (exceptionState.hadException())
1806 return nullptr; 1800 return nullptr;
1801 }
1807 1802
1808 FloatSize logicalSize(fabs(sw), fabs(sh)); 1803 FloatSize logicalSize(fabs(sw), fabs(sh));
1809 if (!logicalSize.isExpressibleAsIntSize()) 1804 if (!logicalSize.isExpressibleAsIntSize())
1810 return nullptr; 1805 return nullptr;
1811 1806
1812 IntSize size = expandedIntSize(logicalSize); 1807 IntSize size = expandedIntSize(logicalSize);
1813 if (size.width() < 1) 1808 if (size.width() < 1)
1814 size.setWidth(1); 1809 size.setWidth(1);
1815 if (size.height() < 1) 1810 if (size.height() < 1)
1816 size.setHeight(1); 1811 size.setHeight(1);
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
2426 c->setAlphaAsFloat(1.0); 2421 c->setAlphaAsFloat(1.0);
2427 c->clearShadow(); 2422 c->clearShadow();
2428 c->setCompositeOperation(CompositeSourceOver, blink::WebBlendModeNormal); 2423 c->setCompositeOperation(CompositeSourceOver, blink::WebBlendModeNormal);
2429 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); 2424 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor);
2430 c->restore(); 2425 c->restore();
2431 2426
2432 didDraw(dirtyRect); 2427 didDraw(dirtyRect);
2433 } 2428 }
2434 2429
2435 } // namespace WebCore 2430 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698