mirror of
https://github.com/servo/servo.git
synced 2025-08-01 19:50:30 +01:00
Auto merge of #7987 - frewsxcv:clippy, r=Manishearth
Fix issues found by rust-clippy <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7987) <!-- Reviewable:end -->
This commit is contained in:
commit
eb7039d04d
23 changed files with 106 additions and 121 deletions
|
@ -756,7 +756,7 @@ fn is_zero_size_gradient(pattern: &Pattern) -> bool {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait PointToi32 {
|
pub trait PointToi32 {
|
||||||
|
|
|
@ -178,7 +178,7 @@ impl FontHandleMethods for FontHandle {
|
||||||
let max_advance_width = au_from_pt(bounding_rect.size.width as f64);
|
let max_advance_width = au_from_pt(bounding_rect.size.width as f64);
|
||||||
let average_advance = self.glyph_index('0')
|
let average_advance = self.glyph_index('0')
|
||||||
.and_then(|idx| self.glyph_h_advance(idx))
|
.and_then(|idx| self.glyph_h_advance(idx))
|
||||||
.map(|advance| Au::from_f64_px(advance))
|
.map(Au::from_f64_px)
|
||||||
.unwrap_or(max_advance_width);
|
.unwrap_or(max_advance_width);
|
||||||
|
|
||||||
let metrics = FontMetrics {
|
let metrics = FontMetrics {
|
||||||
|
@ -201,7 +201,7 @@ impl FontHandleMethods for FontHandle {
|
||||||
line_gap: Au::from_f64_px(line_gap),
|
line_gap: Au::from_f64_px(line_gap),
|
||||||
};
|
};
|
||||||
debug!("Font metrics (@{} pt): {:?}", self.ctfont.pt_size() as f64, metrics);
|
debug!("Font metrics (@{} pt): {:?}", self.ctfont.pt_size() as f64, metrics);
|
||||||
return metrics;
|
metrics
|
||||||
}
|
}
|
||||||
|
|
||||||
fn table_for_tag(&self, tag: FontTableTag) -> Option<Box<FontTable>> {
|
fn table_for_tag(&self, tag: FontTableTag) -> Option<Box<FontTable>> {
|
||||||
|
|
|
@ -1479,7 +1479,7 @@ impl Fragment {
|
||||||
let character_breaking_strategy =
|
let character_breaking_strategy =
|
||||||
text_fragment_info.run.character_slices_in_range(&text_fragment_info.range);
|
text_fragment_info.run.character_slices_in_range(&text_fragment_info.range);
|
||||||
flags.remove(RETRY_AT_CHARACTER_BOUNDARIES);
|
flags.remove(RETRY_AT_CHARACTER_BOUNDARIES);
|
||||||
return self.calculate_split_position_using_breaking_strategy(
|
self.calculate_split_position_using_breaking_strategy(
|
||||||
character_breaking_strategy,
|
character_breaking_strategy,
|
||||||
max_inline_size,
|
max_inline_size,
|
||||||
flags)
|
flags)
|
||||||
|
@ -1685,7 +1685,7 @@ impl Fragment {
|
||||||
|
|
||||||
/// Assigns replaced inline-size, padding, and margins for this fragment only if it is replaced
|
/// Assigns replaced inline-size, padding, and margins for this fragment only if it is replaced
|
||||||
/// content per CSS 2.1 § 10.3.2.
|
/// content per CSS 2.1 § 10.3.2.
|
||||||
pub fn assign_replaced_inline_size_if_necessary<'a>(&'a mut self, container_inline_size: Au) {
|
pub fn assign_replaced_inline_size_if_necessary(&mut self, container_inline_size: Au) {
|
||||||
match self.specific {
|
match self.specific {
|
||||||
SpecificFragmentInfo::Generic |
|
SpecificFragmentInfo::Generic |
|
||||||
SpecificFragmentInfo::GeneratedContent(_) |
|
SpecificFragmentInfo::GeneratedContent(_) |
|
||||||
|
@ -2257,7 +2257,7 @@ impl Fragment {
|
||||||
CharIndex(leading_whitespace_character_count),
|
CharIndex(leading_whitespace_character_count),
|
||||||
-CharIndex(leading_whitespace_character_count));
|
-CharIndex(leading_whitespace_character_count));
|
||||||
|
|
||||||
return WhitespaceStrippingResult::RetainFragment
|
WhitespaceStrippingResult::RetainFragment
|
||||||
}
|
}
|
||||||
SpecificFragmentInfo::UnscannedText(ref mut unscanned_text_fragment_info) => {
|
SpecificFragmentInfo::UnscannedText(ref mut unscanned_text_fragment_info) => {
|
||||||
let mut new_text_string = String::new();
|
let mut new_text_string = String::new();
|
||||||
|
|
|
@ -184,11 +184,11 @@ impl<'a,'b> ResolveGeneratedContentFragmentMutator<'a,'b> {
|
||||||
}
|
}
|
||||||
GeneratedContentInfo::ContentItem(ContentItem::Counter(ref counter_name,
|
GeneratedContentInfo::ContentItem(ContentItem::Counter(ref counter_name,
|
||||||
counter_style)) => {
|
counter_style)) => {
|
||||||
let mut temporary_counter = Counter::new();
|
let temporary_counter = Counter::new();
|
||||||
let counter = self.traversal
|
let counter = self.traversal
|
||||||
.counters
|
.counters
|
||||||
.get(&*counter_name)
|
.get(&*counter_name)
|
||||||
.unwrap_or(&mut temporary_counter);
|
.unwrap_or(&temporary_counter);
|
||||||
new_info = counter.render(self.traversal.layout_context,
|
new_info = counter.render(self.traversal.layout_context,
|
||||||
fragment.node,
|
fragment.node,
|
||||||
fragment.pseudo.clone(),
|
fragment.pseudo.clone(),
|
||||||
|
@ -199,11 +199,11 @@ impl<'a,'b> ResolveGeneratedContentFragmentMutator<'a,'b> {
|
||||||
GeneratedContentInfo::ContentItem(ContentItem::Counters(ref counter_name,
|
GeneratedContentInfo::ContentItem(ContentItem::Counters(ref counter_name,
|
||||||
ref separator,
|
ref separator,
|
||||||
counter_style)) => {
|
counter_style)) => {
|
||||||
let mut temporary_counter = Counter::new();
|
let temporary_counter = Counter::new();
|
||||||
let counter = self.traversal
|
let counter = self.traversal
|
||||||
.counters
|
.counters
|
||||||
.get(&*counter_name)
|
.get(&*counter_name)
|
||||||
.unwrap_or(&mut temporary_counter);
|
.unwrap_or(&temporary_counter);
|
||||||
new_info = counter.render(self.traversal.layout_context,
|
new_info = counter.render(self.traversal.layout_context,
|
||||||
fragment.node,
|
fragment.node,
|
||||||
fragment.pseudo,
|
fragment.pseudo,
|
||||||
|
|
|
@ -1452,7 +1452,7 @@ impl LayoutTask {
|
||||||
// Parallel mode.
|
// Parallel mode.
|
||||||
self.solve_constraints_parallel(parallel,
|
self.solve_constraints_parallel(parallel,
|
||||||
&mut root_flow,
|
&mut root_flow,
|
||||||
&mut *layout_context);
|
&*layout_context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -154,7 +154,7 @@ impl Cookie {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.cookie.secure && url.scheme != "https".to_owned() {
|
if self.cookie.secure && url.scheme != "https" {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if self.cookie.httponly && source == CookieSource::NonHTTP {
|
if self.cookie.httponly && source == CookieSource::NonHTTP {
|
||||||
|
|
|
@ -75,10 +75,9 @@ fn send_error(url: Url, err: String, start_chan: LoadConsumer) {
|
||||||
let mut metadata: Metadata = Metadata::default(url);
|
let mut metadata: Metadata = Metadata::default(url);
|
||||||
metadata.status = None;
|
metadata.status = None;
|
||||||
|
|
||||||
match start_sending_opt(start_chan, metadata) {
|
if let Ok(p) = start_sending_opt(start_chan, metadata) {
|
||||||
Ok(p) => p.send(Done(Err(err))).unwrap(),
|
p.send(Done(Err(err))).unwrap();
|
||||||
_ => {}
|
}
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ReadResult {
|
enum ReadResult {
|
||||||
|
@ -157,8 +156,8 @@ pub trait HttpResponse: Read {
|
||||||
|
|
||||||
fn content_encoding(&self) -> Option<Encoding> {
|
fn content_encoding(&self) -> Option<Encoding> {
|
||||||
self.headers().get::<ContentEncoding>().and_then(|h| {
|
self.headers().get::<ContentEncoding>().and_then(|h| {
|
||||||
match h {
|
match *h {
|
||||||
&ContentEncoding(ref encodings) => {
|
ContentEncoding(ref encodings) => {
|
||||||
if encodings.contains(&Encoding::Gzip) {
|
if encodings.contains(&Encoding::Gzip) {
|
||||||
Some(Encoding::Gzip)
|
Some(Encoding::Gzip)
|
||||||
} else if encodings.contains(&Encoding::Deflate) {
|
} else if encodings.contains(&Encoding::Deflate) {
|
||||||
|
|
|
@ -173,7 +173,7 @@ impl ResourceChannelManager {
|
||||||
self.resource_manager.set_cookies_for_url(request, cookie_list, source)
|
self.resource_manager.set_cookies_for_url(request, cookie_list, source)
|
||||||
}
|
}
|
||||||
ControlMsg::GetCookiesForUrl(url, consumer, source) => {
|
ControlMsg::GetCookiesForUrl(url, consumer, source) => {
|
||||||
let ref cookie_jar = self.resource_manager.cookie_storage;
|
let cookie_jar = &self.resource_manager.cookie_storage;
|
||||||
let mut cookie_jar = cookie_jar.write().unwrap();
|
let mut cookie_jar = cookie_jar.write().unwrap();
|
||||||
consumer.send(cookie_jar.cookies_for_url(&url, source)).unwrap();
|
consumer.send(cookie_jar.cookies_for_url(&url, source)).unwrap();
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ impl ResourceManager {
|
||||||
if let Ok(SetCookie(cookies)) = header {
|
if let Ok(SetCookie(cookies)) = header {
|
||||||
for bare_cookie in cookies {
|
for bare_cookie in cookies {
|
||||||
if let Some(cookie) = cookie::Cookie::new_wrapped(bare_cookie, &request, source) {
|
if let Some(cookie) = cookie::Cookie::new_wrapped(bare_cookie, &request, source) {
|
||||||
let ref cookie_jar = self.cookie_storage;
|
let cookie_jar = &self.cookie_storage;
|
||||||
let mut cookie_jar = cookie_jar.write().unwrap();
|
let mut cookie_jar = cookie_jar.write().unwrap();
|
||||||
cookie_jar.push(cookie, source);
|
cookie_jar.push(cookie, source);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,16 +74,11 @@ impl Profiler {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start(&mut self) {
|
pub fn start(&mut self) {
|
||||||
loop {
|
while let Ok(msg) = self.port.recv() {
|
||||||
match self.port.recv() {
|
|
||||||
Ok(msg) => {
|
|
||||||
if !self.handle_msg(msg) {
|
if !self.handle_msg(msg) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_msg(&mut self, msg: ProfilerMsg) -> bool {
|
fn handle_msg(&mut self, msg: ProfilerMsg) -> bool {
|
||||||
|
|
|
@ -22,9 +22,9 @@ pub trait Formattable {
|
||||||
|
|
||||||
impl Formattable for Option<TimerMetadata> {
|
impl Formattable for Option<TimerMetadata> {
|
||||||
fn format(&self) -> String {
|
fn format(&self) -> String {
|
||||||
match self {
|
match *self {
|
||||||
// TODO(cgaebel): Center-align in the format strings as soon as rustc supports it.
|
// TODO(cgaebel): Center-align in the format strings as soon as rustc supports it.
|
||||||
&Some(ref meta) => {
|
Some(ref meta) => {
|
||||||
let url = &*meta.url;
|
let url = &*meta.url;
|
||||||
let url = if url.len() > 30 {
|
let url = if url.len() > 30 {
|
||||||
&url[..30]
|
&url[..30]
|
||||||
|
@ -35,7 +35,7 @@ impl Formattable for Option<TimerMetadata> {
|
||||||
let iframe = if meta.iframe { " yes" } else { " no " };
|
let iframe = if meta.iframe { " yes" } else { " no " };
|
||||||
format!(" {:14} {:9} {:30}", incremental, iframe, url)
|
format!(" {:14} {:9} {:30}", incremental, iframe, url)
|
||||||
},
|
},
|
||||||
&None =>
|
None =>
|
||||||
format!(" {:14} {:9} {:30}", " N/A", " N/A", " N/A")
|
format!(" {:14} {:9} {:30}", " N/A", " N/A", " N/A")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,17 +198,11 @@ impl Profiler {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start(&mut self) {
|
pub fn start(&mut self) {
|
||||||
loop {
|
while let Ok(msg) = self.port.recv() {
|
||||||
let msg = self.port.recv();
|
|
||||||
match msg {
|
|
||||||
Ok(msg) => {
|
|
||||||
if !self.handle_msg(msg) {
|
if !self.handle_msg(msg) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_or_insert(&mut self, k: (ProfilerCategory, Option<TimerMetadata>), t: f64) {
|
fn find_or_insert(&mut self, k: (ProfilerCategory, Option<TimerMetadata>), t: f64) {
|
||||||
|
@ -227,10 +221,9 @@ impl Profiler {
|
||||||
let ms = (t.1 - t.0) as f64 / 1000000f64;
|
let ms = (t.1 - t.0) as f64 / 1000000f64;
|
||||||
self.find_or_insert(k, ms);
|
self.find_or_insert(k, ms);
|
||||||
},
|
},
|
||||||
ProfilerMsg::Print => match self.last_msg {
|
ProfilerMsg::Print => if let Some(ProfilerMsg::Time(..)) = self.last_msg {
|
||||||
// only print if more data has arrived since the last printout
|
// only print if more data has arrived since the last printout
|
||||||
Some(ProfilerMsg::Time(..)) => self.print_buckets(),
|
self.print_buckets();
|
||||||
_ => ()
|
|
||||||
},
|
},
|
||||||
ProfilerMsg::Exit => {
|
ProfilerMsg::Exit => {
|
||||||
heartbeats::cleanup();
|
heartbeats::cleanup();
|
||||||
|
|
|
@ -112,5 +112,5 @@ pub fn profile<T, F>(category: ProfilerCategory,
|
||||||
profiler_chan.send(ProfilerMsg::Time((category, meta),
|
profiler_chan.send(ProfilerMsg::Time((category, meta),
|
||||||
(start_time, end_time),
|
(start_time, end_time),
|
||||||
(start_energy, end_energy)));
|
(start_energy, end_energy)));
|
||||||
return val;
|
val
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ impl ViewportLength {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromMeta for Zoom {
|
impl FromMeta for Zoom {
|
||||||
fn from_meta<'a>(value: &'a str) -> Option<Zoom> {
|
fn from_meta(value: &str) -> Option<Zoom> {
|
||||||
Some(match value {
|
Some(match value {
|
||||||
v if v.eq_ignore_ascii_case("yes") => Zoom::Number(1.),
|
v if v.eq_ignore_ascii_case("yes") => Zoom::Number(1.),
|
||||||
v if v.eq_ignore_ascii_case("no") => Zoom::Number(0.1),
|
v if v.eq_ignore_ascii_case("no") => Zoom::Number(0.1),
|
||||||
|
@ -113,7 +113,7 @@ impl FromMeta for Zoom {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromMeta for UserZoom {
|
impl FromMeta for UserZoom {
|
||||||
fn from_meta<'a>(value: &'a str) -> Option<UserZoom> {
|
fn from_meta(value: &str) -> Option<UserZoom> {
|
||||||
Some(match value {
|
Some(match value {
|
||||||
v if v.eq_ignore_ascii_case("yes") => UserZoom::Zoom,
|
v if v.eq_ignore_ascii_case("yes") => UserZoom::Zoom,
|
||||||
v if v.eq_ignore_ascii_case("no") => UserZoom::Fixed,
|
v if v.eq_ignore_ascii_case("no") => UserZoom::Fixed,
|
||||||
|
@ -377,13 +377,13 @@ impl ViewportRule {
|
||||||
start: usize)
|
start: usize)
|
||||||
-> Option<(&'a str, &'a str)>
|
-> Option<(&'a str, &'a str)>
|
||||||
{
|
{
|
||||||
fn end_of_token<'a>(iter: &mut Enumerate<Chars<'a>>) -> Option<(usize, char)> {
|
fn end_of_token(iter: &mut Enumerate<Chars>) -> Option<(usize, char)> {
|
||||||
iter.by_ref()
|
iter.by_ref()
|
||||||
.skip_while(|&(_, c)| !is_whitespace_separator_or_equals(&c))
|
.skip_while(|&(_, c)| !is_whitespace_separator_or_equals(&c))
|
||||||
.next()
|
.next()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn skip_whitespace<'a>(iter: &mut Enumerate<Chars<'a>>) -> Option<(usize, char)> {
|
fn skip_whitespace(iter: &mut Enumerate<Chars>) -> Option<(usize, char)> {
|
||||||
iter.by_ref()
|
iter.by_ref()
|
||||||
.skip_while(|&(_, c)| WHITESPACE.contains(&c))
|
.skip_while(|&(_, c)| WHITESPACE.contains(&c))
|
||||||
.next()
|
.next()
|
||||||
|
|
|
@ -76,7 +76,7 @@ impl<K: Clone + PartialEq, V: Clone> LRUCache<K, V> {
|
||||||
self.entries[last_index].1.clone()
|
self.entries[last_index].1.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter<'a>(&'a self) -> Iter<'a, (K, V)> {
|
pub fn iter(&self) -> Iter<(K, V)> {
|
||||||
self.entries.iter()
|
self.entries.iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,8 @@ macro_rules! define_cursor {
|
||||||
|
|
||||||
impl ToCss for Cursor {
|
impl ToCss for Cursor {
|
||||||
fn to_css<W>(&self, dest: &mut W) -> ::std::fmt::Result where W: ::std::fmt::Write {
|
fn to_css<W>(&self, dest: &mut W) -> ::std::fmt::Result where W: ::std::fmt::Write {
|
||||||
match self {
|
match *self {
|
||||||
$( &Cursor::$variant => dest.write_str($css) ),+
|
$( Cursor::$variant => dest.write_str($css) ),+
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,7 +197,7 @@ impl<T: Send + 'static> Worker<T> {
|
||||||
/// Gets access to the buffer pool that this worker is attached to. This can
|
/// Gets access to the buffer pool that this worker is attached to. This can
|
||||||
/// be used to create more deques which share the same buffer pool as this
|
/// be used to create more deques which share the same buffer pool as this
|
||||||
/// deque.
|
/// deque.
|
||||||
pub fn pool<'a>(&'a self) -> &'a BufferPool<T> {
|
pub fn pool(&self) -> &BufferPool<T> {
|
||||||
&self.deque.pool
|
&self.deque.pool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ impl<T: Send + 'static> Stealer<T> {
|
||||||
/// Gets access to the buffer pool that this stealer is attached to. This
|
/// Gets access to the buffer pool that this stealer is attached to. This
|
||||||
/// can be used to create more deques which share the same buffer pool as
|
/// can be used to create more deques which share the same buffer pool as
|
||||||
/// this deque.
|
/// this deque.
|
||||||
pub fn pool<'a>(&'a self) -> &'a BufferPool<T> {
|
pub fn pool(&self) -> &BufferPool<T> {
|
||||||
&self.deque.pool
|
&self.deque.pool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -270,11 +270,11 @@ impl<T: Send + 'static> Deque<T> {
|
||||||
}
|
}
|
||||||
if self.top.compare_and_swap(t, t + 1, SeqCst) == t {
|
if self.top.compare_and_swap(t, t + 1, SeqCst) == t {
|
||||||
self.bottom.store(t + 1, SeqCst);
|
self.bottom.store(t + 1, SeqCst);
|
||||||
return Some(data);
|
Some(data)
|
||||||
} else {
|
} else {
|
||||||
self.bottom.store(t + 1, SeqCst);
|
self.bottom.store(t + 1, SeqCst);
|
||||||
forget(data); // someone else stole this value
|
forget(data); // someone else stole this value
|
||||||
return None;
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@ impl<T: Send + 'static> Deque<T> {
|
||||||
self.bottom.store(b, SeqCst);
|
self.bottom.store(b, SeqCst);
|
||||||
}
|
}
|
||||||
self.pool.free(transmute(old));
|
self.pool.free(transmute(old));
|
||||||
return newbuf;
|
newbuf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,7 +393,7 @@ impl<T> Buffer<T> {
|
||||||
for i in t..b {
|
for i in t..b {
|
||||||
buf.put(i, self.get(i));
|
buf.put(i, self.get(i));
|
||||||
}
|
}
|
||||||
return buf;
|
buf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,9 +123,9 @@ impl HeapSizeOf for url::Url {
|
||||||
|
|
||||||
impl HeapSizeOf for url::SchemeData {
|
impl HeapSizeOf for url::SchemeData {
|
||||||
fn heap_size_of_children(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
match self {
|
match *self {
|
||||||
&url::SchemeData::Relative(ref data) => data.heap_size_of_children(),
|
url::SchemeData::Relative(ref data) => data.heap_size_of_children(),
|
||||||
&url::SchemeData::NonRelative(ref str) => str.heap_size_of_children()
|
url::SchemeData::NonRelative(ref str) => str.heap_size_of_children()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,9 +147,9 @@ impl HeapSizeOf for url::RelativeSchemeData {
|
||||||
|
|
||||||
impl HeapSizeOf for url::Host {
|
impl HeapSizeOf for url::Host {
|
||||||
fn heap_size_of_children(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
match self {
|
match *self {
|
||||||
&url::Host::Domain(ref str) => str.heap_size_of_children(),
|
url::Host::Domain(ref str) => str.heap_size_of_children(),
|
||||||
&url::Host::Ipv6(_) => 0
|
url::Host::Ipv6(_) => 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,8 +302,8 @@ impl<T: Copy + GCMethods<T>> HeapSizeOf for Heap<T> {
|
||||||
|
|
||||||
impl HeapSizeOf for Method {
|
impl HeapSizeOf for Method {
|
||||||
fn heap_size_of_children(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
match self {
|
match *self {
|
||||||
&Method::Extension(ref str) => str.heap_size_of_children(),
|
Method::Extension(ref str) => str.heap_size_of_children(),
|
||||||
_ => 0
|
_ => 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -311,9 +311,9 @@ impl HeapSizeOf for Method {
|
||||||
|
|
||||||
impl<T: HeapSizeOf, U: HeapSizeOf> HeapSizeOf for Result<T, U> {
|
impl<T: HeapSizeOf, U: HeapSizeOf> HeapSizeOf for Result<T, U> {
|
||||||
fn heap_size_of_children(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
match self {
|
match *self {
|
||||||
&Result::Ok(ref ok) => ok.heap_size_of_children(),
|
Result::Ok(ref ok) => ok.heap_size_of_children(),
|
||||||
&Result::Err(ref err) => err.heap_size_of_children()
|
Result::Err(ref err) => err.heap_size_of_children()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -341,13 +341,13 @@ impl HeapSizeOf for CompoundSelector {
|
||||||
|
|
||||||
impl HeapSizeOf for SimpleSelector {
|
impl HeapSizeOf for SimpleSelector {
|
||||||
fn heap_size_of_children(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
match self {
|
match *self {
|
||||||
&SimpleSelector::Negation(ref vec) => vec.heap_size_of_children(),
|
SimpleSelector::Negation(ref vec) => vec.heap_size_of_children(),
|
||||||
&SimpleSelector::AttrIncludes(_, ref str) | &SimpleSelector::AttrPrefixMatch(_, ref str) |
|
SimpleSelector::AttrIncludes(_, ref str) | SimpleSelector::AttrPrefixMatch(_, ref str) |
|
||||||
&SimpleSelector::AttrSubstringMatch(_, ref str) | &SimpleSelector::AttrSuffixMatch(_, ref str)
|
SimpleSelector::AttrSubstringMatch(_, ref str) | SimpleSelector::AttrSuffixMatch(_, ref str)
|
||||||
=> str.heap_size_of_children(),
|
=> str.heap_size_of_children(),
|
||||||
&SimpleSelector::AttrEqual(_, ref str, _) => str.heap_size_of_children(),
|
SimpleSelector::AttrEqual(_, ref str, _) => str.heap_size_of_children(),
|
||||||
&SimpleSelector::AttrDashMatch(_, ref first, ref second) => first.heap_size_of_children()
|
SimpleSelector::AttrDashMatch(_, ref first, ref second) => first.heap_size_of_children()
|
||||||
+ second.heap_size_of_children(),
|
+ second.heap_size_of_children(),
|
||||||
// All other types come down to Atom, enum or i32, all 0
|
// All other types come down to Atom, enum or i32, all 0
|
||||||
_ => 0
|
_ => 0
|
||||||
|
@ -372,8 +372,8 @@ impl HeapSizeOf for Mime {
|
||||||
|
|
||||||
impl HeapSizeOf for TopLevel {
|
impl HeapSizeOf for TopLevel {
|
||||||
fn heap_size_of_children(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
match self {
|
match *self {
|
||||||
&TopLevel::Ext(ref str) => str.heap_size_of_children(),
|
TopLevel::Ext(ref str) => str.heap_size_of_children(),
|
||||||
_ => 0
|
_ => 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -381,8 +381,8 @@ impl HeapSizeOf for TopLevel {
|
||||||
|
|
||||||
impl HeapSizeOf for SubLevel {
|
impl HeapSizeOf for SubLevel {
|
||||||
fn heap_size_of_children(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
match self {
|
match *self {
|
||||||
&SubLevel::Ext(ref str) => str.heap_size_of_children(),
|
SubLevel::Ext(ref str) => str.heap_size_of_children(),
|
||||||
_ => 0
|
_ => 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -390,8 +390,8 @@ impl HeapSizeOf for SubLevel {
|
||||||
|
|
||||||
impl HeapSizeOf for Attr {
|
impl HeapSizeOf for Attr {
|
||||||
fn heap_size_of_children(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
match self {
|
match *self {
|
||||||
&Attr::Ext(ref str) => str.heap_size_of_children(),
|
Attr::Ext(ref str) => str.heap_size_of_children(),
|
||||||
_ => 0
|
_ => 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -399,8 +399,8 @@ impl HeapSizeOf for Attr {
|
||||||
|
|
||||||
impl HeapSizeOf for Value {
|
impl HeapSizeOf for Value {
|
||||||
fn heap_size_of_children(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
match self {
|
match *self {
|
||||||
&Value::Ext(ref str) => str.heap_size_of_children(),
|
Value::Ext(ref str) => str.heap_size_of_children(),
|
||||||
_ => 0
|
_ => 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,7 +257,7 @@ pub struct DebugOptions {
|
||||||
|
|
||||||
|
|
||||||
impl DebugOptions {
|
impl DebugOptions {
|
||||||
pub fn new<'a>(debug_string: &'a str) -> Result<DebugOptions, &'a str> {
|
pub fn new(debug_string: &str) -> Result<DebugOptions, &str> {
|
||||||
let mut debug_options = DebugOptions::default();
|
let mut debug_options = DebugOptions::default();
|
||||||
|
|
||||||
for option in debug_string.split(',') {
|
for option in debug_string.split(',') {
|
||||||
|
|
|
@ -49,7 +49,7 @@ impl<T> PersistentList<T> where T: Send + Sync {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn iter<'a>(&'a self) -> PersistentListIterator<'a, T> {
|
pub fn iter(&self) -> PersistentListIterator<T> {
|
||||||
// This could clone (and would not need the lifetime if it did), but then it would incur
|
// This could clone (and would not need the lifetime if it did), but then it would incur
|
||||||
// atomic operations on every call to `.next()`. Bad.
|
// atomic operations on every call to `.next()`. Bad.
|
||||||
PersistentListIterator {
|
PersistentListIterator {
|
||||||
|
@ -90,4 +90,3 @@ impl<'a, T> Iterator for PersistentListIterator<'a, T> where T: Send + Sync + 's
|
||||||
Some(value)
|
Some(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,8 @@ impl PrefValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_boolean(&self) -> Option<bool> {
|
pub fn as_boolean(&self) -> Option<bool> {
|
||||||
match self {
|
match *self {
|
||||||
&PrefValue::Boolean(value) => {
|
PrefValue::Boolean(value) => {
|
||||||
Some(value)
|
Some(value)
|
||||||
},
|
},
|
||||||
_ => None
|
_ => None
|
||||||
|
@ -87,12 +87,12 @@ impl Pref {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn value(&self) -> &Arc<PrefValue> {
|
pub fn value(&self) -> &Arc<PrefValue> {
|
||||||
match self {
|
match *self {
|
||||||
&Pref::NoDefault(ref x) => x,
|
Pref::NoDefault(ref x) => x,
|
||||||
&Pref::WithDefault(ref default, ref override_value) => {
|
Pref::WithDefault(ref default, ref override_value) => {
|
||||||
match override_value {
|
match *override_value {
|
||||||
&Some(ref x) => x,
|
Some(ref x) => x,
|
||||||
&None => default
|
None => default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,11 +101,11 @@ impl Pref {
|
||||||
fn set(&mut self, value: PrefValue) {
|
fn set(&mut self, value: PrefValue) {
|
||||||
// TODO - this should error if we try to override a pref of one type
|
// TODO - this should error if we try to override a pref of one type
|
||||||
// with a value of a different type
|
// with a value of a different type
|
||||||
match self {
|
match *self {
|
||||||
&mut Pref::NoDefault(ref mut pref_value) => {
|
Pref::NoDefault(ref mut pref_value) => {
|
||||||
*pref_value = Arc::new(value)
|
*pref_value = Arc::new(value)
|
||||||
},
|
},
|
||||||
&mut Pref::WithDefault(_, ref mut override_value) => {
|
Pref::WithDefault(_, ref mut override_value) => {
|
||||||
*override_value = Some(Arc::new(value))
|
*override_value = Some(Arc::new(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ fn do_parse_integer<T: Iterator<Item=char>>(input: T) -> Option<i64> {
|
||||||
|
|
||||||
let value = read_numbers(input);
|
let value = read_numbers(input);
|
||||||
|
|
||||||
return value.and_then(|value| value.checked_mul(sign));
|
value.and_then(|value| value.checked_mul(sign))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parse an integer according to
|
/// Parse an integer according to
|
||||||
|
@ -244,9 +244,8 @@ pub fn parse_legacy_color(mut input: &str) -> Result<RGBA, ()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 5.
|
// Step 5.
|
||||||
match cssparser::parse_color_keyword(input) {
|
if let Ok(Color::RGBA(rgba)) = cssparser::parse_color_keyword(input) {
|
||||||
Ok(Color::RGBA(rgba)) => return Ok(rgba),
|
return Ok(rgba);
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 6.
|
// Step 6.
|
||||||
|
|
|
@ -52,7 +52,7 @@ impl<T> FullBinarySearchMethods<T> for [T] {
|
||||||
Ordering::Equal => return Some(mid),
|
Ordering::Equal => return Some(mid),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return None;
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -259,13 +259,13 @@ impl<QueueData: Sync, WorkData: Send> WorkQueue<QueueData, WorkData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect workers to one another.
|
// Connect workers to one another.
|
||||||
for i in 0..thread_count {
|
for (i, mut thread) in threads.iter_mut().enumerate() {
|
||||||
for j in 0..thread_count {
|
for (j, info) in infos.iter().enumerate() {
|
||||||
if i != j {
|
if i != j {
|
||||||
threads[i].other_deques.push(infos[j].thief.clone())
|
thread.other_deques.push(info.thief.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert!(threads[i].other_deques.len() == thread_count - 1)
|
assert!(thread.other_deques.len() == thread_count - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spawn threads.
|
// Spawn threads.
|
||||||
|
|
|
@ -88,16 +88,16 @@ impl WebDriverExtensionRoute for ServoExtensionRoute {
|
||||||
fn command(&self,
|
fn command(&self,
|
||||||
_captures: &Captures,
|
_captures: &Captures,
|
||||||
body_data: &Json) -> WebDriverResult<WebDriverCommand<ServoExtensionCommand>> {
|
body_data: &Json) -> WebDriverResult<WebDriverCommand<ServoExtensionCommand>> {
|
||||||
let command = match self {
|
let command = match *self {
|
||||||
&ServoExtensionRoute::GetPrefs => {
|
ServoExtensionRoute::GetPrefs => {
|
||||||
let parameters: GetPrefsParameters = try!(Parameters::from_json(&body_data));
|
let parameters: GetPrefsParameters = try!(Parameters::from_json(&body_data));
|
||||||
ServoExtensionCommand::GetPrefs(parameters)
|
ServoExtensionCommand::GetPrefs(parameters)
|
||||||
}
|
}
|
||||||
&ServoExtensionRoute::SetPrefs => {
|
ServoExtensionRoute::SetPrefs => {
|
||||||
let parameters: SetPrefsParameters = try!(Parameters::from_json(&body_data));
|
let parameters: SetPrefsParameters = try!(Parameters::from_json(&body_data));
|
||||||
ServoExtensionCommand::SetPrefs(parameters)
|
ServoExtensionCommand::SetPrefs(parameters)
|
||||||
}
|
}
|
||||||
&ServoExtensionRoute::ResetPrefs => {
|
ServoExtensionRoute::ResetPrefs => {
|
||||||
let parameters: GetPrefsParameters = try!(Parameters::from_json(&body_data));
|
let parameters: GetPrefsParameters = try!(Parameters::from_json(&body_data));
|
||||||
ServoExtensionCommand::ResetPrefs(parameters)
|
ServoExtensionCommand::ResetPrefs(parameters)
|
||||||
}
|
}
|
||||||
|
@ -115,10 +115,10 @@ enum ServoExtensionCommand {
|
||||||
|
|
||||||
impl WebDriverExtensionCommand for ServoExtensionCommand {
|
impl WebDriverExtensionCommand for ServoExtensionCommand {
|
||||||
fn parameters_json(&self) -> Option<Json> {
|
fn parameters_json(&self) -> Option<Json> {
|
||||||
match self {
|
match *self {
|
||||||
&ServoExtensionCommand::GetPrefs(ref x) => Some(x.to_json()),
|
ServoExtensionCommand::GetPrefs(ref x) => Some(x.to_json()),
|
||||||
&ServoExtensionCommand::SetPrefs(ref x) => Some(x.to_json()),
|
ServoExtensionCommand::SetPrefs(ref x) => Some(x.to_json()),
|
||||||
&ServoExtensionCommand::ResetPrefs(ref x) => Some(x.to_json()),
|
ServoExtensionCommand::ResetPrefs(ref x) => Some(x.to_json()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -542,7 +542,7 @@ impl Handler {
|
||||||
"implicit" => self.implicit_wait_timeout = value,
|
"implicit" => self.implicit_wait_timeout = value,
|
||||||
"page load" => self.load_timeout = value,
|
"page load" => self.load_timeout = value,
|
||||||
"script" => self.script_timeout = value,
|
"script" => self.script_timeout = value,
|
||||||
x @ _ => return Err(WebDriverError::new(ErrorStatus::InvalidSelector,
|
x => return Err(WebDriverError::new(ErrorStatus::InvalidSelector,
|
||||||
&format!("Unknown timeout type {}", x)))
|
&format!("Unknown timeout type {}", x)))
|
||||||
}
|
}
|
||||||
Ok(WebDriverResponse::Void)
|
Ok(WebDriverResponse::Void)
|
||||||
|
@ -708,10 +708,10 @@ impl WebDriverHandler<ServoExtensionRoute> for Handler {
|
||||||
WebDriverCommand::SetTimeouts(ref x) => self.handle_set_timeouts(x),
|
WebDriverCommand::SetTimeouts(ref x) => self.handle_set_timeouts(x),
|
||||||
WebDriverCommand::TakeScreenshot => self.handle_take_screenshot(),
|
WebDriverCommand::TakeScreenshot => self.handle_take_screenshot(),
|
||||||
WebDriverCommand::Extension(ref extension) => {
|
WebDriverCommand::Extension(ref extension) => {
|
||||||
match extension {
|
match *extension {
|
||||||
&ServoExtensionCommand::GetPrefs(ref x) => self.handle_get_prefs(x),
|
ServoExtensionCommand::GetPrefs(ref x) => self.handle_get_prefs(x),
|
||||||
&ServoExtensionCommand::SetPrefs(ref x) => self.handle_set_prefs(x),
|
ServoExtensionCommand::SetPrefs(ref x) => self.handle_set_prefs(x),
|
||||||
&ServoExtensionCommand::ResetPrefs(ref x) => self.handle_reset_prefs(x),
|
ServoExtensionCommand::ResetPrefs(ref x) => self.handle_reset_prefs(x),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => Err(WebDriverError::new(ErrorStatus::UnsupportedOperation,
|
_ => Err(WebDriverError::new(ErrorStatus::UnsupportedOperation,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue