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

Side by Side Diff: Source/bindings/core/v8/V8Binding.cpp

Issue 668673002: Move the v8::Isolate* parameter to the first parameter of various binding methods in third_party/We… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git/+/master
Patch Set: Created 6 years, 2 months 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) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 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 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 CRASH(); 819 CRASH();
820 } 820 }
821 } 821 }
822 822
823 v8::Handle<v8::Function> getBoundFunction(v8::Handle<v8::Function> function) 823 v8::Handle<v8::Function> getBoundFunction(v8::Handle<v8::Function> function)
824 { 824 {
825 v8::Handle<v8::Value> boundFunction = function->GetBoundFunction(); 825 v8::Handle<v8::Value> boundFunction = function->GetBoundFunction();
826 return boundFunction->IsFunction() ? v8::Handle<v8::Function>::Cast(boundFun ction) : function; 826 return boundFunction->IsFunction() ? v8::Handle<v8::Function>::Cast(boundFun ction) : function;
827 } 827 }
828 828
829 void addHiddenValueToArray(v8::Handle<v8::Object> object, v8::Local<v8::Value> v alue, int arrayIndex, v8::Isolate* isolate) 829 void addHiddenValueToArray(v8::Isolate* isolate, v8::Handle<v8::Object> object, v8::Local<v8::Value> value, int arrayIndex)
830 { 830 {
831 v8::Local<v8::Value> arrayValue = object->GetInternalField(arrayIndex); 831 v8::Local<v8::Value> arrayValue = object->GetInternalField(arrayIndex);
832 if (arrayValue->IsNull() || arrayValue->IsUndefined()) { 832 if (arrayValue->IsNull() || arrayValue->IsUndefined()) {
833 arrayValue = v8::Array::New(isolate); 833 arrayValue = v8::Array::New(isolate);
834 object->SetInternalField(arrayIndex, arrayValue); 834 object->SetInternalField(arrayIndex, arrayValue);
835 } 835 }
836 836
837 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(arrayValue); 837 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(arrayValue);
838 array->Set(v8::Integer::New(isolate, array->Length()), value); 838 array->Set(v8::Integer::New(isolate, array->Length()), value);
839 } 839 }
840 840
841 void removeHiddenValueFromArray(v8::Handle<v8::Object> object, v8::Local<v8::Val ue> value, int arrayIndex, v8::Isolate* isolate) 841 void removeHiddenValueFromArray(v8::Isolate* isolate, v8::Handle<v8::Object> obj ect, v8::Local<v8::Value> value, int arrayIndex)
842 { 842 {
843 v8::Local<v8::Value> arrayValue = object->GetInternalField(arrayIndex); 843 v8::Local<v8::Value> arrayValue = object->GetInternalField(arrayIndex);
844 if (!arrayValue->IsArray()) 844 if (!arrayValue->IsArray())
845 return; 845 return;
846 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(arrayValue); 846 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(arrayValue);
847 for (int i = array->Length() - 1; i >= 0; --i) { 847 for (int i = array->Length() - 1; i >= 0; --i) {
848 v8::Local<v8::Value> item = array->Get(v8::Integer::New(isolate, i)); 848 v8::Local<v8::Value> item = array->Get(v8::Integer::New(isolate, i));
849 if (item->StrictEquals(value)) { 849 if (item->StrictEquals(value)) {
850 array->Delete(i); 850 array->Delete(i);
851 return; 851 return;
852 } 852 }
853 } 853 }
854 } 854 }
855 855
856 void moveEventListenerToNewWrapper(v8::Handle<v8::Object> object, EventListener* oldValue, v8::Local<v8::Value> newValue, int arrayIndex, v8::Isolate* isolate) 856 void moveEventListenerToNewWrapper(v8::Isolate* isolate, v8::Handle<v8::Object> object, EventListener* oldValue, v8::Local<v8::Value> newValue, int arrayIndex)
857 { 857 {
858 if (oldValue) { 858 if (oldValue) {
859 V8AbstractEventListener* oldListener = V8AbstractEventListener::cast(old Value); 859 V8AbstractEventListener* oldListener = V8AbstractEventListener::cast(old Value);
860 if (oldListener) { 860 if (oldListener) {
861 v8::Local<v8::Object> oldListenerObject = oldListener->getExistingLi stenerObject(); 861 v8::Local<v8::Object> oldListenerObject = oldListener->getExistingLi stenerObject();
862 if (!oldListenerObject.IsEmpty()) 862 if (!oldListenerObject.IsEmpty())
863 removeHiddenValueFromArray(object, oldListenerObject, arrayIndex , isolate); 863 removeHiddenValueFromArray(isolate, object, oldListenerObject, a rrayIndex);
864 } 864 }
865 } 865 }
866 // Non-callable input is treated as null and ignored 866 // Non-callable input is treated as null and ignored
867 if (newValue->IsFunction()) 867 if (newValue->IsFunction())
868 addHiddenValueToArray(object, newValue, arrayIndex, isolate); 868 addHiddenValueToArray(isolate, object, newValue, arrayIndex);
869 } 869 }
870 870
871 v8::Isolate* toIsolate(ExecutionContext* context) 871 v8::Isolate* toIsolate(ExecutionContext* context)
872 { 872 {
873 if (context && context->isDocument()) 873 if (context && context->isDocument())
874 return V8PerIsolateData::mainThreadIsolate(); 874 return V8PerIsolateData::mainThreadIsolate();
875 return v8::Isolate::GetCurrent(); 875 return v8::Isolate::GetCurrent();
876 } 876 }
877 877
878 v8::Isolate* toIsolate(LocalFrame* frame) 878 v8::Isolate* toIsolate(LocalFrame* frame)
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 stringResource.prepare(); 968 stringResource.prepare();
969 resourceName = stringResource; 969 resourceName = stringResource;
970 lineNumber = originalFunction->GetScriptLineNumber() + 1; 970 lineNumber = originalFunction->GetScriptLineNumber() + 1;
971 } 971 }
972 if (resourceName.isEmpty()) { 972 if (resourceName.isEmpty()) {
973 resourceName = "undefined"; 973 resourceName = "undefined";
974 lineNumber = 1; 974 lineNumber = 1;
975 } 975 }
976 } 976 }
977 977
978 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(Executio nContext* context, v8::Handle<v8::Function> function, v8::Isolate* isolate) 978 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(v8::Isol ate* isolate, ExecutionContext* context, v8::Handle<v8::Function> function)
979 { 979 {
980 int scriptId = 0; 980 int scriptId = 0;
981 String resourceName; 981 String resourceName;
982 int lineNumber = 1; 982 int lineNumber = 1;
983 GetDevToolsFunctionInfo(function, isolate, scriptId, resourceName, lineNumbe r); 983 GetDevToolsFunctionInfo(function, isolate, scriptId, resourceName, lineNumbe r);
984 return InspectorFunctionCallEvent::data(context, scriptId, resourceName, lin eNumber); 984 return InspectorFunctionCallEvent::data(context, scriptId, resourceName, lin eNumber);
985 } 985 }
986 986
987 v8::Local<v8::Value> v8DoneIteratorResult(v8::Isolate* isolate) 987 v8::Local<v8::Value> v8DoneIteratorResult(v8::Isolate* isolate)
988 { 988 {
989 v8::Local<v8::Object> result = v8::Object::New(isolate); 989 v8::Local<v8::Object> result = v8::Object::New(isolate);
990 result->Set(v8String(isolate, "value"), v8::Undefined(isolate)); 990 result->Set(v8String(isolate, "value"), v8::Undefined(isolate));
991 result->Set(v8String(isolate, "done"), v8Boolean(true, isolate)); 991 result->Set(v8String(isolate, "done"), v8Boolean(true, isolate));
992 return result; 992 return result;
993 } 993 }
994 994
995 v8::Local<v8::Value> v8IteratorResult(v8::Isolate* isolate, v8::Handle<v8::Value > value) 995 v8::Local<v8::Value> v8IteratorResult(v8::Isolate* isolate, v8::Handle<v8::Value > value)
996 { 996 {
997 v8::Local<v8::Object> result = v8::Object::New(isolate); 997 v8::Local<v8::Object> result = v8::Object::New(isolate);
998 result->Set(v8String(isolate, "value"), value); 998 result->Set(v8String(isolate, "value"), value);
999 result->Set(v8String(isolate, "done"), v8Boolean(false, isolate)); 999 result->Set(v8String(isolate, "done"), v8Boolean(false, isolate));
1000 return result; 1000 return result;
1001 } 1001 }
1002 1002
1003 } // namespace blink 1003 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/V8Binding.h ('k') | Source/bindings/core/v8/V8WorkerGlobalScopeEventListener.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698