mirror of
https://github.com/servo/servo.git
synced 2025-07-31 03:00:29 +01:00
Upgrade stylo to 2024-09-02 (#33370)
* Upgrade stylo to 2024-09-02 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://phabricator.services.mozilla.com/D217308 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://phabricator.services.mozilla.com/D217626 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://phabricator.services.mozilla.com/D218488 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://phabricator.services.mozilla.com/D219537 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Update test expectations Signed-off-by: Oriol Brufau <obrufau@igalia.com> --------- Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
261d60e456
commit
a76daaf04c
9 changed files with 68 additions and 63 deletions
|
@ -119,6 +119,7 @@ impl CSSRule {
|
|||
StyleCssRule::Margin(_) => unimplemented!(), // TODO
|
||||
StyleCssRule::Scope(_) => unimplemented!(), // TODO
|
||||
StyleCssRule::StartingStyle(_) => unimplemented!(), // TODO
|
||||
StyleCssRule::PositionTry(_) => unimplemented!(), // TODO
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1297,16 +1297,7 @@ where
|
|||
/// returns it.
|
||||
#[allow(unsafe_code)]
|
||||
pub unsafe fn from_untrusted_node_address(candidate: UntrustedNodeAddress) -> DomRoot<Node> {
|
||||
// https://github.com/servo/servo/issues/6383
|
||||
let candidate = candidate.0 as usize;
|
||||
// let object: *mut JSObject = jsfriendapi::bindgen::JS_GetAddressableObject(runtime,
|
||||
// candidate);
|
||||
let object = candidate as *mut JSObject;
|
||||
if object.is_null() {
|
||||
panic!("Attempted to create a `Dom<Node>` from an invalid pointer!")
|
||||
}
|
||||
let boxed_node = conversions::private_from_object(object) as *const Node;
|
||||
DomRoot::from_ref(&*boxed_node)
|
||||
DomRoot::from_ref(Node::from_untrusted_node_address(candidate))
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
|
@ -2430,6 +2421,24 @@ impl Node {
|
|||
.map_or(ns!(), |elem| elem.locate_namespace(prefix)),
|
||||
}
|
||||
}
|
||||
|
||||
/// If the given untrusted node address represents a valid DOM node in the given runtime,
|
||||
/// returns it.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Callers should ensure they pass an UntrustedNodeAddress that points to a valid `JSObject`
|
||||
/// in memory that represents a `Node`.
|
||||
#[allow(unsafe_code)]
|
||||
pub unsafe fn from_untrusted_node_address(candidate: UntrustedNodeAddress) -> &'static Self {
|
||||
// https://github.com/servo/servo/issues/6383
|
||||
let candidate = candidate.0 as usize;
|
||||
let object = candidate as *mut JSObject;
|
||||
if object.is_null() {
|
||||
panic!("Attempted to create a `Node` from an invalid pointer!")
|
||||
}
|
||||
&*(conversions::private_from_object(object) as *const Self)
|
||||
}
|
||||
}
|
||||
|
||||
impl NodeMethods for Node {
|
||||
|
|
|
@ -8,10 +8,12 @@ use std::sync::atomic::Ordering;
|
|||
|
||||
use atomic_refcell::{AtomicRef, AtomicRefMut};
|
||||
use html5ever::{local_name, namespace_url, ns, LocalName, Namespace};
|
||||
use js::jsapi::JSObject;
|
||||
use script_layout_interface::wrapper_traits::{
|
||||
LayoutNode, PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode,
|
||||
};
|
||||
use script_layout_interface::{LayoutNodeType, StyleData};
|
||||
use script_traits::UntrustedNodeAddress;
|
||||
use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint};
|
||||
use selectors::bloom::{BloomFilter, BLOOM_HASH_MASK};
|
||||
use selectors::matching::{ElementSelectorFlags, MatchingContext, VisitedHandlingMode};
|
||||
|
@ -44,7 +46,7 @@ use crate::dom::bindings::inheritance::{
|
|||
use crate::dom::bindings::root::LayoutDom;
|
||||
use crate::dom::characterdata::LayoutCharacterDataHelpers;
|
||||
use crate::dom::element::{Element, LayoutElementHelpers};
|
||||
use crate::dom::node::{LayoutNodeHelpers, NodeFlags};
|
||||
use crate::dom::node::{LayoutNodeHelpers, Node, NodeFlags};
|
||||
use crate::layout_dom::{ServoLayoutNode, ServoShadowRoot, ServoThreadSafeLayoutNode};
|
||||
|
||||
/// A wrapper around elements that ensures layout can only ever access safe properties.
|
||||
|
@ -429,6 +431,18 @@ impl<'dom> style::dom::TElement for ServoLayoutElement<'dom> {
|
|||
F: FnMut(&AtomIdent),
|
||||
{
|
||||
}
|
||||
|
||||
/// Convert an opaque element back into the element.
|
||||
fn unopaque(opaque: ::selectors::OpaqueElement) -> Self {
|
||||
unsafe {
|
||||
let ptr = opaque.as_const_ptr::<JSObject>();
|
||||
let untrusted_address = UntrustedNodeAddress::from_id(ptr as usize);
|
||||
let node = Node::from_untrusted_node_address(untrusted_address);
|
||||
let trusted_address = node.to_trusted_node_address();
|
||||
let servo_layout_node = ServoLayoutNode::new(&trusted_address);
|
||||
servo_layout_node.as_element().unwrap()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'dom> ::selectors::Element for ServoLayoutElement<'dom> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue