Auto merge of #11377 - servo:style-attr-ser-rebase, r=SimonSapin

Update style attributes on CSSStyleDeclaration changes

Rebase of #9410. Fixes #9410, fixes #9307.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11377)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-05-25 05:23:14 -05:00
commit 52f17a8814
5 changed files with 554 additions and 116 deletions

View file

@ -2,11 +2,16 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::ToCss;
use rustc_serialize::json::Json;
use std::env;
use std::fs::{File, remove_file};
use std::path::Path;
use std::process::Command;
use std::sync::Arc;
use style::computed_values::display::T::inline_block;
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, DeclaredValue};
use style::values::specified::{Length, LengthOrPercentageOrAuto, LengthOrPercentage};
#[test]
fn properties_list_json() {
@ -51,3 +56,38 @@ fn find_python() -> String {
"python"
}.to_owned()
}
#[test]
fn property_declaration_block_should_serialize_correctly() {
let mut normal = Vec::new();
let mut important = Vec::new();
let length = LengthOrPercentageOrAuto::Length(Length::from_px(70f32));
let value = DeclaredValue::Value(length);
normal.push(PropertyDeclaration::Width(value));
let min_height = LengthOrPercentage::Length(Length::from_px(20f32));
let value = DeclaredValue::Value(min_height);
normal.push(PropertyDeclaration::MinHeight(value));
let value = DeclaredValue::Value(inline_block);
normal.push(PropertyDeclaration::Display(value));
let height = LengthOrPercentageOrAuto::Length(Length::from_px(20f32));
let value = DeclaredValue::Value(height);
important.push(PropertyDeclaration::Height(value));
normal.reverse();
important.reverse();
let block = PropertyDeclarationBlock {
normal: Arc::new(normal),
important: Arc::new(important)
};
let css_string = block.to_css_string();
assert_eq!(
css_string,
"width: 70px; min-height: 20px; display: inline-block; height: 20px !important;"
);
}