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 25 matching lines...) Expand all Loading... |
36 #include "bindings/v8/V8Binding.h" | 36 #include "bindings/v8/V8Binding.h" |
37 #include "bindings/v8/custom/V8NamedNodesCollection.h" | 37 #include "bindings/v8/custom/V8NamedNodesCollection.h" |
38 #include "core/html/HTMLCollection.h" | 38 #include "core/html/HTMLCollection.h" |
39 #include "core/html/HTMLFormElement.h" | 39 #include "core/html/HTMLFormElement.h" |
40 | 40 |
41 namespace WebCore { | 41 namespace WebCore { |
42 | 42 |
43 v8::Handle<v8::Value> V8HTMLFormElement::indexedPropertyGetter(uint32_t index, c
onst v8::AccessorInfo& info) | 43 v8::Handle<v8::Value> V8HTMLFormElement::indexedPropertyGetter(uint32_t index, c
onst v8::AccessorInfo& info) |
44 { | 44 { |
45 HandleScope handleScope; | 45 HandleScope handleScope; |
46 HTMLFormElement* form = V8HTMLFormElement::toNative(info.Holder()); | 46 Handle<HTMLFormElement> form = adoptRawResult(V8HTMLFormElement::toNative(in
fo.Holder())); |
47 | 47 |
48 Handle<Node> formElement = form->elements()->item(index); | 48 Handle<Node> formElement = form->elements()->item(index); |
49 if (!formElement) | 49 if (!formElement) |
50 return v8Undefined(); | 50 return v8Undefined(); |
51 return toV8Fast(formElement, info, form); | 51 return toV8Fast(formElement, info, form); |
52 } | 52 } |
53 | 53 |
54 v8::Handle<v8::Value> V8HTMLFormElement::namedPropertyGetter(v8::Local<v8::Strin
g> name, const v8::AccessorInfo& info) | 54 v8::Handle<v8::Value> V8HTMLFormElement::namedPropertyGetter(v8::Local<v8::Strin
g> name, const v8::AccessorInfo& info) |
55 { | 55 { |
56 HandleScope handleScope; | 56 HandleScope handleScope; |
57 HTMLFormElement* imp = V8HTMLFormElement::toNative(info.Holder()); | 57 Handle<HTMLFormElement> imp = adoptRawResult(V8HTMLFormElement::toNative(inf
o.Holder())); |
58 AtomicString v = toWebCoreAtomicString(name); | 58 AtomicString v = toWebCoreAtomicString(name); |
59 | 59 |
60 // Call getNamedElements twice, first time check if it has a value | 60 // Call getNamedElements twice, first time check if it has a value |
61 // and let HTMLFormElement update its cache. | 61 // and let HTMLFormElement update its cache. |
62 // See issue: 867404 | 62 // See issue: 867404 |
63 { | 63 { |
64 CollectionRoot<Vector<Member<Node> > > elements; | 64 CollectionRoot<Vector<Member<Node> > > elements; |
65 imp->getNamedElements(v, *elements); | 65 imp->getNamedElements(v, *elements); |
66 if (elements->isEmpty()) | 66 if (elements->isEmpty()) |
67 return v8Undefined(); | 67 return v8Undefined(); |
68 } | 68 } |
69 | 69 |
70 // Second call may return different results from the first call, | 70 // Second call may return different results from the first call, |
71 // but if the first the size cannot be zero. | 71 // but if the first the size cannot be zero. |
72 CollectionRoot<Vector<Member<Node> > > elements; | 72 CollectionRoot<Vector<Member<Node> > > elements; |
73 imp->getNamedElements(v, *elements); | 73 imp->getNamedElements(v, *elements); |
74 ASSERT(!elements->isEmpty()); | 74 ASSERT(!elements->isEmpty()); |
75 | 75 |
76 if (elements->size() == 1) | 76 if (elements->size() == 1) |
77 return toV8Fast(elements[0].handle(), info, imp); | 77 return toV8Fast(elements[0].handle(), info, imp); |
78 | 78 |
79 return toV8Fast(V8NamedNodesCollection::create(*elements), info, imp); | 79 return toV8Fast(V8NamedNodesCollection::create(*elements), info, imp.raw()); |
80 } | 80 } |
81 | 81 |
82 } // namespace WebCore | 82 } // namespace WebCore |
OLD | NEW |