Revert "Backport several style changes from Gecko (5) (#30099)" (#30104)

This reverts commit 8e15389cae.
This commit is contained in:
Oriol Brufau 2023-08-16 08:24:42 +02:00 committed by GitHub
parent 8e15389cae
commit d6ae8dc112
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
152 changed files with 4622 additions and 5862 deletions

View file

@ -21,6 +21,7 @@ servo_arc = {path = "../../../components/servo_arc"}
servo_atoms = {path = "../../../components/atoms"}
servo_config = {path = "../../../components/config"}
servo_url = {path = "../../../components/url"}
size_of_test = {path = "../../../components/size_of_test"}
style = {path = "../../../components/style", features = ["servo"]}
style_traits = {path = "../../../components/style_traits"}
std_test_override = { path = "../../../components/std_test_override" }

View file

@ -16,6 +16,9 @@ extern crate serde_json;
extern crate servo_arc;
extern crate servo_atoms;
extern crate servo_url;
#[macro_use]
extern crate size_of_test;
#[macro_use]
extern crate style;
extern crate style_traits;
extern crate test;
@ -27,6 +30,8 @@ mod logical_geometry;
mod parsing;
mod properties;
mod rule_tree;
mod size_of;
mod specified_values;
mod str;
mod stylesheets;
mod stylist;

View file

@ -0,0 +1,51 @@
/* 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 https://mozilla.org/MPL/2.0/. */
use selectors::parser::{SelectorParseError, SelectorParseErrorKind};
use style::invalidation::element::invalidation_map::Dependency;
use style::properties;
size_of_test!(test_size_of_dependency, Dependency, 24);
size_of_test!(
test_size_of_property_declaration,
properties::PropertyDeclaration,
32
);
// This is huge, but we allocate it on the stack and then never move it,
// we only pass `&mut SourcePropertyDeclaration` references around.
size_of_test!(
test_size_of_parsed_declaration,
properties::SourcePropertyDeclaration,
568
);
size_of_test!(
test_size_of_selector_parse_error_kind,
SelectorParseErrorKind,
40
);
size_of_test!(
test_size_of_style_parse_error_kind,
::style_traits::StyleParseErrorKind,
56
);
size_of_test!(
test_size_of_value_parse_error_kind,
::style_traits::ValueParseErrorKind,
40
);
size_of_test!(test_size_of_selector_parse_error, SelectorParseError, 48);
size_of_test!(
test_size_of_style_traits_parse_error,
::style_traits::ParseError,
64
);
size_of_test!(
test_size_of_value_parse_error,
::style_traits::ValueParseError,
48
);

View file

@ -0,0 +1,50 @@
/* 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 https://mozilla.org/MPL/2.0/. */
use style;
#[cfg(all(test, target_pointer_width = "64"))]
#[test]
fn size_of_specified_values() {
use std::mem::size_of;
let threshold = 24;
let mut bad_properties = vec![];
macro_rules! check_property {
( $( { $name: ident, $boxed: expr } )+ ) => {
$(
let size = size_of::<style::properties::longhands::$name::SpecifiedValue>();
let is_boxed = $boxed;
if (!is_boxed && size > threshold) || (is_boxed && size <= threshold) {
bad_properties.push((stringify!($name), size, is_boxed));
}
)+
}
}
longhand_properties_idents!(check_property);
let mut failing_messages = vec![];
for bad_prop in bad_properties {
if !bad_prop.2 {
failing_messages.push(
format!("Your changes have increased the size of {} SpecifiedValue to {}. The threshold is \
currently {}. SpecifiedValues affect size of PropertyDeclaration enum and \
increasing the size may negative affect style system performance. Please consider \
using `boxed=\"True\"` in this longhand.",
bad_prop.0, bad_prop.1, threshold));
} else if bad_prop.2 {
failing_messages.push(
format!("Your changes have decreased the size of {} SpecifiedValue to {}. Good work! \
The threshold is currently {}. Please consider removing `boxed=\"True\"` from this longhand.",
bad_prop.0, bad_prop.1, threshold));
}
}
if !failing_messages.is_empty() {
panic!("{}", failing_messages.join("\n\n"));
}
}

View file

@ -16,9 +16,10 @@ use style::properties::{PropertyDeclaration, PropertyDeclarationBlock};
use style::selector_map::SelectorMap;
use style::selector_parser::{SelectorImpl, SelectorParser};
use style::shared_lock::SharedRwLock;
use style::stylesheets::layer_rule::LayerId;
use style::stylesheets::StyleRule;
use style::stylist::needs_revalidation_for_testing;
use style::stylist::{ContainerConditionId, LayerId, Rule, Stylist};
use style::stylist::{Rule, Stylist};
use style::thread_state::{self, ThreadState};
/// Helper method to get some Rules from selector strings.
@ -55,7 +56,6 @@ fn get_mock_rules(css_selectors: &[&str]) -> (Vec<Vec<Rule>>, SharedRwLock) {
locked.clone(),
i as u32,
LayerId::root(),
ContainerConditionId::none(),
)
})
.collect()