aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlfontelement.rs
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2015-11-07 23:51:31 -0800
committerEli Friedman <eli.friedman@gmail.com>2015-11-08 17:29:50 -0800
commitef52da7acdcfbcf5b15cc82c2434f60ade0d0e33 (patch)
tree9f474df2cab395998e5c89d3340f8365cd286121 /components/script/dom/htmlfontelement.rs
parent0901e5bc972a1df1a11bcc213b9271ce7253b0c7 (diff)
downloadservo-ef52da7acdcfbcf5b15cc82c2434f60ade0d0e33.tar.gz
servo-ef52da7acdcfbcf5b15cc82c2434f60ade0d0e33.zip
Move storage of color attribute on <font>.
Diffstat (limited to 'components/script/dom/htmlfontelement.rs')
-rw-r--r--components/script/dom/htmlfontelement.rs32
1 files 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<Option<RGBA>>,
}
@@ -29,7 +27,6 @@ impl HTMLFontElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, 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::<HTMLElement>() 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<RGBA> {
- self.color.get()
+ unsafe {
+ self.upcast::<Element>()
+ .get_attr_for_layout(&ns!(""), &atom!("color"))
+ .and_then(AttrValue::as_color)
+ .cloned()
+ }
}
#[allow(unsafe_code)]