OLD | NEW |
1 // Copyright (c) 2008, Google Inc. | 1 // Copyright (c) 2008, Google Inc. |
2 // All rights reserved. | 2 // 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 1824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1835 // might get deleted and the global handle for the document | 1835 // might get deleted and the global handle for the document |
1836 // wrapper cleared. Using the cleared global handle will lead to | 1836 // wrapper cleared. Using the cleared global handle will lead to |
1837 // crashes. In this case we clear the cache and let the DOMWindow | 1837 // crashes. In this case we clear the cache and let the DOMWindow |
1838 // accessor handle access to the document. | 1838 // accessor handle access to the document. |
1839 if (!m_frame->document()->frame()) { | 1839 if (!m_frame->document()->frame()) { |
1840 ClearDocumentWrapperCache(); | 1840 ClearDocumentWrapperCache(); |
1841 return; | 1841 return; |
1842 } | 1842 } |
1843 | 1843 |
1844 v8::Handle<v8::Value> document_wrapper = NodeToV8Object(m_frame->document())
; | 1844 v8::Handle<v8::Value> document_wrapper = NodeToV8Object(m_frame->document())
; |
| 1845 |
| 1846 // If instantiation of the document wrapper fails, clear the cache |
| 1847 // and let the DOMWindow accessor handle access to the document. |
| 1848 if (document_wrapper.IsEmpty()) { |
| 1849 ClearDocumentWrapperCache(); |
| 1850 return; |
| 1851 } |
| 1852 |
1845 m_context->Global()->ForceSet(v8::String::New("document"), | 1853 m_context->Global()->ForceSet(v8::String::New("document"), |
1846 document_wrapper, | 1854 document_wrapper, |
1847 static_cast<v8::PropertyAttribute>(v8::ReadOnl
y | v8::DontDelete)); | 1855 static_cast<v8::PropertyAttribute>(v8::ReadOnl
y | v8::DontDelete)); |
1848 } | 1856 } |
1849 | 1857 |
1850 | 1858 |
1851 void V8Proxy::ClearDocumentWrapperCache() | 1859 void V8Proxy::ClearDocumentWrapperCache() |
1852 { | 1860 { |
1853 ASSERT(!m_context.IsEmpty()); | 1861 ASSERT(!m_context.IsEmpty()); |
1854 m_context->Global()->ForceDelete(v8::String::New("document")); | 1862 m_context->Global()->ForceDelete(v8::String::New("document")); |
(...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3467 v8::HandleScope scope; | 3475 v8::HandleScope scope; |
3468 if (!context->GetData()->IsObject()) { | 3476 if (!context->GetData()->IsObject()) { |
3469 return -1; | 3477 return -1; |
3470 } | 3478 } |
3471 v8::Handle<v8::Value> data = context->GetData()->ToObject()->Get( | 3479 v8::Handle<v8::Value> data = context->GetData()->ToObject()->Get( |
3472 v8::String::New(kContextDebugDataValue)); | 3480 v8::String::New(kContextDebugDataValue)); |
3473 return data->IsInt32() ? data->Int32Value() : -1; | 3481 return data->IsInt32() ? data->Int32Value() : -1; |
3474 } | 3482 } |
3475 | 3483 |
3476 } // namespace WebCore | 3484 } // namespace WebCore |
OLD | NEW |