OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 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 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 PassRefPtrWillBeRawPtr<XPathNSResolver> toXPathNSResolver(v8::Handle<v8::Value>
value, v8::Isolate* isolate) | 641 PassRefPtrWillBeRawPtr<XPathNSResolver> toXPathNSResolver(v8::Handle<v8::Value>
value, v8::Isolate* isolate) |
642 { | 642 { |
643 RefPtrWillBeRawPtr<XPathNSResolver> resolver = nullptr; | 643 RefPtrWillBeRawPtr<XPathNSResolver> resolver = nullptr; |
644 if (V8XPathNSResolver::hasInstance(value, isolate)) | 644 if (V8XPathNSResolver::hasInstance(value, isolate)) |
645 resolver = V8XPathNSResolver::toNative(v8::Handle<v8::Object>::Cast(valu
e)); | 645 resolver = V8XPathNSResolver::toNative(v8::Handle<v8::Object>::Cast(valu
e)); |
646 else if (value->IsObject()) | 646 else if (value->IsObject()) |
647 resolver = V8CustomXPathNSResolver::create(value->ToObject(), isolate); | 647 resolver = V8CustomXPathNSResolver::create(value->ToObject(), isolate); |
648 return resolver; | 648 return resolver; |
649 } | 649 } |
650 | 650 |
651 DOMWindow* toDOMWindow(v8::Handle<v8::Value> value, v8::Isolate* isolate) | 651 LocalDOMWindow* toDOMWindow(v8::Handle<v8::Value> value, v8::Isolate* isolate) |
652 { | 652 { |
653 if (value.IsEmpty() || !value->IsObject()) | 653 if (value.IsEmpty() || !value->IsObject()) |
654 return 0; | 654 return 0; |
655 | 655 |
656 v8::Handle<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChai
n(v8::Handle<v8::Object>::Cast(value), isolate); | 656 v8::Handle<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChai
n(v8::Handle<v8::Object>::Cast(value), isolate); |
657 if (!windowWrapper.IsEmpty()) | 657 if (!windowWrapper.IsEmpty()) |
658 return V8Window::toNative(windowWrapper); | 658 return V8Window::toNative(windowWrapper); |
659 return 0; | 659 return 0; |
660 } | 660 } |
661 | 661 |
662 DOMWindow* toDOMWindow(v8::Handle<v8::Context> context) | 662 LocalDOMWindow* toDOMWindow(v8::Handle<v8::Context> context) |
663 { | 663 { |
664 if (context.IsEmpty()) | 664 if (context.IsEmpty()) |
665 return 0; | 665 return 0; |
666 return toDOMWindow(context->Global(), context->GetIsolate()); | 666 return toDOMWindow(context->Global(), context->GetIsolate()); |
667 } | 667 } |
668 | 668 |
669 DOMWindow* enteredDOMWindow(v8::Isolate* isolate) | 669 LocalDOMWindow* enteredDOMWindow(v8::Isolate* isolate) |
670 { | 670 { |
671 DOMWindow* window = toDOMWindow(isolate->GetEnteredContext()); | 671 LocalDOMWindow* window = toDOMWindow(isolate->GetEnteredContext()); |
672 if (!window) { | 672 if (!window) { |
673 // We don't always have an entered DOM window, for example during microt
ask callbacks from V8 | 673 // We don't always have an entered DOM window, for example during microt
ask callbacks from V8 |
674 // (where the entered context may be the DOM-in-JS context). In that cas
e, we fall back | 674 // (where the entered context may be the DOM-in-JS context). In that cas
e, we fall back |
675 // to the current context. | 675 // to the current context. |
676 window = currentDOMWindow(isolate); | 676 window = currentDOMWindow(isolate); |
677 ASSERT(window); | 677 ASSERT(window); |
678 } | 678 } |
679 return window; | 679 return window; |
680 } | 680 } |
681 | 681 |
682 DOMWindow* currentDOMWindow(v8::Isolate* isolate) | 682 LocalDOMWindow* currentDOMWindow(v8::Isolate* isolate) |
683 { | 683 { |
684 return toDOMWindow(isolate->GetCurrentContext()); | 684 return toDOMWindow(isolate->GetCurrentContext()); |
685 } | 685 } |
686 | 686 |
687 DOMWindow* callingDOMWindow(v8::Isolate* isolate) | 687 LocalDOMWindow* callingDOMWindow(v8::Isolate* isolate) |
688 { | 688 { |
689 v8::Handle<v8::Context> context = isolate->GetCallingContext(); | 689 v8::Handle<v8::Context> context = isolate->GetCallingContext(); |
690 if (context.IsEmpty()) { | 690 if (context.IsEmpty()) { |
691 // Unfortunately, when processing script from a plug-in, we might not | 691 // Unfortunately, when processing script from a plug-in, we might not |
692 // have a calling context. In those cases, we fall back to the | 692 // have a calling context. In those cases, we fall back to the |
693 // entered context. | 693 // entered context. |
694 context = isolate->GetEnteredContext(); | 694 context = isolate->GetEnteredContext(); |
695 } | 695 } |
696 return toDOMWindow(context); | 696 return toDOMWindow(context); |
697 } | 697 } |
(...skipping 23 matching lines...) Expand all Loading... |
721 // Unfortunately, when processing script from a plug-in, we might not | 721 // Unfortunately, when processing script from a plug-in, we might not |
722 // have a calling context. In those cases, we fall back to the | 722 // have a calling context. In those cases, we fall back to the |
723 // entered context. | 723 // entered context. |
724 context = isolate->GetEnteredContext(); | 724 context = isolate->GetEnteredContext(); |
725 } | 725 } |
726 return toExecutionContext(context); | 726 return toExecutionContext(context); |
727 } | 727 } |
728 | 728 |
729 LocalFrame* toFrameIfNotDetached(v8::Handle<v8::Context> context) | 729 LocalFrame* toFrameIfNotDetached(v8::Handle<v8::Context> context) |
730 { | 730 { |
731 DOMWindow* window = toDOMWindow(context); | 731 LocalDOMWindow* window = toDOMWindow(context); |
732 if (window && window->isCurrentlyDisplayedInFrame()) | 732 if (window && window->isCurrentlyDisplayedInFrame()) |
733 return window->frame(); | 733 return window->frame(); |
734 // We return 0 here because |context| is detached from the LocalFrame. If we | 734 // We return 0 here because |context| is detached from the LocalFrame. If we |
735 // did return |frame| we could get in trouble because the frame could be | 735 // did return |frame| we could get in trouble because the frame could be |
736 // navigated to another security origin. | 736 // navigated to another security origin. |
737 return 0; | 737 return 0; |
738 } | 738 } |
739 | 739 |
740 v8::Local<v8::Context> toV8Context(ExecutionContext* context, DOMWrapperWorld& w
orld) | 740 v8::Local<v8::Context> toV8Context(ExecutionContext* context, DOMWrapperWorld& w
orld) |
741 { | 741 { |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(Executio
nContext* context, v8::Handle<v8::Function> function, v8::Isolate* isolate) | 931 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(Executio
nContext* context, v8::Handle<v8::Function> function, v8::Isolate* isolate) |
932 { | 932 { |
933 int scriptId = 0; | 933 int scriptId = 0; |
934 String resourceName; | 934 String resourceName; |
935 int lineNumber = 1; | 935 int lineNumber = 1; |
936 GetDevToolsFunctionInfo(function, isolate, scriptId, resourceName, lineNumbe
r); | 936 GetDevToolsFunctionInfo(function, isolate, scriptId, resourceName, lineNumbe
r); |
937 return InspectorFunctionCallEvent::data(context, scriptId, resourceName, lin
eNumber); | 937 return InspectorFunctionCallEvent::data(context, scriptId, resourceName, lin
eNumber); |
938 } | 938 } |
939 | 939 |
940 } // namespace WebCore | 940 } // namespace WebCore |
OLD | NEW |