servo: Merge #12918 - 12902 typedefs (from hsinewu:12902-typedefs); r=Manishearth

<!-- Please describe your changes on the following line: -->
Using type alias instead of newtype.
Removing duplicated implementation, it's already inherited.
No more type constructors and foo.0
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #12902 (github issue number if applicable).

<!-- Either: -->
- [X] These changes do not require tests because it's refactoring.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: daee53cb7697459b9ad28a9ee377cd6d0b90c0a7
This commit is contained in:
hsinewu 2016-08-22 06:01:03 -05:00
Родитель 523e8340d7
Коммит 4bdef435cc
5 изменённых файлов: 17 добавлений и 55 удалений

Просмотреть файл

@ -520,9 +520,9 @@ impl FragmentDisplayListBuilding for Fragment {
};
// Use `background-position` to get the offset.
let horizontal_position = model::specified(background.background_position.0.horizontal,
let horizontal_position = model::specified(background.background_position.horizontal,
bounds.size.width - image_size.width);
let vertical_position = model::specified(background.background_position.0.vertical,
let vertical_position = model::specified(background.background_position.vertical,
bounds.size.height - image_size.height);
let abs_x = border.left + virtual_origin_x + horizontal_position + origin_x;

Просмотреть файл

@ -1041,16 +1041,16 @@ fn static_assert() {
pub fn clone_background_position(&self) -> longhands::background_position::computed_value::T {
use values::computed::position::Position;
let position = &self.gecko.mImage.mLayers.mFirstElement.mPosition;
longhands::background_position::computed_value::T(Position {
Position {
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.0.horizontal.into();
position.mYPosition = v.0.vertical.into();
position.mXPosition = v.horizontal.into();
position.mYPosition = v.vertical.into();
self.gecko.mImage.mPositionXCount = 1;
self.gecko.mImage.mPositionYCount = 1;
}

Просмотреть файл

@ -496,13 +496,6 @@ impl Interpolate for Position {
}
}
impl Interpolate for BackgroundPosition {
#[inline]
fn interpolate(&self, other: &Self, time: f64) -> Result<Self, ()> {
Ok(BackgroundPosition(try!(self.0.interpolate(&other.0, time))))
}
}
impl Interpolate for BackgroundSize {
fn interpolate(&self, other: &Self, time: f64) -> Result<Self, ()> {
use properties::longhands::background_size::computed_value::ExplicitSize;

Просмотреть файл

@ -85,54 +85,23 @@ ${helpers.predefined_type("background-color", "CSSColor",
pub mod computed_value {
use values::computed::position::Position;
#[derive(PartialEq, Copy, Clone, Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct T(pub Position);
pub type T = Position;
}
impl HasViewportPercentage for SpecifiedValue {
fn has_viewport_percentage(&self) -> bool {
self.0.has_viewport_percentage()
}
}
#[derive(Debug, Clone, PartialEq, Copy)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct SpecifiedValue(pub Position);
impl ToCss for SpecifiedValue {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
self.0.to_css(dest)
}
}
impl ToCss for computed_value::T {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
self.0.to_css(dest)
}
}
impl ToComputedValue for SpecifiedValue {
type ComputedValue = computed_value::T;
#[inline]
fn to_computed_value(&self, context: &Context) -> computed_value::T {
computed_value::T(self.0.to_computed_value(context))
}
}
pub type SpecifiedValue = Position;
#[inline]
pub fn get_initial_value() -> computed_value::T {
use values::computed::position::Position;
computed_value::T(Position {
Position {
horizontal: computed::LengthOrPercentage::Percentage(0.0),
vertical: computed::LengthOrPercentage::Percentage(0.0),
})
}
}
pub fn parse(_context: &ParserContext, input: &mut Parser)
-> Result<SpecifiedValue, ()> {
Ok(SpecifiedValue(try!(Position::parse(input))))
Ok(try!(Position::parse(input)))
}
</%helpers:longhand>

Просмотреть файл

@ -704,12 +704,12 @@ mod shorthand_serialization {
authored: None
});
let position = DeclaredValue::Value(PositionContainer(
let position = DeclaredValue::Value(
Position {
horizontal: LengthOrPercentage::Length(Length::from_px(7f32)),
vertical: LengthOrPercentage::Length(Length::from_px(4f32))
}
));
);
let repeat = DeclaredValue::Value(Repeat::repeat_x);
let attachment = DeclaredValue::Value(Attachment::scroll);
@ -755,12 +755,12 @@ mod shorthand_serialization {
authored: None
});
let position = DeclaredValue::Value(PositionContainer(
let position = DeclaredValue::Value(
Position {
horizontal: LengthOrPercentage::Length(Length::from_px(7f32)),
vertical: LengthOrPercentage::Length(Length::from_px(4f32))
}
));
);
let repeat = DeclaredValue::Value(Repeat::repeat_x);
let attachment = DeclaredValue::Value(Attachment::scroll);
@ -805,12 +805,12 @@ mod shorthand_serialization {
authored: None
});
let position = DeclaredValue::Value(PositionContainer(
let position = DeclaredValue::Value(
Position {
horizontal: LengthOrPercentage::Length(Length::from_px(0f32)),
vertical: LengthOrPercentage::Length(Length::from_px(0f32))
}
));
);
let repeat = DeclaredValue::Value(Repeat::repeat_x);
let attachment = DeclaredValue::Value(Attachment::scroll);