- Revision
- 197727
- Author
- [email protected]
- Date
- 2016-03-07 22:42:51 -0800 (Mon, 07 Mar 2016)
Log Message
Align HTMLCanvasElement.width / height with the specification
https://bugs.webkit.org/show_bug.cgi?id=155156
Reviewed by Ryosuke Niwa.
LayoutTests/imported/w3c:
Rebaseline now that more checks are passing.
* web-platform-tests/html/dom/reflection-embedded-expected.txt:
Source/WebCore:
Align HTMLCanvasElement.width / height with the specification:
- https://html.spec.whatwg.org/multipage/scripting.html#dom-canvas-width
- https://html.spec.whatwg.org/multipage/scripting.html#attr-canvas-width
In particular, the following changes were made:
1. The attributes are now 'unsigned long' instead of 'long'
2. The corresponding content attributes are parsed as per the HTML rules
for passing non-negative integers.
3. Upon setting, if the value is out-of-range, the content attributes is
set to its default value.
No new tests, already covered by existing test.
* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::setHeight):
(WebCore::HTMLCanvasElement::setWidth):
(WebCore::HTMLCanvasElement::reset):
* html/HTMLCanvasElement.h:
* html/HTMLCanvasElement.idl:
Modified Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (197726 => 197727)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2016-03-08 06:38:10 UTC (rev 197726)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2016-03-08 06:42:51 UTC (rev 197727)
@@ -1,5 +1,16 @@
2016-03-07 Chris Dumez <[email protected]>
+ Align HTMLCanvasElement.width / height with the specification
+ https://bugs.webkit.org/show_bug.cgi?id=155156
+
+ Reviewed by Ryosuke Niwa.
+
+ Rebaseline now that more checks are passing.
+
+ * web-platform-tests/html/dom/reflection-embedded-expected.txt:
+
+2016-03-07 Chris Dumez <[email protected]>
+
Stop clamping HTMLElement.tabIndex to the range of a short
https://bugs.webkit.org/show_bug.cgi?id=155159
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-embedded-expected.txt (197726 => 197727)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-embedded-expected.txt 2016-03-08 06:38:10 UTC (rev 197726)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-embedded-expected.txt 2016-03-08 06:42:51 UTC (rev 197727)
@@ -14514,7 +14514,7 @@
PASS canvas.width: setAttribute() to "\t7" followed by getAttribute()
PASS canvas.width: setAttribute() to "\t7" followed by IDL get
PASS canvas.width: setAttribute() to "\v7" followed by getAttribute()
-FAIL canvas.width: setAttribute() to "\v7" followed by IDL get assert_equals: expected 300 but got 7
+PASS canvas.width: setAttribute() to "\v7" followed by IDL get
PASS canvas.width: setAttribute() to "\f7" followed by getAttribute()
PASS canvas.width: setAttribute() to "\f7" followed by IDL get
PASS canvas.width: setAttribute() to " 7" followed by getAttribute()
@@ -14528,39 +14528,39 @@
PASS canvas.width: setAttribute() to "\r7" followed by getAttribute()
PASS canvas.width: setAttribute() to "\r7" followed by IDL get
PASS canvas.width: setAttribute() to "
7" followed by getAttribute()
-FAIL canvas.width: setAttribute() to "
7" followed by IDL get assert_equals: expected 300 but got 7
+PASS canvas.width: setAttribute() to "
7" followed by IDL get
PASS canvas.width: setAttribute() to "
7" followed by getAttribute()
PASS canvas.width: setAttribute() to "
7" followed by IDL get
PASS canvas.width: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.width: setAttribute() to " 7" followed by IDL get assert_equals: expected 300 but got 7
+PASS canvas.width: setAttribute() to " 7" followed by IDL get
PASS canvas.width: setAttribute() to "7" followed by getAttribute()
PASS canvas.width: setAttribute() to "7" followed by IDL get
PASS canvas.width: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.width: setAttribute() to " 7" followed by IDL get assert_equals: expected 300 but got 7
+PASS canvas.width: setAttribute() to " 7" followed by IDL get
PASS canvas.width: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.width: setAttribute() to " 7" followed by IDL get assert_equals: expected 300 but got 7
+PASS canvas.width: setAttribute() to " 7" followed by IDL get
PASS canvas.width: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.width: setAttribute() to " 7" followed by IDL get assert_equals: expected 300 but got 7
+PASS canvas.width: setAttribute() to " 7" followed by IDL get
PASS canvas.width: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.width: setAttribute() to " 7" followed by IDL get assert_equals: expected 300 but got 7
+PASS canvas.width: setAttribute() to " 7" followed by IDL get
PASS canvas.width: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.width: setAttribute() to " 7" followed by IDL get assert_equals: expected 300 but got 7
+PASS canvas.width: setAttribute() to " 7" followed by IDL get
PASS canvas.width: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.width: setAttribute() to " 7" followed by IDL get assert_equals: expected 300 but got 7
+PASS canvas.width: setAttribute() to " 7" followed by IDL get
PASS canvas.width: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.width: setAttribute() to " 7" followed by IDL get assert_equals: expected 300 but got 7
+PASS canvas.width: setAttribute() to " 7" followed by IDL get
PASS canvas.width: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.width: setAttribute() to " 7" followed by IDL get assert_equals: expected 300 but got 7
+PASS canvas.width: setAttribute() to " 7" followed by IDL get
PASS canvas.width: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.width: setAttribute() to " 7" followed by IDL get assert_equals: expected 300 but got 7
+PASS canvas.width: setAttribute() to " 7" followed by IDL get
PASS canvas.width: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.width: setAttribute() to " 7" followed by IDL get assert_equals: expected 300 but got 7
+PASS canvas.width: setAttribute() to " 7" followed by IDL get
PASS canvas.width: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.width: setAttribute() to " 7" followed by IDL get assert_equals: expected 300 but got 7
+PASS canvas.width: setAttribute() to " 7" followed by IDL get
PASS canvas.width: setAttribute() to " 7" followed by getAttribute()
PASS canvas.width: setAttribute() to " 7" followed by IDL get
PASS canvas.width: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.width: setAttribute() to " 7" followed by IDL get assert_equals: expected 300 but got 7
+PASS canvas.width: setAttribute() to " 7" followed by IDL get
PASS canvas.width: setAttribute() to " \0\x01\x02\x03\x04\x05\x06\x07 \b\t\n\v\f\r\x0e\x0f \x10\x11\x12\x13\x14\x15\x16\x17 \x18\x19\x1a\x1b\x1c\x1d\x1e\x1f foo " followed by getAttribute()
PASS canvas.width: setAttribute() to " \0\x01\x02\x03\x04\x05\x06\x07 \b\t\n\v\f\r\x0e\x0f \x10\x11\x12\x13\x14\x15\x16\x17 \x18\x19\x1a\x1b\x1c\x1d\x1e\x1f foo " followed by IDL get
PASS canvas.width: setAttribute() to undefined followed by getAttribute()
@@ -14598,10 +14598,10 @@
PASS canvas.width: IDL set to "-0" followed by getAttribute()
PASS canvas.width: IDL set to "-0" followed by IDL get
PASS canvas.width: IDL set to 2147483648 should not throw
-FAIL canvas.width: IDL set to 2147483648 followed by getAttribute() assert_equals: expected "300" but got "-2147483648"
+PASS canvas.width: IDL set to 2147483648 followed by getAttribute()
PASS canvas.width: IDL set to 2147483648 followed by IDL get
PASS canvas.width: IDL set to 4294967295 should not throw
-FAIL canvas.width: IDL set to 4294967295 followed by getAttribute() assert_equals: expected "300" but got "-1"
+PASS canvas.width: IDL set to 4294967295 followed by getAttribute()
PASS canvas.width: IDL set to 4294967295 followed by IDL get
PASS canvas.height: typeof IDL attribute
PASS canvas.height: IDL get with DOM attribute unset
@@ -14638,7 +14638,7 @@
PASS canvas.height: setAttribute() to "\t7" followed by getAttribute()
PASS canvas.height: setAttribute() to "\t7" followed by IDL get
PASS canvas.height: setAttribute() to "\v7" followed by getAttribute()
-FAIL canvas.height: setAttribute() to "\v7" followed by IDL get assert_equals: expected 150 but got 7
+PASS canvas.height: setAttribute() to "\v7" followed by IDL get
PASS canvas.height: setAttribute() to "\f7" followed by getAttribute()
PASS canvas.height: setAttribute() to "\f7" followed by IDL get
PASS canvas.height: setAttribute() to " 7" followed by getAttribute()
@@ -14652,39 +14652,39 @@
PASS canvas.height: setAttribute() to "\r7" followed by getAttribute()
PASS canvas.height: setAttribute() to "\r7" followed by IDL get
PASS canvas.height: setAttribute() to "
7" followed by getAttribute()
-FAIL canvas.height: setAttribute() to "
7" followed by IDL get assert_equals: expected 150 but got 7
+PASS canvas.height: setAttribute() to "
7" followed by IDL get
PASS canvas.height: setAttribute() to "
7" followed by getAttribute()
PASS canvas.height: setAttribute() to "
7" followed by IDL get
PASS canvas.height: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.height: setAttribute() to " 7" followed by IDL get assert_equals: expected 150 but got 7
+PASS canvas.height: setAttribute() to " 7" followed by IDL get
PASS canvas.height: setAttribute() to "7" followed by getAttribute()
PASS canvas.height: setAttribute() to "7" followed by IDL get
PASS canvas.height: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.height: setAttribute() to " 7" followed by IDL get assert_equals: expected 150 but got 7
+PASS canvas.height: setAttribute() to " 7" followed by IDL get
PASS canvas.height: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.height: setAttribute() to " 7" followed by IDL get assert_equals: expected 150 but got 7
+PASS canvas.height: setAttribute() to " 7" followed by IDL get
PASS canvas.height: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.height: setAttribute() to " 7" followed by IDL get assert_equals: expected 150 but got 7
+PASS canvas.height: setAttribute() to " 7" followed by IDL get
PASS canvas.height: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.height: setAttribute() to " 7" followed by IDL get assert_equals: expected 150 but got 7
+PASS canvas.height: setAttribute() to " 7" followed by IDL get
PASS canvas.height: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.height: setAttribute() to " 7" followed by IDL get assert_equals: expected 150 but got 7
+PASS canvas.height: setAttribute() to " 7" followed by IDL get
PASS canvas.height: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.height: setAttribute() to " 7" followed by IDL get assert_equals: expected 150 but got 7
+PASS canvas.height: setAttribute() to " 7" followed by IDL get
PASS canvas.height: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.height: setAttribute() to " 7" followed by IDL get assert_equals: expected 150 but got 7
+PASS canvas.height: setAttribute() to " 7" followed by IDL get
PASS canvas.height: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.height: setAttribute() to " 7" followed by IDL get assert_equals: expected 150 but got 7
+PASS canvas.height: setAttribute() to " 7" followed by IDL get
PASS canvas.height: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.height: setAttribute() to " 7" followed by IDL get assert_equals: expected 150 but got 7
+PASS canvas.height: setAttribute() to " 7" followed by IDL get
PASS canvas.height: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.height: setAttribute() to " 7" followed by IDL get assert_equals: expected 150 but got 7
+PASS canvas.height: setAttribute() to " 7" followed by IDL get
PASS canvas.height: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.height: setAttribute() to " 7" followed by IDL get assert_equals: expected 150 but got 7
+PASS canvas.height: setAttribute() to " 7" followed by IDL get
PASS canvas.height: setAttribute() to " 7" followed by getAttribute()
PASS canvas.height: setAttribute() to " 7" followed by IDL get
PASS canvas.height: setAttribute() to " 7" followed by getAttribute()
-FAIL canvas.height: setAttribute() to " 7" followed by IDL get assert_equals: expected 150 but got 7
+PASS canvas.height: setAttribute() to " 7" followed by IDL get
PASS canvas.height: setAttribute() to " \0\x01\x02\x03\x04\x05\x06\x07 \b\t\n\v\f\r\x0e\x0f \x10\x11\x12\x13\x14\x15\x16\x17 \x18\x19\x1a\x1b\x1c\x1d\x1e\x1f foo " followed by getAttribute()
PASS canvas.height: setAttribute() to " \0\x01\x02\x03\x04\x05\x06\x07 \b\t\n\v\f\r\x0e\x0f \x10\x11\x12\x13\x14\x15\x16\x17 \x18\x19\x1a\x1b\x1c\x1d\x1e\x1f foo " followed by IDL get
PASS canvas.height: setAttribute() to undefined followed by getAttribute()
@@ -14722,10 +14722,10 @@
PASS canvas.height: IDL set to "-0" followed by getAttribute()
PASS canvas.height: IDL set to "-0" followed by IDL get
PASS canvas.height: IDL set to 2147483648 should not throw
-FAIL canvas.height: IDL set to 2147483648 followed by getAttribute() assert_equals: expected "150" but got "-2147483648"
+PASS canvas.height: IDL set to 2147483648 followed by getAttribute()
PASS canvas.height: IDL set to 2147483648 followed by IDL get
PASS canvas.height: IDL set to 4294967295 should not throw
-FAIL canvas.height: IDL set to 4294967295 followed by getAttribute() assert_equals: expected "150" but got "-1"
+PASS canvas.height: IDL set to 4294967295 followed by getAttribute()
PASS canvas.height: IDL set to 4294967295 followed by IDL get
FAIL canvas.itemScope: typeof IDL attribute assert_equals: expected "boolean" but got "undefined"
FAIL canvas.itemScope: IDL get with DOM attribute unset assert_equals: expected (boolean) false but got (undefined) undefined
Modified: trunk/Source/WebCore/ChangeLog (197726 => 197727)
--- trunk/Source/WebCore/ChangeLog 2016-03-08 06:38:10 UTC (rev 197726)
+++ trunk/Source/WebCore/ChangeLog 2016-03-08 06:42:51 UTC (rev 197727)
@@ -1,5 +1,32 @@
2016-03-07 Chris Dumez <[email protected]>
+ Align HTMLCanvasElement.width / height with the specification
+ https://bugs.webkit.org/show_bug.cgi?id=155156
+
+ Reviewed by Ryosuke Niwa.
+
+ Align HTMLCanvasElement.width / height with the specification:
+ - https://html.spec.whatwg.org/multipage/scripting.html#dom-canvas-width
+ - https://html.spec.whatwg.org/multipage/scripting.html#attr-canvas-width
+
+ In particular, the following changes were made:
+ 1. The attributes are now 'unsigned long' instead of 'long'
+ 2. The corresponding content attributes are parsed as per the HTML rules
+ for passing non-negative integers.
+ 3. Upon setting, if the value is out-of-range, the content attributes is
+ set to its default value.
+
+ No new tests, already covered by existing test.
+
+ * html/HTMLCanvasElement.cpp:
+ (WebCore::HTMLCanvasElement::setHeight):
+ (WebCore::HTMLCanvasElement::setWidth):
+ (WebCore::HTMLCanvasElement::reset):
+ * html/HTMLCanvasElement.h:
+ * html/HTMLCanvasElement.idl:
+
+2016-03-07 Chris Dumez <[email protected]>
+
Stop clamping HTMLElement.tabIndex to the range of a short
https://bugs.webkit.org/show_bug.cgi?id=155159
Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (197726 => 197727)
--- trunk/Source/WebCore/html/HTMLCanvasElement.cpp 2016-03-08 06:38:10 UTC (rev 197726)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.cpp 2016-03-08 06:42:51 UTC (rev 197727)
@@ -40,6 +40,7 @@
#include "GeometryUtilities.h"
#include "GraphicsContext.h"
#include "HTMLNames.h"
+#include "HTMLParserIdioms.h"
#include "ImageData.h"
#include "MIMETypeRegistry.h"
#include "Page.h"
@@ -155,14 +156,14 @@
m_observers.remove(&observer);
}
-void HTMLCanvasElement::setHeight(int value)
+void HTMLCanvasElement::setHeight(unsigned value)
{
- setIntegralAttribute(heightAttr, value);
+ setAttributeWithoutSynchronization(heightAttr, AtomicString::number(limitToOnlyHTMLNonNegative(value, DefaultHeight)));
}
-void HTMLCanvasElement::setWidth(int value)
+void HTMLCanvasElement::setWidth(unsigned value)
{
- setIntegralAttribute(widthAttr, value);
+ setAttributeWithoutSynchronization(widthAttr, AtomicString::number(limitToOnlyHTMLNonNegative(value, DefaultWidth)));
}
#if ENABLE(WEBGL)
@@ -330,17 +331,11 @@
if (m_ignoreReset)
return;
- bool ok;
bool hadImageBuffer = hasCreatedImageBuffer();
- int w = getAttribute(widthAttr).toInt(&ok);
- if (!ok || w < 0)
- w = DefaultWidth;
+ int w = limitToOnlyHTMLNonNegative(fastGetAttribute(widthAttr), DefaultWidth);
+ int h = limitToOnlyHTMLNonNegative(fastGetAttribute(heightAttr), DefaultHeight);
- int h = getAttribute(heightAttr).toInt(&ok);
- if (!ok || h < 0)
- h = DefaultHeight;
-
if (m_contextStateSaver) {
// Reset to the initial graphics context state.
m_contextStateSaver->restore();
Modified: trunk/Source/WebCore/html/HTMLCanvasElement.h (197726 => 197727)
--- trunk/Source/WebCore/html/HTMLCanvasElement.h 2016-03-08 06:38:10 UTC (rev 197726)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.h 2016-03-08 06:42:51 UTC (rev 197727)
@@ -75,13 +75,13 @@
void removeObserver(CanvasObserver&);
// Attributes and functions exposed to script
- int width() const { return size().width(); }
- int height() const { return size().height(); }
+ unsigned width() const { return size().width(); }
+ unsigned height() const { return size().height(); }
const IntSize& size() const { return m_size; }
- void setWidth(int);
- void setHeight(int);
+ void setWidth(unsigned);
+ void setHeight(unsigned);
void setSize(const IntSize& newSize)
{
Modified: trunk/Source/WebCore/html/HTMLCanvasElement.idl (197726 => 197727)
--- trunk/Source/WebCore/html/HTMLCanvasElement.idl 2016-03-08 06:38:10 UTC (rev 197726)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.idl 2016-03-08 06:42:51 UTC (rev 197727)
@@ -28,9 +28,13 @@
JSGenerateToNativeObject,
ReportExtraMemoryCost
] interface HTMLCanvasElement : HTMLElement {
-
+#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C || defined(LANGUAGE_GOBJECT) && LANGUAGE_GOBJECT
attribute long width;
attribute long height;
+#else
+ attribute unsigned long width;
+ attribute unsigned long height;
+#endif
[Custom, RaisesException] DOMString toDataURL(optional DOMString? type);