From 2be8901a8afa6e31d722cbe8022cf7b30c17fbe9 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Tue, 24 Mar 2015 10:33:55 -0600 Subject: [PATCH] servo: Merge #5343 - Clean up a few things in script::dom::window (from frewsxcv:script-dom-window); r=jdm Source-Repo: https://github.com/servo/servo Source-Revision: 1432b630d2fb54be1bae512d3a37cc0aee714db4 --- servo/components/script/dom/window.rs | 54 +++++++++++++-------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/servo/components/script/dom/window.rs b/servo/components/script/dom/window.rs index 88178374a455..16fd8358eb71 100644 --- a/servo/components/script/dom/window.rs +++ b/servo/components/script/dom/window.rs @@ -270,11 +270,9 @@ pub fn base64_atob(atob: DOMString) -> Fallible { // U+002B PLUS SIGN (+) // U+002F SOLIDUS (/) // Alphanumeric ASCII characters" - if input.chars() - .find(|&c| !(c == '+' || c == '/' || c.is_alphanumeric())) - .is_some() { - return Err(InvalidCharacter) - } + if input.chars().any(|c| c != '+' && c != '/' && !c.is_alphanumeric()) { + return Err(InvalidCharacter) + } match input.from_base64() { Ok(data) => Ok(data.iter().map(|&b| b as char).collect::()), @@ -631,7 +629,7 @@ impl<'a> WindowHelpers for JSRef<'a, Window> { fn load_url(self, href: DOMString) { let base_url = self.get_url(); debug!("current page url is {}", base_url); - let url = UrlParser::new().base_url(&base_url).parse(href.as_slice()); + let url = UrlParser::new().base_url(&base_url).parse(&href); // FIXME: handle URL parse errors more gracefully. let url = url.unwrap(); match url.fragment { @@ -842,30 +840,30 @@ fn should_move_clip_rect(clip_rect: Rect, new_viewport: Rect) -> bool{ fn debug_reflow_events(goal: &ReflowGoal, query_type: &ReflowQueryType, reason: &ReflowReason) { let mut debug_msg = String::from_str("****"); - match *goal { - ReflowGoal::ForDisplay => debug_msg.push_str("\tForDisplay"), - ReflowGoal::ForScriptQuery => debug_msg.push_str("\tForScriptQuery"), - } + debug_msg.push_str(match *goal { + ReflowGoal::ForDisplay => "\tForDisplay", + ReflowGoal::ForScriptQuery => "\tForScriptQuery", + }); - match *query_type { - ReflowQueryType::NoQuery => debug_msg.push_str("\tNoQuery"), - ReflowQueryType::ContentBoxQuery(_n) => debug_msg.push_str("\tContentBoxQuery"), - ReflowQueryType::ContentBoxesQuery(_n) => debug_msg.push_str("\tContentBoxesQuery"), - } + debug_msg.push_str(match *query_type { + ReflowQueryType::NoQuery => "\tNoQuery", + ReflowQueryType::ContentBoxQuery(_n) => "\tContentBoxQuery", + ReflowQueryType::ContentBoxesQuery(_n) => "\tContentBoxesQuery", + }); - match *reason { - ReflowReason::CachedPageNeededReflow => debug_msg.push_str("\tCachedPageNeededReflow"), - ReflowReason::FirstLoad => debug_msg.push_str("\tFirstLoad"), - ReflowReason::KeyEvent => debug_msg.push_str("\tKeyEvent"), - ReflowReason::MouseEvent => debug_msg.push_str("\tMouseEvent"), - ReflowReason::Query => debug_msg.push_str("\tQuery"), - ReflowReason::ReceivedReflowEvent => debug_msg.push_str("\tReceivedReflowEvent"), - ReflowReason::Timer => debug_msg.push_str("\tTimer"), - ReflowReason::Viewport => debug_msg.push_str("\tViewport"), - ReflowReason::WindowResize => debug_msg.push_str("\tWindowResize"), - ReflowReason::DOMContentLoaded => debug_msg.push_str("\tDOMContentLoaded"), - ReflowReason::DocumentLoaded => debug_msg.push_str("\tDocumentLoaded"), - } + debug_msg.push_str(match *reason { + ReflowReason::CachedPageNeededReflow => "\tCachedPageNeededReflow", + ReflowReason::FirstLoad => "\tFirstLoad", + ReflowReason::KeyEvent => "\tKeyEvent", + ReflowReason::MouseEvent => "\tMouseEvent", + ReflowReason::Query => "\tQuery", + ReflowReason::ReceivedReflowEvent => "\tReceivedReflowEvent", + ReflowReason::Timer => "\tTimer", + ReflowReason::Viewport => "\tViewport", + ReflowReason::WindowResize => "\tWindowResize", + ReflowReason::DOMContentLoaded => "\tDOMContentLoaded", + ReflowReason::DocumentLoaded => "\tDocumentLoaded", + }); println!("{}", debug_msg); }