@@ -1951,15 +1951,19 @@ impl ScriptThread {
19511951 ) ,
19521952 ConstellationControlMsg :: PostMessage {
19531953 target : target_pipeline_id,
1954+ source_parent,
19541955 source : source_pipeline_id,
19551956 source_browsing_context,
1957+ source_top_level_browsing_context,
19561958 target_origin : origin,
19571959 source_origin,
19581960 data,
19591961 } => self . handle_post_message_msg (
19601962 target_pipeline_id,
1963+ source_parent,
19611964 source_pipeline_id,
19621965 source_browsing_context,
1966+ source_top_level_browsing_context,
19631967 origin,
19641968 source_origin,
19651969 data,
@@ -2605,8 +2609,10 @@ impl ScriptThread {
26052609 fn handle_post_message_msg (
26062610 & self ,
26072611 pipeline_id : PipelineId ,
2612+ source_parent : Option < BrowsingContextId > ,
26082613 source_pipeline_id : PipelineId ,
2609- source_browsing_context : TopLevelBrowsingContextId ,
2614+ source_browsing_context : BrowsingContextId ,
2615+ source_top_level_browsing_context : TopLevelBrowsingContextId ,
26102616 origin : Option < ImmutableOrigin > ,
26112617 source_origin : ImmutableOrigin ,
26122618 data : StructuredSerializedData ,
@@ -2615,12 +2621,11 @@ impl ScriptThread {
26152621 match window {
26162622 None => return warn ! ( "postMessage after target pipeline {} closed." , pipeline_id) ,
26172623 Some ( window) => {
2618- // FIXME: synchronously talks to constellation.
2619- // send the required info as part of postmessage instead.
26202624 let source = match self . remote_window_proxy (
26212625 & * window. global ( ) ,
2626+ source_top_level_browsing_context,
26222627 source_browsing_context,
2623- source_pipeline_id ,
2628+ source_parent ,
26242629 None ,
26252630 ) {
26262631 None => {
@@ -3043,20 +3048,6 @@ impl ScriptThread {
30433048 }
30443049 }
30453050
3046- fn ask_constellation_for_browsing_context_info (
3047- & self ,
3048- pipeline_id : PipelineId ,
3049- ) -> Option < ( BrowsingContextId , Option < PipelineId > ) > {
3050- let ( result_sender, result_receiver) = ipc:: channel ( ) . unwrap ( ) ;
3051- let msg = ScriptMsg :: GetBrowsingContextInfo ( pipeline_id, result_sender) ;
3052- self . script_sender
3053- . send ( ( pipeline_id, msg) )
3054- . expect ( "Failed to send to constellation." ) ;
3055- result_receiver
3056- . recv ( )
3057- . expect ( "Failed to get browsing context info from constellation." )
3058- }
3059-
30603051 fn ask_constellation_for_top_level_info (
30613052 & self ,
30623053 sender_pipeline : PipelineId ,
@@ -3082,20 +3073,20 @@ impl ScriptThread {
30823073 & self ,
30833074 global_to_clone : & GlobalScope ,
30843075 top_level_browsing_context_id : TopLevelBrowsingContextId ,
3085- pipeline_id : PipelineId ,
3076+ browsing_context_id : BrowsingContextId ,
3077+ parent : Option < BrowsingContextId > ,
30863078 opener : Option < BrowsingContextId > ,
30873079 ) -> Option < DomRoot < WindowProxy > > {
3088- let ( browsing_context_id, parent_pipeline_id) =
3089- self . ask_constellation_for_browsing_context_info ( pipeline_id) ?;
30903080 if let Some ( window_proxy) = self . window_proxies . borrow ( ) . get ( & browsing_context_id) {
30913081 return Some ( DomRoot :: from_ref ( window_proxy) ) ;
30923082 }
30933083
3094- let parent_browsing_context = parent_pipeline_id . and_then ( |parent_id | {
3084+ let parent_browsing_context = parent . and_then ( |parent_bc | {
30953085 self . remote_window_proxy (
30963086 global_to_clone,
30973087 top_level_browsing_context_id,
3098- parent_id,
3088+ parent_bc,
3089+ None ,
30993090 opener,
31003091 )
31013092 } ) ;
@@ -3147,12 +3138,24 @@ impl ScriptThread {
31473138 } ) ;
31483139 let parent_browsing_context = match ( parent_info, iframe. as_ref ( ) ) {
31493140 ( _, Some ( iframe) ) => Some ( window_from_node ( & * * iframe) . window_proxy ( ) ) ,
3150- ( Some ( parent_id) , _) => self . remote_window_proxy (
3151- window. upcast ( ) ,
3152- top_level_browsing_context_id,
3153- parent_id,
3154- opener,
3155- ) ,
3141+ ( Some ( parent_id) , _) => {
3142+ let ( result_sender, result_receiver) = ipc:: channel ( ) . unwrap ( ) ;
3143+ let msg = ScriptMsg :: GetBrowsingContextInfo ( parent_id, result_sender) ;
3144+ self . script_sender
3145+ . send ( ( parent_id, msg) )
3146+ . expect ( "Failed to send to constellation." ) ;
3147+ let browsing_context_id = result_receiver
3148+ . recv ( )
3149+ . expect ( "Failed to get reply from the constellation." )
3150+ . expect ( "Failed to get browsing context info from constellation." ) ;
3151+ self . remote_window_proxy (
3152+ window. upcast ( ) ,
3153+ top_level_browsing_context_id,
3154+ browsing_context_id,
3155+ None ,
3156+ opener,
3157+ )
3158+ } ,
31563159 _ => None ,
31573160 } ;
31583161
0 commit comments