| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2011 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 if (paramCount > 0) { | 119 if (paramCount > 0) { |
| 120 params = adoptArrayPtr(new v8::Local<v8::Value>[paramCount]); | 120 params = adoptArrayPtr(new v8::Local<v8::Value>[paramCount]); |
| 121 for (int i = 0; i < paramCount; i++) { | 121 for (int i = 0; i < paramCount; i++) { |
| 122 // parameters must be globalized | 122 // parameters must be globalized |
| 123 params[i] = args[i+2]; | 123 params[i] = args[i+2]; |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 // params is passed to action, and released in action's destructor | 127 // params is passed to action, and released in action's destructor |
| 128 ASSERT(imp->frame()); | 128 ASSERT(imp->frame()); |
| 129 action = adoptPtr(new ScheduledAction(imp->frame()->script()->currentWor
ldContext(), v8::Handle<v8::Function>::Cast(function), paramCount, params.get(),
args.GetIsolate())); | 129 action = adoptPtr(new ScheduledAction(imp->frame()->script().currentWorl
dContext(), v8::Handle<v8::Function>::Cast(function), paramCount, params.get(),
args.GetIsolate())); |
| 130 } else { | 130 } else { |
| 131 if (imp->document() && !imp->document()->contentSecurityPolicy()->allowE
val()) { | 131 if (imp->document() && !imp->document()->contentSecurityPolicy()->allowE
val()) { |
| 132 v8SetReturnValue(args, 0); | 132 v8SetReturnValue(args, 0); |
| 133 return; | 133 return; |
| 134 } | 134 } |
| 135 ASSERT(imp->frame()); | 135 ASSERT(imp->frame()); |
| 136 action = adoptPtr(new ScheduledAction(imp->frame()->script()->currentWor
ldContext(), functionString, KURL(), args.GetIsolate())); | 136 action = adoptPtr(new ScheduledAction(imp->frame()->script().currentWorl
dContext(), functionString, KURL(), args.GetIsolate())); |
| 137 } | 137 } |
| 138 | 138 |
| 139 int32_t timeout = argumentCount >= 2 ? args[1]->Int32Value() : 0; | 139 int32_t timeout = argumentCount >= 2 ? args[1]->Int32Value() : 0; |
| 140 int timerId; | 140 int timerId; |
| 141 if (singleShot) | 141 if (singleShot) |
| 142 timerId = DOMWindowTimers::setTimeout(imp, action.release(), timeout); | 142 timerId = DOMWindowTimers::setTimeout(imp, action.release(), timeout); |
| 143 else | 143 else |
| 144 timerId = DOMWindowTimers::setInterval(imp, action.release(), timeout); | 144 timerId = DOMWindowTimers::setInterval(imp, action.release(), timeout); |
| 145 | 145 |
| 146 // Try to do the idle notification before the timeout expires to get better | 146 // Try to do the idle notification before the timeout expires to get better |
| (...skipping 13 matching lines...) Expand all Loading... |
| 160 return; | 160 return; |
| 161 | 161 |
| 162 Frame* frame = V8Window::toNative(holder)->frame(); | 162 Frame* frame = V8Window::toNative(holder)->frame(); |
| 163 ExceptionState es(info.GetIsolate()); | 163 ExceptionState es(info.GetIsolate()); |
| 164 if (!BindingSecurity::shouldAllowAccessToFrame(frame, es)) { | 164 if (!BindingSecurity::shouldAllowAccessToFrame(frame, es)) { |
| 165 es.throwIfNeeded(); | 165 es.throwIfNeeded(); |
| 166 return; | 166 return; |
| 167 } | 167 } |
| 168 | 168 |
| 169 ASSERT(frame); | 169 ASSERT(frame); |
| 170 v8::Local<v8::Context> context = frame->script()->currentWorldContext(); | 170 v8::Local<v8::Context> context = frame->script().currentWorldContext(); |
| 171 if (context.IsEmpty()) | 171 if (context.IsEmpty()) |
| 172 return; | 172 return; |
| 173 | 173 |
| 174 v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event(info.GetIso
late()); | 174 v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event(info.GetIso
late()); |
| 175 v8::Handle<v8::Value> jsEvent = context->Global()->GetHiddenValue(eventSymbo
l); | 175 v8::Handle<v8::Value> jsEvent = context->Global()->GetHiddenValue(eventSymbo
l); |
| 176 if (jsEvent.IsEmpty()) | 176 if (jsEvent.IsEmpty()) |
| 177 return; | 177 return; |
| 178 v8SetReturnValue(info, jsEvent); | 178 v8SetReturnValue(info, jsEvent); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void V8Window::eventAttributeSetterCustom(v8::Local<v8::String> name, v8::Local<
v8::Value> value, const v8::PropertyCallbackInfo<void>& info) | 181 void V8Window::eventAttributeSetterCustom(v8::Local<v8::String> name, v8::Local<
v8::Value> value, const v8::PropertyCallbackInfo<void>& info) |
| 182 { | 182 { |
| 183 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8
Window::GetTemplate(info.GetIsolate(), worldTypeInMainThread(info.GetIsolate()))
); | 183 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8
Window::GetTemplate(info.GetIsolate(), worldTypeInMainThread(info.GetIsolate()))
); |
| 184 if (holder.IsEmpty()) | 184 if (holder.IsEmpty()) |
| 185 return; | 185 return; |
| 186 | 186 |
| 187 Frame* frame = V8Window::toNative(holder)->frame(); | 187 Frame* frame = V8Window::toNative(holder)->frame(); |
| 188 ExceptionState es(info.GetIsolate()); | 188 ExceptionState es(info.GetIsolate()); |
| 189 if (!BindingSecurity::shouldAllowAccessToFrame(frame, es)) { | 189 if (!BindingSecurity::shouldAllowAccessToFrame(frame, es)) { |
| 190 es.throwIfNeeded(); | 190 es.throwIfNeeded(); |
| 191 return; | 191 return; |
| 192 } | 192 } |
| 193 | 193 |
| 194 ASSERT(frame); | 194 ASSERT(frame); |
| 195 v8::Local<v8::Context> context = frame->script()->currentWorldContext(); | 195 v8::Local<v8::Context> context = frame->script().currentWorldContext(); |
| 196 if (context.IsEmpty()) | 196 if (context.IsEmpty()) |
| 197 return; | 197 return; |
| 198 | 198 |
| 199 v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event(info.GetIso
late()); | 199 v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event(info.GetIso
late()); |
| 200 context->Global()->SetHiddenValue(eventSymbol, value); | 200 context->Global()->SetHiddenValue(eventSymbol, value); |
| 201 } | 201 } |
| 202 | 202 |
| 203 void V8Window::openerAttributeSetterCustom(v8::Local<v8::String> name, v8::Local
<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) | 203 void V8Window::openerAttributeSetterCustom(v8::Local<v8::String> name, v8::Local
<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) |
| 204 { | 204 { |
| 205 DOMWindow* imp = V8Window::toNative(info.Holder()); | 205 DOMWindow* imp = V8Window::toNative(info.Holder()); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 void dialogCreated(DOMWindow*); | 302 void dialogCreated(DOMWindow*); |
| 303 v8::Handle<v8::Value> returnValue(v8::Isolate*) const; | 303 v8::Handle<v8::Value> returnValue(v8::Isolate*) const; |
| 304 | 304 |
| 305 private: | 305 private: |
| 306 v8::Handle<v8::Value> m_dialogArguments; | 306 v8::Handle<v8::Value> m_dialogArguments; |
| 307 v8::Handle<v8::Context> m_dialogContext; | 307 v8::Handle<v8::Context> m_dialogContext; |
| 308 }; | 308 }; |
| 309 | 309 |
| 310 inline void DialogHandler::dialogCreated(DOMWindow* dialogFrame) | 310 inline void DialogHandler::dialogCreated(DOMWindow* dialogFrame) |
| 311 { | 311 { |
| 312 m_dialogContext = dialogFrame->frame() ? dialogFrame->frame()->script()->cur
rentWorldContext() : v8::Local<v8::Context>(); | 312 m_dialogContext = dialogFrame->frame() ? dialogFrame->frame()->script().curr
entWorldContext() : v8::Local<v8::Context>(); |
| 313 if (m_dialogContext.IsEmpty()) | 313 if (m_dialogContext.IsEmpty()) |
| 314 return; | 314 return; |
| 315 if (m_dialogArguments.IsEmpty()) | 315 if (m_dialogArguments.IsEmpty()) |
| 316 return; | 316 return; |
| 317 v8::Context::Scope scope(m_dialogContext); | 317 v8::Context::Scope scope(m_dialogContext); |
| 318 m_dialogContext->Global()->Set(v8::String::NewSymbol("dialogArguments"), m_d
ialogArguments); | 318 m_dialogContext->Global()->Set(v8::String::NewSymbol("dialogArguments"), m_d
ialogArguments); |
| 319 } | 319 } |
| 320 | 320 |
| 321 inline v8::Handle<v8::Value> DialogHandler::returnValue(v8::Isolate* isolate) co
nst | 321 inline v8::Handle<v8::Value> DialogHandler::returnValue(v8::Isolate* isolate) co
nst |
| 322 { | 322 { |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 // necessarily the first global object associated with that DOMWindow. | 528 // necessarily the first global object associated with that DOMWindow. |
| 529 v8::Handle<v8::Context> currentContext = v8::Context::GetCurrent(); | 529 v8::Handle<v8::Context> currentContext = v8::Context::GetCurrent(); |
| 530 v8::Handle<v8::Object> currentGlobal = currentContext->Global(); | 530 v8::Handle<v8::Object> currentGlobal = currentContext->Global(); |
| 531 v8::Handle<v8::Object> windowWrapper = currentGlobal->FindInstanceInPrototyp
eChain(V8Window::GetTemplate(isolate, worldTypeInMainThread(isolate))); | 531 v8::Handle<v8::Object> windowWrapper = currentGlobal->FindInstanceInPrototyp
eChain(V8Window::GetTemplate(isolate, worldTypeInMainThread(isolate))); |
| 532 if (!windowWrapper.IsEmpty()) { | 532 if (!windowWrapper.IsEmpty()) { |
| 533 if (V8Window::toNative(windowWrapper) == window) | 533 if (V8Window::toNative(windowWrapper) == window) |
| 534 return currentGlobal; | 534 return currentGlobal; |
| 535 } | 535 } |
| 536 | 536 |
| 537 // Otherwise, return the global object associated with this frame. | 537 // Otherwise, return the global object associated with this frame. |
| 538 v8::Handle<v8::Context> context = frame->script()->currentWorldContext(); | 538 v8::Handle<v8::Context> context = frame->script().currentWorldContext(); |
| 539 if (context.IsEmpty()) | 539 if (context.IsEmpty()) |
| 540 return v8Undefined(); | 540 return v8Undefined(); |
| 541 | 541 |
| 542 v8::Handle<v8::Object> global = context->Global(); | 542 v8::Handle<v8::Object> global = context->Global(); |
| 543 ASSERT(!global.IsEmpty()); | 543 ASSERT(!global.IsEmpty()); |
| 544 return global; | 544 return global; |
| 545 } | 545 } |
| 546 | 546 |
| 547 } // namespace WebCore | 547 } // namespace WebCore |
| OLD | NEW |