mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Merge RawLayoutElementHelpers into LayoutElementHelpers
This commit is contained in:
parent
3b504148d5
commit
0bda174823
17 changed files with 86 additions and 97 deletions
|
@ -48,7 +48,6 @@ use script::layout_exports::{Document, Element, Node, Text};
|
|||
use script::layout_exports::{LayoutCharacterDataHelpers, LayoutDocumentHelpers};
|
||||
use script::layout_exports::{
|
||||
LayoutDom, LayoutElementHelpers, LayoutNodeHelpers, LayoutShadowRootHelpers,
|
||||
RawLayoutElementHelpers,
|
||||
};
|
||||
use script_layout_interface::wrapper_traits::{
|
||||
DangerousThreadSafeLayoutNode, GetLayoutData, LayoutNode,
|
||||
|
@ -699,12 +698,12 @@ impl<'le> ServoLayoutElement<'le> {
|
|||
|
||||
#[inline]
|
||||
fn get_attr_enum(&self, namespace: &Namespace, name: &LocalName) -> Option<&AttrValue> {
|
||||
unsafe { (*self.element.unsafe_get()).get_attr_for_layout(namespace, name) }
|
||||
unsafe { self.element.get_attr_for_layout(namespace, name) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get_attr(&self, namespace: &Namespace, name: &LocalName) -> Option<&str> {
|
||||
unsafe { (*self.element.unsafe_get()).get_attr_val_for_layout(namespace, name) }
|
||||
unsafe { self.element.get_attr_val_for_layout(namespace, name) }
|
||||
}
|
||||
|
||||
fn get_style_data(&self) -> Option<&StyleData> {
|
||||
|
@ -807,8 +806,7 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
|
|||
.get_attr_enum(ns, local_name)
|
||||
.map_or(false, |value| value.eval_selector(operation)),
|
||||
NamespaceConstraint::Any => {
|
||||
let values =
|
||||
unsafe { (*self.element.unsafe_get()).get_attr_vals_for_layout(local_name) };
|
||||
let values = unsafe { self.element.get_attr_vals_for_layout(local_name) };
|
||||
values.iter().any(|value| value.eval_selector(operation))
|
||||
},
|
||||
}
|
||||
|
@ -881,7 +879,8 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
|
|||
NonTSPseudoClass::Lang(ref lang) => self.match_element_lang(None, &*lang),
|
||||
|
||||
NonTSPseudoClass::ServoNonZeroBorder => unsafe {
|
||||
match (*self.element.unsafe_get())
|
||||
match self
|
||||
.element
|
||||
.get_attr_for_layout(&ns!(), &local_name!("border"))
|
||||
{
|
||||
None | Some(&AttrValue::UInt(_, 0)) => false,
|
||||
|
@ -924,7 +923,8 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
|
|||
)) |
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||
HTMLElementTypeId::HTMLLinkElement,
|
||||
)) => (*self.element.unsafe_get())
|
||||
)) => self
|
||||
.element
|
||||
.get_attr_val_for_layout(&ns!(), &local_name!("href"))
|
||||
.is_some(),
|
||||
_ => false,
|
||||
|
@ -1440,9 +1440,7 @@ impl<'le> ::selectors::Element for ServoThreadSafeLayoutElement<'le> {
|
|||
.get_attr_enum(ns, local_name)
|
||||
.map_or(false, |value| value.eval_selector(operation)),
|
||||
NamespaceConstraint::Any => {
|
||||
let values = unsafe {
|
||||
(*self.element.element.unsafe_get()).get_attr_vals_for_layout(local_name)
|
||||
};
|
||||
let values = unsafe { self.element.element.get_attr_vals_for_layout(local_name) };
|
||||
values.iter().any(|v| v.eval_selector(operation))
|
||||
},
|
||||
}
|
||||
|
|
|
@ -48,7 +48,6 @@ use script::layout_exports::{Document, Element, Node, Text};
|
|||
use script::layout_exports::{LayoutCharacterDataHelpers, LayoutDocumentHelpers};
|
||||
use script::layout_exports::{
|
||||
LayoutDom, LayoutElementHelpers, LayoutNodeHelpers, LayoutShadowRootHelpers,
|
||||
RawLayoutElementHelpers,
|
||||
};
|
||||
use script_layout_interface::wrapper_traits::{
|
||||
DangerousThreadSafeLayoutNode, GetLayoutData, LayoutNode,
|
||||
|
@ -706,12 +705,12 @@ impl<'le> ServoLayoutElement<'le> {
|
|||
|
||||
#[inline]
|
||||
fn get_attr_enum(&self, namespace: &Namespace, name: &LocalName) -> Option<&AttrValue> {
|
||||
unsafe { (*self.element.unsafe_get()).get_attr_for_layout(namespace, name) }
|
||||
unsafe { self.element.get_attr_for_layout(namespace, name) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get_attr(&self, namespace: &Namespace, name: &LocalName) -> Option<&str> {
|
||||
unsafe { (*self.element.unsafe_get()).get_attr_val_for_layout(namespace, name) }
|
||||
unsafe { self.element.get_attr_val_for_layout(namespace, name) }
|
||||
}
|
||||
|
||||
fn get_style_data(&self) -> Option<&StyleData> {
|
||||
|
@ -814,8 +813,7 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
|
|||
.get_attr_enum(ns, local_name)
|
||||
.map_or(false, |value| value.eval_selector(operation)),
|
||||
NamespaceConstraint::Any => {
|
||||
let values =
|
||||
unsafe { (*self.element.unsafe_get()).get_attr_vals_for_layout(local_name) };
|
||||
let values = unsafe { self.element.get_attr_vals_for_layout(local_name) };
|
||||
values.iter().any(|value| value.eval_selector(operation))
|
||||
},
|
||||
}
|
||||
|
@ -888,7 +886,8 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
|
|||
NonTSPseudoClass::Lang(ref lang) => self.match_element_lang(None, &*lang),
|
||||
|
||||
NonTSPseudoClass::ServoNonZeroBorder => unsafe {
|
||||
match (*self.element.unsafe_get())
|
||||
match self
|
||||
.element
|
||||
.get_attr_for_layout(&ns!(), &local_name!("border"))
|
||||
{
|
||||
None | Some(&AttrValue::UInt(_, 0)) => false,
|
||||
|
@ -931,7 +930,8 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
|
|||
)) |
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||
HTMLElementTypeId::HTMLLinkElement,
|
||||
)) => (*self.element.unsafe_get())
|
||||
)) => self
|
||||
.element
|
||||
.get_attr_val_for_layout(&ns!(), &local_name!("href"))
|
||||
.is_some(),
|
||||
_ => false,
|
||||
|
@ -1447,9 +1447,7 @@ impl<'le> ::selectors::Element for ServoThreadSafeLayoutElement<'le> {
|
|||
.get_attr_enum(ns, local_name)
|
||||
.map_or(false, |value| value.eval_selector(operation)),
|
||||
NamespaceConstraint::Any => {
|
||||
let values = unsafe {
|
||||
(*self.element.element.unsafe_get()).get_attr_vals_for_layout(local_name)
|
||||
};
|
||||
let values = unsafe { self.element.element.get_attr_vals_for_layout(local_name) };
|
||||
values.iter().any(|v| v.eval_selector(operation))
|
||||
},
|
||||
}
|
||||
|
|
|
@ -595,21 +595,20 @@ pub trait LayoutElementHelpers<'dom> {
|
|||
/// The shadow root this element is a host of.
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_shadow_root_for_layout(self) -> Option<LayoutDom<'dom, ShadowRoot>>;
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub trait RawLayoutElementHelpers {
|
||||
unsafe fn get_attr_for_layout<'a>(
|
||||
&'a self,
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_attr_for_layout(
|
||||
self,
|
||||
namespace: &Namespace,
|
||||
name: &LocalName,
|
||||
) -> Option<&'a AttrValue>;
|
||||
unsafe fn get_attr_val_for_layout<'a>(
|
||||
&'a self,
|
||||
) -> Option<&'dom AttrValue>;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_attr_val_for_layout(
|
||||
self,
|
||||
namespace: &Namespace,
|
||||
name: &LocalName,
|
||||
) -> Option<&'a str>;
|
||||
unsafe fn get_attr_vals_for_layout<'a>(&'a self, name: &LocalName) -> Vec<&'a AttrValue>;
|
||||
) -> Option<&'dom str>;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_attr_vals_for_layout(self, name: &LocalName) -> Vec<&'dom AttrValue>;
|
||||
}
|
||||
|
||||
impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
||||
|
@ -765,7 +764,7 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
|||
|
||||
let size = if let Some(this) = self.downcast::<HTMLInputElement>() {
|
||||
// FIXME(pcwalton): More use of atoms, please!
|
||||
match (*self.unsafe_get()).get_attr_val_for_layout(&ns!(), &local_name!("type")) {
|
||||
match self.get_attr_val_for_layout(&ns!(), &local_name!("type")) {
|
||||
// Not text entry widget
|
||||
Some("hidden") |
|
||||
Some("date") |
|
||||
|
@ -1012,15 +1011,15 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
|||
let mut current_node = Some(self.upcast::<Node>());
|
||||
while let Some(node) = current_node {
|
||||
current_node = node.composed_parent_node_ref();
|
||||
match node.downcast::<Element>().map(|el| el.unsafe_get()) {
|
||||
match node.downcast::<Element>() {
|
||||
Some(elem) => {
|
||||
if let Some(attr) =
|
||||
(*elem).get_attr_val_for_layout(&ns!(xml), &local_name!("lang"))
|
||||
elem.get_attr_val_for_layout(&ns!(xml), &local_name!("lang"))
|
||||
{
|
||||
return attr.to_owned();
|
||||
}
|
||||
if let Some(attr) =
|
||||
(*elem).get_attr_val_for_layout(&ns!(), &local_name!("lang"))
|
||||
elem.get_attr_val_for_layout(&ns!(), &local_name!("lang"))
|
||||
{
|
||||
return attr.to_owned();
|
||||
}
|
||||
|
@ -1066,31 +1065,31 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
|||
.as_ref()
|
||||
.map(|sr| sr.to_layout())
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl RawLayoutElementHelpers for Element {
|
||||
#[allow(unsafe_code)]
|
||||
#[inline]
|
||||
unsafe fn get_attr_for_layout<'a>(
|
||||
&'a self,
|
||||
unsafe fn get_attr_for_layout(
|
||||
self,
|
||||
namespace: &Namespace,
|
||||
name: &LocalName,
|
||||
) -> Option<&'a AttrValue> {
|
||||
get_attr_for_layout(self, namespace, name).map(|attr| attr.value())
|
||||
) -> Option<&'dom AttrValue> {
|
||||
get_attr_for_layout(self.unsafe_get(), namespace, name).map(|attr| attr.value())
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
#[inline]
|
||||
unsafe fn get_attr_val_for_layout<'a>(
|
||||
&'a self,
|
||||
unsafe fn get_attr_val_for_layout(
|
||||
self,
|
||||
namespace: &Namespace,
|
||||
name: &LocalName,
|
||||
) -> Option<&'a str> {
|
||||
get_attr_for_layout(self, namespace, name).map(|attr| attr.as_str())
|
||||
) -> Option<&'dom str> {
|
||||
get_attr_for_layout(self.unsafe_get(), namespace, name).map(|attr| attr.as_str())
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
#[inline]
|
||||
unsafe fn get_attr_vals_for_layout<'a>(&'a self, name: &LocalName) -> Vec<&'a AttrValue> {
|
||||
let attrs = self.attrs.borrow_for_layout();
|
||||
unsafe fn get_attr_vals_for_layout(self, name: &LocalName) -> Vec<&'dom AttrValue> {
|
||||
let attrs = self.unsafe_get().attrs.borrow_for_layout();
|
||||
attrs
|
||||
.iter()
|
||||
.filter_map(|attr| {
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::dom::bindings::inheritance::Castable;
|
|||
use crate::dom::bindings::root::{DomRoot, LayoutDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
|
||||
use crate::dom::element::{AttributeMutation, Element, LayoutElementHelpers};
|
||||
use crate::dom::eventtarget::EventTarget;
|
||||
use crate::dom::htmlelement::HTMLElement;
|
||||
use crate::dom::node::{document_from_node, window_from_node, BindContext, Node};
|
||||
|
@ -103,7 +103,7 @@ impl HTMLBodyElementLayoutHelpers for LayoutDom<'_, HTMLBodyElement> {
|
|||
#[allow(unsafe_code)]
|
||||
fn get_background_color(self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
|
||||
.and_then(AttrValue::as_color)
|
||||
.cloned()
|
||||
|
@ -113,7 +113,7 @@ impl HTMLBodyElementLayoutHelpers for LayoutDom<'_, HTMLBodyElement> {
|
|||
#[allow(unsafe_code)]
|
||||
fn get_color(self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("text"))
|
||||
.and_then(AttrValue::as_color)
|
||||
.cloned()
|
||||
|
@ -123,7 +123,7 @@ impl HTMLBodyElementLayoutHelpers for LayoutDom<'_, HTMLBodyElement> {
|
|||
#[allow(unsafe_code)]
|
||||
fn get_background(self) -> Option<ServoUrl> {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("background"))
|
||||
.and_then(AttrValue::as_resolved_url)
|
||||
.cloned()
|
||||
|
|
|
@ -18,7 +18,7 @@ use crate::dom::canvasrenderingcontext2d::{
|
|||
CanvasRenderingContext2D, LayoutCanvasRenderingContext2DHelpers,
|
||||
};
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
|
||||
use crate::dom::element::{AttributeMutation, Element, LayoutElementHelpers};
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::htmlelement::HTMLElement;
|
||||
use crate::dom::node::{window_from_node, Node};
|
||||
|
@ -124,8 +124,7 @@ impl LayoutHTMLCanvasElementHelpers for LayoutDom<'_, HTMLCanvasElement> {
|
|||
#[allow(unsafe_code)]
|
||||
fn data(self) -> HTMLCanvasData {
|
||||
unsafe {
|
||||
let canvas = &*self.unsafe_get();
|
||||
let source = match canvas.context.borrow_for_layout().as_ref() {
|
||||
let source = match self.unsafe_get().context.borrow_for_layout().as_ref() {
|
||||
Some(&CanvasContext::Context2d(ref context)) => {
|
||||
HTMLCanvasDataSource::Image(Some(context.to_layout().get_ipc_renderer()))
|
||||
},
|
||||
|
@ -138,10 +137,10 @@ impl LayoutHTMLCanvasElementHelpers for LayoutDom<'_, HTMLCanvasElement> {
|
|||
None => HTMLCanvasDataSource::Image(None),
|
||||
};
|
||||
|
||||
let width_attr = canvas
|
||||
let width_attr = self
|
||||
.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("width"));
|
||||
let height_attr = canvas
|
||||
let height_attr = self
|
||||
.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("height"));
|
||||
HTMLCanvasData {
|
||||
|
@ -156,7 +155,7 @@ impl LayoutHTMLCanvasElementHelpers for LayoutDom<'_, HTMLCanvasElement> {
|
|||
#[allow(unsafe_code)]
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("width"))
|
||||
.map(AttrValue::as_uint_px_dimension)
|
||||
.unwrap_or(LengthOrPercentageOrAuto::Auto)
|
||||
|
@ -166,7 +165,7 @@ impl LayoutHTMLCanvasElementHelpers for LayoutDom<'_, HTMLCanvasElement> {
|
|||
#[allow(unsafe_code)]
|
||||
fn get_height(self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("height"))
|
||||
.map(AttrValue::as_uint_px_dimension)
|
||||
.unwrap_or(LengthOrPercentageOrAuto::Auto)
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::dom::bindings::inheritance::Castable;
|
|||
use crate::dom::bindings::root::{DomRoot, LayoutDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::{Element, RawLayoutElementHelpers};
|
||||
use crate::dom::element::{Element, LayoutElementHelpers};
|
||||
use crate::dom::htmlelement::HTMLElement;
|
||||
use crate::dom::node::Node;
|
||||
use crate::dom::virtualmethods::VirtualMethods;
|
||||
|
@ -110,7 +110,7 @@ impl HTMLFontElementLayoutHelpers for LayoutDom<'_, HTMLFontElement> {
|
|||
#[allow(unsafe_code)]
|
||||
fn get_color(self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("color"))
|
||||
.and_then(AttrValue::as_color)
|
||||
.cloned()
|
||||
|
@ -120,7 +120,7 @@ impl HTMLFontElementLayoutHelpers for LayoutDom<'_, HTMLFontElement> {
|
|||
#[allow(unsafe_code)]
|
||||
fn get_face(self) -> Option<Atom> {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("face"))
|
||||
.map(AttrValue::as_atom)
|
||||
.cloned()
|
||||
|
@ -130,7 +130,7 @@ impl HTMLFontElementLayoutHelpers for LayoutDom<'_, HTMLFontElement> {
|
|||
#[allow(unsafe_code)]
|
||||
fn get_size(self) -> Option<u32> {
|
||||
let size = unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("size"))
|
||||
};
|
||||
match size {
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::dom::bindings::inheritance::Castable;
|
|||
use crate::dom::bindings::root::{DomRoot, LayoutDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::{Element, RawLayoutElementHelpers};
|
||||
use crate::dom::element::{Element, LayoutElementHelpers};
|
||||
use crate::dom::htmlelement::HTMLElement;
|
||||
use crate::dom::node::Node;
|
||||
use crate::dom::virtualmethods::VirtualMethods;
|
||||
|
@ -74,7 +74,7 @@ impl HTMLHRLayoutHelpers for LayoutDom<'_, HTMLHRElement> {
|
|||
#[allow(unsafe_code)]
|
||||
fn get_color(self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("color"))
|
||||
.and_then(AttrValue::as_color)
|
||||
.cloned()
|
||||
|
@ -84,7 +84,7 @@ impl HTMLHRLayoutHelpers for LayoutDom<'_, HTMLHRElement> {
|
|||
#[allow(unsafe_code)]
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("width"))
|
||||
.map(AttrValue::as_dimension)
|
||||
.cloned()
|
||||
|
|
|
@ -14,7 +14,7 @@ use crate::dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom};
|
|||
use crate::dom::bindings::str::{DOMString, USVString};
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::domtokenlist::DOMTokenList;
|
||||
use crate::dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
|
||||
use crate::dom::element::{AttributeMutation, Element, LayoutElementHelpers};
|
||||
use crate::dom::eventtarget::EventTarget;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::htmlelement::HTMLElement;
|
||||
|
@ -502,7 +502,7 @@ impl HTMLIFrameElementLayoutMethods for LayoutDom<'_, HTMLIFrameElement> {
|
|||
#[allow(unsafe_code)]
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("width"))
|
||||
.map(AttrValue::as_dimension)
|
||||
.cloned()
|
||||
|
@ -513,7 +513,7 @@ impl HTMLIFrameElementLayoutMethods for LayoutDom<'_, HTMLIFrameElement> {
|
|||
#[allow(unsafe_code)]
|
||||
fn get_height(self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("height"))
|
||||
.map(AttrValue::as_dimension)
|
||||
.cloned()
|
||||
|
|
|
@ -22,7 +22,7 @@ use crate::dom::document::Document;
|
|||
use crate::dom::element::{cors_setting_for_element, referrer_policy_for_element};
|
||||
use crate::dom::element::{reflect_cross_origin_attribute, set_cross_origin_attribute};
|
||||
use crate::dom::element::{
|
||||
AttributeMutation, CustomElementCreationMode, Element, ElementCreator, RawLayoutElementHelpers,
|
||||
AttributeMutation, CustomElementCreationMode, Element, ElementCreator, LayoutElementHelpers,
|
||||
};
|
||||
use crate::dom::event::Event;
|
||||
use crate::dom::eventtarget::EventTarget;
|
||||
|
@ -1418,7 +1418,7 @@ impl LayoutHTMLImageElementHelpers for LayoutDom<'_, HTMLImageElement> {
|
|||
#[allow(unsafe_code)]
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("width"))
|
||||
.map(AttrValue::as_dimension)
|
||||
.cloned()
|
||||
|
@ -1429,7 +1429,7 @@ impl LayoutHTMLImageElementHelpers for LayoutDom<'_, HTMLImageElement> {
|
|||
#[allow(unsafe_code)]
|
||||
fn get_height(self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("height"))
|
||||
.map(AttrValue::as_dimension)
|
||||
.cloned()
|
||||
|
|
|
@ -18,9 +18,7 @@ use crate::dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom};
|
|||
use crate::dom::bindings::str::{DOMString, USVString};
|
||||
use crate::dom::compositionevent::CompositionEvent;
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::{
|
||||
AttributeMutation, Element, LayoutElementHelpers, RawLayoutElementHelpers,
|
||||
};
|
||||
use crate::dom::element::{AttributeMutation, Element, LayoutElementHelpers};
|
||||
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use crate::dom::eventtarget::EventTarget;
|
||||
use crate::dom::file::File;
|
||||
|
@ -735,7 +733,6 @@ impl<'dom> LayoutHTMLInputElementHelpers<'dom> for LayoutDom<'dom, HTMLInputElem
|
|||
unsafe {
|
||||
input
|
||||
.upcast::<Element>()
|
||||
.unsafe_get()
|
||||
.get_attr_val_for_layout(&ns!(), &local_name!("value"))
|
||||
.unwrap_or(default)
|
||||
.into()
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::dom::bindings::root::DomRoot;
|
|||
use crate::dom::bindings::root::LayoutDom;
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::{Element, RawLayoutElementHelpers};
|
||||
use crate::dom::element::{Element, LayoutElementHelpers};
|
||||
use crate::dom::htmlelement::HTMLElement;
|
||||
use crate::dom::htmltablerowelement::HTMLTableRowElement;
|
||||
use crate::dom::node::Node;
|
||||
|
@ -108,7 +108,7 @@ pub trait HTMLTableCellElementLayoutHelpers {
|
|||
impl HTMLTableCellElementLayoutHelpers for LayoutDom<'_, HTMLTableCellElement> {
|
||||
fn get_background_color(self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
|
||||
.and_then(AttrValue::as_color)
|
||||
.cloned()
|
||||
|
@ -117,7 +117,7 @@ impl HTMLTableCellElementLayoutHelpers for LayoutDom<'_, HTMLTableCellElement> {
|
|||
|
||||
fn get_colspan(self) -> Option<u32> {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("colspan"))
|
||||
.map(AttrValue::as_uint)
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ impl HTMLTableCellElementLayoutHelpers for LayoutDom<'_, HTMLTableCellElement> {
|
|||
|
||||
fn get_rowspan(self) -> Option<u32> {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("rowspan"))
|
||||
.map(AttrValue::as_uint)
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ impl HTMLTableCellElementLayoutHelpers for LayoutDom<'_, HTMLTableCellElement> {
|
|||
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("width"))
|
||||
.map(AttrValue::as_dimension)
|
||||
.cloned()
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::dom::bindings::inheritance::Castable;
|
|||
use crate::dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
|
||||
use crate::dom::element::{AttributeMutation, Element, LayoutElementHelpers};
|
||||
use crate::dom::htmlcollection::{CollectionFilter, HTMLCollection};
|
||||
use crate::dom::htmlelement::HTMLElement;
|
||||
use crate::dom::htmltablecaptionelement::HTMLTableCaptionElement;
|
||||
|
@ -416,7 +416,7 @@ impl HTMLTableElementLayoutHelpers for LayoutDom<'_, HTMLTableElement> {
|
|||
#[allow(unsafe_code)]
|
||||
fn get_background_color(self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
|
||||
.and_then(AttrValue::as_color)
|
||||
.cloned()
|
||||
|
@ -436,7 +436,7 @@ impl HTMLTableElementLayoutHelpers for LayoutDom<'_, HTMLTableElement> {
|
|||
#[allow(unsafe_code)]
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("width"))
|
||||
.map(AttrValue::as_dimension)
|
||||
.cloned()
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::dom::bindings::inheritance::Castable;
|
|||
use crate::dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::{Element, RawLayoutElementHelpers};
|
||||
use crate::dom::element::{Element, LayoutElementHelpers};
|
||||
use crate::dom::htmlcollection::{CollectionFilter, HTMLCollection};
|
||||
use crate::dom::htmlelement::HTMLElement;
|
||||
use crate::dom::htmltablecellelement::HTMLTableCellElement;
|
||||
|
@ -153,7 +153,7 @@ pub trait HTMLTableRowElementLayoutHelpers {
|
|||
impl HTMLTableRowElementLayoutHelpers for LayoutDom<'_, HTMLTableRowElement> {
|
||||
fn get_background_color(self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
|
||||
.and_then(AttrValue::as_color)
|
||||
.cloned()
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::dom::bindings::inheritance::Castable;
|
|||
use crate::dom::bindings::root::{DomRoot, LayoutDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::{Element, RawLayoutElementHelpers};
|
||||
use crate::dom::element::{Element, LayoutElementHelpers};
|
||||
use crate::dom::htmlcollection::{CollectionFilter, HTMLCollection};
|
||||
use crate::dom::htmlelement::HTMLElement;
|
||||
use crate::dom::htmltablerowelement::HTMLTableRowElement;
|
||||
|
@ -91,7 +91,7 @@ pub trait HTMLTableSectionElementLayoutHelpers {
|
|||
impl HTMLTableSectionElementLayoutHelpers for LayoutDom<'_, HTMLTableSectionElement> {
|
||||
fn get_background_color(self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
|
||||
.and_then(AttrValue::as_color)
|
||||
.cloned()
|
||||
|
|
|
@ -14,7 +14,7 @@ use crate::dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom};
|
|||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::compositionevent::CompositionEvent;
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::RawLayoutElementHelpers;
|
||||
use crate::dom::element::LayoutElementHelpers;
|
||||
use crate::dom::element::{AttributeMutation, Element};
|
||||
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
|
@ -99,7 +99,7 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutDom<'_, HTMLTextAreaElement> {
|
|||
#[allow(unsafe_code)]
|
||||
fn get_cols(self) -> u32 {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("cols"))
|
||||
.map_or(DEFAULT_COLS, AttrValue::as_uint)
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutDom<'_, HTMLTextAreaElement> {
|
|||
#[allow(unsafe_code)]
|
||||
fn get_rows(self) -> u32 {
|
||||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
self.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("rows"))
|
||||
.map_or(DEFAULT_ROWS, AttrValue::as_uint)
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::dom::bindings::inheritance::Castable;
|
|||
use crate::dom::bindings::root::{DomRoot, LayoutDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
|
||||
use crate::dom::element::{AttributeMutation, Element, LayoutElementHelpers};
|
||||
use crate::dom::node::Node;
|
||||
use crate::dom::svggraphicselement::SVGGraphicsElement;
|
||||
use crate::dom::virtualmethods::VirtualMethods;
|
||||
|
@ -56,12 +56,10 @@ impl LayoutSVGSVGElementHelpers for LayoutDom<'_, SVGSVGElement> {
|
|||
#[allow(unsafe_code, non_snake_case)]
|
||||
fn data(self) -> SVGSVGData {
|
||||
unsafe {
|
||||
let SVG = &*self.unsafe_get();
|
||||
|
||||
let width_attr = SVG
|
||||
let width_attr = self
|
||||
.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("width"));
|
||||
let height_attr = SVG
|
||||
let height_attr = self
|
||||
.upcast::<Element>()
|
||||
.get_attr_for_layout(&ns!(), &local_name!("height"));
|
||||
SVGSVGData {
|
||||
|
|
|
@ -131,7 +131,7 @@ pub mod layout_exports {
|
|||
pub use crate::dom::bindings::root::LayoutDom;
|
||||
pub use crate::dom::characterdata::LayoutCharacterDataHelpers;
|
||||
pub use crate::dom::document::{Document, LayoutDocumentHelpers};
|
||||
pub use crate::dom::element::{Element, LayoutElementHelpers, RawLayoutElementHelpers};
|
||||
pub use crate::dom::element::{Element, LayoutElementHelpers};
|
||||
pub use crate::dom::node::NodeFlags;
|
||||
pub use crate::dom::node::{LayoutNodeHelpers, Node};
|
||||
pub use crate::dom::shadowroot::{LayoutShadowRootHelpers, ShadowRoot};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue