mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Fix a bunch of clippy lints
This commit is contained in:
parent
b1ca3d1cdf
commit
6b215f38ee
58 changed files with 281 additions and 356 deletions
|
@ -191,7 +191,7 @@ impl Attr {
|
|||
/// Sets the owner element. Should be called after the attribute is added
|
||||
/// or removed from its older parent.
|
||||
pub fn set_owner(&self, owner: Option<&Element>) {
|
||||
let ref ns = self.identifier.namespace;
|
||||
let ns = &self.identifier.namespace;
|
||||
match (self.owner().r(), owner) {
|
||||
(None, Some(new)) => {
|
||||
// Already in the list of attributes of new owner.
|
||||
|
|
|
@ -486,7 +486,7 @@ impl RootCollection {
|
|||
}
|
||||
|
||||
/// Start tracking a stack-based root
|
||||
fn root<'b>(&self, untracked_reflector: *const Reflector) {
|
||||
fn root(&self, untracked_reflector: *const Reflector) {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
unsafe {
|
||||
let mut roots = &mut *self.roots.get();
|
||||
|
@ -496,7 +496,7 @@ impl RootCollection {
|
|||
}
|
||||
|
||||
/// Stop tracking a stack-based root, asserting if the reflector isn't found
|
||||
fn unroot<'b, T: Reflectable>(&self, rooted: &Root<T>) {
|
||||
fn unroot<T: Reflectable>(&self, rooted: &Root<T>) {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
unsafe {
|
||||
let mut roots = &mut *self.roots.get();
|
||||
|
|
|
@ -148,9 +148,10 @@ pub fn xml_name_type(name: &str) -> XMLName {
|
|||
return XMLName::InvalidXMLName;
|
||||
}
|
||||
if c == ':' {
|
||||
match seen_colon {
|
||||
true => non_qname_colons = true,
|
||||
false => seen_colon = true,
|
||||
if seen_colon {
|
||||
non_qname_colons = true;
|
||||
} else {
|
||||
seen_colon = true;
|
||||
}
|
||||
}
|
||||
last = c
|
||||
|
@ -160,9 +161,10 @@ pub fn xml_name_type(name: &str) -> XMLName {
|
|||
non_qname_colons = true
|
||||
}
|
||||
|
||||
match non_qname_colons {
|
||||
false => XMLName::QName,
|
||||
true => XMLName::Name,
|
||||
if non_qname_colons {
|
||||
XMLName::Name
|
||||
} else {
|
||||
XMLName::QName
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -320,10 +320,8 @@ impl CanvasRenderingContext2D {
|
|||
}
|
||||
};
|
||||
|
||||
if result.is_ok() {
|
||||
if !self.is_origin_clean(image) {
|
||||
self.set_origin_unclean()
|
||||
}
|
||||
if result.is_ok() && !self.is_origin_clean(image) {
|
||||
self.set_origin_unclean()
|
||||
}
|
||||
result
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
|
|||
}
|
||||
});
|
||||
|
||||
result.map(DOMString::from).unwrap_or(DOMString::new())
|
||||
result.map_or(DOMString::new(), DOMString::from)
|
||||
}
|
||||
|
||||
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertyvalue
|
||||
|
@ -175,11 +175,10 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
|
|||
}
|
||||
|
||||
// Step 3 & 4
|
||||
let result = match owner.get_inline_style_declaration(&property) {
|
||||
match owner.get_inline_style_declaration(&property) {
|
||||
Some(declaration) => DOMString::from(declaration.value()),
|
||||
None => DOMString::new(),
|
||||
};
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertypriority
|
||||
|
|
|
@ -1926,9 +1926,10 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
|
||||
// Step 2.
|
||||
let clone_children = match deep {
|
||||
true => CloneChildrenFlag::CloneChildren,
|
||||
false => CloneChildrenFlag::DoNotCloneChildren,
|
||||
let clone_children = if deep {
|
||||
CloneChildrenFlag::CloneChildren
|
||||
} else {
|
||||
CloneChildrenFlag::DoNotCloneChildren
|
||||
};
|
||||
|
||||
Ok(Node::clone(node, Some(self), clone_children))
|
||||
|
@ -2325,7 +2326,7 @@ impl DocumentMethods for Document {
|
|||
let (tx, rx) = ipc::channel().unwrap();
|
||||
let _ = self.window.resource_task().send(GetCookiesForUrl((*url).clone(), tx, NonHTTP));
|
||||
let cookies = rx.recv().unwrap();
|
||||
Ok(cookies.map(DOMString::from).unwrap_or(DOMString::from("")))
|
||||
Ok(cookies.map_or(DOMString::new(), DOMString::from))
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-cookie
|
||||
|
|
|
@ -54,10 +54,10 @@ impl DOMTokenList {
|
|||
impl DOMTokenListMethods for DOMTokenList {
|
||||
// https://dom.spec.whatwg.org/#dom-domtokenlist-length
|
||||
fn Length(&self) -> u32 {
|
||||
self.attribute().map(|attr| {
|
||||
self.attribute().map_or(0, |attr| {
|
||||
let attr = attr.r();
|
||||
attr.value().as_tokens().len()
|
||||
}).unwrap_or(0) as u32
|
||||
}) as u32
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-domtokenlist-item
|
||||
|
@ -71,13 +71,13 @@ impl DOMTokenListMethods for DOMTokenList {
|
|||
// https://dom.spec.whatwg.org/#dom-domtokenlist-contains
|
||||
fn Contains(&self, token: DOMString) -> Fallible<bool> {
|
||||
self.check_token_exceptions(&token).map(|token| {
|
||||
self.attribute().map(|attr| {
|
||||
self.attribute().map_or(false, |attr| {
|
||||
let attr = attr.r();
|
||||
attr.value()
|
||||
.as_tokens()
|
||||
.iter()
|
||||
.any(|atom: &Atom| *atom == token)
|
||||
}).unwrap_or(false)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -924,9 +924,8 @@ impl Element {
|
|||
// https://html.spec.whatwg.org/multipage/#attr-data-*
|
||||
pub fn set_custom_attribute(&self, name: DOMString, value: DOMString) -> ErrorResult {
|
||||
// Step 1.
|
||||
match xml_name_type(&name) {
|
||||
InvalidXMLName => return Err(Error::InvalidCharacter),
|
||||
_ => {}
|
||||
if let InvalidXMLName = xml_name_type(&name) {
|
||||
return Err(Error::InvalidCharacter);
|
||||
}
|
||||
|
||||
// Steps 2-5.
|
||||
|
@ -1012,8 +1011,7 @@ impl Element {
|
|||
}
|
||||
};
|
||||
self.get_attribute(&ns!(), &atom!("class"))
|
||||
.map(|attr| attr.value().as_tokens().iter().any(|atom| is_equal(name, atom)))
|
||||
.unwrap_or(false)
|
||||
.map_or(false, |attr| attr.value().as_tokens().iter().any(|atom| is_equal(name, atom)))
|
||||
}
|
||||
|
||||
pub fn set_atomic_attribute(&self, local_name: &Atom, value: DOMString) {
|
||||
|
@ -1884,10 +1882,11 @@ impl Element {
|
|||
}
|
||||
let node = self.upcast::<Node>();
|
||||
node.owner_doc().element_state_will_change(self);
|
||||
match value {
|
||||
true => state.insert(which),
|
||||
false => state.remove(which),
|
||||
};
|
||||
if value {
|
||||
state.insert(which);
|
||||
} else {
|
||||
state.remove(which);
|
||||
}
|
||||
self.state.set(state);
|
||||
}
|
||||
|
||||
|
|
|
@ -355,24 +355,21 @@ impl EventTargetMethods for EventTarget {
|
|||
ty: DOMString,
|
||||
listener: Option<Rc<EventListener>>,
|
||||
capture: bool) {
|
||||
match listener {
|
||||
Some(listener) => {
|
||||
let mut handlers = self.handlers.borrow_mut();
|
||||
let entry = match handlers.entry(Atom::from(&*ty)) {
|
||||
Occupied(entry) => entry.into_mut(),
|
||||
Vacant(entry) => entry.insert(vec!()),
|
||||
};
|
||||
if let Some(listener) = listener {
|
||||
let mut handlers = self.handlers.borrow_mut();
|
||||
let entry = match handlers.entry(Atom::from(&*ty)) {
|
||||
Occupied(entry) => entry.into_mut(),
|
||||
Vacant(entry) => entry.insert(vec!()),
|
||||
};
|
||||
|
||||
let phase = if capture { ListenerPhase::Capturing } else { ListenerPhase::Bubbling };
|
||||
let new_entry = EventListenerEntry {
|
||||
phase: phase,
|
||||
listener: EventListenerType::Additive(listener)
|
||||
};
|
||||
if !entry.contains(&new_entry) {
|
||||
entry.push(new_entry);
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
let phase = if capture { ListenerPhase::Capturing } else { ListenerPhase::Bubbling };
|
||||
let new_entry = EventListenerEntry {
|
||||
phase: phase,
|
||||
listener: EventListenerType::Additive(listener)
|
||||
};
|
||||
if !entry.contains(&new_entry) {
|
||||
entry.push(new_entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -381,22 +378,19 @@ impl EventTargetMethods for EventTarget {
|
|||
ty: DOMString,
|
||||
listener: Option<Rc<EventListener>>,
|
||||
capture: bool) {
|
||||
match listener {
|
||||
Some(ref listener) => {
|
||||
let mut handlers = self.handlers.borrow_mut();
|
||||
let entry = handlers.get_mut(&Atom::from(&*ty));
|
||||
for entry in entry {
|
||||
let phase = if capture { ListenerPhase::Capturing } else { ListenerPhase::Bubbling };
|
||||
let old_entry = EventListenerEntry {
|
||||
phase: phase,
|
||||
listener: EventListenerType::Additive(listener.clone())
|
||||
};
|
||||
if let Some(position) = entry.iter().position(|e| *e == old_entry) {
|
||||
entry.remove(position);
|
||||
}
|
||||
if let Some(ref listener) = listener {
|
||||
let mut handlers = self.handlers.borrow_mut();
|
||||
let entry = handlers.get_mut(&Atom::from(&*ty));
|
||||
for entry in entry {
|
||||
let phase = if capture { ListenerPhase::Capturing } else { ListenerPhase::Bubbling };
|
||||
let old_entry = EventListenerEntry {
|
||||
phase: phase,
|
||||
listener: EventListenerType::Additive(listener.clone())
|
||||
};
|
||||
if let Some(position) = entry.iter().position(|e| *e == old_entry) {
|
||||
entry.remove(position);
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -287,8 +287,8 @@ impl<'a> Iterator for HTMLCollectionElementsIter<'a> {
|
|||
type Item = Root<Element>;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
let ref filter = self.filter;
|
||||
let ref root = self.root;
|
||||
let filter = &self.filter;
|
||||
let root = &self.root;
|
||||
self.node_iter.by_ref()
|
||||
.filter_map(Root::downcast)
|
||||
.filter(|element| filter.filter(&element, root))
|
||||
|
@ -306,8 +306,8 @@ impl<'a> Iterator for HTMLCollectionElementsRevIter<'a> {
|
|||
type Item = Root<Element>;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
let ref filter = self.filter;
|
||||
let ref root = self.root;
|
||||
let filter = &self.filter;
|
||||
let root = &self.root;
|
||||
self.node_iter.by_ref()
|
||||
.filter_map(Root::downcast)
|
||||
.filter(|element| filter.filter(&element, root))
|
||||
|
|
|
@ -307,40 +307,37 @@ impl HTMLFormElement {
|
|||
.any(|a| Root::downcast::<HTMLDataListElement>(a).is_some()) {
|
||||
continue;
|
||||
}
|
||||
match child.type_id() {
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(element)) => {
|
||||
match element {
|
||||
HTMLElementTypeId::HTMLInputElement => {
|
||||
let input = child.downcast::<HTMLInputElement>().unwrap();
|
||||
// Step 3.2-3.7
|
||||
if let Some(datum) = input.get_form_datum(submitter) {
|
||||
data_set.push(datum);
|
||||
}
|
||||
if let NodeTypeId::Element(ElementTypeId::HTMLElement(element)) = child.type_id() {
|
||||
match element {
|
||||
HTMLElementTypeId::HTMLInputElement => {
|
||||
let input = child.downcast::<HTMLInputElement>().unwrap();
|
||||
// Step 3.2-3.7
|
||||
if let Some(datum) = input.get_form_datum(submitter) {
|
||||
data_set.push(datum);
|
||||
}
|
||||
HTMLElementTypeId::HTMLButtonElement |
|
||||
HTMLElementTypeId::HTMLObjectElement => {
|
||||
// Unimplemented
|
||||
()
|
||||
}
|
||||
HTMLElementTypeId::HTMLSelectElement => {
|
||||
let select = child.downcast::<HTMLSelectElement>().unwrap();
|
||||
select.push_form_data(&mut data_set);
|
||||
}
|
||||
HTMLElementTypeId::HTMLTextAreaElement => {
|
||||
let textarea = child.downcast::<HTMLTextAreaElement>().unwrap();
|
||||
let name = textarea.Name();
|
||||
if !name.is_empty() {
|
||||
data_set.push(FormDatum {
|
||||
ty: textarea.Type(),
|
||||
name: name,
|
||||
value: textarea.Value()
|
||||
});
|
||||
}
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
HTMLElementTypeId::HTMLButtonElement |
|
||||
HTMLElementTypeId::HTMLObjectElement => {
|
||||
// Unimplemented
|
||||
()
|
||||
}
|
||||
HTMLElementTypeId::HTMLSelectElement => {
|
||||
let select = child.downcast::<HTMLSelectElement>().unwrap();
|
||||
select.push_form_data(&mut data_set);
|
||||
}
|
||||
HTMLElementTypeId::HTMLTextAreaElement => {
|
||||
let textarea = child.downcast::<HTMLTextAreaElement>().unwrap();
|
||||
let name = textarea.Name();
|
||||
if !name.is_empty() {
|
||||
data_set.push(FormDatum {
|
||||
ty: textarea.Type(),
|
||||
name: name,
|
||||
value: textarea.Value()
|
||||
});
|
||||
}
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
data_set
|
||||
|
@ -603,14 +600,11 @@ pub trait FormControl: DerivedFrom<Element> + Reflectable {
|
|||
if !owner.is_empty() {
|
||||
let doc = document_from_node(elem);
|
||||
let owner = doc.GetElementById(owner);
|
||||
match owner {
|
||||
Some(ref o) => {
|
||||
let maybe_form = o.downcast::<HTMLFormElement>();
|
||||
if maybe_form.is_some() {
|
||||
return maybe_form.map(Root::from_ref);
|
||||
}
|
||||
},
|
||||
_ => ()
|
||||
if let Some(ref o) = owner {
|
||||
let maybe_form = o.downcast::<HTMLFormElement>();
|
||||
if maybe_form.is_some() {
|
||||
return maybe_form.map(Root::from_ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
elem.upcast::<Node>().ancestors().filter_map(Root::downcast).next()
|
||||
|
|
|
@ -596,7 +596,7 @@ impl VirtualMethods for HTMLInputElement {
|
|||
&atom!("value") if !self.value_changed.get() => {
|
||||
let value = mutation.new_value(attr).map(|value| (**value).to_owned());
|
||||
self.textinput.borrow_mut().set_content(
|
||||
value.map(DOMString::from).unwrap_or(DOMString::from("")));
|
||||
value.map_or(DOMString::new(), DOMString::from));
|
||||
},
|
||||
&atom!("name") if self.input_type.get() == InputType::InputRadio => {
|
||||
self.radio_group_updated(
|
||||
|
@ -663,9 +663,8 @@ impl VirtualMethods for HTMLInputElement {
|
|||
}
|
||||
|
||||
if event.type_() == atom!("click") && !event.DefaultPrevented() {
|
||||
match self.input_type.get() {
|
||||
InputType::InputRadio => self.update_checked_state(true, true),
|
||||
_ => {}
|
||||
if let InputType::InputRadio = self.input_type.get() {
|
||||
self.update_checked_state(true, true);
|
||||
}
|
||||
|
||||
// TODO: Dispatch events for non activatable inputs
|
||||
|
|
|
@ -49,7 +49,7 @@ impl Activatable for HTMLLabelElement {
|
|||
}
|
||||
|
||||
fn is_instance_activatable(&self) -> bool {
|
||||
return true;
|
||||
true
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#run-pre-click-activation-steps
|
||||
|
|
|
@ -53,9 +53,8 @@ impl HTMLMetaElement {
|
|||
let name = name.value().to_ascii_lowercase();
|
||||
let name = name.trim_matches(HTML_SPACE_CHARACTERS);
|
||||
|
||||
match name {
|
||||
"viewport" => self.apply_viewport(),
|
||||
_ => {}
|
||||
if name == "viewport" {
|
||||
self.apply_viewport();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -287,7 +287,7 @@ impl HTMLScriptElement {
|
|||
}));
|
||||
|
||||
let (action_sender, action_receiver) = ipc::channel().unwrap();
|
||||
let listener = box NetworkListener {
|
||||
let listener = NetworkListener {
|
||||
context: context,
|
||||
script_chan: script_chan,
|
||||
};
|
||||
|
@ -354,7 +354,7 @@ impl HTMLScriptElement {
|
|||
parser.r().suspend();
|
||||
}
|
||||
}
|
||||
return NextParserState::Suspend;
|
||||
NextParserState::Suspend
|
||||
}
|
||||
|
||||
pub fn is_ready_to_be_executed(&self) -> bool {
|
||||
|
|
|
@ -72,7 +72,7 @@ impl HTMLTableCellElementMethods for HTMLTableCellElement {
|
|||
|
||||
parent_children.filter(|c| c.is::<HTMLTableCellElement>())
|
||||
.position(|c| c.r() == self_node)
|
||||
.map(|p| p as i32).unwrap_or(-1)
|
||||
.map_or(-1, |p| p as i32)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,8 +73,7 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutJS<HTMLTextAreaElement> {
|
|||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &atom!("cols"))
|
||||
.map(AttrValue::as_uint)
|
||||
.unwrap_or(DEFAULT_COLS)
|
||||
.map_or(DEFAULT_COLS, AttrValue::as_uint)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,8 +82,7 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutJS<HTMLTextAreaElement> {
|
|||
unsafe {
|
||||
(*self.upcast::<Element>().unsafe_get())
|
||||
.get_attr_for_layout(&ns!(), &atom!("rows"))
|
||||
.map(AttrValue::as_uint)
|
||||
.unwrap_or(DEFAULT_ROWS)
|
||||
.map_or(DEFAULT_ROWS, AttrValue::as_uint)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -768,7 +768,7 @@ impl Node {
|
|||
NodeInfo {
|
||||
uniqueId: self.get_unique_id(),
|
||||
baseURI: String::from(self.BaseURI()),
|
||||
parent: self.GetParentNode().map(|node| node.get_unique_id()).unwrap_or("".to_owned()),
|
||||
parent: self.GetParentNode().map_or("".to_owned(), |node| node.get_unique_id()),
|
||||
nodeType: self.NodeType(),
|
||||
namespaceURI: String::new(), //FIXME
|
||||
nodeName: String::from(self.NodeName()),
|
||||
|
@ -783,8 +783,7 @@ impl Node {
|
|||
isDocumentElement:
|
||||
self.owner_doc()
|
||||
.GetDocumentElement()
|
||||
.map(|elem| elem.upcast::<Node>() == self)
|
||||
.unwrap_or(false),
|
||||
.map_or(false, |elem| elem.upcast::<Node>() == self),
|
||||
|
||||
shortValue: self.GetNodeValue().map(String::from).unwrap_or_default(), //FIXME: truncate
|
||||
incompleteValue: false, //FIXME: reflect truncation
|
||||
|
@ -1602,9 +1601,10 @@ impl Node {
|
|||
},
|
||||
NodeTypeId::Document(_) => {
|
||||
let document = node.downcast::<Document>().unwrap();
|
||||
let is_html_doc = match document.is_html_document() {
|
||||
true => IsHTMLDocument::HTMLDocument,
|
||||
false => IsHTMLDocument::NonHTMLDocument,
|
||||
let is_html_doc = if document.is_html_document() {
|
||||
IsHTMLDocument::HTMLDocument
|
||||
} else {
|
||||
IsHTMLDocument::NonHTMLDocument
|
||||
};
|
||||
let window = document.window();
|
||||
let loader = DocumentLoader::new(&*document.loader());
|
||||
|
@ -2435,8 +2435,7 @@ impl<'a> UnbindContext<'a> {
|
|||
if let Some(index) = self.index.get() {
|
||||
return index;
|
||||
}
|
||||
let index =
|
||||
self.prev_sibling.map(|sibling| sibling.index() + 1).unwrap_or(0);
|
||||
let index = self.prev_sibling.map_or(0, |sibling| sibling.index() + 1);
|
||||
self.index.set(Some(index));
|
||||
index
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ pub fn load_script(head: &HTMLHeadElement) {
|
|||
PathBuf::from(path_str)
|
||||
};
|
||||
|
||||
let mut files = read_dir(&path).ok().expect("Bad path passed to --userscripts")
|
||||
let mut files = read_dir(&path).expect("Bad path passed to --userscripts")
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| e.path()).collect::<Vec<_>>();
|
||||
|
||||
|
|
|
@ -323,7 +323,7 @@ impl Window {
|
|||
}
|
||||
|
||||
pub fn css_error_reporter(&self) -> Box<ParseErrorReporter + Send> {
|
||||
return self.error_reporter.clone();
|
||||
self.error_reporter.clone()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -782,9 +782,7 @@ impl WindowMethods for Window {
|
|||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-window-devicepixelratio
|
||||
fn DevicePixelRatio(&self) -> Finite<f64> {
|
||||
let dpr = self.window_size.get()
|
||||
.map(|data| data.device_pixel_ratio.get())
|
||||
.unwrap_or(1.0f32);
|
||||
let dpr = self.window_size.get().map_or(1.0f32, |data| data.device_pixel_ratio.get());
|
||||
Finite::wrap(dpr as f64)
|
||||
}
|
||||
}
|
||||
|
@ -904,10 +902,10 @@ impl Window {
|
|||
let point = Point2D::new(x, y);
|
||||
let smooth = match behavior {
|
||||
ScrollBehavior::Auto => {
|
||||
element.map(|_element| {
|
||||
element.map_or(false, |_element| {
|
||||
// TODO check computed scroll-behaviour CSS property
|
||||
true
|
||||
}).unwrap_or(false)
|
||||
})
|
||||
}
|
||||
ScrollBehavior::Instant => false,
|
||||
ScrollBehavior::Smooth => true
|
||||
|
|
|
@ -271,7 +271,7 @@ impl XMLHttpRequest {
|
|||
}
|
||||
|
||||
let (action_sender, action_receiver) = ipc::channel().unwrap();
|
||||
let listener = box NetworkListener {
|
||||
let listener = NetworkListener {
|
||||
context: context,
|
||||
script_chan: script_chan,
|
||||
};
|
||||
|
@ -483,7 +483,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
|||
_ => data
|
||||
};
|
||||
let extracted = data.as_ref().map(|d| d.extract());
|
||||
self.request_body_len.set(extracted.as_ref().map(|e| e.len()).unwrap_or(0));
|
||||
self.request_body_len.set(extracted.as_ref().map_or(0, |e| e.len()));
|
||||
|
||||
// Step 6
|
||||
self.upload_events.set(false);
|
||||
|
@ -1120,13 +1120,12 @@ impl XMLHttpRequest {
|
|||
let content_type = mime_type.map(|mime|{
|
||||
DOMString::from(format!("{}", mime))
|
||||
});
|
||||
let document = Document::new(win,
|
||||
parsed_url,
|
||||
is_html_document,
|
||||
content_type,
|
||||
None,
|
||||
DocumentSource::FromParser, docloader);
|
||||
document
|
||||
Document::new(win,
|
||||
parsed_url,
|
||||
is_html_document,
|
||||
content_type,
|
||||
None,
|
||||
DocumentSource::FromParser, docloader)
|
||||
}
|
||||
|
||||
fn filter_response_headers(&self) -> Headers {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue