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 13 matching lines...) Expand all Loading... | |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "V8Window.h" | 32 #include "V8Window.h" |
33 | 33 |
34 #include "RuntimeEnabledFeatures.h" | |
34 #include "V8HTMLCollection.h" | 35 #include "V8HTMLCollection.h" |
35 #include "V8Node.h" | 36 #include "V8Node.h" |
36 #include "bindings/v8/BindingSecurity.h" | 37 #include "bindings/v8/BindingSecurity.h" |
37 #include "bindings/v8/ExceptionMessages.h" | 38 #include "bindings/v8/ExceptionMessages.h" |
38 #include "bindings/v8/ExceptionState.h" | 39 #include "bindings/v8/ExceptionState.h" |
39 #include "bindings/v8/ScheduledAction.h" | 40 #include "bindings/v8/ScheduledAction.h" |
40 #include "bindings/v8/ScriptController.h" | 41 #include "bindings/v8/ScriptController.h" |
41 #include "bindings/v8/ScriptSourceCode.h" | 42 #include "bindings/v8/ScriptSourceCode.h" |
42 #include "bindings/v8/SerializedScriptValue.h" | 43 #include "bindings/v8/SerializedScriptValue.h" |
43 #include "bindings/v8/V8Binding.h" | 44 #include "bindings/v8/V8Binding.h" |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
379 } | 380 } |
380 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullChe ck>, windowFeaturesString, info[2]); | 381 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullChe ck>, windowFeaturesString, info[2]); |
381 | 382 |
382 RefPtr<DOMWindow> openedWindow = impl->open(urlString, frameName, windowFeat uresString, activeDOMWindow(), firstDOMWindow()); | 383 RefPtr<DOMWindow> openedWindow = impl->open(urlString, frameName, windowFeat uresString, activeDOMWindow(), firstDOMWindow()); |
383 if (!openedWindow) | 384 if (!openedWindow) |
384 return; | 385 return; |
385 | 386 |
386 v8SetReturnValueFast(info, openedWindow.release(), impl); | 387 v8SetReturnValueFast(info, openedWindow.release(), impl); |
387 } | 388 } |
388 | 389 |
390 void V8Window::scrollByMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& i nfo) | |
haraken
2014/01/27 01:44:13
Ditto. Can't you avoid writing custom bindings by
ajuma
2014/01/27 02:07:00
The problem is that specifying that a particular a
haraken
2014/01/27 02:30:48
Probably we want to improve code_generator_v8.pm s
Nils Barth (inactive)
2014/01/27 05:23:45
Ow! (>.<)
That's in principle possible, but would
| |
391 { | |
392 ExceptionState exceptionState(ExceptionState::ExecutionContext, "scrollBy", "Window", info.Holder(), info.GetIsolate()); | |
393 if (UNLIKELY(info.Length() < 2)) { | |
394 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length())); | |
395 exceptionState.throwIfNeeded(); | |
396 return; | |
397 } | |
398 DOMWindow* impl = V8Window::toNative(info.Holder()); | |
399 if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame(), exceptionState )) { | |
400 exceptionState.throwIfNeeded(); | |
401 return; | |
402 } | |
403 V8TRYCATCH_EXCEPTION_VOID(int, x, toInt32(info[0], exceptionState), exceptio nState); | |
404 V8TRYCATCH_EXCEPTION_VOID(int, y, toInt32(info[1], exceptionState), exceptio nState); | |
405 | |
406 if (info.Length() >= 3 && RuntimeEnabledFeatures::cssomSmoothScrollEnabled() ) { | |
407 V8TRYCATCH_VOID(Dictionary, scrollOptions, Dictionary(info[2], info.GetI solate())); | |
408 impl->scrollBy(x, y, scrollOptions, exceptionState); | |
409 } else { | |
410 impl->scrollBy(x, y, Dictionary(), exceptionState); | |
411 } | |
412 exceptionState.throwIfNeeded(); | |
413 } | |
414 | |
415 void V8Window::scrollToMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& i nfo) | |
416 { | |
417 ExceptionState exceptionState(ExceptionState::ExecutionContext, "scrollTo", "Window", info.Holder(), info.GetIsolate()); | |
418 if (UNLIKELY(info.Length() < 2)) { | |
419 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length())); | |
420 exceptionState.throwIfNeeded(); | |
421 return; | |
422 } | |
423 DOMWindow* impl = V8Window::toNative(info.Holder()); | |
424 if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame(), exceptionState )) { | |
425 exceptionState.throwIfNeeded(); | |
426 return; | |
427 } | |
428 V8TRYCATCH_EXCEPTION_VOID(int, x, toInt32(info[0], exceptionState), exceptio nState); | |
429 V8TRYCATCH_EXCEPTION_VOID(int, y, toInt32(info[1], exceptionState), exceptio nState); | |
430 | |
431 if (info.Length() >= 3 && RuntimeEnabledFeatures::cssomSmoothScrollEnabled() ) { | |
432 V8TRYCATCH_VOID(Dictionary, scrollOptions, Dictionary(info[2], info.GetI solate())); | |
433 impl->scrollTo(x, y, scrollOptions, exceptionState); | |
434 } else { | |
435 impl->scrollTo(x, y, Dictionary(), exceptionState); | |
436 } | |
437 exceptionState.throwIfNeeded(); | |
438 } | |
439 | |
440 void V8Window::scrollMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& inf o) | |
441 { | |
442 ExceptionState exceptionState(ExceptionState::ExecutionContext, "scroll", "W indow", info.Holder(), info.GetIsolate()); | |
443 if (UNLIKELY(info.Length() < 2)) { | |
444 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length())); | |
445 exceptionState.throwIfNeeded(); | |
446 return; | |
447 } | |
448 DOMWindow* impl = V8Window::toNative(info.Holder()); | |
449 if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame(), exceptionState )) { | |
450 exceptionState.throwIfNeeded(); | |
451 return; | |
452 } | |
453 V8TRYCATCH_EXCEPTION_VOID(int, x, toInt32(info[0], exceptionState), exceptio nState); | |
454 V8TRYCATCH_EXCEPTION_VOID(int, y, toInt32(info[1], exceptionState), exceptio nState); | |
455 | |
456 if (info.Length() >= 3 && RuntimeEnabledFeatures::cssomSmoothScrollEnabled() ) { | |
457 V8TRYCATCH_VOID(Dictionary, scrollOptions, Dictionary(info[2], info.GetI solate())); | |
458 impl->scroll(x, y, scrollOptions, exceptionState); | |
459 } else { | |
460 impl->scroll(x, y, Dictionary(), exceptionState); | |
461 } | |
462 exceptionState.throwIfNeeded(); | |
463 } | |
464 | |
389 void V8Window::namedPropertyGetterCustom(v8::Local<v8::String> name, const v8::P ropertyCallbackInfo<v8::Value>& info) | 465 void V8Window::namedPropertyGetterCustom(v8::Local<v8::String> name, const v8::P ropertyCallbackInfo<v8::Value>& info) |
390 { | 466 { |
391 | 467 |
392 DOMWindow* window = V8Window::toNative(info.Holder()); | 468 DOMWindow* window = V8Window::toNative(info.Holder()); |
393 if (!window) | 469 if (!window) |
394 return; | 470 return; |
395 | 471 |
396 Frame* frame = window->frame(); | 472 Frame* frame = window->frame(); |
397 // window is detached from a frame. | 473 // window is detached from a frame. |
398 if (!frame) | 474 if (!frame) |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
550 v8::Handle<v8::Context> context = frame->script().currentWorldContextOrMainW orldContext(); | 626 v8::Handle<v8::Context> context = frame->script().currentWorldContextOrMainW orldContext(); |
551 if (context.IsEmpty()) | 627 if (context.IsEmpty()) |
552 return v8Undefined(); | 628 return v8Undefined(); |
553 | 629 |
554 v8::Handle<v8::Object> global = context->Global(); | 630 v8::Handle<v8::Object> global = context->Global(); |
555 ASSERT(!global.IsEmpty()); | 631 ASSERT(!global.IsEmpty()); |
556 return global; | 632 return global; |
557 } | 633 } |
558 | 634 |
559 } // namespace WebCore | 635 } // namespace WebCore |
OLD | NEW |