Combine ReflowGoal and ReflowQueryType

This simplifies the logic in the layout_thread and makes it clearer
which types of reflows generate display lists and cause display updates.
This commit is contained in:
Martin Robinson 2017-09-30 14:57:59 +02:00
parent 75a4dcf293
commit 0380431157
9 changed files with 177 additions and 267 deletions

View file

@ -20,7 +20,7 @@ use servo_atoms::Atom;
use servo_url::ServoUrl;
use std::sync::Arc;
use std::sync::mpsc::{Receiver, Sender};
use style::context::{QuirksMode, ReflowGoal};
use style::context::QuirksMode;
use style::properties::PropertyId;
use style::selector_parser::PseudoElement;
use style::stylesheets::Stylesheet;
@ -103,8 +103,9 @@ pub enum Msg {
/// Any query to perform with this reflow.
#[derive(Debug, PartialEq)]
pub enum ReflowQueryType {
NoQuery,
pub enum ReflowGoal {
Full,
TickAnimations,
ContentBoxQuery(TrustedNodeAddress),
ContentBoxesQuery(TrustedNodeAddress),
NodeOverflowQuery(TrustedNodeAddress),
@ -119,10 +120,38 @@ pub enum ReflowQueryType {
NodesFromPoint(Point2D<f32>),
}
impl ReflowGoal {
/// Returns true if the given ReflowQuery needs a full, up-to-date display list to
/// be present or false if it only needs stacking-relative positions.
pub fn needs_display_list(&self) -> bool {
match *self {
ReflowGoal::NodesFromPoint(..) | ReflowGoal::HitTestQuery(..) |
ReflowGoal::TextIndexQuery(..) | ReflowGoal::Full => true,
ReflowGoal::ContentBoxQuery(_) | ReflowGoal::ContentBoxesQuery(_) |
ReflowGoal::NodeGeometryQuery(_) | ReflowGoal::NodeScrollGeometryQuery(_) |
ReflowGoal::NodeOverflowQuery(_) | ReflowGoal::NodeScrollRootIdQuery(_) |
ReflowGoal::ResolvedStyleQuery(..) | ReflowGoal::OffsetParentQuery(_) |
ReflowGoal::MarginStyleQuery(_) | ReflowGoal::TickAnimations => false,
}
}
/// Returns true if the given ReflowQuery needs its display list send to WebRender or
/// false if a layout_thread display list is sufficient.
pub fn needs_display(&self) -> bool {
match *self {
ReflowGoal::MarginStyleQuery(_) | ReflowGoal::TextIndexQuery(..) |
ReflowGoal::HitTestQuery(..) | ReflowGoal::ContentBoxQuery(_) |
ReflowGoal::ContentBoxesQuery(_) | ReflowGoal::NodeGeometryQuery(_) |
ReflowGoal::NodeScrollGeometryQuery(_) | ReflowGoal::NodeOverflowQuery(_) |
ReflowGoal::NodeScrollRootIdQuery(_) | ReflowGoal::ResolvedStyleQuery(..) |
ReflowGoal::OffsetParentQuery(_) | ReflowGoal::NodesFromPoint(..) => false,
ReflowGoal::Full | ReflowGoal::TickAnimations => true,
}
}
}
/// Information needed for a reflow.
pub struct Reflow {
/// The goal of reflow: either to render to the screen or to flush layout info for script.
pub goal: ReflowGoal,
/// A clipping rectangle for the page, an enlarged rectangle containing the viewport.
pub page_clip_rect: Rect<Au>,
}
@ -148,8 +177,8 @@ pub struct ScriptReflow {
pub window_size: WindowSizeData,
/// The channel that we send a notification to.
pub script_join_chan: Sender<ReflowComplete>,
/// The type of query if any to perform during this reflow.
pub query_type: ReflowQueryType,
/// The goal of this reflow.
pub reflow_goal: ReflowGoal,
/// The number of objects in the dom #10110
pub dom_count: u32,
}