mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #16609 - nox:quirks, r=Manishearth,emilio
Implement unitless length quirk The Gecko side doesn't propagate its quirks mode yet. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16609) <!-- Reviewable:end -->
This commit is contained in:
commit
d8bcc0db1a
70 changed files with 2321 additions and 194 deletions
|
@ -8,6 +8,7 @@
|
|||
|
||||
use {Atom, LocalName};
|
||||
use bit_vec::BitVec;
|
||||
use context::QuirksMode;
|
||||
use data::ComputedStyle;
|
||||
use dom::{AnimationRules, PresentationalHintsSynthetizer, TElement};
|
||||
use error_reporting::RustLogReporter;
|
||||
|
@ -76,7 +77,7 @@ pub struct Stylist {
|
|||
viewport_constraints: Option<ViewportConstraints>,
|
||||
|
||||
/// If true, the quirks-mode stylesheet is applied.
|
||||
quirks_mode: bool,
|
||||
quirks_mode: QuirksMode,
|
||||
|
||||
/// If true, the device has changed, and the stylist needs to be updated.
|
||||
is_device_dirty: bool,
|
||||
|
@ -166,7 +167,7 @@ impl Stylist {
|
|||
viewport_constraints: None,
|
||||
device: Arc::new(device),
|
||||
is_device_dirty: true,
|
||||
quirks_mode: false,
|
||||
quirks_mode: QuirksMode::NoQuirks,
|
||||
|
||||
element_map: PerPseudoElementSelectorMap::new(),
|
||||
pseudos_map: Default::default(),
|
||||
|
@ -240,7 +241,7 @@ impl Stylist {
|
|||
};
|
||||
|
||||
self.viewport_constraints =
|
||||
ViewportConstraints::maybe_new(&self.device, &cascaded_rule);
|
||||
ViewportConstraints::maybe_new(&self.device, &cascaded_rule, self.quirks_mode);
|
||||
|
||||
if let Some(ref constraints) = self.viewport_constraints {
|
||||
Arc::get_mut(&mut self.device).unwrap()
|
||||
|
@ -269,7 +270,7 @@ impl Stylist {
|
|||
self.add_stylesheet(&stylesheet, guards.ua_or_user, extra_data);
|
||||
}
|
||||
|
||||
if self.quirks_mode {
|
||||
if self.quirks_mode != QuirksMode::NoQuirks {
|
||||
self.add_stylesheet(&ua_stylesheets.quirks_mode_stylesheet,
|
||||
guards.ua_or_user, extra_data);
|
||||
}
|
||||
|
@ -424,7 +425,8 @@ impl Stylist {
|
|||
None,
|
||||
&RustLogReporter,
|
||||
font_metrics,
|
||||
cascade_flags);
|
||||
cascade_flags,
|
||||
self.quirks_mode);
|
||||
ComputedStyle::new(rule_node, Arc::new(computed))
|
||||
}
|
||||
|
||||
|
@ -548,7 +550,8 @@ impl Stylist {
|
|||
None,
|
||||
&RustLogReporter,
|
||||
font_metrics,
|
||||
CascadeFlags::empty());
|
||||
CascadeFlags::empty(),
|
||||
self.quirks_mode);
|
||||
|
||||
Some(ComputedStyle::new(rule_node, Arc::new(computed)))
|
||||
}
|
||||
|
@ -581,22 +584,22 @@ impl Stylist {
|
|||
};
|
||||
|
||||
self.viewport_constraints =
|
||||
ViewportConstraints::maybe_new(&device, &cascaded_rule);
|
||||
ViewportConstraints::maybe_new(&device, &cascaded_rule, self.quirks_mode);
|
||||
|
||||
if let Some(ref constraints) = self.viewport_constraints {
|
||||
device.account_for_viewport_rule(constraints);
|
||||
}
|
||||
|
||||
fn mq_eval_changed(guard: &SharedRwLockReadGuard, rules: &[CssRule],
|
||||
before: &Device, after: &Device) -> bool {
|
||||
before: &Device, after: &Device, quirks_mode: QuirksMode) -> bool {
|
||||
for rule in rules {
|
||||
let changed = rule.with_nested_rules_and_mq(guard, |rules, mq| {
|
||||
if let Some(mq) = mq {
|
||||
if mq.evaluate(before) != mq.evaluate(after) {
|
||||
if mq.evaluate(before, quirks_mode) != mq.evaluate(after, quirks_mode) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
mq_eval_changed(guard, rules, before, after)
|
||||
mq_eval_changed(guard, rules, before, after, quirks_mode)
|
||||
});
|
||||
if changed {
|
||||
return true
|
||||
|
@ -606,11 +609,11 @@ impl Stylist {
|
|||
}
|
||||
self.is_device_dirty |= stylesheets.iter().any(|stylesheet| {
|
||||
let mq = stylesheet.media.read_with(guard);
|
||||
if mq.evaluate(&self.device) != mq.evaluate(&device) {
|
||||
if mq.evaluate(&self.device, self.quirks_mode) != mq.evaluate(&device, self.quirks_mode) {
|
||||
return true
|
||||
}
|
||||
|
||||
mq_eval_changed(guard, &stylesheet.rules.read_with(guard).0, &self.device, &device)
|
||||
mq_eval_changed(guard, &stylesheet.rules.read_with(guard).0, &self.device, &device, self.quirks_mode)
|
||||
});
|
||||
|
||||
self.device = Arc::new(device);
|
||||
|
@ -623,14 +626,14 @@ impl Stylist {
|
|||
}
|
||||
|
||||
/// Sets the quirks mode of the document.
|
||||
pub fn set_quirks_mode(&mut self, enabled: bool) {
|
||||
pub fn set_quirks_mode(&mut self, quirks_mode: QuirksMode) {
|
||||
// FIXME(emilio): We don't seem to change the quirks mode dynamically
|
||||
// during multiple layout passes, but this is totally bogus, in the
|
||||
// sense that it's updated asynchronously.
|
||||
//
|
||||
// This should probably be an argument to `update`, and use the quirks
|
||||
// mode info in the `SharedLayoutContext`.
|
||||
self.quirks_mode = enabled;
|
||||
self.quirks_mode = quirks_mode;
|
||||
}
|
||||
|
||||
/// Returns the applicable CSS declarations for the given element.
|
||||
|
@ -893,7 +896,8 @@ impl Stylist {
|
|||
None,
|
||||
&RustLogReporter,
|
||||
&metrics,
|
||||
CascadeFlags::empty()))
|
||||
CascadeFlags::empty(),
|
||||
self.quirks_mode))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue