mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
Move more unsafe layout calls onto LayoutJS.
This commit is contained in:
parent
5293afc122
commit
af78173243
2 changed files with 37 additions and 15 deletions
|
@ -47,7 +47,7 @@ use dom::htmllabelelement::HTMLLabelElement;
|
|||
use dom::htmllegendelement::HTMLLegendElement;
|
||||
use dom::htmloptgroupelement::HTMLOptGroupElement;
|
||||
use dom::htmltablecellelement::{HTMLTableCellElement, HTMLTableCellElementLayoutHelpers};
|
||||
use dom::htmltableelement::HTMLTableElement;
|
||||
use dom::htmltableelement::{HTMLTableElement, HTMLTableElementLayoutHelpers};
|
||||
use dom::htmltablerowelement::HTMLTableRowElement;
|
||||
use dom::htmltablesectionelement::HTMLTableSectionElement;
|
||||
use dom::htmltemplateelement::HTMLTemplateElement;
|
||||
|
@ -276,7 +276,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
|
|||
let bgcolor = if let Some(this) = self.downcast::<HTMLBodyElement>() {
|
||||
this.get_background_color()
|
||||
} else if let Some(this) = self.downcast::<HTMLTableElement>() {
|
||||
(*this.unsafe_get()).get_background_color()
|
||||
this.get_background_color()
|
||||
} else if let Some(this) = self.downcast::<HTMLTableCellElement>() {
|
||||
this.get_background_color()
|
||||
} else if let Some(this) = self.downcast::<HTMLTableRowElement>() {
|
||||
|
@ -355,7 +355,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
|
|||
}
|
||||
|
||||
let cellspacing = if let Some(this) = self.downcast::<HTMLTableElement>() {
|
||||
(*this.unsafe_get()).get_cellspacing()
|
||||
this.get_cellspacing()
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
@ -400,7 +400,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
|
|||
let width = if let Some(this) = self.downcast::<HTMLIFrameElement>() {
|
||||
this.get_width()
|
||||
} else if let Some(this) = self.downcast::<HTMLTableElement>() {
|
||||
(*this.unsafe_get()).get_width()
|
||||
this.get_width()
|
||||
} else if let Some(this) = self.downcast::<HTMLTableCellElement>() {
|
||||
this.get_width()
|
||||
} else {
|
||||
|
@ -490,7 +490,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
|
|||
|
||||
|
||||
let border = if let Some(this) = self.downcast::<HTMLTableElement>() {
|
||||
(*this.unsafe_get()).get_border()
|
||||
this.get_border()
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::HTMLTableElementBinding;
|
|||
use dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods;
|
||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::{Root, RootedReference};
|
||||
use dom::bindings::js::{LayoutJS, Root, RootedReference};
|
||||
use dom::document::Document;
|
||||
use dom::element::{AttributeMutation, Element};
|
||||
use dom::htmlelement::HTMLElement;
|
||||
|
@ -47,6 +47,10 @@ impl HTMLTableElement {
|
|||
let element = HTMLTableElement::new_inherited(localName, prefix, document);
|
||||
Node::reflect_node(box element, document, HTMLTableElementBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn get_border(&self) -> Option<u32> {
|
||||
self.border.get()
|
||||
}
|
||||
}
|
||||
|
||||
impl HTMLTableElementMethods for HTMLTableElement {
|
||||
|
@ -115,22 +119,40 @@ impl HTMLTableElementMethods for HTMLTableElement {
|
|||
make_setter!(SetBgColor, "bgcolor");
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
impl HTMLTableElement {
|
||||
pub fn get_background_color(&self) -> Option<RGBA> {
|
||||
self.background_color.get()
|
||||
impl HTMLTableElementLayoutHelpers for LayoutJS<HTMLTableElement> {
|
||||
#[allow(unsafe_code)]
|
||||
fn get_background_color(&self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(*self.unsafe_get()).background_color.get()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_border(&self) -> Option<u32> {
|
||||
self.border.get()
|
||||
#[allow(unsafe_code)]
|
||||
fn get_border(&self) -> Option<u32> {
|
||||
unsafe {
|
||||
(*self.unsafe_get()).border.get()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_cellspacing(&self) -> Option<u32> {
|
||||
self.cellspacing.get()
|
||||
#[allow(unsafe_code)]
|
||||
fn get_cellspacing(&self) -> Option<u32> {
|
||||
unsafe {
|
||||
(*self.unsafe_get()).cellspacing.get()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_width(&self) -> LengthOrPercentageOrAuto {
|
||||
self.width.get()
|
||||
#[allow(unsafe_code)]
|
||||
fn get_width(&self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
(*self.unsafe_get()).width.get()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue