diff options
author | Corey Farwell <coreyf@rwell.org> | 2015-10-03 14:02:58 -0400 |
---|---|---|
committer | Corey Farwell <coreyf@rwell.org> | 2015-10-08 10:55:12 -0400 |
commit | 64f4835a4f490ede8b264d611013ee33ea6ad9fe (patch) | |
tree | bc8f420d36d53ad4a052eb4c63305c3acea0db58 /components/script/dom/attr.rs | |
parent | 26dd1233103eb75c2e94fcc2ba34c18fa4432afc (diff) | |
download | servo-64f4835a4f490ede8b264d611013ee33ea6ad9fe.tar.gz servo-64f4835a4f490ede8b264d611013ee33ea6ad9fe.zip |
Implement <body>'s "text" attribute
Diffstat (limited to 'components/script/dom/attr.rs')
-rw-r--r-- | components/script/dom/attr.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index 2cd742ee422..fcb914aa1a7 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -2,6 +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 cssparser::RGBA; use devtools_traits::AttrInfo; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::AttrBinding::{self, AttrMethods}; @@ -28,6 +29,7 @@ pub enum AttrValue { UInt(DOMString, u32), Atom(Atom), Length(DOMString, Option<Length>), + Color(DOMString, Option<RGBA>), } impl AttrValue { @@ -98,6 +100,18 @@ impl AttrValue { } } + /// Assumes the `AttrValue` is a `Color` and returns its value + /// + /// ## Panics + /// + /// Panics if the `AttrValue` is not a `Color` + pub fn as_color(&self) -> Option<&RGBA> { + match *self { + AttrValue::Color(_, ref color) => color.as_ref(), + _ => panic!("Color not found"), + } + } + /// Assumes the `AttrValue` is a `Length` and returns its value /// /// ## Panics @@ -134,7 +148,8 @@ impl Deref for AttrValue { AttrValue::String(ref value) | AttrValue::TokenList(ref value, _) | AttrValue::UInt(ref value, _) | - AttrValue::Length(ref value, _) => &value, + AttrValue::Length(ref value, _) | + AttrValue::Color(ref value, _) => &value, AttrValue::Atom(ref value) => &value, } } |