Changeset 201664 in webkit
- Timestamp:
- Jun 3, 2016 3:26:50 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r201662 r201664 1 2016-06-03 Chris Dumez <cdumez@apple.com> 2 3 CanvasRenderingContext2D.createPattern() / putImageData() throw wrong exception type 4 https://bugs.webkit.org/show_bug.cgi?id=158322 5 6 Reviewed by Ryosuke Niwa. 7 8 Update several outdated layout tests. 9 10 * canvas/philip/tests/2d.imageData.put.null.html: 11 * canvas/philip/tests/2d.pattern.image.null.html: 12 * canvas/philip/tests/2d.pattern.image.undefined.html: 13 1 14 2016-06-03 Ryan Haddad <ryanhaddad@apple.com> 2 15 -
trunk/LayoutTests/canvas/philip/tests/2d.imageData.put.null.html
r134440 r201664 15 15 try { var _thrown = false; 16 16 ctx.putImageData(null, 0, 0); 17 } catch (e) { if (e. code != DOMException.TYPE_MISMATCH_ERR) _fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TYPE_MISMATCH_ERR: ctx.putImageData(null, 0, 0)"); }17 } catch (e) { if (e.name != "TypeError") _fail("Failed assertion: expected exception of type TypeError, got: "+e.message); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TypeError: ctx.putImageData(null, 0, 0)"); } 18 18 19 19 -
trunk/LayoutTests/canvas/philip/tests/2d.pattern.image.null.html
r134440 r201664 15 15 try { var _thrown = false; 16 16 ctx.createPattern(null, 'repeat'); 17 } catch (e) { if (e. code != DOMException.TYPE_MISMATCH_ERR) _fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TYPE_MISMATCH_ERR: ctx.createPattern(null, 'repeat')"); }17 } catch (e) { if (e.name != "TypeError") _fail("Failed assertion: expected exception of type TypeError, got: "+e.message); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TypeError: ctx.createPattern(null, 'repeat')"); } 18 18 19 19 -
trunk/LayoutTests/canvas/philip/tests/2d.pattern.image.undefined.html
r71481 r201664 15 15 try { var _thrown = false; 16 16 ctx.createPattern(undefined, 'repeat'); 17 } catch (e) { if (e. code != DOMException.TYPE_MISMATCH_ERR) _fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TYPE_MISMATCH_ERR: ctx.createPattern(undefined, 'repeat')"); }17 } catch (e) { if (e.name != "TypeError") _fail("Failed assertion: expected exception of type TypeError, got: "+e.message); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TypeError: ctx.createPattern(undefined, 'repeat')"); } 18 18 19 19 -
trunk/LayoutTests/imported/w3c/ChangeLog
r201627 r201664 1 2016-06-03 Chris Dumez <cdumez@apple.com> 2 3 CanvasRenderingContext2D.createPattern() / putImageData() throw wrong exception type 4 https://bugs.webkit.org/show_bug.cgi?id=158322 5 6 Reviewed by Ryosuke Niwa. 7 8 Rebaseline test now that it is passing. 9 10 * canvas/2d.pattern.image.undefined-expected.txt: 11 1 12 2016-06-02 Chris Dumez <cdumez@apple.com> 2 13 -
trunk/LayoutTests/imported/w3c/canvas/2d.pattern.image.undefined-expected.txt
r201627 r201664 3 3 Defined in "Web IDL" (draft) 4 4 Actual output: 5 Failed assertion: expected exception of type TypeError, got: Error: TypeMismatchError: DOM Exception 17 5 Passed -
trunk/Source/WebCore/ChangeLog
r201663 r201664 1 2016-06-03 Chris Dumez <cdumez@apple.com> 2 3 CanvasRenderingContext2D.createPattern() / putImageData() throw wrong exception type 4 https://bugs.webkit.org/show_bug.cgi?id=158322 5 6 Reviewed by Ryosuke Niwa. 7 8 CanvasRenderingContext2D.createPattern() / putImageData() were throwing the wrong 9 exception type when the first parameter was null. It should throw a TypeError 10 but it was throwing a legacy TYPE_MISMATCH_ERR: 11 - http://www.w3.org/TR/2dcontext/#canvasrenderingcontext2d 12 - http://www.w3.org/TR/2dcontext/#canvasimagesource 13 14 This patch aligns our behavior with the specification. 15 16 No new tests, covered by existing tests. 17 18 * html/canvas/CanvasRenderingContext2D.cpp: 19 (WebCore::CanvasRenderingContext2D::createPattern): 20 (WebCore::CanvasRenderingContext2D::putImageData): 21 (WebCore::CanvasRenderingContext2D::webkitPutImageDataHD): 22 (WebCore::CanvasRenderingContext2D::didDraw): Deleted. 23 (WebCore::CanvasRenderingContext2D::drawFocusIfNeeded): Deleted. 24 (WebCore::CanvasRenderingContext2D::drawFocusIfNeededInternal): Deleted. 25 (WebCore::CanvasRenderingContext2D::font): Deleted. 26 * html/canvas/CanvasRenderingContext2D.h: 27 * html/canvas/CanvasRenderingContext2D.idl: 28 1 29 2016-06-03 Anders Carlsson <andersca@apple.com> 2 30 -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
r201629 r201664 1745 1745 } 1746 1746 1747 RefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLImageElement *imageElement,1747 RefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLImageElement& imageElement, 1748 1748 const String& repetitionType, ExceptionCode& ec) 1749 1749 { 1750 if (!imageElement) {1751 ec = TYPE_MISMATCH_ERR;1752 return nullptr;1753 }1754 1750 bool repeatX, repeatY; 1755 1751 ec = 0; … … 1758 1754 return nullptr; 1759 1755 1760 CachedImage* cachedImage = imageElement ->cachedImage();1756 CachedImage* cachedImage = imageElement.cachedImage(); 1761 1757 // If the image loading hasn't started or the image is not complete, it is not fully decodable. 1762 if (!cachedImage || !imageElement ->complete())1758 if (!cachedImage || !imageElement.complete()) 1763 1759 return nullptr; 1764 1760 … … 1768 1764 } 1769 1765 1770 if (!imageElement ->cachedImage()->imageForRenderer(imageElement->renderer()))1766 if (!imageElement.cachedImage()->imageForRenderer(imageElement.renderer())) 1771 1767 return CanvasPattern::create(Image::nullImage(), repeatX, repeatY, true); 1772 1768 … … 1782 1778 originClean = false; 1783 1779 1784 return CanvasPattern::create(cachedImage->imageForRenderer(imageElement ->renderer()), repeatX, repeatY, originClean);1785 } 1786 1787 RefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLCanvasElement *canvas,1780 return CanvasPattern::create(cachedImage->imageForRenderer(imageElement.renderer()), repeatX, repeatY, originClean); 1781 } 1782 1783 RefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLCanvasElement& canvas, 1788 1784 const String& repetitionType, ExceptionCode& ec) 1789 1785 { 1790 if (!canvas) { 1791 ec = TYPE_MISMATCH_ERR; 1792 return nullptr; 1793 } 1794 if (!canvas->width() || !canvas->height() || !canvas->buffer()) { 1786 if (!canvas.width() || !canvas.height() || !canvas.buffer()) { 1795 1787 ec = INVALID_STATE_ERR; 1796 1788 return nullptr; … … 1802 1794 if (ec) 1803 1795 return nullptr; 1804 return CanvasPattern::create(canvas ->copiedImage(), repeatX, repeatY, canvas->originClean());1796 return CanvasPattern::create(canvas.copiedImage(), repeatX, repeatY, canvas.originClean()); 1805 1797 } 1806 1798 … … 2017 2009 } 2018 2010 2019 void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy, ExceptionCode& ec) 2020 { 2021 if (!data) { 2022 ec = TYPE_MISMATCH_ERR; 2023 return; 2024 } 2025 putImageData(data, dx, dy, 0, 0, data->width(), data->height(), ec); 2026 } 2027 2028 void CanvasRenderingContext2D::webkitPutImageDataHD(ImageData* data, float dx, float dy, ExceptionCode& ec) 2029 { 2030 if (!data) { 2031 ec = TYPE_MISMATCH_ERR; 2032 return; 2033 } 2034 webkitPutImageDataHD(data, dx, dy, 0, 0, data->width(), data->height(), ec); 2035 } 2036 2037 void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy, float dirtyX, float dirtyY, 2011 void CanvasRenderingContext2D::putImageData(ImageData& data, float dx, float dy, ExceptionCode& ec) 2012 { 2013 putImageData(data, dx, dy, 0, 0, data.width(), data.height(), ec); 2014 } 2015 2016 void CanvasRenderingContext2D::webkitPutImageDataHD(ImageData& data, float dx, float dy, ExceptionCode& ec) 2017 { 2018 webkitPutImageDataHD(data, dx, dy, 0, 0, data.width(), data.height(), ec); 2019 } 2020 2021 void CanvasRenderingContext2D::putImageData(ImageData& data, float dx, float dy, float dirtyX, float dirtyY, 2038 2022 float dirtyWidth, float dirtyHeight, ExceptionCode& ec) 2039 2023 { … … 2041 2025 } 2042 2026 2043 void CanvasRenderingContext2D::webkitPutImageDataHD(ImageData *data, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionCode& ec)2027 void CanvasRenderingContext2D::webkitPutImageDataHD(ImageData& data, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionCode& ec) 2044 2028 { 2045 2029 putImageData(data, ImageBuffer::BackingStoreCoordinateSystem, dx, dy, dirtyX, dirtyY, dirtyWidth, dirtyHeight, ec); … … 2067 2051 } 2068 2052 2069 void CanvasRenderingContext2D::putImageData(ImageData *data, ImageBuffer::CoordinateSystem coordinateSystem, float dx, float dy, float dirtyX, float dirtyY,2053 void CanvasRenderingContext2D::putImageData(ImageData& data, ImageBuffer::CoordinateSystem coordinateSystem, float dx, float dy, float dirtyX, float dirtyY, 2070 2054 float dirtyWidth, float dirtyHeight, ExceptionCode& ec) 2071 2055 { 2072 if (!data) {2073 ec = TYPE_MISMATCH_ERR;2074 return;2075 }2076 2056 if (!std::isfinite(dx) || !std::isfinite(dy) || !std::isfinite(dirtyX) || !std::isfinite(dirtyY) || !std::isfinite(dirtyWidth) || !std::isfinite(dirtyHeight)) { 2077 2057 ec = NOT_SUPPORTED_ERR; … … 2094 2074 2095 2075 FloatRect clipRect(dirtyX, dirtyY, dirtyWidth, dirtyHeight); 2096 clipRect.intersect(IntRect(0, 0, data ->width(), data->height()));2076 clipRect.intersect(IntRect(0, 0, data.width(), data.height())); 2097 2077 IntSize destOffset(static_cast<int>(dx), static_cast<int>(dy)); 2098 2078 IntRect destRect = enclosingIntRect(clipRect); … … 2104 2084 sourceRect.move(-destOffset); 2105 2085 2106 buffer->putByteArray(Unmultiplied, data ->data(), IntSize(data->width(), data->height()), sourceRect, IntPoint(destOffset), coordinateSystem);2086 buffer->putByteArray(Unmultiplied, data.data(), IntSize(data.width(), data.height()), sourceRect, IntPoint(destOffset), coordinateSystem); 2107 2087 2108 2088 didDraw(destRect, CanvasDidDrawApplyNone); // ignore transform, shadow and clip -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h
r200361 r201664 181 181 RefPtr<CanvasGradient> createLinearGradient(float x0, float y0, float x1, float y1, ExceptionCode&); 182 182 RefPtr<CanvasGradient> createRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1, ExceptionCode&); 183 RefPtr<CanvasPattern> createPattern(HTMLImageElement *, const String& repetitionType, ExceptionCode&);184 RefPtr<CanvasPattern> createPattern(HTMLCanvasElement *, const String& repetitionType, ExceptionCode&);183 RefPtr<CanvasPattern> createPattern(HTMLImageElement&, const String& repetitionType, ExceptionCode&); 184 RefPtr<CanvasPattern> createPattern(HTMLCanvasElement&, const String& repetitionType, ExceptionCode&); 185 185 186 186 RefPtr<ImageData> createImageData(RefPtr<ImageData>&&, ExceptionCode&) const; … … 188 188 RefPtr<ImageData> getImageData(float sx, float sy, float sw, float sh, ExceptionCode&) const; 189 189 RefPtr<ImageData> webkitGetImageDataHD(float sx, float sy, float sw, float sh, ExceptionCode&) const; 190 void putImageData(ImageData *, float dx, float dy, ExceptionCode&);191 void putImageData(ImageData *, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionCode&);192 void webkitPutImageDataHD(ImageData *, float dx, float dy, ExceptionCode&);193 void webkitPutImageDataHD(ImageData *, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionCode&);190 void putImageData(ImageData&, float dx, float dy, ExceptionCode&); 191 void putImageData(ImageData&, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionCode&); 192 void webkitPutImageDataHD(ImageData&, float dx, float dy, ExceptionCode&); 193 void webkitPutImageDataHD(ImageData&, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionCode&); 194 194 195 195 void drawFocusIfNeeded(Element*); … … 371 371 372 372 RefPtr<ImageData> getImageData(ImageBuffer::CoordinateSystem, float sx, float sy, float sw, float sh, ExceptionCode&) const; 373 void putImageData(ImageData *, ImageBuffer::CoordinateSystem, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionCode&);373 void putImageData(ImageData&, ImageBuffer::CoordinateSystem, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionCode&); 374 374 375 375 bool is2d() const override { return true; } -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl
r200058 r201664 170 170 unrestricted float y, unrestricted float k, unrestricted float a); 171 171 172 [RaisesException] void putImageData(ImageData ?imagedata, float dx, float dy);173 [RaisesException] void putImageData(ImageData ?imagedata, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight);174 175 [RaisesException] void webkitPutImageDataHD(ImageData ?imagedata, float dx, float dy);176 [RaisesException] void webkitPutImageDataHD(ImageData ?imagedata, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight);177 178 [RaisesException] CanvasPattern createPattern(HTMLCanvasElement ?canvas, [TreatNullAs=EmptyString] DOMString repetitionType);179 [RaisesException] CanvasPattern createPattern(HTMLImageElement ?image, [TreatNullAs=EmptyString] DOMString repetitionType);172 [RaisesException] void putImageData(ImageData imagedata, float dx, float dy); 173 [RaisesException] void putImageData(ImageData imagedata, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight); 174 175 [RaisesException] void webkitPutImageDataHD(ImageData imagedata, float dx, float dy); 176 [RaisesException] void webkitPutImageDataHD(ImageData imagedata, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight); 177 178 [RaisesException] CanvasPattern createPattern(HTMLCanvasElement canvas, [TreatNullAs=EmptyString] DOMString repetitionType); 179 [RaisesException] CanvasPattern createPattern(HTMLImageElement image, [TreatNullAs=EmptyString] DOMString repetitionType); 180 180 [RaisesException] ImageData createImageData(ImageData? imagedata); 181 181 [RaisesException] ImageData createImageData(float sw, float sh);
Note: See TracChangeset
for help on using the changeset viewer.