| 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 | 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 return m_liveRoot.getUnsafe(); | 86 return m_liveRoot.getUnsafe(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void V8PerIsolateData::dispose(v8::Isolate* isolate) | 89 void V8PerIsolateData::dispose(v8::Isolate* isolate) |
| 90 { | 90 { |
| 91 void* data = isolate->GetData(gin::kEmbedderBlink); | 91 void* data = isolate->GetData(gin::kEmbedderBlink); |
| 92 delete static_cast<V8PerIsolateData*>(data); | 92 delete static_cast<V8PerIsolateData*>(data); |
| 93 isolate->SetData(gin::kEmbedderBlink, 0); | 93 isolate->SetData(gin::kEmbedderBlink, 0); |
| 94 } | 94 } |
| 95 | 95 |
| 96 v8::Handle<v8::FunctionTemplate> V8PerIsolateData::domTemplate(WrapperWorldType
currentWorldType, void* domTemplateKey, v8::FunctionCallback callback, v8::Handl
e<v8::Value> data, v8::Handle<v8::Signature> signature, int length) | 96 V8PerIsolateData::TemplateMap& V8PerIsolateData::templateMap() |
| 97 { | 97 { |
| 98 TemplateMap& templates = templateMap(currentWorldType); | 98 if (DOMWrapperWorld::current(m_isolate)->isMainWorld()) |
| 99 return m_templatesForMainWorld; |
| 100 return m_templatesForNonMainWorld; |
| 101 } |
| 102 |
| 103 v8::Handle<v8::FunctionTemplate> V8PerIsolateData::domTemplate(void* domTemplate
Key, v8::FunctionCallback callback, v8::Handle<v8::Value> data, v8::Handle<v8::S
ignature> signature, int length) |
| 104 { |
| 105 TemplateMap& templates = templateMap(); |
| 99 TemplateMap::iterator result = templates.find(domTemplateKey); | 106 TemplateMap::iterator result = templates.find(domTemplateKey); |
| 100 if (result != templates.end()) | 107 if (result != templates.end()) |
| 101 return result->value.newLocal(m_isolate); | 108 return result->value.newLocal(m_isolate); |
| 102 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(m_isolate,
callback, data, signature, length); | 109 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(m_isolate,
callback, data, signature, length); |
| 103 templates.add(domTemplateKey, UnsafePersistent<v8::FunctionTemplate>(m_isola
te, templ)); | 110 templates.add(domTemplateKey, UnsafePersistent<v8::FunctionTemplate>(m_isola
te, templ)); |
| 104 return templ; | 111 return templ; |
| 105 } | 112 } |
| 106 | 113 |
| 107 v8::Handle<v8::FunctionTemplate> V8PerIsolateData::existingDOMTemplate(WrapperWo
rldType currentWorldType, void* domTemplateKey) | 114 v8::Handle<v8::FunctionTemplate> V8PerIsolateData::existingDOMTemplate(void* dom
TemplateKey) |
| 108 { | 115 { |
| 109 TemplateMap& templates = templateMap(currentWorldType); | 116 TemplateMap& templates = templateMap(); |
| 110 TemplateMap::iterator result = templates.find(domTemplateKey); | 117 TemplateMap::iterator result = templates.find(domTemplateKey); |
| 111 if (result != templates.end()) | 118 if (result != templates.end()) |
| 112 return result->value.newLocal(m_isolate); | 119 return result->value.newLocal(m_isolate); |
| 113 return v8::Local<v8::FunctionTemplate>(); | 120 return v8::Local<v8::FunctionTemplate>(); |
| 114 } | 121 } |
| 115 | 122 |
| 116 void V8PerIsolateData::setDOMTemplate(WrapperWorldType currentWorldType, void* d
omTemplateKey, v8::Handle<v8::FunctionTemplate> templ) | 123 void V8PerIsolateData::setDOMTemplate(void* domTemplateKey, v8::Handle<v8::Funct
ionTemplate> templ) |
| 117 { | 124 { |
| 118 templateMap(currentWorldType).add(domTemplateKey, UnsafePersistent<v8::Funct
ionTemplate>(m_isolate, templ)); | 125 templateMap().add(domTemplateKey, UnsafePersistent<v8::FunctionTemplate>(m_i
solate, templ)); |
| 119 } | 126 } |
| 120 | 127 |
| 121 v8::Local<v8::Context> V8PerIsolateData::ensureRegexContext() | 128 v8::Local<v8::Context> V8PerIsolateData::ensureRegexContext() |
| 122 { | 129 { |
| 123 if (m_regexContext.isEmpty()) | 130 if (m_regexContext.isEmpty()) |
| 124 m_regexContext.set(m_isolate, v8::Context::New(m_isolate)); | 131 m_regexContext.set(m_isolate, v8::Context::New(m_isolate)); |
| 125 return m_regexContext.newLocal(m_isolate); | 132 return m_regexContext.newLocal(m_isolate); |
| 126 } | 133 } |
| 127 | 134 |
| 128 bool V8PerIsolateData::hasInstance(const WrapperTypeInfo* info, v8::Handle<v8::V
alue> value) | 135 bool V8PerIsolateData::hasInstance(const WrapperTypeInfo* info, v8::Handle<v8::V
alue> value) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 } | 185 } |
| 179 | 186 |
| 180 v8::Handle<v8::FunctionTemplate> V8PerIsolateData::toStringTemplate() | 187 v8::Handle<v8::FunctionTemplate> V8PerIsolateData::toStringTemplate() |
| 181 { | 188 { |
| 182 if (m_toStringTemplate.isEmpty()) | 189 if (m_toStringTemplate.isEmpty()) |
| 183 m_toStringTemplate.set(m_isolate, v8::FunctionTemplate::New(m_isolate, c
onstructorOfToString)); | 190 m_toStringTemplate.set(m_isolate, v8::FunctionTemplate::New(m_isolate, c
onstructorOfToString)); |
| 184 return m_toStringTemplate.newLocal(m_isolate); | 191 return m_toStringTemplate.newLocal(m_isolate); |
| 185 } | 192 } |
| 186 | 193 |
| 187 } // namespace WebCore | 194 } // namespace WebCore |
| OLD | NEW |