Remove the layout debug methods.

Premature abstraction; nothing used the traits polymorphically. Furthermore,
they increased coupling between layout and the DOM.
This commit is contained in:
Patrick Walton 2013-05-28 16:55:07 -07:00
parent 0a95672236
commit 0ea1a94f8e
8 changed files with 14 additions and 45 deletions

View file

@ -12,7 +12,6 @@ use dom::characterdata::CharacterData;
use dom::document::Document;
use dom::element::{Element, ElementTypeId, HTMLImageElement, HTMLImageElementTypeId};
use dom::element::{HTMLStyleElementTypeId};
use layout::debug::DebugMethods;
use scripting::script_task::global_script_context;
use core::cast::transmute;
@ -354,16 +353,14 @@ impl<View> AbstractNode<View> {
obj: raw
}
}
}
impl<View> DebugMethods for AbstractNode<View> {
// Dumps the subtree rooted at this node, for debugging.
fn dump(&self) {
/// Dumps the subtree rooted at this node, for debugging.
pub fn dump(&self) {
self.dump_indent(0);
}
// Dumps the node tree, for debugging, with indentation.
fn dump_indent(&self, indent: uint) {
/// Dumps the node tree, for debugging, with indentation.
pub fn dump_indent(&self, indent: uint) {
let mut s = ~"";
for uint::range(0u, indent) |_i| {
s += ~" ";
@ -378,7 +375,8 @@ impl<View> DebugMethods for AbstractNode<View> {
}
}
fn debug_str(&self) -> ~str {
/// Returns a string that describes this node.
pub fn debug_str(&self) -> ~str {
fmt!("%?", self.type_id())
}
}

View file

@ -7,7 +7,6 @@
use css::node_style::StyledNode;
use dom::node::{AbstractNode, LayoutView};
use layout::context::LayoutContext;
use layout::debug::DebugMethods;
use layout::display_list_builder::{DisplayListBuilder, ToGfxColor};
use layout::flow::FlowContext;
use layout::text;
@ -795,15 +794,14 @@ pub impl RenderBox {
}
get_propagated_text_decoration(self.nearest_ancestor_element())
}
}
impl DebugMethods for RenderBox {
fn dump(&self) {
/// Dumps this node, for debugging.
pub fn dump(&self) {
self.dump_indent(0);
}
/// Dumps a render box for debugging, with indentation.
fn dump_indent(&self, indent: uint) {
pub fn dump_indent(&self, indent: uint) {
let mut string = ~"";
for uint::range(0u, indent) |_i| {
string += ~" ";
@ -814,7 +812,7 @@ impl DebugMethods for RenderBox {
}
/// Returns a debugging string describing this box.
fn debug_str(&self) -> ~str {
pub fn debug_str(&self) -> ~str {
let representation = match *self {
GenericRenderBoxClass(*) => ~"GenericRenderBox",
ImageRenderBoxClass(*) => ~"ImageRenderBox",

View file

@ -13,7 +13,6 @@ use layout::box::{GenericRenderBoxClass, ImageRenderBox, ImageRenderBoxClass, Re
use layout::box::{RenderBoxBase, RenderBoxType, RenderBox_Generic, RenderBox_Image};
use layout::box::{RenderBox_Text, UnscannedTextRenderBox, UnscannedTextRenderBoxClass};
use layout::context::LayoutContext;
use layout::debug::{BoxedMutDebugMethods, DebugMethods};
use layout::flow::{AbsoluteFlow, BlockFlow, FloatFlow, Flow_Absolute, Flow_Block, Flow_Float};
use layout::flow::{Flow_Inline, Flow_InlineBlock, Flow_Root, Flow_Table, FlowContext};
use layout::flow::{FlowContextType, FlowData, InlineBlockFlow, InlineFlow, TableFlow};

View file

@ -1,21 +0,0 @@
/* 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 trait BoxedMutDebugMethods {
fn dump(@mut self);
fn dump_indent(@mut self, ident: uint);
fn debug_str(@mut self) -> ~str;
}
pub trait BoxedDebugMethods {
fn dump(@self);
fn dump_indent(@self, ident: uint);
fn debug_str(@self) -> ~str;
}
pub trait DebugMethods {
fn dump(&self);
fn dump_indent(&self, ident: uint);
fn debug_str(&self) -> ~str;
}

View file

@ -29,7 +29,6 @@ use dom::node::{AbstractNode, LayoutView};
use layout::block::BlockFlowData;
use layout::box::RenderBox;
use layout::context::LayoutContext;
use layout::debug::DebugMethods;
use layout::display_list_builder::DisplayListBuilder;
use layout::inline::{InlineFlowData};
@ -372,15 +371,14 @@ impl<'self> FlowContext {
true
}
}
impl DebugMethods for FlowContext {
fn dump(&self) {
/// Dumps the flow tree for debugging.
pub fn dump(&self) {
self.dump_indent(0);
}
/// Dumps the flow tree, for debugging, with indentation.
fn dump_indent(&self, indent: uint) {
pub fn dump_indent(&self, indent: uint) {
let mut s = ~"|";
for uint::range(0, indent) |_i| {
s += ~"---- ";
@ -395,7 +393,7 @@ impl DebugMethods for FlowContext {
}
}
fn debug_str(&self) -> ~str {
pub fn debug_str(&self) -> ~str {
let repr = match *self {
InlineFlow(inline) => {
let mut s = inline.boxes.foldl(~"InlineFlow(children=", |s, box| {

View file

@ -8,7 +8,6 @@ use dom::node::{AbstractNode, LayoutView};
use layout::box::{CannotSplit, GenericRenderBoxClass, ImageRenderBoxClass, RenderBox};
use layout::box::{SplitDidFit, SplitDidNotFit, TextRenderBoxClass, UnscannedTextRenderBoxClass};
use layout::context::LayoutContext;
use layout::debug::{BoxedDebugMethods, BoxedMutDebugMethods, DebugMethods};
use layout::display_list_builder::DisplayListBuilder;
use layout::flow::{FlowContext, FlowData, InlineFlow};
use layout::text::{UnscannedMethods, adapt_textbox_with_range};

View file

@ -12,7 +12,6 @@ use dom::node::{AbstractNode, LayoutView};
use layout::aux::{LayoutData, LayoutAuxMethods};
use layout::box_builder::LayoutTreeBuilder;
use layout::context::LayoutContext;
use layout::debug::{BoxedMutDebugMethods, DebugMethods};
use layout::display_list_builder::{DisplayListBuilder, FlowDisplayListBuilderMethods};
use layout::flow::FlowContext;
use layout_interface::{AddStylesheetMsg, BuildData, BuildMsg, ContentBoxQuery, ContentBoxResponse};

View file

@ -107,7 +107,6 @@ pub mod layout {
pub mod box;
pub mod box_builder;
pub mod context;
pub mod debug;
pub mod display_list_builder;
pub mod flow;
pub mod layout_task;