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 14 matching lines...) Expand all Loading... |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "V8HTMLCollection.h" | 32 #include "V8HTMLCollection.h" |
33 | 33 |
34 #include "HTMLCollection.h" | 34 #include "HTMLCollection.h" |
35 #include "HTMLPropertiesCollection.h" | |
36 #include "PropertyNodeList.h" | |
37 #include "V8Binding.h" | 35 #include "V8Binding.h" |
38 #include "V8HTMLAllCollection.h" | 36 #include "V8HTMLAllCollection.h" |
39 #include "V8HTMLFormControlsCollection.h" | 37 #include "V8HTMLFormControlsCollection.h" |
40 #include "V8HTMLOptionsCollection.h" | 38 #include "V8HTMLOptionsCollection.h" |
41 #include "V8NamedNodesCollection.h" | 39 #include "V8NamedNodesCollection.h" |
42 #include "V8Node.h" | 40 #include "V8Node.h" |
43 #include "V8PropertyNodeList.h" | |
44 | 41 |
45 namespace WebCore { | 42 namespace WebCore { |
46 | 43 |
47 v8::Handle<v8::Value> V8HTMLCollection::namedPropertyGetter(v8::Local<v8::String
> name, const v8::AccessorInfo& info) | 44 v8::Handle<v8::Value> V8HTMLCollection::namedPropertyGetter(v8::Local<v8::String
> name, const v8::AccessorInfo& info) |
48 { | 45 { |
49 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) | 46 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) |
50 return v8Undefined(); | 47 return v8Undefined(); |
51 if (info.Holder()->HasRealNamedCallbackProperty(name)) | 48 if (info.Holder()->HasRealNamedCallbackProperty(name)) |
52 return v8Undefined(); | 49 return v8Undefined(); |
53 | 50 |
54 HTMLCollection* imp = V8HTMLCollection::toNative(info.Holder()); | 51 HTMLCollection* imp = V8HTMLCollection::toNative(info.Holder()); |
55 #if ENABLE(MICRODATA) | |
56 if (imp->type() == ItemProperties) { | |
57 if (!static_cast<HTMLPropertiesCollection*>(imp)->hasNamedItem(toWebCore
AtomicString(name))) | |
58 return v8Undefined(); | |
59 RefPtr<PropertyNodeList> item = static_cast<HTMLPropertiesCollection*>(i
mp)->propertyNodeList(toWebCoreAtomicString(name)); | |
60 if (!item) | |
61 return v8Undefined(); | |
62 return toV8Fast(item.release(), info, imp); | |
63 } | |
64 #endif | |
65 Node* item = imp->namedItem(toWebCoreAtomicString(name)); | 52 Node* item = imp->namedItem(toWebCoreAtomicString(name)); |
66 if (!item) | 53 if (!item) |
67 return v8Undefined(); | 54 return v8Undefined(); |
68 return toV8Fast(item, info, imp); | 55 return toV8Fast(item, info, imp); |
69 } | 56 } |
70 | 57 |
71 v8::Handle<v8::Object> wrap(HTMLCollection* impl, v8::Handle<v8::Object> creatio
nContext, v8::Isolate* isolate) | 58 v8::Handle<v8::Object> wrap(HTMLCollection* impl, v8::Handle<v8::Object> creatio
nContext, v8::Isolate* isolate) |
72 { | 59 { |
73 ASSERT(impl); | 60 ASSERT(impl); |
74 switch (impl->type()) { | 61 switch (impl->type()) { |
75 case FormControls: | 62 case FormControls: |
76 return wrap(static_cast<HTMLFormControlsCollection*>(impl), creationCont
ext, isolate); | 63 return wrap(static_cast<HTMLFormControlsCollection*>(impl), creationCont
ext, isolate); |
77 case SelectOptions: | 64 case SelectOptions: |
78 return wrap(static_cast<HTMLOptionsCollection*>(impl), creationContext,
isolate); | 65 return wrap(static_cast<HTMLOptionsCollection*>(impl), creationContext,
isolate); |
79 case DocAll: | 66 case DocAll: |
80 return wrap(static_cast<HTMLAllCollection*>(impl), creationContext, isol
ate); | 67 return wrap(static_cast<HTMLAllCollection*>(impl), creationContext, isol
ate); |
81 default: | 68 default: |
82 break; | 69 break; |
83 } | 70 } |
84 | 71 |
85 return V8HTMLCollection::createWrapper(impl, creationContext, isolate); | 72 return V8HTMLCollection::createWrapper(impl, creationContext, isolate); |
86 } | 73 } |
87 | 74 |
88 } // namespace WebCore | 75 } // namespace WebCore |
OLD | NEW |