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

Support line-height in geckolib #11445

Merged
merged 3 commits into from Jun 1, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Factor out nsStyleCoord::copy_from

  • Loading branch information
mbrubeck committed May 31, 2016
commit ae2dec4e604b63b88b8709360572d3992af5cc68
@@ -149,6 +149,12 @@ pub struct ${style_struct.gecko_struct_name} {
}
</%def>

<%def name="impl_coord_copy(ident, gecko_ffi_name)">
fn copy_${ident}_from(&mut self, other: &Self) {
self.gecko.${gecko_ffi_name}.copy_from(&other.gecko.${gecko_ffi_name});
}
</%def>

<%!
def is_border_style_masked(ffi_name):
return ffi_name.split("[")[0] in ["mBorderStyle", "mOutlineStyle", "mTextDecorationStyle"]
@@ -673,11 +679,8 @@ fn static_assert() {
T::LengthOrPercentage(v) => self.gecko.mVerticalAlign.set(v),
}
}
fn copy_vertical_align_from(&mut self, other: &Self) {
debug_assert_unit_is_safe_to_copy(self.gecko.mVerticalAlign.mUnit);
self.gecko.mVerticalAlign.mUnit = other.gecko.mVerticalAlign.mUnit;
self.gecko.mVerticalAlign.mValue = other.gecko.mVerticalAlign.mValue;
}

<%call expr="impl_coord_copy('vertical_align', 'mVerticalAlign')"></%call>

fn set__moz_binding(&mut self, v: longhands::_moz_binding::computed_value::T) {
use style::properties::longhands::_moz_binding::SpecifiedValue as BindingValue;
@@ -736,11 +739,8 @@ fn static_assert() {
self.gecko.mLineHeight.set_enum(structs::NS_STYLE_LINE_HEIGHT_BLOCK_HEIGHT as i32),
}
}
fn copy_line_height_from(&mut self, other: &Self) {
debug_assert_unit_is_safe_to_copy(self.gecko.mLineHeight.mUnit);
self.gecko.mLineHeight.mUnit = other.gecko.mLineHeight.mUnit;
self.gecko.mLineHeight.mValue = other.gecko.mLineHeight.mValue;
}

<%call expr="impl_coord_copy('line_height', 'mLineHeight')"></%call>

</%self:impl_trait>

@@ -9,6 +9,7 @@ use std::cmp::max;
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};

pub trait StyleCoordHelpers {
fn copy_from(&mut self, other: &Self);
fn set<T: ToGeckoStyleCoord>(&mut self, val: T);
fn set_auto(&mut self);
fn set_normal(&mut self);
@@ -20,6 +21,13 @@ pub trait StyleCoordHelpers {
}

impl StyleCoordHelpers for nsStyleCoord {
fn copy_from(&mut self, other: &Self) {
debug_assert_unit_is_safe_to_copy(self.mUnit);
debug_assert_unit_is_safe_to_copy(other.mUnit);
self.mUnit = other.mUnit;
self.mValue = other.mValue;
}

fn set<T: ToGeckoStyleCoord>(&mut self, val: T) {
val.to_gecko_style_coord(&mut self.mUnit, &mut self.mValue);
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.