mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
auto merge of #2468 : glennw/servo/show-traits, r=jdm
This commit is contained in:
commit
cad6dff95f
3 changed files with 40 additions and 1 deletions
|
@ -8,6 +8,7 @@ use geom::size::Size2D;
|
|||
use servo_util::cowarc::CowArc;
|
||||
use servo_util::geometry::{Au, max, min};
|
||||
use std::i32;
|
||||
use std::fmt;
|
||||
use style::computed_values::float;
|
||||
|
||||
/// The kind of float: left or right.
|
||||
|
@ -43,6 +44,12 @@ struct Float {
|
|||
kind: FloatKind,
|
||||
}
|
||||
|
||||
impl fmt::Show for Float {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f.buf, "bounds={} kind={:?}", self.bounds, self.kind)
|
||||
}
|
||||
}
|
||||
|
||||
/// Information about the floats next to a flow.
|
||||
///
|
||||
/// FIXME(pcwalton): When we have fast `MutexArc`s, try removing `#[deriving(Clone)]` and wrap in a
|
||||
|
@ -64,6 +71,12 @@ impl FloatList {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Show for FloatList {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f.buf, "max_top={} floats={:?}", self.max_top, self.floats)
|
||||
}
|
||||
}
|
||||
|
||||
/// Wraps a `FloatList` to avoid allocation in the common case of no floats.
|
||||
///
|
||||
/// FIXME(pcwalton): When we have fast `MutexArc`s, try removing `CowArc` and use a mutex instead.
|
||||
|
@ -114,6 +127,12 @@ pub struct PlacementInfo {
|
|||
pub kind: FloatKind
|
||||
}
|
||||
|
||||
impl fmt::Show for PlacementInfo {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f.buf, "size={} ceiling={} max_width={} kind={:?}", self.size, self.ceiling, self.max_width, self.kind)
|
||||
}
|
||||
}
|
||||
|
||||
fn range_intersect(top_1: Au, bottom_1: Au, top_2: Au, bottom_2: Au) -> (Au, Au) {
|
||||
(max(top_1, top_2), min(bottom_1, bottom_2))
|
||||
}
|
||||
|
@ -128,6 +147,19 @@ pub struct Floats {
|
|||
offset: Point2D<Au>,
|
||||
}
|
||||
|
||||
impl fmt::Show for Floats {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self.list.get() {
|
||||
None => {
|
||||
write!(f.buf, "[empty]")
|
||||
}
|
||||
Some(list) => {
|
||||
write!(f.buf, "offset={} floats={}", self.offset, list)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Floats {
|
||||
/// Creates a new `Floats` object.
|
||||
pub fn new() -> Floats {
|
||||
|
|
|
@ -12,6 +12,7 @@ use style::computed_values::{LPA_Auto, LPA_Length, LPA_Percentage, LP_Length, LP
|
|||
use style::ComputedValues;
|
||||
use servo_util::geometry::Au;
|
||||
use servo_util::geometry;
|
||||
use std::fmt;
|
||||
|
||||
/// A collapsible margin. See CSS 2.1 § 8.3.1.
|
||||
pub struct AdjoiningMargins {
|
||||
|
@ -249,6 +250,12 @@ pub struct IntrinsicWidths {
|
|||
pub surround_width: Au,
|
||||
}
|
||||
|
||||
impl fmt::Show for IntrinsicWidths {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f.buf, "min={}, pref={}, surr={}", self.minimum_width, self.preferred_width, self.surround_width)
|
||||
}
|
||||
}
|
||||
|
||||
impl IntrinsicWidths {
|
||||
pub fn new() -> IntrinsicWidths {
|
||||
IntrinsicWidths {
|
||||
|
|
|
@ -25,7 +25,7 @@ impl Default for Au {
|
|||
impl fmt::Show for Au {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let Au(n) = *self;
|
||||
write!(f.buf, "Au({})", n)
|
||||
write!(f.buf, "Au(au={} px={})", n, to_frac_px(*self))
|
||||
}}
|
||||
|
||||
impl Add<Au,Au> for Au {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue