Merge branch 'main' into outreachy-intern

Signed-off-by: Aniebiet Afia <54312052+aniebietafia@users.noreply.github.com>
This commit is contained in:
Aniebiet Afia 2025-05-14 13:01:33 +01:00 committed by GitHub
commit 2e9bc76b7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5603 changed files with 188713 additions and 83849 deletions

View file

@ -6,6 +6,10 @@ use std::cell::Cell;
use std::ptr;
use base::id::{BrowsingContextId, PipelineId, WebViewId};
use constellation_traits::{
AuxiliaryWebViewCreationRequest, LoadData, LoadOrigin, NavigationHistoryBehavior,
ScriptToConstellationMessage,
};
use dom_struct::dom_struct;
use html5ever::local_name;
use indexmap::map::IndexMap;
@ -29,10 +33,7 @@ use js::rust::wrappers::{JS_TransplantObject, NewWindowProxy, SetWindowProxy};
use js::rust::{Handle, MutableHandle, MutableHandleValue, get_object_class};
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use net_traits::request::Referrer;
use script_traits::{
AuxiliaryWebViewCreationRequest, LoadData, LoadOrigin, NavigationHistoryBehavior,
NewLayoutInfo, ScriptMsg,
};
use script_traits::NewLayoutInfo;
use serde::{Deserialize, Serialize};
use servo_url::{ImmutableOrigin, ServoUrl};
use style::attr::parse_integer;
@ -306,6 +307,7 @@ impl WindowProxy {
document.get_referrer_policy(),
None, // Doesn't inherit secure context
None,
false,
);
let load_info = AuxiliaryWebViewCreationRequest {
load_data: load_data.clone(),
@ -313,7 +315,7 @@ impl WindowProxy {
opener_pipeline_id: self.currently_active.get().unwrap(),
response_sender,
};
let constellation_msg = ScriptMsg::CreateAuxiliaryWebView(load_info);
let constellation_msg = ScriptToConstellationMessage::CreateAuxiliaryWebView(load_info);
window.send_to_constellation(constellation_msg);
let response = response_receiver.recv().unwrap()?;
@ -325,7 +327,7 @@ impl WindowProxy {
webview_id: response.new_webview_id,
opener: Some(self.browsing_context_id),
load_data,
window_size: window.window_size(),
viewport_details: window.viewport_details(),
};
ScriptThread::process_attach_layout(new_layout_info, document.origin().clone());
// TODO: if noopener is false, copy the sessionStorage storage area of the creator origin.
@ -484,6 +486,11 @@ impl WindowProxy {
Some(target_document) => target_document,
None => return Ok(None),
};
let has_trustworthy_ancestor_origin = if new {
target_document.has_trustworthy_ancestor_or_current_origin()
} else {
false
};
let target_window = target_document.window();
// Step 13, and 14.4, will have happened elsewhere,
// since we've created a new browsing context and loaded it with about:blank.
@ -516,6 +523,7 @@ impl WindowProxy {
referrer_policy,
Some(secure),
Some(target_document.insecure_requests_policy()),
has_trustworthy_ancestor_origin,
);
let history_handling = if new {
NavigationHistoryBehavior::Replace
@ -611,6 +619,23 @@ impl WindowProxy {
result
}
/// Run [the focusing steps] with this browsing context.
///
/// [the focusing steps]: https://html.spec.whatwg.org/multipage/#focusing-steps
pub fn focus(&self) {
debug!(
"Requesting the constellation to initiate a focus operation for \
browsing context {}",
self.browsing_context_id()
);
self.global()
.script_to_constellation_chan()
.send(ScriptToConstellationMessage::FocusRemoteDocument(
self.browsing_context_id(),
))
.unwrap();
}
#[allow(unsafe_code)]
/// Change the Window that this WindowProxy resolves to.
// TODO: support setting the window proxy to a dummy value,
@ -852,7 +877,7 @@ unsafe fn GetSubframeWindowProxy(
proxy: RawHandleObject,
id: RawHandleId,
) -> Option<(DomRoot<WindowProxy>, u32)> {
let index = get_array_index_from_id(cx, Handle::from_raw(id));
let index = get_array_index_from_id(Handle::from_raw(id));
if let Some(index) = index {
let mut slot = UndefinedValue();
GetProxyPrivate(*proxy, &mut slot);
@ -862,7 +887,7 @@ unsafe fn GetSubframeWindowProxy(
let (result_sender, result_receiver) = ipc::channel().unwrap();
let _ = win.as_global_scope().script_to_constellation_chan().send(
ScriptMsg::GetChildBrowsingContextId(
ScriptToConstellationMessage::GetChildBrowsingContextId(
browsing_context_id,
index as usize,
result_sender,
@ -881,7 +906,7 @@ unsafe fn GetSubframeWindowProxy(
let (result_sender, result_receiver) = ipc::channel().unwrap();
let _ = win.global().script_to_constellation_chan().send(
ScriptMsg::GetChildBrowsingContextId(
ScriptToConstellationMessage::GetChildBrowsingContextId(
browsing_context_id,
index as usize,
result_sender,
@ -934,7 +959,7 @@ unsafe extern "C" fn defineProperty(
desc: RawHandle<PropertyDescriptor>,
res: *mut ObjectOpResult,
) -> bool {
if get_array_index_from_id(cx, Handle::from_raw(id)).is_some() {
if get_array_index_from_id(Handle::from_raw(id)).is_some() {
// Spec says to Reject whether this is a supported index or not,
// since we have no indexed setter or indexed creator. That means
// throwing in strict mode (FIXME: Bug 828137), doing nothing in
@ -1003,7 +1028,7 @@ unsafe extern "C" fn set(
receiver: RawHandleValue,
res: *mut ObjectOpResult,
) -> bool {
if get_array_index_from_id(cx, Handle::from_raw(id)).is_some() {
if get_array_index_from_id(Handle::from_raw(id)).is_some() {
// Reject (which means throw if and only if strict) the set.
(*res).code_ = JSErrNum::JSMSG_READ_ONLY as ::libc::uintptr_t;
return true;