mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Make a bunch or trivial LayoutElementHelpers safe
This commit is contained in:
parent
a913c6650d
commit
fbc3e430ab
3 changed files with 15 additions and 25 deletions
|
@ -443,7 +443,7 @@ impl<'le> TElement for ServoLayoutElement<'le> {
|
|||
}
|
||||
|
||||
fn is_html_element(&self) -> bool {
|
||||
unsafe { self.element.is_html_element() }
|
||||
self.element.is_html_element()
|
||||
}
|
||||
|
||||
fn is_mathml_element(&self) -> bool {
|
||||
|
@ -954,14 +954,12 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
|
|||
}
|
||||
|
||||
fn is_html_slot_element(&self) -> bool {
|
||||
unsafe { self.element.is_html_element() && self.local_name() == &local_name!("slot") }
|
||||
self.element.is_html_element() && self.local_name() == &local_name!("slot")
|
||||
}
|
||||
|
||||
fn is_html_element_in_html_document(&self) -> bool {
|
||||
unsafe {
|
||||
if !self.element.is_html_element() {
|
||||
return false;
|
||||
}
|
||||
if !self.element.is_html_element() {
|
||||
return false;
|
||||
}
|
||||
|
||||
self.as_node().owner_doc().is_html_document()
|
||||
|
|
|
@ -450,7 +450,7 @@ impl<'le> TElement for ServoLayoutElement<'le> {
|
|||
}
|
||||
|
||||
fn is_html_element(&self) -> bool {
|
||||
unsafe { self.element.is_html_element() }
|
||||
self.element.is_html_element()
|
||||
}
|
||||
|
||||
fn is_mathml_element(&self) -> bool {
|
||||
|
@ -961,14 +961,12 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
|
|||
}
|
||||
|
||||
fn is_html_slot_element(&self) -> bool {
|
||||
unsafe { self.element.is_html_element() && self.local_name() == &local_name!("slot") }
|
||||
self.element.is_html_element() && self.local_name() == &local_name!("slot")
|
||||
}
|
||||
|
||||
fn is_html_element_in_html_document(&self) -> bool {
|
||||
unsafe {
|
||||
if !self.element.is_html_element() {
|
||||
return false;
|
||||
}
|
||||
if !self.element.is_html_element() {
|
||||
return false;
|
||||
}
|
||||
|
||||
self.as_node().owner_doc().is_html_document()
|
||||
|
|
|
@ -571,12 +571,9 @@ pub trait LayoutElementHelpers<'dom> {
|
|||
unsafe fn synthesize_presentational_hints_for_legacy_attributes<V>(self, _: &mut V)
|
||||
where
|
||||
V: Push<ApplicableDeclarationBlock>;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_colspan(self) -> u32;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_rowspan(self) -> u32;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn is_html_element(self) -> bool;
|
||||
fn get_colspan(self) -> u32;
|
||||
fn get_rowspan(self) -> u32;
|
||||
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;
|
||||
|
@ -951,8 +948,7 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_colspan(self) -> u32 {
|
||||
fn get_colspan(self) -> u32 {
|
||||
if let Some(this) = self.downcast::<HTMLTableCellElement>() {
|
||||
this.get_colspan().unwrap_or(1)
|
||||
} else {
|
||||
|
@ -962,8 +958,7 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_rowspan(self) -> u32 {
|
||||
fn get_rowspan(self) -> u32 {
|
||||
if let Some(this) = self.downcast::<HTMLTableCellElement>() {
|
||||
this.get_rowspan().unwrap_or(1)
|
||||
} else {
|
||||
|
@ -974,9 +969,8 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn is_html_element(self) -> bool {
|
||||
(*self.unsafe_get()).namespace == ns!(html)
|
||||
fn is_html_element(self) -> bool {
|
||||
*self.namespace() == ns!(html)
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue