diff options
Diffstat (limited to 'components/script/dom/htmlfontelement.rs')
-rw-r--r-- | components/script/dom/htmlfontelement.rs | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/components/script/dom/htmlfontelement.rs b/components/script/dom/htmlfontelement.rs index dbd876b1751..bee1711916e 100644 --- a/components/script/dom/htmlfontelement.rs +++ b/components/script/dom/htmlfontelement.rs @@ -2,7 +2,8 @@ * 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; +use dom::attr::{Attr, AttrValue}; +use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::HTMLFontElementBinding; use dom::bindings::codegen::Bindings::HTMLFontElementBinding::HTMLFontElementMethods; use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLFontElementDerived}; @@ -13,6 +14,7 @@ use dom::eventtarget::{EventTarget, EventTargetTypeId}; use dom::htmlelement::{HTMLElement, HTMLElementTypeId}; use dom::node::{Node, NodeTypeId}; use dom::virtualmethods::VirtualMethods; +use string_cache::Atom; use util::str::{self, DOMString}; use cssparser::RGBA; @@ -22,6 +24,7 @@ use std::cell::Cell; pub struct HTMLFontElement { htmlelement: HTMLElement, color: Cell<Option<RGBA>>, + face: DOMRefCell<Option<Atom>>, } impl HTMLFontElementDerived for EventTarget { @@ -37,6 +40,7 @@ impl HTMLFontElement { HTMLFontElement { htmlelement: HTMLElement::new_inherited(HTMLElementTypeId::HTMLFontElement, localName, prefix, document), color: Cell::new(None), + face: DOMRefCell::new(None), } } @@ -55,6 +59,12 @@ impl HTMLFontElementMethods for HTMLFontElement { // https://html.spec.whatwg.org/multipage/#dom-font-color make_setter!(SetColor, "color"); + + // https://html.spec.whatwg.org/multipage/#dom-font-face + make_getter!(Face); + + // https://html.spec.whatwg.org/multipage/#dom-font-face + make_atomic_setter!(SetFace, "face"); } impl VirtualMethods for HTMLFontElement { @@ -71,9 +81,21 @@ impl VirtualMethods for HTMLFontElement { str::parse_legacy_color(&value).ok() })); }, + &atom!(face) => { + *self.face.borrow_mut() = + mutation.new_value(attr) + .map(|value| value.as_atom().clone()) + }, _ => {}, } } + + fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue { + match name { + &atom!("face") => AttrValue::from_atomic(value), + _ => self.super_type().unwrap().parse_plain_attribute(name, value), + } + } } @@ -81,4 +103,13 @@ impl HTMLFontElement { pub fn get_color(&self) -> Option<RGBA> { self.color.get() } + + #[allow(unsafe_code)] + pub fn get_face(&self) -> Option<Atom> { + let face = unsafe { self.face.borrow_for_layout() }; + match *face { + Some(ref s) => Some(s.clone()), + None => None, + } + } } |