Skip to content

Commit

Permalink
Remove extraneous references to flow tree objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Atkinson committed Aug 20, 2013
1 parent e4bfad1 commit eb58e4f
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 119 deletions.
33 changes: 18 additions & 15 deletions src/components/gfx/render_task.rs
Expand Up @@ -19,19 +19,22 @@ use render_context::RenderContext;

use std::cell::Cell;
use std::comm::{Chan, Port, SharedChan};
use extra::arc::Arc;

use servo_util::time::{ProfilerChan, profile};
use servo_util::time;

use extra::arc;

pub struct RenderLayer {
display_list: DisplayList<()>,


pub struct RenderLayer<T> {
display_list: Arc<DisplayList<T>>,
size: Size2D<uint>
}

pub enum Msg {
RenderMsg(RenderLayer),
pub enum Msg<T> {
RenderMsg(RenderLayer<T>),
ReRenderMsg(~[BufferRequest], f32, PipelineId, Epoch),
PaintPermissionGranted,
PaintPermissionRevoked,
Expand All @@ -56,24 +59,24 @@ pub fn BufferRequest(screen_rect: Rect<uint>, page_rect: Rect<f32>) -> BufferReq
}

#[deriving(Clone)]
pub struct RenderChan {
chan: SharedChan<Msg>,
pub struct RenderChan<T> {
chan: SharedChan<Msg<T>>,
}

impl RenderChan {
pub fn new(chan: Chan<Msg>) -> RenderChan {
impl<T> RenderChan<T> {
pub fn new(chan: Chan<Msg<T>>) -> RenderChan<T> {
RenderChan {
chan: SharedChan::new(chan),
}
}
pub fn send(&self, msg: Msg) {
pub fn send(&self, msg: Msg<T>) {
self.chan.send(msg);
}
}

struct RenderTask<C> {
struct RenderTask<C,T> {
id: PipelineId,
port: Port<Msg>,
port: Port<Msg<T>>,
compositor: C,
font_ctx: @mut FontContext,
opts: Opts,
Expand All @@ -84,7 +87,7 @@ struct RenderTask<C> {
share_gl_context: AzGLContext,

/// The layer to be rendered
render_layer: Option<RenderLayer>,
render_layer: Option<RenderLayer<T>>,
/// Permission to send paint messages to the compositor
paint_permission: bool,
/// Cached copy of last layers rendered
Expand All @@ -93,9 +96,9 @@ struct RenderTask<C> {
epoch: Epoch,
}

impl<C: RenderListener + Send> RenderTask<C> {
impl<C: RenderListener + Send,T:Send+Freeze> RenderTask<C,T> {
pub fn create(id: PipelineId,
port: Port<Msg>,
port: Port<Msg<T>>,
compositor: C,
opts: Opts,
profiler_chan: ProfilerChan) {
Expand Down Expand Up @@ -226,7 +229,7 @@ impl<C: RenderListener + Send> RenderTask<C> {

// Draw the display list.
do profile(time::RenderingDrawingCategory, self.profiler_chan.clone()) {
render_layer.display_list.draw_into_context(&ctx);
render_layer.display_list.get().draw_into_context(&ctx);
ctx.canvas.draw_target.flush();
}
}
Expand Down
26 changes: 14 additions & 12 deletions src/components/main/layout/aux.rs
Expand Up @@ -4,13 +4,20 @@

//! Code for managing the layout data in the DOM.

use layout::flow::FlowContext;
use layout::incremental::RestyleDamage;
use gfx::display_list::DisplayList;
use servo_util::range::Range;

use extra::arc::Arc;
use newcss::complete::CompleteSelectResults;
use script::dom::node::{AbstractNode, LayoutView};
use servo_util::tree::TreeNodeRef;

pub struct DisplayBoxes {
display_list: Option<Arc<DisplayList<AbstractNode<()>>>>,
range: Option<Range>,
}

/// Data that layout associates with a node.
pub struct LayoutData {
/// The results of CSS styling for this node.
Expand All @@ -19,8 +26,9 @@ pub struct LayoutData {
/// Description of how to account for recent style changes.
restyle_damage: Option<RestyleDamage>,

/// The CSS flow that this node is associated with.
flow: Option<FlowContext>,
/// The boxes assosiated with this flow.
/// Used for getBoundingClientRect and friends.
boxes: DisplayBoxes,
}

impl LayoutData {
Expand All @@ -29,7 +37,7 @@ impl LayoutData {
LayoutData {
style: None,
restyle_damage: None,
flow: None,
boxes: DisplayBoxes{ display_list: None, range: None },
}
}
}
Expand Down Expand Up @@ -65,14 +73,8 @@ impl LayoutAuxMethods for AbstractNode<LayoutView> {
/// box in the COW model) and populates it with an empty style object.
fn initialize_layout_data(self) -> Option<@mut LayoutData> {
if self.has_layout_data() {
{
let layout_data = &mut self.layout_data().flow;
match *layout_data {
Some(ref flow) => flow.teardown(),
None => ()
}
}
self.layout_data().flow = None;
self.layout_data().boxes.display_list = None;
self.layout_data().boxes.range = None;
None
} else {
let data = @mut LayoutData::new();
Expand Down
13 changes: 0 additions & 13 deletions src/components/main/layout/box_builder.rs
Expand Up @@ -4,7 +4,6 @@

//! Creates CSS boxes from a DOM tree.

use layout::aux::LayoutAuxMethods;
use layout::block::BlockFlowData;
use layout::float::FloatFlowData;
use layout::box::{GenericRenderBoxClass, ImageRenderBox, ImageRenderBoxClass, RenderBox};
Expand Down Expand Up @@ -334,18 +333,6 @@ impl LayoutTreeBuilder {
this_generator.pop_node(layout_ctx, cur_node);
self.simplify_children_of_flow(layout_ctx, &mut this_generator.flow);

// store reference to the flow context which contains any
// boxes that correspond to child_flow.node. These boxes may
// eventually be elided or split, but the mapping between
// nodes and FlowContexts should not change during layout.
let flow: &FlowContext = &this_generator.flow;
for child_flow in flow.children() {
do child_flow.with_base |child_node| {
let dom_node = child_node.node;
assert!(dom_node.has_layout_data());
dom_node.layout_data().flow = Some(child_flow);
}
}
Some(next_generator)
}

Expand Down
17 changes: 13 additions & 4 deletions src/components/main/layout/display_list_builder.rs
Expand Up @@ -6,20 +6,29 @@

use layout::box::RenderBox;
use layout::context::LayoutContext;
use std::cast::transmute;
use script::dom::node::AbstractNode;

use gfx;
use newcss;

/// Extra display list data is either nothing (if the display list is to be rendered) or the
/// originating render box (if the display list is generated for hit testing).
/// Display list data is usually an AbstractNode with view () to indicate
/// that nodes in this view shoud not really be touched. The idea is to
/// store the nodes in the display list and have layout transmute them.
pub trait ExtraDisplayListData {
fn new(box: RenderBox) -> Self;
}

/// The type representing the lack of extra display list data. This is used when sending display
/// list data off to be rendered.
pub type Nothing = ();

impl ExtraDisplayListData for AbstractNode<()> {
fn new (box: RenderBox) -> AbstractNode<()> {
unsafe {
transmute(box.node())
}
}
}

impl ExtraDisplayListData for Nothing {
fn new(_: RenderBox) -> Nothing {
()
Expand Down

0 comments on commit eb58e4f

Please sign in to comment.