Auto merge of #14034 - bholley:more_concrete_types, r=emilio

incremental restyle: Use more concrete types in the style system

We need to hang both snapshots and restyle damage off of ElementData, and so we need them to be concrete to avoid infecting ElementData with the trait hierarchy.

<!-- 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/14034)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-11-07 16:31:10 -06:00 committed by GitHub
commit d8ac5100e8
33 changed files with 157 additions and 140 deletions

View file

@ -9,12 +9,12 @@ use flow::{self, Flow};
use gfx::display_list::OpaqueNode; use gfx::display_list::OpaqueNode;
use ipc_channel::ipc::IpcSender; use ipc_channel::ipc::IpcSender;
use msg::constellation_msg::PipelineId; use msg::constellation_msg::PipelineId;
use script_layout_interface::restyle_damage::RestyleDamage;
use script_traits::{AnimationState, ConstellationControlMsg, LayoutMsg as ConstellationMsg}; use script_traits::{AnimationState, ConstellationControlMsg, LayoutMsg as ConstellationMsg};
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::mpsc::Receiver; use std::sync::mpsc::Receiver;
use style::animation::{Animation, update_style_for_animation}; use style::animation::{Animation, update_style_for_animation};
use style::dom::TRestyleDamage; use style::dom::TRestyleDamage;
use style::selector_impl::RestyleDamage;
use style::timer::Timer; use style::timer::Timer;
/// Processes any new animations that were discovered after style recalculation. /// Processes any new animations that were discovered after style recalculation.

View file

@ -48,8 +48,6 @@ use gfx_traits::print_tree::PrintTree;
use layout_debug; use layout_debug;
use model::{CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo, MaybeAuto}; use model::{CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo, MaybeAuto};
use model::{specified, specified_or_none}; use model::{specified, specified_or_none};
use script_layout_interface::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW};
use script_layout_interface::restyle_damage::REPOSITION;
use sequential; use sequential;
use serde::{Serialize, Serializer}; use serde::{Serialize, Serializer};
use std::cmp::{max, min}; use std::cmp::{max, min};
@ -60,6 +58,7 @@ use style::computed_values::{position, text_align};
use style::context::{SharedStyleContext, StyleContext}; use style::context::{SharedStyleContext, StyleContext};
use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode}; use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode};
use style::properties::ServoComputedValues; use style::properties::ServoComputedValues;
use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPOSITION};
use style::values::computed::{LengthOrPercentageOrNone, LengthOrPercentage}; use style::values::computed::{LengthOrPercentageOrNone, LengthOrPercentage};
use style::values::computed::LengthOrPercentageOrAuto; use style::values::computed::LengthOrPercentageOrAuto;
use util::clamp; use util::clamp;

View file

@ -36,7 +36,6 @@ use list_item::{ListItemFlow, ListStyleTypeContent};
use multicol::{MulticolColumnFlow, MulticolFlow}; use multicol::{MulticolColumnFlow, MulticolFlow};
use parallel; use parallel;
use script_layout_interface::{LayoutElementType, LayoutNodeType, is_image_data}; use script_layout_interface::{LayoutElementType, LayoutNodeType, is_image_data};
use script_layout_interface::restyle_damage::{BUBBLE_ISIZES, RECONSTRUCT_FLOW, RestyleDamage};
use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode}; use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
use std::borrow::ToOwned; use std::borrow::ToOwned;
use std::collections::LinkedList; use std::collections::LinkedList;
@ -49,8 +48,9 @@ use style::computed_values::content::ContentItem;
use style::computed_values::position; use style::computed_values::position;
use style::context::SharedStyleContext; use style::context::SharedStyleContext;
use style::properties::{self, ServoComputedValues}; use style::properties::{self, ServoComputedValues};
use style::selector_impl::{PseudoElement, RestyleDamage};
use style::selector_matching::Stylist; use style::selector_matching::Stylist;
use style::servo_selector_impl::PseudoElement; use style::servo::restyle_damage::{BUBBLE_ISIZES, RECONSTRUCT_FLOW};
use table::TableFlow; use table::TableFlow;
use table_caption::TableCaptionFlow; use table_caption::TableCaptionFlow;
use table_cell::TableCellFlow; use table_cell::TableCellFlow;

View file

@ -35,7 +35,6 @@ use model::{self, MaybeAuto, ToGfxMatrix};
use net_traits::image::base::PixelFormat; use net_traits::image::base::PixelFormat;
use net_traits::image_cache_thread::UsePlaceholder; use net_traits::image_cache_thread::UsePlaceholder;
use range::Range; use range::Range;
use script_layout_interface::restyle_damage::REPAINT;
use std::{cmp, f32}; use std::{cmp, f32};
use std::collections::HashMap; use std::collections::HashMap;
use std::default::Default; use std::default::Default;
@ -51,6 +50,7 @@ use style::computed_values::text_shadow::TextShadow;
use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode}; use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode};
use style::properties::{self, ServoComputedValues}; use style::properties::{self, ServoComputedValues};
use style::properties::style_structs; use style::properties::style_structs;
use style::servo::restyle_damage::REPAINT;
use style::values::RGBA; use style::values::RGBA;
use style::values::computed; use style::values::computed;
use style::values::computed::{Gradient, GradientKind, LengthOrNone, LengthOrPercentage, LengthOrPercentageOrAuto}; use style::values::computed::{Gradient, GradientKind, LengthOrNone, LengthOrPercentage, LengthOrPercentageOrAuto};

View file

@ -21,7 +21,6 @@ use gfx_traits::ScrollRootId;
use layout_debug; use layout_debug;
use model::{Direction, IntrinsicISizes, MaybeAuto, MinMaxConstraint}; use model::{Direction, IntrinsicISizes, MaybeAuto, MinMaxConstraint};
use model::{specified, specified_or_none}; use model::{specified, specified_or_none};
use script_layout_interface::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
use std::cmp::{max, min}; use std::cmp::{max, min};
use std::ops::Range; use std::ops::Range;
use std::sync::Arc; use std::sync::Arc;
@ -30,6 +29,7 @@ use style::computed_values::border_collapse;
use style::context::{SharedStyleContext, StyleContext}; use style::context::{SharedStyleContext, StyleContext};
use style::logical_geometry::LogicalSize; use style::logical_geometry::LogicalSize;
use style::properties::ServoComputedValues; use style::properties::ServoComputedValues;
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto}; use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
use style::values::computed::{LengthOrPercentageOrAutoOrContent, LengthOrPercentageOrNone}; use style::values::computed::{LengthOrPercentageOrAutoOrContent, LengthOrPercentageOrNone};

View file

@ -41,8 +41,6 @@ use inline::InlineFlow;
use model::{CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo}; use model::{CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo};
use multicol::MulticolFlow; use multicol::MulticolFlow;
use parallel::FlowParallelInfo; use parallel::FlowParallelInfo;
use script_layout_interface::restyle_damage::{RECONSTRUCT_FLOW, REFLOW, REFLOW_OUT_OF_FLOW};
use script_layout_interface::restyle_damage::{REPAINT, REPOSITION, RestyleDamage};
use serde::{Serialize, Serializer}; use serde::{Serialize, Serializer};
use std::{fmt, mem, raw}; use std::{fmt, mem, raw};
use std::iter::Zip; use std::iter::Zip;
@ -54,6 +52,8 @@ use style::context::SharedStyleContext;
use style::dom::TRestyleDamage; use style::dom::TRestyleDamage;
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode}; use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
use style::properties::ServoComputedValues; use style::properties::ServoComputedValues;
use style::selector_impl::RestyleDamage;
use style::servo::restyle_damage::{RECONSTRUCT_FLOW, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION};
use style::values::computed::LengthOrPercentageOrAuto; use style::values::computed::LengthOrPercentageOrAuto;
use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, TableFlow}; use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, TableFlow};
use table_caption::TableCaptionFlow; use table_caption::TableCaptionFlow;

View file

@ -30,7 +30,6 @@ use net_traits::image_cache_thread::{ImageOrMetadataAvailable, UsePlaceholder};
use range::*; use range::*;
use script_layout_interface::HTMLCanvasData; use script_layout_interface::HTMLCanvasData;
use script_layout_interface::SVGSVGData; use script_layout_interface::SVGSVGData;
use script_layout_interface::restyle_damage::{RECONSTRUCT_FLOW, RestyleDamage};
use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode}; use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
use serde::{Serialize, Serializer}; use serde::{Serialize, Serializer};
use std::borrow::ToOwned; use std::borrow::ToOwned;
@ -47,6 +46,8 @@ use style::context::SharedStyleContext;
use style::dom::TRestyleDamage; use style::dom::TRestyleDamage;
use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode}; use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode};
use style::properties::ServoComputedValues; use style::properties::ServoComputedValues;
use style::selector_impl::RestyleDamage;
use style::servo::restyle_damage::RECONSTRUCT_FLOW;
use style::str::char_is_whitespace; use style::str::char_is_whitespace;
use style::values::computed::{LengthOrNone, LengthOrPercentage, LengthOrPercentageOrAuto}; use style::values::computed::{LengthOrNone, LengthOrPercentage, LengthOrPercentageOrAuto};
use style::values::computed::LengthOrPercentageOrNone; use style::values::computed::LengthOrPercentageOrNone;

View file

@ -13,7 +13,6 @@ use flow::{self, AFFECTS_COUNTERS, Flow, HAS_COUNTER_AFFECTING_CHILDREN, Immutab
use flow::InorderFlowTraversal; use flow::InorderFlowTraversal;
use fragment::{Fragment, GeneratedContentInfo, SpecificFragmentInfo, UnscannedTextFragmentInfo}; use fragment::{Fragment, GeneratedContentInfo, SpecificFragmentInfo, UnscannedTextFragmentInfo};
use gfx::display_list::OpaqueNode; use gfx::display_list::OpaqueNode;
use script_layout_interface::restyle_damage::{RESOLVE_GENERATED_CONTENT, RestyleDamage};
use script_layout_interface::wrapper_traits::PseudoElementType; use script_layout_interface::wrapper_traits::PseudoElementType;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::collections::{HashMap, LinkedList}; use std::collections::{HashMap, LinkedList};
@ -22,6 +21,8 @@ use style::computed_values::{display, list_style_type};
use style::computed_values::content::ContentItem; use style::computed_values::content::ContentItem;
use style::dom::TRestyleDamage; use style::dom::TRestyleDamage;
use style::properties::ServoComputedValues; use style::properties::ServoComputedValues;
use style::selector_impl::RestyleDamage;
use style::servo::restyle_damage::RESOLVE_GENERATED_CONTENT;
use text::TextRunScanner; use text::TextRunScanner;
// Decimal styles per CSS-COUNTER-STYLES § 6.1: // Decimal styles per CSS-COUNTER-STYLES § 6.1:

View file

@ -3,9 +3,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use flow::{self, AFFECTS_COUNTERS, Flow, HAS_COUNTER_AFFECTING_CHILDREN, IS_ABSOLUTELY_POSITIONED}; use flow::{self, AFFECTS_COUNTERS, Flow, HAS_COUNTER_AFFECTING_CHILDREN, IS_ABSOLUTELY_POSITIONED};
use script_layout_interface::restyle_damage::{RestyleDamage, REFLOW, RECONSTRUCT_FLOW};
use style::computed_values::float; use style::computed_values::float;
use style::dom::TRestyleDamage; use style::dom::TRestyleDamage;
use style::selector_impl::RestyleDamage;
use style::servo::restyle_damage::{REFLOW, RECONSTRUCT_FLOW};
bitflags! { bitflags! {
pub flags SpecialRestyleDamage: u8 { pub flags SpecialRestyleDamage: u8 {

View file

@ -24,8 +24,6 @@ use gfx_traits::print_tree::PrintTree;
use layout_debug; use layout_debug;
use model::IntrinsicISizesContribution; use model::IntrinsicISizesContribution;
use range::{Range, RangeIndex}; use range::{Range, RangeIndex};
use script_layout_interface::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW};
use script_layout_interface::restyle_damage::{REPOSITION, RESOLVE_GENERATED_CONTENT};
use script_layout_interface::wrapper_traits::PseudoElementType; use script_layout_interface::wrapper_traits::PseudoElementType;
use std::{fmt, i32, isize, mem}; use std::{fmt, i32, isize, mem};
use std::cmp::max; use std::cmp::max;
@ -37,6 +35,7 @@ use style::computed_values::{text_overflow, vertical_align, white_space};
use style::context::{SharedStyleContext, StyleContext}; use style::context::{SharedStyleContext, StyleContext};
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode}; use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
use style::properties::ServoComputedValues; use style::properties::ServoComputedValues;
use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPOSITION, RESOLVE_GENERATED_CONTENT};
use text; use text;
use unicode_bidi; use unicode_bidi;

View file

@ -20,12 +20,12 @@ use generated_content;
use gfx::display_list::StackingContext; use gfx::display_list::StackingContext;
use gfx_traits::ScrollRootId; use gfx_traits::ScrollRootId;
use inline::InlineFlow; use inline::InlineFlow;
use script_layout_interface::restyle_damage::RESOLVE_GENERATED_CONTENT;
use std::sync::Arc; use std::sync::Arc;
use style::computed_values::{list_style_type, position}; use style::computed_values::{list_style_type, position};
use style::context::SharedStyleContext; use style::context::SharedStyleContext;
use style::logical_geometry::LogicalSize; use style::logical_geometry::LogicalSize;
use style::properties::ServoComputedValues; use style::properties::ServoComputedValues;
use style::servo::restyle_damage::RESOLVE_GENERATED_CONTENT;
/// A block with the CSS `display` property equal to `list-item`. /// A block with the CSS `display` property equal to `list-item`.
#[derive(Debug)] #[derive(Debug)]

View file

@ -15,8 +15,8 @@ use flow::IS_ABSOLUTELY_POSITIONED;
use fragment::FragmentBorderBoxIterator; use fragment::FragmentBorderBoxIterator;
use generated_content::ResolveGeneratedContent; use generated_content::ResolveGeneratedContent;
use gfx_traits::ScrollRootId; use gfx_traits::ScrollRootId;
use script_layout_interface::restyle_damage::{REFLOW, STORE_OVERFLOW};
use style::context::StyleContext; use style::context::StyleContext;
use style::servo::restyle_damage::{REFLOW, STORE_OVERFLOW};
use traversal::{AssignBSizes, AssignISizes, BubbleISizes, BuildDisplayList}; use traversal::{AssignBSizes, AssignISizes, BubbleISizes, BuildDisplayList};
use util::opts; use util::opts;

View file

@ -21,7 +21,6 @@ use gfx_traits::ScrollRootId;
use gfx_traits::print_tree::PrintTree; use gfx_traits::print_tree::PrintTree;
use layout_debug; use layout_debug;
use model::{IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto}; use model::{IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto};
use script_layout_interface::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
use std::cmp; use std::cmp;
use std::fmt; use std::fmt;
use std::sync::Arc; use std::sync::Arc;
@ -29,6 +28,7 @@ use style::computed_values::{border_collapse, border_spacing, table_layout};
use style::context::SharedStyleContext; use style::context::SharedStyleContext;
use style::logical_geometry::LogicalSize; use style::logical_geometry::LogicalSize;
use style::properties::ServoComputedValues; use style::properties::ServoComputedValues;
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
use style::values::CSSFloat; use style::values::CSSFloat;
use style::values::computed::LengthOrPercentageOrAuto; use style::values::computed::LengthOrPercentageOrAuto;
use table_row::{self, CellIntrinsicInlineSize, CollapsedBorder, CollapsedBorderProvenance}; use table_row::{self, CellIntrinsicInlineSize, CollapsedBorder, CollapsedBorderProvenance};

View file

@ -20,7 +20,6 @@ use gfx_traits::ScrollRootId;
use gfx_traits::print_tree::PrintTree; use gfx_traits::print_tree::PrintTree;
use layout_debug; use layout_debug;
use model::MaybeAuto; use model::MaybeAuto;
use script_layout_interface::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
use serde::{Serialize, Serializer}; use serde::{Serialize, Serializer};
use std::cmp::max; use std::cmp::max;
use std::fmt; use std::fmt;
@ -30,6 +29,7 @@ use style::computed_values::{border_collapse, border_spacing, border_top_style};
use style::context::SharedStyleContext; use style::context::SharedStyleContext;
use style::logical_geometry::{LogicalSize, PhysicalSide, WritingMode}; use style::logical_geometry::{LogicalSize, PhysicalSide, WritingMode};
use style::properties::ServoComputedValues; use style::properties::ServoComputedValues;
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
use style::values::computed::LengthOrPercentageOrAuto; use style::values::computed::LengthOrPercentageOrAuto;
use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, VecExt}; use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, VecExt};
use table_cell::{CollapsedBordersForCell, TableCellFlow}; use table_cell::{CollapsedBordersForCell, TableCellFlow};

View file

@ -10,13 +10,14 @@ use display_list_builder::DisplayListBuildState;
use flow::{self, PreorderFlowTraversal}; use flow::{self, PreorderFlowTraversal};
use flow::{CAN_BE_FRAGMENTED, Flow, ImmutableFlowUtils, PostorderFlowTraversal}; use flow::{CAN_BE_FRAGMENTED, Flow, ImmutableFlowUtils, PostorderFlowTraversal};
use gfx::display_list::OpaqueNode; use gfx::display_list::OpaqueNode;
use script_layout_interface::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, RestyleDamage};
use script_layout_interface::wrapper_traits::{LayoutElement, LayoutNode, ThreadSafeLayoutNode}; use script_layout_interface::wrapper_traits::{LayoutElement, LayoutNode, ThreadSafeLayoutNode};
use std::mem; use std::mem;
use style::atomic_refcell::AtomicRefCell; use style::atomic_refcell::AtomicRefCell;
use style::context::{LocalStyleContext, SharedStyleContext, StyleContext}; use style::context::{LocalStyleContext, SharedStyleContext, StyleContext};
use style::data::ElementData; use style::data::ElementData;
use style::dom::{StylingMode, TElement, TNode}; use style::dom::{StylingMode, TElement, TNode};
use style::selector_impl::RestyleDamage;
use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT};
use style::traversal::{DomTraversalContext, put_thread_local_bloom_filter}; use style::traversal::{DomTraversalContext, put_thread_local_bloom_filter};
use style::traversal::{recalc_style_at, remove_from_bloom_filter}; use style::traversal::{recalc_style_at, remove_from_bloom_filter};
use style::traversal::take_thread_local_bloom_filter; use style::traversal::take_thread_local_bloom_filter;

View file

@ -87,8 +87,6 @@ use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType};
use script::layout_wrapper::{ServoLayoutDocument, ServoLayoutNode}; use script::layout_wrapper::{ServoLayoutDocument, ServoLayoutNode};
use script_layout_interface::message::{Msg, NewLayoutThreadInfo, Reflow, ReflowQueryType, ScriptReflow}; use script_layout_interface::message::{Msg, NewLayoutThreadInfo, Reflow, ReflowQueryType, ScriptReflow};
use script_layout_interface::reporter::CSSErrorReporter; use script_layout_interface::reporter::CSSErrorReporter;
use script_layout_interface::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION};
use script_layout_interface::restyle_damage::STORE_OVERFLOW;
use script_layout_interface::rpc::{LayoutRPC, MarginStyleResponse, NodeOverflowResponse, OffsetParentResponse}; use script_layout_interface::rpc::{LayoutRPC, MarginStyleResponse, NodeOverflowResponse, OffsetParentResponse};
use script_layout_interface::wrapper_traits::LayoutNode; use script_layout_interface::wrapper_traits::LayoutNode;
use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg}; use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg};
@ -111,6 +109,7 @@ use style::media_queries::{Device, MediaType};
use style::parallel::WorkQueueData; use style::parallel::WorkQueueData;
use style::parser::ParserContextExtraData; use style::parser::ParserContextExtraData;
use style::selector_matching::Stylist; use style::selector_matching::Stylist;
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION, STORE_OVERFLOW};
use style::stylesheets::{Origin, Stylesheet, UserAgentStylesheets}; use style::stylesheets::{Origin, Stylesheet, UserAgentStylesheets};
use style::thread_state; use style::thread_state;
use style::timer::Timer; use style::timer::Timer;

View file

@ -94,7 +94,7 @@ use style::attr::{AttrIdentifier, AttrValue, LengthOrPercentageOrAuto};
use style::element_state::*; use style::element_state::*;
use style::media_queries::MediaQueryList; use style::media_queries::MediaQueryList;
use style::properties::PropertyDeclarationBlock; use style::properties::PropertyDeclarationBlock;
use style::selector_impl::{ElementSnapshot, PseudoElement}; use style::selector_impl::{PseudoElement, Snapshot};
use style::values::specified::Length; use style::values::specified::Length;
use time::Duration; use time::Duration;
use url::Origin as UrlOrigin; use url::Origin as UrlOrigin;
@ -346,7 +346,7 @@ no_jsmanaged_fields!(DOMString);
no_jsmanaged_fields!(Mime); no_jsmanaged_fields!(Mime);
no_jsmanaged_fields!(AttrIdentifier); no_jsmanaged_fields!(AttrIdentifier);
no_jsmanaged_fields!(AttrValue); no_jsmanaged_fields!(AttrValue);
no_jsmanaged_fields!(ElementSnapshot); no_jsmanaged_fields!(Snapshot);
no_jsmanaged_fields!(HttpsState); no_jsmanaged_fields!(HttpsState);
no_jsmanaged_fields!(Request); no_jsmanaged_fields!(Request);
no_jsmanaged_fields!(SharedRt); no_jsmanaged_fields!(SharedRt);

View file

@ -125,7 +125,7 @@ use std::sync::Arc;
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
use style::attr::AttrValue; use style::attr::AttrValue;
use style::context::ReflowGoal; use style::context::ReflowGoal;
use style::selector_impl::ElementSnapshot; use style::selector_impl::Snapshot;
use style::str::{split_html_space_chars, str_join}; use style::str::{split_html_space_chars, str_join};
use style::stylesheets::Stylesheet; use style::stylesheets::Stylesheet;
use time; use time;
@ -236,7 +236,7 @@ pub struct Document {
appropriate_template_contents_owner_document: MutNullableHeap<JS<Document>>, appropriate_template_contents_owner_document: MutNullableHeap<JS<Document>>,
/// For each element that has had a state or attribute change since the last restyle, /// For each element that has had a state or attribute change since the last restyle,
/// track the original condition of the element. /// track the original condition of the element.
modified_elements: DOMRefCell<HashMap<JS<Element>, ElementSnapshot>>, modified_elements: DOMRefCell<HashMap<JS<Element>, Snapshot>>,
/// This flag will be true if layout suppressed a reflow attempt that was /// This flag will be true if layout suppressed a reflow attempt that was
/// needed in order for the page to be painted. /// needed in order for the page to be painted.
needs_paint: Cell<bool>, needs_paint: Cell<bool>,
@ -1708,7 +1708,7 @@ pub enum DocumentSource {
#[allow(unsafe_code)] #[allow(unsafe_code)]
pub trait LayoutDocumentHelpers { pub trait LayoutDocumentHelpers {
unsafe fn is_html_document_for_layout(&self) -> bool; unsafe fn is_html_document_for_layout(&self) -> bool;
unsafe fn drain_modified_elements(&self) -> Vec<(LayoutJS<Element>, ElementSnapshot)>; unsafe fn drain_modified_elements(&self) -> Vec<(LayoutJS<Element>, Snapshot)>;
unsafe fn needs_paint_from_layout(&self); unsafe fn needs_paint_from_layout(&self);
unsafe fn will_paint(&self); unsafe fn will_paint(&self);
} }
@ -1722,7 +1722,7 @@ impl LayoutDocumentHelpers for LayoutJS<Document> {
#[inline] #[inline]
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
unsafe fn drain_modified_elements(&self) -> Vec<(LayoutJS<Element>, ElementSnapshot)> { unsafe fn drain_modified_elements(&self) -> Vec<(LayoutJS<Element>, Snapshot)> {
let mut elements = (*self.unsafe_get()).modified_elements.borrow_mut_for_layout(); let mut elements = (*self.unsafe_get()).modified_elements.borrow_mut_for_layout();
let result = elements.drain().map(|(k, v)| (k.to_layout(), v)).collect(); let result = elements.drain().map(|(k, v)| (k.to_layout(), v)).collect();
result result
@ -1970,7 +1970,7 @@ impl Document {
let mut map = self.modified_elements.borrow_mut(); let mut map = self.modified_elements.borrow_mut();
let snapshot = map.entry(JS::from_ref(el)) let snapshot = map.entry(JS::from_ref(el))
.or_insert_with(|| { .or_insert_with(|| {
ElementSnapshot::new(el.html_element_in_html_document()) Snapshot::new(el.html_element_in_html_document())
}); });
if snapshot.state.is_none() { if snapshot.state.is_none() {
snapshot.state = Some(el.state()); snapshot.state = Some(el.state());
@ -1981,7 +1981,7 @@ impl Document {
let mut map = self.modified_elements.borrow_mut(); let mut map = self.modified_elements.borrow_mut();
let mut snapshot = map.entry(JS::from_ref(el)) let mut snapshot = map.entry(JS::from_ref(el))
.or_insert_with(|| { .or_insert_with(|| {
ElementSnapshot::new(el.html_element_in_html_document()) Snapshot::new(el.html_element_in_html_document())
}); });
if snapshot.attrs.is_none() { if snapshot.attrs.is_none() {
let attrs = el.attrs() let attrs = el.attrs()

View file

@ -46,7 +46,6 @@ use parking_lot::RwLock;
use range::Range; use range::Range;
use script_layout_interface::{HTMLCanvasData, LayoutNodeType, SVGSVGData, TrustedNodeAddress}; use script_layout_interface::{HTMLCanvasData, LayoutNodeType, SVGSVGData, TrustedNodeAddress};
use script_layout_interface::{OpaqueStyleAndLayoutData, PartialPersistentLayoutData}; use script_layout_interface::{OpaqueStyleAndLayoutData, PartialPersistentLayoutData};
use script_layout_interface::restyle_damage::RestyleDamage;
use script_layout_interface::wrapper_traits::{DangerousThreadSafeLayoutNode, GetLayoutData, LayoutElement, LayoutNode}; use script_layout_interface::wrapper_traits::{DangerousThreadSafeLayoutNode, GetLayoutData, LayoutElement, LayoutNode};
use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode}; use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
use selectors::matching::ElementFlags; use selectors::matching::ElementFlags;
@ -66,7 +65,7 @@ use style::dom::{LayoutIterator, NodeInfo, OpaqueNode, PresentationalHintsSynthe
use style::dom::{TRestyleDamage, UnsafeNode}; use style::dom::{TRestyleDamage, UnsafeNode};
use style::element_state::*; use style::element_state::*;
use style::properties::{ComputedValues, PropertyDeclarationBlock}; use style::properties::{ComputedValues, PropertyDeclarationBlock};
use style::selector_impl::{ElementSnapshot, NonTSPseudoClass, PseudoElement, ServoSelectorImpl}; use style::selector_impl::{NonTSPseudoClass, PseudoElement, RestyleDamage, ServoSelectorImpl, Snapshot};
use style::selector_matching::ApplicableDeclarationBlock; use style::selector_matching::ApplicableDeclarationBlock;
use style::sink::Push; use style::sink::Push;
use style::str::is_whitespace; use style::str::is_whitespace;
@ -382,7 +381,7 @@ impl<'ld> TDocument for ServoLayoutDocument<'ld> {
self.as_node().children().find(ServoLayoutNode::is_element) self.as_node().children().find(ServoLayoutNode::is_element)
} }
fn drain_modified_elements(&self) -> Vec<(ServoLayoutElement<'ld>, ElementSnapshot)> { fn drain_modified_elements(&self) -> Vec<(ServoLayoutElement<'ld>, Snapshot)> {
let elements = unsafe { self.document.drain_modified_elements() }; let elements = unsafe { self.document.drain_modified_elements() };
elements.into_iter().map(|(el, snapshot)| (ServoLayoutElement::from_layout_js(el), snapshot)).collect() elements.into_iter().map(|(el, snapshot)| (ServoLayoutElement::from_layout_js(el), snapshot)).collect()
} }
@ -435,7 +434,6 @@ impl<'le> PresentationalHintsSynthetizer for ServoLayoutElement<'le> {
impl<'le> TElement for ServoLayoutElement<'le> { impl<'le> TElement for ServoLayoutElement<'le> {
type ConcreteNode = ServoLayoutNode<'le>; type ConcreteNode = ServoLayoutNode<'le>;
type ConcreteDocument = ServoLayoutDocument<'le>; type ConcreteDocument = ServoLayoutDocument<'le>;
type ConcreteRestyleDamage = RestyleDamage;
fn as_node(&self) -> ServoLayoutNode<'le> { fn as_node(&self) -> ServoLayoutNode<'le> {
ServoLayoutNode::from_layout_js(self.element.upcast()) ServoLayoutNode::from_layout_js(self.element.upcast())

View file

@ -41,7 +41,6 @@ extern crate url;
pub mod message; pub mod message;
pub mod reporter; pub mod reporter;
pub mod restyle_damage;
pub mod rpc; pub mod rpc;
pub mod wrapper_traits; pub mod wrapper_traits;
@ -49,10 +48,10 @@ use canvas_traits::CanvasMsg;
use core::nonzero::NonZero; use core::nonzero::NonZero;
use ipc_channel::ipc::IpcSender; use ipc_channel::ipc::IpcSender;
use libc::c_void; use libc::c_void;
use restyle_damage::RestyleDamage;
use std::sync::atomic::AtomicIsize; use std::sync::atomic::AtomicIsize;
use style::atomic_refcell::AtomicRefCell; use style::atomic_refcell::AtomicRefCell;
use style::data::ElementData; use style::data::ElementData;
use style::selector_impl::RestyleDamage;
pub struct PartialPersistentLayoutData { pub struct PartialPersistentLayoutData {
/// Data that the style system associates with a node. When the /// Data that the style system associates with a node. When the

View file

@ -12,7 +12,6 @@ use gfx_traits::ByteIndex;
use html5ever_atoms::{Namespace, LocalName}; use html5ever_atoms::{Namespace, LocalName};
use msg::constellation_msg::PipelineId; use msg::constellation_msg::PipelineId;
use range::Range; use range::Range;
use restyle_damage::RestyleDamage;
use std::fmt::Debug; use std::fmt::Debug;
use std::sync::Arc; use std::sync::Arc;
use style::atomic_refcell::AtomicRefCell; use style::atomic_refcell::AtomicRefCell;
@ -22,7 +21,7 @@ use style::data::ElementData;
use style::dom::{LayoutIterator, NodeInfo, PresentationalHintsSynthetizer, TElement, TNode}; use style::dom::{LayoutIterator, NodeInfo, PresentationalHintsSynthetizer, TElement, TNode};
use style::dom::OpaqueNode; use style::dom::OpaqueNode;
use style::properties::ServoComputedValues; use style::properties::ServoComputedValues;
use style::selector_impl::{PseudoElement, PseudoElementCascadeType, ServoSelectorImpl}; use style::selector_impl::{PseudoElement, PseudoElementCascadeType, RestyleDamage, ServoSelectorImpl};
use url::Url; use url::Url;
#[derive(Copy, PartialEq, Clone, Debug)] #[derive(Copy, PartialEq, Clone, Debug)]

View file

@ -14,7 +14,7 @@ use parking_lot::RwLock;
use properties::{ComputedValues, PropertyDeclarationBlock}; use properties::{ComputedValues, PropertyDeclarationBlock};
use properties::longhands::display::computed_value as display; use properties::longhands::display::computed_value as display;
use restyle_hints::{RESTYLE_DESCENDANTS, RESTYLE_LATER_SIBLINGS, RESTYLE_SELF, RestyleHint}; use restyle_hints::{RESTYLE_DESCENDANTS, RESTYLE_LATER_SIBLINGS, RESTYLE_SELF, RestyleHint};
use selector_impl::{ElementExt, PseudoElement}; use selector_impl::{ElementExt, PseudoElement, RestyleDamage, Snapshot};
use selector_matching::ApplicableDeclarationBlock; use selector_matching::ApplicableDeclarationBlock;
use sink::Push; use sink::Push;
use std::fmt::Debug; use std::fmt::Debug;
@ -159,8 +159,7 @@ pub trait TDocument : Sized + Copy + Clone {
fn root_node(&self) -> Option<Self::ConcreteNode>; fn root_node(&self) -> Option<Self::ConcreteNode>;
fn drain_modified_elements(&self) -> Vec<(Self::ConcreteElement, fn drain_modified_elements(&self) -> Vec<(Self::ConcreteElement, Snapshot)>;
<Self::ConcreteElement as ElementExt>::Snapshot)>;
fn needs_paint_from_layout(&self); fn needs_paint_from_layout(&self);
fn will_paint(&self); fn will_paint(&self);
@ -174,7 +173,6 @@ pub trait PresentationalHintsSynthetizer {
pub trait TElement : PartialEq + Debug + Sized + Copy + Clone + ElementExt + PresentationalHintsSynthetizer { pub trait TElement : PartialEq + Debug + Sized + Copy + Clone + ElementExt + PresentationalHintsSynthetizer {
type ConcreteNode: TNode<ConcreteElement = Self, ConcreteDocument = Self::ConcreteDocument>; type ConcreteNode: TNode<ConcreteElement = Self, ConcreteDocument = Self::ConcreteDocument>;
type ConcreteDocument: TDocument<ConcreteNode = Self::ConcreteNode, ConcreteElement = Self>; type ConcreteDocument: TDocument<ConcreteNode = Self::ConcreteNode, ConcreteElement = Self>;
type ConcreteRestyleDamage: TRestyleDamage;
fn as_node(&self) -> Self::ConcreteNode; fn as_node(&self) -> Self::ConcreteNode;
@ -186,7 +184,7 @@ pub trait TElement : PartialEq + Debug + Sized + Copy + Clone + ElementExt + Pre
fn attr_equals(&self, namespace: &Namespace, attr: &LocalName, value: &Atom) -> bool; fn attr_equals(&self, namespace: &Namespace, attr: &LocalName, value: &Atom) -> bool;
/// Set the restyle damage field. /// Set the restyle damage field.
fn set_restyle_damage(self, damage: Self::ConcreteRestyleDamage); fn set_restyle_damage(self, damage: RestyleDamage);
/// XXX: It's a bit unfortunate we need to pass the current computed values /// XXX: It's a bit unfortunate we need to pass the current computed values
/// as an argument here, but otherwise Servo would crash due to double /// as an argument here, but otherwise Servo would crash due to double
@ -194,7 +192,7 @@ pub trait TElement : PartialEq + Debug + Sized + Copy + Clone + ElementExt + Pre
fn existing_style_for_restyle_damage<'a>(&'a self, fn existing_style_for_restyle_damage<'a>(&'a self,
current_computed_values: Option<&'a Arc<ComputedValues>>, current_computed_values: Option<&'a Arc<ComputedValues>>,
pseudo: Option<&PseudoElement>) pseudo: Option<&PseudoElement>)
-> Option<&'a <Self::ConcreteRestyleDamage as TRestyleDamage>::PreExistingComputedValues>; -> Option<&'a <RestyleDamage as TRestyleDamage>::PreExistingComputedValues>;
/// The concept of a dirty bit doesn't exist in our new restyle algorithm. /// The concept of a dirty bit doesn't exist in our new restyle algorithm.
/// Instead, we associate restyle and change hints with nodes. However, we /// Instead, we associate restyle and change hints with nodes. However, we

View file

@ -5,6 +5,7 @@
pub mod context; pub mod context;
pub mod data; pub mod data;
pub mod restyle_damage;
pub mod snapshot; pub mod snapshot;
pub mod snapshot_helpers; pub mod snapshot_helpers;
pub mod traversal; pub mod traversal;

View file

@ -0,0 +1,53 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::TRestyleDamage;
use gecko_bindings::bindings;
use gecko_bindings::structs::{nsChangeHint, nsStyleContext};
use gecko_bindings::sugar::ownership::FFIArcHelpers;
use properties::ComputedValues;
use std::ops::BitOr;
use std::sync::Arc;
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct GeckoRestyleDamage(nsChangeHint);
impl GeckoRestyleDamage {
pub fn as_change_hint(&self) -> nsChangeHint {
self.0
}
}
impl TRestyleDamage for GeckoRestyleDamage {
type PreExistingComputedValues = nsStyleContext;
fn empty() -> Self {
use std::mem;
GeckoRestyleDamage(unsafe { mem::transmute(0u32) })
}
fn compute(source: &nsStyleContext,
new_style: &Arc<ComputedValues>) -> Self {
let context = source as *const nsStyleContext as *mut nsStyleContext;
let hint = unsafe {
bindings::Gecko_CalcStyleDifference(context,
new_style.as_borrowed_opt().unwrap())
};
GeckoRestyleDamage(hint)
}
fn rebuild_and_reflow() -> Self {
GeckoRestyleDamage(nsChangeHint::nsChangeHint_ReconstructFrame)
}
}
impl BitOr for GeckoRestyleDamage {
type Output = Self;
fn bitor(self, other: Self) -> Self {
use std::mem;
GeckoRestyleDamage(unsafe { mem::transmute(self.0 as u32 | other.0 as u32) })
}
}

View file

@ -7,15 +7,15 @@
use atomic_refcell::{AtomicRef, AtomicRefCell}; use atomic_refcell::{AtomicRef, AtomicRefCell};
use data::ElementData; use data::ElementData;
use dom::{LayoutIterator, NodeInfo, TDocument, TElement, TNode, TRestyleDamage, UnsafeNode}; use dom::{LayoutIterator, NodeInfo, TDocument, TElement, TNode, UnsafeNode};
use dom::{OpaqueNode, PresentationalHintsSynthetizer}; use dom::{OpaqueNode, PresentationalHintsSynthetizer};
use element_state::ElementState; use element_state::ElementState;
use error_reporting::StdoutErrorReporter; use error_reporting::StdoutErrorReporter;
use gecko::restyle_damage::GeckoRestyleDamage;
use gecko::selector_impl::{GeckoSelectorImpl, NonTSPseudoClass, PseudoElement}; use gecko::selector_impl::{GeckoSelectorImpl, NonTSPseudoClass, PseudoElement};
use gecko::snapshot::GeckoElementSnapshot; use gecko::snapshot::GeckoElementSnapshot;
use gecko::snapshot_helpers; use gecko::snapshot_helpers;
use gecko_bindings::bindings; use gecko_bindings::bindings;
use gecko_bindings::bindings::{Gecko_CalcStyleDifference, Gecko_StoreStyleDifference};
use gecko_bindings::bindings::{Gecko_DropStyleChildrenIterator, Gecko_MaybeCreateStyleChildrenIterator}; use gecko_bindings::bindings::{Gecko_DropStyleChildrenIterator, Gecko_MaybeCreateStyleChildrenIterator};
use gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetDocumentElement}; use gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetDocumentElement};
use gecko_bindings::bindings::{Gecko_GetLastChild, Gecko_GetNextStyleChild}; use gecko_bindings::bindings::{Gecko_GetLastChild, Gecko_GetNextStyleChild};
@ -26,10 +26,10 @@ use gecko_bindings::bindings::{RawGeckoDocument, RawGeckoElement, RawGeckoNode};
use gecko_bindings::bindings::Gecko_ClassOrClassList; use gecko_bindings::bindings::Gecko_ClassOrClassList;
use gecko_bindings::bindings::Gecko_GetStyleContext; use gecko_bindings::bindings::Gecko_GetStyleContext;
use gecko_bindings::bindings::Gecko_SetNodeFlags; use gecko_bindings::bindings::Gecko_SetNodeFlags;
use gecko_bindings::bindings::Gecko_StoreStyleDifference;
use gecko_bindings::structs; use gecko_bindings::structs;
use gecko_bindings::structs::{NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO, NODE_IS_DIRTY_FOR_SERVO}; use gecko_bindings::structs::{NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO, NODE_IS_DIRTY_FOR_SERVO};
use gecko_bindings::structs::{nsChangeHint, nsIAtom, nsIContent, nsStyleContext}; use gecko_bindings::structs::{nsIAtom, nsIContent, nsStyleContext};
use gecko_bindings::sugar::ownership::FFIArcHelpers;
use libc::uintptr_t; use libc::uintptr_t;
use parking_lot::RwLock; use parking_lot::RwLock;
use parser::ParserContextExtraData; use parser::ParserContextExtraData;
@ -41,7 +41,6 @@ use selectors::Element;
use selectors::parser::{AttrSelector, NamespaceConstraint}; use selectors::parser::{AttrSelector, NamespaceConstraint};
use sink::Push; use sink::Push;
use std::fmt; use std::fmt;
use std::ops::BitOr;
use std::ptr; use std::ptr;
use std::sync::Arc; use std::sync::Arc;
use string_cache::{Atom, Namespace, WeakAtom, WeakNamespace}; use string_cache::{Atom, Namespace, WeakAtom, WeakNamespace};
@ -66,39 +65,6 @@ impl<'ln> GeckoNode<'ln> {
} }
} }
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct GeckoRestyleDamage(nsChangeHint);
impl TRestyleDamage for GeckoRestyleDamage {
type PreExistingComputedValues = nsStyleContext;
fn empty() -> Self {
use std::mem;
GeckoRestyleDamage(unsafe { mem::transmute(0u32) })
}
fn compute(source: &nsStyleContext,
new_style: &Arc<ComputedValues>) -> Self {
let context = source as *const nsStyleContext as *mut nsStyleContext;
let hint = unsafe { Gecko_CalcStyleDifference(context, new_style.as_borrowed_opt().unwrap()) };
GeckoRestyleDamage(hint)
}
fn rebuild_and_reflow() -> Self {
GeckoRestyleDamage(nsChangeHint::nsChangeHint_ReconstructFrame)
}
}
impl BitOr for GeckoRestyleDamage {
type Output = Self;
fn bitor(self, other: Self) -> Self {
use std::mem;
GeckoRestyleDamage(unsafe { mem::transmute(self.0 as u32 | other.0 as u32) })
}
}
impl<'ln> NodeInfo for GeckoNode<'ln> { impl<'ln> NodeInfo for GeckoNode<'ln> {
fn is_element(&self) -> bool { fn is_element(&self) -> bool {
use gecko_bindings::structs::nsINode_BooleanFlag; use gecko_bindings::structs::nsINode_BooleanFlag;
@ -358,7 +324,6 @@ lazy_static! {
impl<'le> TElement for GeckoElement<'le> { impl<'le> TElement for GeckoElement<'le> {
type ConcreteNode = GeckoNode<'le>; type ConcreteNode = GeckoNode<'le>;
type ConcreteDocument = GeckoDocument<'le>; type ConcreteDocument = GeckoDocument<'le>;
type ConcreteRestyleDamage = GeckoRestyleDamage;
fn as_node(&self) -> Self::ConcreteNode { fn as_node(&self) -> Self::ConcreteNode {
unsafe { GeckoNode(&*(self.0 as *const _ as *const RawGeckoNode)) } unsafe { GeckoNode(&*(self.0 as *const _ as *const RawGeckoNode)) }
@ -400,7 +365,7 @@ impl<'le> TElement for GeckoElement<'le> {
// drive the post-traversal. This will go away soon. // drive the post-traversal. This will go away soon.
unsafe { self.set_flags(NODE_IS_DIRTY_FOR_SERVO as u32) } unsafe { self.set_flags(NODE_IS_DIRTY_FOR_SERVO as u32) }
unsafe { Gecko_StoreStyleDifference(self.as_node().0, damage.0) } unsafe { Gecko_StoreStyleDifference(self.as_node().0, damage.as_change_hint()) }
} }
fn existing_style_for_restyle_damage<'a>(&'a self, fn existing_style_for_restyle_damage<'a>(&'a self,
@ -691,8 +656,6 @@ impl<'le> ::selectors::MatchAttr for GeckoElement<'le> {
} }
impl<'le> ElementExt for GeckoElement<'le> { impl<'le> ElementExt for GeckoElement<'le> {
type Snapshot = GeckoElementSnapshot;
#[inline] #[inline]
fn is_link(&self) -> bool { fn is_link(&self) -> bool {
self.match_non_ts_pseudo_class(NonTSPseudoClass::AnyLink) self.match_non_ts_pseudo_class(NonTSPseudoClass::AnyLink)

View file

@ -117,8 +117,8 @@ pub mod restyle_hints;
pub mod rule_tree; pub mod rule_tree;
pub mod selector_impl; pub mod selector_impl;
pub mod selector_matching; pub mod selector_matching;
#[cfg(feature = "servo")] #[allow(unsafe_code)] pub mod servo;
pub mod sequential; pub mod sequential;
#[cfg(feature = "servo")] pub mod servo_selector_impl;
pub mod sink; pub mod sink;
pub mod str; pub mod str;
pub mod stylesheets; pub mod stylesheets;

View file

@ -17,7 +17,7 @@ use dom::{TElement, TNode, TRestyleDamage, UnsafeNode};
use properties::{CascadeFlags, ComputedValues, SHAREABLE, cascade}; use properties::{CascadeFlags, ComputedValues, SHAREABLE, cascade};
use properties::longhands::display::computed_value as display; use properties::longhands::display::computed_value as display;
use rule_tree::StrongRuleNode; use rule_tree::StrongRuleNode;
use selector_impl::{TheSelectorImpl, PseudoElement}; use selector_impl::{PseudoElement, RestyleDamage, TheSelectorImpl};
use selector_matching::{ApplicableDeclarationBlock, Stylist}; use selector_matching::{ApplicableDeclarationBlock, Stylist};
use selectors::MatchAttr; use selectors::MatchAttr;
use selectors::bloom::BloomFilter; use selectors::bloom::BloomFilter;
@ -373,14 +373,14 @@ impl StyleSharingCandidateCache {
} }
/// The results of attempting to share a style. /// The results of attempting to share a style.
pub enum StyleSharingResult<ConcreteRestyleDamage: TRestyleDamage> { pub enum StyleSharingResult {
/// We didn't find anybody to share the style with. /// We didn't find anybody to share the style with.
CannotShare, CannotShare,
/// The node's style can be shared. The integer specifies the index in the /// The node's style can be shared. The integer specifies the index in the
/// LRU cache that was hit and the damage that was done, and the restyle /// LRU cache that was hit and the damage that was done, and the restyle
/// result the original result of the candidate's styling, that is, whether /// result the original result of the candidate's styling, that is, whether
/// it should stop the traversal or not. /// it should stop the traversal or not.
StyleWasShared(usize, ConcreteRestyleDamage), StyleWasShared(usize, RestyleDamage),
} }
// Callers need to pass several boolean flags to cascade_node_pseudo_element. // Callers need to pass several boolean flags to cascade_node_pseudo_element.
@ -565,7 +565,7 @@ pub trait MatchMethods : TElement {
&mut StyleSharingCandidateCache, &mut StyleSharingCandidateCache,
shared_context: &SharedStyleContext, shared_context: &SharedStyleContext,
data: &mut AtomicRefMut<ElementData>) data: &mut AtomicRefMut<ElementData>)
-> StyleSharingResult<Self::ConcreteRestyleDamage> { -> StyleSharingResult {
if opts::get().disable_share_style_cache { if opts::get().disable_share_style_cache {
return StyleSharingResult::CannotShare return StyleSharingResult::CannotShare
} }
@ -591,12 +591,8 @@ pub trait MatchMethods : TElement {
// replaced content, or similar stuff! // replaced content, or similar stuff!
let damage = let damage =
match self.existing_style_for_restyle_damage(data.previous_styles().map(|x| &x.primary), None) { match self.existing_style_for_restyle_damage(data.previous_styles().map(|x| &x.primary), None) {
Some(ref source) => { Some(ref source) => RestyleDamage::compute(source, &shared_style),
Self::ConcreteRestyleDamage::compute(source, &shared_style) None => RestyleDamage::rebuild_and_reflow(),
}
None => {
Self::ConcreteRestyleDamage::rebuild_and_reflow()
}
}; };
data.finish_styling(ElementStyles::new(shared_style, rule_node)); data.finish_styling(ElementStyles::new(shared_style, rule_node));
@ -678,13 +674,10 @@ pub trait MatchMethods : TElement {
old_style: Option<&Arc<ComputedValues>>, old_style: Option<&Arc<ComputedValues>>,
new_style: &Arc<ComputedValues>, new_style: &Arc<ComputedValues>,
pseudo: Option<&PseudoElement>) pseudo: Option<&PseudoElement>)
-> Self::ConcreteRestyleDamage -> RestyleDamage
{ {
match self.existing_style_for_restyle_damage(old_style, pseudo) { match self.existing_style_for_restyle_damage(old_style, pseudo) {
Some(ref source) => { Some(ref source) => RestyleDamage::compute(source, new_style),
Self::ConcreteRestyleDamage::compute(source,
new_style)
}
None => { None => {
// If there's no style source, two things can happen: // If there's no style source, two things can happen:
// //
@ -710,7 +703,7 @@ pub trait MatchMethods : TElement {
// stick without the assertions. // stick without the assertions.
debug_assert!(pseudo.is_none() || debug_assert!(pseudo.is_none() ||
new_style.get_box().clone_display() != display::T::none); new_style.get_box().clone_display() != display::T::none);
Self::ConcreteRestyleDamage::rebuild_and_reflow() RestyleDamage::rebuild_and_reflow()
} }
} }
} }
@ -783,7 +776,7 @@ pub trait MatchMethods : TElement {
new_pseudos: &mut PseudoStyles, new_pseudos: &mut PseudoStyles,
context: &Ctx, context: &Ctx,
applicable_declarations: &mut ApplicableDeclarations) applicable_declarations: &mut ApplicableDeclarations)
-> Self::ConcreteRestyleDamage -> RestyleDamage
where Ctx: StyleContext<'a> where Ctx: StyleContext<'a>
{ {
// Here we optimise the case of the style changing but both the // Here we optimise the case of the style changing but both the
@ -800,9 +793,9 @@ pub trait MatchMethods : TElement {
// otherwise, we don't do anything. // otherwise, we don't do anything.
let damage = match old_display { let damage = match old_display {
Some(display) if display == this_display => { Some(display) if display == this_display => {
Self::ConcreteRestyleDamage::empty() RestyleDamage::empty()
} }
_ => Self::ConcreteRestyleDamage::rebuild_and_reflow() _ => RestyleDamage::rebuild_and_reflow()
}; };
debug!("Short-circuiting traversal: {:?} {:?} {:?}", debug!("Short-circuiting traversal: {:?} {:?} {:?}",
@ -820,8 +813,7 @@ pub trait MatchMethods : TElement {
return damage; return damage;
} }
let rebuild_and_reflow = let rebuild_and_reflow = RestyleDamage::rebuild_and_reflow();
Self::ConcreteRestyleDamage::rebuild_and_reflow();
debug_assert!(new_pseudos.is_empty()); debug_assert!(new_pseudos.is_empty());
<Self as MatchAttr>::Impl::each_eagerly_cascaded_pseudo_element(|pseudo| { <Self as MatchAttr>::Impl::each_eagerly_cascaded_pseudo_element(|pseudo| {

View file

@ -8,7 +8,7 @@ use Atom;
use element_state::*; use element_state::*;
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
use heapsize::HeapSizeOf; use heapsize::HeapSizeOf;
use selector_impl::{AttrValue, ElementExt, NonTSPseudoClass, TheSelectorImpl}; use selector_impl::{AttrValue, ElementExt, NonTSPseudoClass, Snapshot, TheSelectorImpl};
use selectors::{Element, MatchAttr}; use selectors::{Element, MatchAttr};
use selectors::matching::{MatchingReason, StyleRelations}; use selectors::matching::{MatchingReason, StyleRelations};
use selectors::matching::matches_complex_selector; use selectors::matching::matches_complex_selector;
@ -85,7 +85,7 @@ struct ElementWrapper<'a, E>
where E: ElementExt where E: ElementExt
{ {
element: E, element: E,
snapshot: Option<&'a E::Snapshot>, snapshot: Option<&'a Snapshot>,
} }
impl<'a, E> ElementWrapper<'a, E> impl<'a, E> ElementWrapper<'a, E>
@ -95,7 +95,7 @@ impl<'a, E> ElementWrapper<'a, E>
ElementWrapper { element: el, snapshot: None } ElementWrapper { element: el, snapshot: None }
} }
pub fn new_with_snapshot(el: E, snapshot: &'a E::Snapshot) -> ElementWrapper<'a, E> { pub fn new_with_snapshot(el: E, snapshot: &'a Snapshot) -> ElementWrapper<'a, E> {
ElementWrapper { element: el, snapshot: Some(snapshot) } ElementWrapper { element: el, snapshot: Some(snapshot) }
} }
} }
@ -424,7 +424,7 @@ impl DependencySet {
} }
pub fn compute_hint<E>(&self, el: &E, pub fn compute_hint<E>(&self, el: &E,
snapshot: &E::Snapshot, snapshot: &Snapshot,
current_state: ElementState) current_state: ElementState)
-> RestyleHint -> RestyleHint
where E: ElementExt + Clone where E: ElementExt + Clone

View file

@ -5,23 +5,34 @@
//! The pseudo-classes and pseudo-elements supported by the style system. //! The pseudo-classes and pseudo-elements supported by the style system.
use matching::{common_style_affecting_attributes, CommonStyleAffectingAttributeMode}; use matching::{common_style_affecting_attributes, CommonStyleAffectingAttributeMode};
use restyle_hints;
use selectors::Element; use selectors::Element;
use selectors::parser::{AttrSelector, SelectorImpl}; use selectors::parser::{AttrSelector, SelectorImpl};
pub type AttrValue = <TheSelectorImpl as SelectorImpl>::AttrValue; pub type AttrValue = <TheSelectorImpl as SelectorImpl>::AttrValue;
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
pub use servo_selector_impl::*; pub use servo::selector_impl::*;
#[cfg(feature = "servo")]
pub use servo_selector_impl::{ServoSelectorImpl as TheSelectorImpl, ServoElementSnapshot as ElementSnapshot};
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub use gecko::selector_impl::*; pub use gecko::selector_impl::*;
#[cfg(feature = "servo")]
pub use servo::selector_impl::ServoSelectorImpl as TheSelectorImpl;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub use gecko::selector_impl::{GeckoSelectorImpl as TheSelectorImpl}; pub use gecko::selector_impl::GeckoSelectorImpl as TheSelectorImpl;
#[cfg(feature = "servo")]
pub use servo::selector_impl::ServoElementSnapshot as Snapshot;
#[cfg(feature = "gecko")]
pub use gecko::snapshot::GeckoElementSnapshot as Snapshot;
#[cfg(feature = "servo")]
pub use servo::restyle_damage::ServoRestyleDamage as RestyleDamage;
#[cfg(feature = "gecko")]
pub use gecko::restyle_damage::GeckoRestyleDamage as RestyleDamage;
/// This function determines if a pseudo-element is eagerly cascaded or not. /// This function determines if a pseudo-element is eagerly cascaded or not.
/// ///
@ -71,8 +82,6 @@ impl PseudoElementCascadeType {
} }
pub trait ElementExt: Element<Impl=TheSelectorImpl> { pub trait ElementExt: Element<Impl=TheSelectorImpl> {
type Snapshot: restyle_hints::ElementSnapshot + 'static;
fn is_link(&self) -> bool; fn is_link(&self) -> bool;
} }

View file

@ -16,7 +16,7 @@ use properties::{PropertyDeclaration, PropertyDeclarationBlock};
use quickersort::sort_by; use quickersort::sort_by;
use restyle_hints::{RestyleHint, DependencySet}; use restyle_hints::{RestyleHint, DependencySet};
use rule_tree::{RuleTree, StrongRuleNode, StyleSource}; use rule_tree::{RuleTree, StrongRuleNode, StyleSource};
use selector_impl::{ElementExt, TheSelectorImpl, PseudoElement}; use selector_impl::{ElementExt, TheSelectorImpl, PseudoElement, Snapshot};
use selectors::Element; use selectors::Element;
use selectors::bloom::BloomFilter; use selectors::bloom::BloomFilter;
use selectors::matching::{AFFECTED_BY_STYLE_ATTRIBUTE, AFFECTED_BY_PRESENTATIONAL_HINTS}; use selectors::matching::{AFFECTED_BY_STYLE_ATTRIBUTE, AFFECTED_BY_PRESENTATIONAL_HINTS};
@ -611,7 +611,7 @@ impl Stylist {
} }
pub fn compute_restyle_hint<E>(&self, element: &E, pub fn compute_restyle_hint<E>(&self, element: &E,
snapshot: &E::Snapshot, snapshot: &Snapshot,
// NB: We need to pass current_state as an argument because // NB: We need to pass current_state as an argument because
// selectors::Element doesn't provide access to ElementState // selectors::Element doesn't provide access to ElementState
// directly, and computing it from the ElementState would be // directly, and computing it from the ElementState would be

View file

@ -0,0 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
pub mod restyle_damage;
pub mod selector_impl;

View file

@ -2,15 +2,15 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use computed_values::display;
use dom::TRestyleDamage;
use properties::ServoComputedValues;
use std::fmt; use std::fmt;
use std::sync::Arc; use std::sync::Arc;
use style::computed_values::display;
use style::dom::TRestyleDamage;
use style::properties::ServoComputedValues;
bitflags! { bitflags! {
#[doc = "Individual layout actions that may be necessary after restyling."] #[doc = "Individual layout actions that may be necessary after restyling."]
pub flags RestyleDamage: u8 { pub flags ServoRestyleDamage: u8 {
#[doc = "Repaint the node itself."] #[doc = "Repaint the node itself."]
#[doc = "Currently unused; need to decide how this propagates."] #[doc = "Currently unused; need to decide how this propagates."]
const REPAINT = 0x01, const REPAINT = 0x01,
@ -48,35 +48,35 @@ bitflags! {
} }
} }
impl TRestyleDamage for RestyleDamage { impl TRestyleDamage for ServoRestyleDamage {
/// For Servo the style source is always the computed values. /// For Servo the style source is always the computed values.
type PreExistingComputedValues = Arc<ServoComputedValues>; type PreExistingComputedValues = Arc<ServoComputedValues>;
fn empty() -> Self { fn empty() -> Self {
RestyleDamage::empty() ServoRestyleDamage::empty()
} }
fn compute(old: &Arc<ServoComputedValues>, fn compute(old: &Arc<ServoComputedValues>,
new: &Arc<ServoComputedValues>) -> RestyleDamage { new: &Arc<ServoComputedValues>) -> ServoRestyleDamage {
compute_damage(old, new) compute_damage(old, new)
} }
/// Returns a bitmask that represents a flow that needs to be rebuilt and /// Returns a bitmask that represents a flow that needs to be rebuilt and
/// reflowed. /// reflowed.
/// ///
/// Use this instead of `RestyleDamage::all()` because /// Use this instead of `ServoRestyleDamage::all()` because
/// `RestyleDamage::all()` will result in unnecessary sequential resolution /// `ServoRestyleDamage::all()` will result in unnecessary sequential resolution
/// of generated content. /// of generated content.
fn rebuild_and_reflow() -> RestyleDamage { fn rebuild_and_reflow() -> ServoRestyleDamage {
REPAINT | REPOSITION | STORE_OVERFLOW | BUBBLE_ISIZES | REFLOW_OUT_OF_FLOW | REFLOW | REPAINT | REPOSITION | STORE_OVERFLOW | BUBBLE_ISIZES | REFLOW_OUT_OF_FLOW | REFLOW |
RECONSTRUCT_FLOW RECONSTRUCT_FLOW
} }
} }
impl RestyleDamage { impl ServoRestyleDamage {
/// Supposing a flow has the given `position` property and this damage, /// Supposing a flow has the given `position` property and this damage,
/// returns the damage that we should add to the *parent* of this flow. /// returns the damage that we should add to the *parent* of this flow.
pub fn damage_for_parent(self, child_is_absolutely_positioned: bool) -> RestyleDamage { pub fn damage_for_parent(self, child_is_absolutely_positioned: bool) -> ServoRestyleDamage {
if child_is_absolutely_positioned { if child_is_absolutely_positioned {
self & (REPAINT | REPOSITION | STORE_OVERFLOW | REFLOW_OUT_OF_FLOW | self & (REPAINT | REPOSITION | STORE_OVERFLOW | REFLOW_OUT_OF_FLOW |
RESOLVE_GENERATED_CONTENT) RESOLVE_GENERATED_CONTENT)
@ -91,7 +91,7 @@ impl RestyleDamage {
pub fn damage_for_child(self, pub fn damage_for_child(self,
parent_is_absolutely_positioned: bool, parent_is_absolutely_positioned: bool,
child_is_absolutely_positioned: bool) child_is_absolutely_positioned: bool)
-> RestyleDamage { -> ServoRestyleDamage {
match (parent_is_absolutely_positioned, child_is_absolutely_positioned) { match (parent_is_absolutely_positioned, child_is_absolutely_positioned) {
(false, true) => { (false, true) => {
// Absolute children are out-of-flow and therefore insulated from changes. // Absolute children are out-of-flow and therefore insulated from changes.
@ -116,7 +116,7 @@ impl RestyleDamage {
} }
} }
impl fmt::Display for RestyleDamage { impl fmt::Display for ServoRestyleDamage {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
let mut first_elem = true; let mut first_elem = true;
@ -162,8 +162,8 @@ macro_rules! add_if_not_equal(
}) })
); );
fn compute_damage(old: &ServoComputedValues, new: &ServoComputedValues) -> RestyleDamage { fn compute_damage(old: &ServoComputedValues, new: &ServoComputedValues) -> ServoRestyleDamage {
let mut damage = RestyleDamage::empty(); let mut damage = ServoRestyleDamage::empty();
// This should check every CSS property, as enumerated in the fields of // This should check every CSS property, as enumerated in the fields of
// http://doc.servo.org/style/properties/struct.ServoComputedValues.html // http://doc.servo.org/style/properties/struct.ServoComputedValues.html
@ -260,7 +260,7 @@ fn compute_damage(old: &ServoComputedValues, new: &ServoComputedValues) -> Resty
// If the layer requirements of this flow have changed due to the value // If the layer requirements of this flow have changed due to the value
// of the transform, then reflow is required to rebuild the layers. // of the transform, then reflow is required to rebuild the layers.
if old.transform_requires_layer() != new.transform_requires_layer() { if old.transform_requires_layer() != new.transform_requires_layer() {
damage.insert(RestyleDamage::rebuild_and_reflow()); damage.insert(ServoRestyleDamage::rebuild_and_reflow());
} }
damage damage

View file

@ -384,8 +384,6 @@ impl MatchAttrGeneric for ServoElementSnapshot {
} }
impl<E: Element<Impl=TheSelectorImpl>> ElementExt for E { impl<E: Element<Impl=TheSelectorImpl>> ElementExt for E {
type Snapshot = ServoElementSnapshot;
fn is_link(&self) -> bool { fn is_link(&self) -> bool {
self.match_non_ts_pseudo_class(NonTSPseudoClass::AnyLink) self.match_non_ts_pseudo_class(NonTSPseudoClass::AnyLink)
} }