зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #14365 - Property declaration block serialization should check for importance (from canaltinova:block-important); r=emilio
<!-- Please describe your changes on the following line: --> r? @emilio , @Manishearth --- <!-- 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 #14329 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes <!-- 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: a0269027db848354fe779ce73d03d60a2b26a87f
This commit is contained in:
Родитель
dd3f6b0834
Коммит
5eae07c4ed
|
@ -81,6 +81,7 @@ impl PropertyDeclarationBlock {
|
|||
if let Some(shorthand) = Shorthand::from_name(&property) {
|
||||
// Step 2.1
|
||||
let mut list = Vec::new();
|
||||
let mut important_count = 0;
|
||||
|
||||
// Step 2.2
|
||||
for longhand in shorthand.longhands() {
|
||||
|
@ -89,13 +90,26 @@ impl PropertyDeclarationBlock {
|
|||
|
||||
// Step 2.2.2 & 2.2.3
|
||||
match declaration {
|
||||
Some(&(ref declaration, _importance)) => list.push(declaration),
|
||||
Some(&(ref declaration, importance)) => {
|
||||
list.push(declaration);
|
||||
if importance.important() {
|
||||
important_count += 1;
|
||||
}
|
||||
},
|
||||
None => return Ok(()),
|
||||
}
|
||||
}
|
||||
|
||||
// Step 3.3.2.4
|
||||
// If there is one or more longhand with important, and one or more
|
||||
// without important, we don't serialize it as a shorthand.
|
||||
if important_count > 0 && important_count != list.len() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Step 2.3
|
||||
// TODO: importance is hardcoded because method does not implement it yet
|
||||
// We don't print !important when serializing individual properties,
|
||||
// so we treat this as a normal-importance property
|
||||
let importance = Importance::Normal;
|
||||
let appendable_value = shorthand.get_shorthand_appendable_value(list).unwrap();
|
||||
return append_declaration_value(dest, appendable_value, importance)
|
||||
|
@ -286,15 +300,20 @@ impl ToCss for PropertyDeclarationBlock {
|
|||
if is_important && important_count != current_longhands.len() {
|
||||
continue;
|
||||
}
|
||||
let importance = if is_important {
|
||||
Importance::Important
|
||||
} else {
|
||||
Importance::Normal
|
||||
};
|
||||
|
||||
// TODO: serialize shorthand does not take is_important into account currently
|
||||
// Substep 5
|
||||
let was_serialized =
|
||||
try!(
|
||||
shorthand.serialize_shorthand_to_buffer(
|
||||
dest,
|
||||
current_longhands.iter().cloned(),
|
||||
&mut is_first_serialization
|
||||
&mut is_first_serialization,
|
||||
importance
|
||||
)
|
||||
);
|
||||
// If serialization occured, Substep 7 & 8 will have been completed
|
||||
|
|
|
@ -435,7 +435,8 @@ impl Shorthand {
|
|||
pub fn serialize_shorthand_to_buffer<'a, W, I>(self,
|
||||
dest: &mut W,
|
||||
declarations: I,
|
||||
is_first_serialization: &mut bool)
|
||||
is_first_serialization: &mut bool,
|
||||
importance: Importance)
|
||||
-> Result<bool, fmt::Error>
|
||||
where W: Write, I: IntoIterator<Item=&'a PropertyDeclaration>, I::IntoIter: Clone {
|
||||
match self.get_shorthand_appendable_value(declarations) {
|
||||
|
@ -447,7 +448,7 @@ impl Shorthand {
|
|||
dest,
|
||||
property_name,
|
||||
appendable_value,
|
||||
Importance::Normal,
|
||||
importance,
|
||||
is_first_serialization
|
||||
).and_then(|_| Ok(true))
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче