style: Remove PresentationalHintsSynthesizer.

This is not really an useful abstraction, and I never knew how to spell it.
This commit is contained in:
Emilio Cobos Álvarez 2017-10-26 11:40:44 +02:00
parent a814fc578f
commit 6c796b50ec
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
4 changed files with 48 additions and 54 deletions

View file

@ -69,7 +69,7 @@ use style::computed_values::display;
use style::context::SharedStyleContext; use style::context::SharedStyleContext;
use style::data::ElementData; use style::data::ElementData;
use style::dom::{DomChildren, LayoutIterator, NodeInfo, OpaqueNode}; use style::dom::{DomChildren, LayoutIterator, NodeInfo, OpaqueNode};
use style::dom::{PresentationalHintsSynthesizer, TElement, TNode}; use style::dom::{TElement, TNode};
use style::element_state::*; use style::element_state::*;
use style::font_metrics::ServoMetricsProvider; use style::font_metrics::ServoMetricsProvider;
use style::properties::{ComputedValues, PropertyDeclarationBlock}; use style::properties::{ComputedValues, PropertyDeclarationBlock};
@ -338,18 +338,6 @@ impl<'le> fmt::Debug for ServoLayoutElement<'le> {
} }
} }
impl<'le> PresentationalHintsSynthesizer for ServoLayoutElement<'le> {
fn synthesize_presentational_hints_for_legacy_attributes<V>(&self,
_visited_handling: VisitedHandlingMode,
hints: &mut V)
where V: Push<ApplicableDeclarationBlock>
{
unsafe {
self.element.synthesize_presentational_hints_for_legacy_attributes(hints);
}
}
}
impl<'le> TElement for ServoLayoutElement<'le> { impl<'le> TElement for ServoLayoutElement<'le> {
type ConcreteNode = ServoLayoutNode<'le>; type ConcreteNode = ServoLayoutNode<'le>;
type TraversalChildrenIterator = DomChildren<Self::ConcreteNode>; type TraversalChildrenIterator = DomChildren<Self::ConcreteNode>;
@ -520,6 +508,19 @@ impl<'le> TElement for ServoLayoutElement<'le> {
// FIXME(emilio): We should be able to give the right answer though! // FIXME(emilio): We should be able to give the right answer though!
false false
} }
fn synthesize_presentational_hints_for_legacy_attributes<V>(
&self,
_visited_handling: VisitedHandlingMode,
hints: &mut V,
)
where
V: Push<ApplicableDeclarationBlock>,
{
unsafe {
self.element.synthesize_presentational_hints_for_legacy_attributes(hints);
}
}
} }
impl<'le> PartialEq for ServoLayoutElement<'le> { impl<'le> PartialEq for ServoLayoutElement<'le> {
@ -1245,10 +1246,3 @@ impl<'le> ::selectors::Element for ServoThreadSafeLayoutElement<'le> {
false false
} }
} }
impl<'le> PresentationalHintsSynthesizer for ServoThreadSafeLayoutElement<'le> {
fn synthesize_presentational_hints_for_legacy_attributes<V>(&self,
_visited_handling: VisitedHandlingMode,
_hints: &mut V)
where V: Push<ApplicableDeclarationBlock> {}
}

View file

@ -20,7 +20,7 @@ use style::attr::AttrValue;
use style::computed_values::display; use style::computed_values::display;
use style::context::SharedStyleContext; use style::context::SharedStyleContext;
use style::data::ElementData; use style::data::ElementData;
use style::dom::{LayoutIterator, NodeInfo, PresentationalHintsSynthesizer, TNode}; use style::dom::{LayoutIterator, NodeInfo, TNode};
use style::dom::OpaqueNode; use style::dom::OpaqueNode;
use style::font_metrics::ServoMetricsProvider; use style::font_metrics::ServoMetricsProvider;
use style::properties::{CascadeFlags, ComputedValues}; use style::properties::{CascadeFlags, ComputedValues};
@ -290,10 +290,14 @@ pub trait DangerousThreadSafeLayoutNode: ThreadSafeLayoutNode {
unsafe fn dangerous_next_sibling(&self) -> Option<Self>; unsafe fn dangerous_next_sibling(&self) -> Option<Self>;
} }
pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug + pub trait ThreadSafeLayoutElement
::selectors::Element<Impl=SelectorImpl> + : Clone
GetLayoutData + + Copy
PresentationalHintsSynthesizer { + Sized
+ Debug
+ ::selectors::Element<Impl=SelectorImpl>
+ GetLayoutData
{
type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<ConcreteThreadSafeLayoutElement = Self>; type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<ConcreteThreadSafeLayoutElement = Self>;
fn as_node(&self) -> Self::ConcreteThreadSafeLayoutNode; fn as_node(&self) -> Self::ConcreteThreadSafeLayoutNode;

View file

@ -311,16 +311,6 @@ fn fmt_subtree<F, N: TNode>(f: &mut fmt::Formatter, stringify: &F, n: N, indent:
Ok(()) Ok(())
} }
/// A trait used to synthesize presentational hints for HTML element attributes.
pub trait PresentationalHintsSynthesizer {
/// Generate the proper applicable declarations due to presentational hints,
/// and insert them into `hints`.
fn synthesize_presentational_hints_for_legacy_attributes<V>(&self,
visited_handling: VisitedHandlingMode,
hints: &mut V)
where V: Push<ApplicableDeclarationBlock>;
}
/// The element trait, the main abstraction the style crate acts over. /// The element trait, the main abstraction the style crate acts over.
pub trait TElement pub trait TElement
: Eq : Eq
@ -331,7 +321,6 @@ pub trait TElement
+ Copy + Copy
+ Clone + Clone
+ SelectorsElement<Impl = SelectorImpl> + SelectorsElement<Impl = SelectorImpl>
+ PresentationalHintsSynthesizer
{ {
/// The concrete node type. /// The concrete node type.
type ConcreteNode: TNode<ConcreteElement = Self>; type ConcreteNode: TNode<ConcreteElement = Self>;
@ -808,6 +797,16 @@ pub trait TElement
/// Returns whether this element is the main body element of the HTML /// Returns whether this element is the main body element of the HTML
/// document it is on. /// document it is on.
fn is_html_document_body_element(&self) -> bool; fn is_html_document_body_element(&self) -> bool;
/// Generate the proper applicable declarations due to presentational hints,
/// and insert them into `hints`.
fn synthesize_presentational_hints_for_legacy_attributes<V>(
&self,
visited_handling: VisitedHandlingMode,
hints: &mut V,
)
where
V: Push<ApplicableDeclarationBlock>;
} }
/// TNode and TElement aren't Send because we want to be careful and explicit /// TNode and TElement aren't Send because we want to be careful and explicit

View file

@ -20,8 +20,7 @@ use applicable_declarations::ApplicableDeclarationBlock;
use atomic_refcell::{AtomicRefCell, AtomicRef, AtomicRefMut}; use atomic_refcell::{AtomicRefCell, AtomicRef, AtomicRefMut};
use context::{QuirksMode, SharedStyleContext, PostAnimationTasks, UpdateAnimationsTasks}; use context::{QuirksMode, SharedStyleContext, PostAnimationTasks, UpdateAnimationsTasks};
use data::ElementData; use data::ElementData;
use dom::{LayoutIterator, NodeInfo, TElement, TNode}; use dom::{LayoutIterator, NodeInfo, OpaqueNode, TElement, TNode};
use dom::{OpaqueNode, PresentationalHintsSynthesizer};
use element_state::{ElementState, DocumentState, NS_DOCUMENT_STATE_WINDOW_INACTIVE}; use element_state::{ElementState, DocumentState, NS_DOCUMENT_STATE_WINDOW_INACTIVE};
use error_reporting::ParseErrorReporter; use error_reporting::ParseErrorReporter;
use font_metrics::{FontMetrics, FontMetricsProvider, FontMetricsQueryResult}; use font_metrics::{FontMetrics, FontMetricsProvider, FontMetricsQueryResult};
@ -1526,23 +1525,7 @@ impl<'le> TElement for GeckoElement<'le> {
unsafe { bindings::Gecko_IsDocumentBody(self.0) } unsafe { bindings::Gecko_IsDocumentBody(self.0) }
} }
}
impl<'le> PartialEq for GeckoElement<'le> {
fn eq(&self, other: &Self) -> bool {
self.0 as *const _ == other.0 as *const _
}
}
impl<'le> Eq for GeckoElement<'le> {}
impl<'le> Hash for GeckoElement<'le> {
fn hash<H: Hasher>(&self, state: &mut H) {
(self.0 as *const _).hash(state);
}
}
impl<'le> PresentationalHintsSynthesizer for GeckoElement<'le> {
fn synthesize_presentational_hints_for_legacy_attributes<V>( fn synthesize_presentational_hints_for_legacy_attributes<V>(
&self, &self,
visited_handling: VisitedHandlingMode, visited_handling: VisitedHandlingMode,
@ -1690,6 +1673,20 @@ impl<'le> PresentationalHintsSynthesizer for GeckoElement<'le> {
} }
} }
impl<'le> PartialEq for GeckoElement<'le> {
fn eq(&self, other: &Self) -> bool {
self.0 as *const _ == other.0 as *const _
}
}
impl<'le> Eq for GeckoElement<'le> {}
impl<'le> Hash for GeckoElement<'le> {
fn hash<H: Hasher>(&self, state: &mut H) {
(self.0 as *const _).hash(state);
}
}
impl<'le> ::selectors::Element for GeckoElement<'le> { impl<'le> ::selectors::Element for GeckoElement<'le> {
type Impl = SelectorImpl; type Impl = SelectorImpl;