| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright (C) 2009 Google Inc. All rights reserved. | 2  * Copyright (C) 2009 Google Inc. All rights reserved. | 
| 3  * | 3  * | 
| 4  * Redistribution and use in source and binary forms, with or without | 4  * Redistribution and use in source and binary forms, with or without | 
| 5  * modification, are permitted provided that the following conditions are | 5  * modification, are permitted provided that the following conditions are | 
| 6  * met: | 6  * met: | 
| 7  * | 7  * | 
| 8  *     * Redistributions of source code must retain the above copyright | 8  *     * Redistributions of source code must retain the above copyright | 
| 9  * notice, this list of conditions and the following disclaimer. | 9  * notice, this list of conditions and the following disclaimer. | 
| 10  *     * Redistributions in binary form must reproduce the above | 10  *     * Redistributions in binary form must reproduce the above | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 66 | 66 | 
| 67 void V8HTMLOptionsCollection::namedItemMethodCustom(const v8::FunctionCallbackIn
     fo<v8::Value>& info) | 67 void V8HTMLOptionsCollection::namedItemMethodCustom(const v8::FunctionCallbackIn
     fo<v8::Value>& info) | 
| 68 { | 68 { | 
| 69     V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, name, info[0]); | 69     V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, name, info[0]); | 
| 70     HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder()
     ); | 70     HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder()
     ); | 
| 71     getNamedItems(imp, name, info); | 71     getNamedItems(imp, name, info); | 
| 72 } | 72 } | 
| 73 | 73 | 
| 74 void V8HTMLOptionsCollection::addMethodCustom(const v8::FunctionCallbackInfo<v8:
     :Value>& info) | 74 void V8HTMLOptionsCollection::addMethodCustom(const v8::FunctionCallbackInfo<v8:
     :Value>& info) | 
| 75 { | 75 { | 
|  | 76     ExceptionState exceptionState(ExceptionState::ExecutionContext, "add", "HTML
     OptionsCollection", info.Holder(), info.GetIsolate()); | 
| 76     if (!V8HTMLOptionElement::hasInstance(info[0], info.GetIsolate(), worldType(
     info.GetIsolate()))) { | 77     if (!V8HTMLOptionElement::hasInstance(info[0], info.GetIsolate(), worldType(
     info.GetIsolate()))) { | 
| 77         setDOMException(TypeMismatchError, info.GetIsolate()); | 78         exceptionState.throwTypeError("The element provided was not an HTMLOptio
     nElement."); | 
| 78         return; | 79     } else { | 
| 79     } | 80         HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Hold
     er()); | 
| 80     HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder()
     ); | 81         HTMLOptionElement* option = V8HTMLOptionElement::toNative(v8::Handle<v8:
     :Object>(v8::Handle<v8::Object>::Cast(info[0]))); | 
| 81     HTMLOptionElement* option = V8HTMLOptionElement::toNative(v8::Handle<v8::Obj
     ect>(v8::Handle<v8::Object>::Cast(info[0]))); |  | 
| 82 | 82 | 
| 83     ExceptionState exceptionState(info.Holder(), info.GetIsolate()); | 83         if (info.Length() < 2) { | 
| 84     if (info.Length() < 2) | 84             imp->add(option, exceptionState); | 
| 85         imp->add(option, exceptionState); | 85         } else { | 
| 86     else { | 86             bool ok; | 
| 87         bool ok; | 87             V8TRYCATCH_VOID(int, index, toInt32(info[1], ok)); | 
| 88         V8TRYCATCH_VOID(int, index, toInt32(info[1], ok)); | 88             if (!ok) | 
| 89         if (!ok) | 89                 exceptionState.throwTypeError("The index provided could not be i
     nterpreted as an integer."); | 
| 90             exceptionState.throwDOMException(TypeMismatchError, ExceptionMessage
     s::failedToExecute("add", "HTMLOptionsCollection", "The index provided could not
      be interpreted as an integer.")); | 90             else | 
| 91         else | 91                 imp->add(option, index, exceptionState); | 
| 92             imp->add(option, index, exceptionState); | 92         } | 
| 93     } | 93     } | 
| 94 | 94 | 
| 95     exceptionState.throwIfNeeded(); | 95     exceptionState.throwIfNeeded(); | 
| 96 } | 96 } | 
| 97 | 97 | 
| 98 void V8HTMLOptionsCollection::lengthAttributeSetterCustom(v8::Local<v8::Value> v
     alue, const v8::PropertyCallbackInfo<void>& info) | 98 void V8HTMLOptionsCollection::lengthAttributeSetterCustom(v8::Local<v8::Value> v
     alue, const v8::PropertyCallbackInfo<void>& info) | 
| 99 { | 99 { | 
| 100     HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder()
     ); | 100     HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder()
     ); | 
| 101     double v = value->NumberValue(); | 101     double v = value->NumberValue(); | 
| 102     unsigned newLength = 0; | 102     unsigned newLength = 0; | 
| 103     ExceptionState exceptionState(info.Holder(), info.GetIsolate()); | 103     ExceptionState exceptionState(ExceptionState::SetterContext, "length", "HTML
     OptionsCollection", info.Holder(), info.GetIsolate()); | 
| 104     if (!std::isnan(v) && !std::isinf(v)) { | 104     if (!std::isnan(v) && !std::isinf(v)) { | 
| 105         if (v < 0.0) | 105         if (v < 0.0) | 
| 106             exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::
     failedToSet("length", "HTMLOptionsCollection", "The value provided (" + String::
     number(v) + ") is negative. Lengths must be greater than or equal to 0.")); | 106             exceptionState.throwDOMException(IndexSizeError, "The value provided
      (" + String::number(v) + ") is negative. Lengths must be greater than or equal 
     to 0."); | 
| 107         else if (v > static_cast<double>(UINT_MAX)) | 107         else if (v > static_cast<double>(UINT_MAX)) | 
| 108             newLength = UINT_MAX; | 108             newLength = UINT_MAX; | 
| 109         else | 109         else | 
| 110             newLength = static_cast<unsigned>(v); | 110             newLength = static_cast<unsigned>(v); | 
| 111     } | 111     } | 
| 112 | 112 | 
| 113     if (exceptionState.throwIfNeeded()) | 113     if (exceptionState.throwIfNeeded()) | 
| 114         return; | 114         return; | 
| 115 | 115 | 
| 116     imp->setLength(newLength, exceptionState); | 116     imp->setLength(newLength, exceptionState); | 
| 117 } | 117 } | 
| 118 | 118 | 
| 119 } // namespace WebCore | 119 } // namespace WebCore | 
| OLD | NEW | 
|---|