Update rust-css, rust-netsurfcss

This commit is contained in:
Brian Anderson 2012-11-03 21:17:48 -07:00
parent 908f52edac
commit c3efff57bf
15 changed files with 56 additions and 53 deletions

@ -1 +1 @@
Subproject commit 9496e6d60d2a3f75aebcd63ad65a8d886a299960
Subproject commit 41d232fe56314d0406a3d846b70182405811865b

@ -1 +1 @@
Subproject commit 372d0334abe19eca4d9b9ba3e0948f81d586c14e
Subproject commit 2865a9282299ee21f70e2ebf409e6804767db160

View file

@ -23,7 +23,7 @@ use layout::layout_task;
use layout_task::{LayoutTask, BuildMsg, BuildData, AddStylesheet};
use resource::image_cache_task::ImageCacheTask;
use newcss::Stylesheet;
use newcss::stylesheet::Stylesheet;
use jsrt = js::rust::rt;
use js::rust::{cx, methods};

View file

@ -7,8 +7,10 @@ The only exception is that this is where inheritance is resolved.
use dom::node::Node;
use newcss::color::{Color, rgba};
use newcss::values::{CSSValue, Specified, Inherit, Length, Px, CSSBorderWidth, BdrWidthLength};
use newcss::ComputedStyle;
use newcss::units::{Length, Px};
use newcss::values::{CSSValue, Specified, Inherit};
use newcss::values::{CSSBorderWidth, CSSBorderWidthLength};
use newcss::computed::ComputedStyle;
pub trait ComputeStyles {
fn compute_background_color(&self) -> Color;
@ -28,19 +30,19 @@ impl Node: ComputeStyles {
}
fn compute_border_top_width(&self) -> CSSBorderWidth {
resolve(self, BdrWidthLength(Px(0.0)), |cs| cs.border_top_width() )
resolve(self, CSSBorderWidthLength(Px(0.0)), |cs| cs.border_top_width() )
}
fn compute_border_right_width(&self) -> CSSBorderWidth {
resolve(self, BdrWidthLength(Px(0.0)), |cs| cs.border_right_width() )
resolve(self, CSSBorderWidthLength(Px(0.0)), |cs| cs.border_right_width() )
}
fn compute_border_bottom_width(&self) -> CSSBorderWidth {
resolve(self, BdrWidthLength(Px(0.0)), |cs| cs.border_bottom_width() )
resolve(self, CSSBorderWidthLength(Px(0.0)), |cs| cs.border_bottom_width() )
}
fn compute_border_left_width(&self) -> CSSBorderWidth {
resolve(self, BdrWidthLength(Px(0.0)), |cs| cs.border_left_width() )
resolve(self, CSSBorderWidthLength(Px(0.0)), |cs| cs.border_left_width() )
}
fn compute_border_top_color(&self) -> Color {
@ -68,6 +70,5 @@ fn resolve<T>(node: &Node, default: T, get: &fn(cs: ComputedStyle) -> CSSValue<T
match move value {
Inherit => /* FIXME: need inheritance */ move default,
Specified(move value) => move value,
_ => fail
}
}

View file

@ -3,7 +3,7 @@
*/
use std::arc::{ARC, get, clone};
use dom::node::{Node, NodeTree};
use newcss::{SelectCtx, SelectResults};
use newcss::select::{SelectCtx, SelectResults};
use layout::context::LayoutContext;
use select_handler::NodeSelectHandler;

View file

@ -1,5 +1,5 @@
use dom::node::Node;
use newcss::SelectResults;
use newcss::select::SelectResults;
use std::cell::Cell;
trait NodeUtil {

View file

@ -1,5 +1,5 @@
use dom::node::{Node, NodeData, NodeTree, Doctype, Comment, Element, Text};
use newcss::SelectHandler;
use newcss::select::SelectHandler;
use util::tree;
pub struct NodeSelectHandler {

View file

@ -1,4 +1,4 @@
use newcss::values::Stylesheet;
use newcss::stylesheet::Stylesheet;
use dom::node::{NodeScope, Node};
use std::arc::ARC;

View file

@ -1,5 +1,5 @@
/* The core DOM types. Defines the basic DOM hierarchy as well as all the HTML elements. */
use newcss::SelectResults;
use newcss::select::SelectResults;
use dom::bindings;
use dom::document::Document;
use dom::element::{Attr, ElementData};

View file

@ -5,7 +5,7 @@ Some little helpers for hooking up the HTML parser with the CSS parser
use std::net::url::Url;
use std::cell::Cell;
use resource::resource_task::{ResourceTask, ProgressMsg, Load, Payload, Done};
use newcss::Stylesheet;
use newcss::stylesheet::Stylesheet;
use newcss::util::DataStream;
pub fn spawn_css_parser(url: Url, resource_task: ResourceTask) -> comm::Port<Stylesheet> {

View file

@ -1,6 +1,6 @@
use au = gfx::geometry;
use content::content_task::ContentTask;
use newcss::Stylesheet;
use newcss::stylesheet::Stylesheet;
use dom::cow;
use dom::element::*;
use dom::event::{Event, ReflowEvent};

View file

@ -9,9 +9,10 @@ use core::dvec::DVec;
use core::to_str::ToStr;
use core::rand;
use css::compute::ComputeStyles;
use newcss::values::{BoxSizing, Length, Px, CSSDisplay, Specified, BgColor, BgColorTransparent};
use newcss::values::{BdrColor, PosAbsolute};
use newcss::values::{BdrWidthLength, BdrWidthMedium};
use newcss::units::{BoxSizing, Length, Px};
use newcss::values::{CSSDisplay, Specified, CSSBackgroundColorColor, CSSBackgroundColorTransparent};
use newcss::values::{CSSBorderColor, CSSPositionAbsolute};
use newcss::values::{CSSBorderWidthLength, CSSBorderWidthMedium};
use newcss::color::{Color, rgba};
use dom::element::{ElementKind, HTMLDivElement, HTMLImageElement};
use dom::node::{Element, Node, NodeData, NodeKind, NodeTree};
@ -442,10 +443,10 @@ impl RenderBox : RenderBoxMethods {
let left_width = self.d().node.compute_border_left_width();
match (top_width, right_width, bottom_width, left_width) {
(BdrWidthLength(Px(top)),
BdrWidthLength(Px(right)),
BdrWidthLength(Px(bottom)),
BdrWidthLength(Px(left))) => {
(CSSBorderWidthLength(Px(top)),
CSSBorderWidthLength(Px(right)),
CSSBorderWidthLength(Px(bottom)),
CSSBorderWidthLength(Px(left))) => {
let top_au = au::from_frac_px(top);
let right_au = au::from_frac_px(right);
let bottom_au = au::from_frac_px(bottom);
@ -474,10 +475,10 @@ impl RenderBox : RenderBoxMethods {
fail ~"unimplemented border widths";
}
}
(BdrWidthMedium,
BdrWidthMedium,
BdrWidthMedium,
BdrWidthMedium) => {
(CSSBorderWidthMedium,
CSSBorderWidthMedium,
CSSBorderWidthMedium,
CSSBorderWidthMedium) => {
// FIXME: This seems to be the default for non-root nodes. For now we'll ignore it
warn!("ignoring medium border widths");
}

View file

@ -1,8 +1,8 @@
/** Creates CSS boxes from a DOM. */
use au = gfx::geometry;
use core::dvec::DVec;
use newcss::values::{CSSDisplay, DisplayBlock, DisplayInline, DisplayInlineBlock, DisplayNone};
use newcss::values::{Inherit, Initial, Specified};
use newcss::values::{CSSDisplay, CSSDisplayBlock, CSSDisplayInline, CSSDisplayInlineBlock, CSSDisplayNone};
use newcss::values::{Inherit, Specified};
use dom::element::*;
use dom::node::{Comment, Doctype, Element, Text, Node, LayoutData};
use image::holder::ImageHolder;
@ -52,23 +52,23 @@ priv fn simulate_UA_display_rules(node: Node) -> CSSDisplay {
Specified(v) => v
}
};*/
let resolved = DisplayInline;
if (resolved == DisplayNone) { return resolved; }
let resolved = CSSDisplayInline;
if (resolved == CSSDisplayNone) { return resolved; }
do node.read |n| {
match n.kind {
~Doctype(*) | ~Comment(*) => DisplayNone,
~Text(*) => DisplayInline,
~Doctype(*) | ~Comment(*) => CSSDisplayNone,
~Text(*) => CSSDisplayInline,
~Element(e) => match e.kind {
~HTMLHeadElement(*) => DisplayNone,
~HTMLScriptElement(*) => DisplayNone,
~HTMLParagraphElement(*) => DisplayBlock,
~HTMLDivElement(*) => DisplayBlock,
~HTMLBodyElement(*) => DisplayBlock,
~HTMLHeadingElement(*) => DisplayBlock,
~HTMLHtmlElement(*) => DisplayBlock,
~HTMLUListElement(*) => DisplayBlock,
~HTMLOListElement(*) => DisplayBlock,
~HTMLHeadElement(*) => CSSDisplayNone,
~HTMLScriptElement(*) => CSSDisplayNone,
~HTMLParagraphElement(*) => CSSDisplayBlock,
~HTMLDivElement(*) => CSSDisplayBlock,
~HTMLBodyElement(*) => CSSDisplayBlock,
~HTMLHeadingElement(*) => CSSDisplayBlock,
~HTMLHtmlElement(*) => CSSDisplayBlock,
~HTMLUListElement(*) => CSSDisplayBlock,
~HTMLOListElement(*) => CSSDisplayBlock,
_ => resolved
}
}
@ -223,15 +223,15 @@ impl BuilderContext {
fn containing_context_for_display(display: CSSDisplay,
builder: &LayoutTreeBuilder) -> BuilderContext {
match (display, self.default_collector.flow) {
(DisplayBlock, @RootFlow(*)) => self.create_child_flow_of_type(Flow_Block, builder),
(DisplayBlock, @BlockFlow(*)) => {
(CSSDisplayBlock, @RootFlow(*)) => self.create_child_flow_of_type(Flow_Block, builder),
(CSSDisplayBlock, @BlockFlow(*)) => {
self.clear_inline_collector();
self.create_child_flow_of_type(Flow_Block, builder)
},
(DisplayInline, @InlineFlow(*)) => self.clone(),
(DisplayInlineBlock, @InlineFlow(*)) => self.clone(),
(DisplayInline, @BlockFlow(*)) => self.get_inline_collector(builder),
(DisplayInlineBlock, @BlockFlow(*)) => self.get_inline_collector(builder),
(CSSDisplayInline, @InlineFlow(*)) => self.clone(),
(CSSDisplayInlineBlock, @InlineFlow(*)) => self.clone(),
(CSSDisplayInline, @BlockFlow(*)) => self.get_inline_collector(builder),
(CSSDisplayInlineBlock, @BlockFlow(*)) => self.get_inline_collector(builder),
_ => self.clone()
}
}
@ -251,7 +251,7 @@ impl LayoutTreeBuilder {
// TODO: remove this once UA styles work
// TODO: handle interactions with 'float', 'position' (CSS 2.1, Section 9.7)
let simulated_display = match simulate_UA_display_rules(cur_node) {
DisplayNone => return, // tree ends here if 'display: none'
CSSDisplayNone => return, // tree ends here if 'display: none'
v => v
};

View file

@ -2,7 +2,8 @@ export DisplayListBuilder;
use au = gfx::geometry;
use au::Au;
use newcss::values::{BgColor, BgColorTransparent, Specified};
use newcss::values::Specified;
use newcss::values::{CSSBackgroundColorColor, CSSBackgroundColorTransparent};
use dom::node::{Text, NodeScope};
use dom::cow::Scope;
use dvec::DVec;

View file

@ -7,7 +7,7 @@ use au = gfx::geometry;
use au::Au;
use content::content_task;
use core::dvec::DVec;
use newcss::Stylesheet;
use newcss::stylesheet::Stylesheet;
use dl = gfx::display_list;
use dom::event::{Event, ReflowEvent};
use dom::node::{Node, LayoutData};
@ -36,7 +36,7 @@ use layout::traverse::*;
use comm::*;
use task::*;
use core::mutable::Mut;
use newcss::SelectCtx;
use newcss::select::SelectCtx;
pub type LayoutTask = comm::Chan<Msg>;