Refactor flow tree construction and actually use display property.

This commit is contained in:
Eric Atkinson 2013-06-07 22:02:44 -07:00 committed by Patrick Walton
parent ff1178f7ca
commit 0bbf2fc30a
3 changed files with 28 additions and 18 deletions

View file

@ -627,19 +627,20 @@ pub impl RenderBox {
}, },
GenericRenderBoxClass(_) => { GenericRenderBoxClass(_) => {
// FIXME(pcwalton): This is somewhat of an abuse of the logging system.
debug!("%?", { debug!("%?", {
// Compute the text box bounds and draw a border surrounding them. // Compute the text box bounds and draw a border surrounding them.
do list.with_mut_ref |list| { do list.with_mut_ref |list| {
let border_display_item = ~BorderDisplayItem { let border_display_item = ~BorderDisplayItem {
base: BaseDisplayItem { base: BaseDisplayItem {
bounds: absolute_box_bounds, bounds: absolute_box_bounds,
extra: ExtraDisplayListData::new(*self), extra: ExtraDisplayListData::new(*self),
}, },
width: Au::from_px(1), width: Au::from_px(1),
color: rgb(0, 0, 0).to_gfx_color(), color: rgb(0, 0, 0).to_gfx_color(),
}; };
list.append_item(BorderDisplayItemClass(border_display_item)) list.append_item(BorderDisplayItemClass(border_display_item))
} }
}); });
} }

View file

@ -451,7 +451,7 @@ pub impl LayoutTreeBuilder {
let first_child = do parent_flow.with_base |parent_node| { let first_child = do parent_flow.with_base |parent_node| {
parent_node.first_child parent_node.first_child
}; };
for first_child.each |first_flow| { for first_child.each |&first_flow| {
if first_flow.starts_inline_flow() { if first_flow.starts_inline_flow() {
// FIXME: workaround for rust#6393 // FIXME: workaround for rust#6393
let mut do_remove = false; let mut do_remove = false;
@ -466,7 +466,7 @@ pub impl LayoutTreeBuilder {
} }
} }
if (do_remove) { if (do_remove) {
(*parent_flow).remove_child(*first_flow); (*parent_flow).remove_child(first_flow);
} }
} }
} }
@ -474,7 +474,7 @@ pub impl LayoutTreeBuilder {
let last_child = do parent_flow.with_base |parent_node| { let last_child = do parent_flow.with_base |parent_node| {
parent_node.last_child parent_node.last_child
}; };
for last_child.each |last_flow| { for last_child.each |&last_flow| {
if last_flow.starts_inline_flow() { if last_flow.starts_inline_flow() {
// FIXME: workaround for rust#6393 // FIXME: workaround for rust#6393
let mut do_remove = false; let mut do_remove = false;
@ -489,7 +489,7 @@ pub impl LayoutTreeBuilder {
} }
} }
if (do_remove) { if (do_remove) {
(*parent_flow).remove_child(*last_flow); (*parent_flow).remove_child(last_flow);
} }
} }
} }

View file

@ -15,7 +15,7 @@ use alert::{Alert, AlertMethods};
use core::libc::c_int; use core::libc::c_int;
use geom::point::Point2D; use geom::point::Point2D;
use geom::size::Size2D; use geom::size::Size2D;
use glut::glut::{ACTIVE_CTRL, DOUBLE, WindowHeight, WindowWidth}; use glut::glut::{ACTIVE_CTRL, DOUBLE, HAVE_PRECISE_MOUSE_WHEEL, WindowHeight, WindowWidth};
use glut::glut; use glut::glut;
use glut::machack; use glut::machack;
@ -92,10 +92,19 @@ impl WindowMethods<Application> for Window {
do glut::mouse_func |button, state, x, y| { do glut::mouse_func |button, state, x, y| {
if button < 3 { if button < 3 {
window.handle_mouse(button, state, x, y); window.handle_mouse(button, state, x, y);
} else {
window.handle_scroll(if button == 4 { -30.0 } else { 30.0 });
} }
} }
do glut::mouse_wheel_func |button, direction, x, y| {
let delta = if HAVE_PRECISE_MOUSE_WHEEL {
(direction as f32) / 10000.0
} else {
(direction as f32) * 30.0
};
println(fmt!("delta is %f", delta as float));
window.handle_scroll(delta);
}
machack::perform_scroll_wheel_hack(); machack::perform_scroll_wheel_hack();