aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmltablesectionelement.rs
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2015-11-09 12:25:34 -0800
committerEli Friedman <eli.friedman@gmail.com>2015-11-09 12:27:16 -0800
commit4b68fc18c32e889c1726e17bdcf7c0b1bac02b05 (patch)
treed95b28633c207c8489c17bf020cc8b9edc39203c /components/script/dom/htmltablesectionelement.rs
parentd8df028197505ca439363cdb05bed58fe9b4b726 (diff)
downloadservo-4b68fc18c32e889c1726e17bdcf7c0b1bac02b05.tar.gz
servo-4b68fc18c32e889c1726e17bdcf7c0b1bac02b05.zip
Move storage of bgcolor for `<tr>` and `<tbody>`.
Diffstat (limited to 'components/script/dom/htmltablesectionelement.rs')
-rw-r--r--components/script/dom/htmltablesectionelement.rs45
1 files changed, 25 insertions, 20 deletions
diff --git a/components/script/dom/htmltablesectionelement.rs b/components/script/dom/htmltablesectionelement.rs
index 296d1c93dbe..94010724ded 100644
--- a/components/script/dom/htmltablesectionelement.rs
+++ b/components/script/dom/htmltablesectionelement.rs
@@ -3,26 +3,25 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::RGBA;
-use dom::attr::Attr;
+use dom::attr::AttrValue;
use dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::{self, HTMLTableSectionElementMethods};
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::error::{ErrorResult, Fallible};
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::element::{Element, RawLayoutElementHelpers};
use dom::htmlcollection::{CollectionFilter, HTMLCollection};
use dom::htmlelement::HTMLElement;
use dom::htmltablerowelement::HTMLTableRowElement;
use dom::node::{Node, window_from_node};
use dom::virtualmethods::VirtualMethods;
-use std::cell::Cell;
-use util::str::{self, DOMString};
+use string_cache::Atom;
+use util::str::DOMString;
#[dom_struct]
pub struct HTMLTableSectionElement {
htmlelement: HTMLElement,
- background_color: Cell<Option<RGBA>>,
}
impl HTMLTableSectionElement {
@@ -30,7 +29,6 @@ impl HTMLTableSectionElement {
-> HTMLTableSectionElement {
HTMLTableSectionElement {
htmlelement: HTMLElement::new_inherited(localName, prefix, document),
- background_color: Cell::new(None),
}
}
@@ -40,10 +38,6 @@ impl HTMLTableSectionElement {
let element = HTMLTableSectionElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLTableSectionElementBinding::Wrap)
}
-
- pub fn get_background_color(&self) -> Option<RGBA> {
- self.background_color.get()
- }
}
#[derive(JSTraceable)]
@@ -80,20 +74,31 @@ impl HTMLTableSectionElementMethods for HTMLTableSectionElement {
}
}
+pub trait HTMLTableSectionElementLayoutHelpers {
+ fn get_background_color(&self) -> Option<RGBA>;
+}
+
+#[allow(unsafe_code)]
+impl HTMLTableSectionElementLayoutHelpers for LayoutJS<HTMLTableSectionElement> {
+ fn get_background_color(&self) -> Option<RGBA> {
+ unsafe {
+ (&*self.upcast::<Element>().unsafe_get())
+ .get_attr_for_layout(&ns!(""), &atom!("bgcolor"))
+ .and_then(AttrValue::as_color)
+ .cloned()
+ }
+ }
+}
+
impl VirtualMethods for HTMLTableSectionElement {
fn super_type(&self) -> Option<&VirtualMethods> {
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
}
- fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
- self.super_type().unwrap().attribute_mutated(attr, mutation);
- match *attr.local_name() {
- atom!(bgcolor) => {
- self.background_color.set(mutation.new_value(attr).and_then(|value| {
- str::parse_legacy_color(&value).ok()
- }));
- },
- _ => {},
+ fn parse_plain_attribute(&self, local_name: &Atom, value: DOMString) -> AttrValue {
+ match *local_name {
+ atom!("bgcolor") => AttrValue::from_legacy_color(value),
+ _ => self.super_type().unwrap().parse_plain_attribute(local_name, value),
}
}
}