mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Add support for background-position in geckolib.
This commit is contained in:
parent
11ad48f8e3
commit
77e57aab5b
2 changed files with 58 additions and 2 deletions
|
@ -921,7 +921,8 @@ fn static_assert() {
|
|||
// add support for parsing these lists in servo and pushing to nsTArray's.
|
||||
<% skip_background_longhands = """background-color background-repeat
|
||||
background-image background-clip
|
||||
background-origin background-attachment""" %>
|
||||
background-origin background-attachment
|
||||
background-position""" %>
|
||||
<%self:impl_trait style_struct_name="Background"
|
||||
skip_longhands="${skip_background_longhands}"
|
||||
skip_additionals="*">
|
||||
|
@ -1009,6 +1010,29 @@ fn static_assert() {
|
|||
};
|
||||
}
|
||||
|
||||
pub fn copy_background_position_from(&mut self, other: &Self) {
|
||||
self.gecko.mImage.mPositionXCount = cmp::min(1, other.gecko.mImage.mPositionXCount);
|
||||
self.gecko.mImage.mPositionYCount = cmp::min(1, other.gecko.mImage.mPositionYCount);
|
||||
self.gecko.mImage.mLayers.mFirstElement.mPosition =
|
||||
other.gecko.mImage.mLayers.mFirstElement.mPosition;
|
||||
}
|
||||
|
||||
pub fn clone_background_position(&self) -> longhands::background_position::computed_value::T {
|
||||
let position = &self.gecko.mImage.mLayers.mFirstElement.mPosition;
|
||||
longhands::background_position::computed_value::T {
|
||||
horizontal: position.mXPosition.into(),
|
||||
vertical: position.mYPosition.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_background_position(&mut self, v: longhands::background_position::computed_value::T) {
|
||||
let position = &mut self.gecko.mImage.mLayers.mFirstElement.mPosition;
|
||||
position.mXPosition = v.horizontal.into();
|
||||
position.mYPosition = v.vertical.into();
|
||||
self.gecko.mImage.mPositionXCount = 1;
|
||||
self.gecko.mImage.mPositionYCount = 1;
|
||||
}
|
||||
|
||||
pub fn copy_background_image_from(&mut self, other: &Self) {
|
||||
unsafe {
|
||||
Gecko_CopyImageValueFrom(&mut self.gecko.mImage.mLayers.mFirstElement.mImage,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue