mirror of
https://github.com/servo/servo.git
synced 2025-06-29 19:43:39 +01:00
Stop using associated types for the concrete ElementSnapshot implementation.
MozReview-Commit-ID: LS23s2RbMBg
This commit is contained in:
parent
9588065120
commit
b69fdad8e4
9 changed files with 28 additions and 30 deletions
|
@ -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);
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -66,7 +66,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, ServoSelectorImpl, Snapshot};
|
||||
use style::selector_matching::ApplicableDeclarationBlock;
|
||||
use style::sink::Push;
|
||||
use style::str::is_whitespace;
|
||||
|
@ -382,7 +382,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()
|
||||
}
|
||||
|
|
|
@ -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, 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);
|
||||
|
|
|
@ -691,8 +691,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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
//! 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};
|
||||
|
||||
|
@ -14,14 +13,20 @@ pub type AttrValue = <TheSelectorImpl as SelectorImpl>::AttrValue;
|
|||
#[cfg(feature = "servo")]
|
||||
pub use servo_selector_impl::*;
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
pub use servo_selector_impl::{ServoSelectorImpl as TheSelectorImpl, ServoElementSnapshot as ElementSnapshot};
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
pub use gecko::selector_impl::*;
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
pub use servo_selector_impl::ServoSelectorImpl as TheSelectorImpl;
|
||||
|
||||
#[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;
|
||||
|
||||
/// This function determines if a pseudo-element is eagerly cascaded or not.
|
||||
///
|
||||
|
@ -71,8 +76,6 @@ impl PseudoElementCascadeType {
|
|||
}
|
||||
|
||||
pub trait ElementExt: Element<Impl=TheSelectorImpl> {
|
||||
type Snapshot: restyle_hints::ElementSnapshot + 'static;
|
||||
|
||||
fn is_link(&self) -> bool;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue