mirror of
https://github.com/servo/servo.git
synced 2025-08-10 16:05:43 +01:00
style: Don't try to compute @viewport unnecessarily.
If the viewport rule is not enabled, there's just no point in computing it. Bug: 1372058
This commit is contained in:
parent
cb04ef933b
commit
f8755d6cf0
3 changed files with 38 additions and 19 deletions
|
@ -368,14 +368,30 @@ impl Stylist {
|
|||
|
||||
self.num_rebuilds += 1;
|
||||
|
||||
let cascaded_rule = ViewportRule {
|
||||
declarations: viewport_rule::Cascade::from_stylesheets(
|
||||
doc_stylesheets.clone(), guards.author, &self.device
|
||||
).finish(),
|
||||
};
|
||||
self.viewport_constraints = None;
|
||||
|
||||
self.viewport_constraints =
|
||||
ViewportConstraints::maybe_new(&self.device, &cascaded_rule, self.quirks_mode);
|
||||
if viewport_rule::enabled() {
|
||||
// TODO(emilio): This doesn't look so efficient.
|
||||
//
|
||||
// Presumably when we properly implement this we can at least have a
|
||||
// bit on the stylesheet that says whether it contains viewport
|
||||
// rules to skip it entirely?
|
||||
//
|
||||
// Processing it with the rest of rules seems tricky since it
|
||||
// overrides the viewport size which may change the evaluation of
|
||||
// media queries (or may not? how are viewport units in media
|
||||
// queries defined?)
|
||||
let cascaded_rule = ViewportRule {
|
||||
declarations: viewport_rule::Cascade::from_stylesheets(
|
||||
doc_stylesheets.clone(), guards.author, &self.device
|
||||
).finish()
|
||||
};
|
||||
|
||||
self.viewport_constraints =
|
||||
ViewportConstraints::maybe_new(&self.device,
|
||||
&cascaded_rule,
|
||||
self.quirks_mode)
|
||||
}
|
||||
|
||||
if let Some(ref constraints) = self.viewport_constraints {
|
||||
self.device.account_for_viewport_rule(constraints);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue