mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Add some fmt::Debug implementations
This commit is contained in:
parent
477cae67df
commit
bc71e8b65b
7 changed files with 59 additions and 4 deletions
|
@ -79,6 +79,7 @@ use std::borrow::Cow;
|
||||||
use std::cell::{Cell, Ref};
|
use std::cell::{Cell, Ref};
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
use std::fmt;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
@ -115,6 +116,16 @@ pub struct Element {
|
||||||
atomic_flags: AtomicElementFlags,
|
atomic_flags: AtomicElementFlags,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for Element {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
try!(write!(f, "<{}", self.local_name));
|
||||||
|
if let Some(ref id) = *self.id_attribute.borrow() {
|
||||||
|
try!(write!(f, " id={}", id));
|
||||||
|
}
|
||||||
|
write!(f, ">")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, HeapSizeOf)]
|
#[derive(PartialEq, HeapSizeOf)]
|
||||||
pub enum ElementCreator {
|
pub enum ElementCreator {
|
||||||
ParserCreated,
|
ParserCreated,
|
||||||
|
|
|
@ -49,6 +49,7 @@ use script_layout_interface::{HTMLCanvasData, LayoutNodeType, TrustedNodeAddress
|
||||||
use script_layout_interface::{OpaqueStyleAndLayoutData, PartialStyleAndLayoutData};
|
use script_layout_interface::{OpaqueStyleAndLayoutData, PartialStyleAndLayoutData};
|
||||||
use selectors::matching::{DeclarationBlock, ElementFlags};
|
use selectors::matching::{DeclarationBlock, ElementFlags};
|
||||||
use selectors::parser::{AttrSelector, NamespaceConstraint};
|
use selectors::parser::{AttrSelector, NamespaceConstraint};
|
||||||
|
use std::fmt;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::mem::{transmute, transmute_copy};
|
use std::mem::{transmute, transmute_copy};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
@ -405,6 +406,16 @@ pub struct ServoLayoutElement<'le> {
|
||||||
chain: PhantomData<&'le ()>,
|
chain: PhantomData<&'le ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'le> fmt::Debug for ServoLayoutElement<'le> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
try!(write!(f, "<{}", self.element.local_name()));
|
||||||
|
if let &Some(ref id) = unsafe { &*self.element.id_attribute() } {
|
||||||
|
try!(write!(f, " id={}", id));
|
||||||
|
}
|
||||||
|
write!(f, ">")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'le> PresentationalHintsSynthetizer for ServoLayoutElement<'le> {
|
impl<'le> PresentationalHintsSynthetizer for ServoLayoutElement<'le> {
|
||||||
fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, hints: &mut V)
|
fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, hints: &mut V)
|
||||||
where V: Push<DeclarationBlock<Vec<PropertyDeclaration>>>
|
where V: Push<DeclarationBlock<Vec<PropertyDeclaration>>>
|
||||||
|
@ -926,7 +937,7 @@ impl<ConcreteNode> Iterator for ThreadSafeLayoutNodeChildrenIterator<ConcreteNod
|
||||||
|
|
||||||
/// A wrapper around elements that ensures layout can only
|
/// A wrapper around elements that ensures layout can only
|
||||||
/// ever access safe properties and cannot race on elements.
|
/// ever access safe properties and cannot race on elements.
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct ServoThreadSafeLayoutElement<'le> {
|
pub struct ServoThreadSafeLayoutElement<'le> {
|
||||||
element: &'le Element,
|
element: &'le Element,
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ use gfx_traits::{ByteIndex, LayerId, LayerType};
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use range::Range;
|
use range::Range;
|
||||||
use restyle_damage::RestyleDamage;
|
use restyle_damage::RestyleDamage;
|
||||||
|
use std::fmt::Debug;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use string_cache::{Atom, Namespace};
|
use string_cache::{Atom, Namespace};
|
||||||
use style::computed_values::display;
|
use style::computed_values::display;
|
||||||
|
@ -350,7 +351,7 @@ 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 +
|
pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug +
|
||||||
::selectors::Element<Impl=ServoSelectorImpl> +
|
::selectors::Element<Impl=ServoSelectorImpl> +
|
||||||
PresentationalHintsSynthetizer {
|
PresentationalHintsSynthetizer {
|
||||||
type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<ConcreteThreadSafeLayoutElement = Self>;
|
type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<ConcreteThreadSafeLayoutElement = Self>;
|
||||||
|
|
|
@ -201,7 +201,7 @@ pub trait PresentationalHintsSynthetizer {
|
||||||
where V: Push<DeclarationBlock<Vec<PropertyDeclaration>>>;
|
where V: Push<DeclarationBlock<Vec<PropertyDeclaration>>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait TElement : PartialEq + 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>;
|
||||||
|
|
||||||
|
|
|
@ -803,7 +803,7 @@ impl<T: ToCss> ToCss for DeclaredValue<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Debug)]
|
#[derive(PartialEq, Clone)]
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
pub enum PropertyDeclaration {
|
pub enum PropertyDeclaration {
|
||||||
% for property in data.longhands:
|
% for property in data.longhands:
|
||||||
|
@ -867,6 +867,24 @@ impl fmt::Display for PropertyDeclarationName {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for PropertyDeclaration {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
try!(write!(f, "{}: ", self.name()));
|
||||||
|
match *self {
|
||||||
|
% for property in data.longhands:
|
||||||
|
% if not property.derived_from:
|
||||||
|
PropertyDeclaration::${property.camel_case}(ref value) => value.to_css(f),
|
||||||
|
% endif
|
||||||
|
% endfor
|
||||||
|
PropertyDeclaration::Custom(_, ref value) => value.to_css(f),
|
||||||
|
% if any(property.derived_from for property in data.longhands):
|
||||||
|
_ => Err(fmt::Error),
|
||||||
|
% endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ToCss for PropertyDeclaration {
|
impl ToCss for PropertyDeclaration {
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
match *self {
|
match *self {
|
||||||
|
|
|
@ -21,6 +21,7 @@ use selectors::parser::Selector;
|
||||||
use sink::Push;
|
use sink::Push;
|
||||||
use smallvec::VecLike;
|
use smallvec::VecLike;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::fmt;
|
||||||
use std::hash::BuildHasherDefault;
|
use std::hash::BuildHasherDefault;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
|
@ -275,6 +276,7 @@ impl Stylist {
|
||||||
parent: &Arc<ComputedValues>)
|
parent: &Arc<ComputedValues>)
|
||||||
-> Option<Arc<ComputedValues>>
|
-> Option<Arc<ComputedValues>>
|
||||||
where E: Element<Impl=TheSelectorImpl> +
|
where E: Element<Impl=TheSelectorImpl> +
|
||||||
|
Debug +
|
||||||
PresentationalHintsSynthetizer
|
PresentationalHintsSynthetizer
|
||||||
{
|
{
|
||||||
debug_assert!(TheSelectorImpl::pseudo_element_cascade_type(pseudo).is_lazy());
|
debug_assert!(TheSelectorImpl::pseudo_element_cascade_type(pseudo).is_lazy());
|
||||||
|
@ -343,6 +345,7 @@ impl Stylist {
|
||||||
pseudo_element: Option<&PseudoElement>,
|
pseudo_element: Option<&PseudoElement>,
|
||||||
applicable_declarations: &mut V) -> StyleRelations
|
applicable_declarations: &mut V) -> StyleRelations
|
||||||
where E: Element<Impl=TheSelectorImpl> +
|
where E: Element<Impl=TheSelectorImpl> +
|
||||||
|
fmt::Debug +
|
||||||
PresentationalHintsSynthetizer,
|
PresentationalHintsSynthetizer,
|
||||||
V: Push<DeclarationBlock> + VecLike<DeclarationBlock>
|
V: Push<DeclarationBlock> + VecLike<DeclarationBlock>
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,6 +34,7 @@ use selectors::matching::DeclarationBlock;
|
||||||
use selectors::parser::{AttrSelector, NamespaceConstraint};
|
use selectors::parser::{AttrSelector, NamespaceConstraint};
|
||||||
use snapshot::GeckoElementSnapshot;
|
use snapshot::GeckoElementSnapshot;
|
||||||
use snapshot_helpers;
|
use snapshot_helpers;
|
||||||
|
use std::fmt;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::ops::BitOr;
|
use std::ops::BitOr;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
@ -382,6 +383,16 @@ pub struct GeckoElement<'le> {
|
||||||
chain: PhantomData<&'le ()>,
|
chain: PhantomData<&'le ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'le> fmt::Debug for GeckoElement<'le> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
try!(write!(f, "<{}", self.get_local_name()));
|
||||||
|
if let Some(id) = self.get_id() {
|
||||||
|
try!(write!(f, " id={}", id));
|
||||||
|
}
|
||||||
|
write!(f, ">")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'le> GeckoElement<'le> {
|
impl<'le> GeckoElement<'le> {
|
||||||
pub unsafe fn from_raw(el: *mut RawGeckoElement) -> GeckoElement<'le> {
|
pub unsafe fn from_raw(el: *mut RawGeckoElement) -> GeckoElement<'le> {
|
||||||
GeckoElement {
|
GeckoElement {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue