Auto merge of #14370 - thiagopnts:master, r=Wafflespeanut

use Either type for UrlOrNone

Use the Either type for UrlOrNone

---
<!-- 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
- [ ] These changes fix #14298 (github issue number if applicable).

<!-- Either: -->
- [ ] 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/14370)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-12-01 22:03:31 -08:00 committed by GitHub
commit 290ff5c801
9 changed files with 30 additions and 49 deletions

View file

@ -1089,10 +1089,10 @@ fn static_assert() {
#[allow(non_snake_case)]
pub fn set__moz_binding(&mut self, v: longhands::_moz_binding::computed_value::T) {
use properties::longhands::_moz_binding::computed_value::T as BindingValue;
use values::Either;
match v {
BindingValue::None => debug_assert!(self.gecko.mBinding.mRawPtr.is_null()),
BindingValue::Url(ref url) => {
Either::Second(_none) => debug_assert!(self.gecko.mBinding.mRawPtr.is_null()),
Either::First(ref url) => {
let extra_data = url.extra_data();
let (ptr, len) = url.as_slice_components();
unsafe {
@ -1617,14 +1617,14 @@ fn static_assert() {
skip_additionals="*">
pub fn set_list_style_image(&mut self, image: longhands::list_style_image::computed_value::T) {
use values::computed::UrlOrNone;
use values::Either;
match image {
UrlOrNone::None => {
Either::Second(_none) => {
unsafe {
Gecko_SetListStyleImageNone(&mut self.gecko);
}
}
UrlOrNone::Url(ref url) => {
Either::First(ref url) => {
let (ptr, len) = url.as_slice_components();
let extra_data = url.extra_data();
unsafe {

View file

@ -1551,7 +1551,7 @@ ${helpers.single_keyword("-moz-appearance",
animatable=False)}
// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-binding
${helpers.predefined_type("-moz-binding", "UrlOrNone", "computed_value::T::None",
${helpers.predefined_type("-moz-binding", "UrlOrNone", "Either::Second(None_)",
products="gecko",
animatable="False",
disable_when_testing="True")}

View file

@ -26,7 +26,7 @@ ${helpers.single_keyword("list-style-type", """
gecko_constant_prefix="NS_STYLE_LIST_STYLE",
animatable=False)}
${helpers.predefined_type("list-style-image", "UrlOrNone", "computed_value::T::None",
${helpers.predefined_type("list-style-image", "UrlOrNone", "Either::Second(None_)",
animatable="False")}
<%helpers:longhand name="quotes" animatable="False">

View file

@ -7,6 +7,7 @@
<%helpers:shorthand name="list-style"
sub_properties="list-style-image list-style-position list-style-type">
use properties::longhands::{list_style_image, list_style_position, list_style_type};
use values::{Either, None_};
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
// `none` is ambiguous until we've finished parsing the shorthands, so we count the number
@ -56,7 +57,7 @@
(true, 2, None, None) => {
Ok(Longhands {
list_style_position: position,
list_style_image: Some(list_style_image::SpecifiedValue::None),
list_style_image: Some(Either::Second(None_)),
list_style_type: Some(list_style_type::SpecifiedValue::none),
})
}
@ -70,14 +71,14 @@
(true, 1, Some(list_style_type), None) => {
Ok(Longhands {
list_style_position: position,
list_style_image: Some(list_style_image::SpecifiedValue::None),
list_style_image: Some(Either::Second(None_)),
list_style_type: Some(list_style_type),
})
}
(true, 1, None, None) => {
Ok(Longhands {
list_style_position: position,
list_style_image: Some(list_style_image::SpecifiedValue::None),
list_style_image: Some(Either::Second(None_)),
list_style_type: Some(list_style_type::SpecifiedValue::none),
})
}