Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy fixes #2614

Merged
merged 9 commits into from Apr 6, 2018
@@ -240,7 +240,7 @@ impl OpaqueBatchList {
// case we just see if it can be added to the existing batch or
// create a new one.
if item_area > self.pixel_area_threshold_for_new_batch {
if let Some(ref batch) = self.batches.last() {
if let Some(batch) = self.batches.last() {
if batch.key.is_compatible_with(&key) {
selected_batch_index = Some(self.batches.len() - 1);
}
@@ -655,7 +655,7 @@ impl AlphaBatchBuilder {
.into();
let polygon = make_polygon(
picture.real_local_rect,
&real_xf,
real_xf,
prim_index.0,
);

@@ -955,7 +955,7 @@ impl AlphaBatchBuilder {
ctx.resource_cache,
gpu_cache,
deferred_resolves,
&ctx.cached_gradients,
ctx.cached_gradients,
) {
self.add_brush_to_batch(
brush,
@@ -462,7 +462,7 @@ impl<'a> DisplayListFlattener<'a> {

self.add_solid_rectangle(
clip_and_scroll,
&info,
info,
border.top.color,
Some(descriptor),
);
@@ -478,7 +478,7 @@ impl<'a> DisplayListFlattener<'a> {

self.add_solid_rectangle(
clip_and_scroll,
&info,
info,
border.left.color,
Some(descriptor),
);
@@ -494,7 +494,7 @@ impl<'a> DisplayListFlattener<'a> {

self.add_solid_rectangle(
clip_and_scroll,
&info,
info,
border.right.color,
Some(descriptor),
);
@@ -512,7 +512,7 @@ impl<'a> DisplayListFlattener<'a> {

self.add_solid_rectangle(
clip_and_scroll,
&info,
info,
border.bottom.color,
Some(descriptor),
);
@@ -66,9 +66,9 @@ impl ClipRegion {
local_clip: &LocalClip,
reference_frame_relative_offset: &LayoutVector2D
) -> ClipRegion {
let complex_clips = match local_clip {
&LocalClip::Rect(_) => Vec::new(),
&LocalClip::RoundedRect(_, ref region) => vec![region.clone()],
let complex_clips = match *local_clip {
LocalClip::Rect(_) => Vec::new(),
LocalClip::RoundedRect(_, ref region) => vec![region.clone()],
};
ClipRegion::create_for_clip_node(
*local_clip.clip_rect(),
@@ -335,14 +335,16 @@ impl ClipSources {
}
}

let outer = match can_calculate_outer_rect {
true => Some(local_outer.unwrap_or_else(LayerRect::zero)),
false => None,
let outer = if can_calculate_outer_rect {
Some(local_outer.unwrap_or_else(LayerRect::zero))
} else {
None
};

let inner = match can_calculate_inner_rect {
true => local_inner.unwrap_or_else(LayerRect::zero),
false => LayerRect::zero(),
let inner = if can_calculate_inner_rect {
local_inner.unwrap_or_else(LayerRect::zero)
} else {
LayerRect::zero()
};

(inner, outer)
@@ -251,14 +251,13 @@ impl ClipScrollTree {
scroll_node_at_point_index
}
(_, scroll_node_at_point_index, Some(cached_node_index)) => {
let node_index = match self.nodes.get(cached_node_index.0) {
match self.nodes.get(cached_node_index.0) {
Some(_) => cached_node_index,
None => {
self.currently_scrolling_node_index = Some(scroll_node_at_point_index);
scroll_node_at_point_index
}
};
node_index
}
}
(_, _, None) => return false,
};
@@ -550,7 +549,7 @@ impl ClipScrollTree {
pt.new_level("Clip".to_owned());

pt.add_item(format!("index: {:?}", index));
let clips = clip_store.get(&handle).clips();
let clips = clip_store.get(handle).clips();
pt.new_level(format!("Clip Sources [{}]", clips.len()));
for source in clips {
pt.add_item(format!("{:?}", source));
@@ -174,7 +174,7 @@ fn parse_shader_source(source: String, base_path: &Option<PathBuf>, output: &mut

for (line_num, line) in source.lines().enumerate() {
if line.starts_with(SHADER_IMPORT) {
let imports = line[SHADER_IMPORT.len() ..].split(",");
let imports = line[SHADER_IMPORT.len() ..].split(',');

// For each import, get the source, and recurse.
for import in imports {
@@ -349,11 +349,11 @@ impl VertexDescriptor {
}

fn bind(&self, gl: &gl::Gl, main: VBOId, instance: VBOId) {
Self::bind_attributes(&self.vertex_attributes, 0, 0, gl, main);
Self::bind_attributes(self.vertex_attributes, 0, 0, gl, main);

if !self.instance_attributes.is_empty() {
Self::bind_attributes(
&self.instance_attributes,
self.instance_attributes,
self.vertex_attributes.len(),
1, gl, instance,
);
@@ -410,7 +410,7 @@ impl<'a> DisplayListFlattener<'a> {
parent_id: &ClipId,
reference_frame_relative_offset: &LayerVector2D,
) {
let frame_rect = item.rect().translate(&reference_frame_relative_offset);
let frame_rect = item.rect().translate(reference_frame_relative_offset);
let sticky_frame_info = StickyFrameInfo::new(
info.margins,
info.vertical_offset_bounds,
@@ -426,7 +426,7 @@ impl<'a> DisplayListFlattener<'a> {
sticky_frame_info,
info.id.pipeline_id(),
);
self.id_to_index_mapper.map_to_parent_clip_chain(info.id, &parent_id);
self.id_to_index_mapper.map_to_parent_clip_chain(info.id, parent_id);
}

fn flatten_scroll_frame(
@@ -442,14 +442,14 @@ impl<'a> DisplayListFlattener<'a> {
*item.clip_rect(),
complex_clips,
info.image_mask,
&reference_frame_relative_offset,
reference_frame_relative_offset,
);
// Just use clip rectangle as the frame rect for this scroll frame.
// This is useful when calculating scroll extents for the
// ClipScrollNode::scroll(..) API as well as for properly setting sticky
// positioning offsets.
let frame_rect = item.clip_rect().translate(&reference_frame_relative_offset);
let content_rect = item.rect().translate(&reference_frame_relative_offset);
let frame_rect = item.clip_rect().translate(reference_frame_relative_offset);
let content_rect = item.rect().translate(reference_frame_relative_offset);

debug_assert!(info.clip_id != info.scroll_frame_id);

@@ -579,7 +579,7 @@ impl<'a> DisplayListFlattener<'a> {
clip_and_scroll_ids.scroll_node_id,
ClipRegion::create_for_clip_node_with_local_clip(
&LocalClip::from(*item.clip_rect()),
&reference_frame_relative_offset
reference_frame_relative_offset
),
);

@@ -870,16 +870,14 @@ impl<'a> DisplayListFlattener<'a> {
Some(self.clip_store.insert(ClipSources::new(clip_sources)))
};

let prim_index = self.prim_store.add_primitive(
self.prim_store.add_primitive(
&info.rect,
&info.clip_rect,
info.is_backface_visible && stacking_context.is_backface_visible,
clip_sources,
info.tag,
container,
);

prim_index
)
}

pub fn add_primitive_to_hit_testing_list(
@@ -2078,7 +2076,7 @@ impl<'a> DisplayListFlattener<'a> {
) {
let prim = {
let instance_map = self.font_instances.read().unwrap();
let font_instance = match instance_map.get(&font_instance_key) {
let font_instance = match instance_map.get(font_instance_key) {
Some(instance) => instance,
None => {
warn!("Unknown font instance key");
@@ -2122,7 +2120,7 @@ impl<'a> DisplayListFlattener<'a> {
// TODO(gw): It's possible we can relax this in
// the future, if we modify the way
// we handle subpixel blending.
if let Some(ref stacking_context) = self.sc_stack.last() {
if let Some(stacking_context) = self.sc_stack.last() {
if !stacking_context.allow_subpixel_aa {
render_mode = FontRenderMode::Alpha;
}
@@ -122,7 +122,7 @@ impl Ellipse {

let si = (1.0 - co * co).sqrt();
let r = LayerVector2D::new(ab.x * co, ab.y * si);
return (r - p).length() * (p.y - r.y).signum();
(r - p).length() * (p.y - r.y).signum()
}
}

@@ -294,7 +294,7 @@ impl FrameBuilder {

let mut node_data = Vec::with_capacity(clip_scroll_tree.nodes.len());
let total_prim_runs =
self.prim_store.pictures.iter().fold(1, |count, ref pic| count + pic.runs.len());
self.prim_store.pictures.iter().fold(1, |count, pic| count + pic.runs.len());
let mut clip_chain_local_clip_rects = Vec::with_capacity(total_prim_runs);
clip_chain_local_clip_rects.push(LayerRect::max_rect());

@@ -414,7 +414,7 @@ impl FrameBuilder {
pub fn create_hit_tester(&mut self, clip_scroll_tree: &ClipScrollTree) -> HitTester {
HitTester::new(
&self.hit_testing_runs,
&clip_scroll_tree,
clip_scroll_tree,
&self.clip_store
)
}
@@ -777,7 +777,7 @@ impl GlyphRasterizer {
GlyphRasterResult::Bitmap(glyph) => {
assert_eq!((glyph.left.fract(), glyph.top.fract()), (0.0, 0.0));
let mut texture_cache_handle = TextureCacheHandle::new();
texture_cache.request(&mut texture_cache_handle, gpu_cache);
texture_cache.request(&texture_cache_handle, gpu_cache);
texture_cache.update(
&mut texture_cache_handle,
ImageDescriptor {
@@ -845,12 +845,12 @@ trait AddFont {

impl AddFont for FontContext {
fn add_font(&mut self, font_key: &FontKey, template: &FontTemplate) {
match template {
&FontTemplate::Raw(ref bytes, index) => {
self.add_raw_font(&font_key, bytes.clone(), index);
match *template {
FontTemplate::Raw(ref bytes, index) => {
self.add_raw_font(font_key, bytes.clone(), index);
}
&FontTemplate::Native(ref native_font_handle) => {
self.add_native_font(&font_key, (*native_font_handle).clone());
FontTemplate::Native(ref native_font_handle) => {
self.add_native_font(font_key, (*native_font_handle).clone());
}
}
}
@@ -859,12 +859,12 @@ impl AddFont for FontContext {
#[cfg(feature = "pathfinder")]
impl AddFont for PathfinderFontContext {
fn add_font(&mut self, font_key: &FontKey, template: &FontTemplate) {
match template {
&FontTemplate::Raw(ref bytes, index) => {
drop(self.add_font_from_memory(&font_key, bytes.clone(), index));
match *template {
FontTemplate::Raw(ref bytes, index) => {
drop(self.add_font_from_memory(font_key, bytes.clone(), index));
}
&FontTemplate::Native(ref native_font_handle) => {
drop(self.add_native_font(&font_key, (*native_font_handle).clone().0));
FontTemplate::Native(ref native_font_handle) => {
drop(self.add_native_font(font_key, (*native_font_handle).clone().0));
}
}
}
@@ -81,11 +81,11 @@ enum HitTestRegion {

impl HitTestRegion {
pub fn contains(&self, point: &LayerPoint) -> bool {
match self {
&HitTestRegion::Rectangle(ref rectangle) => rectangle.contains(point),
&HitTestRegion::RoundedRectangle(rect, radii, ClipMode::Clip) =>
match *self {
HitTestRegion::Rectangle(ref rectangle) => rectangle.contains(point),
HitTestRegion::RoundedRectangle(rect, radii, ClipMode::Clip) =>
rounded_rectangle_contains_point(point, &rect, &radii),
&HitTestRegion::RoundedRectangle(rect, radii, ClipMode::ClipOut) =>
HitTestRegion::RoundedRectangle(rect, radii, ClipMode::ClipOut) =>
!rounded_rectangle_contains_point(point, &rect, &radii),
}
}
@@ -305,7 +305,7 @@ fn get_regions_for_clip_scroll_node(
_ => return Vec::new(),
};

clips.iter().map(|ref source| {
clips.iter().map(|source| {
match source.0 {
ClipSource::Rectangle(ref rect) => HitTestRegion::Rectangle(*rect),
ClipSource::RoundedRectangle(ref rect, ref radii, ref mode) =>
@@ -365,7 +365,7 @@ impl HitTest {

let point = &LayerPoint::new(self.point.x, self.point.y);
self.pipeline_id.map(|id|
hit_tester.get_pipeline_root(id).world_viewport_transform.transform_point2d(&point)
hit_tester.get_pipeline_root(id).world_viewport_transform.transform_point2d(point)
).unwrap_or_else(|| WorldPoint::new(self.point.x, self.point.y))
}
}
@@ -89,7 +89,7 @@ fn decompose_row(item_rect: &LayerRect, info: &TiledImageInfo, callback: &mut Fn
item_rect.origin.y,
info.stretch_size.width,
item_rect.size.height,
).intersection(&item_rect);
).intersection(item_rect);

if let Some(decomposed_rect) = decomposed_rect {
decompose_cache_tiles(&decomposed_rect, info, callback);
@@ -270,7 +270,7 @@ fn add_device_tile(
}

// Fix up the primitive's rect if it overflows the original item rect.
if let Some(rect) = prim_rect.intersection(&item_rect) {
if let Some(rect) = prim_rect.intersection(item_rect) {
callback(&DecomposedTile {
tile_offset,
rect,
@@ -94,8 +94,8 @@ impl PicturePrimitive {
pub fn resolve_scene_properties(&mut self, properties: &SceneProperties) -> bool {
match self.composite_mode {
Some(PictureCompositeMode::Filter(ref mut filter)) => {
match filter {
&mut FilterOp::Opacity(ref binding, ref mut value) => {
match *filter {
FilterOp::Opacity(ref binding, ref mut value) => {
*value = properties.resolve_float(binding, *value);
}
_ => {}
@@ -147,16 +147,14 @@ fn get_glyph_metrics(
let width = right - left;
let height = top - bottom;

let metrics = GlyphMetrics {
GlyphMetrics {
rasterized_left: left,
rasterized_width: width as u32,
rasterized_height: height as u32,
rasterized_ascent: top,
rasterized_descent: -bottom,
advance: advance.width as f32,
};

metrics
}
}

#[link(name = "ApplicationServices", kind = "framework")]
@@ -453,7 +451,7 @@ impl FontContext {
let a = pixel[3];
print!("({}, {}, {}, {}) ", r, g, b, a);
}
println!("");
println!();
}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.