mirror of
https://github.com/servo/servo.git
synced 2025-06-18 22:34:30 +01:00
Auto merge of #26048 - nox:layout-2020-transparent-data, r=jdm
Give a lifetime parameter to LayoutDom
This commit is contained in:
commit
15d8c6058b
44 changed files with 335 additions and 432 deletions
|
@ -241,7 +241,7 @@ pub trait AttrHelpersForLayout {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl AttrHelpersForLayout for LayoutDom<Attr> {
|
||||
impl AttrHelpersForLayout for LayoutDom<'_, Attr> {
|
||||
#[inline]
|
||||
unsafe fn value_forever(&self) -> &'static AttrValue {
|
||||
// This transmute is used to cheat the lifetime restriction.
|
||||
|
|
|
@ -331,6 +331,7 @@ impl<T> Dom<T> {
|
|||
debug_assert!(thread_state::get().is_layout());
|
||||
LayoutDom {
|
||||
ptr: self.ptr.clone(),
|
||||
marker: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -413,13 +414,17 @@ where
|
|||
/// An unrooted reference to a DOM object for use in layout. `Layout*Helpers`
|
||||
/// traits must be implemented on this.
|
||||
#[unrooted_must_root_lint::allow_unrooted_interior]
|
||||
pub struct LayoutDom<T> {
|
||||
pub struct LayoutDom<'dom, T> {
|
||||
ptr: ptr::NonNull<T>,
|
||||
marker: PhantomData<&'dom T>,
|
||||
}
|
||||
|
||||
impl<T: Castable> LayoutDom<T> {
|
||||
impl<'dom, T> LayoutDom<'dom, T>
|
||||
where
|
||||
T: Castable,
|
||||
{
|
||||
/// Cast a DOM object root upwards to one of the interfaces it derives from.
|
||||
pub fn upcast<U>(&self) -> LayoutDom<U>
|
||||
pub fn upcast<U>(&self) -> LayoutDom<'dom, U>
|
||||
where
|
||||
U: Castable,
|
||||
T: DerivedFrom<U>,
|
||||
|
@ -428,11 +433,12 @@ impl<T: Castable> LayoutDom<T> {
|
|||
let ptr: *mut T = self.ptr.as_ptr();
|
||||
LayoutDom {
|
||||
ptr: unsafe { ptr::NonNull::new_unchecked(ptr as *mut U) },
|
||||
marker: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
/// Cast a DOM object downwards to one of the interfaces it might implement.
|
||||
pub fn downcast<U>(&self) -> Option<LayoutDom<U>>
|
||||
pub fn downcast<U>(&self) -> Option<LayoutDom<'dom, U>>
|
||||
where
|
||||
U: DerivedFrom<T>,
|
||||
{
|
||||
|
@ -442,6 +448,7 @@ impl<T: Castable> LayoutDom<T> {
|
|||
let ptr: *mut T = self.ptr.as_ptr();
|
||||
Some(LayoutDom {
|
||||
ptr: ptr::NonNull::new_unchecked(ptr as *mut U),
|
||||
marker: PhantomData,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
|
@ -450,7 +457,10 @@ impl<T: Castable> LayoutDom<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: DomObject> LayoutDom<T> {
|
||||
impl<T> LayoutDom<'_, T>
|
||||
where
|
||||
T: DomObject,
|
||||
{
|
||||
/// Get the reflector.
|
||||
pub unsafe fn get_jsobject(&self) -> *mut JSObject {
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
|
@ -458,7 +468,7 @@ impl<T: DomObject> LayoutDom<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> Copy for LayoutDom<T> {}
|
||||
impl<T> Copy for LayoutDom<'_, T> {}
|
||||
|
||||
impl<T> PartialEq for Dom<T> {
|
||||
fn eq(&self, other: &Dom<T>) -> bool {
|
||||
|
@ -474,13 +484,13 @@ impl<'a, T: DomObject> PartialEq<&'a T> for Dom<T> {
|
|||
|
||||
impl<T> Eq for Dom<T> {}
|
||||
|
||||
impl<T> PartialEq for LayoutDom<T> {
|
||||
fn eq(&self, other: &LayoutDom<T>) -> bool {
|
||||
impl<T> PartialEq for LayoutDom<'_, T> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.ptr.as_ptr() == other.ptr.as_ptr()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Eq for LayoutDom<T> {}
|
||||
impl<T> Eq for LayoutDom<'_, T> {}
|
||||
|
||||
impl<T> Hash for Dom<T> {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
|
@ -488,7 +498,7 @@ impl<T> Hash for Dom<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> Hash for LayoutDom<T> {
|
||||
impl<T> Hash for LayoutDom<'_, T> {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
self.ptr.as_ptr().hash(state)
|
||||
}
|
||||
|
@ -497,7 +507,7 @@ impl<T> Hash for LayoutDom<T> {
|
|||
impl<T> Clone for Dom<T> {
|
||||
#[inline]
|
||||
#[allow(unrooted_must_root)]
|
||||
fn clone(&self) -> Dom<T> {
|
||||
fn clone(&self) -> Self {
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
Dom {
|
||||
ptr: self.ptr.clone(),
|
||||
|
@ -505,24 +515,26 @@ impl<T> Clone for Dom<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> Clone for LayoutDom<T> {
|
||||
impl<T> Clone for LayoutDom<'_, T> {
|
||||
#[inline]
|
||||
fn clone(&self) -> LayoutDom<T> {
|
||||
fn clone(&self) -> Self {
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
LayoutDom {
|
||||
ptr: self.ptr.clone(),
|
||||
marker: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl LayoutDom<Node> {
|
||||
impl LayoutDom<'_, Node> {
|
||||
/// Create a new JS-owned value wrapped from an address known to be a
|
||||
/// `Node` pointer.
|
||||
pub unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> LayoutDom<Node> {
|
||||
pub unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> Self {
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
let TrustedNodeAddress(addr) = inner;
|
||||
LayoutDom {
|
||||
ptr: ptr::NonNull::new_unchecked(addr as *const Node as *mut Node),
|
||||
marker: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -624,7 +636,7 @@ impl<T: DomObject> MutNullableDom<T> {
|
|||
#[allow(unrooted_must_root)]
|
||||
pub unsafe fn get_inner_as_layout(&self) -> Option<LayoutDom<T>> {
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
ptr::read(self.ptr.get()).map(|js| js.to_layout())
|
||||
(*self.ptr.get()).as_ref().map(|js| js.to_layout())
|
||||
}
|
||||
|
||||
/// Get a rooted value out of this object
|
||||
|
@ -732,7 +744,10 @@ unsafe impl<T: DomObject> JSTraceable for DomOnceCell<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: DomObject> LayoutDom<T> {
|
||||
impl<'dom, T> LayoutDom<'dom, T>
|
||||
where
|
||||
T: 'dom + DomObject,
|
||||
{
|
||||
/// Returns an unsafe pointer to the interior of this JS object. This is
|
||||
/// the only method that be safely accessed from layout. (The fact that
|
||||
/// this is unsafe is what necessitates the layout wrappers.)
|
||||
|
|
|
@ -36,7 +36,6 @@ use crate::dom::bindings::reflector::{DomObject, Reflector};
|
|||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
use crate::dom::bindings::str::{DOMString, USVString};
|
||||
use crate::dom::bindings::utils::WindowProxyHandler;
|
||||
use crate::dom::document::PendingRestyle;
|
||||
use crate::dom::gpubuffer::GPUBufferState;
|
||||
use crate::dom::htmlimageelement::SourceSet;
|
||||
use crate::dom::htmlmediaelement::{HTMLMediaElementFetchContext, MediaFrameRenderer};
|
||||
|
@ -96,6 +95,7 @@ use net_traits::storage_thread::StorageType;
|
|||
use net_traits::{Metadata, NetworkError, ReferrerPolicy, ResourceFetchTiming, ResourceThreads};
|
||||
use profile_traits::mem::ProfilerChan as MemProfilerChan;
|
||||
use profile_traits::time::ProfilerChan as TimeProfilerChan;
|
||||
use script_layout_interface::message::PendingRestyle;
|
||||
use script_layout_interface::rpc::LayoutRPC;
|
||||
use script_layout_interface::OpaqueStyleAndLayoutData;
|
||||
use script_traits::serializable::BlobImpl;
|
||||
|
|
|
@ -157,7 +157,7 @@ pub trait LayoutCanvasRenderingContext2DHelpers {
|
|||
unsafe fn get_canvas_id(&self) -> CanvasId;
|
||||
}
|
||||
|
||||
impl LayoutCanvasRenderingContext2DHelpers for LayoutDom<CanvasRenderingContext2D> {
|
||||
impl LayoutCanvasRenderingContext2DHelpers for LayoutDom<'_, CanvasRenderingContext2D> {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_ipc_renderer(&self) -> IpcSender<CanvasMsg> {
|
||||
(*self.unsafe_get())
|
||||
|
|
|
@ -286,7 +286,7 @@ pub trait LayoutCharacterDataHelpers {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl LayoutCharacterDataHelpers for LayoutDom<CharacterData> {
|
||||
impl LayoutCharacterDataHelpers for LayoutDom<'_, CharacterData> {
|
||||
#[inline]
|
||||
unsafe fn data_for_layout(&self) -> &str {
|
||||
&(*self.unsafe_get()).data.borrow_for_layout()
|
||||
|
|
|
@ -71,7 +71,7 @@ use crate::dom::location::Location;
|
|||
use crate::dom::messageevent::MessageEvent;
|
||||
use crate::dom::mouseevent::MouseEvent;
|
||||
use crate::dom::node::{self, document_from_node, window_from_node, CloneChildrenFlag};
|
||||
use crate::dom::node::{LayoutNodeHelpers, Node, NodeDamage, NodeFlags, ShadowIncluding};
|
||||
use crate::dom::node::{Node, NodeDamage, NodeFlags, ShadowIncluding};
|
||||
use crate::dom::nodeiterator::NodeIterator;
|
||||
use crate::dom::nodelist::NodeList;
|
||||
use crate::dom::pagetransitionevent::PageTransitionEvent;
|
||||
|
@ -133,7 +133,8 @@ use percent_encoding::percent_decode;
|
|||
use profile_traits::ipc as profile_ipc;
|
||||
use profile_traits::time::{TimerMetadata, TimerMetadataFrameType, TimerMetadataReflowType};
|
||||
use ref_slice::ref_slice;
|
||||
use script_layout_interface::message::{Msg, ReflowGoal};
|
||||
use script_layout_interface::message::{Msg, PendingRestyle, ReflowGoal};
|
||||
use script_layout_interface::TrustedNodeAddress;
|
||||
use script_traits::{AnimationState, DocumentActivity, MouseButton, MouseEventType};
|
||||
use script_traits::{
|
||||
MsDuration, ScriptMsg, TouchEventType, TouchId, UntrustedNodeAddress, WheelDelta,
|
||||
|
@ -157,7 +158,7 @@ use style::attr::AttrValue;
|
|||
use style::context::QuirksMode;
|
||||
use style::invalidation::element::restyle_hints::RestyleHint;
|
||||
use style::media_queries::{Device, MediaType};
|
||||
use style::selector_parser::{RestyleDamage, Snapshot};
|
||||
use style::selector_parser::Snapshot;
|
||||
use style::shared_lock::SharedRwLock as StyleSharedRwLock;
|
||||
use style::str::{split_html_space_chars, str_join};
|
||||
use style::stylesheet_set::DocumentStylesheetSet;
|
||||
|
@ -201,29 +202,6 @@ pub enum IsHTMLDocument {
|
|||
NonHTMLDocument,
|
||||
}
|
||||
|
||||
#[derive(Debug, MallocSizeOf)]
|
||||
pub struct PendingRestyle {
|
||||
/// If this element had a state or attribute change since the last restyle, track
|
||||
/// the original condition of the element.
|
||||
pub snapshot: Option<Snapshot>,
|
||||
|
||||
/// Any explicit restyles hints that have been accumulated for this element.
|
||||
pub hint: RestyleHint,
|
||||
|
||||
/// Any explicit restyles damage that have been accumulated for this element.
|
||||
pub damage: RestyleDamage,
|
||||
}
|
||||
|
||||
impl PendingRestyle {
|
||||
pub fn new() -> Self {
|
||||
PendingRestyle {
|
||||
snapshot: None,
|
||||
hint: RestyleHint::empty(),
|
||||
damage: RestyleDamage::empty(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <https://dom.spec.whatwg.org/#document>
|
||||
#[dom_struct]
|
||||
pub struct Document {
|
||||
|
@ -2629,7 +2607,6 @@ pub enum DocumentSource {
|
|||
#[allow(unsafe_code)]
|
||||
pub trait LayoutDocumentHelpers {
|
||||
unsafe fn is_html_document_for_layout(&self) -> bool;
|
||||
unsafe fn drain_pending_restyles(&self) -> Vec<(LayoutDom<Element>, PendingRestyle)>;
|
||||
unsafe fn needs_paint_from_layout(&self);
|
||||
unsafe fn will_paint(&self);
|
||||
unsafe fn quirks_mode(&self) -> QuirksMode;
|
||||
|
@ -2640,28 +2617,12 @@ pub trait LayoutDocumentHelpers {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl LayoutDocumentHelpers for LayoutDom<Document> {
|
||||
impl LayoutDocumentHelpers for LayoutDom<'_, Document> {
|
||||
#[inline]
|
||||
unsafe fn is_html_document_for_layout(&self) -> bool {
|
||||
(*self.unsafe_get()).is_html_document
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unrooted_must_root)]
|
||||
unsafe fn drain_pending_restyles(&self) -> Vec<(LayoutDom<Element>, PendingRestyle)> {
|
||||
let mut elements = (*self.unsafe_get())
|
||||
.pending_restyles
|
||||
.borrow_mut_for_layout();
|
||||
// Elements were in a document when they were added to this list, but that
|
||||
// may no longer be true when the next layout occurs.
|
||||
let result = elements
|
||||
.drain()
|
||||
.map(|(k, v)| (k.to_layout(), v))
|
||||
.filter(|&(ref k, _)| k.upcast::<Node>().get_flag(NodeFlags::IS_CONNECTED))
|
||||
.collect();
|
||||
result
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn needs_paint_from_layout(&self) {
|
||||
(*self.unsafe_get()).needs_paint.set(true)
|
||||
|
@ -3602,6 +3563,16 @@ impl Document {
|
|||
(None, None) => ElementLookupResult::None,
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn drain_pending_restyles(&self) -> Vec<(TrustedNodeAddress, PendingRestyle)> {
|
||||
self.pending_restyles
|
||||
.borrow_mut()
|
||||
.drain()
|
||||
.filter(|(k, _)| k.upcast::<Node>().get_flag(NodeFlags::IS_CONNECTED))
|
||||
.map(|(k, v)| (k.upcast::<Node>().to_trusted_node_address(), v))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl Element {
|
||||
|
|
|
@ -567,11 +567,11 @@ pub trait RawLayoutElementHelpers {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
pub unsafe fn get_attr_for_layout<'a>(
|
||||
elem: &'a Element,
|
||||
pub unsafe fn get_attr_for_layout<'dom>(
|
||||
elem: &'dom Element,
|
||||
namespace: &Namespace,
|
||||
name: &LocalName,
|
||||
) -> Option<LayoutDom<Attr>> {
|
||||
) -> Option<LayoutDom<'dom, Attr>> {
|
||||
// cast to point to T in RefCell<T> directly
|
||||
let attrs = elem.attrs.borrow_for_layout();
|
||||
attrs
|
||||
|
@ -620,7 +620,7 @@ impl RawLayoutElementHelpers for Element {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait LayoutElementHelpers {
|
||||
pub trait LayoutElementHelpers<'dom> {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn has_class_for_layout(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool;
|
||||
#[allow(unsafe_code)]
|
||||
|
@ -646,10 +646,10 @@ pub trait LayoutElementHelpers {
|
|||
fn has_selector_flags(&self, flags: ElementSelectorFlags) -> bool;
|
||||
/// The shadow root this element is a host of.
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_shadow_root_for_layout(&self) -> Option<LayoutDom<ShadowRoot>>;
|
||||
unsafe fn get_shadow_root_for_layout(&self) -> Option<LayoutDom<'dom, ShadowRoot>>;
|
||||
}
|
||||
|
||||
impl LayoutElementHelpers for LayoutDom<Element> {
|
||||
impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
||||
#[allow(unsafe_code)]
|
||||
#[inline]
|
||||
unsafe fn has_class_for_layout(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool {
|
||||
|
@ -1095,7 +1095,7 @@ impl LayoutElementHelpers for LayoutDom<Element> {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_shadow_root_for_layout(&self) -> Option<LayoutDom<ShadowRoot>> {
|
||||
unsafe fn get_shadow_root_for_layout(&self) -> Option<LayoutDom<'dom, ShadowRoot>> {
|
||||
(*self.unsafe_get())
|
||||
.rare_data_for_layout()
|
||||
.as_ref()?
|
||||
|
|
|
@ -99,7 +99,7 @@ pub trait HTMLBodyElementLayoutHelpers {
|
|||
fn get_background(&self) -> Option<ServoUrl>;
|
||||
}
|
||||
|
||||
impl HTMLBodyElementLayoutHelpers for LayoutDom<HTMLBodyElement> {
|
||||
impl HTMLBodyElementLayoutHelpers for LayoutDom<'_, HTMLBodyElement> {
|
||||
#[allow(unsafe_code)]
|
||||
fn get_background_color(&self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
|
|
|
@ -120,7 +120,7 @@ pub trait LayoutHTMLCanvasElementHelpers {
|
|||
fn get_canvas_id_for_layout(&self) -> CanvasId;
|
||||
}
|
||||
|
||||
impl LayoutHTMLCanvasElementHelpers for LayoutDom<HTMLCanvasElement> {
|
||||
impl LayoutHTMLCanvasElementHelpers for LayoutDom<'_, HTMLCanvasElement> {
|
||||
#[allow(unsafe_code)]
|
||||
fn data(&self) -> HTMLCanvasData {
|
||||
unsafe {
|
||||
|
|
|
@ -106,7 +106,7 @@ pub trait HTMLFontElementLayoutHelpers {
|
|||
fn get_size(&self) -> Option<u32>;
|
||||
}
|
||||
|
||||
impl HTMLFontElementLayoutHelpers for LayoutDom<HTMLFontElement> {
|
||||
impl HTMLFontElementLayoutHelpers for LayoutDom<'_, HTMLFontElement> {
|
||||
#[allow(unsafe_code)]
|
||||
fn get_color(&self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
|
|
|
@ -70,7 +70,7 @@ pub trait HTMLHRLayoutHelpers {
|
|||
fn get_width(&self) -> LengthOrPercentageOrAuto;
|
||||
}
|
||||
|
||||
impl HTMLHRLayoutHelpers for LayoutDom<HTMLHRElement> {
|
||||
impl HTMLHRLayoutHelpers for LayoutDom<'_, HTMLHRElement> {
|
||||
#[allow(unsafe_code)]
|
||||
fn get_color(&self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
|
|
|
@ -486,7 +486,7 @@ pub trait HTMLIFrameElementLayoutMethods {
|
|||
fn get_height(&self) -> LengthOrPercentageOrAuto;
|
||||
}
|
||||
|
||||
impl HTMLIFrameElementLayoutMethods for LayoutDom<HTMLIFrameElement> {
|
||||
impl HTMLIFrameElementLayoutMethods for LayoutDom<'_, HTMLIFrameElement> {
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
fn pipeline_id(&self) -> Option<PipelineId> {
|
||||
|
|
|
@ -1382,7 +1382,7 @@ pub trait LayoutHTMLImageElementHelpers {
|
|||
fn get_height(&self) -> LengthOrPercentageOrAuto;
|
||||
}
|
||||
|
||||
impl LayoutHTMLImageElementHelpers for LayoutDom<HTMLImageElement> {
|
||||
impl LayoutHTMLImageElementHelpers for LayoutDom<'_, HTMLImageElement> {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn image(&self) -> Option<Arc<Image>> {
|
||||
(*self.unsafe_get())
|
||||
|
|
|
@ -726,11 +726,14 @@ unsafe fn get_raw_textinput_value(input: LayoutDom<HTMLInputElement>) -> DOMStri
|
|||
.get_content()
|
||||
}
|
||||
|
||||
impl LayoutHTMLInputElementHelpers for LayoutDom<HTMLInputElement> {
|
||||
impl LayoutHTMLInputElementHelpers for LayoutDom<'_, HTMLInputElement> {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn value_for_layout(self) -> String {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_raw_attr_value(input: LayoutDom<HTMLInputElement>, default: &str) -> String {
|
||||
unsafe fn get_raw_attr_value(
|
||||
input: LayoutDom<'_, HTMLInputElement>,
|
||||
default: &str,
|
||||
) -> String {
|
||||
let elem = input.upcast::<Element>();
|
||||
let value = (*elem.unsafe_get())
|
||||
.get_attr_val_for_layout(&ns!(), &local_name!("value"))
|
||||
|
|
|
@ -2447,7 +2447,7 @@ pub trait LayoutHTMLMediaElementHelpers {
|
|||
fn data(&self) -> HTMLMediaData;
|
||||
}
|
||||
|
||||
impl LayoutHTMLMediaElementHelpers for LayoutDom<HTMLMediaElement> {
|
||||
impl LayoutHTMLMediaElementHelpers for LayoutDom<'_, HTMLMediaElement> {
|
||||
#[allow(unsafe_code)]
|
||||
fn data(&self) -> HTMLMediaData {
|
||||
let media = unsafe { &*self.unsafe_get() };
|
||||
|
|
|
@ -105,7 +105,7 @@ pub trait HTMLTableCellElementLayoutHelpers {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl HTMLTableCellElementLayoutHelpers for LayoutDom<HTMLTableCellElement> {
|
||||
impl HTMLTableCellElementLayoutHelpers for LayoutDom<'_, HTMLTableCellElement> {
|
||||
fn get_background_color(&self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
|
|
|
@ -412,7 +412,7 @@ pub trait HTMLTableElementLayoutHelpers {
|
|||
fn get_width(&self) -> LengthOrPercentageOrAuto;
|
||||
}
|
||||
|
||||
impl HTMLTableElementLayoutHelpers for LayoutDom<HTMLTableElement> {
|
||||
impl HTMLTableElementLayoutHelpers for LayoutDom<'_, HTMLTableElement> {
|
||||
#[allow(unsafe_code)]
|
||||
fn get_background_color(&self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
|
|
|
@ -150,7 +150,7 @@ pub trait HTMLTableRowElementLayoutHelpers {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl HTMLTableRowElementLayoutHelpers for LayoutDom<HTMLTableRowElement> {
|
||||
impl HTMLTableRowElementLayoutHelpers for LayoutDom<'_, HTMLTableRowElement> {
|
||||
fn get_background_color(&self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
|
|
|
@ -88,7 +88,7 @@ pub trait HTMLTableSectionElementLayoutHelpers {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl HTMLTableSectionElementLayoutHelpers for LayoutDom<HTMLTableSectionElement> {
|
||||
impl HTMLTableSectionElementLayoutHelpers for LayoutDom<'_, HTMLTableSectionElement> {
|
||||
fn get_background_color(&self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
|
|
|
@ -66,7 +66,7 @@ pub trait LayoutHTMLTextAreaElementHelpers {
|
|||
fn get_rows(self) -> u32;
|
||||
}
|
||||
|
||||
impl LayoutHTMLTextAreaElementHelpers for LayoutDom<HTMLTextAreaElement> {
|
||||
impl LayoutHTMLTextAreaElementHelpers for LayoutDom<'_, HTMLTextAreaElement> {
|
||||
#[allow(unrooted_must_root)]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn value_for_layout(self) -> String {
|
||||
|
|
|
@ -1304,17 +1304,17 @@ pub unsafe fn from_untrusted_node_address(
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub trait LayoutNodeHelpers {
|
||||
pub trait LayoutNodeHelpers<'dom> {
|
||||
unsafe fn type_id_for_layout(&self) -> NodeTypeId;
|
||||
|
||||
unsafe fn composed_parent_node_ref(&self) -> Option<LayoutDom<Node>>;
|
||||
unsafe fn first_child_ref(&self) -> Option<LayoutDom<Node>>;
|
||||
unsafe fn last_child_ref(&self) -> Option<LayoutDom<Node>>;
|
||||
unsafe fn prev_sibling_ref(&self) -> Option<LayoutDom<Node>>;
|
||||
unsafe fn next_sibling_ref(&self) -> Option<LayoutDom<Node>>;
|
||||
unsafe fn composed_parent_node_ref(&self) -> Option<LayoutDom<'dom, Node>>;
|
||||
unsafe fn first_child_ref(&self) -> Option<LayoutDom<'dom, Node>>;
|
||||
unsafe fn last_child_ref(&self) -> Option<LayoutDom<'dom, Node>>;
|
||||
unsafe fn prev_sibling_ref(&self) -> Option<LayoutDom<'dom, Node>>;
|
||||
unsafe fn next_sibling_ref(&self) -> Option<LayoutDom<'dom, Node>>;
|
||||
|
||||
unsafe fn owner_doc_for_layout(&self) -> LayoutDom<Document>;
|
||||
unsafe fn containing_shadow_root_for_layout(&self) -> Option<LayoutDom<ShadowRoot>>;
|
||||
unsafe fn owner_doc_for_layout(&self) -> LayoutDom<'dom, Document>;
|
||||
unsafe fn containing_shadow_root_for_layout(&self) -> Option<LayoutDom<'dom, ShadowRoot>>;
|
||||
|
||||
unsafe fn is_element_for_layout(&self) -> bool;
|
||||
unsafe fn get_flag(&self, flag: NodeFlags) -> bool;
|
||||
|
@ -1339,7 +1339,7 @@ pub trait LayoutNodeHelpers {
|
|||
fn opaque(&self) -> OpaqueNode;
|
||||
}
|
||||
|
||||
impl LayoutNodeHelpers for LayoutDom<Node> {
|
||||
impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> {
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn type_id_for_layout(&self) -> NodeTypeId {
|
||||
|
@ -1354,7 +1354,7 @@ impl LayoutNodeHelpers for LayoutDom<Node> {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn composed_parent_node_ref(&self) -> Option<LayoutDom<Node>> {
|
||||
unsafe fn composed_parent_node_ref(&self) -> Option<LayoutDom<'dom, Node>> {
|
||||
let parent = (*self.unsafe_get()).parent_node.get_inner_as_layout();
|
||||
if let Some(ref parent) = parent {
|
||||
if let Some(shadow_root) = parent.downcast::<ShadowRoot>() {
|
||||
|
@ -1366,31 +1366,31 @@ impl LayoutNodeHelpers for LayoutDom<Node> {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn first_child_ref(&self) -> Option<LayoutDom<Node>> {
|
||||
unsafe fn first_child_ref(&self) -> Option<LayoutDom<'dom, Node>> {
|
||||
(*self.unsafe_get()).first_child.get_inner_as_layout()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn last_child_ref(&self) -> Option<LayoutDom<Node>> {
|
||||
unsafe fn last_child_ref(&self) -> Option<LayoutDom<'dom, Node>> {
|
||||
(*self.unsafe_get()).last_child.get_inner_as_layout()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn prev_sibling_ref(&self) -> Option<LayoutDom<Node>> {
|
||||
unsafe fn prev_sibling_ref(&self) -> Option<LayoutDom<'dom, Node>> {
|
||||
(*self.unsafe_get()).prev_sibling.get_inner_as_layout()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn next_sibling_ref(&self) -> Option<LayoutDom<Node>> {
|
||||
unsafe fn next_sibling_ref(&self) -> Option<LayoutDom<'dom, Node>> {
|
||||
(*self.unsafe_get()).next_sibling.get_inner_as_layout()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn owner_doc_for_layout(&self) -> LayoutDom<Document> {
|
||||
unsafe fn owner_doc_for_layout(&self) -> LayoutDom<'dom, Document> {
|
||||
(*self.unsafe_get())
|
||||
.owner_doc
|
||||
.get_inner_as_layout()
|
||||
|
@ -1399,7 +1399,7 @@ impl LayoutNodeHelpers for LayoutDom<Node> {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn containing_shadow_root_for_layout(&self) -> Option<LayoutDom<ShadowRoot>> {
|
||||
unsafe fn containing_shadow_root_for_layout(&self) -> Option<LayoutDom<'dom, ShadowRoot>> {
|
||||
(*self.unsafe_get())
|
||||
.rare_data_for_layout()
|
||||
.as_ref()?
|
||||
|
|
|
@ -239,8 +239,8 @@ impl ShadowRootMethods for ShadowRoot {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub trait LayoutShadowRootHelpers {
|
||||
unsafe fn get_host_for_layout(&self) -> LayoutDom<Element>;
|
||||
pub trait LayoutShadowRootHelpers<'dom> {
|
||||
unsafe fn get_host_for_layout(&self) -> LayoutDom<'dom, Element>;
|
||||
unsafe fn get_style_data_for_layout<'a, E: TElement>(
|
||||
&self,
|
||||
) -> &'a AuthorStyles<StyleSheetInDocument>;
|
||||
|
@ -252,10 +252,10 @@ pub trait LayoutShadowRootHelpers {
|
|||
);
|
||||
}
|
||||
|
||||
impl LayoutShadowRootHelpers for LayoutDom<ShadowRoot> {
|
||||
impl<'dom> LayoutShadowRootHelpers<'dom> for LayoutDom<'dom, ShadowRoot> {
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_host_for_layout(&self) -> LayoutDom<Element> {
|
||||
unsafe fn get_host_for_layout(&self) -> LayoutDom<'dom, Element> {
|
||||
(*self.unsafe_get())
|
||||
.host
|
||||
.get_inner_as_layout()
|
||||
|
|
|
@ -52,7 +52,7 @@ pub trait LayoutSVGSVGElementHelpers {
|
|||
fn data(&self) -> SVGSVGData;
|
||||
}
|
||||
|
||||
impl LayoutSVGSVGElementHelpers for LayoutDom<SVGSVGElement> {
|
||||
impl LayoutSVGSVGElementHelpers for LayoutDom<'_, SVGSVGElement> {
|
||||
#[allow(unsafe_code, non_snake_case)]
|
||||
fn data(&self) -> SVGSVGData {
|
||||
unsafe {
|
||||
|
|
|
@ -3884,7 +3884,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
}
|
||||
}
|
||||
|
||||
impl LayoutCanvasWebGLRenderingContextHelpers for LayoutDom<WebGL2RenderingContext> {
|
||||
impl LayoutCanvasWebGLRenderingContextHelpers for LayoutDom<'_, WebGL2RenderingContext> {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn canvas_data_source(&self) -> HTMLCanvasDataSource {
|
||||
let this = &*self.unsafe_get();
|
||||
|
|
|
@ -4450,7 +4450,7 @@ pub trait LayoutCanvasWebGLRenderingContextHelpers {
|
|||
unsafe fn canvas_data_source(&self) -> HTMLCanvasDataSource;
|
||||
}
|
||||
|
||||
impl LayoutCanvasWebGLRenderingContextHelpers for LayoutDom<WebGLRenderingContext> {
|
||||
impl LayoutCanvasWebGLRenderingContextHelpers for LayoutDom<'_, WebGLRenderingContext> {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn canvas_data_source(&self) -> HTMLCanvasDataSource {
|
||||
(*self.unsafe_get()).layout_handle()
|
||||
|
|
|
@ -1617,13 +1617,14 @@ impl Window {
|
|||
reflow_info: Reflow {
|
||||
page_clip_rect: self.page_clip_rect.get(),
|
||||
},
|
||||
document: self.Document().upcast::<Node>().to_trusted_node_address(),
|
||||
document: document.upcast::<Node>().to_trusted_node_address(),
|
||||
stylesheets_changed,
|
||||
window_size: self.window_size.get(),
|
||||
origin: self.origin().immutable().clone(),
|
||||
reflow_goal,
|
||||
script_join_chan: join_chan,
|
||||
dom_count: self.Document().dom_count(),
|
||||
dom_count: document.dom_count(),
|
||||
pending_restyles: document.drain_pending_restyles(),
|
||||
};
|
||||
|
||||
self.layout_chan
|
||||
|
|
|
@ -130,7 +130,7 @@ pub mod layout_exports {
|
|||
pub use crate::dom::bindings::inheritance::{HTMLElementTypeId, NodeTypeId, TextTypeId};
|
||||
pub use crate::dom::bindings::root::LayoutDom;
|
||||
pub use crate::dom::characterdata::LayoutCharacterDataHelpers;
|
||||
pub use crate::dom::document::{Document, LayoutDocumentHelpers, PendingRestyle};
|
||||
pub use crate::dom::document::{Document, LayoutDocumentHelpers};
|
||||
pub use crate::dom::element::{Element, LayoutElementHelpers, RawLayoutElementHelpers};
|
||||
pub use crate::dom::node::NodeFlags;
|
||||
pub use crate::dom::node::{LayoutNodeHelpers, Node};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue