aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-11-07 16:31:10 -0600
committerGitHub <noreply@github.com>2016-11-07 16:31:10 -0600
commitd8ac5100e81ccbad4b5131688b96bedb9b5e279d (patch)
tree50e4518ec7459d74feeb6b4ea15f453238af31f1
parentf1c3e97fb47b6fbe1d82ebb30a38ab7afd4fe0b8 (diff)
parenta2c7a9d0fb7174f9188640ba2fb5a3df7821c1a8 (diff)
downloadservo-d8ac5100e81ccbad4b5131688b96bedb9b5e279d.tar.gz
servo-d8ac5100e81ccbad4b5131688b96bedb9b5e279d.zip
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 -->
-rw-r--r--components/layout/animation.rs2
-rw-r--r--components/layout/block.rs3
-rw-r--r--components/layout/construct.rs4
-rw-r--r--components/layout/display_list_builder.rs2
-rw-r--r--components/layout/flex.rs2
-rw-r--r--components/layout/flow.rs4
-rw-r--r--components/layout/fragment.rs3
-rw-r--r--components/layout/generated_content.rs3
-rw-r--r--components/layout/incremental.rs3
-rw-r--r--components/layout/inline.rs3
-rw-r--r--components/layout/list_item.rs2
-rw-r--r--components/layout/sequential.rs2
-rw-r--r--components/layout/table.rs2
-rw-r--r--components/layout/table_row.rs2
-rw-r--r--components/layout/traversal.rs3
-rw-r--r--components/layout_thread/lib.rs3
-rw-r--r--components/script/dom/bindings/trace.rs4
-rw-r--r--components/script/dom/document.rs12
-rw-r--r--components/script/layout_wrapper.rs6
-rw-r--r--components/script_layout_interface/lib.rs3
-rw-r--r--components/script_layout_interface/wrapper_traits.rs3
-rw-r--r--components/style/dom.rs10
-rw-r--r--components/style/gecko/mod.rs1
-rw-r--r--components/style/gecko/restyle_damage.rs53
-rw-r--r--components/style/gecko/wrapper.rs47
-rw-r--r--components/style/lib.rs2
-rw-r--r--components/style/matching.rs34
-rw-r--r--components/style/restyle_hints.rs8
-rw-r--r--components/style/selector_impl.rs23
-rw-r--r--components/style/selector_matching.rs4
-rw-r--r--components/style/servo/mod.rs6
-rw-r--r--components/style/servo/restyle_damage.rs (renamed from components/script_layout_interface/restyle_damage.rs)34
-rw-r--r--components/style/servo/selector_impl.rs (renamed from components/style/servo_selector_impl.rs)2
33 files changed, 156 insertions, 139 deletions
diff --git a/components/layout/animation.rs b/components/layout/animation.rs
index 22387dff562..9147970f8cf 100644
--- a/components/layout/animation.rs
+++ b/components/layout/animation.rs
@@ -9,12 +9,12 @@ use flow::{self, Flow};
use gfx::display_list::OpaqueNode;
use ipc_channel::ipc::IpcSender;
use msg::constellation_msg::PipelineId;
-use script_layout_interface::restyle_damage::RestyleDamage;
use script_traits::{AnimationState, ConstellationControlMsg, LayoutMsg as ConstellationMsg};
use std::collections::HashMap;
use std::sync::mpsc::Receiver;
use style::animation::{Animation, update_style_for_animation};
use style::dom::TRestyleDamage;
+use style::selector_impl::RestyleDamage;
use style::timer::Timer;
/// Processes any new animations that were discovered after style recalculation.
diff --git a/components/layout/block.rs b/components/layout/block.rs
index 71db966d69c..1d6ad5a08d9 100644
--- a/components/layout/block.rs
+++ b/components/layout/block.rs
@@ -48,8 +48,6 @@ use gfx_traits::print_tree::PrintTree;
use layout_debug;
use model::{CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo, MaybeAuto};
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 serde::{Serialize, Serializer};
use std::cmp::{max, min};
@@ -60,6 +58,7 @@ use style::computed_values::{position, text_align};
use style::context::{SharedStyleContext, StyleContext};
use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode};
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::LengthOrPercentageOrAuto;
use util::clamp;
diff --git a/components/layout/construct.rs b/components/layout/construct.rs
index 69e3a2d20d2..0b489459352 100644
--- a/components/layout/construct.rs
+++ b/components/layout/construct.rs
@@ -36,7 +36,6 @@ use list_item::{ListItemFlow, ListStyleTypeContent};
use multicol::{MulticolColumnFlow, MulticolFlow};
use parallel;
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 std::borrow::ToOwned;
use std::collections::LinkedList;
@@ -49,8 +48,9 @@ use style::computed_values::content::ContentItem;
use style::computed_values::position;
use style::context::SharedStyleContext;
use style::properties::{self, ServoComputedValues};
+use style::selector_impl::{PseudoElement, RestyleDamage};
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_caption::TableCaptionFlow;
use table_cell::TableCellFlow;
diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs
index cbecdba4187..e6501e64050 100644
--- a/components/layout/display_list_builder.rs
+++ b/components/layout/display_list_builder.rs
@@ -35,7 +35,6 @@ use model::{self, MaybeAuto, ToGfxMatrix};
use net_traits::image::base::PixelFormat;
use net_traits::image_cache_thread::UsePlaceholder;
use range::Range;
-use script_layout_interface::restyle_damage::REPAINT;
use std::{cmp, f32};
use std::collections::HashMap;
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::properties::{self, ServoComputedValues};
use style::properties::style_structs;
+use style::servo::restyle_damage::REPAINT;
use style::values::RGBA;
use style::values::computed;
use style::values::computed::{Gradient, GradientKind, LengthOrNone, LengthOrPercentage, LengthOrPercentageOrAuto};
diff --git a/components/layout/flex.rs b/components/layout/flex.rs
index 0fca93fb5f3..337abc3227a 100644
--- a/components/layout/flex.rs
+++ b/components/layout/flex.rs
@@ -21,7 +21,6 @@ use gfx_traits::ScrollRootId;
use layout_debug;
use model::{Direction, IntrinsicISizes, MaybeAuto, MinMaxConstraint};
use model::{specified, specified_or_none};
-use script_layout_interface::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
use std::cmp::{max, min};
use std::ops::Range;
use std::sync::Arc;
@@ -30,6 +29,7 @@ use style::computed_values::border_collapse;
use style::context::{SharedStyleContext, StyleContext};
use style::logical_geometry::LogicalSize;
use style::properties::ServoComputedValues;
+use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
use style::values::computed::{LengthOrPercentageOrAutoOrContent, LengthOrPercentageOrNone};
diff --git a/components/layout/flow.rs b/components/layout/flow.rs
index 22f64438f91..3da277d924d 100644
--- a/components/layout/flow.rs
+++ b/components/layout/flow.rs
@@ -41,8 +41,6 @@ use inline::InlineFlow;
use model::{CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo};
use multicol::MulticolFlow;
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 std::{fmt, mem, raw};
use std::iter::Zip;
@@ -54,6 +52,8 @@ use style::context::SharedStyleContext;
use style::dom::TRestyleDamage;
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
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 table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, TableFlow};
use table_caption::TableCaptionFlow;
diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs
index e624ad6013c..93206782983 100644
--- a/components/layout/fragment.rs
+++ b/components/layout/fragment.rs
@@ -30,7 +30,6 @@ use net_traits::image_cache_thread::{ImageOrMetadataAvailable, UsePlaceholder};
use range::*;
use script_layout_interface::HTMLCanvasData;
use script_layout_interface::SVGSVGData;
-use script_layout_interface::restyle_damage::{RECONSTRUCT_FLOW, RestyleDamage};
use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
use serde::{Serialize, Serializer};
use std::borrow::ToOwned;
@@ -47,6 +46,8 @@ use style::context::SharedStyleContext;
use style::dom::TRestyleDamage;
use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode};
use style::properties::ServoComputedValues;
+use style::selector_impl::RestyleDamage;
+use style::servo::restyle_damage::RECONSTRUCT_FLOW;
use style::str::char_is_whitespace;
use style::values::computed::{LengthOrNone, LengthOrPercentage, LengthOrPercentageOrAuto};
use style::values::computed::LengthOrPercentageOrNone;
diff --git a/components/layout/generated_content.rs b/components/layout/generated_content.rs
index a4c7f4e06fa..0d8038a0348 100644
--- a/components/layout/generated_content.rs
+++ b/components/layout/generated_content.rs
@@ -13,7 +13,6 @@ use flow::{self, AFFECTS_COUNTERS, Flow, HAS_COUNTER_AFFECTING_CHILDREN, Immutab
use flow::InorderFlowTraversal;
use fragment::{Fragment, GeneratedContentInfo, SpecificFragmentInfo, UnscannedTextFragmentInfo};
use gfx::display_list::OpaqueNode;
-use script_layout_interface::restyle_damage::{RESOLVE_GENERATED_CONTENT, RestyleDamage};
use script_layout_interface::wrapper_traits::PseudoElementType;
use smallvec::SmallVec;
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::dom::TRestyleDamage;
use style::properties::ServoComputedValues;
+use style::selector_impl::RestyleDamage;
+use style::servo::restyle_damage::RESOLVE_GENERATED_CONTENT;
use text::TextRunScanner;
// Decimal styles per CSS-COUNTER-STYLES § 6.1:
diff --git a/components/layout/incremental.rs b/components/layout/incremental.rs
index 14644be6ddc..83c9a5f4ddb 100644
--- a/components/layout/incremental.rs
+++ b/components/layout/incremental.rs
@@ -3,9 +3,10 @@
* 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 script_layout_interface::restyle_damage::{RestyleDamage, REFLOW, RECONSTRUCT_FLOW};
use style::computed_values::float;
use style::dom::TRestyleDamage;
+use style::selector_impl::RestyleDamage;
+use style::servo::restyle_damage::{REFLOW, RECONSTRUCT_FLOW};
bitflags! {
pub flags SpecialRestyleDamage: u8 {
diff --git a/components/layout/inline.rs b/components/layout/inline.rs
index 80b8c29eae6..735ee0acf90 100644
--- a/components/layout/inline.rs
+++ b/components/layout/inline.rs
@@ -24,8 +24,6 @@ use gfx_traits::print_tree::PrintTree;
use layout_debug;
use model::IntrinsicISizesContribution;
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 std::{fmt, i32, isize, mem};
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::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
use style::properties::ServoComputedValues;
+use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPOSITION, RESOLVE_GENERATED_CONTENT};
use text;
use unicode_bidi;
diff --git a/components/layout/list_item.rs b/components/layout/list_item.rs
index 2a925acd883..b3f8df9752d 100644
--- a/components/layout/list_item.rs
+++ b/components/layout/list_item.rs
@@ -20,12 +20,12 @@ use generated_content;
use gfx::display_list::StackingContext;
use gfx_traits::ScrollRootId;
use inline::InlineFlow;
-use script_layout_interface::restyle_damage::RESOLVE_GENERATED_CONTENT;
use std::sync::Arc;
use style::computed_values::{list_style_type, position};
use style::context::SharedStyleContext;
use style::logical_geometry::LogicalSize;
use style::properties::ServoComputedValues;
+use style::servo::restyle_damage::RESOLVE_GENERATED_CONTENT;
/// A block with the CSS `display` property equal to `list-item`.
#[derive(Debug)]
diff --git a/components/layout/sequential.rs b/components/layout/sequential.rs
index 59819efe414..71626243206 100644
--- a/components/layout/sequential.rs
+++ b/components/layout/sequential.rs
@@ -15,8 +15,8 @@ use flow::IS_ABSOLUTELY_POSITIONED;
use fragment::FragmentBorderBoxIterator;
use generated_content::ResolveGeneratedContent;
use gfx_traits::ScrollRootId;
-use script_layout_interface::restyle_damage::{REFLOW, STORE_OVERFLOW};
use style::context::StyleContext;
+use style::servo::restyle_damage::{REFLOW, STORE_OVERFLOW};
use traversal::{AssignBSizes, AssignISizes, BubbleISizes, BuildDisplayList};
use util::opts;
diff --git a/components/layout/table.rs b/components/layout/table.rs
index 3ffc5231f5a..b1f3a01fc22 100644
--- a/components/layout/table.rs
+++ b/components/layout/table.rs
@@ -21,7 +21,6 @@ use gfx_traits::ScrollRootId;
use gfx_traits::print_tree::PrintTree;
use layout_debug;
use model::{IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto};
-use script_layout_interface::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
use std::cmp;
use std::fmt;
use std::sync::Arc;
@@ -29,6 +28,7 @@ use style::computed_values::{border_collapse, border_spacing, table_layout};
use style::context::SharedStyleContext;
use style::logical_geometry::LogicalSize;
use style::properties::ServoComputedValues;
+use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
use style::values::CSSFloat;
use style::values::computed::LengthOrPercentageOrAuto;
use table_row::{self, CellIntrinsicInlineSize, CollapsedBorder, CollapsedBorderProvenance};
diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs
index 1b4df7b7bfc..3a39b4c1ce1 100644
--- a/components/layout/table_row.rs
+++ b/components/layout/table_row.rs
@@ -20,7 +20,6 @@ use gfx_traits::ScrollRootId;
use gfx_traits::print_tree::PrintTree;
use layout_debug;
use model::MaybeAuto;
-use script_layout_interface::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
use serde::{Serialize, Serializer};
use std::cmp::max;
use std::fmt;
@@ -30,6 +29,7 @@ use style::computed_values::{border_collapse, border_spacing, border_top_style};
use style::context::SharedStyleContext;
use style::logical_geometry::{LogicalSize, PhysicalSide, WritingMode};
use style::properties::ServoComputedValues;
+use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
use style::values::computed::LengthOrPercentageOrAuto;
use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, VecExt};
use table_cell::{CollapsedBordersForCell, TableCellFlow};
diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs
index c897838875a..3124bca1dfc 100644
--- a/components/layout/traversal.rs
+++ b/components/layout/traversal.rs
@@ -10,13 +10,14 @@ use display_list_builder::DisplayListBuildState;
use flow::{self, PreorderFlowTraversal};
use flow::{CAN_BE_FRAGMENTED, Flow, ImmutableFlowUtils, PostorderFlowTraversal};
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 std::mem;
use style::atomic_refcell::AtomicRefCell;
use style::context::{LocalStyleContext, SharedStyleContext, StyleContext};
use style::data::ElementData;
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::{recalc_style_at, remove_from_bloom_filter};
use style::traversal::take_thread_local_bloom_filter;
diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs
index 60956b00150..6d4f45ef99e 100644
--- a/components/layout_thread/lib.rs
+++ b/components/layout_thread/lib.rs
@@ -87,8 +87,6 @@ use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType};
use script::layout_wrapper::{ServoLayoutDocument, ServoLayoutNode};
use script_layout_interface::message::{Msg, NewLayoutThreadInfo, Reflow, ReflowQueryType, ScriptReflow};
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::wrapper_traits::LayoutNode;
use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg};
@@ -111,6 +109,7 @@ use style::media_queries::{Device, MediaType};
use style::parallel::WorkQueueData;
use style::parser::ParserContextExtraData;
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::thread_state;
use style::timer::Timer;
diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs
index 59a6178e462..67c2721f973 100644
--- a/components/script/dom/bindings/trace.rs
+++ b/components/script/dom/bindings/trace.rs
@@ -94,7 +94,7 @@ use style::attr::{AttrIdentifier, AttrValue, LengthOrPercentageOrAuto};
use style::element_state::*;
use style::media_queries::MediaQueryList;
use style::properties::PropertyDeclarationBlock;
-use style::selector_impl::{ElementSnapshot, PseudoElement};
+use style::selector_impl::{PseudoElement, Snapshot};
use style::values::specified::Length;
use time::Duration;
use url::Origin as UrlOrigin;
@@ -346,7 +346,7 @@ no_jsmanaged_fields!(DOMString);
no_jsmanaged_fields!(Mime);
no_jsmanaged_fields!(AttrIdentifier);
no_jsmanaged_fields!(AttrValue);
-no_jsmanaged_fields!(ElementSnapshot);
+no_jsmanaged_fields!(Snapshot);
no_jsmanaged_fields!(HttpsState);
no_jsmanaged_fields!(Request);
no_jsmanaged_fields!(SharedRt);
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index cb8a2d37cf9..5b1f4cfe404 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -125,7 +125,7 @@ use std::sync::Arc;
use std::time::{Duration, Instant};
use style::attr::AttrValue;
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::stylesheets::Stylesheet;
use time;
@@ -236,7 +236,7 @@ pub struct Document {
appropriate_template_contents_owner_document: MutNullableHeap<JS<Document>>,
/// For each element that has had a state or attribute change since the last restyle,
/// 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
/// needed in order for the page to be painted.
needs_paint: Cell<bool>,
@@ -1708,7 +1708,7 @@ pub enum DocumentSource {
#[allow(unsafe_code)]
pub trait LayoutDocumentHelpers {
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 will_paint(&self);
}
@@ -1722,7 +1722,7 @@ impl LayoutDocumentHelpers for LayoutJS<Document> {
#[inline]
#[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 result = elements.drain().map(|(k, v)| (k.to_layout(), v)).collect();
result
@@ -1970,7 +1970,7 @@ impl Document {
let mut map = self.modified_elements.borrow_mut();
let snapshot = map.entry(JS::from_ref(el))
.or_insert_with(|| {
- ElementSnapshot::new(el.html_element_in_html_document())
+ Snapshot::new(el.html_element_in_html_document())
});
if snapshot.state.is_none() {
snapshot.state = Some(el.state());
@@ -1981,7 +1981,7 @@ impl Document {
let mut map = self.modified_elements.borrow_mut();
let mut snapshot = map.entry(JS::from_ref(el))
.or_insert_with(|| {
- ElementSnapshot::new(el.html_element_in_html_document())
+ Snapshot::new(el.html_element_in_html_document())
});
if snapshot.attrs.is_none() {
let attrs = el.attrs()
diff --git a/components/script/layout_wrapper.rs b/components/script/layout_wrapper.rs
index c83e8232a40..00c7ce1413c 100644
--- a/components/script/layout_wrapper.rs
+++ b/components/script/layout_wrapper.rs
@@ -46,7 +46,6 @@ use parking_lot::RwLock;
use range::Range;
use script_layout_interface::{HTMLCanvasData, LayoutNodeType, SVGSVGData, TrustedNodeAddress};
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::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
use selectors::matching::ElementFlags;
@@ -66,7 +65,7 @@ use style::dom::{LayoutIterator, NodeInfo, OpaqueNode, PresentationalHintsSynthe
use style::dom::{TRestyleDamage, UnsafeNode};
use style::element_state::*;
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::sink::Push;
use style::str::is_whitespace;
@@ -382,7 +381,7 @@ impl<'ld> TDocument for ServoLayoutDocument<'ld> {
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() };
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> {
type ConcreteNode = ServoLayoutNode<'le>;
type ConcreteDocument = ServoLayoutDocument<'le>;
- type ConcreteRestyleDamage = RestyleDamage;
fn as_node(&self) -> ServoLayoutNode<'le> {
ServoLayoutNode::from_layout_js(self.element.upcast())
diff --git a/components/script_layout_interface/lib.rs b/components/script_layout_interface/lib.rs
index b442e502b2b..284f6f33498 100644
--- a/components/script_layout_interface/lib.rs
+++ b/components/script_layout_interface/lib.rs
@@ -41,7 +41,6 @@ extern crate url;
pub mod message;
pub mod reporter;
-pub mod restyle_damage;
pub mod rpc;
pub mod wrapper_traits;
@@ -49,10 +48,10 @@ use canvas_traits::CanvasMsg;
use core::nonzero::NonZero;
use ipc_channel::ipc::IpcSender;
use libc::c_void;
-use restyle_damage::RestyleDamage;
use std::sync::atomic::AtomicIsize;
use style::atomic_refcell::AtomicRefCell;
use style::data::ElementData;
+use style::selector_impl::RestyleDamage;
pub struct PartialPersistentLayoutData {
/// Data that the style system associates with a node. When the
diff --git a/components/script_layout_interface/wrapper_traits.rs b/components/script_layout_interface/wrapper_traits.rs
index 7bd91bdb0d0..9123c0c1f45 100644
--- a/components/script_layout_interface/wrapper_traits.rs
+++ b/components/script_layout_interface/wrapper_traits.rs
@@ -12,7 +12,6 @@ use gfx_traits::ByteIndex;
use html5ever_atoms::{Namespace, LocalName};
use msg::constellation_msg::PipelineId;
use range::Range;
-use restyle_damage::RestyleDamage;
use std::fmt::Debug;
use std::sync::Arc;
use style::atomic_refcell::AtomicRefCell;
@@ -22,7 +21,7 @@ use style::data::ElementData;
use style::dom::{LayoutIterator, NodeInfo, PresentationalHintsSynthetizer, TElement, TNode};
use style::dom::OpaqueNode;
use style::properties::ServoComputedValues;
-use style::selector_impl::{PseudoElement, PseudoElementCascadeType, ServoSelectorImpl};
+use style::selector_impl::{PseudoElement, PseudoElementCascadeType, RestyleDamage, ServoSelectorImpl};
use url::Url;
#[derive(Copy, PartialEq, Clone, Debug)]
diff --git a/components/style/dom.rs b/components/style/dom.rs
index 702d56a6f4d..388a7310ab0 100644
--- a/components/style/dom.rs
+++ b/components/style/dom.rs
@@ -14,7 +14,7 @@ use parking_lot::RwLock;
use properties::{ComputedValues, PropertyDeclarationBlock};
use properties::longhands::display::computed_value as display;
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 sink::Push;
use std::fmt::Debug;
@@ -159,8 +159,7 @@ pub trait TDocument : Sized + Copy + Clone {
fn root_node(&self) -> Option<Self::ConcreteNode>;
- fn drain_modified_elements(&self) -> Vec<(Self::ConcreteElement,
- <Self::ConcreteElement as ElementExt>::Snapshot)>;
+ fn drain_modified_elements(&self) -> Vec<(Self::ConcreteElement, Snapshot)>;
fn needs_paint_from_layout(&self);
fn will_paint(&self);
@@ -174,7 +173,6 @@ pub trait PresentationalHintsSynthetizer {
pub trait TElement : PartialEq + Debug + Sized + Copy + Clone + ElementExt + PresentationalHintsSynthetizer {
type ConcreteNode: TNode<ConcreteElement = Self, ConcreteDocument = Self::ConcreteDocument>;
type ConcreteDocument: TDocument<ConcreteNode = Self::ConcreteNode, ConcreteElement = Self>;
- type ConcreteRestyleDamage: TRestyleDamage;
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;
/// 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
/// 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,
current_computed_values: Option<&'a Arc<ComputedValues>>,
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.
/// Instead, we associate restyle and change hints with nodes. However, we
diff --git a/components/style/gecko/mod.rs b/components/style/gecko/mod.rs
index 7153a7e3da2..ee462ef4b81 100644
--- a/components/style/gecko/mod.rs
+++ b/components/style/gecko/mod.rs
@@ -5,6 +5,7 @@
pub mod context;
pub mod data;
+pub mod restyle_damage;
pub mod snapshot;
pub mod snapshot_helpers;
pub mod traversal;
diff --git a/components/style/gecko/restyle_damage.rs b/components/style/gecko/restyle_damage.rs
new file mode 100644
index 00000000000..ed23bb15062
--- /dev/null
+++ b/components/style/gecko/restyle_damage.rs
@@ -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) })
+ }
+}
+
diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs
index 3723045bae7..9adac5f269f 100644
--- a/components/style/gecko/wrapper.rs
+++ b/components/style/gecko/wrapper.rs
@@ -7,15 +7,15 @@
use atomic_refcell::{AtomicRef, AtomicRefCell};
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 element_state::ElementState;
use error_reporting::StdoutErrorReporter;
+use gecko::restyle_damage::GeckoRestyleDamage;
use gecko::selector_impl::{GeckoSelectorImpl, NonTSPseudoClass, PseudoElement};
use gecko::snapshot::GeckoElementSnapshot;
use gecko::snapshot_helpers;
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_ElementState, Gecko_GetDocumentElement};
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_GetStyleContext;
use gecko_bindings::bindings::Gecko_SetNodeFlags;
+use gecko_bindings::bindings::Gecko_StoreStyleDifference;
use gecko_bindings::structs;
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::sugar::ownership::FFIArcHelpers;
+use gecko_bindings::structs::{nsIAtom, nsIContent, nsStyleContext};
use libc::uintptr_t;
use parking_lot::RwLock;
use parser::ParserContextExtraData;
@@ -41,7 +41,6 @@ use selectors::Element;
use selectors::parser::{AttrSelector, NamespaceConstraint};
use sink::Push;
use std::fmt;
-use std::ops::BitOr;
use std::ptr;
use std::sync::Arc;
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> {
fn is_element(&self) -> bool {
use gecko_bindings::structs::nsINode_BooleanFlag;
@@ -358,7 +324,6 @@ lazy_static! {
impl<'le> TElement for GeckoElement<'le> {
type ConcreteNode = GeckoNode<'le>;
type ConcreteDocument = GeckoDocument<'le>;
- type ConcreteRestyleDamage = GeckoRestyleDamage;
fn as_node(&self) -> Self::ConcreteNode {
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.
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,
@@ -691,8 +656,6 @@ impl<'le> ::selectors::MatchAttr for GeckoElement<'le> {
}
impl<'le> ElementExt for GeckoElement<'le> {
- type Snapshot = GeckoElementSnapshot;
-
#[inline]
fn is_link(&self) -> bool {
self.match_non_ts_pseudo_class(NonTSPseudoClass::AnyLink)
diff --git a/components/style/lib.rs b/components/style/lib.rs
index c6010def374..d7312bbb904 100644
--- a/components/style/lib.rs
+++ b/components/style/lib.rs
@@ -117,8 +117,8 @@ pub mod restyle_hints;
pub mod rule_tree;
pub mod selector_impl;
pub mod selector_matching;
+#[cfg(feature = "servo")] #[allow(unsafe_code)] pub mod servo;
pub mod sequential;
-#[cfg(feature = "servo")] pub mod servo_selector_impl;
pub mod sink;
pub mod str;
pub mod stylesheets;
diff --git a/components/style/matching.rs b/components/style/matching.rs
index ac4bdb0b59a..97faf4d0a6a 100644
--- a/components/style/matching.rs
+++ b/components/style/matching.rs
@@ -17,7 +17,7 @@ use dom::{TElement, TNode, TRestyleDamage, UnsafeNode};
use properties::{CascadeFlags, ComputedValues, SHAREABLE, cascade};
use properties::longhands::display::computed_value as display;
use rule_tree::StrongRuleNode;
-use selector_impl::{TheSelectorImpl, PseudoElement};
+use selector_impl::{PseudoElement, RestyleDamage, TheSelectorImpl};
use selector_matching::{ApplicableDeclarationBlock, Stylist};
use selectors::MatchAttr;
use selectors::bloom::BloomFilter;
@@ -373,14 +373,14 @@ impl StyleSharingCandidateCache {
}
/// 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.
CannotShare,
/// 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
/// result the original result of the candidate's styling, that is, whether
/// 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.
@@ -565,7 +565,7 @@ pub trait MatchMethods : TElement {
&mut StyleSharingCandidateCache,
shared_context: &SharedStyleContext,
data: &mut AtomicRefMut<ElementData>)
- -> StyleSharingResult<Self::ConcreteRestyleDamage> {
+ -> StyleSharingResult {
if opts::get().disable_share_style_cache {
return StyleSharingResult::CannotShare
}
@@ -591,12 +591,8 @@ pub trait MatchMethods : TElement {
// replaced content, or similar stuff!
let damage =
match self.existing_style_for_restyle_damage(data.previous_styles().map(|x| &x.primary), None) {
- Some(ref source) => {
- Self::ConcreteRestyleDamage::compute(source, &shared_style)
- }
- None => {
- Self::ConcreteRestyleDamage::rebuild_and_reflow()
- }
+ Some(ref source) => RestyleDamage::compute(source, &shared_style),
+ None => RestyleDamage::rebuild_and_reflow(),
};
data.finish_styling(ElementStyles::new(shared_style, rule_node));
@@ -678,13 +674,10 @@ pub trait MatchMethods : TElement {
old_style: Option<&Arc<ComputedValues>>,
new_style: &Arc<ComputedValues>,
pseudo: Option<&PseudoElement>)
- -> Self::ConcreteRestyleDamage
+ -> RestyleDamage
{
match self.existing_style_for_restyle_damage(old_style, pseudo) {
- Some(ref source) => {
- Self::ConcreteRestyleDamage::compute(source,
- new_style)
- }
+ Some(ref source) => RestyleDamage::compute(source, new_style),
None => {
// If there's no style source, two things can happen:
//
@@ -710,7 +703,7 @@ pub trait MatchMethods : TElement {
// stick without the assertions.
debug_assert!(pseudo.is_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,
context: &Ctx,
applicable_declarations: &mut ApplicableDeclarations)
- -> Self::ConcreteRestyleDamage
+ -> RestyleDamage
where Ctx: StyleContext<'a>
{
// 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.
let damage = match old_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: {:?} {:?} {:?}",
@@ -820,8 +813,7 @@ pub trait MatchMethods : TElement {
return damage;
}
- let rebuild_and_reflow =
- Self::ConcreteRestyleDamage::rebuild_and_reflow();
+ let rebuild_and_reflow = RestyleDamage::rebuild_and_reflow();
debug_assert!(new_pseudos.is_empty());
<Self as MatchAttr>::Impl::each_eagerly_cascaded_pseudo_element(|pseudo| {
diff --git a/components/style/restyle_hints.rs b/components/style/restyle_hints.rs
index a856d02a823..c2e4da3dede 100644
--- a/components/style/restyle_hints.rs
+++ b/components/style/restyle_hints.rs
@@ -8,7 +8,7 @@ use Atom;
use element_state::*;
#[cfg(feature = "servo")]
use heapsize::HeapSizeOf;
-use selector_impl::{AttrValue, ElementExt, NonTSPseudoClass, TheSelectorImpl};
+use selector_impl::{AttrValue, ElementExt, NonTSPseudoClass, Snapshot, TheSelectorImpl};
use selectors::{Element, MatchAttr};
use selectors::matching::{MatchingReason, StyleRelations};
use selectors::matching::matches_complex_selector;
@@ -85,7 +85,7 @@ struct ElementWrapper<'a, E>
where E: ElementExt
{
element: E,
- snapshot: Option<&'a E::Snapshot>,
+ snapshot: Option<&'a Snapshot>,
}
impl<'a, E> ElementWrapper<'a, E>
@@ -95,7 +95,7 @@ impl<'a, E> ElementWrapper<'a, E>
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) }
}
}
@@ -424,7 +424,7 @@ impl DependencySet {
}
pub fn compute_hint<E>(&self, el: &E,
- snapshot: &E::Snapshot,
+ snapshot: &Snapshot,
current_state: ElementState)
-> RestyleHint
where E: ElementExt + Clone
diff --git a/components/style/selector_impl.rs b/components/style/selector_impl.rs
index 3d1d7813bd2..85734d51387 100644
--- a/components/style/selector_impl.rs
+++ b/components/style/selector_impl.rs
@@ -5,23 +5,34 @@
//! The pseudo-classes and pseudo-elements supported by the style system.
use matching::{common_style_affecting_attributes, CommonStyleAffectingAttributeMode};
-use restyle_hints;
use selectors::Element;
use selectors::parser::{AttrSelector, SelectorImpl};
pub type AttrValue = <TheSelectorImpl as SelectorImpl>::AttrValue;
#[cfg(feature = "servo")]
-pub use servo_selector_impl::*;
+pub use servo::selector_impl::*;
+
+#[cfg(feature = "gecko")]
+pub use gecko::selector_impl::*;
#[cfg(feature = "servo")]
-pub use servo_selector_impl::{ServoSelectorImpl as TheSelectorImpl, ServoElementSnapshot as ElementSnapshot};
+pub use servo::selector_impl::ServoSelectorImpl as TheSelectorImpl;
#[cfg(feature = "gecko")]
-pub use gecko::selector_impl::*;
+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::selector_impl::{GeckoSelectorImpl as TheSelectorImpl};
+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.
///
@@ -71,8 +82,6 @@ impl PseudoElementCascadeType {
}
pub trait ElementExt: Element<Impl=TheSelectorImpl> {
- type Snapshot: restyle_hints::ElementSnapshot + 'static;
-
fn is_link(&self) -> bool;
}
diff --git a/components/style/selector_matching.rs b/components/style/selector_matching.rs
index 1a0a07b32e4..3cac2d48670 100644
--- a/components/style/selector_matching.rs
+++ b/components/style/selector_matching.rs
@@ -16,7 +16,7 @@ use properties::{PropertyDeclaration, PropertyDeclarationBlock};
use quickersort::sort_by;
use restyle_hints::{RestyleHint, DependencySet};
use rule_tree::{RuleTree, StrongRuleNode, StyleSource};
-use selector_impl::{ElementExt, TheSelectorImpl, PseudoElement};
+use selector_impl::{ElementExt, TheSelectorImpl, PseudoElement, Snapshot};
use selectors::Element;
use selectors::bloom::BloomFilter;
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,
- snapshot: &E::Snapshot,
+ snapshot: &Snapshot,
// NB: We need to pass current_state as an argument because
// selectors::Element doesn't provide access to ElementState
// directly, and computing it from the ElementState would be
diff --git a/components/style/servo/mod.rs b/components/style/servo/mod.rs
new file mode 100644
index 00000000000..bd3db996eff
--- /dev/null
+++ b/components/style/servo/mod.rs
@@ -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;
diff --git a/components/script_layout_interface/restyle_damage.rs b/components/style/servo/restyle_damage.rs
index ff0e26af03f..08dd549b288 100644
--- a/components/script_layout_interface/restyle_damage.rs
+++ b/components/style/servo/restyle_damage.rs
@@ -2,15 +2,15 @@
* 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 computed_values::display;
+use dom::TRestyleDamage;
+use properties::ServoComputedValues;
use std::fmt;
use std::sync::Arc;
-use style::computed_values::display;
-use style::dom::TRestyleDamage;
-use style::properties::ServoComputedValues;
bitflags! {
#[doc = "Individual layout actions that may be necessary after restyling."]
- pub flags RestyleDamage: u8 {
+ pub flags ServoRestyleDamage: u8 {
#[doc = "Repaint the node itself."]
#[doc = "Currently unused; need to decide how this propagates."]
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.
type PreExistingComputedValues = Arc<ServoComputedValues>;
fn empty() -> Self {
- RestyleDamage::empty()
+ ServoRestyleDamage::empty()
}
fn compute(old: &Arc<ServoComputedValues>,
- new: &Arc<ServoComputedValues>) -> RestyleDamage {
+ new: &Arc<ServoComputedValues>) -> ServoRestyleDamage {
compute_damage(old, new)
}
/// Returns a bitmask that represents a flow that needs to be rebuilt and
/// reflowed.
///
- /// Use this instead of `RestyleDamage::all()` because
- /// `RestyleDamage::all()` will result in unnecessary sequential resolution
+ /// Use this instead of `ServoRestyleDamage::all()` because
+ /// `ServoRestyleDamage::all()` will result in unnecessary sequential resolution
/// of generated content.
- fn rebuild_and_reflow() -> RestyleDamage {
+ fn rebuild_and_reflow() -> ServoRestyleDamage {
REPAINT | REPOSITION | STORE_OVERFLOW | BUBBLE_ISIZES | REFLOW_OUT_OF_FLOW | REFLOW |
RECONSTRUCT_FLOW
}
}
-impl RestyleDamage {
+impl ServoRestyleDamage {
/// Supposing a flow has the given `position` property and this damage,
/// 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 {
self & (REPAINT | REPOSITION | STORE_OVERFLOW | REFLOW_OUT_OF_FLOW |
RESOLVE_GENERATED_CONTENT)
@@ -91,7 +91,7 @@ impl RestyleDamage {
pub fn damage_for_child(self,
parent_is_absolutely_positioned: bool,
child_is_absolutely_positioned: bool)
- -> RestyleDamage {
+ -> ServoRestyleDamage {
match (parent_is_absolutely_positioned, child_is_absolutely_positioned) {
(false, true) => {
// 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> {
let mut first_elem = true;
@@ -162,8 +162,8 @@ macro_rules! add_if_not_equal(
})
);
-fn compute_damage(old: &ServoComputedValues, new: &ServoComputedValues) -> RestyleDamage {
- let mut damage = RestyleDamage::empty();
+fn compute_damage(old: &ServoComputedValues, new: &ServoComputedValues) -> ServoRestyleDamage {
+ let mut damage = ServoRestyleDamage::empty();
// This should check every CSS property, as enumerated in the fields of
// 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
// of the transform, then reflow is required to rebuild the layers.
if old.transform_requires_layer() != new.transform_requires_layer() {
- damage.insert(RestyleDamage::rebuild_and_reflow());
+ damage.insert(ServoRestyleDamage::rebuild_and_reflow());
}
damage
diff --git a/components/style/servo_selector_impl.rs b/components/style/servo/selector_impl.rs
index f0dd0b3695c..9e5516da9cc 100644
--- a/components/style/servo_selector_impl.rs
+++ b/components/style/servo/selector_impl.rs
@@ -384,8 +384,6 @@ impl MatchAttrGeneric for ServoElementSnapshot {
}
impl<E: Element<Impl=TheSelectorImpl>> ElementExt for E {
- type Snapshot = ServoElementSnapshot;
-
fn is_link(&self) -> bool {
self.match_non_ts_pseudo_class(NonTSPseudoClass::AnyLink)
}