Auto merge of #18376 - kuoe0:set-fallbacktype-to-none-when-the-fallback-color-of-context-property-is-none, r=xidorn

Support None and NotSet for the fallback type of SVGPaint.

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

We didn't set None and NotSet for the fallback type of SVGPaint, and it caused the fallback color is wrong when fallback color is empty or keyword `none`. So, we add the None and NotSet support for it.

---
<!-- 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 [Bug 1380590](https://bugzilla.mozilla.org/show_bug.cgi?id=1380590)

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because of the test cases already in Gecko.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/18376)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-09-05 21:43:02 -05:00 committed by GitHub
commit 1cf87a243a
2 changed files with 32 additions and 15 deletions

View file

@ -60,7 +60,7 @@ use selector_parser::PseudoElement;
use servo_arc::{Arc, RawOffsetArc};
use std::mem::{forget, uninitialized, transmute, zeroed};
use std::{cmp, ops, ptr};
use values::{self, Auto, CustomIdent, Either, KeyframesName};
use values::{self, Auto, CustomIdent, Either, KeyframesName, None_};
use values::computed::{NonNegativeAu, ToComputedValue, Percentage};
use values::computed::effects::{BoxShadow, Filter, SimpleShadow};
use computed_values::border_style;
@ -743,10 +743,16 @@ def set_gecko_property(ffi_name, expr):
}
}
if let Some(fallback) = fallback {
paint.mFallbackType = nsStyleSVGFallbackType::eStyleSVGFallbackType_Color;
paint.mFallbackColor = convert_rgba_to_nscolor(&fallback);
}
paint.mFallbackType = match fallback {
Some(Either::First(color)) => {
paint.mFallbackColor = convert_rgba_to_nscolor(&color);
nsStyleSVGFallbackType::eStyleSVGFallbackType_Color
},
Some(Either::Second(_)) => {
nsStyleSVGFallbackType::eStyleSVGFallbackType_None
},
None => nsStyleSVGFallbackType::eStyleSVGFallbackType_NotSet
};
}
#[allow(non_snake_case)]
@ -771,11 +777,17 @@ def set_gecko_property(ffi_name, expr):
use self::structs::nsStyleSVGPaintType;
use self::structs::nsStyleSVGFallbackType;
let ref paint = ${get_gecko_property(gecko_ffi_name)};
let fallback = if let nsStyleSVGFallbackType::eStyleSVGFallbackType_Color = paint.mFallbackType {
Some(convert_nscolor_to_rgba(paint.mFallbackColor))
} else {
None
let fallback = match paint.mFallbackType {
nsStyleSVGFallbackType::eStyleSVGFallbackType_Color => {
Some(Either::First(convert_nscolor_to_rgba(paint.mFallbackColor)))
},
nsStyleSVGFallbackType::eStyleSVGFallbackType_None => {
Some(Either::Second(None_))
},
nsStyleSVGFallbackType::eStyleSVGFallbackType_NotSet => None,
};
let kind = match paint.mType {
nsStyleSVGPaintType::eStyleSVGPaintType_None => SVGPaintKind::None,
nsStyleSVGPaintType::eStyleSVGPaintType_ContextFill => SVGPaintKind::ContextFill,