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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/WrapperTypeInfo.h

Issue 1399763004: NPObject should not be retrieved as ScriptWrappable Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/V8NPObject.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/core/v8/WrapperTypeInfo.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/WrapperTypeInfo.h b/third_party/WebKit/Source/bindings/core/v8/WrapperTypeInfo.h
index dfdd028b74668c5a59270212f88b0c88b4d94e87..fe8e4eea1e1bec16476252d235762a5917456985 100644
--- a/third_party/WebKit/Source/bindings/core/v8/WrapperTypeInfo.h
+++ b/third_party/WebKit/Source/bindings/core/v8/WrapperTypeInfo.h
@@ -234,24 +234,32 @@ inline T* getInternalField(v8::Local<v8::Object> wrapper)
return reinterpret_cast<T*>(wrapper->GetAlignedPointerFromInternalField(offset));
}
-inline ScriptWrappable* toScriptWrappable(const v8::PersistentBase<v8::Object>& wrapper)
+inline const WrapperTypeInfo* toWrapperTypeInfo(const v8::PersistentBase<v8::Object>& wrapper)
{
- return getInternalField<ScriptWrappable, v8DOMWrapperObjectIndex>(wrapper);
+ return getInternalField<WrapperTypeInfo, v8DOMWrapperTypeIndex>(wrapper);
}
-inline ScriptWrappable* toScriptWrappable(v8::Local<v8::Object> wrapper)
+inline const WrapperTypeInfo* toWrapperTypeInfo(v8::Local<v8::Object> wrapper)
{
- return getInternalField<ScriptWrappable, v8DOMWrapperObjectIndex>(wrapper);
+ return getInternalField<WrapperTypeInfo, v8DOMWrapperTypeIndex>(wrapper);
}
-inline const WrapperTypeInfo* toWrapperTypeInfo(const v8::PersistentBase<v8::Object>& wrapper)
+const WrapperTypeInfo* npObjectTypeInfo();
+
+inline ScriptWrappable* toScriptWrappable(const v8::PersistentBase<v8::Object>& wrapper)
{
- return getInternalField<WrapperTypeInfo, v8DOMWrapperTypeIndex>(wrapper);
+ // NPObject is not ScriptWrappable. We must not retrieve the pointer
vivekg 2015/10/15 11:23:22 nit: Shall we put a FIXME here to remove the code
+ // as ScriptWrappable.
+ ASSERT(toWrapperTypeInfo(wrapper) != npObjectTypeInfo());
+ return getInternalField<ScriptWrappable, v8DOMWrapperObjectIndex>(wrapper);
}
-inline const WrapperTypeInfo* toWrapperTypeInfo(v8::Local<v8::Object> wrapper)
+inline ScriptWrappable* toScriptWrappable(v8::Local<v8::Object> wrapper)
{
- return getInternalField<WrapperTypeInfo, v8DOMWrapperTypeIndex>(wrapper);
+ // NPObject is not ScriptWrappable. We must not retrieve the pointer
+ // as ScriptWrappable.
+ ASSERT(toWrapperTypeInfo(wrapper) != npObjectTypeInfo());
+ return getInternalField<ScriptWrappable, v8DOMWrapperObjectIndex>(wrapper);
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/V8NPObject.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698