mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Update rust-css, rust-netsurfcss
This commit is contained in:
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
|
|
@ -23,7 +23,7 @@ use layout::layout_task;
|
||||||
use layout_task::{LayoutTask, BuildMsg, BuildData, AddStylesheet};
|
use layout_task::{LayoutTask, BuildMsg, BuildData, AddStylesheet};
|
||||||
use resource::image_cache_task::ImageCacheTask;
|
use resource::image_cache_task::ImageCacheTask;
|
||||||
|
|
||||||
use newcss::Stylesheet;
|
use newcss::stylesheet::Stylesheet;
|
||||||
|
|
||||||
use jsrt = js::rust::rt;
|
use jsrt = js::rust::rt;
|
||||||
use js::rust::{cx, methods};
|
use js::rust::{cx, methods};
|
||||||
|
|
|
@ -7,8 +7,10 @@ The only exception is that this is where inheritance is resolved.
|
||||||
|
|
||||||
use dom::node::Node;
|
use dom::node::Node;
|
||||||
use newcss::color::{Color, rgba};
|
use newcss::color::{Color, rgba};
|
||||||
use newcss::values::{CSSValue, Specified, Inherit, Length, Px, CSSBorderWidth, BdrWidthLength};
|
use newcss::units::{Length, Px};
|
||||||
use newcss::ComputedStyle;
|
use newcss::values::{CSSValue, Specified, Inherit};
|
||||||
|
use newcss::values::{CSSBorderWidth, CSSBorderWidthLength};
|
||||||
|
use newcss::computed::ComputedStyle;
|
||||||
|
|
||||||
pub trait ComputeStyles {
|
pub trait ComputeStyles {
|
||||||
fn compute_background_color(&self) -> Color;
|
fn compute_background_color(&self) -> Color;
|
||||||
|
@ -28,19 +30,19 @@ impl Node: ComputeStyles {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compute_border_top_width(&self) -> CSSBorderWidth {
|
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 {
|
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 {
|
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 {
|
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 {
|
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 {
|
match move value {
|
||||||
Inherit => /* FIXME: need inheritance */ move default,
|
Inherit => /* FIXME: need inheritance */ move default,
|
||||||
Specified(move value) => move value,
|
Specified(move value) => move value,
|
||||||
_ => fail
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
use std::arc::{ARC, get, clone};
|
use std::arc::{ARC, get, clone};
|
||||||
use dom::node::{Node, NodeTree};
|
use dom::node::{Node, NodeTree};
|
||||||
use newcss::{SelectCtx, SelectResults};
|
use newcss::select::{SelectCtx, SelectResults};
|
||||||
use layout::context::LayoutContext;
|
use layout::context::LayoutContext;
|
||||||
use select_handler::NodeSelectHandler;
|
use select_handler::NodeSelectHandler;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use dom::node::Node;
|
use dom::node::Node;
|
||||||
use newcss::SelectResults;
|
use newcss::select::SelectResults;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
|
||||||
trait NodeUtil {
|
trait NodeUtil {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use dom::node::{Node, NodeData, NodeTree, Doctype, Comment, Element, Text};
|
use dom::node::{Node, NodeData, NodeTree, Doctype, Comment, Element, Text};
|
||||||
use newcss::SelectHandler;
|
use newcss::select::SelectHandler;
|
||||||
use util::tree;
|
use util::tree;
|
||||||
|
|
||||||
pub struct NodeSelectHandler {
|
pub struct NodeSelectHandler {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use newcss::values::Stylesheet;
|
use newcss::stylesheet::Stylesheet;
|
||||||
use dom::node::{NodeScope, Node};
|
use dom::node::{NodeScope, Node};
|
||||||
use std::arc::ARC;
|
use std::arc::ARC;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* The core DOM types. Defines the basic DOM hierarchy as well as all the HTML elements. */
|
/* 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::bindings;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::element::{Attr, ElementData};
|
use dom::element::{Attr, ElementData};
|
||||||
|
|
|
@ -5,7 +5,7 @@ Some little helpers for hooking up the HTML parser with the CSS parser
|
||||||
use std::net::url::Url;
|
use std::net::url::Url;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use resource::resource_task::{ResourceTask, ProgressMsg, Load, Payload, Done};
|
use resource::resource_task::{ResourceTask, ProgressMsg, Load, Payload, Done};
|
||||||
use newcss::Stylesheet;
|
use newcss::stylesheet::Stylesheet;
|
||||||
use newcss::util::DataStream;
|
use newcss::util::DataStream;
|
||||||
|
|
||||||
pub fn spawn_css_parser(url: Url, resource_task: ResourceTask) -> comm::Port<Stylesheet> {
|
pub fn spawn_css_parser(url: Url, resource_task: ResourceTask) -> comm::Port<Stylesheet> {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use au = gfx::geometry;
|
use au = gfx::geometry;
|
||||||
use content::content_task::ContentTask;
|
use content::content_task::ContentTask;
|
||||||
use newcss::Stylesheet;
|
use newcss::stylesheet::Stylesheet;
|
||||||
use dom::cow;
|
use dom::cow;
|
||||||
use dom::element::*;
|
use dom::element::*;
|
||||||
use dom::event::{Event, ReflowEvent};
|
use dom::event::{Event, ReflowEvent};
|
||||||
|
|
|
@ -9,9 +9,10 @@ use core::dvec::DVec;
|
||||||
use core::to_str::ToStr;
|
use core::to_str::ToStr;
|
||||||
use core::rand;
|
use core::rand;
|
||||||
use css::compute::ComputeStyles;
|
use css::compute::ComputeStyles;
|
||||||
use newcss::values::{BoxSizing, Length, Px, CSSDisplay, Specified, BgColor, BgColorTransparent};
|
use newcss::units::{BoxSizing, Length, Px};
|
||||||
use newcss::values::{BdrColor, PosAbsolute};
|
use newcss::values::{CSSDisplay, Specified, CSSBackgroundColorColor, CSSBackgroundColorTransparent};
|
||||||
use newcss::values::{BdrWidthLength, BdrWidthMedium};
|
use newcss::values::{CSSBorderColor, CSSPositionAbsolute};
|
||||||
|
use newcss::values::{CSSBorderWidthLength, CSSBorderWidthMedium};
|
||||||
use newcss::color::{Color, rgba};
|
use newcss::color::{Color, rgba};
|
||||||
use dom::element::{ElementKind, HTMLDivElement, HTMLImageElement};
|
use dom::element::{ElementKind, HTMLDivElement, HTMLImageElement};
|
||||||
use dom::node::{Element, Node, NodeData, NodeKind, NodeTree};
|
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();
|
let left_width = self.d().node.compute_border_left_width();
|
||||||
|
|
||||||
match (top_width, right_width, bottom_width, left_width) {
|
match (top_width, right_width, bottom_width, left_width) {
|
||||||
(BdrWidthLength(Px(top)),
|
(CSSBorderWidthLength(Px(top)),
|
||||||
BdrWidthLength(Px(right)),
|
CSSBorderWidthLength(Px(right)),
|
||||||
BdrWidthLength(Px(bottom)),
|
CSSBorderWidthLength(Px(bottom)),
|
||||||
BdrWidthLength(Px(left))) => {
|
CSSBorderWidthLength(Px(left))) => {
|
||||||
let top_au = au::from_frac_px(top);
|
let top_au = au::from_frac_px(top);
|
||||||
let right_au = au::from_frac_px(right);
|
let right_au = au::from_frac_px(right);
|
||||||
let bottom_au = au::from_frac_px(bottom);
|
let bottom_au = au::from_frac_px(bottom);
|
||||||
|
@ -474,10 +475,10 @@ impl RenderBox : RenderBoxMethods {
|
||||||
fail ~"unimplemented border widths";
|
fail ~"unimplemented border widths";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(BdrWidthMedium,
|
(CSSBorderWidthMedium,
|
||||||
BdrWidthMedium,
|
CSSBorderWidthMedium,
|
||||||
BdrWidthMedium,
|
CSSBorderWidthMedium,
|
||||||
BdrWidthMedium) => {
|
CSSBorderWidthMedium) => {
|
||||||
// FIXME: This seems to be the default for non-root nodes. For now we'll ignore it
|
// FIXME: This seems to be the default for non-root nodes. For now we'll ignore it
|
||||||
warn!("ignoring medium border widths");
|
warn!("ignoring medium border widths");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/** Creates CSS boxes from a DOM. */
|
/** Creates CSS boxes from a DOM. */
|
||||||
use au = gfx::geometry;
|
use au = gfx::geometry;
|
||||||
use core::dvec::DVec;
|
use core::dvec::DVec;
|
||||||
use newcss::values::{CSSDisplay, DisplayBlock, DisplayInline, DisplayInlineBlock, DisplayNone};
|
use newcss::values::{CSSDisplay, CSSDisplayBlock, CSSDisplayInline, CSSDisplayInlineBlock, CSSDisplayNone};
|
||||||
use newcss::values::{Inherit, Initial, Specified};
|
use newcss::values::{Inherit, Specified};
|
||||||
use dom::element::*;
|
use dom::element::*;
|
||||||
use dom::node::{Comment, Doctype, Element, Text, Node, LayoutData};
|
use dom::node::{Comment, Doctype, Element, Text, Node, LayoutData};
|
||||||
use image::holder::ImageHolder;
|
use image::holder::ImageHolder;
|
||||||
|
@ -52,23 +52,23 @@ priv fn simulate_UA_display_rules(node: Node) -> CSSDisplay {
|
||||||
Specified(v) => v
|
Specified(v) => v
|
||||||
}
|
}
|
||||||
};*/
|
};*/
|
||||||
let resolved = DisplayInline;
|
let resolved = CSSDisplayInline;
|
||||||
if (resolved == DisplayNone) { return resolved; }
|
if (resolved == CSSDisplayNone) { return resolved; }
|
||||||
|
|
||||||
do node.read |n| {
|
do node.read |n| {
|
||||||
match n.kind {
|
match n.kind {
|
||||||
~Doctype(*) | ~Comment(*) => DisplayNone,
|
~Doctype(*) | ~Comment(*) => CSSDisplayNone,
|
||||||
~Text(*) => DisplayInline,
|
~Text(*) => CSSDisplayInline,
|
||||||
~Element(e) => match e.kind {
|
~Element(e) => match e.kind {
|
||||||
~HTMLHeadElement(*) => DisplayNone,
|
~HTMLHeadElement(*) => CSSDisplayNone,
|
||||||
~HTMLScriptElement(*) => DisplayNone,
|
~HTMLScriptElement(*) => CSSDisplayNone,
|
||||||
~HTMLParagraphElement(*) => DisplayBlock,
|
~HTMLParagraphElement(*) => CSSDisplayBlock,
|
||||||
~HTMLDivElement(*) => DisplayBlock,
|
~HTMLDivElement(*) => CSSDisplayBlock,
|
||||||
~HTMLBodyElement(*) => DisplayBlock,
|
~HTMLBodyElement(*) => CSSDisplayBlock,
|
||||||
~HTMLHeadingElement(*) => DisplayBlock,
|
~HTMLHeadingElement(*) => CSSDisplayBlock,
|
||||||
~HTMLHtmlElement(*) => DisplayBlock,
|
~HTMLHtmlElement(*) => CSSDisplayBlock,
|
||||||
~HTMLUListElement(*) => DisplayBlock,
|
~HTMLUListElement(*) => CSSDisplayBlock,
|
||||||
~HTMLOListElement(*) => DisplayBlock,
|
~HTMLOListElement(*) => CSSDisplayBlock,
|
||||||
_ => resolved
|
_ => resolved
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,15 +223,15 @@ impl BuilderContext {
|
||||||
fn containing_context_for_display(display: CSSDisplay,
|
fn containing_context_for_display(display: CSSDisplay,
|
||||||
builder: &LayoutTreeBuilder) -> BuilderContext {
|
builder: &LayoutTreeBuilder) -> BuilderContext {
|
||||||
match (display, self.default_collector.flow) {
|
match (display, self.default_collector.flow) {
|
||||||
(DisplayBlock, @RootFlow(*)) => self.create_child_flow_of_type(Flow_Block, builder),
|
(CSSDisplayBlock, @RootFlow(*)) => self.create_child_flow_of_type(Flow_Block, builder),
|
||||||
(DisplayBlock, @BlockFlow(*)) => {
|
(CSSDisplayBlock, @BlockFlow(*)) => {
|
||||||
self.clear_inline_collector();
|
self.clear_inline_collector();
|
||||||
self.create_child_flow_of_type(Flow_Block, builder)
|
self.create_child_flow_of_type(Flow_Block, builder)
|
||||||
},
|
},
|
||||||
(DisplayInline, @InlineFlow(*)) => self.clone(),
|
(CSSDisplayInline, @InlineFlow(*)) => self.clone(),
|
||||||
(DisplayInlineBlock, @InlineFlow(*)) => self.clone(),
|
(CSSDisplayInlineBlock, @InlineFlow(*)) => self.clone(),
|
||||||
(DisplayInline, @BlockFlow(*)) => self.get_inline_collector(builder),
|
(CSSDisplayInline, @BlockFlow(*)) => self.get_inline_collector(builder),
|
||||||
(DisplayInlineBlock, @BlockFlow(*)) => self.get_inline_collector(builder),
|
(CSSDisplayInlineBlock, @BlockFlow(*)) => self.get_inline_collector(builder),
|
||||||
_ => self.clone()
|
_ => self.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ impl LayoutTreeBuilder {
|
||||||
// TODO: remove this once UA styles work
|
// TODO: remove this once UA styles work
|
||||||
// TODO: handle interactions with 'float', 'position' (CSS 2.1, Section 9.7)
|
// TODO: handle interactions with 'float', 'position' (CSS 2.1, Section 9.7)
|
||||||
let simulated_display = match simulate_UA_display_rules(cur_node) {
|
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
|
v => v
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@ export DisplayListBuilder;
|
||||||
|
|
||||||
use au = gfx::geometry;
|
use au = gfx::geometry;
|
||||||
use au::Au;
|
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::node::{Text, NodeScope};
|
||||||
use dom::cow::Scope;
|
use dom::cow::Scope;
|
||||||
use dvec::DVec;
|
use dvec::DVec;
|
||||||
|
|
|
@ -7,7 +7,7 @@ use au = gfx::geometry;
|
||||||
use au::Au;
|
use au::Au;
|
||||||
use content::content_task;
|
use content::content_task;
|
||||||
use core::dvec::DVec;
|
use core::dvec::DVec;
|
||||||
use newcss::Stylesheet;
|
use newcss::stylesheet::Stylesheet;
|
||||||
use dl = gfx::display_list;
|
use dl = gfx::display_list;
|
||||||
use dom::event::{Event, ReflowEvent};
|
use dom::event::{Event, ReflowEvent};
|
||||||
use dom::node::{Node, LayoutData};
|
use dom::node::{Node, LayoutData};
|
||||||
|
@ -36,7 +36,7 @@ use layout::traverse::*;
|
||||||
use comm::*;
|
use comm::*;
|
||||||
use task::*;
|
use task::*;
|
||||||
use core::mutable::Mut;
|
use core::mutable::Mut;
|
||||||
use newcss::SelectCtx;
|
use newcss::select::SelectCtx;
|
||||||
|
|
||||||
pub type LayoutTask = comm::Chan<Msg>;
|
pub type LayoutTask = comm::Chan<Msg>;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue