diff --git a/third_party/blink/renderer/bindings/modules/v8/v8_context_snapshot_impl.cc b/third_party/blink/renderer/bindings/modules/v8/v8_context_snapshot_impl.cc index 0e5881b79ddc9f..c923c0ab75cd16 100644 --- a/third_party/blink/renderer/bindings/modules/v8/v8_context_snapshot_impl.cc +++ b/third_party/blink/renderer/bindings/modules/v8/v8_context_snapshot_impl.cc @@ -271,22 +271,6 @@ void DeserializeInternalFieldCallback(v8::Local object, } } -namespace { -// We only care for WrapperTypeInfo and do not supply an actual instance of -// the document. Since we need a script wrappable to get type info now, this -// class is a minimal implementation of ScriptWrappable that returns correct -// type info for HTMLDocument. -class DummyHTMLDocumentForSnapshot : public ScriptWrappable { - public: - DummyHTMLDocumentForSnapshot() = default; - - private: - const WrapperTypeInfo* GetWrapperTypeInfo() const override { - return V8HTMLDocument::GetWrapperTypeInfo(); - } -}; -} // namespace - void TakeSnapshotForWorld(v8::SnapshotCreator* snapshot_creator, const DOMWrapperWorld& world) { v8::Isolate* isolate = snapshot_creator->GetIsolate(); @@ -316,9 +300,11 @@ void TakeSnapshotForWorld(v8::SnapshotCreator* snapshot_creator, v8::Local document_wrapper = CreatePlatformObject( isolate, context, world, document_wrapper_type_info); - V8DOMWrapper::SetNativeInfo( - isolate, document_wrapper, document_wrapper_type_info, - MakeGarbageCollected()); + int indices[] = {kV8DOMWrapperObjectIndex, kV8DOMWrapperTypeIndex}; + void* values[] = {nullptr, + const_cast(document_wrapper_type_info)}; + document_wrapper->SetAlignedPointerInInternalFields(std::size(indices), + indices, values); V8PrivateProperty::GetWindowDocumentCachedAccessor(isolate).Set( context->Global(), document_wrapper); diff --git a/third_party/blink/renderer/platform/bindings/wrapper_type_info.cc b/third_party/blink/renderer/platform/bindings/wrapper_type_info.cc index f618f00697f1fc..e823d598033a54 100644 --- a/third_party/blink/renderer/platform/bindings/wrapper_type_info.cc +++ b/third_party/blink/renderer/platform/bindings/wrapper_type_info.cc @@ -57,14 +57,13 @@ v8::Local WrapperTypeInfo::GetV8ClassTemplate( return v8_template; } +const WrapperTypeInfo* ToWrapperTypeInfo( + const v8::TracedReference& wrapper) { + return GetInternalField(wrapper); +} + const WrapperTypeInfo* ToWrapperTypeInfo(v8::Local wrapper) { - const auto* wrappable = ToScriptWrappable(wrapper->GetIsolate(), wrapper); - const WrapperTypeInfo* type_info = - wrappable ? wrappable->GetWrapperTypeInfo() : nullptr; - DCHECK_EQ( - type_info, - (GetInternalField(wrapper))); - return type_info; + return GetInternalField(wrapper); } } // namespace blink diff --git a/third_party/blink/renderer/platform/bindings/wrapper_type_info.h b/third_party/blink/renderer/platform/bindings/wrapper_type_info.h index a153137318feca..6cd34f0a2ace5f 100644 --- a/third_party/blink/renderer/platform/bindings/wrapper_type_info.h +++ b/third_party/blink/renderer/platform/bindings/wrapper_type_info.h @@ -206,6 +206,9 @@ inline ScriptWrappable* ToScriptWrappable(v8::Isolate* isolate, wrapper); } +PLATFORM_EXPORT const WrapperTypeInfo* ToWrapperTypeInfo( + const v8::TracedReference& wrapper); + PLATFORM_EXPORT const WrapperTypeInfo* ToWrapperTypeInfo( v8::Local wrapper);