mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Move DOMString into servo_util.
This commit is contained in:
parent
f1de0b7381
commit
59184bf6e1
96 changed files with 177 additions and 131 deletions
|
@ -5,6 +5,7 @@
|
|||
use dom::bindings::codegen::PrototypeList;
|
||||
use dom::bindings::codegen::PrototypeList::MAX_PROTO_CHAIN_LENGTH;
|
||||
use dom::window;
|
||||
use servo_util::str::DOMString;
|
||||
|
||||
use std::libc::c_uint;
|
||||
use std::cast;
|
||||
|
@ -114,31 +115,6 @@ extern fn InterfaceObjectToString(cx: *JSContext, _argc: c_uint, vp: *mut JSVal)
|
|||
}
|
||||
}
|
||||
|
||||
pub type DOMString = ~str;
|
||||
|
||||
pub fn null_str_as_empty(s: &Option<DOMString>) -> ~str {
|
||||
// We don't use map_default because it would allocate ~"" even for Some.
|
||||
match *s {
|
||||
Some(ref s) => s.clone(),
|
||||
None => ~""
|
||||
}
|
||||
}
|
||||
|
||||
pub fn null_str_as_empty_ref<'a>(s: &'a Option<DOMString>) -> &'a str {
|
||||
match *s {
|
||||
Some(ref s) => s.as_slice(),
|
||||
None => &'a ""
|
||||
}
|
||||
}
|
||||
|
||||
pub fn null_str_as_word_null(s: &Option<DOMString>) -> ~str {
|
||||
// We don't use map_default because it would allocate ~"null" even for Some.
|
||||
match *s {
|
||||
Some(ref s) => s.clone(),
|
||||
None => ~"null"
|
||||
}
|
||||
}
|
||||
|
||||
fn is_dom_class(clasp: *JSClass) -> bool {
|
||||
unsafe {
|
||||
((*clasp).flags & js::JSCLASS_IS_DOMJSCLASS) != 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue