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

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

Issue 14334002: Delete WorldContextHandle in favor of DOMWrapperWorld (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 8 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
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 return V8LazyEventListener::create(name.localName().string(), eventParameter Name(frame->document()->isSVGDocument()), value, sourceURL, position, 0); 87 return V8LazyEventListener::create(name.localName().string(), eventParameter Name(frame->document()->isSVGDocument()), value, sourceURL, position, 0);
88 } 88 }
89 89
90 String eventListenerHandlerBody(Document* document, EventListener* listener) 90 String eventListenerHandlerBody(Document* document, EventListener* listener)
91 { 91 {
92 if (listener->type() != EventListener::JSEventListenerType) 92 if (listener->type() != EventListener::JSEventListenerType)
93 return ""; 93 return "";
94 94
95 v8::HandleScope scope; 95 v8::HandleScope scope;
96 V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>( listener); 96 V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>( listener);
97 v8::Handle<v8::Context> context = toV8Context(document, v8Listener->worldCon text()); 97 v8::Handle<v8::Context> context = toV8Context(document, v8Listener->world()) ;
98 v8::Context::Scope contextScope(context); 98 v8::Context::Scope contextScope(context);
99 v8::Handle<v8::Object> function = v8Listener->getListenerObject(document); 99 v8::Handle<v8::Object> function = v8Listener->getListenerObject(document);
100 if (function.IsEmpty()) 100 if (function.IsEmpty())
101 return ""; 101 return "";
102 102
103 return toWebCoreStringWithNullCheck(function); 103 return toWebCoreStringWithNullCheck(function);
104 } 104 }
105 105
106 ScriptValue eventListenerHandler(Document* document, EventListener* listener) 106 ScriptValue eventListenerHandler(Document* document, EventListener* listener)
107 { 107 {
108 if (listener->type() != EventListener::JSEventListenerType) 108 if (listener->type() != EventListener::JSEventListenerType)
109 return ScriptValue(); 109 return ScriptValue();
110 110
111 v8::HandleScope scope; 111 v8::HandleScope scope;
112 V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>( listener); 112 V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>( listener);
113 v8::Handle<v8::Context> context = toV8Context(document, v8Listener->worldCon text()); 113 v8::Handle<v8::Context> context = toV8Context(document, v8Listener->world()) ;
114 v8::Context::Scope contextScope(context); 114 v8::Context::Scope contextScope(context);
115 v8::Handle<v8::Object> function = v8Listener->getListenerObject(document); 115 v8::Handle<v8::Object> function = v8Listener->getListenerObject(document);
116 if (function.IsEmpty()) 116 if (function.IsEmpty())
117 return ScriptValue(); 117 return ScriptValue();
118 return ScriptValue(function); 118 return ScriptValue(function);
119 } 119 }
120 120
121 ScriptState* eventListenerHandlerScriptState(Frame* frame, EventListener* listen er) 121 ScriptState* eventListenerHandlerScriptState(Frame* frame, EventListener* listen er)
122 { 122 {
123 if (listener->type() != EventListener::JSEventListenerType) 123 if (listener->type() != EventListener::JSEventListenerType)
124 return 0; 124 return 0;
125 V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>( listener); 125 V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>( listener);
126 v8::HandleScope scope; 126 v8::HandleScope scope;
127 v8::Handle<v8::Context> v8Context = v8Listener->worldContext().adjustedConte xt(frame->script()); 127 v8::Handle<v8::Context> v8Context = v8::Local<v8::Context>::New(frame->scrip t()->windowShell(v8Listener->world())->context());
128 return ScriptState::forContext(*v8Context); 128 return ScriptState::forContext(*v8Context);
129 } 129 }
130 130
131 bool eventListenerHandlerLocation(Document* document, EventListener* listener, S tring& sourceName, String& scriptId, int& lineNumber) 131 bool eventListenerHandlerLocation(Document* document, EventListener* listener, S tring& sourceName, String& scriptId, int& lineNumber)
132 { 132 {
133 if (listener->type() != EventListener::JSEventListenerType) 133 if (listener->type() != EventListener::JSEventListenerType)
134 return false; 134 return false;
135 135
136 v8::HandleScope scope; 136 v8::HandleScope scope;
137 V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>( listener); 137 V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>( listener);
138 v8::Handle<v8::Context> context = toV8Context(document, v8Listener->worldCon text()); 138 v8::Handle<v8::Context> context = toV8Context(document, v8Listener->world()) ;
139 v8::Context::Scope contextScope(context); 139 v8::Context::Scope contextScope(context);
140 v8::Handle<v8::Object> object = v8Listener->getListenerObject(document); 140 v8::Handle<v8::Object> object = v8Listener->getListenerObject(document);
141 if (object.IsEmpty() || !object->IsFunction()) 141 if (object.IsEmpty() || !object->IsFunction())
142 return false; 142 return false;
143 143
144 v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(object); 144 v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(object);
145 v8::Handle<v8::Value> scriptIdValue = function->GetScriptId(); 145 v8::Handle<v8::Value> scriptIdValue = function->GetScriptId();
146 scriptId = toWebCoreStringWithUndefinedOrNullCheck(scriptIdValue); 146 scriptId = toWebCoreStringWithUndefinedOrNullCheck(scriptIdValue);
147 v8::ScriptOrigin origin = function->GetScriptOrigin(); 147 v8::ScriptOrigin origin = function->GetScriptOrigin();
148 if (origin.ResourceName()->IsString() && !origin.ResourceName().IsEmpty()) 148 if (origin.ResourceName()->IsString() && !origin.ResourceName().IsEmpty())
149 sourceName = toWebCoreString(origin.ResourceName()); 149 sourceName = toWebCoreString(origin.ResourceName());
150 else 150 else
151 sourceName = ""; 151 sourceName = "";
152 lineNumber = function->GetScriptLineNumber(); 152 lineNumber = function->GetScriptLineNumber();
153 return true; 153 return true;
154 } 154 }
155 155
156 } // namespace WebCore 156 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698