mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Bug 1365370 - stylo: Use correct counts when copying from image layers.
This commit is contained in:
parent
61d64daf4c
commit
a8b0a550cd
1 changed files with 10 additions and 13 deletions
|
@ -2750,19 +2750,18 @@ fn static_assert() {
|
||||||
pub fn copy_${shorthand}_${name}_from(&mut self, other: &Self) {
|
pub fn copy_${shorthand}_${name}_from(&mut self, other: &Self) {
|
||||||
use gecko_bindings::structs::nsStyleImageLayers_LayerType as LayerType;
|
use gecko_bindings::structs::nsStyleImageLayers_LayerType as LayerType;
|
||||||
|
|
||||||
|
let count = other.gecko.${image_layers_field}.${field_name}Count;
|
||||||
unsafe {
|
unsafe {
|
||||||
Gecko_EnsureImageLayersLength(&mut self.gecko.${image_layers_field},
|
Gecko_EnsureImageLayersLength(&mut self.gecko.${image_layers_field},
|
||||||
other.gecko.${image_layers_field}.mLayers.len(),
|
count as usize,
|
||||||
LayerType::${shorthand.title()});
|
LayerType::${shorthand.title()});
|
||||||
}
|
}
|
||||||
for (layer, other) in self.gecko.${image_layers_field}.mLayers.iter_mut()
|
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(other.gecko.${image_layers_field}
|
.take(count as usize) {
|
||||||
.${field_name}Count as usize) {
|
|
||||||
layer.${field_name} = other.${field_name};
|
layer.${field_name} = other.${field_name};
|
||||||
}
|
}
|
||||||
self.gecko.${image_layers_field}.${field_name}Count =
|
self.gecko.${image_layers_field}.${field_name}Count = count;
|
||||||
other.gecko.${image_layers_field}.${field_name}Count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2855,23 +2854,21 @@ fn static_assert() {
|
||||||
pub fn copy_${shorthand}_position_${orientation}_from(&mut self, other: &Self) {
|
pub fn copy_${shorthand}_position_${orientation}_from(&mut self, other: &Self) {
|
||||||
use gecko_bindings::structs::nsStyleImageLayers_LayerType as LayerType;
|
use gecko_bindings::structs::nsStyleImageLayers_LayerType as LayerType;
|
||||||
|
|
||||||
self.gecko.${image_layers_field}.mPosition${orientation.upper()}Count
|
let count = other.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;
|
|
||||||
unsafe {
|
unsafe {
|
||||||
Gecko_EnsureImageLayersLength(&mut self.gecko.${image_layers_field},
|
Gecko_EnsureImageLayersLength(&mut self.gecko.${image_layers_field},
|
||||||
other.gecko.${image_layers_field}.mLayers.len(),
|
count as usize,
|
||||||
LayerType::${shorthand.capitalize()});
|
LayerType::${shorthand.capitalize()});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (layer, other) in self.gecko.${image_layers_field}.mLayers.iter_mut()
|
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
|
layer.mPosition.m${orientation.upper()}Position
|
||||||
= other.mPosition.m${orientation.upper()}Position;
|
= other.mPosition.m${orientation.upper()}Position;
|
||||||
}
|
}
|
||||||
self.gecko.${image_layers_field}.mPosition${orientation.upper()}Count
|
self.gecko.${image_layers_field}.mPosition${orientation.upper()}Count = count;
|
||||||
= other.gecko.${image_layers_field}.mPosition${orientation.upper()}Count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clone_${shorthand}_position_${orientation}(&self)
|
pub fn clone_${shorthand}_position_${orientation}(&self)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue