Changeset 196769 in webkit
- Timestamp:
- Feb 18, 2016 12:14:13 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r196742 r196769 1 2016-02-18 Chris Dumez <cdumez@apple.com> 2 3 Fix behavior of reflecting unsigned long IDL attributes that are limited to only non-negative numbers greater than zero 4 https://bugs.webkit.org/show_bug.cgi?id=154398 5 6 Reviewed by Ryosuke Niwa. 7 8 Rebaseline now that more checks are passing. 9 10 * web-platform-tests/html/dom/reflection-forms-expected.txt: 11 * web-platform-tests/html/dom/reflection-tabular-expected.txt: 12 1 13 2016-02-17 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-forms-expected.txt
r196710 r196769 6960 6960 PASS input.size: IDL set to 2147483647 followed by IDL get 6961 6961 PASS input.size: IDL set to 2147483648 should not throw 6962 FAIL input.size: IDL set to 2147483648 followed by getAttribute() assert_equals: expected "20" but got "2147483648" 6962 PASS input.size: IDL set to 2147483648 followed by getAttribute() 6963 6963 PASS input.size: IDL set to 2147483648 followed by IDL get 6964 6964 PASS input.size: IDL set to 4294967295 should not throw 6965 FAIL input.size: IDL set to 4294967295 followed by getAttribute() assert_equals: expected "20" but got "4294967295" 6965 PASS input.size: IDL set to 4294967295 followed by getAttribute() 6966 6966 PASS input.size: IDL set to 4294967295 followed by IDL get 6967 6967 PASS input.src: typeof IDL attribute … … 14643 14643 PASS textarea.cols: IDL set to 2147483647 followed by IDL get 14644 14644 PASS textarea.cols: IDL set to 2147483648 should not throw 14645 FAIL textarea.cols: IDL set to 2147483648 followed by getAttribute() assert_equals: expected "20" but got "-2147483648" 14645 PASS textarea.cols: IDL set to 2147483648 followed by getAttribute() 14646 14646 PASS textarea.cols: IDL set to 2147483648 followed by IDL get 14647 14647 PASS textarea.cols: IDL set to 4294967295 should not throw 14648 FAIL textarea.cols: IDL set to 4294967295 followed by getAttribute() assert_equals: expected "20" but got "-1" 14648 PASS textarea.cols: IDL set to 4294967295 followed by getAttribute() 14649 14649 PASS textarea.cols: IDL set to 4294967295 followed by IDL get 14650 14650 PASS textarea.dirName: typeof IDL attribute … … 15710 15710 PASS textarea.rows: IDL set to 2147483647 followed by IDL get 15711 15711 PASS textarea.rows: IDL set to 2147483648 should not throw 15712 FAIL textarea.rows: IDL set to 2147483648 followed by getAttribute() assert_equals: expected "2" but got "-2147483648" 15712 PASS textarea.rows: IDL set to 2147483648 followed by getAttribute() 15713 15713 PASS textarea.rows: IDL set to 2147483648 followed by IDL get 15714 15714 PASS textarea.rows: IDL set to 4294967295 should not throw 15715 FAIL textarea.rows: IDL set to 4294967295 followed by getAttribute() assert_equals: expected "2" but got "-1" 15715 PASS textarea.rows: IDL set to 4294967295 followed by getAttribute() 15716 15716 PASS textarea.rows: IDL set to 4294967295 followed by IDL get 15717 15717 PASS textarea.wrap: typeof IDL attribute -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-tabular-expected.txt
r196710 r196769 2975 2975 PASS colgroup.span: setAttribute() to -2147483649 followed by IDL get 2976 2976 PASS colgroup.span: setAttribute() to -2147483648 followed by getAttribute() 2977 FAIL colgroup.span: setAttribute() to -2147483648 followed by IDL get assert_equals: expected 1 but got -2147483648 2977 PASS colgroup.span: setAttribute() to -2147483648 followed by IDL get 2978 2978 PASS colgroup.span: setAttribute() to -36 followed by getAttribute() 2979 FAIL colgroup.span: setAttribute() to -36 followed by IDL get assert_equals: expected 1 but got -36 2979 PASS colgroup.span: setAttribute() to -36 followed by IDL get 2980 2980 PASS colgroup.span: setAttribute() to -1 followed by getAttribute() 2981 FAIL colgroup.span: setAttribute() to -1 followed by IDL get assert_equals: expected 1 but got -1 2981 PASS colgroup.span: setAttribute() to -1 followed by IDL get 2982 2982 PASS colgroup.span: setAttribute() to 0 followed by getAttribute() 2983 2983 PASS colgroup.span: setAttribute() to 0 followed by IDL get … … 2995 2995 PASS colgroup.span: setAttribute() to "" followed by IDL get 2996 2996 PASS colgroup.span: setAttribute() to "-1" followed by getAttribute() 2997 FAIL colgroup.span: setAttribute() to "-1" followed by IDL get assert_equals: expected 1 but got -1 2997 PASS colgroup.span: setAttribute() to "-1" followed by IDL get 2998 2998 PASS colgroup.span: setAttribute() to "-0" followed by getAttribute() 2999 2999 PASS colgroup.span: setAttribute() to "-0" followed by IDL get … … 3089 3089 PASS colgroup.span: IDL set to 2147483647 followed by IDL get 3090 3090 PASS colgroup.span: IDL set to 2147483648 should not throw 3091 FAIL colgroup.span: IDL set to 2147483648 followed by getAttribute() assert_equals: expected "1" but got "-2147483648" 3092 FAIL colgroup.span: IDL set to 2147483648 followed by IDL get assert_equals: expected 1 but got -2147483648 3091 PASS colgroup.span: IDL set to 2147483648 followed by getAttribute() 3092 PASS colgroup.span: IDL set to 2147483648 followed by IDL get 3093 3093 PASS colgroup.span: IDL set to 4294967295 should not throw 3094 FAIL colgroup.span: IDL set to 4294967295 followed by getAttribute() assert_equals: expected "1" but got "-1" 3095 FAIL colgroup.span: IDL set to 4294967295 followed by IDL get assert_equals: expected 1 but got -1 3094 PASS colgroup.span: IDL set to 4294967295 followed by getAttribute() 3095 PASS colgroup.span: IDL set to 4294967295 followed by IDL get 3096 3096 PASS colgroup.align: typeof IDL attribute 3097 3097 PASS colgroup.align: IDL get with DOM attribute unset … … 4246 4246 PASS col.span: setAttribute() to -2147483649 followed by IDL get 4247 4247 PASS col.span: setAttribute() to -2147483648 followed by getAttribute() 4248 FAIL col.span: setAttribute() to -2147483648 followed by IDL get assert_equals: expected 1 but got -2147483648 4248 PASS col.span: setAttribute() to -2147483648 followed by IDL get 4249 4249 PASS col.span: setAttribute() to -36 followed by getAttribute() 4250 FAIL col.span: setAttribute() to -36 followed by IDL get assert_equals: expected 1 but got -36 4250 PASS col.span: setAttribute() to -36 followed by IDL get 4251 4251 PASS col.span: setAttribute() to -1 followed by getAttribute() 4252 FAIL col.span: setAttribute() to -1 followed by IDL get assert_equals: expected 1 but got -1 4252 PASS col.span: setAttribute() to -1 followed by IDL get 4253 4253 PASS col.span: setAttribute() to 0 followed by getAttribute() 4254 4254 PASS col.span: setAttribute() to 0 followed by IDL get … … 4266 4266 PASS col.span: setAttribute() to "" followed by IDL get 4267 4267 PASS col.span: setAttribute() to "-1" followed by getAttribute() 4268 FAIL col.span: setAttribute() to "-1" followed by IDL get assert_equals: expected 1 but got -1 4268 PASS col.span: setAttribute() to "-1" followed by IDL get 4269 4269 PASS col.span: setAttribute() to "-0" followed by getAttribute() 4270 4270 PASS col.span: setAttribute() to "-0" followed by IDL get … … 4360 4360 PASS col.span: IDL set to 2147483647 followed by IDL get 4361 4361 PASS col.span: IDL set to 2147483648 should not throw 4362 FAIL col.span: IDL set to 2147483648 followed by getAttribute() assert_equals: expected "1" but got "-2147483648" 4363 FAIL col.span: IDL set to 2147483648 followed by IDL get assert_equals: expected 1 but got -2147483648 4362 PASS col.span: IDL set to 2147483648 followed by getAttribute() 4363 PASS col.span: IDL set to 2147483648 followed by IDL get 4364 4364 PASS col.span: IDL set to 4294967295 should not throw 4365 FAIL col.span: IDL set to 4294967295 followed by getAttribute() assert_equals: expected "1" but got "-1" 4366 FAIL col.span: IDL set to 4294967295 followed by IDL get assert_equals: expected 1 but got -1 4365 PASS col.span: IDL set to 4294967295 followed by getAttribute() 4366 PASS col.span: IDL set to 4294967295 followed by IDL get 4367 4367 PASS col.align: typeof IDL attribute 4368 4368 PASS col.align: IDL get with DOM attribute unset -
trunk/Source/WebCore/ChangeLog
r196763 r196769 1 2016-02-18 Chris Dumez <cdumez@apple.com> 2 3 Fix behavior of reflecting unsigned long IDL attributes that are limited to only non-negative numbers greater than zero 4 https://bugs.webkit.org/show_bug.cgi?id=154398 5 6 Reviewed by Ryosuke Niwa. 7 8 Fix behavior of reflecting unsigned long IDL attributes that are limited 9 to only non-negative numbers greater than zero to comply with: 10 - https://html.spec.whatwg.org/#limited-to-only-non-negative-numbers-greater-than-zero 11 12 This patch updates the following IDL attributes: 13 - colgroup.span 14 - col.span 15 - input.size 16 - textarea.cols 17 - textareal.rows 18 19 All of them now: 20 - Have "unsigned long" type on IDL size and "unsigned" type on native 21 side. 22 - On getting, return the value if it is in the range [1; 2147483647], 23 otherwise return the default value. 24 - On setting, set to the input value if it is in the range 25 [1; 2147483647], otherwise, set to the default value. 26 27 Note that as per the specification, we are supposed to throw an 28 IndexSizeError exception when trying to set those attributes to zero. 29 However, we instead use the default value to match other browsers. 30 It would be risky to be the only browser to throw in this case. 31 32 No new tests, already covered by existing test. 33 34 * html/HTMLInputElement.cpp: 35 (WebCore::HTMLInputElement::parseAttribute): 36 (WebCore::HTMLInputElement::setSize): 37 * html/HTMLTableColElement.cpp: 38 (WebCore::HTMLTableColElement::parseAttribute): 39 (WebCore::HTMLTableColElement::setSpan): 40 * html/HTMLTableColElement.h: 41 * html/HTMLTableColElement.idl: 42 * html/HTMLTextAreaElement.cpp: 43 (WebCore::HTMLTextAreaElement::parseAttribute): 44 (WebCore::HTMLTextAreaElement::setCols): 45 (WebCore::HTMLTextAreaElement::setRows): 46 (WebCore::HTMLTextAreaElement::shouldUseInputMethod): Deleted. 47 * html/HTMLTextAreaElement.h: 48 * html/HTMLTextAreaElement.idl: 49 * html/parser/HTMLParserIdioms.h: 50 (WebCore::limitToOnlyNonNegativeNumbersGreaterThanZero): 51 1 52 2016-02-18 David Kilzer <ddkilzer@apple.com> 2 53 -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r196080 r196769 686 686 else if (name == sizeAttr) { 687 687 int oldSize = m_size; 688 int valueAsInteger = value.toInt(); 689 m_size = valueAsInteger > 0 ? valueAsInteger : defaultSize; 688 m_size = limitToOnlyNonNegativeNumbersGreaterThanZero(value.string().toUInt(), defaultSize); 690 689 if (m_size != oldSize && renderer()) 691 690 renderer()->setNeedsLayoutAndPrefWidthsRecalc(); … … 1276 1275 void HTMLInputElement::setSize(unsigned size) 1277 1276 { 1278 setUnsignedIntegralAttribute(sizeAttr, size);1277 setUnsignedIntegralAttribute(sizeAttr, limitToOnlyNonNegativeNumbersGreaterThanZero(size, defaultSize)); 1279 1278 } 1280 1279 -
trunk/Source/WebCore/html/HTMLTableColElement.cpp
r182120 r196769 28 28 #include "CSSPropertyNames.h" 29 29 #include "HTMLNames.h" 30 #include "HTMLParserIdioms.h" 30 31 #include "HTMLTableElement.h" 31 32 #include "RenderTableCol.h" … … 65 66 { 66 67 if (name == spanAttr) { 67 int newSpan = value.toInt(); 68 m_span = newSpan ? newSpan : 1; 68 m_span = limitToOnlyNonNegativeNumbersGreaterThanZero(value.string().toUInt()); 69 69 if (is<RenderTableCol>(renderer())) 70 70 downcast<RenderTableCol>(*renderer()).updateFromElement(); … … 91 91 } 92 92 93 void HTMLTableColElement::setSpan( intn)93 void HTMLTableColElement::setSpan(unsigned n) 94 94 { 95 set IntegralAttribute(spanAttr, n);95 setUnsignedIntegralAttribute(spanAttr, limitToOnlyNonNegativeNumbersGreaterThanZero(n)); 96 96 } 97 97 -
trunk/Source/WebCore/html/HTMLTableColElement.h
r177996 r196769 35 35 static Ref<HTMLTableColElement> create(const QualifiedName& tagName, Document&); 36 36 37 intspan() const { return m_span; }38 void setSpan( int);37 unsigned span() const { return m_span; } 38 void setSpan(unsigned); 39 39 40 40 String width() const; … … 48 48 virtual const StyleProperties* additionalPresentationAttributeStyle() override; 49 49 50 intm_span;50 unsigned m_span; 51 51 }; 52 52 -
trunk/Source/WebCore/html/HTMLTableColElement.idl
r131172 r196769 23 23 [Reflect=char] attribute DOMString ch; 24 24 [Reflect=charoff] attribute DOMString chOff; 25 #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT 26 attribute unsigned long span; 27 #else 25 28 attribute long span; 29 #endif 26 30 [Reflect] attribute DOMString vAlign; 27 31 [Reflect] attribute DOMString width; -
trunk/Source/WebCore/html/HTMLTextAreaElement.cpp
r195452 r196769 41 41 #include "FrameSelection.h" 42 42 #include "HTMLNames.h" 43 #include "HTMLParserIdioms.h" 43 44 #include "LocalizedStrings.h" 44 45 #include "RenderTextControlMultiLine.h" … … 170 171 { 171 172 if (name == rowsAttr) { 172 int rows = value.toInt(); 173 if (rows <= 0) 174 rows = defaultRows; 173 unsigned rows = limitToOnlyNonNegativeNumbersGreaterThanZero(value.string().toUInt(), defaultRows); 175 174 if (m_rows != rows) { 176 175 m_rows = rows; … … 179 178 } 180 179 } else if (name == colsAttr) { 181 int cols = value.toInt(); 182 if (cols <= 0) 183 cols = defaultCols; 180 unsigned cols = limitToOnlyNonNegativeNumbersGreaterThanZero(value.string().toUInt(), defaultCols); 184 181 if (m_cols != cols) { 185 182 m_cols = cols; … … 493 490 } 494 491 495 void HTMLTextAreaElement::setCols( intcols)496 { 497 set IntegralAttribute(colsAttr, cols);498 } 499 500 void HTMLTextAreaElement::setRows( introws)501 { 502 set IntegralAttribute(rowsAttr, rows);492 void HTMLTextAreaElement::setCols(unsigned cols) 493 { 494 setUnsignedIntegralAttribute(colsAttr, limitToOnlyNonNegativeNumbersGreaterThanZero(cols, defaultCols)); 495 } 496 497 void HTMLTextAreaElement::setRows(unsigned rows) 498 { 499 setUnsignedIntegralAttribute(rowsAttr, limitToOnlyNonNegativeNumbersGreaterThanZero(rows, defaultRows)); 503 500 } 504 501 -
trunk/Source/WebCore/html/HTMLTextAreaElement.h
r191451 r196769 36 36 static Ref<HTMLTextAreaElement> create(const QualifiedName&, Document&, HTMLFormElement*); 37 37 38 intcols() const { return m_cols; }39 introws() const { return m_rows; }38 unsigned cols() const { return m_cols; } 39 unsigned rows() const { return m_rows; } 40 40 41 41 bool shouldWrapText() const { return m_wrap != NoWrap; } … … 58 58 void rendererWillBeDestroyed(); 59 59 60 void setCols( int);61 void setRows( int);60 void setCols(unsigned); 61 void setRows(unsigned); 62 62 63 63 virtual bool willRespondToMouseClickEvents() override; … … 119 119 bool tooLong(const String&, NeedsToCheckDirtyFlag) const; 120 120 121 intm_rows;122 intm_cols;121 unsigned m_rows; 122 unsigned m_cols; 123 123 WrapMethod m_wrap; 124 124 HTMLElement* m_placeholder; -
trunk/Source/WebCore/html/HTMLTextAreaElement.idl
r195700 r196769 22 22 interface HTMLTextAreaElement : HTMLElement { 23 23 [Reflect] attribute boolean autofocus; 24 attribute long cols;25 24 [Reflect] attribute DOMString dirName; 26 25 [Reflect] attribute boolean disabled; … … 31 30 [Reflect] attribute boolean readOnly; 32 31 [Reflect] attribute boolean required; 32 #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C 33 33 attribute long rows; 34 attribute long cols; 35 #else 36 attribute unsigned long rows; 37 attribute unsigned long cols; 38 #endif 34 39 [Reflect] attribute DOMString wrap; 35 40 -
trunk/Source/WebCore/html/parser/HTMLParserIdioms.h
r195951 r196769 107 107 } 108 108 109 // https://html.spec.whatwg.org/multipage/infrastructure.html#limited-to-only-non-negative-numbers-greater-than-zero 110 inline unsigned limitToOnlyNonNegativeNumbersGreaterThanZero(unsigned value, unsigned defaultValue = 1) 111 { 112 return (value > 0 && value <= 2147483647) ? value : defaultValue; 113 } 114 109 115 } 110 116
Note: See TracChangeset
for help on using the changeset viewer.