Add CSSNamespaceRule.{namespaceURI, prefix}

This commit is contained in:
Manish Goregaokar 2016-11-17 16:53:54 -08:00
parent 64442090ba
commit 8108fc465a
3 changed files with 18 additions and 3 deletions

View file

@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding; use dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding;
use dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding::CSSNamespaceRuleMethods;
use dom::bindings::js::Root; use dom::bindings::js::Root;
use dom::bindings::reflector::reflect_dom_object; use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::str::DOMString; use dom::bindings::str::DOMString;
@ -38,6 +39,20 @@ impl CSSNamespaceRule {
} }
} }
impl CSSNamespaceRuleMethods for CSSNamespaceRule {
// https://drafts.csswg.org/cssom/#dom-cssnamespacerule-prefix
fn Prefix(&self) -> DOMString {
self.namespacerule.read().prefix
.as_ref().map(|s| s.to_string().into())
.unwrap_or(DOMString::new())
}
// https://drafts.csswg.org/cssom/#dom-cssnamespacerule-namespaceuri
fn NamespaceURI(&self) -> DOMString {
(*self.namespacerule.read().url).into()
}
}
impl SpecificCSSRule for CSSNamespaceRule { impl SpecificCSSRule for CSSNamespaceRule {
fn ty(&self) -> u16 { fn ty(&self) -> u16 {
use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleConstants; use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleConstants;

View file

@ -5,6 +5,6 @@
// https://drafts.csswg.org/cssom/#the-cssnamespacerule-interface // https://drafts.csswg.org/cssom/#the-cssnamespacerule-interface
[Exposed=Window] [Exposed=Window]
interface CSSNamespaceRule : CSSRule { interface CSSNamespaceRule : CSSRule {
// readonly attribute DOMString namespaceURI; readonly attribute DOMString namespaceURI;
// readonly attribute DOMString prefix; readonly attribute DOMString prefix;
}; };

View file

@ -10,9 +10,9 @@ use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock};
use properties::PropertyDeclarationParseResult; use properties::PropertyDeclarationParseResult;
use properties::animated_properties::TransitionProperty; use properties::animated_properties::TransitionProperty;
use std::fmt; use std::fmt;
use servo_url::ServoUrl;
use std::sync::Arc; use std::sync::Arc;
use stylesheets::{MemoryHoleReporter, Origin}; use stylesheets::{MemoryHoleReporter, Origin};
use servo_url::ServoUrl;
use style_traits::ToCss; use style_traits::ToCss;
/// A number from 1 to 100, indicating the percentage of the animation where /// A number from 1 to 100, indicating the percentage of the animation where