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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 DOMWindow* imp = V8Window::toNative(info.Holder()); | 84 DOMWindow* imp = V8Window::toNative(info.Holder()); |
85 if (!imp->document()) { | 85 if (!imp->document()) { |
86 exceptionState.throwDOMException(InvalidAccessError, "No script context
is available in which to execute the script."); | 86 exceptionState.throwDOMException(InvalidAccessError, "No script context
is available in which to execute the script."); |
87 return; | 87 return; |
88 } | 88 } |
89 | 89 |
90 v8::Handle<v8::Value> function = info[0]; | 90 v8::Handle<v8::Value> function = info[0]; |
91 String functionString; | 91 String functionString; |
92 if (!function->IsFunction()) { | 92 if (!function->IsFunction()) { |
93 if (function->IsString()) { | 93 if (function->IsString()) { |
94 functionString = toWebCoreString(function.As<v8::String>()); | 94 functionString = toCoreString(function.As<v8::String>()); |
95 } else { | 95 } else { |
96 v8::Handle<v8::String> v8String = function->ToString(); | 96 v8::Handle<v8::String> v8String = function->ToString(); |
97 | 97 |
98 // Bail out if string conversion failed. | 98 // Bail out if string conversion failed. |
99 if (v8String.IsEmpty()) | 99 if (v8String.IsEmpty()) |
100 return; | 100 return; |
101 | 101 |
102 functionString = toWebCoreString(v8String); | 102 functionString = toCoreString(v8String); |
103 } | 103 } |
104 | 104 |
105 // Don't allow setting timeouts to run empty functions! | 105 // Don't allow setting timeouts to run empty functions! |
106 // (Bug 1009597) | 106 // (Bug 1009597) |
107 if (!functionString.length()) | 107 if (!functionString.length()) |
108 return; | 108 return; |
109 } | 109 } |
110 | 110 |
111 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState)
) | 111 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState)
) |
112 return; | 112 return; |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 void V8Window::showModalDialogMethodCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) | 358 void V8Window::showModalDialogMethodCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) |
359 { | 359 { |
360 DOMWindow* impl = V8Window::toNative(info.Holder()); | 360 DOMWindow* impl = V8Window::toNative(info.Holder()); |
361 ExceptionState exceptionState(ExceptionState::ExecutionContext, "showModalDi
alog", "Window", info.Holder(), info.GetIsolate()); | 361 ExceptionState exceptionState(ExceptionState::ExecutionContext, "showModalDi
alog", "Window", info.Holder(), info.GetIsolate()); |
362 if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame(), exceptionState
)) { | 362 if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame(), exceptionState
)) { |
363 exceptionState.throwIfNeeded(); | 363 exceptionState.throwIfNeeded(); |
364 return; | 364 return; |
365 } | 365 } |
366 | 366 |
367 // FIXME: Handle exceptions properly. | 367 // FIXME: Handle exceptions properly. |
368 String urlString = toWebCoreStringWithUndefinedOrNullCheck(info[0]); | 368 String urlString = toCoreStringWithUndefinedOrNullCheck(info[0]); |
369 DialogHandler handler(info[1]); | 369 DialogHandler handler(info[1]); |
370 String dialogFeaturesString = toWebCoreStringWithUndefinedOrNullCheck(info[2
]); | 370 String dialogFeaturesString = toCoreStringWithUndefinedOrNullCheck(info[2]); |
371 | 371 |
372 impl->showModalDialog(urlString, dialogFeaturesString, activeDOMWindow(), fi
rstDOMWindow(), setUpDialog, &handler); | 372 impl->showModalDialog(urlString, dialogFeaturesString, activeDOMWindow(), fi
rstDOMWindow(), setUpDialog, &handler); |
373 | 373 |
374 v8SetReturnValue(info, handler.returnValue(info.GetIsolate())); | 374 v8SetReturnValue(info, handler.returnValue(info.GetIsolate())); |
375 } | 375 } |
376 | 376 |
377 void V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) | 377 void V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) |
378 { | 378 { |
379 DOMWindow* impl = V8Window::toNative(info.Holder()); | 379 DOMWindow* impl = V8Window::toNative(info.Holder()); |
380 ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "Win
dow", info.Holder(), info.GetIsolate()); | 380 ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "Win
dow", info.Holder(), info.GetIsolate()); |
(...skipping 25 matching lines...) Expand all Loading... |
406 DOMWindow* window = V8Window::toNative(info.Holder()); | 406 DOMWindow* window = V8Window::toNative(info.Holder()); |
407 if (!window) | 407 if (!window) |
408 return; | 408 return; |
409 | 409 |
410 Frame* frame = window->frame(); | 410 Frame* frame = window->frame(); |
411 // window is detached from a frame. | 411 // window is detached from a frame. |
412 if (!frame) | 412 if (!frame) |
413 return; | 413 return; |
414 | 414 |
415 // Search sub-frames. | 415 // Search sub-frames. |
416 AtomicString propName = toWebCoreAtomicString(name); | 416 AtomicString propName = toCoreAtomicString(name); |
417 Frame* child = frame->tree().scopedChild(propName); | 417 Frame* child = frame->tree().scopedChild(propName); |
418 if (child) { | 418 if (child) { |
419 v8SetReturnValueFast(info, child->domWindow(), window); | 419 v8SetReturnValueFast(info, child->domWindow(), window); |
420 return; | 420 return; |
421 } | 421 } |
422 | 422 |
423 // Search IDL functions defined in the prototype | 423 // Search IDL functions defined in the prototype |
424 if (!info.Holder()->GetRealNamedProperty(name).IsEmpty()) | 424 if (!info.Holder()->GetRealNamedProperty(name).IsEmpty()) |
425 return; | 425 return; |
426 | 426 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 if (!target) | 473 if (!target) |
474 return false; | 474 return false; |
475 | 475 |
476 // Notify the loader's client if the initial document has been accessed. | 476 // Notify the loader's client if the initial document has been accessed. |
477 if (target->loader().stateMachine()->isDisplayingInitialEmptyDocument()) | 477 if (target->loader().stateMachine()->isDisplayingInitialEmptyDocument()) |
478 target->loader().didAccessInitialDocument(); | 478 target->loader().didAccessInitialDocument(); |
479 | 479 |
480 if (key->IsString()) { | 480 if (key->IsString()) { |
481 DEFINE_STATIC_LOCAL(const AtomicString, nameOfProtoProperty, ("__proto__
", AtomicString::ConstructFromLiteral)); | 481 DEFINE_STATIC_LOCAL(const AtomicString, nameOfProtoProperty, ("__proto__
", AtomicString::ConstructFromLiteral)); |
482 | 482 |
483 AtomicString name = toWebCoreAtomicString(key.As<v8::String>()); | 483 AtomicString name = toCoreAtomicString(key.As<v8::String>()); |
484 Frame* childFrame = target->tree().scopedChild(name); | 484 Frame* childFrame = target->tree().scopedChild(name); |
485 // Notice that we can't call HasRealNamedProperty for ACCESS_HAS | 485 // Notice that we can't call HasRealNamedProperty for ACCESS_HAS |
486 // because that would generate infinite recursion. | 486 // because that would generate infinite recursion. |
487 if (type == v8::ACCESS_HAS && childFrame) | 487 if (type == v8::ACCESS_HAS && childFrame) |
488 return true; | 488 return true; |
489 // We need to explicitly compare against nameOfProtoProperty because | 489 // We need to explicitly compare against nameOfProtoProperty because |
490 // V8's JSObject::LocalLookup finds __proto__ before | 490 // V8's JSObject::LocalLookup finds __proto__ before |
491 // interceptors and even when __proto__ isn't a "real named property". | 491 // interceptors and even when __proto__ isn't a "real named property". |
492 v8::Handle<v8::String> keyString = key.As<v8::String>(); | 492 v8::Handle<v8::String> keyString = key.As<v8::String>(); |
493 if (type == v8::ACCESS_GET | 493 if (type == v8::ACCESS_GET |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 v8::Handle<v8::Context> context = frame->script().currentWorldContext(); | 564 v8::Handle<v8::Context> context = frame->script().currentWorldContext(); |
565 if (context.IsEmpty()) | 565 if (context.IsEmpty()) |
566 return v8Undefined(); | 566 return v8Undefined(); |
567 | 567 |
568 v8::Handle<v8::Object> global = context->Global(); | 568 v8::Handle<v8::Object> global = context->Global(); |
569 ASSERT(!global.IsEmpty()); | 569 ASSERT(!global.IsEmpty()); |
570 return global; | 570 return global; |
571 } | 571 } |
572 | 572 |
573 } // namespace WebCore | 573 } // namespace WebCore |
OLD | NEW |