mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Only restyle viewport-relative nodes on viewport size change
This commit is contained in:
parent
e7a55ae55e
commit
f754cacbd5
28 changed files with 515 additions and 11 deletions
|
@ -24,6 +24,7 @@ mod media_queries;
|
|||
mod properties;
|
||||
mod str;
|
||||
mod stylesheets;
|
||||
mod value;
|
||||
mod viewport;
|
||||
|
||||
mod writing_modes {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* 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 app_units::Au;
|
||||
use cssparser::ToCss;
|
||||
use rustc_serialize::json::Json;
|
||||
use std::env;
|
||||
|
@ -10,8 +11,10 @@ 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};
|
||||
use style::properties::longhands::border_top_width;
|
||||
use style::properties::{DeclaredValue, PropertyDeclaration, PropertyDeclarationBlock};
|
||||
use style::values::HasViewportPercentage;
|
||||
use style::values::specified::{Length, LengthOrPercentageOrAuto, LengthOrPercentage, ViewportPercentageLength};
|
||||
|
||||
#[test]
|
||||
fn properties_list_json() {
|
||||
|
@ -91,3 +94,21 @@ fn property_declaration_block_should_serialize_correctly() {
|
|||
"width: 70px; min-height: 20px; display: inline-block; height: 20px !important;"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn has_viewport_percentage_for_specified_value() {
|
||||
//TODO: test all specified value with a HasViewportPercentage impl
|
||||
let pvw = PropertyDeclaration::BorderTopWidth(
|
||||
DeclaredValue::Value(border_top_width::SpecifiedValue(
|
||||
Length::ViewportPercentage(ViewportPercentageLength::Vw(100.))
|
||||
))
|
||||
);
|
||||
assert!(pvw.has_viewport_percentage());
|
||||
|
||||
let pabs = PropertyDeclaration::BorderTopWidth(
|
||||
DeclaredValue::Value(border_top_width::SpecifiedValue(
|
||||
Length::Absolute(Au(100))
|
||||
))
|
||||
);
|
||||
assert!(!pabs.has_viewport_percentage());
|
||||
}
|
||||
|
|
15
tests/unit/style/value.rs
Normal file
15
tests/unit/style/value.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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 app_units::Au;
|
||||
use style::values::HasViewportPercentage;
|
||||
use style::values::specified::{ViewportPercentageLength, Length};
|
||||
|
||||
#[test]
|
||||
fn length_has_viewport_percentage() {
|
||||
let l = Length::ViewportPercentage(ViewportPercentageLength::Vw(100.));
|
||||
assert!(l.has_viewport_percentage());
|
||||
let l = Length::Absolute(Au(100));
|
||||
assert!(!l.has_viewport_percentage());
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue