From 179fde9278ba3e2a3b7c9047a0c7b73e4f8f1c4e Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 4 Mar 2025 13:55:17 +0100 Subject: [PATCH] fix: correct electron gin embedder indices (#45879) fix: correct gin embedder indices. Move electron extra embedders to the end of the enum so they do not interfere with chromium embedders indices. Also use kEmbedderBlinkTag directly in its index calculation without adding extra indices from other tags. Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Marek Haranczyk --- .../fix_harden_blink_scriptstate_maybefrom.patch | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/patches/chromium/fix_harden_blink_scriptstate_maybefrom.patch b/patches/chromium/fix_harden_blink_scriptstate_maybefrom.patch index 64b700f961b1..f70fb46267ec 100644 --- a/patches/chromium/fix_harden_blink_scriptstate_maybefrom.patch +++ b/patches/chromium/fix_harden_blink_scriptstate_maybefrom.patch @@ -43,15 +43,15 @@ diff --git a/gin/public/gin_embedders.h b/gin/public/gin_embedders.h index 8d7c5631fd8f1499c67384286f0e3c4037673b32..99b2e2f63be8a46c5546dd53bc9b05e8c54e857c 100644 --- a/gin/public/gin_embedders.h +++ b/gin/public/gin_embedders.h -@@ -18,6 +18,8 @@ namespace gin { - enum GinEmbedder : uint16_t { - kEmbedderNativeGin, +@@ -20,6 +20,8 @@ enum GinEmbedder : uint16_t { kEmbedderBlink, -+ kEmbedderElectron, -+ kEmbedderBlinkTag, kEmbedderPDFium, kEmbedderFuchsia, ++ kEmbedderElectron, ++ kEmbedderBlinkTag, }; + + } // namespace gin diff --git a/third_party/blink/renderer/platform/bindings/script_state.cc b/third_party/blink/renderer/platform/bindings/script_state.cc index e4a27a24c83dd1a478b2ada8b6c8220076790791..c76dc818f38a62fff63852dbecbc85e304ac731d 100644 --- a/third_party/blink/renderer/platform/bindings/script_state.cc @@ -112,14 +112,13 @@ index b3cc8d819b06108386aed9465cab4f27a28b675f..a1757901e52360a9c2ec3c573adb20d0 static constexpr int kV8ContextPerContextDataIndex = static_cast(gin::kPerContextDataStartIndex) + static_cast(gin::kEmbedderBlink); -@@ -271,6 +278,11 @@ class PLATFORM_EXPORT ScriptState : public GarbageCollected { +@@ -271,6 +278,10 @@ class PLATFORM_EXPORT ScriptState : public GarbageCollected { // internals.idl. String last_compiled_script_file_name_; bool last_compiled_script_used_code_cache_ = false; + + static constexpr int kV8ContextPerContextDataTagIndex = + static_cast(gin::kPerContextDataStartIndex) + -+ static_cast(gin::kEmbedderBlink) + + static_cast(gin::kEmbedderBlinkTag); };