diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index c7ec95b97322b70a62f948f246c0f032df9c4ad7..eccd111391e6c4495cc7f0728a4c165e1944096f 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,17 @@ +2010-12-08 Mihai Parparita + + Reviewed by Darin Adler. + + fast/canvas/canvas-getImageData-negative-source.html fails on Mac + https://bugs.webkit.org/show_bug.cgi?id=47901 + + Add test for rounding behavior. Remove now-passing tests from + test_expectations.txt. + + * fast/canvas/canvas-getImageData-rounding-expected.txt: Added. + * fast/canvas/canvas-getImageData-rounding.html: Added. + * platform/chromium/test_expectations.txt: + 2010-12-10 Alejandro G. Castro Unreviewed GTK test expectation update. diff --git a/LayoutTests/fast/canvas/canvas-getImageData-rounding-expected.txt b/LayoutTests/fast/canvas/canvas-getImageData-rounding-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..e7ea28bb747d73ff5d05d0d642c8f7dad923463a --- /dev/null +++ b/LayoutTests/fast/canvas/canvas-getImageData-rounding-expected.txt @@ -0,0 +1,36 @@ +Test the handling of non-integer source coordinates in getImageData(). + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +getImageData(0, 0, 20, 10) +PASS imageData.width is 20 +PASS imageData.height is 10 +getImageData(0.1, 0.2, 20, 10) +PASS imageData.width is 21 +PASS imageData.height is 11 +getImageData(0.9, 0.8, 20, 10) +PASS imageData.width is 21 +PASS imageData.height is 11 +getImageData(0, 0, 19.9, 9.9) +PASS imageData.width is 20 +PASS imageData.height is 10 +getImageData(0, 0, 19.1, 9.1) +PASS imageData.width is 20 +PASS imageData.height is 10 +getImageData(0.9, 0, 0.2, 10) +PASS imageData.width is 2 +PASS imageData.height is 10 +getImageData(-1, -1, 20, 10) +PASS imageData.width is 20 +PASS imageData.height is 10 +getImageData(-1.1, 0, 20, 10) +PASS imageData.width is 21 +PASS imageData.height is 10 +getImageData(-1.9, 0, 20, 10) +PASS imageData.width is 21 +PASS imageData.height is 10 +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/fast/canvas/canvas-getImageData-rounding.html b/LayoutTests/fast/canvas/canvas-getImageData-rounding.html new file mode 100644 index 0000000000000000000000000000000000000000..fe4f07f3a001d4455fafd091dab4a59cb03bc293 --- /dev/null +++ b/LayoutTests/fast/canvas/canvas-getImageData-rounding.html @@ -0,0 +1,48 @@ + + + + + + + +

+
+ + + + diff --git a/LayoutTests/platform/chromium/test_expectations.txt b/LayoutTests/platform/chromium/test_expectations.txt index 74caf647fb75559ffba66d2d79c7a86cb9751bc3..8e66305f69b3ec34e8195a44a66689bbedbf4f5f 100644 --- a/LayoutTests/platform/chromium/test_expectations.txt +++ b/LayoutTests/platform/chromium/test_expectations.txt @@ -2415,14 +2415,10 @@ BUGWK45991 MAC : canvas/philip/tests/2d.shadow.enable.blur.html = TEXT BUGWK45991 MAC : canvas/philip/tests/2d.shadow.enable.x.html = TEXT BUGWK45991 MAC : canvas/philip/tests/2d.shadow.enable.y.html = TEXT BUGWK45991 MAC : canvas/philip/tests/2d.strokeRect.zero.4.html = TEXT -BUGWK45991 MAC : canvas/philip/tests/2d.imageData.get.source.outside.html = TEXT BUGWK45991 WIN : canvas/philip/tests/2d.gradient.radial.touch2.html = TEXT BUGWK40147 : canvas/philip/tests/toDataURL.jpeg.alpha.html = TEXT BUG61824 : canvas/philip/tests/2d.pattern.image.string.html = TEXT -// Failures after WebKit roll 70949:71000 -BUGWK45991 MAC : canvas/philip/tests/2d.imageData.get.source.negative.html = TEXT - // Flaky tests BUG44229 WIN LINUX : fast/loader/recursive-before-unload-crash.html = PASS TEXT @@ -2924,8 +2920,6 @@ BUG47578 : printing/simultaneous-position-float-change.html = IMAGE+TEXT BUG59647 WIN : svg/dom/length-list-parser.html = PASS CRASH -BUGWK47901 MAC : fast/canvas/canvas-getImageData-negative-source.html = TEXT - // We don't support layoutTestController.nodesFromRect so this test just times out BUGWK46600 SKIP : fast/dom/nodesFromRect-links-and-text.html = TEXT BUGWK46600 SKIP : fast/dom/nodesFromRect-inner-documents.html = TEXT diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 9d01cbe2ae75a803048ff84c866b718eb27e259b..90b945754038d7f690064f1f2c4ffbe18267a25a 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,24 @@ +2010-12-08 Mihai Parparita + + Reviewed by Darin Adler. + + fast/canvas/canvas-getImageData-negative-source.html fails on Mac + https://bugs.webkit.org/show_bug.cgi?id=47901 + + Test: fast/canvas/canvas-getImageData-rounding.html + + static_cast is generally not what we want in + convertLogicalToDevice. It produces inconsistent results when compiling + for 32-bit vs. 64-bit, and in any case we weren't getting correct + rounding behavior for source rectangles (e.g. we should get a source rect + of width 2 if the source X is 0.9 and the source width is 0.2, but we + were getting only one of width 1). + + * html/HTMLCanvasElement.cpp: + (WebCore::HTMLCanvasElement::convertLogicalToDevice): + (WebCore::HTMLCanvasElement::convertToValidDeviceSize): + * html/HTMLCanvasElement.h: + 2010-12-10 Hironori Bono Reviewed by Ojan Vafai. diff --git a/WebCore/html/HTMLCanvasElement.cpp b/WebCore/html/HTMLCanvasElement.cpp index fea70d1635e051f15524a58fba4a629acc638b68..4130e382fdf420fdf07dc387bc1ea168ff217d74 100644 --- a/WebCore/html/HTMLCanvasElement.cpp +++ b/WebCore/html/HTMLCanvasElement.cpp @@ -322,31 +322,33 @@ String HTMLCanvasElement::toDataURL(const String& mimeType, const double* qualit IntRect HTMLCanvasElement::convertLogicalToDevice(const FloatRect& logicalRect) const { - return IntRect(convertLogicalToDevice(logicalRect.location()), convertLogicalToDevice(logicalRect.size())); + float left = floorf(logicalRect.left() * m_pageScaleFactor); + float top = floorf(logicalRect.top() * m_pageScaleFactor); + float right = ceilf(logicalRect.right() * m_pageScaleFactor); + float bottom = ceilf(logicalRect.bottom() * m_pageScaleFactor); + + return IntRect(IntPoint(left, top), convertToValidDeviceSize(right - left, bottom - top)); } IntSize HTMLCanvasElement::convertLogicalToDevice(const FloatSize& logicalSize) const { - float wf = ceilf(logicalSize.width() * m_pageScaleFactor); - float hf = ceilf(logicalSize.height() * m_pageScaleFactor); + return convertToValidDeviceSize(logicalSize.width() * m_pageScaleFactor, logicalSize.height() * m_pageScaleFactor); +} - if (!(wf >= 1 && hf >= 1 && wf * hf <= MaxCanvasArea)) +IntSize HTMLCanvasElement::convertToValidDeviceSize(float width, float height) const +{ + width = ceilf(width); + height = ceilf(height); + + if (width < 1 || height < 1 || width * height > MaxCanvasArea) return IntSize(); #if PLATFORM(SKIA) - if (wf > MaxSkiaDim || hf > MaxSkiaDim) + if (width > MaxSkiaDim || height > MaxSkiaDim) return IntSize(); #endif - return IntSize(static_cast(wf), static_cast(hf)); -} - -IntPoint HTMLCanvasElement::convertLogicalToDevice(const FloatPoint& logicalPos) const -{ - float xf = logicalPos.x() * m_pageScaleFactor; - float yf = logicalPos.y() * m_pageScaleFactor; - - return IntPoint(static_cast(xf), static_cast(yf)); + return IntSize(width, height); } const SecurityOrigin& HTMLCanvasElement::securityOrigin() const diff --git a/WebCore/html/HTMLCanvasElement.h b/WebCore/html/HTMLCanvasElement.h index d9b7736812601f59fb0e17c12916d87edeaea0c9..1081c33afebf1fa3f55684c407524bbd1aeaf131 100644 --- a/WebCore/html/HTMLCanvasElement.h +++ b/WebCore/html/HTMLCanvasElement.h @@ -107,7 +107,7 @@ public: IntRect convertLogicalToDevice(const FloatRect&) const; IntSize convertLogicalToDevice(const FloatSize&) const; - IntPoint convertLogicalToDevice(const FloatPoint&) const; + IntSize convertToValidDeviceSize(float width, float height) const; const SecurityOrigin& securityOrigin() const; void setOriginTainted() { m_originClean = false; }