Changeset 207497 in webkit
- Timestamp:
- Oct 18, 2016 4:18:20 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r207486 r207497 1 2016-10-18 Chris Dumez <cdumez@apple.com> 2 3 Leverage new union type support for HTMLSelectElement.add() / HTMLOptionsCollection.add() 4 https://bugs.webkit.org/show_bug.cgi?id=163608 5 6 Reviewed by Ryosuke Niwa. 7 8 Rebaseline existing tests now that exception messages are different. 9 10 * fast/dom/HTMLSelectElement/add-expected.txt: 11 * fast/dom/HTMLSelectElement/options-collection-add-expected.txt: 12 * fast/dom/incompatible-operations-expected.txt: 13 1 14 2016-10-18 Ryosuke Niwa <rniwa@webkit.org> 2 15 -
trunk/LayoutTests/fast/dom/HTMLSelectElement/add-expected.txt
r204028 r207497 10 10 Call HTMLSelectElement.add() with one argument: 11 11 PASS testAdd(createOption("Y1")) is "0,1,2,Y1" 12 PASS testAdd("foo") threw exception TypeError: Argument 1 ('element') to HTMLSelectElement.add must be an instance of HTMLElement.13 PASS testAdd(undefined) threw exception TypeError: Argument 1 ('element') to HTMLSelectElement.add must be an instance of HTMLElement.14 PASS testAdd(null) threw exception TypeError: Argument 1 ('element') to HTMLSelectElement.add must be an instance of HTMLElement.12 PASS testAdd("foo") threw exception TypeError: Type error. 13 PASS testAdd(undefined) threw exception TypeError: Type error. 14 PASS testAdd(null) threw exception TypeError: Type error. 15 15 16 16 Call HTMLSelectElement.add() with two arguments: … … 41 41 PASS testAdd(createOption("X"), mySelect.options[1]) is "0,X,1,2" 42 42 PASS testAdd(createOption("X"), mySelect.options[2]) is "0,1,X,2" 43 PASS testAdd("foo", 0) threw exception TypeError: Argument 1 ('element') to HTMLSelectElement.add must be an instance of HTMLElement.44 PASS testAdd(undefined, 0) threw exception TypeError: Argument 1 ('element') to HTMLSelectElement.add must be an instance of HTMLElement.45 PASS testAdd(null, 0) threw exception TypeError: Argument 1 ('element') to HTMLSelectElement.add must be an instance of HTMLElement.43 PASS testAdd("foo", 0) threw exception TypeError: Type error. 44 PASS testAdd(undefined, 0) threw exception TypeError: Type error. 45 PASS testAdd(null, 0) threw exception TypeError: Type error. 46 46 47 47 Call HTMLSelectElement.add() with three arguments (when it only takes two arguments): -
trunk/LayoutTests/fast/dom/HTMLSelectElement/options-collection-add-expected.txt
r204028 r207497 10 10 Call HTMLOptionsCollection.add() with only one argument: 11 11 PASS testAdd(createOption("Y9")) is "0,1,2,Y9" 12 PASS testAdd("foo") threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.13 PASS testAdd(undefined) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.14 PASS testAdd(null) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.12 PASS testAdd("foo") threw exception TypeError: Type error. 13 PASS testAdd(undefined) threw exception TypeError: Type error. 14 PASS testAdd(null) threw exception TypeError: Type error. 15 15 16 16 Call HTMLOptionsCollection.add() with two arguments: … … 53 53 PASS testAdd(createOption("Y25"), 0, 1) is "Y25,0,1,2" 54 54 PASS testAdd(createOption("Y25"), mySelect.options[0], 1) is "Y25,0,1,2" 55 PASS testAdd("foo", 0) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.56 PASS testAdd(undefined, 0) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.57 PASS testAdd(null, 0) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.55 PASS testAdd("foo", 0) threw exception TypeError: Type error. 56 PASS testAdd(undefined, 0) threw exception TypeError: Type error. 57 PASS testAdd(null, 0) threw exception TypeError: Type error. 58 58 59 59 Call HTMLOptionsCollection.add() with three arguments (when it only takes two arguments): -
trunk/LayoutTests/fast/dom/incompatible-operations-expected.txt
r204028 r207497 13 13 PASS aNode.lookupPrefix(void 0) is null 14 14 PASS aNode.cloneNode(aDOMImplementation) instanceof HTMLDivElement is true 15 PASS aSelect.add(aDOMImplementation, aDOMImplementation) threw exception TypeError: Argument 1 ('element') to HTMLSelectElement.add must be an instance of HTMLElement.16 PASS aSelect.add(aDOMImplementation, anOption) threw exception TypeError: Argument 1 ('element') to HTMLSelectElement.add must be an instance of HTMLElement.15 PASS aSelect.add(aDOMImplementation, aDOMImplementation) threw exception TypeError: Type error. 16 PASS aSelect.add(aDOMImplementation, anOption) threw exception TypeError: Type error. 17 17 PASS aSelect.add(anOption, aDOMImplementation) is undefined. 18 PASS aSelect.add(void 0, void 0) threw exception TypeError: Argument 1 ('element') to HTMLSelectElement.add must be an instance of HTMLElement.19 PASS aSelect.add(void 0, anOption) threw exception TypeError: Argument 1 ('element') to HTMLSelectElement.add must be an instance of HTMLElement.18 PASS aSelect.add(void 0, void 0) threw exception TypeError: Type error. 19 PASS aSelect.add(void 0, anOption) threw exception TypeError: Type error. 20 20 PASS aSelect.add(anOption, void 0) is undefined. 21 21 PASS successfullyParsed is true -
trunk/LayoutTests/imported/w3c/ChangeLog
r207468 r207497 1 2016-10-18 Chris Dumez <cdumez@apple.com> 2 3 Leverage new union type support for HTMLSelectElement.add() / HTMLOptionsCollection.add() 4 https://bugs.webkit.org/show_bug.cgi?id=163608 5 6 Reviewed by Ryosuke Niwa. 7 8 Rebaseline W3C test now that one more check is passing. This is because we are now 9 correctly throwing a TypeError when calling add() with an unexpected HTMLElement type. 10 11 * web-platform-tests/html/infrastructure/common-dom-interfaces/collections/htmloptionscollection-expected.txt: 12 1 13 2016-10-18 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/common-dom-interfaces/collections/htmloptionscollection-expected.txt
r207181 r207497 24 24 PASS HTMLOptionsCollection.add method insert HTMLOptionElement Option element 25 25 PASS HTMLOptionsCollection.remove method remove Option element by index 26 FAIL Add non-option to collection assert_throws: function "function () {b_opts.add(add);}" did not throw 26 PASS Add non-option to collection 27 27 -
trunk/LayoutTests/js/dom/script-tests/select-options-add.js
r178097 r207497 54 54 55 55 debug("1.4 Add a non-Option element"); 56 option1= document.createElement("DIV");57 should BeUndefined("select1.options.add(option1)");56 div = document.createElement("DIV"); 57 shouldThrowErrorName("select1.options.add(div)", "TypeError"); 58 58 shouldBe("select1.options.length", "3"); 59 59 shouldBe("select1.selectedIndex", "0"); … … 265 265 266 266 debug("2.12 Add a non-Option element"); 267 option2= document.createElement("DIV");268 should BeUndefined("select2.options.add(option2, 1)");267 div = document.createElement("DIV"); 268 shouldThrowErrorName("select2.options.add(div, 1)", "TypeError"); 269 269 shouldBe("select2.options.length", "11"); 270 270 shouldBe("select2.selectedIndex", "4"); -
trunk/LayoutTests/js/dom/select-options-add-expected.txt
r204028 r207497 30 30 31 31 1.4 Add a non-Option element 32 PASS select1.options.add( option1) is undefined.32 PASS select1.options.add(div) threw exception TypeError: Type error. 33 33 PASS select1.options.length is 3 34 34 PASS select1.selectedIndex is 0 35 35 36 36 1.5 Add a non-element (string) 37 PASS select1.options.add(option1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.37 PASS select1.options.add(option1) threw exception TypeError: Type error. 38 38 PASS select1.options.length is 3 39 39 PASS select1.selectedIndex is 0 40 40 41 41 1.6 Add a non-element (number) 42 PASS select1.options.add(option1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.42 PASS select1.options.add(option1) threw exception TypeError: Type error. 43 43 PASS select1.options.length is 3 44 44 PASS select1.selectedIndex is 0 45 45 46 46 1.7 Add a non-element (boolean) 47 PASS select1.options.add(option1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.47 PASS select1.options.add(option1) threw exception TypeError: Type error. 48 48 PASS select1.options.length is 3 49 49 PASS select1.selectedIndex is 0 50 50 51 51 1.8 Add undefined 52 PASS select1.options.add(option1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.52 PASS select1.options.add(option1) threw exception TypeError: Type error. 53 53 PASS select1.options.length is 3 54 54 PASS select1.selectedIndex is 0 55 55 56 56 1.9 Add null 57 PASS select1.options.add(option1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.57 PASS select1.options.add(option1) threw exception TypeError: Type error. 58 58 PASS select1.options.length is 3 59 59 PASS select1.selectedIndex is 0 60 60 61 61 1.10 Add negative infinity 62 PASS select1.options.add(option1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.62 PASS select1.options.add(option1) threw exception TypeError: Type error. 63 63 PASS select1.options.length is 3 64 64 PASS select1.selectedIndex is 0 65 65 66 66 1.11 Add NaN 67 PASS select1.options.add(option1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.67 PASS select1.options.add(option1) threw exception TypeError: Type error. 68 68 PASS select1.options.length is 3 69 69 PASS select1.selectedIndex is 0 70 70 71 71 1.12 Add positive infinity 72 PASS select1.options.add(option1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.72 PASS select1.options.add(option1) threw exception TypeError: Type error. 73 73 PASS select1.options.length is 3 74 74 PASS select1.selectedIndex is 0 … … 179 179 180 180 2.12 Add a non-Option element 181 PASS select2.options.add( option2, 1) is undefined.181 PASS select2.options.add(div, 1) threw exception TypeError: Type error. 182 182 PASS select2.options.length is 11 183 183 PASS select2.selectedIndex is 4 184 184 185 185 2.13 Add a non-element (string) 186 PASS select2.options.add(option2, 1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.186 PASS select2.options.add(option2, 1) threw exception TypeError: Type error. 187 187 PASS select2.options.length is 11 188 188 PASS select2.selectedIndex is 4 189 189 190 190 2.14 Add a non-element (number) 191 PASS select2.options.add(option2, 1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.191 PASS select2.options.add(option2, 1) threw exception TypeError: Type error. 192 192 PASS select2.options.length is 11 193 193 PASS select2.selectedIndex is 4 194 194 195 195 2.15 Add a non-element (boolean) 196 PASS select2.options.add(option2, 1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.196 PASS select2.options.add(option2, 1) threw exception TypeError: Type error. 197 197 PASS select2.options.length is 11 198 198 PASS select2.selectedIndex is 4 199 199 200 200 2.16 Add undefined 201 PASS select2.options.add(option2, 1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.201 PASS select2.options.add(option2, 1) threw exception TypeError: Type error. 202 202 PASS select2.options.length is 11 203 203 PASS select2.selectedIndex is 4 204 204 205 205 2.17 Add null 206 PASS select2.options.add(option2, 1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.206 PASS select2.options.add(option2, 1) threw exception TypeError: Type error. 207 207 PASS select2.options.length is 11 208 208 PASS select2.selectedIndex is 4 209 209 210 210 2.18 Add negative infinity 211 PASS select2.options.add(option2, 1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.211 PASS select2.options.add(option2, 1) threw exception TypeError: Type error. 212 212 PASS select2.options.length is 11 213 213 PASS select2.selectedIndex is 4 214 214 215 215 2.19 Add NaN 216 PASS select2.options.add(option2, 1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.216 PASS select2.options.add(option2, 1) threw exception TypeError: Type error. 217 217 PASS select2.options.length is 11 218 218 PASS select2.selectedIndex is 4 219 219 220 220 2.20 Add positive infinity 221 PASS select2.options.add(option2, 1) threw exception TypeError: Argument 1 ('element') to HTMLOptionsCollection.add must be an instance of HTMLElement.221 PASS select2.options.add(option2, 1) threw exception TypeError: Type error. 222 222 PASS select2.options.length is 11 223 223 PASS select2.selectedIndex is 4 -
trunk/Source/WebCore/ChangeLog
r207496 r207497 1 2016-10-18 Chris Dumez <cdumez@apple.com> 2 3 Leverage new union type support for HTMLSelectElement.add() / HTMLOptionsCollection.add() 4 https://bugs.webkit.org/show_bug.cgi?id=163608 5 6 Reviewed by Ryosuke Niwa. 7 8 Leverage new union type support for HTMLSelectElement.add() / HTMLOptionsCollection.add(): 9 - https://html.spec.whatwg.org/#htmlselectelement 10 - https://html.spec.whatwg.org/#htmloptionscollection 11 12 No new tests, rebaseline existing test. 13 14 * bindings/scripts/CodeGeneratorJS.pm: 15 (GenerateDefaultValue): 16 (GenerateParametersCheck): 17 * bindings/scripts/test/JS/JSTestObj.cpp: 18 (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalSequenceIsEmptyCaller): 19 * bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp: 20 (WebCore::constructJSTestOverloadedConstructorsWithSequence1): 21 * bindings/scripts/test/JS/JSTestTypedefs.cpp: 22 (WebCore::jsTestTypedefsPrototypeFunctionFuncCaller): 23 * html/HTMLOptGroupElement.idl: 24 * html/HTMLOptionsCollection.cpp: 25 (WebCore::HTMLOptionsCollection::add): 26 * html/HTMLOptionsCollection.h: 27 * html/HTMLOptionsCollection.idl: 28 * html/HTMLSelectElement.cpp: 29 (WebCore::HTMLSelectElement::add): 30 (WebCore::HTMLSelectElement::setOption): 31 (WebCore::HTMLSelectElement::setLength): 32 * html/HTMLSelectElement.h: 33 * html/HTMLSelectElement.idl: 34 1 35 2016-10-18 Aaron Chu <aaron_chu@apple.com> 2 36 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r207462 r207497 997 997 sub GenerateDefaultValue 998 998 { 999 my ($interface, $ member) = @_;1000 1001 my $defaultValue = $ member->default;1002 1003 if ($codeGenerator->IsEnumType($ member->type)) {999 my ($interface, $signature) = @_; 1000 1001 my $defaultValue = $signature->default; 1002 1003 if ($codeGenerator->IsEnumType($signature->type)) { 1004 1004 # FIXME: Would be nice to report an error if the value does not have quote marks around it. 1005 1005 # FIXME: Would be nice to report an error if the value is not one of the enumeration values. 1006 my $className = GetEnumerationClassName($ member->type, $interface);1006 my $className = GetEnumerationClassName($signature->type, $interface); 1007 1007 my $enumerationValueName = GetEnumerationValueName(substr($defaultValue, 1, -1)); 1008 1008 return $className . "::" . $enumerationValueName; 1009 1009 } 1010 1010 if ($defaultValue eq "null") { 1011 return "jsNull()" if $member->type eq "any"; 1012 return "nullptr" if $codeGenerator->IsWrapperType($member->type) || $codeGenerator->IsTypedArrayType($member->type); 1013 return "String()" if $codeGenerator->IsStringType($member->type); 1011 return "Nullopt" if $signature->idlType->isUnion; 1012 return "jsNull()" if $signature->type eq "any"; 1013 return "nullptr" if $codeGenerator->IsWrapperType($signature->type) || $codeGenerator->IsTypedArrayType($signature->type); 1014 return "String()" if $codeGenerator->IsStringType($signature->type); 1014 1015 return "Nullopt"; 1015 1016 } 1016 return "{ }" if $defaultValue eq "[]"; 1017 if ($defaultValue eq "[]") { 1018 my $nativeType = GetNativeTypeFromSignature($interface, $signature); 1019 return "$nativeType()" 1020 } 1021 1017 1022 return "jsUndefined()" if $defaultValue eq "undefined"; 1023 return "PNaN" if $defaultValue eq "NaN"; 1018 1024 1019 1025 return $defaultValue; … … 4343 4349 } 4344 4350 } else { 4345 $defaultValue = "nullptr" if $defaultValue eq "null"; 4346 $defaultValue = "PNaN" if $defaultValue eq "NaN"; 4347 $defaultValue = "$nativeType()" if $defaultValue eq "[]"; 4348 $defaultValue = "JSValue::JSUndefined" if $defaultValue eq "undefined"; 4351 $defaultValue = GenerateDefaultValue($interface, $parameter); 4349 4352 } 4350 4353 -
trunk/Source/WebCore/html/HTMLOptGroupElement.idl
r131172 r207497 18 18 */ 19 19 20 interface HTMLOptGroupElement : HTMLElement { 20 [ 21 JSGenerateToNativeObject, 22 ] interface HTMLOptGroupElement : HTMLElement { 21 23 [Reflect] attribute boolean disabled; 22 24 [Reflect] attribute DOMString label; -
trunk/Source/WebCore/html/HTMLOptionsCollection.cpp
r199335 r207497 37 37 } 38 38 39 void HTMLOptionsCollection::add(HTMLElement& element, HTMLElement* beforeElement, ExceptionCode& ec)39 ExceptionOr<void> HTMLOptionsCollection::add(const OptionOrOptGroupElement& element, Optional<HTMLElementOrInt> before) 40 40 { 41 selectElement().add(element, beforeElement, ec); 42 } 43 44 void HTMLOptionsCollection::add(HTMLElement& element, int beforeIndex, ExceptionCode& ec) 45 { 46 add(element, item(beforeIndex), ec); 41 return selectElement().add(element, before); 47 42 } 48 43 -
trunk/Source/WebCore/html/HTMLOptionsCollection.h
r207181 r207497 42 42 HTMLOptionElement* namedItem(const AtomicString& name) const final; 43 43 44 WEBCORE_EXPORT void add(HTMLElement&, HTMLElement* beforeElement, ExceptionCode&); 45 WEBCORE_EXPORT void add(HTMLElement&, int beforeIndex, ExceptionCode&); 44 using OptionOrOptGroupElement = std::experimental::variant<RefPtr<HTMLOptionElement>, RefPtr<HTMLOptGroupElement>>; 45 using HTMLElementOrInt = std::experimental::variant<RefPtr<HTMLElement>, int>; 46 WEBCORE_EXPORT ExceptionOr<void> add(const OptionOrOptGroupElement&, Optional<HTMLElementOrInt> before); 46 47 WEBCORE_EXPORT void remove(int index); 47 48 void remove(HTMLOptionElement&); -
trunk/Source/WebCore/html/HTMLOptionsCollection.idl
r206723 r207497 31 31 getter HTMLOptionElement? namedItem(DOMString name); 32 32 33 // FIXME: Should be: 34 // void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null); 35 [MayThrowLegacyException] void add(HTMLElement element, optional HTMLElement? before = null); 36 [MayThrowLegacyException] void add(HTMLElement element, long index); 33 [MayThrowException] void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null); 37 34 38 35 void remove(long index); -
trunk/Source/WebCore/html/HTMLSelectElement.cpp
r207458 r207497 222 222 } 223 223 224 void HTMLSelectElement::add(HTMLElement& element, HTMLElement* beforeElement, ExceptionCode& ec) 225 { 226 if (!(is<HTMLOptionElement>(element) || is<HTMLHRElement>(element) || is<HTMLOptGroupElement>(element))) 227 return; 228 insertBefore(element, beforeElement, ec); 229 } 230 231 void HTMLSelectElement::add(HTMLElement& element, int beforeIndex, ExceptionCode& ec) 232 { 233 add(element, item(beforeIndex), ec); 224 ExceptionOr<void> HTMLSelectElement::add(const OptionOrOptGroupElement& element, Optional<HTMLElementOrInt> before) 225 { 226 HTMLElement* beforeElement = nullptr; 227 if (before) { 228 auto visitor = WTF::makeVisitor( 229 [](const RefPtr<HTMLElement>& element) -> HTMLElement* { return element.get(); }, 230 [this](int index) -> HTMLElement* { return item(index); } 231 ); 232 233 beforeElement = std::experimental::visit(visitor, before.value()); 234 } 235 HTMLElement& toInsert = std::experimental::visit([](const auto& htmlElement) -> HTMLElement& { 236 return *htmlElement; 237 }, element); 238 239 240 ExceptionCode ec = 0; 241 insertBefore(toInsert, beforeElement, ec); 242 if (ec) 243 return Exception { ec }; 244 return { }; 234 245 } 235 246 … … 441 452 // Finally add the new element. 442 453 if (!ec) { 443 add(option, before.get(), ec); 454 auto exception = add(&option, HTMLElementOrInt(before.get())); 455 if (exception.hasException()) 456 ec = exception.releaseException().code(); 444 457 if (diff >= 0 && option.selected()) 445 458 optionSelectionStateChanged(option, true); … … 457 470 do { 458 471 auto option = document().createElement(optionTag, false); 459 add(downcast<HTMLElement>(option.get()), nullptr, ec); 460 if (ec) 472 auto exception = add(downcast<HTMLOptionElement>(option.ptr()), Nullopt); 473 if (exception.hasException()) { 474 ec = exception.releaseException().code(); 461 475 break; 476 } 462 477 } while (++diff); 463 478 } else { -
trunk/Source/WebCore/html/HTMLSelectElement.h
r205249 r207497 52 52 bool usesMenuList() const; 53 53 54 WEBCORE_EXPORT void add(HTMLElement&, HTMLElement* beforeElement, ExceptionCode&); 55 void add(HTMLElement&, int beforeIndex, ExceptionCode&); 54 using OptionOrOptGroupElement = std::experimental::variant<RefPtr<HTMLOptionElement>, RefPtr<HTMLOptGroupElement>>; 55 using HTMLElementOrInt = std::experimental::variant<RefPtr<HTMLElement>, int>; 56 WEBCORE_EXPORT ExceptionOr<void> add(const OptionOrOptGroupElement&, Optional<HTMLElementOrInt> before); 56 57 57 58 using Node::remove; -
trunk/Source/WebCore/html/HTMLSelectElement.idl
r207426 r207497 41 41 HTMLOptionElement? namedItem(DOMString name); 42 42 43 [MayThrowLegacyException] void add(HTMLElement element, optional HTMLElement? before = null); 44 // FIXME: Should be: 45 // void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null); 46 [MayThrowLegacyException] void add(HTMLElement element, long index); 43 [MayThrowException] void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null); 47 44 48 45 [MayThrowLegacyException] void remove(); // ChildNode overload -
trunk/Source/WebKit/mac/ChangeLog
r207493 r207497 1 2016-10-18 Chris Dumez <cdumez@apple.com> 2 3 Leverage new union type support for HTMLSelectElement.add() / HTMLOptionsCollection.add() 4 https://bugs.webkit.org/show_bug.cgi?id=163608 5 6 Reviewed by Ryosuke Niwa. 7 8 Update add() call sites now that it takes std::variant types in. 9 10 * DOM/DOMHTMLOptionsCollection.mm: 11 (-[DOMHTMLOptionsCollection add:index:]): 12 * DOM/DOMHTMLSelectElement.mm: 13 (-[DOMHTMLSelectElement add:before:]): 14 1 15 2016-10-18 Anders Carlsson <andersca@apple.com> 2 16 -
trunk/Source/WebKit/mac/DOM/DOMHTMLOptionsCollection.mm
r204717 r207497 30 30 #import "DOMNodeInternal.h" 31 31 #import "ExceptionHandlers.h" 32 #import <WebCore/HTMLOptGroupElement.h> 32 33 #import <WebCore/HTMLOptionElement.h> 33 34 #import <WebCore/HTMLOptionsCollection.h> … … 39 40 #import <WebCore/WebScriptObjectPrivate.h> 40 41 #import <wtf/GetPtr.h> 42 #import <wtf/Variant.h> 41 43 42 44 #define IMPL reinterpret_cast<WebCore::HTMLOptionsCollection*>(_internal) … … 91 93 if (!option) 92 94 raiseTypeErrorException(); 93 WebCore::ExceptionCode ec = 0;94 IMPL->add(*core(option), index, ec);95 raiseOnDOMError(ec);95 auto exception = IMPL->add(core(option), Optional<WebCore::HTMLOptionsCollection::HTMLElementOrInt>(static_cast<int>(index))); 96 if (exception.hasException()) 97 raiseOnDOMError(exception.releaseException().code()); 96 98 } 97 99 -
trunk/Source/WebKit/mac/DOM/DOMHTMLSelectElement.mm
r204717 r207497 37 37 #import <WebCore/HTMLFormElement.h> 38 38 #import <WebCore/HTMLNames.h> 39 #import <WebCore/HTMLOptGroupElement.h> 39 40 #import <WebCore/HTMLOptionsCollection.h> 40 41 #import <WebCore/HTMLSelectElement.h> … … 183 184 if (!element) 184 185 raiseTypeErrorException(); 185 WebCore::ExceptionCode ec = 0; 186 IMPL->add(*core(element), core(before), ec); 187 raiseOnDOMError(ec); 186 187 auto& coreElement = *core(element); 188 std::experimental::variant<RefPtr<WebCore::HTMLOptionElement>, RefPtr<WebCore::HTMLOptGroupElement>> variantElement; 189 if (is<WebCore::HTMLOptionElement>(coreElement)) 190 variantElement = &downcast<WebCore::HTMLOptionElement>(coreElement); 191 else if (is<WebCore::HTMLOptGroupElement>(coreElement)) 192 variantElement = &downcast<WebCore::HTMLOptGroupElement>(coreElement); 193 else { 194 raiseTypeErrorException(); 195 return; 196 } 197 auto exception = IMPL->add(WTFMove(variantElement), WebCore::HTMLSelectElement::HTMLElementOrInt(core(before))); 198 if (exception.hasException()) 199 raiseOnDOMError(exception.releaseException().code()); 188 200 } 189 201
Note: See TracChangeset
for help on using the changeset viewer.