Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8DOMWrapper.cpp

Issue 2209593002: Stop returning an empty handle from createWrapper() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: temp Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 v8::Local<v8::Object> wrapper; 55 v8::Local<v8::Object> wrapper;
56 if (perContextData) { 56 if (perContextData) {
57 wrapper = perContextData->createWrapperFromCache(type); 57 wrapper = perContextData->createWrapperFromCache(type);
58 } else { 58 } else {
59 // The context is detached, but still accessible. 59 // The context is detached, but still accessible.
60 // TODO(yukishiino): This code does not create a wrapper with 60 // TODO(yukishiino): This code does not create a wrapper with
61 // the correct settings. Should follow the same way as 61 // the correct settings. Should follow the same way as
62 // V8PerContextData::createWrapperFromCache, though there is no need to 62 // V8PerContextData::createWrapperFromCache, though there is no need to
63 // cache resulting objects or their constructors. 63 // cache resulting objects or their constructors.
64 const DOMWrapperWorld& world = DOMWrapperWorld::world(scope.context()); 64 const DOMWrapperWorld& world = DOMWrapperWorld::world(scope.context());
65 if (!type->domTemplate(isolate, world)->InstanceTemplate()->NewInstance( scope.context()).ToLocal(&wrapper)) { 65 wrapper = type->domTemplate(isolate, world)->InstanceTemplate()->NewInst ance(scope.context()).ToLocalChecked();
66 // Nothing to do.
67 }
68 } 66 }
69
70 return wrapper; 67 return wrapper;
71 } 68 }
72 69
73 bool V8DOMWrapper::isWrapper(v8::Isolate* isolate, v8::Local<v8::Value> value) 70 bool V8DOMWrapper::isWrapper(v8::Isolate* isolate, v8::Local<v8::Value> value)
74 { 71 {
75 if (value.IsEmpty() || !value->IsObject()) 72 if (value.IsEmpty() || !value->IsObject())
76 return false; 73 return false;
77 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); 74 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value);
78 75
79 if (object->InternalFieldCount() < v8DefaultWrapperInternalFieldCount) 76 if (object->InternalFieldCount() < v8DefaultWrapperInternalFieldCount)
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 v8::Isolate* isolate = m_context->GetIsolate(); 136 v8::Isolate* isolate = m_context->GetIsolate();
140 // TODO(jochen): Currently, Location is the only object for which we can rea ch this code path. Should be generalized. 137 // TODO(jochen): Currently, Location is the only object for which we can rea ch this code path. Should be generalized.
141 ExceptionState exceptionState(ExceptionState::ConstructionContext, "Location ", isolate->GetCurrentContext()->Global(), isolate); 138 ExceptionState exceptionState(ExceptionState::ConstructionContext, "Location ", isolate->GetCurrentContext()->Global(), isolate);
142 LocalDOMWindow* callingWindow = currentDOMWindow(isolate); 139 LocalDOMWindow* callingWindow = currentDOMWindow(isolate);
143 DOMWindow* targetWindow = toDOMWindow(m_context); 140 DOMWindow* targetWindow = toDOMWindow(m_context);
144 exceptionState.throwSecurityError(targetWindow->sanitizedCrossDomainAccessEr rorMessage(callingWindow), targetWindow->crossDomainAccessErrorMessage(callingWi ndow)); 141 exceptionState.throwSecurityError(targetWindow->sanitizedCrossDomainAccessEr rorMessage(callingWindow), targetWindow->crossDomainAccessErrorMessage(callingWi ndow));
145 exceptionState.throwIfNeeded(); 142 exceptionState.throwIfNeeded();
146 } 143 }
147 144
148 } // namespace blink 145 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ScriptWrappable.cpp ('k') | third_party/WebKit/Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698