mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Auto merge of #26058 - servo:layout-2020-improvements, r=SimonSapin
Make many improvements to the layout/script comms story Now `LayoutDom<'dom, T>` is a mere wrapper around a `&'dom T`.
This commit is contained in:
commit
236762880c
24 changed files with 215 additions and 253 deletions
|
@ -177,12 +177,7 @@ impl<'lr> TShadowRoot for ServoShadowRoot<'lr> {
|
|||
where
|
||||
Self: 'a,
|
||||
{
|
||||
Some(unsafe {
|
||||
&self
|
||||
.shadow_root
|
||||
.get_style_data_for_layout::<ServoLayoutElement>()
|
||||
.data
|
||||
})
|
||||
Some(unsafe { &self.shadow_root.get_style_data_for_layout().data })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -184,12 +184,7 @@ impl<'lr> TShadowRoot for ServoShadowRoot<'lr> {
|
|||
where
|
||||
Self: 'a,
|
||||
{
|
||||
Some(unsafe {
|
||||
&self
|
||||
.shadow_root
|
||||
.get_style_data_for_layout::<ServoLayoutElement>()
|
||||
.data
|
||||
})
|
||||
Some(unsafe { &self.shadow_root.get_style_data_for_layout().data })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -233,37 +233,36 @@ impl Attr {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub trait AttrHelpersForLayout {
|
||||
unsafe fn value_forever(&self) -> &'static AttrValue;
|
||||
unsafe fn value_ref_forever(&self) -> &'static str;
|
||||
unsafe fn value_tokens_forever(&self) -> Option<&'static [Atom]>;
|
||||
unsafe fn local_name_atom_forever(&self) -> LocalName;
|
||||
pub trait AttrHelpersForLayout<'dom> {
|
||||
unsafe fn value(self) -> &'dom AttrValue;
|
||||
unsafe fn value_ref_forever(self) -> &'dom str;
|
||||
unsafe fn value_tokens(self) -> Option<&'dom [Atom]>;
|
||||
unsafe fn local_name_atom(self) -> LocalName;
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl AttrHelpersForLayout for LayoutDom<'_, Attr> {
|
||||
impl<'dom> AttrHelpersForLayout<'dom> for LayoutDom<'dom, Attr> {
|
||||
#[inline]
|
||||
unsafe fn value_forever(&self) -> &'static AttrValue {
|
||||
// This transmute is used to cheat the lifetime restriction.
|
||||
mem::transmute::<&AttrValue, &AttrValue>((*self.unsafe_get()).value.borrow_for_layout())
|
||||
unsafe fn value(self) -> &'dom AttrValue {
|
||||
(*self.unsafe_get()).value.borrow_for_layout()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn value_ref_forever(&self) -> &'static str {
|
||||
&**self.value_forever()
|
||||
unsafe fn value_ref_forever(self) -> &'dom str {
|
||||
&**self.value()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn value_tokens_forever(&self) -> Option<&'static [Atom]> {
|
||||
unsafe fn value_tokens(self) -> Option<&'dom [Atom]> {
|
||||
// This transmute is used to cheat the lifetime restriction.
|
||||
match *self.value_forever() {
|
||||
match *self.value() {
|
||||
AttrValue::TokenList(_, ref tokens) => Some(tokens),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn local_name_atom_forever(&self) -> LocalName {
|
||||
unsafe fn local_name_atom(self) -> LocalName {
|
||||
(*self.unsafe_get()).identifier.local_name.clone()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -330,8 +330,7 @@ impl<T> Dom<T> {
|
|||
pub unsafe fn to_layout(&self) -> LayoutDom<T> {
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
LayoutDom {
|
||||
ptr: self.ptr.clone(),
|
||||
marker: PhantomData,
|
||||
value: self.ptr.as_ref(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -415,8 +414,7 @@ where
|
|||
/// traits must be implemented on this.
|
||||
#[unrooted_must_root_lint::allow_unrooted_interior]
|
||||
pub struct LayoutDom<'dom, T> {
|
||||
ptr: ptr::NonNull<T>,
|
||||
marker: PhantomData<&'dom T>,
|
||||
value: &'dom T,
|
||||
}
|
||||
|
||||
impl<'dom, T> LayoutDom<'dom, T>
|
||||
|
@ -430,10 +428,8 @@ where
|
|||
T: DerivedFrom<U>,
|
||||
{
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
let ptr: *mut T = self.ptr.as_ptr();
|
||||
LayoutDom {
|
||||
ptr: unsafe { ptr::NonNull::new_unchecked(ptr as *mut U) },
|
||||
marker: PhantomData,
|
||||
value: self.value.upcast::<U>(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -443,17 +439,7 @@ where
|
|||
U: DerivedFrom<T>,
|
||||
{
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
unsafe {
|
||||
if (*self.unsafe_get()).is::<U>() {
|
||||
let ptr: *mut T = self.ptr.as_ptr();
|
||||
Some(LayoutDom {
|
||||
ptr: ptr::NonNull::new_unchecked(ptr as *mut U),
|
||||
marker: PhantomData,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
self.value.downcast::<U>().map(|value| LayoutDom { value })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -464,7 +450,7 @@ where
|
|||
/// Get the reflector.
|
||||
pub unsafe fn get_jsobject(&self) -> *mut JSObject {
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
(*self.ptr.as_ptr()).reflector().get_jsobject().get()
|
||||
self.value.reflector().get_jsobject().get()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -486,7 +472,7 @@ impl<T> Eq for Dom<T> {}
|
|||
|
||||
impl<T> PartialEq for LayoutDom<'_, T> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.ptr.as_ptr() == other.ptr.as_ptr()
|
||||
self.value as *const T == other.value as *const T
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -500,7 +486,7 @@ impl<T> Hash for Dom<T> {
|
|||
|
||||
impl<T> Hash for LayoutDom<'_, T> {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
self.ptr.as_ptr().hash(state)
|
||||
(self.value as *const T).hash(state)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -519,10 +505,7 @@ impl<T> Clone for LayoutDom<'_, T> {
|
|||
#[inline]
|
||||
fn clone(&self) -> Self {
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
LayoutDom {
|
||||
ptr: self.ptr.clone(),
|
||||
marker: PhantomData,
|
||||
}
|
||||
LayoutDom { value: self.value }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -533,8 +516,7 @@ impl LayoutDom<'_, Node> {
|
|||
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,
|
||||
value: &*(addr as *const Node),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -748,12 +730,11 @@ 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.)
|
||||
pub unsafe fn unsafe_get(&self) -> *const T {
|
||||
/// Returns a reference to the interior of this JS object. The fact
|
||||
/// that this is unsafe is what necessitates the layout wrappers.
|
||||
pub unsafe fn unsafe_get(self) -> &'dom T {
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
self.ptr.as_ptr()
|
||||
self.value
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -152,14 +152,14 @@ impl CanvasRenderingContext2D {
|
|||
|
||||
pub trait LayoutCanvasRenderingContext2DHelpers {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_ipc_renderer(&self) -> IpcSender<CanvasMsg>;
|
||||
unsafe fn get_ipc_renderer(self) -> IpcSender<CanvasMsg>;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_canvas_id(&self) -> CanvasId;
|
||||
unsafe fn get_canvas_id(self) -> CanvasId;
|
||||
}
|
||||
|
||||
impl LayoutCanvasRenderingContext2DHelpers for LayoutDom<'_, CanvasRenderingContext2D> {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_ipc_renderer(&self) -> IpcSender<CanvasMsg> {
|
||||
unsafe fn get_ipc_renderer(self) -> IpcSender<CanvasMsg> {
|
||||
(*self.unsafe_get())
|
||||
.canvas_state
|
||||
.borrow_for_layout()
|
||||
|
@ -168,7 +168,7 @@ impl LayoutCanvasRenderingContext2DHelpers for LayoutDom<'_, CanvasRenderingCont
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_canvas_id(&self) -> CanvasId {
|
||||
unsafe fn get_canvas_id(self) -> CanvasId {
|
||||
(*self.unsafe_get())
|
||||
.canvas_state
|
||||
.borrow_for_layout()
|
||||
|
|
|
@ -281,14 +281,14 @@ impl CharacterDataMethods for CharacterData {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub trait LayoutCharacterDataHelpers {
|
||||
unsafe fn data_for_layout(&self) -> &str;
|
||||
pub trait LayoutCharacterDataHelpers<'dom> {
|
||||
unsafe fn data_for_layout(self) -> &'dom str;
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl LayoutCharacterDataHelpers for LayoutDom<'_, CharacterData> {
|
||||
impl<'dom> LayoutCharacterDataHelpers<'dom> for LayoutDom<'dom, CharacterData> {
|
||||
#[inline]
|
||||
unsafe fn data_for_layout(&self) -> &str {
|
||||
unsafe fn data_for_layout(self) -> &'dom str {
|
||||
&(*self.unsafe_get()).data.borrow_for_layout()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2605,46 +2605,46 @@ pub enum DocumentSource {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub trait LayoutDocumentHelpers {
|
||||
unsafe fn is_html_document_for_layout(&self) -> bool;
|
||||
unsafe fn needs_paint_from_layout(&self);
|
||||
unsafe fn will_paint(&self);
|
||||
unsafe fn quirks_mode(&self) -> QuirksMode;
|
||||
unsafe fn style_shared_lock(&self) -> &StyleSharedRwLock;
|
||||
unsafe fn shadow_roots(&self) -> Vec<LayoutDom<ShadowRoot>>;
|
||||
unsafe fn shadow_roots_styles_changed(&self) -> bool;
|
||||
unsafe fn flush_shadow_roots_stylesheets(&self);
|
||||
pub trait LayoutDocumentHelpers<'dom> {
|
||||
unsafe fn is_html_document_for_layout(self) -> bool;
|
||||
unsafe fn needs_paint_from_layout(self);
|
||||
unsafe fn will_paint(self);
|
||||
unsafe fn quirks_mode(self) -> QuirksMode;
|
||||
unsafe fn style_shared_lock(self) -> &'dom StyleSharedRwLock;
|
||||
unsafe fn shadow_roots(self) -> Vec<LayoutDom<'dom, ShadowRoot>>;
|
||||
unsafe fn shadow_roots_styles_changed(self) -> bool;
|
||||
unsafe fn flush_shadow_roots_stylesheets(self);
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl LayoutDocumentHelpers for LayoutDom<'_, Document> {
|
||||
impl<'dom> LayoutDocumentHelpers<'dom> for LayoutDom<'dom, Document> {
|
||||
#[inline]
|
||||
unsafe fn is_html_document_for_layout(&self) -> bool {
|
||||
unsafe fn is_html_document_for_layout(self) -> bool {
|
||||
(*self.unsafe_get()).is_html_document
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn needs_paint_from_layout(&self) {
|
||||
unsafe fn needs_paint_from_layout(self) {
|
||||
(*self.unsafe_get()).needs_paint.set(true)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn will_paint(&self) {
|
||||
unsafe fn will_paint(self) {
|
||||
(*self.unsafe_get()).needs_paint.set(false)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn quirks_mode(&self) -> QuirksMode {
|
||||
unsafe fn quirks_mode(self) -> QuirksMode {
|
||||
(*self.unsafe_get()).quirks_mode()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn style_shared_lock(&self) -> &StyleSharedRwLock {
|
||||
unsafe fn style_shared_lock(self) -> &'dom StyleSharedRwLock {
|
||||
(*self.unsafe_get()).style_shared_lock()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn shadow_roots(&self) -> Vec<LayoutDom<ShadowRoot>> {
|
||||
unsafe fn shadow_roots(self) -> Vec<LayoutDom<'dom, ShadowRoot>> {
|
||||
(*self.unsafe_get())
|
||||
.shadow_roots
|
||||
.borrow_for_layout()
|
||||
|
@ -2654,12 +2654,12 @@ impl LayoutDocumentHelpers for LayoutDom<'_, Document> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn shadow_roots_styles_changed(&self) -> bool {
|
||||
unsafe fn shadow_roots_styles_changed(self) -> bool {
|
||||
(*self.unsafe_get()).shadow_roots_styles_changed()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn flush_shadow_roots_stylesheets(&self) {
|
||||
unsafe fn flush_shadow_roots_stylesheets(self) {
|
||||
(*self.unsafe_get()).flush_shadow_roots_stylesheets()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -578,7 +578,7 @@ pub unsafe fn get_attr_for_layout<'dom>(
|
|||
.iter()
|
||||
.find(|attr| {
|
||||
let attr = attr.to_layout();
|
||||
*name == attr.local_name_atom_forever() && (*attr.unsafe_get()).namespace() == namespace
|
||||
*name == attr.local_name_atom() && (*attr.unsafe_get()).namespace() == namespace
|
||||
})
|
||||
.map(|attr| attr.to_layout())
|
||||
}
|
||||
|
@ -591,7 +591,7 @@ impl RawLayoutElementHelpers for Element {
|
|||
namespace: &Namespace,
|
||||
name: &LocalName,
|
||||
) -> Option<&'a AttrValue> {
|
||||
get_attr_for_layout(self, namespace, name).map(|attr| attr.value_forever())
|
||||
get_attr_for_layout(self, namespace, name).map(|attr| attr.value())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -610,8 +610,8 @@ impl RawLayoutElementHelpers for Element {
|
|||
.iter()
|
||||
.filter_map(|attr| {
|
||||
let attr = attr.to_layout();
|
||||
if *name == attr.local_name_atom_forever() {
|
||||
Some(attr.value_forever())
|
||||
if *name == attr.local_name_atom() {
|
||||
Some(attr.value())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -622,12 +622,12 @@ impl RawLayoutElementHelpers for Element {
|
|||
|
||||
pub trait LayoutElementHelpers<'dom> {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn has_class_for_layout(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool;
|
||||
unsafe fn has_class_for_layout(self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_classes_for_layout(&self) -> Option<&'static [Atom]>;
|
||||
unsafe fn get_classes_for_layout(self) -> Option<&'dom [Atom]>;
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, _: &mut V)
|
||||
unsafe fn synthesize_presentational_hints_for_legacy_attributes<V>(self, _: &mut V)
|
||||
where
|
||||
V: Push<ApplicableDeclarationBlock>;
|
||||
#[allow(unsafe_code)]
|
||||
|
@ -635,28 +635,28 @@ pub trait LayoutElementHelpers<'dom> {
|
|||
#[allow(unsafe_code)]
|
||||
unsafe fn get_rowspan(self) -> u32;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn is_html_element(&self) -> bool;
|
||||
fn id_attribute(&self) -> *const Option<Atom>;
|
||||
fn style_attribute(&self) -> *const Option<Arc<Locked<PropertyDeclarationBlock>>>;
|
||||
fn local_name(&self) -> &LocalName;
|
||||
fn namespace(&self) -> &Namespace;
|
||||
fn get_lang_for_layout(&self) -> String;
|
||||
fn get_state_for_layout(&self) -> ElementState;
|
||||
fn insert_selector_flags(&self, flags: ElementSelectorFlags);
|
||||
fn has_selector_flags(&self, flags: ElementSelectorFlags) -> bool;
|
||||
unsafe fn is_html_element(self) -> bool;
|
||||
fn id_attribute(self) -> *const Option<Atom>;
|
||||
fn style_attribute(self) -> *const Option<Arc<Locked<PropertyDeclarationBlock>>>;
|
||||
fn local_name(self) -> &'dom LocalName;
|
||||
fn namespace(self) -> &'dom Namespace;
|
||||
fn get_lang_for_layout(self) -> String;
|
||||
fn get_state_for_layout(self) -> ElementState;
|
||||
fn insert_selector_flags(self, flags: ElementSelectorFlags);
|
||||
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<'dom, ShadowRoot>>;
|
||||
unsafe fn get_shadow_root_for_layout(self) -> Option<LayoutDom<'dom, ShadowRoot>>;
|
||||
}
|
||||
|
||||
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 {
|
||||
unsafe fn has_class_for_layout(self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool {
|
||||
get_attr_for_layout(&*self.unsafe_get(), &ns!(), &local_name!("class")).map_or(
|
||||
false,
|
||||
|attr| {
|
||||
attr.value_tokens_forever()
|
||||
attr.value_tokens()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.any(|atom| case_sensitivity.eq_atom(atom, name))
|
||||
|
@ -666,13 +666,13 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
#[inline]
|
||||
unsafe fn get_classes_for_layout(&self) -> Option<&'static [Atom]> {
|
||||
unsafe fn get_classes_for_layout(self) -> Option<&'dom [Atom]> {
|
||||
get_attr_for_layout(&*self.unsafe_get(), &ns!(), &local_name!("class"))
|
||||
.map(|attr| attr.value_tokens_forever().unwrap())
|
||||
.map(|attr| attr.value_tokens().unwrap())
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, hints: &mut V)
|
||||
unsafe fn synthesize_presentational_hints_for_legacy_attributes<V>(self, hints: &mut V)
|
||||
where
|
||||
V: Push<ApplicableDeclarationBlock>,
|
||||
{
|
||||
|
@ -1019,32 +1019,32 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn is_html_element(&self) -> bool {
|
||||
unsafe fn is_html_element(self) -> bool {
|
||||
(*self.unsafe_get()).namespace == ns!(html)
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn id_attribute(&self) -> *const Option<Atom> {
|
||||
fn id_attribute(self) -> *const Option<Atom> {
|
||||
unsafe { (*self.unsafe_get()).id_attribute.borrow_for_layout() }
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn style_attribute(&self) -> *const Option<Arc<Locked<PropertyDeclarationBlock>>> {
|
||||
fn style_attribute(self) -> *const Option<Arc<Locked<PropertyDeclarationBlock>>> {
|
||||
unsafe { (*self.unsafe_get()).style_attribute.borrow_for_layout() }
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn local_name(&self) -> &LocalName {
|
||||
fn local_name(self) -> &'dom LocalName {
|
||||
unsafe { &(*self.unsafe_get()).local_name }
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn namespace(&self) -> &Namespace {
|
||||
fn namespace(self) -> &'dom Namespace {
|
||||
unsafe { &(*self.unsafe_get()).namespace }
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_lang_for_layout(&self) -> String {
|
||||
fn get_lang_for_layout(self) -> String {
|
||||
unsafe {
|
||||
let mut current_node = Some(self.upcast::<Node>());
|
||||
while let Some(node) = current_node {
|
||||
|
@ -1073,13 +1073,13 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
fn get_state_for_layout(&self) -> ElementState {
|
||||
fn get_state_for_layout(self) -> ElementState {
|
||||
unsafe { (*self.unsafe_get()).state.get() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
fn insert_selector_flags(&self, flags: ElementSelectorFlags) {
|
||||
fn insert_selector_flags(self, flags: ElementSelectorFlags) {
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
unsafe {
|
||||
let f = &(*self.unsafe_get()).selector_flags;
|
||||
|
@ -1089,13 +1089,13 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
fn has_selector_flags(&self, flags: ElementSelectorFlags) -> bool {
|
||||
fn has_selector_flags(self, flags: ElementSelectorFlags) -> bool {
|
||||
unsafe { (*self.unsafe_get()).selector_flags.get().contains(flags) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_shadow_root_for_layout(&self) -> Option<LayoutDom<'dom, ShadowRoot>> {
|
||||
unsafe fn get_shadow_root_for_layout(self) -> Option<LayoutDom<'dom, ShadowRoot>> {
|
||||
(*self.unsafe_get())
|
||||
.rare_data_for_layout()
|
||||
.as_ref()?
|
||||
|
|
|
@ -94,14 +94,14 @@ impl HTMLBodyElementMethods for HTMLBodyElement {
|
|||
}
|
||||
|
||||
pub trait HTMLBodyElementLayoutHelpers {
|
||||
fn get_background_color(&self) -> Option<RGBA>;
|
||||
fn get_color(&self) -> Option<RGBA>;
|
||||
fn get_background(&self) -> Option<ServoUrl>;
|
||||
fn get_background_color(self) -> Option<RGBA>;
|
||||
fn get_color(self) -> Option<RGBA>;
|
||||
fn get_background(self) -> Option<ServoUrl>;
|
||||
}
|
||||
|
||||
impl HTMLBodyElementLayoutHelpers for LayoutDom<'_, HTMLBodyElement> {
|
||||
#[allow(unsafe_code)]
|
||||
fn get_background_color(&self) -> Option<RGBA> {
|
||||
fn get_background_color(self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
|
||||
|
@ -111,7 +111,7 @@ impl HTMLBodyElementLayoutHelpers for LayoutDom<'_, HTMLBodyElement> {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_color(&self) -> Option<RGBA> {
|
||||
fn get_color(self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("text"))
|
||||
|
@ -121,7 +121,7 @@ impl HTMLBodyElementLayoutHelpers for LayoutDom<'_, HTMLBodyElement> {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_background(&self) -> Option<ServoUrl> {
|
||||
fn get_background(self) -> Option<ServoUrl> {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("background"))
|
||||
|
|
|
@ -114,15 +114,15 @@ impl HTMLCanvasElement {
|
|||
}
|
||||
|
||||
pub trait LayoutHTMLCanvasElementHelpers {
|
||||
fn data(&self) -> HTMLCanvasData;
|
||||
fn get_width(&self) -> LengthOrPercentageOrAuto;
|
||||
fn get_height(&self) -> LengthOrPercentageOrAuto;
|
||||
fn get_canvas_id_for_layout(&self) -> CanvasId;
|
||||
fn data(self) -> HTMLCanvasData;
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto;
|
||||
fn get_height(self) -> LengthOrPercentageOrAuto;
|
||||
fn get_canvas_id_for_layout(self) -> CanvasId;
|
||||
}
|
||||
|
||||
impl LayoutHTMLCanvasElementHelpers for LayoutDom<'_, HTMLCanvasElement> {
|
||||
#[allow(unsafe_code)]
|
||||
fn data(&self) -> HTMLCanvasData {
|
||||
fn data(self) -> HTMLCanvasData {
|
||||
unsafe {
|
||||
let canvas = &*self.unsafe_get();
|
||||
let source = match canvas.context.borrow_for_layout().as_ref() {
|
||||
|
@ -154,7 +154,7 @@ impl LayoutHTMLCanvasElementHelpers for LayoutDom<'_, HTMLCanvasElement> {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_width(&self) -> LengthOrPercentageOrAuto {
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("width"))
|
||||
|
@ -164,7 +164,7 @@ impl LayoutHTMLCanvasElementHelpers for LayoutDom<'_, HTMLCanvasElement> {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_height(&self) -> LengthOrPercentageOrAuto {
|
||||
fn get_height(self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("height"))
|
||||
|
@ -174,7 +174,7 @@ impl LayoutHTMLCanvasElementHelpers for LayoutDom<'_, HTMLCanvasElement> {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_canvas_id_for_layout(&self) -> CanvasId {
|
||||
fn get_canvas_id_for_layout(self) -> CanvasId {
|
||||
unsafe {
|
||||
let canvas = &*self.unsafe_get();
|
||||
if let &Some(CanvasContext::Context2d(ref context)) = canvas.context.borrow_for_layout()
|
||||
|
|
|
@ -101,14 +101,14 @@ impl VirtualMethods for HTMLFontElement {
|
|||
}
|
||||
|
||||
pub trait HTMLFontElementLayoutHelpers {
|
||||
fn get_color(&self) -> Option<RGBA>;
|
||||
fn get_face(&self) -> Option<Atom>;
|
||||
fn get_size(&self) -> Option<u32>;
|
||||
fn get_color(self) -> Option<RGBA>;
|
||||
fn get_face(self) -> Option<Atom>;
|
||||
fn get_size(self) -> Option<u32>;
|
||||
}
|
||||
|
||||
impl HTMLFontElementLayoutHelpers for LayoutDom<'_, HTMLFontElement> {
|
||||
#[allow(unsafe_code)]
|
||||
fn get_color(&self) -> Option<RGBA> {
|
||||
fn get_color(self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("color"))
|
||||
|
@ -118,7 +118,7 @@ impl HTMLFontElementLayoutHelpers for LayoutDom<'_, HTMLFontElement> {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_face(&self) -> Option<Atom> {
|
||||
fn get_face(self) -> Option<Atom> {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("face"))
|
||||
|
@ -128,7 +128,7 @@ impl HTMLFontElementLayoutHelpers for LayoutDom<'_, HTMLFontElement> {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_size(&self) -> Option<u32> {
|
||||
fn get_size(self) -> Option<u32> {
|
||||
let size = unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("size"))
|
||||
|
|
|
@ -66,13 +66,13 @@ impl HTMLHRElementMethods for HTMLHRElement {
|
|||
}
|
||||
|
||||
pub trait HTMLHRLayoutHelpers {
|
||||
fn get_color(&self) -> Option<RGBA>;
|
||||
fn get_width(&self) -> LengthOrPercentageOrAuto;
|
||||
fn get_color(self) -> Option<RGBA>;
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto;
|
||||
}
|
||||
|
||||
impl HTMLHRLayoutHelpers for LayoutDom<'_, HTMLHRElement> {
|
||||
#[allow(unsafe_code)]
|
||||
fn get_color(&self) -> Option<RGBA> {
|
||||
fn get_color(self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("color"))
|
||||
|
@ -82,7 +82,7 @@ impl HTMLHRLayoutHelpers for LayoutDom<'_, HTMLHRElement> {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_width(&self) -> LengthOrPercentageOrAuto {
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("width"))
|
||||
|
|
|
@ -480,27 +480,27 @@ impl HTMLIFrameElement {
|
|||
}
|
||||
|
||||
pub trait HTMLIFrameElementLayoutMethods {
|
||||
fn pipeline_id(&self) -> Option<PipelineId>;
|
||||
fn browsing_context_id(&self) -> Option<BrowsingContextId>;
|
||||
fn get_width(&self) -> LengthOrPercentageOrAuto;
|
||||
fn get_height(&self) -> LengthOrPercentageOrAuto;
|
||||
fn pipeline_id(self) -> Option<PipelineId>;
|
||||
fn browsing_context_id(self) -> Option<BrowsingContextId>;
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto;
|
||||
fn get_height(self) -> LengthOrPercentageOrAuto;
|
||||
}
|
||||
|
||||
impl HTMLIFrameElementLayoutMethods for LayoutDom<'_, HTMLIFrameElement> {
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
fn pipeline_id(&self) -> Option<PipelineId> {
|
||||
fn pipeline_id(self) -> Option<PipelineId> {
|
||||
unsafe { (*self.unsafe_get()).pipeline_id.get() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
fn browsing_context_id(&self) -> Option<BrowsingContextId> {
|
||||
fn browsing_context_id(self) -> Option<BrowsingContextId> {
|
||||
unsafe { (*self.unsafe_get()).browsing_context_id.get() }
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_width(&self) -> LengthOrPercentageOrAuto {
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("width"))
|
||||
|
@ -511,7 +511,7 @@ impl HTMLIFrameElementLayoutMethods for LayoutDom<'_, HTMLIFrameElement> {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_height(&self) -> LengthOrPercentageOrAuto {
|
||||
fn get_height(self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("height"))
|
||||
|
|
|
@ -1367,24 +1367,20 @@ impl MicrotaskRunnable for ImageElementMicrotask {
|
|||
|
||||
pub trait LayoutHTMLImageElementHelpers {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn image(&self) -> Option<Arc<Image>>;
|
||||
|
||||
unsafe fn image(self) -> Option<Arc<Image>>;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn image_url(&self) -> Option<ServoUrl>;
|
||||
|
||||
unsafe fn image_url(self) -> Option<ServoUrl>;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn image_density(&self) -> Option<f64>;
|
||||
|
||||
unsafe fn image_density(self) -> Option<f64>;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn image_data(&self) -> (Option<Arc<Image>>, Option<ImageMetadata>);
|
||||
|
||||
fn get_width(&self) -> LengthOrPercentageOrAuto;
|
||||
fn get_height(&self) -> LengthOrPercentageOrAuto;
|
||||
unsafe fn image_data(self) -> (Option<Arc<Image>>, Option<ImageMetadata>);
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto;
|
||||
fn get_height(self) -> LengthOrPercentageOrAuto;
|
||||
}
|
||||
|
||||
impl LayoutHTMLImageElementHelpers for LayoutDom<'_, HTMLImageElement> {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn image(&self) -> Option<Arc<Image>> {
|
||||
unsafe fn image(self) -> Option<Arc<Image>> {
|
||||
(*self.unsafe_get())
|
||||
.current_request
|
||||
.borrow_for_layout()
|
||||
|
@ -1393,7 +1389,7 @@ impl LayoutHTMLImageElementHelpers for LayoutDom<'_, HTMLImageElement> {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn image_url(&self) -> Option<ServoUrl> {
|
||||
unsafe fn image_url(self) -> Option<ServoUrl> {
|
||||
(*self.unsafe_get())
|
||||
.current_request
|
||||
.borrow_for_layout()
|
||||
|
@ -1402,7 +1398,7 @@ impl LayoutHTMLImageElementHelpers for LayoutDom<'_, HTMLImageElement> {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn image_data(&self) -> (Option<Arc<Image>>, Option<ImageMetadata>) {
|
||||
unsafe fn image_data(self) -> (Option<Arc<Image>>, Option<ImageMetadata>) {
|
||||
let current_request = (*self.unsafe_get()).current_request.borrow_for_layout();
|
||||
(
|
||||
current_request.image.clone(),
|
||||
|
@ -1411,7 +1407,7 @@ impl LayoutHTMLImageElementHelpers for LayoutDom<'_, HTMLImageElement> {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn image_density(&self) -> Option<f64> {
|
||||
unsafe fn image_density(self) -> Option<f64> {
|
||||
(*self.unsafe_get())
|
||||
.current_request
|
||||
.borrow_for_layout()
|
||||
|
@ -1420,7 +1416,7 @@ impl LayoutHTMLImageElementHelpers for LayoutDom<'_, HTMLImageElement> {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_width(&self) -> LengthOrPercentageOrAuto {
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("width"))
|
||||
|
@ -1431,7 +1427,7 @@ impl LayoutHTMLImageElementHelpers for LayoutDom<'_, HTMLImageElement> {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_height(&self) -> LengthOrPercentageOrAuto {
|
||||
fn get_height(self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("height"))
|
||||
|
|
|
@ -2444,12 +2444,12 @@ impl VirtualMethods for HTMLMediaElement {
|
|||
}
|
||||
|
||||
pub trait LayoutHTMLMediaElementHelpers {
|
||||
fn data(&self) -> HTMLMediaData;
|
||||
fn data(self) -> HTMLMediaData;
|
||||
}
|
||||
|
||||
impl LayoutHTMLMediaElementHelpers for LayoutDom<'_, HTMLMediaElement> {
|
||||
#[allow(unsafe_code)]
|
||||
fn data(&self) -> HTMLMediaData {
|
||||
fn data(self) -> HTMLMediaData {
|
||||
let media = unsafe { &*self.unsafe_get() };
|
||||
HTMLMediaData {
|
||||
current_frame: media.video_renderer.lock().unwrap().current_frame.clone(),
|
||||
|
|
|
@ -98,15 +98,15 @@ impl HTMLTableCellElementMethods for HTMLTableCellElement {
|
|||
}
|
||||
|
||||
pub trait HTMLTableCellElementLayoutHelpers {
|
||||
fn get_background_color(&self) -> Option<RGBA>;
|
||||
fn get_colspan(&self) -> Option<u32>;
|
||||
fn get_rowspan(&self) -> Option<u32>;
|
||||
fn get_width(&self) -> LengthOrPercentageOrAuto;
|
||||
fn get_background_color(self) -> Option<RGBA>;
|
||||
fn get_colspan(self) -> Option<u32>;
|
||||
fn get_rowspan(self) -> Option<u32>;
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto;
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl HTMLTableCellElementLayoutHelpers for LayoutDom<'_, HTMLTableCellElement> {
|
||||
fn get_background_color(&self) -> Option<RGBA> {
|
||||
fn get_background_color(self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
|
||||
|
@ -115,7 +115,7 @@ impl HTMLTableCellElementLayoutHelpers for LayoutDom<'_, HTMLTableCellElement> {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_colspan(&self) -> Option<u32> {
|
||||
fn get_colspan(self) -> Option<u32> {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("colspan"))
|
||||
|
@ -123,7 +123,7 @@ impl HTMLTableCellElementLayoutHelpers for LayoutDom<'_, HTMLTableCellElement> {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_rowspan(&self) -> Option<u32> {
|
||||
fn get_rowspan(self) -> Option<u32> {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("rowspan"))
|
||||
|
@ -131,7 +131,7 @@ impl HTMLTableCellElementLayoutHelpers for LayoutDom<'_, HTMLTableCellElement> {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_width(&self) -> LengthOrPercentageOrAuto {
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("width"))
|
||||
|
|
|
@ -406,15 +406,15 @@ impl HTMLTableElementMethods for HTMLTableElement {
|
|||
}
|
||||
|
||||
pub trait HTMLTableElementLayoutHelpers {
|
||||
fn get_background_color(&self) -> Option<RGBA>;
|
||||
fn get_border(&self) -> Option<u32>;
|
||||
fn get_cellspacing(&self) -> Option<u32>;
|
||||
fn get_width(&self) -> LengthOrPercentageOrAuto;
|
||||
fn get_background_color(self) -> Option<RGBA>;
|
||||
fn get_border(self) -> Option<u32>;
|
||||
fn get_cellspacing(self) -> Option<u32>;
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto;
|
||||
}
|
||||
|
||||
impl HTMLTableElementLayoutHelpers for LayoutDom<'_, HTMLTableElement> {
|
||||
#[allow(unsafe_code)]
|
||||
fn get_background_color(&self) -> Option<RGBA> {
|
||||
fn get_background_color(self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
|
||||
|
@ -424,17 +424,17 @@ impl HTMLTableElementLayoutHelpers for LayoutDom<'_, HTMLTableElement> {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_border(&self) -> Option<u32> {
|
||||
fn get_border(self) -> Option<u32> {
|
||||
unsafe { (*self.unsafe_get()).border.get() }
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_cellspacing(&self) -> Option<u32> {
|
||||
fn get_cellspacing(self) -> Option<u32> {
|
||||
unsafe { (*self.unsafe_get()).cellspacing.get() }
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_width(&self) -> LengthOrPercentageOrAuto {
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("width"))
|
||||
|
|
|
@ -146,12 +146,12 @@ impl HTMLTableRowElementMethods for HTMLTableRowElement {
|
|||
}
|
||||
|
||||
pub trait HTMLTableRowElementLayoutHelpers {
|
||||
fn get_background_color(&self) -> Option<RGBA>;
|
||||
fn get_background_color(self) -> Option<RGBA>;
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl HTMLTableRowElementLayoutHelpers for LayoutDom<'_, HTMLTableRowElement> {
|
||||
fn get_background_color(&self) -> Option<RGBA> {
|
||||
fn get_background_color(self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
|
||||
|
|
|
@ -84,12 +84,12 @@ impl HTMLTableSectionElementMethods for HTMLTableSectionElement {
|
|||
}
|
||||
|
||||
pub trait HTMLTableSectionElementLayoutHelpers {
|
||||
fn get_background_color(&self) -> Option<RGBA>;
|
||||
fn get_background_color(self) -> Option<RGBA>;
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl HTMLTableSectionElementLayoutHelpers for LayoutDom<'_, HTMLTableSectionElement> {
|
||||
fn get_background_color(&self) -> Option<RGBA> {
|
||||
fn get_background_color(self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
|
||||
|
|
|
@ -1305,56 +1305,56 @@ pub unsafe fn from_untrusted_node_address(
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
pub trait LayoutNodeHelpers<'dom> {
|
||||
unsafe fn type_id_for_layout(&self) -> NodeTypeId;
|
||||
unsafe fn type_id_for_layout(self) -> NodeTypeId;
|
||||
|
||||
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 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<'dom, Document>;
|
||||
unsafe fn containing_shadow_root_for_layout(&self) -> Option<LayoutDom<'dom, 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;
|
||||
unsafe fn set_flag(&self, flag: NodeFlags, value: bool);
|
||||
unsafe fn is_element_for_layout(self) -> bool;
|
||||
unsafe fn get_flag(self, flag: NodeFlags) -> bool;
|
||||
unsafe fn set_flag(self, flag: NodeFlags, value: bool);
|
||||
|
||||
unsafe fn children_count(&self) -> u32;
|
||||
unsafe fn children_count(self) -> u32;
|
||||
|
||||
unsafe fn get_style_and_layout_data(&self) -> Option<OpaqueStyleAndLayoutData>;
|
||||
unsafe fn init_style_and_layout_data(&self, _: OpaqueStyleAndLayoutData);
|
||||
unsafe fn take_style_and_layout_data(&self) -> OpaqueStyleAndLayoutData;
|
||||
unsafe fn get_style_and_layout_data(self) -> Option<OpaqueStyleAndLayoutData>;
|
||||
unsafe fn init_style_and_layout_data(self, _: OpaqueStyleAndLayoutData);
|
||||
unsafe fn take_style_and_layout_data(self) -> OpaqueStyleAndLayoutData;
|
||||
|
||||
fn text_content(&self) -> String;
|
||||
fn selection(&self) -> Option<Range<usize>>;
|
||||
fn image_url(&self) -> Option<ServoUrl>;
|
||||
fn image_density(&self) -> Option<f64>;
|
||||
fn image_data(&self) -> Option<(Option<StdArc<Image>>, Option<ImageMetadata>)>;
|
||||
fn canvas_data(&self) -> Option<HTMLCanvasData>;
|
||||
fn media_data(&self) -> Option<HTMLMediaData>;
|
||||
fn svg_data(&self) -> Option<SVGSVGData>;
|
||||
fn iframe_browsing_context_id(&self) -> Option<BrowsingContextId>;
|
||||
fn iframe_pipeline_id(&self) -> Option<PipelineId>;
|
||||
fn opaque(&self) -> OpaqueNode;
|
||||
fn text_content(self) -> String;
|
||||
fn selection(self) -> Option<Range<usize>>;
|
||||
fn image_url(self) -> Option<ServoUrl>;
|
||||
fn image_density(self) -> Option<f64>;
|
||||
fn image_data(self) -> Option<(Option<StdArc<Image>>, Option<ImageMetadata>)>;
|
||||
fn canvas_data(self) -> Option<HTMLCanvasData>;
|
||||
fn media_data(self) -> Option<HTMLMediaData>;
|
||||
fn svg_data(self) -> Option<SVGSVGData>;
|
||||
fn iframe_browsing_context_id(self) -> Option<BrowsingContextId>;
|
||||
fn iframe_pipeline_id(self) -> Option<PipelineId>;
|
||||
fn opaque(self) -> OpaqueNode;
|
||||
}
|
||||
|
||||
impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> {
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn type_id_for_layout(&self) -> NodeTypeId {
|
||||
unsafe fn type_id_for_layout(self) -> NodeTypeId {
|
||||
(*self.unsafe_get()).type_id()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn is_element_for_layout(&self) -> bool {
|
||||
unsafe fn is_element_for_layout(self) -> bool {
|
||||
(*self.unsafe_get()).is::<Element>()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn composed_parent_node_ref(&self) -> Option<LayoutDom<'dom, 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<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn first_child_ref(&self) -> Option<LayoutDom<'dom, 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<'dom, 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<'dom, 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<'dom, 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<'dom, 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<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn containing_shadow_root_for_layout(&self) -> Option<LayoutDom<'dom, ShadowRoot>> {
|
||||
unsafe fn containing_shadow_root_for_layout(self) -> Option<LayoutDom<'dom, ShadowRoot>> {
|
||||
(*self.unsafe_get())
|
||||
.rare_data_for_layout()
|
||||
.as_ref()?
|
||||
|
@ -1410,13 +1410,13 @@ impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_flag(&self, flag: NodeFlags) -> bool {
|
||||
unsafe fn get_flag(self, flag: NodeFlags) -> bool {
|
||||
(*self.unsafe_get()).flags.get().contains(flag)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn set_flag(&self, flag: NodeFlags, value: bool) {
|
||||
unsafe fn set_flag(self, flag: NodeFlags, value: bool) {
|
||||
let this = self.unsafe_get();
|
||||
let mut flags = (*this).flags.get();
|
||||
|
||||
|
@ -1431,33 +1431,33 @@ impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn children_count(&self) -> u32 {
|
||||
unsafe fn children_count(self) -> u32 {
|
||||
(*self.unsafe_get()).children_count.get()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_style_and_layout_data(&self) -> Option<OpaqueStyleAndLayoutData> {
|
||||
unsafe fn get_style_and_layout_data(self) -> Option<OpaqueStyleAndLayoutData> {
|
||||
(*self.unsafe_get()).style_and_layout_data.get()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn init_style_and_layout_data(&self, val: OpaqueStyleAndLayoutData) {
|
||||
unsafe fn init_style_and_layout_data(self, val: OpaqueStyleAndLayoutData) {
|
||||
debug_assert!((*self.unsafe_get()).style_and_layout_data.get().is_none());
|
||||
(*self.unsafe_get()).style_and_layout_data.set(Some(val));
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn take_style_and_layout_data(&self) -> OpaqueStyleAndLayoutData {
|
||||
unsafe fn take_style_and_layout_data(self) -> OpaqueStyleAndLayoutData {
|
||||
let val = (*self.unsafe_get()).style_and_layout_data.get().unwrap();
|
||||
(*self.unsafe_get()).style_and_layout_data.set(None);
|
||||
val
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn text_content(&self) -> String {
|
||||
fn text_content(self) -> String {
|
||||
if let Some(text) = self.downcast::<Text>() {
|
||||
return unsafe { text.upcast().data_for_layout().to_owned() };
|
||||
}
|
||||
|
@ -1474,7 +1474,7 @@ impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn selection(&self) -> Option<Range<usize>> {
|
||||
fn selection(self) -> Option<Range<usize>> {
|
||||
if let Some(area) = self.downcast::<HTMLTextAreaElement>() {
|
||||
return unsafe { area.selection_for_layout() };
|
||||
}
|
||||
|
@ -1487,7 +1487,7 @@ impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn image_url(&self) -> Option<ServoUrl> {
|
||||
fn image_url(self) -> Option<ServoUrl> {
|
||||
unsafe {
|
||||
self.downcast::<HTMLImageElement>()
|
||||
.expect("not an image!")
|
||||
|
@ -1496,12 +1496,12 @@ impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn image_data(&self) -> Option<(Option<StdArc<Image>>, Option<ImageMetadata>)> {
|
||||
fn image_data(self) -> Option<(Option<StdArc<Image>>, Option<ImageMetadata>)> {
|
||||
unsafe { self.downcast::<HTMLImageElement>().map(|e| e.image_data()) }
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn image_density(&self) -> Option<f64> {
|
||||
fn image_density(self) -> Option<f64> {
|
||||
unsafe {
|
||||
self.downcast::<HTMLImageElement>()
|
||||
.expect("not an image!")
|
||||
|
@ -1509,28 +1509,28 @@ impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> {
|
|||
}
|
||||
}
|
||||
|
||||
fn canvas_data(&self) -> Option<HTMLCanvasData> {
|
||||
fn canvas_data(self) -> Option<HTMLCanvasData> {
|
||||
self.downcast::<HTMLCanvasElement>()
|
||||
.map(|canvas| canvas.data())
|
||||
}
|
||||
|
||||
fn media_data(&self) -> Option<HTMLMediaData> {
|
||||
fn media_data(self) -> Option<HTMLMediaData> {
|
||||
self.downcast::<HTMLMediaElement>()
|
||||
.map(|media| media.data())
|
||||
}
|
||||
|
||||
fn svg_data(&self) -> Option<SVGSVGData> {
|
||||
fn svg_data(self) -> Option<SVGSVGData> {
|
||||
self.downcast::<SVGSVGElement>().map(|svg| svg.data())
|
||||
}
|
||||
|
||||
fn iframe_browsing_context_id(&self) -> Option<BrowsingContextId> {
|
||||
fn iframe_browsing_context_id(self) -> Option<BrowsingContextId> {
|
||||
let iframe_element = self
|
||||
.downcast::<HTMLIFrameElement>()
|
||||
.expect("not an iframe element!");
|
||||
iframe_element.browsing_context_id()
|
||||
}
|
||||
|
||||
fn iframe_pipeline_id(&self) -> Option<PipelineId> {
|
||||
fn iframe_pipeline_id(self) -> Option<PipelineId> {
|
||||
let iframe_element = self
|
||||
.downcast::<HTMLIFrameElement>()
|
||||
.expect("not an iframe element!");
|
||||
|
@ -1538,7 +1538,7 @@ impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn opaque(&self) -> OpaqueNode {
|
||||
fn opaque(self) -> OpaqueNode {
|
||||
unsafe { OpaqueNode(self.get_jsobject() as usize) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -240,12 +240,10 @@ impl ShadowRootMethods for ShadowRoot {
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
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>;
|
||||
unsafe fn get_host_for_layout(self) -> LayoutDom<'dom, Element>;
|
||||
unsafe fn get_style_data_for_layout(self) -> &'dom AuthorStyles<StyleSheetInDocument>;
|
||||
unsafe fn flush_stylesheets<E: TElement>(
|
||||
&self,
|
||||
self,
|
||||
device: &Device,
|
||||
quirks_mode: QuirksMode,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
|
@ -255,7 +253,7 @@ pub trait LayoutShadowRootHelpers<'dom> {
|
|||
impl<'dom> LayoutShadowRootHelpers<'dom> for LayoutDom<'dom, ShadowRoot> {
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_host_for_layout(&self) -> LayoutDom<'dom, Element> {
|
||||
unsafe fn get_host_for_layout(self) -> LayoutDom<'dom, Element> {
|
||||
(*self.unsafe_get())
|
||||
.host
|
||||
.get_inner_as_layout()
|
||||
|
@ -264,16 +262,14 @@ impl<'dom> LayoutShadowRootHelpers<'dom> for LayoutDom<'dom, ShadowRoot> {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_style_data_for_layout<'a, E: TElement>(
|
||||
&self,
|
||||
) -> &'a AuthorStyles<StyleSheetInDocument> {
|
||||
unsafe fn get_style_data_for_layout(self) -> &'dom AuthorStyles<StyleSheetInDocument> {
|
||||
(*self.unsafe_get()).author_styles.borrow_for_layout()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn flush_stylesheets<E: TElement>(
|
||||
&self,
|
||||
self,
|
||||
device: &Device,
|
||||
quirks_mode: QuirksMode,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
|
|
|
@ -49,12 +49,12 @@ impl SVGSVGElement {
|
|||
}
|
||||
|
||||
pub trait LayoutSVGSVGElementHelpers {
|
||||
fn data(&self) -> SVGSVGData;
|
||||
fn data(self) -> SVGSVGData;
|
||||
}
|
||||
|
||||
impl LayoutSVGSVGElementHelpers for LayoutDom<'_, SVGSVGElement> {
|
||||
#[allow(unsafe_code, non_snake_case)]
|
||||
fn data(&self) -> SVGSVGData {
|
||||
fn data(self) -> SVGSVGData {
|
||||
unsafe {
|
||||
let SVG = &*self.unsafe_get();
|
||||
|
||||
|
|
|
@ -3886,7 +3886,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
|
||||
impl LayoutCanvasWebGLRenderingContextHelpers for LayoutDom<'_, WebGL2RenderingContext> {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn canvas_data_source(&self) -> HTMLCanvasDataSource {
|
||||
unsafe fn canvas_data_source(self) -> HTMLCanvasDataSource {
|
||||
let this = &*self.unsafe_get();
|
||||
(*this.base.to_layout().unsafe_get()).layout_handle()
|
||||
}
|
||||
|
|
|
@ -4447,12 +4447,12 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
|
||||
pub trait LayoutCanvasWebGLRenderingContextHelpers {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn canvas_data_source(&self) -> HTMLCanvasDataSource;
|
||||
unsafe fn canvas_data_source(self) -> HTMLCanvasDataSource;
|
||||
}
|
||||
|
||||
impl LayoutCanvasWebGLRenderingContextHelpers for LayoutDom<'_, WebGLRenderingContext> {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn canvas_data_source(&self) -> HTMLCanvasDataSource {
|
||||
unsafe fn canvas_data_source(self) -> HTMLCanvasDataSource {
|
||||
(*self.unsafe_get()).layout_handle()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue