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

Side by Side Diff: Source/bindings/v8/V8PerIsolateData.cpp

Issue 40433002: Make wrapperTypeInfo static member const in bindings classes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 7 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
« no previous file with comments | « Source/bindings/v8/V8PerIsolateData.h ('k') | Source/bindings/v8/WorkerScriptController.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 if (result != templates.end()) 110 if (result != templates.end())
111 return result->value.newLocal(m_isolate); 111 return result->value.newLocal(m_isolate);
112 return v8::Local<v8::FunctionTemplate>(); 112 return v8::Local<v8::FunctionTemplate>();
113 } 113 }
114 114
115 void V8PerIsolateData::setPrivateTemplate(WrapperWorldType currentWorldType, voi d* privatePointer, v8::Handle<v8::FunctionTemplate> templ) 115 void V8PerIsolateData::setPrivateTemplate(WrapperWorldType currentWorldType, voi d* privatePointer, v8::Handle<v8::FunctionTemplate> templ)
116 { 116 {
117 templateMap(currentWorldType).add(privatePointer, UnsafePersistent<v8::Funct ionTemplate>(m_isolate, templ)); 117 templateMap(currentWorldType).add(privatePointer, UnsafePersistent<v8::Funct ionTemplate>(m_isolate, templ));
118 } 118 }
119 119
120 v8::Handle<v8::FunctionTemplate> V8PerIsolateData::rawTemplate(WrapperTypeInfo* info, WrapperWorldType currentWorldType) 120 v8::Handle<v8::FunctionTemplate> V8PerIsolateData::rawTemplate(const WrapperType Info* info, WrapperWorldType currentWorldType)
121 { 121 {
122 TemplateMap& templates = rawTemplateMap(currentWorldType); 122 TemplateMap& templates = rawTemplateMap(currentWorldType);
123 TemplateMap::iterator result = templates.find(info); 123 TemplateMap::iterator result = templates.find(info);
124 if (result != templates.end()) 124 if (result != templates.end())
125 return result->value.newLocal(m_isolate); 125 return result->value.newLocal(m_isolate);
126 126
127 v8::HandleScope handleScope(m_isolate); 127 v8::HandleScope handleScope(m_isolate);
128 v8::Handle<v8::FunctionTemplate> templ = createRawTemplate(m_isolate); 128 v8::Handle<v8::FunctionTemplate> templ = createRawTemplate(m_isolate);
129 templates.add(info, UnsafePersistent<v8::FunctionTemplate>(m_isolate, templ) ); 129 templates.add(info, UnsafePersistent<v8::FunctionTemplate>(m_isolate, templ) );
130 return handleScope.Close(templ); 130 return handleScope.Close(templ);
131 } 131 }
132 132
133 v8::Local<v8::Context> V8PerIsolateData::ensureRegexContext() 133 v8::Local<v8::Context> V8PerIsolateData::ensureRegexContext()
134 { 134 {
135 if (m_regexContext.isEmpty()) { 135 if (m_regexContext.isEmpty()) {
136 v8::HandleScope handleScope(m_isolate); 136 v8::HandleScope handleScope(m_isolate);
137 m_regexContext.set(m_isolate, v8::Context::New(m_isolate)); 137 m_regexContext.set(m_isolate, v8::Context::New(m_isolate));
138 } 138 }
139 return m_regexContext.newLocal(m_isolate); 139 return m_regexContext.newLocal(m_isolate);
140 } 140 }
141 141
142 bool V8PerIsolateData::hasInstance(WrapperTypeInfo* info, v8::Handle<v8::Value> value, WrapperWorldType currentWorldType) 142 bool V8PerIsolateData::hasInstance(const WrapperTypeInfo* info, v8::Handle<v8::V alue> value, WrapperWorldType currentWorldType)
143 { 143 {
144 TemplateMap& templates = rawTemplateMap(currentWorldType); 144 TemplateMap& templates = rawTemplateMap(currentWorldType);
145 TemplateMap::iterator result = templates.find(info); 145 TemplateMap::iterator result = templates.find(info);
146 if (result == templates.end()) 146 if (result == templates.end())
147 return false; 147 return false;
148 v8::HandleScope handleScope(m_isolate); 148 v8::HandleScope handleScope(m_isolate);
149 return result->value.newLocal(m_isolate)->HasInstance(value); 149 return result->value.newLocal(m_isolate)->HasInstance(value);
150 } 150 }
151 151
152 void V8PerIsolateData::constructorOfToString(const v8::FunctionCallbackInfo<v8:: Value>& args) 152 void V8PerIsolateData::constructorOfToString(const v8::FunctionCallbackInfo<v8:: Value>& args)
153 { 153 {
154 // The DOM constructors' toString functions grab the current toString 154 // The DOM constructors' toString functions grab the current toString
155 // for Functions by taking the toString function of itself and then 155 // for Functions by taking the toString function of itself and then
156 // calling it with the constructor as its receiver. This means that 156 // calling it with the constructor as its receiver. This means that
157 // changes to the Function prototype chain or toString function are 157 // changes to the Function prototype chain or toString function are
158 // reflected when printing DOM constructors. The only wart is that 158 // reflected when printing DOM constructors. The only wart is that
159 // changes to a DOM constructor's toString's toString will cause the 159 // changes to a DOM constructor's toString's toString will cause the
160 // toString of the DOM constructor itself to change. This is extremely 160 // toString of the DOM constructor itself to change. This is extremely
161 // obscure and unlikely to be a problem. 161 // obscure and unlikely to be a problem.
162 v8::Handle<v8::Value> value = args.Callee()->Get(v8::String::NewSymbol("toSt ring")); 162 v8::Handle<v8::Value> value = args.Callee()->Get(v8::String::NewSymbol("toSt ring"));
163 if (!value->IsFunction()) { 163 if (!value->IsFunction()) {
164 v8SetReturnValue(args, v8::String::Empty(args.GetIsolate())); 164 v8SetReturnValue(args, v8::String::Empty(args.GetIsolate()));
165 return; 165 return;
166 } 166 }
167 v8SetReturnValue(args, V8ScriptRunner::callInternalFunction(v8::Handle<v8::F unction>::Cast(value), args.This(), 0, 0, v8::Isolate::GetCurrent())); 167 v8SetReturnValue(args, V8ScriptRunner::callInternalFunction(v8::Handle<v8::F unction>::Cast(value), args.This(), 0, 0, v8::Isolate::GetCurrent()));
168 } 168 }
169 169
170 } // namespace WebCore 170 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/V8PerIsolateData.h ('k') | Source/bindings/v8/WorkerScriptController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698