mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Make DOMString a newtype around String, rather than a typedef.
This should make it somewhat easier to experiment with alternative representations in the future. To reduce churn, this commit leaves the String field public, though. Also, this will allow us to use the default String type to represent the IDL USVString type, which explicitly forbids unpaired surrogates, ans as such is a better match to the Rust String type.
This commit is contained in:
parent
e6aa976462
commit
6b75078503
83 changed files with 393 additions and 297 deletions
|
@ -39,10 +39,10 @@ macro_rules! css_properties(
|
|||
( $([$getter:ident, $setter:ident, $cssprop:expr]),* ) => (
|
||||
$(
|
||||
fn $getter(&self) -> DOMString {
|
||||
self.GetPropertyValue($cssprop.to_owned())
|
||||
self.GetPropertyValue(DOMString($cssprop.to_owned()))
|
||||
}
|
||||
fn $setter(&self, value: DOMString) -> ErrorResult {
|
||||
self.SetPropertyValue($cssprop.to_owned(), value)
|
||||
self.SetPropertyValue(DOMString($cssprop.to_owned()), value)
|
||||
}
|
||||
)*
|
||||
);
|
||||
|
@ -50,7 +50,7 @@ macro_rules! css_properties(
|
|||
|
||||
fn serialize_list(list: &[Ref<PropertyDeclaration>]) -> DOMString {
|
||||
let str_iter = list.iter().map(|d| d.value());
|
||||
str_join(str_iter, " ")
|
||||
DOMString(str_join(str_iter, " "))
|
||||
}
|
||||
|
||||
impl CSSStyleDeclaration {
|
||||
|
@ -113,7 +113,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
|
|||
}
|
||||
});
|
||||
|
||||
result.unwrap_or("".to_owned())
|
||||
DOMString(result.unwrap_or(String::new()))
|
||||
}
|
||||
|
||||
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertyvalue
|
||||
|
@ -153,7 +153,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
|
|||
|
||||
// Step 3 & 4
|
||||
let result = match owner.get_inline_style_declaration(&property) {
|
||||
Some(declaration) => declaration.value(),
|
||||
Some(declaration) => DOMString(declaration.value()),
|
||||
None => DOMString::new(),
|
||||
};
|
||||
result
|
||||
|
@ -170,15 +170,15 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
|
|||
if let Some(longhand_properties) = longhand_properties {
|
||||
// Step 2.1 & 2.2 & 2.3
|
||||
if longhand_properties.iter()
|
||||
.map(|&longhand| self.GetPropertyPriority(longhand.to_owned()))
|
||||
.map(|&longhand| self.GetPropertyPriority(DOMString(longhand.to_owned())))
|
||||
.all(|priority| priority == "important") {
|
||||
|
||||
return "important".to_owned();
|
||||
return DOMString("important".to_owned());
|
||||
}
|
||||
// Step 3
|
||||
} else {
|
||||
if self.owner.get_important_inline_style_declaration(&property).is_some() {
|
||||
return "important".to_owned();
|
||||
return DOMString("important".to_owned());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -309,12 +309,12 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
|
|||
|
||||
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-cssfloat
|
||||
fn CssFloat(&self) -> DOMString {
|
||||
self.GetPropertyValue("float".to_owned())
|
||||
self.GetPropertyValue(DOMString("float".to_owned()))
|
||||
}
|
||||
|
||||
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-cssfloat
|
||||
fn SetCssFloat(&self, value: DOMString) -> ErrorResult {
|
||||
self.SetPropertyValue("float".to_owned(), value)
|
||||
self.SetPropertyValue(DOMString("float".to_owned()), value)
|
||||
}
|
||||
|
||||
// https://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue