Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/custom/V8HTMLAllCollectionCustom.cpp

Issue 2571063002: Remove Blink-in-JS (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 static v8::Local<v8::Value> getItem( 62 static v8::Local<v8::Value> getItem(
63 HTMLAllCollection* collection, 63 HTMLAllCollection* collection,
64 v8::Local<v8::Value> argument, 64 v8::Local<v8::Value> argument,
65 const CallbackInfo& info, 65 const CallbackInfo& info,
66 UseCounter::Feature namedFeature, 66 UseCounter::Feature namedFeature,
67 UseCounter::Feature indexedFeature, 67 UseCounter::Feature indexedFeature,
68 UseCounter::Feature indexedWithNonNumberFeature) { 68 UseCounter::Feature indexedWithNonNumberFeature) {
69 v8::Local<v8::Uint32> index; 69 v8::Local<v8::Uint32> index;
70 if (!argument->ToArrayIndex(info.GetIsolate()->GetCurrentContext()) 70 if (!argument->ToArrayIndex(info.GetIsolate()->GetCurrentContext())
71 .ToLocal(&index)) { 71 .ToLocal(&index)) {
72 UseCounter::countIfNotPrivateScript( 72 UseCounter::count(currentExecutionContext(info.GetIsolate()), namedFeature);
73 info.GetIsolate(), currentExecutionContext(info.GetIsolate()),
74 namedFeature);
75 TOSTRING_DEFAULT(V8StringResource<>, name, argument, 73 TOSTRING_DEFAULT(V8StringResource<>, name, argument,
76 v8::Undefined(info.GetIsolate())); 74 v8::Undefined(info.GetIsolate()));
77 v8::Local<v8::Value> result = getNamedItems(collection, name, info); 75 v8::Local<v8::Value> result = getNamedItems(collection, name, info);
78 76
79 if (result.IsEmpty()) 77 if (result.IsEmpty())
80 return v8::Undefined(info.GetIsolate()); 78 return v8::Undefined(info.GetIsolate());
81 79
82 return result; 80 return result;
83 } 81 }
84 82
85 UseCounter::countIfNotPrivateScript( 83 UseCounter::count(currentExecutionContext(info.GetIsolate()), indexedFeature);
86 info.GetIsolate(), currentExecutionContext(info.GetIsolate()), 84 if (!argument->IsNumber()) {
87 indexedFeature); 85 UseCounter::count(currentExecutionContext(info.GetIsolate()),
88 if (!argument->IsNumber()) 86 indexedWithNonNumberFeature);
89 UseCounter::countIfNotPrivateScript( 87 }
90 info.GetIsolate(), currentExecutionContext(info.GetIsolate()),
91 indexedWithNonNumberFeature);
92
93 Element* result = collection->item(index->Value()); 88 Element* result = collection->item(index->Value());
94 return toV8(result, info.Holder(), info.GetIsolate()); 89 return toV8(result, info.Holder(), info.GetIsolate());
95 } 90 }
96 91
97 void V8HTMLAllCollection::itemMethodCustom( 92 void V8HTMLAllCollection::itemMethodCustom(
98 const v8::FunctionCallbackInfo<v8::Value>& info) { 93 const v8::FunctionCallbackInfo<v8::Value>& info) {
99 if (info.Length() < 1) { 94 if (info.Length() < 1) {
100 UseCounter::countIfNotPrivateScript( 95 UseCounter::count(currentExecutionContext(info.GetIsolate()),
101 info.GetIsolate(), currentExecutionContext(info.GetIsolate()), 96 UseCounter::DocumentAllItemNoArguments);
102 UseCounter::DocumentAllItemNoArguments);
103 return; 97 return;
104 } 98 }
105 99
106 HTMLAllCollection* impl = V8HTMLAllCollection::toImpl(info.Holder()); 100 HTMLAllCollection* impl = V8HTMLAllCollection::toImpl(info.Holder());
107 v8SetReturnValue( 101 v8SetReturnValue(
108 info, getItem(impl, info[0], info, UseCounter::DocumentAllItemNamed, 102 info, getItem(impl, info[0], info, UseCounter::DocumentAllItemNamed,
109 UseCounter::DocumentAllItemIndexed, 103 UseCounter::DocumentAllItemIndexed,
110 UseCounter::DocumentAllItemIndexedWithNonNumber)); 104 UseCounter::DocumentAllItemIndexedWithNonNumber));
111 } 105 }
112 106
113 void V8HTMLAllCollection::legacyCallCustom( 107 void V8HTMLAllCollection::legacyCallCustom(
114 const v8::FunctionCallbackInfo<v8::Value>& info) { 108 const v8::FunctionCallbackInfo<v8::Value>& info) {
115 if (info.Length() < 1) { 109 if (info.Length() < 1) {
116 UseCounter::countIfNotPrivateScript( 110 UseCounter::count(currentExecutionContext(info.GetIsolate()),
117 info.GetIsolate(), currentExecutionContext(info.GetIsolate()), 111 UseCounter::DocumentAllLegacyCallNoArguments);
118 UseCounter::DocumentAllLegacyCallNoArguments);
119 return; 112 return;
120 } 113 }
121 114
122 UseCounter::countIfNotPrivateScript( 115 UseCounter::count(currentExecutionContext(info.GetIsolate()),
123 info.GetIsolate(), currentExecutionContext(info.GetIsolate()), 116 UseCounter::DocumentAllLegacyCall);
124 UseCounter::DocumentAllLegacyCall);
125 117
126 HTMLAllCollection* impl = V8HTMLAllCollection::toImpl(info.Holder()); 118 HTMLAllCollection* impl = V8HTMLAllCollection::toImpl(info.Holder());
127 119
128 if (info.Length() == 1) { 120 if (info.Length() == 1) {
129 v8SetReturnValue( 121 v8SetReturnValue(
130 info, 122 info,
131 getItem(impl, info[0], info, UseCounter::DocumentAllLegacyCallNamed, 123 getItem(impl, info[0], info, UseCounter::DocumentAllLegacyCallNamed,
132 UseCounter::DocumentAllLegacyCallIndexed, 124 UseCounter::DocumentAllLegacyCallIndexed,
133 UseCounter::DocumentAllLegacyCallIndexedWithNonNumber)); 125 UseCounter::DocumentAllLegacyCallIndexedWithNonNumber));
134 return; 126 return;
135 } 127 }
136 128
137 UseCounter::countIfNotPrivateScript( 129 UseCounter::count(currentExecutionContext(info.GetIsolate()),
138 info.GetIsolate(), currentExecutionContext(info.GetIsolate()), 130 UseCounter::DocumentAllLegacyCallTwoArguments);
139 UseCounter::DocumentAllLegacyCallTwoArguments);
140 131
141 // If there is a second argument it is the index of the item we want. 132 // If there is a second argument it is the index of the item we want.
142 TOSTRING_VOID(V8StringResource<>, name, info[0]); 133 TOSTRING_VOID(V8StringResource<>, name, info[0]);
143 v8::Local<v8::Uint32> index; 134 v8::Local<v8::Uint32> index;
144 if (!info[1] 135 if (!info[1]
145 ->ToArrayIndex(info.GetIsolate()->GetCurrentContext()) 136 ->ToArrayIndex(info.GetIsolate()->GetCurrentContext())
146 .ToLocal(&index)) 137 .ToLocal(&index))
147 return; 138 return;
148 139
149 if (Node* node = impl->namedItemWithIndex(name, index->Value())) { 140 if (Node* node = impl->namedItemWithIndex(name, index->Value())) {
150 v8SetReturnValueFast(info, node, impl); 141 v8SetReturnValueFast(info, node, impl);
151 return; 142 return;
152 } 143 }
153 } 144 }
154 145
155 } // namespace blink 146 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698