diff options
Diffstat (limited to 'chromium/third_party/WebKit/Source/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp')
-rw-r--r-- | chromium/third_party/WebKit/Source/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp | 56 |
1 files changed, 14 insertions, 42 deletions
diff --git a/chromium/third_party/WebKit/Source/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp b/chromium/third_party/WebKit/Source/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp index 094bf4acc8b..08ffb16adbd 100644 --- a/chromium/third_party/WebKit/Source/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp +++ b/chromium/third_party/WebKit/Source/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp @@ -29,12 +29,11 @@ */ #include "config.h" -#include "V8HTMLOptionsCollection.h" +#include "bindings/core/v8/V8HTMLOptionsCollection.h" -#include "V8HTMLOptionElement.h" -#include "V8Node.h" -#include "V8NodeList.h" -#include "bindings/v8/ExceptionMessages.h" +#include "bindings/core/v8/V8HTMLOptionElement.h" +#include "bindings/core/v8/V8Node.h" +#include "bindings/core/v8/V8NodeList.h" #include "bindings/v8/ExceptionState.h" #include "bindings/v8/V8Binding.h" #include "core/dom/ExceptionCode.h" @@ -45,50 +44,23 @@ namespace WebCore { -template<typename CallbackInfo> -static void getNamedItems(HTMLOptionsCollection* collection, const AtomicString& name, const CallbackInfo& info) -{ - Vector<RefPtr<Node> > namedItems; - collection->namedItems(name, namedItems); - - if (!namedItems.size()) { - v8SetReturnValueNull(info); - return; - } - - if (namedItems.size() == 1) { - v8SetReturnValueFast(info, namedItems.at(0).release(), collection); - return; - } - - v8SetReturnValueFast(info, NamedNodesCollection::create(namedItems), collection); -} - -void V8HTMLOptionsCollection::namedItemMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) -{ - V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, name, info[0]); - HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder()); - getNamedItems(imp, name, info); -} - void V8HTMLOptionsCollection::addMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "add", "HTMLOptionsCollection", info.Holder(), info.GetIsolate()); - if (!V8HTMLOptionElement::hasInstance(info[0], info.GetIsolate(), worldType(info.GetIsolate()))) { + if (!V8HTMLOptionElement::hasInstance(info[0], info.GetIsolate())) { exceptionState.throwTypeError("The element provided was not an HTMLOptionElement."); } else { - HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder()); + HTMLOptionsCollection* impl = V8HTMLOptionsCollection::toNative(info.Holder()); HTMLOptionElement* option = V8HTMLOptionElement::toNative(v8::Handle<v8::Object>(v8::Handle<v8::Object>::Cast(info[0]))); if (info.Length() < 2) { - imp->add(option, exceptionState); + impl->add(option, exceptionState); } else { - bool ok; - V8TRYCATCH_VOID(int, index, toInt32(info[1], ok)); - if (!ok) - exceptionState.throwTypeError("The index provided could not be interpreted as an integer."); - else - imp->add(option, index, exceptionState); + int index = toInt32(info[1], exceptionState); + if (exceptionState.throwIfNeeded()) + return; + + impl->add(option, index, exceptionState); } } @@ -97,7 +69,7 @@ void V8HTMLOptionsCollection::addMethodCustom(const v8::FunctionCallbackInfo<v8: void V8HTMLOptionsCollection::lengthAttributeSetterCustom(v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) { - HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder()); + HTMLOptionsCollection* impl = V8HTMLOptionsCollection::toNative(info.Holder()); double v = value->NumberValue(); unsigned newLength = 0; ExceptionState exceptionState(ExceptionState::SetterContext, "length", "HTMLOptionsCollection", info.Holder(), info.GetIsolate()); @@ -113,7 +85,7 @@ void V8HTMLOptionsCollection::lengthAttributeSetterCustom(v8::Local<v8::Value> v if (exceptionState.throwIfNeeded()) return; - imp->setLength(newLength, exceptionState); + impl->setLength(newLength, exceptionState); } } // namespace WebCore |