From 0901e5bc972a1df1a11bcc213b9271ce7253b0c7 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Sat, 7 Nov 2015 23:27:07 -0800 Subject: [PATCH 1/4] Move storage of bgcolor attribute on . --- components/script/dom/document.rs | 4 ++- components/script/dom/htmlbodyelement.rs | 31 ++++++++++-------------- components/script/dom/macros.rs | 15 ++++++++++++ 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index dc3225bba04..14c4f5da5e9 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -968,7 +968,9 @@ impl Document { pub fn set_body_attribute(&self, local_name: &Atom, value: DOMString) { if let Some(ref body) = self.GetBody().and_then(Root::downcast::) { - body.upcast::().set_string_attribute(local_name, value); + let body = body.upcast::(); + let value = body.parse_attribute(&ns!(""), &local_name, value); + body.set_attribute(local_name, value); } } diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs index 1f8de257596..87a2d6ee3d8 100644 --- a/components/script/dom/htmlbodyelement.rs +++ b/components/script/dom/htmlbodyelement.rs @@ -20,12 +20,11 @@ use dom::virtualmethods::VirtualMethods; use msg::constellation_msg::ConstellationChan; use msg::constellation_msg::Msg as ConstellationMsg; use std::borrow::ToOwned; -use std::cell::Cell; use std::rc::Rc; use string_cache::Atom; use time; use url::{Url, UrlParser}; -use util::str::{self, DOMString}; +use util::str::DOMString; /// How long we should wait before performing the initial reflow after `` is parsed, in /// nanoseconds. @@ -34,7 +33,6 @@ const INITIAL_REFLOW_DELAY: u64 = 200_000_000; #[dom_struct] pub struct HTMLBodyElement { htmlelement: HTMLElement, - background_color: Cell>, background: DOMRefCell> } @@ -43,7 +41,6 @@ impl HTMLBodyElement { -> HTMLBodyElement { HTMLBodyElement { htmlelement: HTMLElement::new_inherited(localName, prefix, document), - background_color: Cell::new(None), background: DOMRefCell::new(None) } } @@ -61,17 +58,13 @@ impl HTMLBodyElementMethods for HTMLBodyElement { make_getter!(BgColor, "bgcolor"); // https://html.spec.whatwg.org/multipage/#dom-body-bgcolor - make_setter!(SetBgColor, "bgcolor"); + make_legacy_color_setter!(SetBgColor, "bgcolor"); // https://html.spec.whatwg.org/multipage/#dom-body-text make_getter!(Text); // https://html.spec.whatwg.org/multipage/#dom-body-text - fn SetText(&self, value: DOMString) { - let element = self.upcast::(); - let color = str::parse_legacy_color(&value).ok(); - element.set_attribute(&atom!("text"), AttrValue::Color(value, color)); - } + make_legacy_color_setter!(SetText, "text"); // https://html.spec.whatwg.org/multipage/#the-body-element fn GetOnunload(&self) -> Option> { @@ -96,8 +89,14 @@ impl HTMLBodyElementMethods for HTMLBodyElement { impl HTMLBodyElement { + #[allow(unsafe_code)] pub fn get_background_color(&self) -> Option { - self.background_color.get() + unsafe { + self.upcast::() + .get_attr_for_layout(&ns!(""), &atom!("bgcolor")) + .and_then(AttrValue::as_color) + .cloned() + } } #[allow(unsafe_code)] @@ -141,8 +140,9 @@ impl VirtualMethods for HTMLBodyElement { } fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue { - match name { - &atom!("text") => AttrValue::from_legacy_color(value), + match *name { + atom!("bgcolor") | + atom!("text") => AttrValue::from_legacy_color(value), _ => self.super_type().unwrap().parse_plain_attribute(name, value), } } @@ -150,11 +150,6 @@ impl VirtualMethods for HTMLBodyElement { fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { self.super_type().unwrap().attribute_mutated(attr, mutation); match (attr.local_name(), mutation) { - (&atom!(bgcolor), _) => { - self.background_color.set(mutation.new_value(attr).and_then(|value| { - str::parse_legacy_color(&value).ok() - })); - }, (&atom!(background), _) => { *self.background.borrow_mut() = mutation.new_value(attr).and_then(|value| { let document = document_from_node(self); diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs index c41e100638c..d230bec5404 100644 --- a/components/script/dom/macros.rs +++ b/components/script/dom/macros.rs @@ -215,6 +215,21 @@ macro_rules! make_atomic_setter( ); ); +#[macro_export] +macro_rules! make_legacy_color_setter( + ( $attr:ident, $htmlname:expr ) => ( + fn $attr(&self, value: DOMString) { + use dom::bindings::inheritance::Castable; + use dom::element::Element; + use string_cache::Atom; + let element = self.upcast::(); + let value = AttrValue::from_legacy_color(value); + // FIXME(pcwalton): Do this at compile time, not at runtime. + element.set_attribute(&Atom::from_slice($htmlname), value) + } + ); +); + /// For use on non-jsmanaged types /// Use #[derive(JSTraceable)] on JS managed types macro_rules! no_jsmanaged_fields( From ef52da7acdcfbcf5b15cc82c2434f60ade0d0e33 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Sat, 7 Nov 2015 23:51:31 -0800 Subject: [PATCH 2/4] Move storage of color attribute on . --- components/script/dom/htmlfontelement.rs | 32 +++++++++--------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/components/script/dom/htmlfontelement.rs b/components/script/dom/htmlfontelement.rs index 61ac4f47797..4e291db7802 100644 --- a/components/script/dom/htmlfontelement.rs +++ b/components/script/dom/htmlfontelement.rs @@ -3,25 +3,23 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use cssparser::RGBA; -use dom::attr::{Attr, AttrValue}; +use dom::attr::AttrValue; use dom::bindings::codegen::Bindings::HTMLFontElementBinding; use dom::bindings::codegen::Bindings::HTMLFontElementBinding::HTMLFontElementMethods; use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::document::Document; -use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers}; +use dom::element::{Element, RawLayoutElementHelpers}; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom::virtualmethods::VirtualMethods; -use std::cell::Cell; use string_cache::Atom; use style::values::specified; -use util::str::{self, DOMString, parse_legacy_font_size}; +use util::str::{DOMString, parse_legacy_font_size}; #[dom_struct] pub struct HTMLFontElement { htmlelement: HTMLElement, - color: Cell>, } @@ -29,7 +27,6 @@ impl HTMLFontElement { fn new_inherited(localName: DOMString, prefix: Option, document: &Document) -> HTMLFontElement { HTMLFontElement { htmlelement: HTMLElement::new_inherited(localName, prefix, document), - color: Cell::new(None), } } @@ -47,7 +44,7 @@ impl HTMLFontElementMethods for HTMLFontElement { make_getter!(Color, "color"); // https://html.spec.whatwg.org/multipage/#dom-font-color - make_setter!(SetColor, "color"); + make_legacy_color_setter!(SetColor, "color"); // https://html.spec.whatwg.org/multipage/#dom-font-face make_getter!(Face); @@ -71,21 +68,10 @@ impl VirtualMethods for HTMLFontElement { Some(self.upcast::() as &VirtualMethods) } - fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { - self.super_type().unwrap().attribute_mutated(attr, mutation); - match attr.local_name() { - &atom!(color) => { - self.color.set(mutation.new_value(attr).and_then(|value| { - str::parse_legacy_color(&value).ok() - })); - }, - _ => {}, - } - } - fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue { match name { &atom!("face") => AttrValue::from_atomic(value), + &atom!("color") => AttrValue::from_legacy_color(value), &atom!("size") => { let length = parse_length(&value); AttrValue::Length(value, length) @@ -97,8 +83,14 @@ impl VirtualMethods for HTMLFontElement { impl HTMLFontElement { + #[allow(unsafe_code)] pub fn get_color(&self) -> Option { - self.color.get() + unsafe { + self.upcast::() + .get_attr_for_layout(&ns!(""), &atom!("color")) + .and_then(AttrValue::as_color) + .cloned() + } } #[allow(unsafe_code)] From 5293afc122626d997bab168554ac0a3cbb5ab03c Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Sun, 8 Nov 2015 00:09:15 -0800 Subject: [PATCH 3/4] Move unsafe layout calls onto LayoutJS. --- components/script/dom/element.rs | 22 +++++----- components/script/dom/htmlbodyelement.rs | 21 ++++++---- components/script/dom/htmlfontelement.rs | 21 ++++++---- components/script/dom/htmliframeelement.rs | 48 +++++++++++----------- 4 files changed, 61 insertions(+), 51 deletions(-) diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 9b5fb30c1c6..4377ca82026 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -36,12 +36,12 @@ use dom::domrectlist::DOMRectList; use dom::domtokenlist::DOMTokenList; use dom::event::Event; use dom::htmlanchorelement::HTMLAnchorElement; -use dom::htmlbodyelement::HTMLBodyElement; +use dom::htmlbodyelement::{HTMLBodyElement, HTMLBodyElementLayoutHelpers}; use dom::htmlcollection::HTMLCollection; use dom::htmlfieldsetelement::HTMLFieldSetElement; -use dom::htmlfontelement::HTMLFontElement; +use dom::htmlfontelement::{HTMLFontElement, HTMLFontElementLayoutHelpers}; use dom::htmlhrelement::{HTMLHRElement, HTMLHRLayoutHelpers}; -use dom::htmliframeelement::HTMLIFrameElement; +use dom::htmliframeelement::{HTMLIFrameElement, HTMLIFrameElementLayoutMethods}; use dom::htmlinputelement::{HTMLInputElement, LayoutHTMLInputElementHelpers}; use dom::htmllabelelement::HTMLLabelElement; use dom::htmllegendelement::HTMLLegendElement; @@ -274,7 +274,7 @@ impl LayoutElementHelpers for LayoutJS { where V: VecLike>> { let bgcolor = if let Some(this) = self.downcast::() { - (*this.unsafe_get()).get_background_color() + this.get_background_color() } else if let Some(this) = self.downcast::() { (*this.unsafe_get()).get_background_color() } else if let Some(this) = self.downcast::() { @@ -294,7 +294,7 @@ impl LayoutElementHelpers for LayoutJS { } let background = if let Some(this) = self.downcast::() { - (*this.unsafe_get()).get_background() + this.get_background() } else { None }; @@ -306,10 +306,10 @@ impl LayoutElementHelpers for LayoutJS { } let color = if let Some(this) = self.downcast::() { - (*this.unsafe_get()).get_color() + this.get_color() } else if let Some(this) = self.downcast::() { // https://html.spec.whatwg.org/multipage/#the-page:the-body-element-20 - (*this.unsafe_get()).get_color() + this.get_color() } else if let Some(this) = self.downcast::() { // https://html.spec.whatwg.org/multipage/#the-hr-element-2:presentational-hints-5 this.get_color() @@ -326,7 +326,7 @@ impl LayoutElementHelpers for LayoutJS { } let font_family = if let Some(this) = self.downcast::() { - (*this.unsafe_get()).get_face() + this.get_face() } else { None }; @@ -341,7 +341,7 @@ impl LayoutElementHelpers for LayoutJS { } let font_size = if let Some(this) = self.downcast::() { - (*this.unsafe_get()).get_size() + this.get_size() } else { None }; @@ -398,7 +398,7 @@ impl LayoutElementHelpers for LayoutJS { let width = if let Some(this) = self.downcast::() { - (*this.unsafe_get()).get_width() + this.get_width() } else if let Some(this) = self.downcast::() { (*this.unsafe_get()).get_width() } else if let Some(this) = self.downcast::() { @@ -425,7 +425,7 @@ impl LayoutElementHelpers for LayoutJS { let height = if let Some(this) = self.downcast::() { - (*this.unsafe_get()).get_height() + this.get_height() } else { LengthOrPercentageOrAuto::Auto }; diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs index 87a2d6ee3d8..80c3098e62f 100644 --- a/components/script/dom/htmlbodyelement.rs +++ b/components/script/dom/htmlbodyelement.rs @@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindings::HTMLBodyElementBinding::{self, HTMLBodyElementMethods}; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; +use dom::bindings::js::{LayoutJS, Root}; use dom::bindings::reflector::Reflectable; use dom::document::Document; use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers}; @@ -87,12 +87,17 @@ impl HTMLBodyElementMethods for HTMLBodyElement { } } +pub trait HTMLBodyElementLayoutHelpers { + fn get_background_color(&self) -> Option; + fn get_color(&self) -> Option; + fn get_background(&self) -> Option; +} -impl HTMLBodyElement { +impl HTMLBodyElementLayoutHelpers for LayoutJS { #[allow(unsafe_code)] - pub fn get_background_color(&self) -> Option { + fn get_background_color(&self) -> Option { unsafe { - self.upcast::() + (*self.upcast::().unsafe_get()) .get_attr_for_layout(&ns!(""), &atom!("bgcolor")) .and_then(AttrValue::as_color) .cloned() @@ -100,9 +105,9 @@ impl HTMLBodyElement { } #[allow(unsafe_code)] - pub fn get_color(&self) -> Option { + fn get_color(&self) -> Option { unsafe { - self.upcast::() + (*self.upcast::().unsafe_get()) .get_attr_for_layout(&ns!(""), &atom!("text")) .and_then(AttrValue::as_color) .cloned() @@ -110,9 +115,9 @@ impl HTMLBodyElement { } #[allow(unsafe_code)] - pub fn get_background(&self) -> Option { + fn get_background(&self) -> Option { unsafe { - self.background.borrow_for_layout().clone() + (*self.unsafe_get()).background.borrow_for_layout().clone() } } } diff --git a/components/script/dom/htmlfontelement.rs b/components/script/dom/htmlfontelement.rs index 4e291db7802..6bc093c9e05 100644 --- a/components/script/dom/htmlfontelement.rs +++ b/components/script/dom/htmlfontelement.rs @@ -7,7 +7,7 @@ use dom::attr::AttrValue; use dom::bindings::codegen::Bindings::HTMLFontElementBinding; use dom::bindings::codegen::Bindings::HTMLFontElementBinding::HTMLFontElementMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; +use dom::bindings::js::{LayoutJS, Root}; use dom::document::Document; use dom::element::{Element, RawLayoutElementHelpers}; use dom::htmlelement::HTMLElement; @@ -81,12 +81,17 @@ impl VirtualMethods for HTMLFontElement { } } +pub trait HTMLFontElementLayoutHelpers { + fn get_color(&self) -> Option; + fn get_face(&self) -> Option; + fn get_size(&self) -> Option; +} -impl HTMLFontElement { +impl HTMLFontElementLayoutHelpers for LayoutJS { #[allow(unsafe_code)] - pub fn get_color(&self) -> Option { + fn get_color(&self) -> Option { unsafe { - self.upcast::() + (*self.upcast::().unsafe_get()) .get_attr_for_layout(&ns!(""), &atom!("color")) .and_then(AttrValue::as_color) .cloned() @@ -94,9 +99,9 @@ impl HTMLFontElement { } #[allow(unsafe_code)] - pub fn get_face(&self) -> Option { + fn get_face(&self) -> Option { unsafe { - self.upcast::() + (*self.upcast::().unsafe_get()) .get_attr_for_layout(&ns!(""), &atom!("face")) .map(AttrValue::as_atom) .cloned() @@ -104,9 +109,9 @@ impl HTMLFontElement { } #[allow(unsafe_code)] - pub fn get_size(&self) -> Option { + fn get_size(&self) -> Option { unsafe { - self.upcast::() + (*self.upcast::().unsafe_get()) .get_attr_for_layout(&ns!(""), &atom!("size")) .and_then(AttrValue::as_length) .cloned() diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 37564d22e54..6bc48da1c4f 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use dom::attr::{Attr, AttrHelpersForLayout, AttrValue}; +use dom::attr::{Attr, AttrValue}; use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding; use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElementMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; @@ -14,7 +14,7 @@ use dom::bindings::js::{Root, LayoutJS}; use dom::bindings::reflector::Reflectable; use dom::customevent::CustomEvent; use dom::document::Document; -use dom::element::{self, AttributeMutation, Element}; +use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers}; use dom::event::Event; use dom::htmlelement::HTMLElement; use dom::node::{Node, window_from_node}; @@ -156,28 +156,6 @@ impl HTMLIFrameElement { self.subpage_id.set(Some(new_subpage_id)); } - #[allow(unsafe_code)] - pub fn get_width(&self) -> LengthOrPercentageOrAuto { - unsafe { - element::get_attr_for_layout(self.upcast(), - &ns!(""), - &atom!("width")).map(|attribute| { - str::parse_length(&**attribute.value_for_layout()) - }).unwrap_or(LengthOrPercentageOrAuto::Auto) - } - } - - #[allow(unsafe_code)] - pub fn get_height(&self) -> LengthOrPercentageOrAuto { - unsafe { - element::get_attr_for_layout(self.upcast(), - &ns!(""), - &atom!("height")).map(|attribute| { - str::parse_length(&**attribute.value_for_layout()) - }).unwrap_or(LengthOrPercentageOrAuto::Auto) - } - } - fn new_inherited(localName: DOMString, prefix: Option, document: &Document) -> HTMLIFrameElement { @@ -211,6 +189,8 @@ impl HTMLIFrameElement { pub trait HTMLIFrameElementLayoutMethods { fn pipeline_id(self) -> Option; + fn get_width(&self) -> LengthOrPercentageOrAuto; + fn get_height(&self) -> LengthOrPercentageOrAuto; } impl HTMLIFrameElementLayoutMethods for LayoutJS { @@ -221,6 +201,26 @@ impl HTMLIFrameElementLayoutMethods for LayoutJS { (*self.unsafe_get()).pipeline_id.get() } } + + #[allow(unsafe_code)] + fn get_width(&self) -> LengthOrPercentageOrAuto { + unsafe { + (*self.upcast::().unsafe_get()) + .get_attr_for_layout(&ns!(""), &atom!("width")) + .map(|attribute| str::parse_length(&attribute)) + .unwrap_or(LengthOrPercentageOrAuto::Auto) + } + } + + #[allow(unsafe_code)] + fn get_height(&self) -> LengthOrPercentageOrAuto { + unsafe { + (*self.upcast::().unsafe_get()) + .get_attr_for_layout(&ns!(""), &atom!("height")) + .map(|attribute| str::parse_length(&attribute)) + .unwrap_or(LengthOrPercentageOrAuto::Auto) + } + } } pub fn Navigate(iframe: &HTMLIFrameElement, direction: NavigationDirection) -> Fallible<()> { From af78173243a621e1da74ae0553222614c2338b91 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Sun, 8 Nov 2015 00:30:34 -0800 Subject: [PATCH 4/4] Move more unsafe layout calls onto LayoutJS. --- components/script/dom/element.rs | 10 +++--- components/script/dom/htmltableelement.rs | 42 +++++++++++++++++------ 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 4377ca82026..9c625dde32e 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -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 { let bgcolor = if let Some(this) = self.downcast::() { this.get_background_color() } else if let Some(this) = self.downcast::() { - (*this.unsafe_get()).get_background_color() + this.get_background_color() } else if let Some(this) = self.downcast::() { this.get_background_color() } else if let Some(this) = self.downcast::() { @@ -355,7 +355,7 @@ impl LayoutElementHelpers for LayoutJS { } let cellspacing = if let Some(this) = self.downcast::() { - (*this.unsafe_get()).get_cellspacing() + this.get_cellspacing() } else { None }; @@ -400,7 +400,7 @@ impl LayoutElementHelpers for LayoutJS { let width = if let Some(this) = self.downcast::() { this.get_width() } else if let Some(this) = self.downcast::() { - (*this.unsafe_get()).get_width() + this.get_width() } else if let Some(this) = self.downcast::() { this.get_width() } else { @@ -490,7 +490,7 @@ impl LayoutElementHelpers for LayoutJS { let border = if let Some(this) = self.downcast::() { - (*this.unsafe_get()).get_border() + this.get_border() } else { None }; diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs index 259104ae09c..548cf240b9b 100644 --- a/components/script/dom/htmltableelement.rs +++ b/components/script/dom/htmltableelement.rs @@ -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 { + 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; + fn get_border(&self) -> Option; + fn get_cellspacing(&self) -> Option; + fn get_width(&self) -> LengthOrPercentageOrAuto; +} -impl HTMLTableElement { - pub fn get_background_color(&self) -> Option { - self.background_color.get() +impl HTMLTableElementLayoutHelpers for LayoutJS { + #[allow(unsafe_code)] + fn get_background_color(&self) -> Option { + unsafe { + (*self.unsafe_get()).background_color.get() + } } - pub fn get_border(&self) -> Option { - self.border.get() + #[allow(unsafe_code)] + fn get_border(&self) -> Option { + unsafe { + (*self.unsafe_get()).border.get() + } } - pub fn get_cellspacing(&self) -> Option { - self.cellspacing.get() + #[allow(unsafe_code)] + fn get_cellspacing(&self) -> Option { + 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() + } } }