mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Propagate quirks mode all the way to ParserContext
The quirks mode is still not properly propagated in geckolib.
This commit is contained in:
parent
10fb8e61c7
commit
f68e2fded9
39 changed files with 225 additions and 100 deletions
|
@ -8,6 +8,7 @@ use servo_url::ServoUrl;
|
|||
use std::borrow::ToOwned;
|
||||
use std::sync::Arc;
|
||||
use style::Atom;
|
||||
use style::context::QuirksMode;
|
||||
use style::error_reporting::ParseErrorReporter;
|
||||
use style::media_queries::*;
|
||||
use style::servo::media_queries::*;
|
||||
|
@ -37,7 +38,7 @@ fn test_media_rule<F>(css: &str, callback: F)
|
|||
let media_list = Arc::new(lock.wrap(MediaList::empty()));
|
||||
let stylesheet = Stylesheet::from_str(
|
||||
css, url, Origin::Author, media_list, lock,
|
||||
None, &CSSErrorReporterTest, 0u64);
|
||||
None, &CSSErrorReporterTest, QuirksMode::NoQuirks, 0u64);
|
||||
let mut rule_count = 0;
|
||||
let guard = stylesheet.shared_lock.read();
|
||||
media_queries(&guard, &stylesheet.rules.read_with(&guard).0, &mut |mq| {
|
||||
|
@ -66,7 +67,7 @@ fn media_query_test(device: &Device, css: &str, expected_rule_count: usize) {
|
|||
let media_list = Arc::new(lock.wrap(MediaList::empty()));
|
||||
let ss = Stylesheet::from_str(
|
||||
css, url, Origin::Author, media_list, lock,
|
||||
None, &CSSErrorReporterTest, 0u64);
|
||||
None, &CSSErrorReporterTest, QuirksMode::NoQuirks, 0u64);
|
||||
let mut rule_count = 0;
|
||||
ss.effective_style_rules(device, &ss.shared_lock.read(), |_| rule_count += 1);
|
||||
assert!(rule_count == expected_rule_count, css.to_owned());
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
use euclid::size::TypedSize2D;
|
||||
use parsing::parse;
|
||||
use std::f32::consts::PI;
|
||||
use style::context::QuirksMode;
|
||||
use style::font_metrics::ServoMetricsProvider;
|
||||
use style::media_queries::{Device, MediaType};
|
||||
use style::properties::ComputedValues;
|
||||
|
@ -51,6 +52,7 @@ fn test_linear_gradient() {
|
|||
style: initial_style.clone(),
|
||||
font_metrics_provider: &ServoMetricsProvider,
|
||||
in_media_query: false,
|
||||
quirks_mode: QuirksMode::NoQuirks,
|
||||
};
|
||||
assert_eq!(specified::AngleOrCorner::None.to_computed_value(&specified_context),
|
||||
computed::AngleOrCorner::Angle(Angle::from_radians(PI)));
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
use cssparser::Parser;
|
||||
use media_queries::CSSErrorReporterTest;
|
||||
use parsing::parse;
|
||||
use style::context::QuirksMode;
|
||||
use style::parser::{LengthParsingMode, Parse, ParserContext};
|
||||
use style::stylesheets::{CssRuleType, Origin};
|
||||
use style::values::specified::length::{AbsoluteLength, Length, NoCalcLength};
|
||||
|
@ -38,7 +39,8 @@ fn test_length_parsing_modes() {
|
|||
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
||||
let reporter = CSSErrorReporterTest;
|
||||
let context = ParserContext::new(Origin::Author, &url, &reporter,
|
||||
Some(CssRuleType::Style), LengthParsingMode::SVG);
|
||||
Some(CssRuleType::Style), LengthParsingMode::SVG,
|
||||
QuirksMode::NoQuirks);
|
||||
let mut parser = Parser::new("1");
|
||||
let result = Length::parse(&context, &mut parser);
|
||||
assert!(result.is_ok());
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
use cssparser::Parser;
|
||||
use media_queries::CSSErrorReporterTest;
|
||||
use style::context::QuirksMode;
|
||||
use style::parser::{LengthParsingMode, ParserContext};
|
||||
use style::stylesheets::{CssRuleType, Origin};
|
||||
|
||||
|
@ -13,7 +14,8 @@ fn parse<T, F: Fn(&ParserContext, &mut Parser) -> Result<T, ()>>(f: F, s: &str)
|
|||
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
||||
let reporter = CSSErrorReporterTest;
|
||||
let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style),
|
||||
LengthParsingMode::Default);
|
||||
LengthParsingMode::Default,
|
||||
QuirksMode::NoQuirks);
|
||||
let mut parser = Parser::new(s);
|
||||
f(&context, &mut parser)
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
use cssparser::Parser;
|
||||
use media_queries::CSSErrorReporterTest;
|
||||
use style::context::QuirksMode;
|
||||
use style::parser::{LengthParsingMode, ParserContext};
|
||||
use style::stylesheets::{CssRuleType, Origin};
|
||||
|
||||
|
@ -11,7 +12,8 @@ fn parse<T, F: Fn(&ParserContext, &mut Parser) -> Result<T, ()>>(f: F, s: &str)
|
|||
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
||||
let reporter = CSSErrorReporterTest;
|
||||
let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style),
|
||||
LengthParsingMode::Default);
|
||||
LengthParsingMode::Default,
|
||||
QuirksMode::NoQuirks);
|
||||
let mut parser = Parser::new(s);
|
||||
f(&context, &mut parser)
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ use cssparser::{Parser, SourcePosition};
|
|||
use rayon;
|
||||
use servo_url::ServoUrl;
|
||||
use std::sync::Arc;
|
||||
use style::context::QuirksMode;
|
||||
use style::error_reporting::ParseErrorReporter;
|
||||
use style::media_queries::MediaList;
|
||||
use style::properties::{longhands, Importance, PropertyDeclaration, PropertyDeclarationBlock};
|
||||
|
@ -58,6 +59,7 @@ fn parse_rules(css: &str) -> Vec<(StyleSource, CascadeLevel)> {
|
|||
lock,
|
||||
None,
|
||||
&ErrorringErrorReporter,
|
||||
QuirksMode::NoQuirks,
|
||||
0u64);
|
||||
let guard = s.shared_lock.read();
|
||||
let rules = s.rules.read_with(&guard);
|
||||
|
|
|
@ -13,6 +13,7 @@ use std::borrow::ToOwned;
|
|||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use style::context::QuirksMode;
|
||||
use style::error_reporting::ParseErrorReporter;
|
||||
use style::keyframes::{Keyframe, KeyframeSelector, KeyframePercentage};
|
||||
use style::media_queries::MediaList;
|
||||
|
@ -66,7 +67,7 @@ fn test_parse_stylesheet() {
|
|||
let lock = SharedRwLock::new();
|
||||
let media = Arc::new(lock.wrap(MediaList::empty()));
|
||||
let stylesheet = Stylesheet::from_str(css, url.clone(), Origin::UserAgent, media, lock,
|
||||
None, &CSSErrorReporterTest, 0u64);
|
||||
None, &CSSErrorReporterTest, QuirksMode::NoQuirks, 0u64);
|
||||
let mut namespaces = Namespaces::default();
|
||||
namespaces.default = Some(ns!(html));
|
||||
let expected = Stylesheet {
|
||||
|
@ -77,6 +78,7 @@ fn test_parse_stylesheet() {
|
|||
url_data: url,
|
||||
dirty_on_viewport_size_change: AtomicBool::new(false),
|
||||
disabled: AtomicBool::new(false),
|
||||
quirks_mode: QuirksMode::NoQuirks,
|
||||
rules: CssRules::new(vec![
|
||||
CssRule::Namespace(Arc::new(stylesheet.shared_lock.wrap(NamespaceRule {
|
||||
prefix: None,
|
||||
|
@ -316,7 +318,7 @@ fn test_report_error_stylesheet() {
|
|||
let lock = SharedRwLock::new();
|
||||
let media = Arc::new(lock.wrap(MediaList::empty()));
|
||||
Stylesheet::from_str(css, url.clone(), Origin::UserAgent, media, lock,
|
||||
None, &error_reporter, 5u64);
|
||||
None, &error_reporter, QuirksMode::NoQuirks, 5u64);
|
||||
|
||||
let mut errors = errors.lock().unwrap();
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ use media_queries::CSSErrorReporterTest;
|
|||
use servo_config::prefs::{PREFS, PrefValue};
|
||||
use servo_url::ServoUrl;
|
||||
use std::sync::Arc;
|
||||
use style::context::QuirksMode;
|
||||
use style::media_queries::{Device, MediaList, MediaType};
|
||||
use style::parser::{LengthParsingMode, Parse, ParserContext};
|
||||
use style::shared_lock::SharedRwLock;
|
||||
|
@ -32,6 +33,7 @@ macro_rules! stylesheet {
|
|||
$shared_lock,
|
||||
None,
|
||||
&$error_reporter,
|
||||
QuirksMode::NoQuirks,
|
||||
0u64
|
||||
))
|
||||
}
|
||||
|
@ -293,7 +295,8 @@ fn constrain_viewport() {
|
|||
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||
let reporter = CSSErrorReporterTest;
|
||||
let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Viewport),
|
||||
LengthParsingMode::Default);
|
||||
LengthParsingMode::Default,
|
||||
QuirksMode::NoQuirks);
|
||||
|
||||
macro_rules! from_css {
|
||||
($css:expr) => {
|
||||
|
@ -303,9 +306,9 @@ fn constrain_viewport() {
|
|||
|
||||
let initial_viewport = TypedSize2D::new(800., 600.);
|
||||
let device = Device::new(MediaType::Screen, initial_viewport);
|
||||
assert_eq!(ViewportConstraints::maybe_new(&device, from_css!("")), None);
|
||||
assert_eq!(ViewportConstraints::maybe_new(&device, from_css!(""), QuirksMode::NoQuirks), None);
|
||||
|
||||
assert_eq!(ViewportConstraints::maybe_new(&device, from_css!("width: 320px auto")),
|
||||
assert_eq!(ViewportConstraints::maybe_new(&device, from_css!("width: 320px auto"), QuirksMode::NoQuirks),
|
||||
Some(ViewportConstraints {
|
||||
size: initial_viewport,
|
||||
|
||||
|
@ -317,7 +320,7 @@ fn constrain_viewport() {
|
|||
orientation: Orientation::Auto
|
||||
}));
|
||||
|
||||
assert_eq!(ViewportConstraints::maybe_new(&device, from_css!("width: 320px auto")),
|
||||
assert_eq!(ViewportConstraints::maybe_new(&device, from_css!("width: 320px auto"), QuirksMode::NoQuirks),
|
||||
Some(ViewportConstraints {
|
||||
size: initial_viewport,
|
||||
|
||||
|
@ -329,10 +332,12 @@ fn constrain_viewport() {
|
|||
orientation: Orientation::Auto
|
||||
}));
|
||||
|
||||
assert_eq!(ViewportConstraints::maybe_new(&device, from_css!("width: 800px; height: 600px;\
|
||||
zoom: 1;\
|
||||
user-zoom: zoom;\
|
||||
orientation: auto;")),
|
||||
assert_eq!(ViewportConstraints::maybe_new(&device,
|
||||
from_css!("width: 800px; height: 600px;\
|
||||
zoom: 1;\
|
||||
user-zoom: zoom;\
|
||||
orientation: auto;"),
|
||||
QuirksMode::NoQuirks),
|
||||
Some(ViewportConstraints {
|
||||
size: initial_viewport,
|
||||
|
||||
|
@ -346,7 +351,7 @@ fn constrain_viewport() {
|
|||
|
||||
let initial_viewport = TypedSize2D::new(200., 150.);
|
||||
let device = Device::new(MediaType::Screen, initial_viewport);
|
||||
assert_eq!(ViewportConstraints::maybe_new(&device, from_css!("width: 320px auto")),
|
||||
assert_eq!(ViewportConstraints::maybe_new(&device, from_css!("width: 320px auto"), QuirksMode::NoQuirks),
|
||||
Some(ViewportConstraints {
|
||||
size: TypedSize2D::new(320., 240.),
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue