mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
Bug 1331213: Bootstrap a Gecko-side Device, and track it's dirtiness manually in the per-doc data. r=heycam
The setup is quite different to Servo-land, so add a comment about the different setup. Also, check viewport rules when flushing stylesheets. I believe that the previous behavior is plain wrong, though I haven't taken the time to come up with a test case. In any case, it doesn't hurt any of both back-ends. MozReview-Commit-ID: 46gtTkesOsr Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
parent
5d6ac65e04
commit
5b5243b8af
11 changed files with 685 additions and 83 deletions
|
@ -49,6 +49,20 @@ pub use ::fnv::FnvHashMap;
|
|||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct Stylist {
|
||||
/// Device that the stylist is currently evaluating against.
|
||||
///
|
||||
/// This field deserves a bigger comment due to the different use that Gecko
|
||||
/// and Servo give to it (that we should eventually unify).
|
||||
///
|
||||
/// With Gecko, the device is never changed. Gecko manually tracks whether
|
||||
/// the device data should be reconstructed, and "resets" the state of the
|
||||
/// device.
|
||||
///
|
||||
/// On Servo, on the other hand, the device is a really cheap representation
|
||||
/// that is recreated each time some constraint changes and calling
|
||||
/// `set_device`.
|
||||
///
|
||||
/// In both cases, the device is actually _owned_ by the Stylist, and it's
|
||||
/// only an `Arc` so we can implement `add_stylesheet` more idiomatically.
|
||||
pub device: Arc<Device>,
|
||||
|
||||
/// Viewport constraints based on the current device.
|
||||
|
@ -146,6 +160,18 @@ impl Stylist {
|
|||
return false;
|
||||
}
|
||||
|
||||
let cascaded_rule = ViewportRule {
|
||||
declarations: viewport::Cascade::from_stylesheets(doc_stylesheets, &self.device).finish(),
|
||||
};
|
||||
|
||||
self.viewport_constraints =
|
||||
ViewportConstraints::maybe_new(&self.device, &cascaded_rule);
|
||||
|
||||
if let Some(ref constraints) = self.viewport_constraints {
|
||||
Arc::get_mut(&mut self.device).unwrap()
|
||||
.account_for_viewport_rule(constraints);
|
||||
}
|
||||
|
||||
self.element_map = PerPseudoElementSelectorMap::new();
|
||||
self.pseudos_map = Default::default();
|
||||
self.animations = Default::default();
|
||||
|
@ -394,6 +420,13 @@ impl Stylist {
|
|||
///
|
||||
/// Probably worth to make the stylist own a single `Device`, and have a
|
||||
/// `update_device` function?
|
||||
///
|
||||
/// feature = "servo" because gecko only has one device, and manually tracks
|
||||
/// when the device is dirty.
|
||||
///
|
||||
/// FIXME(emilio): The semantics of the device for Servo and Gecko are
|
||||
/// different enough we may want to unify them.
|
||||
#[cfg(feature = "servo")]
|
||||
pub fn set_device(&mut self, mut device: Device, stylesheets: &[Arc<Stylesheet>]) {
|
||||
let cascaded_rule = ViewportRule {
|
||||
declarations: viewport::Cascade::from_stylesheets(stylesheets, &device).finish(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue