mirror of
https://github.com/servo/servo
synced 2026-05-03 04:42:17 +02:00
Split WindowProxies in script to own struct and allow to get an Rc to it. (#39274)
Split the window_proxies in script thread into its own struct with appropiate methods. ScriptThread allows to get an Rc to it. HtmlIFrameElement, Window and WindowProxy now get the Rc on construction from ScriptThread. Testing: Just a refactor so should not change any behavior. Fixes: Addresses part of https://github.com/servo/servo/issues/37969 --------- Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
|
||||
use base::id::{BrowsingContextId, PipelineId, WebViewId};
|
||||
use bitflags::bitflags;
|
||||
@@ -48,6 +49,7 @@ use crate::dom::virtualmethods::VirtualMethods;
|
||||
use crate::dom::windowproxy::WindowProxy;
|
||||
use crate::script_runtime::CanGc;
|
||||
use crate::script_thread::ScriptThread;
|
||||
use crate::script_window_proxies::ScriptWindowProxies;
|
||||
|
||||
#[derive(Clone, Copy, JSTraceable, MallocSizeOf)]
|
||||
struct SandboxAllowance(u8);
|
||||
@@ -93,6 +95,8 @@ pub(crate) struct HTMLIFrameElement {
|
||||
sandbox_allowance: Cell<Option<SandboxAllowance>>,
|
||||
load_blocker: DomRefCell<Option<LoadBlocker>>,
|
||||
throttled: Cell<bool>,
|
||||
#[conditional_malloc_size_of]
|
||||
script_window_proxies: Rc<ScriptWindowProxies>,
|
||||
}
|
||||
|
||||
impl HTMLIFrameElement {
|
||||
@@ -490,6 +494,7 @@ impl HTMLIFrameElement {
|
||||
sandbox_allowance: Cell::new(None),
|
||||
load_blocker: DomRefCell::new(None),
|
||||
throttled: Cell::new(false),
|
||||
script_window_proxies: ScriptThread::window_proxies(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -649,7 +654,7 @@ impl HTMLIFrameElementMethods<crate::DomTypeHolder> for HTMLIFrameElement {
|
||||
fn GetContentWindow(&self) -> Option<DomRoot<WindowProxy>> {
|
||||
self.browsing_context_id
|
||||
.get()
|
||||
.and_then(ScriptThread::find_window_proxy)
|
||||
.and_then(|id| self.script_window_proxies.find_window_proxy(id))
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-iframe-contentdocument
|
||||
|
||||
Reference in New Issue
Block a user