diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp')
-rw-r--r-- | Source/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp | 43 |
1 files changed, 11 insertions, 32 deletions
diff --git a/Source/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp b/Source/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp index 43f694b50..c74aed3df 100644 --- a/Source/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp +++ b/Source/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp @@ -21,55 +21,34 @@ #include "config.h" #include "JSHTMLSelectElementCustom.h" +#include "CustomElementReactionQueue.h" #include "ExceptionCode.h" #include "HTMLNames.h" #include "HTMLOptionElement.h" #include "HTMLSelectElement.h" #include "JSHTMLOptionElement.h" +#include "JSHTMLSelectElement.h" namespace WebCore { using namespace JSC; using namespace HTMLNames; -JSValue JSHTMLSelectElement::remove(ExecState* exec) +void selectElementIndexSetter(JSC::ExecState& state, HTMLSelectElement& element, unsigned index, JSC::JSValue value) { - HTMLSelectElement& select = impl(); + VM& vm = state.vm(); + auto throwScope = DECLARE_THROW_SCOPE(vm); - if (!exec->argumentCount()) { - // When called with no argument, we should call Element::remove() to detach. - ExceptionCode ec = 0; - select.remove(ec); - setDOMException(exec, ec); - } else { - // The HTMLSelectElement::remove() function can take either an option object or the index of an option. - if (HTMLOptionElement* option = toHTMLOptionElement(exec->argument(0))) - select.remove(option); - else - select.removeByIndex(exec->argument(0).toInt32(exec)); - } + auto* option = convert<IDLNullable<IDLInterface<HTMLOptionElement>>>(state, value); + RETURN_IF_EXCEPTION(throwScope, void()); - return jsUndefined(); + propagateException(state, throwScope, element.setItem(index, option)); } -void selectIndexSetter(HTMLSelectElement* select, JSC::ExecState* exec, unsigned index, JSC::JSValue value) +void JSHTMLSelectElement::indexSetter(JSC::ExecState* state, unsigned index, JSC::JSValue value) { - if (value.isUndefinedOrNull()) - select->removeByIndex(index); - else { - ExceptionCode ec = 0; - HTMLOptionElement* option = toHTMLOptionElement(value); - if (!option) - ec = TYPE_MISMATCH_ERR; - else - select->setOption(index, option, ec); - setDOMException(exec, ec); - } -} - -void JSHTMLSelectElement::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) -{ - selectIndexSetter(&impl(), exec, index, value); + CustomElementReactionStack customElementReactionStack; + selectElementIndexSetter(*state, wrapped(), index, value); } } |