Chromium Code Reviews| 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 30 matching lines...) Expand all Loading... | |
| 41 #include "bindings/core/v8/V8Window.h" | 41 #include "bindings/core/v8/V8Window.h" |
| 42 #include "bindings/core/v8/V8WorkerGlobalScope.h" | 42 #include "bindings/core/v8/V8WorkerGlobalScope.h" |
| 43 #include "bindings/core/v8/V8XPathNSResolver.h" | 43 #include "bindings/core/v8/V8XPathNSResolver.h" |
| 44 #include "bindings/core/v8/WindowProxy.h" | 44 #include "bindings/core/v8/WindowProxy.h" |
| 45 #include "bindings/core/v8/WorkerScriptController.h" | 45 #include "bindings/core/v8/WorkerScriptController.h" |
| 46 #include "bindings/core/v8/custom/V8CustomXPathNSResolver.h" | 46 #include "bindings/core/v8/custom/V8CustomXPathNSResolver.h" |
| 47 #include "core/dom/Document.h" | 47 #include "core/dom/Document.h" |
| 48 #include "core/dom/Element.h" | 48 #include "core/dom/Element.h" |
| 49 #include "core/dom/NodeFilter.h" | 49 #include "core/dom/NodeFilter.h" |
| 50 #include "core/dom/QualifiedName.h" | 50 #include "core/dom/QualifiedName.h" |
| 51 #include "core/frame/LocalDOMWindow.h" | |
| 51 #include "core/frame/LocalFrame.h" | 52 #include "core/frame/LocalFrame.h" |
| 52 #include "core/frame/Settings.h" | 53 #include "core/frame/Settings.h" |
| 53 #include "core/inspector/BindingVisitors.h" | 54 #include "core/inspector/BindingVisitors.h" |
| 54 #include "core/inspector/InspectorTraceEvents.h" | 55 #include "core/inspector/InspectorTraceEvents.h" |
| 55 #include "core/loader/FrameLoader.h" | 56 #include "core/loader/FrameLoader.h" |
| 56 #include "core/loader/FrameLoaderClient.h" | 57 #include "core/loader/FrameLoaderClient.h" |
| 57 #include "core/workers/WorkerGlobalScope.h" | 58 #include "core/workers/WorkerGlobalScope.h" |
| 58 #include "core/xml/XPathNSResolver.h" | 59 #include "core/xml/XPathNSResolver.h" |
| 59 #include "platform/EventTracer.h" | 60 #include "platform/EventTracer.h" |
| 60 #include "platform/JSONValues.h" | 61 #include "platform/JSONValues.h" |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 688 PassRefPtrWillBeRawPtr<XPathNSResolver> toXPathNSResolver(v8::Isolate* isolate, v8::Handle<v8::Value> value) | 689 PassRefPtrWillBeRawPtr<XPathNSResolver> toXPathNSResolver(v8::Isolate* isolate, v8::Handle<v8::Value> value) |
| 689 { | 690 { |
| 690 RefPtrWillBeRawPtr<XPathNSResolver> resolver = nullptr; | 691 RefPtrWillBeRawPtr<XPathNSResolver> resolver = nullptr; |
| 691 if (V8XPathNSResolver::hasInstance(value, isolate)) | 692 if (V8XPathNSResolver::hasInstance(value, isolate)) |
| 692 resolver = V8XPathNSResolver::toImpl(v8::Handle<v8::Object>::Cast(value) ); | 693 resolver = V8XPathNSResolver::toImpl(v8::Handle<v8::Object>::Cast(value) ); |
| 693 else if (value->IsObject()) | 694 else if (value->IsObject()) |
| 694 resolver = V8CustomXPathNSResolver::create(value->ToObject(), isolate); | 695 resolver = V8CustomXPathNSResolver::create(value->ToObject(), isolate); |
| 695 return resolver; | 696 return resolver; |
| 696 } | 697 } |
| 697 | 698 |
| 698 LocalDOMWindow* toDOMWindow(v8::Handle<v8::Value> value, v8::Isolate* isolate) | 699 DOMWindow* toDOMWindow(v8::Handle<v8::Value> value, v8::Isolate* isolate) |
| 699 { | 700 { |
| 700 if (value.IsEmpty() || !value->IsObject()) | 701 if (value.IsEmpty() || !value->IsObject()) |
| 701 return 0; | 702 return 0; |
| 702 | 703 |
| 703 v8::Handle<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChai n(v8::Handle<v8::Object>::Cast(value), isolate); | 704 v8::Handle<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChai n(v8::Handle<v8::Object>::Cast(value), isolate); |
| 704 if (!windowWrapper.IsEmpty()) | 705 if (!windowWrapper.IsEmpty()) |
| 705 return V8Window::toImpl(windowWrapper); | 706 return V8Window::toImpl(windowWrapper); |
| 706 return 0; | 707 return 0; |
| 707 } | 708 } |
| 708 | 709 |
| 709 LocalDOMWindow* toDOMWindow(v8::Handle<v8::Context> context) | 710 DOMWindow* toDOMWindow(v8::Handle<v8::Context> context) |
| 710 { | 711 { |
| 711 if (context.IsEmpty()) | 712 if (context.IsEmpty()) |
| 712 return 0; | 713 return 0; |
| 713 return toDOMWindow(context->Global(), context->GetIsolate()); | 714 return toDOMWindow(context->Global(), context->GetIsolate()); |
| 714 } | 715 } |
| 715 | 716 |
| 716 LocalDOMWindow* enteredDOMWindow(v8::Isolate* isolate) | 717 LocalDOMWindow* enteredDOMWindow(v8::Isolate* isolate) |
|
haraken
2014/10/31 06:07:04
Rename this to enteredLocalDOMWindow in a follow-u
| |
| 717 { | 718 { |
| 718 LocalDOMWindow* window = toDOMWindow(isolate->GetEnteredContext()); | 719 LocalDOMWindow* window = toLocalDOMWindow(toDOMWindow(isolate->GetEnteredCon text())); |
| 719 if (!window) { | 720 if (!window) { |
| 720 // We don't always have an entered DOM window, for example during microt ask callbacks from V8 | 721 // We don't always have an entered DOM window, for example during microt ask callbacks from V8 |
| 721 // (where the entered context may be the DOM-in-JS context). In that cas e, we fall back | 722 // (where the entered context may be the DOM-in-JS context). In that cas e, we fall back |
| 722 // to the current context. | 723 // to the current context. |
| 723 window = currentDOMWindow(isolate); | 724 window = currentDOMWindow(isolate); |
| 724 ASSERT(window); | 725 ASSERT(window); |
| 725 } | 726 } |
| 726 return window; | 727 return window; |
| 727 } | 728 } |
| 728 | 729 |
| 729 LocalDOMWindow* currentDOMWindow(v8::Isolate* isolate) | 730 LocalDOMWindow* currentDOMWindow(v8::Isolate* isolate) |
|
haraken
2014/10/31 06:07:04
currentLocalDOMWindow
| |
| 730 { | 731 { |
| 731 return toDOMWindow(isolate->GetCurrentContext()); | 732 return toLocalDOMWindow(toDOMWindow(isolate->GetCurrentContext())); |
| 732 } | 733 } |
| 733 | 734 |
| 734 LocalDOMWindow* callingDOMWindow(v8::Isolate* isolate) | 735 LocalDOMWindow* callingDOMWindow(v8::Isolate* isolate) |
|
haraken
2014/10/31 06:07:04
callingLocalDOMWindow
| |
| 735 { | 736 { |
| 736 v8::Handle<v8::Context> context = isolate->GetCallingContext(); | 737 v8::Handle<v8::Context> context = isolate->GetCallingContext(); |
| 737 if (context.IsEmpty()) { | 738 if (context.IsEmpty()) { |
| 738 // Unfortunately, when processing script from a plug-in, we might not | 739 // Unfortunately, when processing script from a plug-in, we might not |
| 739 // have a calling context. In those cases, we fall back to the | 740 // have a calling context. In those cases, we fall back to the |
| 740 // entered context. | 741 // entered context. |
| 741 context = isolate->GetEnteredContext(); | 742 context = isolate->GetEnteredContext(); |
| 742 } | 743 } |
| 743 return toDOMWindow(context); | 744 return toLocalDOMWindow(toDOMWindow(context)); |
| 744 } | 745 } |
| 745 | 746 |
| 746 ExecutionContext* toExecutionContext(v8::Handle<v8::Context> context) | 747 ExecutionContext* toExecutionContext(v8::Handle<v8::Context> context) |
| 747 { | 748 { |
| 748 if (context.IsEmpty()) | 749 if (context.IsEmpty()) |
| 749 return 0; | 750 return 0; |
| 750 v8::Handle<v8::Object> global = context->Global(); | 751 v8::Handle<v8::Object> global = context->Global(); |
| 751 v8::Handle<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChai n(global, context->GetIsolate()); | 752 v8::Handle<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChai n(global, context->GetIsolate()); |
| 752 if (!windowWrapper.IsEmpty()) | 753 if (!windowWrapper.IsEmpty()) |
| 753 return V8Window::toImpl(windowWrapper)->executionContext(); | 754 return V8Window::toImpl(windowWrapper)->executionContext(); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 770 // Unfortunately, when processing script from a plug-in, we might not | 771 // Unfortunately, when processing script from a plug-in, we might not |
| 771 // have a calling context. In those cases, we fall back to the | 772 // have a calling context. In those cases, we fall back to the |
| 772 // entered context. | 773 // entered context. |
| 773 context = isolate->GetEnteredContext(); | 774 context = isolate->GetEnteredContext(); |
| 774 } | 775 } |
| 775 return toExecutionContext(context); | 776 return toExecutionContext(context); |
| 776 } | 777 } |
| 777 | 778 |
| 778 LocalFrame* toFrameIfNotDetached(v8::Handle<v8::Context> context) | 779 LocalFrame* toFrameIfNotDetached(v8::Handle<v8::Context> context) |
| 779 { | 780 { |
| 780 LocalDOMWindow* window = toDOMWindow(context); | 781 LocalDOMWindow* window = toLocalDOMWindow(toDOMWindow(context)); |
| 781 if (window && window->isCurrentlyDisplayedInFrame()) | 782 if (window && window->isCurrentlyDisplayedInFrame()) |
| 782 return window->frame(); | 783 return window->frame(); |
| 783 // We return 0 here because |context| is detached from the LocalFrame. If we | 784 // We return 0 here because |context| is detached from the LocalFrame. If we |
| 784 // did return |frame| we could get in trouble because the frame could be | 785 // did return |frame| we could get in trouble because the frame could be |
| 785 // navigated to another security origin. | 786 // navigated to another security origin. |
| 786 return 0; | 787 return 0; |
| 787 } | 788 } |
| 788 | 789 |
| 789 v8::Local<v8::Context> toV8Context(ExecutionContext* context, DOMWrapperWorld& w orld) | 790 v8::Local<v8::Context> toV8Context(ExecutionContext* context, DOMWrapperWorld& w orld) |
| 790 { | 791 { |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 993 | 994 |
| 994 v8::Local<v8::Value> v8IteratorResult(v8::Isolate* isolate, v8::Handle<v8::Value > value) | 995 v8::Local<v8::Value> v8IteratorResult(v8::Isolate* isolate, v8::Handle<v8::Value > value) |
| 995 { | 996 { |
| 996 v8::Local<v8::Object> result = v8::Object::New(isolate); | 997 v8::Local<v8::Object> result = v8::Object::New(isolate); |
| 997 result->Set(v8String(isolate, "value"), value); | 998 result->Set(v8String(isolate, "value"), value); |
| 998 result->Set(v8String(isolate, "done"), v8Boolean(false, isolate)); | 999 result->Set(v8String(isolate, "done"), v8Boolean(false, isolate)); |
| 999 return result; | 1000 return result; |
| 1000 } | 1001 } |
| 1001 | 1002 |
| 1002 } // namespace blink | 1003 } // namespace blink |
| OLD | NEW |