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

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

Issue 23477075: Rename isolateFor*() utility functions to toIsolate() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 3 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/DOMRequestState.h ('k') | Source/bindings/v8/ScriptState.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 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 String sourceURL = frame->document()->url().string(); 87 String sourceURL = frame->document()->url().string();
88 88
89 return V8LazyEventListener::create(name.localName().string(), eventParameter Name(frame->document()->isSVGDocument()), value, sourceURL, position, 0); 89 return V8LazyEventListener::create(name.localName().string(), eventParameter Name(frame->document()->isSVGDocument()), value, sourceURL, position, 0);
90 } 90 }
91 91
92 String eventListenerHandlerBody(Document* document, EventListener* listener) 92 String eventListenerHandlerBody(Document* document, EventListener* listener)
93 { 93 {
94 if (listener->type() != EventListener::JSEventListenerType) 94 if (listener->type() != EventListener::JSEventListenerType)
95 return ""; 95 return "";
96 96
97 v8::HandleScope scope(isolateForScriptExecutionContext(document)); 97 v8::HandleScope scope(toIsolate(document));
98 V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>( listener); 98 V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>( listener);
99 v8::Handle<v8::Context> context = toV8Context(document, v8Listener->world()) ; 99 v8::Handle<v8::Context> context = toV8Context(document, v8Listener->world()) ;
100 v8::Context::Scope contextScope(context); 100 v8::Context::Scope contextScope(context);
101 v8::Handle<v8::Object> function = v8Listener->getListenerObject(document); 101 v8::Handle<v8::Object> function = v8Listener->getListenerObject(document);
102 if (function.IsEmpty()) 102 if (function.IsEmpty())
103 return ""; 103 return "";
104 104
105 return toWebCoreStringWithNullCheck(function); 105 return toWebCoreStringWithNullCheck(function);
106 } 106 }
107 107
108 ScriptValue eventListenerHandler(Document* document, EventListener* listener) 108 ScriptValue eventListenerHandler(Document* document, EventListener* listener)
109 { 109 {
110 if (listener->type() != EventListener::JSEventListenerType) 110 if (listener->type() != EventListener::JSEventListenerType)
111 return ScriptValue(); 111 return ScriptValue();
112 112
113 v8::HandleScope scope(isolateForScriptExecutionContext(document)); 113 v8::HandleScope scope(toIsolate(document));
114 V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>( listener); 114 V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>( listener);
115 v8::Handle<v8::Context> context = toV8Context(document, v8Listener->world()) ; 115 v8::Handle<v8::Context> context = toV8Context(document, v8Listener->world()) ;
116 v8::Context::Scope contextScope(context); 116 v8::Context::Scope contextScope(context);
117 v8::Handle<v8::Object> function = v8Listener->getListenerObject(document); 117 v8::Handle<v8::Object> function = v8Listener->getListenerObject(document);
118 if (function.IsEmpty()) 118 if (function.IsEmpty())
119 return ScriptValue(); 119 return ScriptValue();
120 return ScriptValue(function); 120 return ScriptValue(function);
121 } 121 }
122 122
123 ScriptState* eventListenerHandlerScriptState(Frame* frame, EventListener* listen er) 123 ScriptState* eventListenerHandlerScriptState(Frame* frame, EventListener* listen er)
124 { 124 {
125 if (listener->type() != EventListener::JSEventListenerType) 125 if (listener->type() != EventListener::JSEventListenerType)
126 return 0; 126 return 0;
127 V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>( listener); 127 V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>( listener);
128 v8::HandleScope scope(isolateForFrame(frame)); 128 v8::HandleScope scope(toIsolate(frame));
129 v8::Handle<v8::Context> v8Context = frame->script()->windowShell(v8Listener- >world())->context(); 129 v8::Handle<v8::Context> v8Context = frame->script()->windowShell(v8Listener- >world())->context();
130 return ScriptState::forContext(v8Context); 130 return ScriptState::forContext(v8Context);
131 } 131 }
132 132
133 bool eventListenerHandlerLocation(Document* document, EventListener* listener, S tring& sourceName, String& scriptId, int& lineNumber) 133 bool eventListenerHandlerLocation(Document* document, EventListener* listener, S tring& sourceName, String& scriptId, int& lineNumber)
134 { 134 {
135 if (listener->type() != EventListener::JSEventListenerType) 135 if (listener->type() != EventListener::JSEventListenerType)
136 return false; 136 return false;
137 137
138 v8::HandleScope scope(isolateForScriptExecutionContext(document)); 138 v8::HandleScope scope(toIsolate(document));
139 V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>( listener); 139 V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>( listener);
140 v8::Handle<v8::Context> context = toV8Context(document, v8Listener->world()) ; 140 v8::Handle<v8::Context> context = toV8Context(document, v8Listener->world()) ;
141 v8::Context::Scope contextScope(context); 141 v8::Context::Scope contextScope(context);
142 v8::Handle<v8::Object> object = v8Listener->getListenerObject(document); 142 v8::Handle<v8::Object> object = v8Listener->getListenerObject(document);
143 if (object.IsEmpty() || !object->IsFunction()) 143 if (object.IsEmpty() || !object->IsFunction())
144 return false; 144 return false;
145 145
146 v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(object); 146 v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(object);
147 v8::Handle<v8::Value> scriptIdValue = function->GetScriptId(); 147 v8::Handle<v8::Value> scriptIdValue = function->GetScriptId();
148 scriptId = toWebCoreStringWithUndefinedOrNullCheck(scriptIdValue); 148 scriptId = toWebCoreStringWithUndefinedOrNullCheck(scriptIdValue);
149 v8::ScriptOrigin origin = function->GetScriptOrigin(); 149 v8::ScriptOrigin origin = function->GetScriptOrigin();
150 if (origin.ResourceName()->IsString() && !origin.ResourceName().IsEmpty()) 150 if (origin.ResourceName()->IsString() && !origin.ResourceName().IsEmpty())
151 sourceName = toWebCoreString(origin.ResourceName()); 151 sourceName = toWebCoreString(origin.ResourceName());
152 else 152 else
153 sourceName = ""; 153 sourceName = "";
154 lineNumber = function->GetScriptLineNumber(); 154 lineNumber = function->GetScriptLineNumber();
155 return true; 155 return true;
156 } 156 }
157 157
158 } // namespace WebCore 158 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/DOMRequestState.h ('k') | Source/bindings/v8/ScriptState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698