| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(args.Holder()
); | 79 HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(args.Holder()
); |
| 80 HTMLOptionElement* option = V8HTMLOptionElement::toNative(v8::Handle<v8::Obj
ect>(v8::Handle<v8::Object>::Cast(args[0]))); | 80 HTMLOptionElement* option = V8HTMLOptionElement::toNative(v8::Handle<v8::Obj
ect>(v8::Handle<v8::Object>::Cast(args[0]))); |
| 81 | 81 |
| 82 ExceptionState es(args.GetIsolate()); | 82 ExceptionState es(args.GetIsolate()); |
| 83 if (args.Length() < 2) | 83 if (args.Length() < 2) |
| 84 imp->add(option, es); | 84 imp->add(option, es); |
| 85 else { | 85 else { |
| 86 bool ok; | 86 bool ok; |
| 87 V8TRYCATCH_VOID(int, index, toInt32(args[1], ok)); | 87 V8TRYCATCH_VOID(int, index, toInt32(args[1], ok)); |
| 88 if (!ok) | 88 if (!ok) |
| 89 es.throwDOMException(TypeMismatchError); | 89 es.throwUninformativeAndGenericDOMException(TypeMismatchError); |
| 90 else | 90 else |
| 91 imp->add(option, index, es); | 91 imp->add(option, index, es); |
| 92 } | 92 } |
| 93 | 93 |
| 94 es.throwIfNeeded(); | 94 es.throwIfNeeded(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void V8HTMLOptionsCollection::lengthAttributeSetterCustom(v8::Local<v8::String>
name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) | 97 void V8HTMLOptionsCollection::lengthAttributeSetterCustom(v8::Local<v8::String>
name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) |
| 98 { | 98 { |
| 99 HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder()
); | 99 HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder()
); |
| 100 double v = value->NumberValue(); | 100 double v = value->NumberValue(); |
| 101 unsigned newLength = 0; | 101 unsigned newLength = 0; |
| 102 ExceptionState es(info.GetIsolate()); | 102 ExceptionState es(info.GetIsolate()); |
| 103 if (!std::isnan(v) && !std::isinf(v)) { | 103 if (!std::isnan(v) && !std::isinf(v)) { |
| 104 if (v < 0.0) | 104 if (v < 0.0) |
| 105 es.throwDOMException(IndexSizeError); | 105 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 106 else if (v > static_cast<double>(UINT_MAX)) | 106 else if (v > static_cast<double>(UINT_MAX)) |
| 107 newLength = UINT_MAX; | 107 newLength = UINT_MAX; |
| 108 else | 108 else |
| 109 newLength = static_cast<unsigned>(v); | 109 newLength = static_cast<unsigned>(v); |
| 110 } | 110 } |
| 111 | 111 |
| 112 if (es.throwIfNeeded()) | 112 if (es.throwIfNeeded()) |
| 113 return; | 113 return; |
| 114 | 114 |
| 115 imp->setLength(newLength, es); | 115 imp->setLength(newLength, es); |
| 116 } | 116 } |
| 117 | 117 |
| 118 } // namespace WebCore | 118 } // namespace WebCore |
| OLD | NEW |