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

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

Issue 209713003: Make DOMWrapperWorld::current() return a reference instead of a pointer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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/V8DOMConfiguration.h ('k') | Source/bindings/v8/V8ErrorHandler.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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 23 matching lines...) Expand all
34 namespace WebCore { 34 namespace WebCore {
35 35
36 void V8DOMConfiguration::installAttributes(v8::Handle<v8::ObjectTemplate> instan ceTemplate, v8::Handle<v8::ObjectTemplate> prototype, const AttributeConfigurati on* attributes, size_t attributeCount, v8::Isolate* isolate) 36 void V8DOMConfiguration::installAttributes(v8::Handle<v8::ObjectTemplate> instan ceTemplate, v8::Handle<v8::ObjectTemplate> prototype, const AttributeConfigurati on* attributes, size_t attributeCount, v8::Isolate* isolate)
37 { 37 {
38 for (size_t i = 0; i < attributeCount; ++i) 38 for (size_t i = 0; i < attributeCount; ++i)
39 installAttribute(instanceTemplate, prototype, attributes[i], isolate); 39 installAttribute(instanceTemplate, prototype, attributes[i], isolate);
40 } 40 }
41 41
42 void V8DOMConfiguration::installAccessors(v8::Handle<v8::ObjectTemplate> prototy pe, v8::Handle<v8::Signature> signature, const AccessorConfiguration* accessors, size_t accessorCount, v8::Isolate* isolate) 42 void V8DOMConfiguration::installAccessors(v8::Handle<v8::ObjectTemplate> prototy pe, v8::Handle<v8::Signature> signature, const AccessorConfiguration* accessors, size_t accessorCount, v8::Isolate* isolate)
43 { 43 {
44 bool isMainWorld = DOMWrapperWorld::current(isolate)->isMainWorld(); 44 bool isMainWorld = DOMWrapperWorld::current(isolate).isMainWorld();
45 for (size_t i = 0; i < accessorCount; ++i) { 45 for (size_t i = 0; i < accessorCount; ++i) {
46 v8::FunctionCallback getterCallback = accessors[i].getter; 46 v8::FunctionCallback getterCallback = accessors[i].getter;
47 v8::FunctionCallback setterCallback = accessors[i].setter; 47 v8::FunctionCallback setterCallback = accessors[i].setter;
48 if (isMainWorld) { 48 if (isMainWorld) {
49 if (accessors[i].getterForMainWorld) 49 if (accessors[i].getterForMainWorld)
50 getterCallback = accessors[i].getterForMainWorld; 50 getterCallback = accessors[i].getterForMainWorld;
51 if (accessors[i].setterForMainWorld) 51 if (accessors[i].setterForMainWorld)
52 setterCallback = accessors[i].setterForMainWorld; 52 setterCallback = accessors[i].setterForMainWorld;
53 } 53 }
54 54
(...skipping 16 matching lines...) Expand all
71 for (size_t i = 0; i < constantCount; ++i) { 71 for (size_t i = 0; i < constantCount; ++i) {
72 const ConstantConfiguration* constant = &constants[i]; 72 const ConstantConfiguration* constant = &constants[i];
73 v8::Handle<v8::String> constantName = v8AtomicString(isolate, constant-> name); 73 v8::Handle<v8::String> constantName = v8AtomicString(isolate, constant-> name);
74 functionDescriptor->Set(constantName, v8::Integer::New(isolate, constant ->value), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete)); 74 functionDescriptor->Set(constantName, v8::Integer::New(isolate, constant ->value), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
75 prototype->Set(constantName, v8::Integer::New(isolate, constant->value), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete)); 75 prototype->Set(constantName, v8::Integer::New(isolate, constant->value), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
76 } 76 }
77 } 77 }
78 78
79 void V8DOMConfiguration::installCallbacks(v8::Handle<v8::ObjectTemplate> prototy pe, v8::Handle<v8::Signature> signature, v8::PropertyAttribute attributes, const MethodConfiguration* callbacks, size_t callbackCount, v8::Isolate* isolate) 79 void V8DOMConfiguration::installCallbacks(v8::Handle<v8::ObjectTemplate> prototy pe, v8::Handle<v8::Signature> signature, v8::PropertyAttribute attributes, const MethodConfiguration* callbacks, size_t callbackCount, v8::Isolate* isolate)
80 { 80 {
81 bool isMainWorld = DOMWrapperWorld::current(isolate)->isMainWorld(); 81 bool isMainWorld = DOMWrapperWorld::current(isolate).isMainWorld();
82 for (size_t i = 0; i < callbackCount; ++i) { 82 for (size_t i = 0; i < callbackCount; ++i) {
83 v8::FunctionCallback callback = callbacks[i].callback; 83 v8::FunctionCallback callback = callbacks[i].callback;
84 if (isMainWorld && callbacks[i].callbackForMainWorld) 84 if (isMainWorld && callbacks[i].callbackForMainWorld)
85 callback = callbacks[i].callbackForMainWorld; 85 callback = callbacks[i].callbackForMainWorld;
86 v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate: :New(isolate, callback, v8Undefined(), signature, callbacks[i].length); 86 v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate: :New(isolate, callback, v8Undefined(), signature, callbacks[i].length);
87 functionTemplate->RemovePrototype(); 87 functionTemplate->RemovePrototype();
88 prototype->Set(v8AtomicString(isolate, callbacks[i].name), functionTempl ate, attributes); 88 prototype->Set(v8AtomicString(isolate, callbacks[i].name), functionTempl ate, attributes);
89 } 89 }
90 } 90 }
91 91
(...skipping 19 matching lines...) Expand all
111 if (attributeCount) 111 if (attributeCount)
112 installAttributes(instanceTemplate, functionDescriptor->PrototypeTemplat e(), attributes, attributeCount, isolate); 112 installAttributes(instanceTemplate, functionDescriptor->PrototypeTemplat e(), attributes, attributeCount, isolate);
113 if (accessorCount) 113 if (accessorCount)
114 installAccessors(functionDescriptor->PrototypeTemplate(), defaultSignatu re, accessors, accessorCount, isolate); 114 installAccessors(functionDescriptor->PrototypeTemplate(), defaultSignatu re, accessors, accessorCount, isolate);
115 if (callbackCount) 115 if (callbackCount)
116 installCallbacks(functionDescriptor->PrototypeTemplate(), defaultSignatu re, static_cast<v8::PropertyAttribute>(v8::DontDelete), callbacks, callbackCount , isolate); 116 installCallbacks(functionDescriptor->PrototypeTemplate(), defaultSignatu re, static_cast<v8::PropertyAttribute>(v8::DontDelete), callbacks, callbackCount , isolate);
117 return defaultSignature; 117 return defaultSignature;
118 } 118 }
119 119
120 } // namespace WebCore 120 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/V8DOMConfiguration.h ('k') | Source/bindings/v8/V8ErrorHandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698