Auto merge of #14049 - Wafflespeanut:lon, r=SimonSapin

Add a generic type for sharing some CSS types

<!-- Please describe your changes on the following line: -->

This would be useful for types such as `T(pub Option<U>)` or any type that's a mixture of two types (like `LengthOrFoo` for example). Well, it's a bit ugly, especially because we have to address the types as `Either::First` and `Either::Second` everywhere, but I don't have a brighter idea 😄

---
<!-- 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

<!-- Either: -->
- [x] These changes do not require tests because it's a refactor

r? @SimonSapin (cc @Manishearth @emilio)

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

<!-- 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/14049)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-11-09 08:15:16 -06:00 committed by GitHub
commit 35f328d717
11 changed files with 125 additions and 117 deletions

View file

@ -52,9 +52,8 @@ use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMod
use style::properties::{self, ServoComputedValues};
use style::properties::style_structs;
use style::servo::restyle_damage::REPAINT;
use style::values::RGBA;
use style::values::computed;
use style::values::computed::{Gradient, GradientKind, LengthOrNone, LengthOrPercentage, LengthOrPercentageOrAuto};
use style::values::{self, Either, RGBA, computed};
use style::values::computed::{Gradient, GradientKind, LengthOrPercentage, LengthOrPercentageOrAuto};
use style::values::specified::{AngleOrCorner, HorizontalDirection, VerticalDirection};
use style_traits::cursor::Cursor;
use table_cell::CollapsedBordersForCell;
@ -1563,7 +1562,7 @@ impl FragmentDisplayListBuilding for Fragment {
let transform = self.transform_matrix(&border_box);
let perspective = match self.style().get_effects().perspective {
LengthOrNone::Length(d) => {
Either::First(length) => {
let perspective_origin = self.style().get_effects().perspective_origin;
let perspective_origin =
Point2D::new(model::specified(perspective_origin.horizontal,
@ -1578,11 +1577,11 @@ impl FragmentDisplayListBuilding for Fragment {
-perspective_origin.y,
0.0);
let perspective_matrix = create_perspective_matrix(d);
let perspective_matrix = create_perspective_matrix(length);
pre_transform.pre_mul(&perspective_matrix).pre_mul(&post_transform)
}
LengthOrNone::None => {
Either::Second(values::None_) => {
Matrix4D::identity()
}
};

View file

@ -49,7 +49,8 @@ use style::properties::ServoComputedValues;
use style::selector_impl::RestyleDamage;
use style::servo::restyle_damage::RECONSTRUCT_FLOW;
use style::str::char_is_whitespace;
use style::values::computed::{LengthOrNone, LengthOrPercentage, LengthOrPercentageOrAuto};
use style::values::Either;
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
use style::values::computed::LengthOrPercentageOrNone;
use text;
use text::TextRunScanner;
@ -2586,7 +2587,7 @@ impl Fragment {
// TODO(mrobinson): Determine if this is necessary, since blocks with
// transformations already create stacking contexts.
if self.style().get_effects().perspective != LengthOrNone::None {
if let Either::First(ref _length) = self.style().get_effects().perspective {
return true
}