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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "core/html/HTMLSelectElement.h" | 43 #include "core/html/HTMLSelectElement.h" |
44 | 44 |
45 namespace WebCore { | 45 namespace WebCore { |
46 | 46 |
47 void V8HTMLOptionsCollection::addMethodCustom(const v8::FunctionCallbackInfo<v8:
:Value>& info) | 47 void V8HTMLOptionsCollection::addMethodCustom(const v8::FunctionCallbackInfo<v8:
:Value>& info) |
48 { | 48 { |
49 ExceptionState exceptionState(ExceptionState::ExecutionContext, "add", "HTML
OptionsCollection", info.Holder(), info.GetIsolate()); | 49 ExceptionState exceptionState(ExceptionState::ExecutionContext, "add", "HTML
OptionsCollection", info.Holder(), info.GetIsolate()); |
50 if (!V8HTMLOptionElement::hasInstance(info[0], info.GetIsolate())) { | 50 if (!V8HTMLOptionElement::hasInstance(info[0], info.GetIsolate())) { |
51 exceptionState.throwTypeError("The element provided was not an HTMLOptio
nElement."); | 51 exceptionState.throwTypeError("The element provided was not an HTMLOptio
nElement."); |
52 } else { | 52 } else { |
53 HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Hold
er()); | 53 HTMLOptionsCollection* impl = V8HTMLOptionsCollection::toNative(info.Hol
der()); |
54 HTMLOptionElement* option = V8HTMLOptionElement::toNative(v8::Handle<v8:
:Object>(v8::Handle<v8::Object>::Cast(info[0]))); | 54 HTMLOptionElement* option = V8HTMLOptionElement::toNative(v8::Handle<v8:
:Object>(v8::Handle<v8::Object>::Cast(info[0]))); |
55 | 55 |
56 if (info.Length() < 2) { | 56 if (info.Length() < 2) { |
57 imp->add(option, exceptionState); | 57 impl->add(option, exceptionState); |
58 } else { | 58 } else { |
59 int index = toInt32(info[1], exceptionState); | 59 int index = toInt32(info[1], exceptionState); |
60 if (exceptionState.throwIfNeeded()) | 60 if (exceptionState.throwIfNeeded()) |
61 return; | 61 return; |
62 | 62 |
63 imp->add(option, index, exceptionState); | 63 impl->add(option, index, exceptionState); |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 exceptionState.throwIfNeeded(); | 67 exceptionState.throwIfNeeded(); |
68 } | 68 } |
69 | 69 |
70 void V8HTMLOptionsCollection::lengthAttributeSetterCustom(v8::Local<v8::Value> v
alue, const v8::PropertyCallbackInfo<void>& info) | 70 void V8HTMLOptionsCollection::lengthAttributeSetterCustom(v8::Local<v8::Value> v
alue, const v8::PropertyCallbackInfo<void>& info) |
71 { | 71 { |
72 HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder()
); | 72 HTMLOptionsCollection* impl = V8HTMLOptionsCollection::toNative(info.Holder(
)); |
73 double v = value->NumberValue(); | 73 double v = value->NumberValue(); |
74 unsigned newLength = 0; | 74 unsigned newLength = 0; |
75 ExceptionState exceptionState(ExceptionState::SetterContext, "length", "HTML
OptionsCollection", info.Holder(), info.GetIsolate()); | 75 ExceptionState exceptionState(ExceptionState::SetterContext, "length", "HTML
OptionsCollection", info.Holder(), info.GetIsolate()); |
76 if (!std::isnan(v) && !std::isinf(v)) { | 76 if (!std::isnan(v) && !std::isinf(v)) { |
77 if (v < 0.0) | 77 if (v < 0.0) |
78 exceptionState.throwDOMException(IndexSizeError, "The value provided
(" + String::number(v) + ") is negative. Lengths must be greater than or equal
to 0."); | 78 exceptionState.throwDOMException(IndexSizeError, "The value provided
(" + String::number(v) + ") is negative. Lengths must be greater than or equal
to 0."); |
79 else if (v > static_cast<double>(UINT_MAX)) | 79 else if (v > static_cast<double>(UINT_MAX)) |
80 newLength = UINT_MAX; | 80 newLength = UINT_MAX; |
81 else | 81 else |
82 newLength = static_cast<unsigned>(v); | 82 newLength = static_cast<unsigned>(v); |
83 } | 83 } |
84 | 84 |
85 if (exceptionState.throwIfNeeded()) | 85 if (exceptionState.throwIfNeeded()) |
86 return; | 86 return; |
87 | 87 |
88 imp->setLength(newLength, exceptionState); | 88 impl->setLength(newLength, exceptionState); |
89 } | 89 } |
90 | 90 |
91 } // namespace WebCore | 91 } // namespace WebCore |
OLD | NEW |