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 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 } | 718 } |
719 | 719 |
720 DOMWindow* toDOMWindow(v8::Local<v8::Context> context) { | 720 DOMWindow* toDOMWindow(v8::Local<v8::Context> context) { |
721 if (context.IsEmpty()) | 721 if (context.IsEmpty()) |
722 return 0; | 722 return 0; |
723 return toDOMWindow(context->GetIsolate(), context->Global()); | 723 return toDOMWindow(context->GetIsolate(), context->Global()); |
724 } | 724 } |
725 | 725 |
726 LocalDOMWindow* enteredDOMWindow(v8::Isolate* isolate) { | 726 LocalDOMWindow* enteredDOMWindow(v8::Isolate* isolate) { |
727 LocalDOMWindow* window = | 727 LocalDOMWindow* window = |
728 toLocalDOMWindow(toDOMWindow(isolate->GetEnteredContext())); | |
729 if (!window) { | |
730 // We don't always have an entered DOM window, for example during microtask | |
731 // callbacks from V8 (where the entered context may be the DOM-in-JS | |
732 // context). In that case, we fall back to the current context. | |
733 // | |
734 // TODO(haraken): It's nasty to return a current window from | |
735 // enteredDOMWindow. All call sites should be updated so that it works even | |
736 // if it doesn't have an entered window. Consider using | |
737 // enteredOrMicrotaskDOMWindow everywhere. | |
738 window = currentDOMWindow(isolate); | |
739 ASSERT(window); | |
740 } | |
741 return window; | |
742 } | |
743 | |
744 LocalDOMWindow* enteredOrMicrotaskDOMWindow(v8::Isolate* isolate) { | |
745 LocalDOMWindow* window = | |
746 toLocalDOMWindow(toDOMWindow(isolate->GetEnteredOrMicrotaskContext())); | 728 toLocalDOMWindow(toDOMWindow(isolate->GetEnteredOrMicrotaskContext())); |
747 DCHECK(window); | 729 DCHECK(window); |
748 return window; | 730 return window; |
749 } | 731 } |
750 | 732 |
751 LocalDOMWindow* currentDOMWindow(v8::Isolate* isolate) { | 733 LocalDOMWindow* currentDOMWindow(v8::Isolate* isolate) { |
752 return toLocalDOMWindow(toDOMWindow(isolate->GetCurrentContext())); | 734 return toLocalDOMWindow(toDOMWindow(isolate->GetCurrentContext())); |
753 } | 735 } |
754 | 736 |
755 ExecutionContext* toExecutionContext(v8::Local<v8::Context> context) { | 737 ExecutionContext* toExecutionContext(v8::Local<v8::Context> context) { |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 if (!v8Call(v8::JSON::Parse(isolate, v8String(isolate, stringifiedJSON)), | 971 if (!v8Call(v8::JSON::Parse(isolate, v8String(isolate, stringifiedJSON)), |
990 parsed, tryCatch)) { | 972 parsed, tryCatch)) { |
991 if (tryCatch.HasCaught()) | 973 if (tryCatch.HasCaught()) |
992 exceptionState.rethrowV8Exception(tryCatch.Exception()); | 974 exceptionState.rethrowV8Exception(tryCatch.Exception()); |
993 } | 975 } |
994 | 976 |
995 return parsed; | 977 return parsed; |
996 } | 978 } |
997 | 979 |
998 } // namespace blink | 980 } // namespace blink |
OLD | NEW |