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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 if (!V8HTMLOptionElement::HasInstance(info[0], info.GetIsolate(), worldType(
info.GetIsolate()))) { | 76 if (!V8HTMLOptionElement::HasInstance(info[0], info.GetIsolate(), worldType(
info.GetIsolate()))) { |
77 setDOMException(TypeMismatchError, info.GetIsolate()); | 77 setDOMException(TypeMismatchError, info.GetIsolate()); |
78 return; | 78 return; |
79 } | 79 } |
80 HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder()
); | 80 HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder()
); |
81 HTMLOptionElement* option = V8HTMLOptionElement::toNative(v8::Handle<v8::Obj
ect>(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 es(info.GetIsolate()); | 83 ExceptionState es(info.Holder(), info.GetIsolate()); |
84 if (info.Length() < 2) | 84 if (info.Length() < 2) |
85 imp->add(option, es); | 85 imp->add(option, es); |
86 else { | 86 else { |
87 bool ok; | 87 bool ok; |
88 V8TRYCATCH_VOID(int, index, toInt32(info[1], ok)); | 88 V8TRYCATCH_VOID(int, index, toInt32(info[1], ok)); |
89 if (!ok) | 89 if (!ok) |
90 es.throwDOMException(TypeMismatchError, ExceptionMessages::failedToE
xecute("add", "HTMLOptionsCollection", "The index provided could not be interpre
ted as an integer.")); | 90 es.throwDOMException(TypeMismatchError, ExceptionMessages::failedToE
xecute("add", "HTMLOptionsCollection", "The index provided could not be interpre
ted as an integer.")); |
91 else | 91 else |
92 imp->add(option, index, es); | 92 imp->add(option, index, es); |
93 } | 93 } |
94 | 94 |
95 es.throwIfNeeded(); | 95 es.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 es(info.GetIsolate()); | 103 ExceptionState es(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 es.throwDOMException(IndexSizeError, ExceptionMessages::failedToSet(
"length", "HTMLOptionsCollection", "The value provided (" + String::number(v) +
") is negative. Lengths must be greater than or equal to 0.")); | 106 es.throwDOMException(IndexSizeError, ExceptionMessages::failedToSet(
"length", "HTMLOptionsCollection", "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 (es.throwIfNeeded()) | 113 if (es.throwIfNeeded()) |
114 return; | 114 return; |
115 | 115 |
116 imp->setLength(newLength, es); | 116 imp->setLength(newLength, es); |
117 } | 117 } |
118 | 118 |
119 } // namespace WebCore | 119 } // namespace WebCore |
OLD | NEW |