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

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

Issue 125043004: Remove world type from hasInstance() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/v8/V8PerIsolateData.h ('k') | Source/bindings/v8/V8Utilities.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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 v8::Local<v8::Context> V8PerIsolateData::ensureRegexContext() 120 v8::Local<v8::Context> V8PerIsolateData::ensureRegexContext()
121 { 121 {
122 if (m_regexContext.isEmpty()) { 122 if (m_regexContext.isEmpty()) {
123 v8::HandleScope handleScope(m_isolate); 123 v8::HandleScope handleScope(m_isolate);
124 m_regexContext.set(m_isolate, v8::Context::New(m_isolate)); 124 m_regexContext.set(m_isolate, v8::Context::New(m_isolate));
125 } 125 }
126 return m_regexContext.newLocal(m_isolate); 126 return m_regexContext.newLocal(m_isolate);
127 } 127 }
128 128
129 bool V8PerIsolateData::hasInstance(const WrapperTypeInfo* info, v8::Handle<v8::V alue> value, WrapperWorldType currentWorldType) 129 bool V8PerIsolateData::hasInstanceInMainWorld(const WrapperTypeInfo* info, v8::H andle<v8::Value> value)
130 { 130 {
131 TemplateMap& templates = templateMap(currentWorldType); 131 return hasInstance(info, value, m_templatesForMainWorld);
132 }
133
134 bool V8PerIsolateData::hasInstanceInNonMainWorld(const WrapperTypeInfo* info, v8 ::Handle<v8::Value> value)
135 {
136 return hasInstance(info, value, m_templatesForNonMainWorld);
137 }
138
139 bool V8PerIsolateData::hasInstance(const WrapperTypeInfo* info, v8::Handle<v8::V alue> value, TemplateMap& templates)
140 {
132 TemplateMap::iterator result = templates.find(info); 141 TemplateMap::iterator result = templates.find(info);
133 if (result == templates.end()) 142 if (result == templates.end())
134 return false; 143 return false;
135 v8::HandleScope handleScope(m_isolate); 144 v8::HandleScope handleScope(m_isolate);
136 return result->value.newLocal(m_isolate)->HasInstance(value); 145 return result->value.newLocal(m_isolate)->HasInstance(value);
137 } 146 }
138 147
139 void V8PerIsolateData::constructorOfToString(const v8::FunctionCallbackInfo<v8:: Value>& info) 148 void V8PerIsolateData::constructorOfToString(const v8::FunctionCallbackInfo<v8:: Value>& info)
140 { 149 {
141 // The DOM constructors' toString functions grab the current toString 150 // The DOM constructors' toString functions grab the current toString
142 // for Functions by taking the toString function of itself and then 151 // for Functions by taking the toString function of itself and then
143 // calling it with the constructor as its receiver. This means that 152 // calling it with the constructor as its receiver. This means that
144 // changes to the Function prototype chain or toString function are 153 // changes to the Function prototype chain or toString function are
145 // reflected when printing DOM constructors. The only wart is that 154 // reflected when printing DOM constructors. The only wart is that
146 // changes to a DOM constructor's toString's toString will cause the 155 // changes to a DOM constructor's toString's toString will cause the
147 // toString of the DOM constructor itself to change. This is extremely 156 // toString of the DOM constructor itself to change. This is extremely
148 // obscure and unlikely to be a problem. 157 // obscure and unlikely to be a problem.
149 v8::Handle<v8::Value> value = info.Callee()->Get(v8AtomicString(info.GetIsol ate(), "toString")); 158 v8::Handle<v8::Value> value = info.Callee()->Get(v8AtomicString(info.GetIsol ate(), "toString"));
150 if (!value->IsFunction()) { 159 if (!value->IsFunction()) {
151 v8SetReturnValue(info, v8::String::Empty(info.GetIsolate())); 160 v8SetReturnValue(info, v8::String::Empty(info.GetIsolate()));
152 return; 161 return;
153 } 162 }
154 v8SetReturnValue(info, V8ScriptRunner::callInternalFunction(v8::Handle<v8::F unction>::Cast(value), info.This(), 0, 0, v8::Isolate::GetCurrent())); 163 v8SetReturnValue(info, V8ScriptRunner::callInternalFunction(v8::Handle<v8::F unction>::Cast(value), info.This(), 0, 0, v8::Isolate::GetCurrent()));
155 } 164 }
156 165
157 } // namespace WebCore 166 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/V8PerIsolateData.h ('k') | Source/bindings/v8/V8Utilities.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698