Auto merge of #13908 - aethanyc:add-border-width-keyword, r=emilio

Use enum BorderWidth as SpecifiedValue

Use enum BorderWidth instead of a tuple-like struct to store the specified
value. BorderWidth is needed to be used in both longhand and shorthand
border width properties, so I put it in `specified` module.

Fixed #13869.

---
<!-- 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 #13869 (github issue number if applicable).

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- 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/13908)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-10-29 19:48:27 -05:00 committed by GitHub
commit 357e746a9a
6 changed files with 122 additions and 79 deletions

View file

@ -88,7 +88,7 @@ use style::matching::{common_style_affecting_attributes, rare_style_affecting_at
use style::parser::ParserContextExtraData;
use style::properties::{DeclaredValue, Importance};
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, parse_style_attribute};
use style::properties::longhands::{self, background_image, border_spacing, font_family, font_size, overflow_x};
use style::properties::longhands::{background_image, border_spacing, font_family, font_size, overflow_x};
use style::selector_impl::{NonTSPseudoClass, ServoSelectorImpl};
use style::selector_matching::ApplicableDeclarationBlock;
use style::sink::Push;
@ -574,19 +574,16 @@ impl LayoutElementHelpers for LayoutJS<Element> {
};
if let Some(border) = border {
let width_value = specified::Length::Absolute(Au::from_px(border as i32));
let width_value = specified::BorderWidth::from_length(
specified::Length::Absolute(Au::from_px(border as i32)));
hints.push(from_declaration(
PropertyDeclaration::BorderTopWidth(DeclaredValue::Value(
longhands::border_top_width::SpecifiedValue(width_value)))));
PropertyDeclaration::BorderTopWidth(DeclaredValue::Value(width_value))));
hints.push(from_declaration(
PropertyDeclaration::BorderLeftWidth(DeclaredValue::Value(
longhands::border_left_width::SpecifiedValue(width_value)))));
PropertyDeclaration::BorderLeftWidth(DeclaredValue::Value(width_value))));
hints.push(from_declaration(
PropertyDeclaration::BorderBottomWidth(DeclaredValue::Value(
longhands::border_bottom_width::SpecifiedValue(width_value)))));
PropertyDeclaration::BorderBottomWidth(DeclaredValue::Value(width_value))));
hints.push(from_declaration(
PropertyDeclaration::BorderRightWidth(DeclaredValue::Value(
longhands::border_right_width::SpecifiedValue(width_value)))));
PropertyDeclaration::BorderRightWidth(DeclaredValue::Value(width_value))));
}
}