Skip to content

Commit

Permalink
Auto merge of #16956 - mbrubeck:cleanup, r=Manishearth
Browse files Browse the repository at this point in the history
stylo: Use correct counts when copying from image layers.

---

- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes do not require tests because they are code cleanup.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16956)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed May 21, 2017
2 parents cdf5277 + a8b0a55 commit 460c90a
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions components/style/properties/gecko.mako.rs
Expand Up @@ -2769,19 +2769,18 @@ fn static_assert() {
pub fn copy_${shorthand}_${name}_from(&mut self, other: &Self) {
use gecko_bindings::structs::nsStyleImageLayers_LayerType as LayerType;

let count = other.gecko.${image_layers_field}.${field_name}Count;
unsafe {
Gecko_EnsureImageLayersLength(&mut self.gecko.${image_layers_field},
other.gecko.${image_layers_field}.mLayers.len(),
count as usize,
LayerType::${shorthand.title()});
}
for (layer, other) in self.gecko.${image_layers_field}.mLayers.iter_mut()
.zip(other.gecko.${image_layers_field}.mLayers.iter())
.take(other.gecko.${image_layers_field}
.${field_name}Count as usize) {
.take(count as usize) {
layer.${field_name} = other.${field_name};
}
self.gecko.${image_layers_field}.${field_name}Count =
other.gecko.${image_layers_field}.${field_name}Count;
self.gecko.${image_layers_field}.${field_name}Count = count;
}


Expand Down Expand Up @@ -2874,23 +2873,21 @@ fn static_assert() {
pub fn copy_${shorthand}_position_${orientation}_from(&mut self, other: &Self) {
use gecko_bindings::structs::nsStyleImageLayers_LayerType as LayerType;

self.gecko.${image_layers_field}.mPosition${orientation.upper()}Count
= cmp::min(1, other.gecko.${image_layers_field}.mPosition${orientation.upper()}Count);
self.gecko.${image_layers_field}.mLayers.mFirstElement.mPosition =
other.gecko.${image_layers_field}.mLayers.mFirstElement.mPosition;
let count = other.gecko.${image_layers_field}.mPosition${orientation.upper()}Count;

unsafe {
Gecko_EnsureImageLayersLength(&mut self.gecko.${image_layers_field},
other.gecko.${image_layers_field}.mLayers.len(),
count as usize,
LayerType::${shorthand.capitalize()});
}

for (layer, other) in self.gecko.${image_layers_field}.mLayers.iter_mut()
.zip(other.gecko.${image_layers_field}.mLayers.iter()) {
.zip(other.gecko.${image_layers_field}.mLayers.iter())
.take(count as usize) {
layer.mPosition.m${orientation.upper()}Position
= other.mPosition.m${orientation.upper()}Position;
}
self.gecko.${image_layers_field}.mPosition${orientation.upper()}Count
= other.gecko.${image_layers_field}.mPosition${orientation.upper()}Count;
self.gecko.${image_layers_field}.mPosition${orientation.upper()}Count = count;
}

pub fn clone_${shorthand}_position_${orientation}(&self)
Expand Down

0 comments on commit 460c90a

Please sign in to comment.