auto merge of #474 : pcwalton/servo/separation, r=pcwalton

r? @metajack
This commit is contained in:
bors-servo 2013-05-30 00:06:42 -07:00
commit 473b0941ec
157 changed files with 391 additions and 327 deletions

View file

@ -192,14 +192,21 @@ DONE_gfx = $(B)src/components/gfx/libgfx.dummy
DEPS_gfx = $(CRATE_gfx) $(SRC_gfx) $(DONE_SUBMODULES) $(DONE_util) $(DONE_net) DEPS_gfx = $(CRATE_gfx) $(SRC_gfx) $(DONE_SUBMODULES) $(DONE_util) $(DONE_net)
RFLAGS_servo = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/components/gfx -L $(B)src/components/util -L $(B)src/components/net RFLAGS_script = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/components/util -L $(B)src/components/net -L $(B)src/components/gfx
WEBIDL_script = $(call rwildcard,$(S)src/components/script/,*.webidl)
AUTOGEN_SRC_script = $(patsubst %.webidl, %Binding.rs, $(WEBIDL_script))
SRC_script = $(call rwildcard,$(S)src/components/script/,*.rs) $(AUTOGEN_SRC_script)
CRATE_script = $(S)src/components/script/script.rc
DONE_script = $(B)src/components/script/libscript.dummy
WEBIDL_servo = $(call rwildcard,$(S)src/components/main/,*.webidl) DEPS_script = $(CRATE_script) $(SRC_script) $(DONE_SUBMODULES) $(DONE_util) $(DONE_net)
AUTOGEN_SRC_servo = $(patsubst %.webidl, %Binding.rs, $(WEBIDL_servo))
SRC_servo = $(call rwildcard,$(S)src/components/main/,*.rs) $(AUTOGEN_SRC_servo) RFLAGS_servo = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/components/gfx -L $(B)src/components/util -L $(B)src/components/net -L $(B)src/components/script
SRC_servo = $(call rwildcard,$(S)src/components/main/,*.rs)
CRATE_servo = $(S)src/components/main/servo.rc CRATE_servo = $(S)src/components/main/servo.rc
DEPS_servo = $(CRATE_servo) $(SRC_servo) $(DONE_SUBMODULES) $(DONE_util) $(DONE_gfx) $(DONE_net) DEPS_servo = $(CRATE_servo) $(SRC_servo) $(DONE_SUBMODULES) $(DONE_util) $(DONE_gfx) $(DONE_script) $(DONE_net)
# rules that depend on having correct meta-target vars (DEPS_CLEAN, DEPS_servo, etc) # rules that depend on having correct meta-target vars (DEPS_CLEAN, DEPS_servo, etc)
include $(S)mk/check.mk include $(S)mk/check.mk
@ -220,13 +227,16 @@ $(DONE_net): $(DEPS_net)
$(DONE_gfx): $(DEPS_gfx) $(DONE_gfx): $(DEPS_gfx)
$(RUSTC) $(RFLAGS_gfx) -o $@ $< && touch $@ $(RUSTC) $(RFLAGS_gfx) -o $@ $< && touch $@
BINDINGS_SRC = $(S)/src/components/main/dom/bindings/codegen $(DONE_script): $(DEPS_script)
$(RUSTC) $(RFLAGS_script) -o $@ $< && touch $@
BINDINGS_SRC = $(S)/src/components/script/dom/bindings/codegen
CACHE_DIR = $(BINDINGS_SRC)/_cache CACHE_DIR = $(BINDINGS_SRC)/_cache
bindinggen_dependencies := $(addprefix $(BINDINGS_SRC)/, BindingGen.py Bindings.conf Configuration.py CodegenRust.py parser/WebIDL.py ParserResults.pkl) bindinggen_dependencies := $(addprefix $(BINDINGS_SRC)/, BindingGen.py Bindings.conf Configuration.py CodegenRust.py parser/WebIDL.py ParserResults.pkl)
$(AUTOGEN_SRC_servo): %Binding.rs: $(bindinggen_dependencies) \ $(AUTOGEN_SRC_script): %Binding.rs: $(bindinggen_dependencies) \
%.webidl %.webidl
PYTHONDONTWRITEBYTECODE=1 $(CFG_PYTHON2) $(BINDINGS_SRC)/pythonpath.py \ PYTHONDONTWRITEBYTECODE=1 $(CFG_PYTHON2) $(BINDINGS_SRC)/pythonpath.py \
-I$(BINDINGS_SRC)/parser -I$(BINDINGS_SRC)/ply \ -I$(BINDINGS_SRC)/parser -I$(BINDINGS_SRC)/ply \
@ -241,13 +251,13 @@ $(CACHE_DIR)/.done:
@touch $@ @touch $@
$(BINDINGS_SRC)/ParserResults.pkl: $(globalgen_dependencies) \ $(BINDINGS_SRC)/ParserResults.pkl: $(globalgen_dependencies) \
$(WEBIDL_servo) $(WEBIDL_script)
PYTHONDONTWRITEBYTECODE=1 $(CFG_PYTHON2) $(BINDINGS_SRC)/pythonpath.py \ PYTHONDONTWRITEBYTECODE=1 $(CFG_PYTHON2) $(BINDINGS_SRC)/pythonpath.py \
-I$(BINDINGS_SRC)/parser -I$(BINDINGS_SRC)/ply \ -I$(BINDINGS_SRC)/parser -I$(BINDINGS_SRC)/ply \
-D$(BINDINGS_SRC) \ -D$(BINDINGS_SRC) \
$(BINDINGS_SRC)/GlobalGen.py $(BINDINGS_SRC)/Bindings.conf . \ $(BINDINGS_SRC)/GlobalGen.py $(BINDINGS_SRC)/Bindings.conf . \
--cachedir=$(CACHE_DIR) \ --cachedir=$(CACHE_DIR) \
$(WEBIDL_servo) $(WEBIDL_script)
# Servo binaries # Servo binaries
@ -268,7 +278,7 @@ package: servo
else else
bindings: $(AUTOGEN_SRC_servo) bindings: $(AUTOGEN_SRC_script)
.PHONY: package .PHONY: package
package: package:

1
configure vendored
View file

@ -452,6 +452,7 @@ done
make_dir ${CFG_BUILD_DIR}src/components/util make_dir ${CFG_BUILD_DIR}src/components/util
make_dir ${CFG_BUILD_DIR}src/components/net make_dir ${CFG_BUILD_DIR}src/components/net
make_dir ${CFG_BUILD_DIR}src/components/gfx make_dir ${CFG_BUILD_DIR}src/components/gfx
make_dir ${CFG_BUILD_DIR}src/components/script
make_dir ${CFG_BUILD_DIR}src/components/main make_dir ${CFG_BUILD_DIR}src/components/main
make_dir src/test/html/ref make_dir src/test/html/ref
make_dir src/compiler/rust make_dir src/compiler/rust

View file

@ -34,5 +34,8 @@ clean-net:
clean-gfx: clean-gfx:
cd $(B)/src/components/gfx/ && rm -rf libservo_gfx*.dylib $(DONE_servo_gfx) cd $(B)/src/components/gfx/ && rm -rf libservo_gfx*.dylib $(DONE_servo_gfx)
clean-servo: clean-gfx clean-util clean-net clean-script:
cd $(B)/src/components/script/ && rm -rf libservo_script*.dylib $(DONE_servo_script)
clean-servo: clean-gfx clean-util clean-net clean-script
rm -f servo servo-test rm -f servo servo-test

View file

@ -4,7 +4,7 @@
use compositing::resize_rate_limiter::ResizeRateLimiter; use compositing::resize_rate_limiter::ResizeRateLimiter;
use platform::{Application, Window}; use platform::{Application, Window};
use scripting::script_task::{LoadMsg, ScriptMsg}; use script::script_task::{LoadMsg, ScriptMsg};
use windowing::{ApplicationMethods, WindowMethods}; use windowing::{ApplicationMethods, WindowMethods};
use azure::azure_hl::{DataSourceSurface, DrawTarget, SourceSurfaceMethods}; use azure::azure_hl::{DataSourceSurface, DrawTarget, SourceSurfaceMethods};

View file

@ -7,10 +7,9 @@
/// before sending the next. If the window is resized multiple times before an event is handled /// before sending the next. If the window is resized multiple times before an event is handled
/// then some events will never be sent. /// then some events will never be sent.
use dom::event::ResizeEvent;
use scripting::script_task::{ScriptMsg, SendEventMsg};
use core::comm::{Port, SharedChan}; use core::comm::{Port, SharedChan};
use script::dom::event::ResizeEvent;
use script::script_task::{ScriptMsg, SendEventMsg};
pub struct ResizeRateLimiter { pub struct ResizeRateLimiter {
/// The channel we send resize events on /// The channel we send resize events on

View file

@ -6,10 +6,10 @@
use css::node_util::NodeUtil; use css::node_util::NodeUtil;
use css::select_handler::NodeSelectHandler; use css::select_handler::NodeSelectHandler;
use dom::node::{AbstractNode, LayoutView};
use script::dom::node::{AbstractNode, LayoutView};
use newcss::complete::CompleteSelectResults; use newcss::complete::CompleteSelectResults;
use newcss::select::{SelectCtx, SelectResults}; use newcss::select::{SelectCtx, SelectResults};
use servo_util::tree::TreeUtils; use servo_util::tree::TreeUtils;
pub trait MatchMethods { pub trait MatchMethods {

View file

@ -5,9 +5,9 @@
// Style retrieval from DOM elements. // Style retrieval from DOM elements.
use css::node_util::NodeUtil; use css::node_util::NodeUtil;
use dom::node::{AbstractNode, LayoutView};
use newcss::complete::CompleteStyle; use newcss::complete::CompleteStyle;
use script::dom::node::{AbstractNode, LayoutView};
/// Node mixin providing `style` method that returns a `NodeStyle` /// Node mixin providing `style` method that returns a `NodeStyle`
pub trait StyledNode { pub trait StyledNode {

View file

@ -2,11 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::node::{AbstractNode, LayoutView};
use layout::aux::LayoutAuxMethods; use layout::aux::LayoutAuxMethods;
use core::cast::transmute; use core::cast::transmute;
use newcss::complete::CompleteSelectResults; use newcss::complete::CompleteSelectResults;
use script::dom::node::{AbstractNode, LayoutView};
pub trait NodeUtil<'self> { pub trait NodeUtil<'self> {
fn get_css_select_results(self) -> &'self CompleteSelectResults; fn get_css_select_results(self) -> &'self CompleteSelectResults;

View file

@ -1,28 +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/. */
//! CSS library requires that DOM nodes be convertable to *c_void through this trait
extern mod netsurfcss;
use dom::node::{AbstractNode, LayoutView};
use core::cast;
// FIXME: Rust #3908. rust-css can't reexport VoidPtrLike
use css::node_void_ptr::netsurfcss::util::VoidPtrLike;
impl VoidPtrLike for AbstractNode<LayoutView> {
fn from_void_ptr(node: *libc::c_void) -> AbstractNode<LayoutView> {
assert!(node.is_not_null());
unsafe {
cast::transmute(node)
}
}
fn to_void_ptr(&self) -> *libc::c_void {
unsafe {
cast::transmute(*self)
}
}
}

View file

@ -6,10 +6,9 @@
/// Implementation of the callbacks that the CSS selector engine uses to query the DOM. /// Implementation of the callbacks that the CSS selector engine uses to query the DOM.
/// ///
use dom::node::{AbstractNode, LayoutView};
use newcss::select::SelectHandler;
use core::str::eq_slice; use core::str::eq_slice;
use newcss::select::SelectHandler;
use script::dom::node::{AbstractNode, LayoutView};
pub struct NodeSelectHandler { pub struct NodeSelectHandler {
node: AbstractNode<LayoutView>, node: AbstractNode<LayoutView>,

View file

@ -3,10 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use compositing::CompositorTask; use compositing::CompositorTask;
use layout::layout_task::LayoutTask;
use layout::layout_task; use layout::layout_task;
use scripting::script_task::{ExecuteMsg, LoadMsg, ScriptMsg, ScriptTask};
use scripting::script_task;
use util::task::spawn_listener; use util::task::spawn_listener;
use core::cell::Cell; use core::cell::Cell;
@ -14,11 +11,14 @@ use core::comm::{Chan, Port, SharedChan};
use gfx::opts::Opts; use gfx::opts::Opts;
use gfx::render_task::RenderTask; use gfx::render_task::RenderTask;
use gfx::render_task; use gfx::render_task;
use script::layout_interface::LayoutTask;
use script::layout_interface;
use script::script_task::{ExecuteMsg, LoadMsg, ScriptMsg, ScriptTask};
use script::script_task;
use servo_net::image_cache_task::{ImageCacheTask, ImageCacheTaskClient}; use servo_net::image_cache_task::{ImageCacheTask, ImageCacheTaskClient};
use servo_net::resource_task::ResourceTask; use servo_net::resource_task::ResourceTask;
use servo_net::resource_task; use servo_net::resource_task;
use servo_util::time::{ProfilerChan, ProfilerPort, ProfilerTask}; use servo_util::time::{ProfilerChan, ProfilerPort, ProfilerTask};
use servo_util::time;
use std::net::url::Url; use std::net::url::Url;
pub type EngineTask = Chan<Msg>; pub type EngineTask = Chan<Msg>;
@ -61,10 +61,10 @@ impl Engine {
let profiler_task = ProfilerTask::new(profiler_port.take(), profiler_chan.clone()); let profiler_task = ProfilerTask::new(profiler_port.take(), profiler_chan.clone());
let opts = opts.take(); let opts = opts.take();
let layout_task = LayoutTask(render_task.clone(), let layout_task = layout_task::create_layout_task(render_task.clone(),
image_cache_task.clone(), image_cache_task.clone(),
opts, opts,
profiler_task.chan.clone()); profiler_task.chan.clone());
let script_task = ScriptTask::new(script_port.take(), let script_task = ScriptTask::new(script_port.take(),
script_chan.take(), script_chan.take(),
@ -105,7 +105,7 @@ impl Engine {
ExitMsg(sender) => { ExitMsg(sender) => {
self.script_task.chan.send(script_task::ExitMsg); self.script_task.chan.send(script_task::ExitMsg);
self.layout_task.send(layout_task::ExitMsg); self.layout_task.chan.send(layout_interface::ExitMsg);
let (response_port, response_chan) = comm::stream(); let (response_port, response_chan) = comm::stream();

View file

@ -4,10 +4,10 @@
//! Code for managing the layout data in the DOM. //! Code for managing the layout data in the DOM.
use dom::node::{AbstractNode, LayoutView};
use layout::flow::FlowContext; use layout::flow::FlowContext;
use newcss::complete::CompleteSelectResults; use newcss::complete::CompleteSelectResults;
use script::dom::node::{AbstractNode, LayoutView};
use servo_util::tree::TreeUtils; use servo_util::tree::TreeUtils;
/// Data that layout associates with a node. /// Data that layout associates with a node.

View file

@ -5,9 +5,7 @@
//! The `RenderBox` type, which represents the leaves of the layout tree. //! The `RenderBox` type, which represents the leaves of the layout tree.
use css::node_style::StyledNode; use css::node_style::StyledNode;
use dom::node::{AbstractNode, LayoutView};
use layout::context::LayoutContext; use layout::context::LayoutContext;
use layout::debug::DebugMethods;
use layout::display_list_builder::{DisplayListBuilder, ToGfxColor}; use layout::display_list_builder::{DisplayListBuilder, ToGfxColor};
use layout::flow::FlowContext; use layout::flow::FlowContext;
use layout::text; use layout::text;
@ -29,6 +27,7 @@ use newcss::values::{CSSFontSizeLength, CSSFontStyleItalic, CSSFontStyleNormal};
use newcss::values::{CSSFontStyleOblique, CSSTextAlign, CSSTextDecoration}; use newcss::values::{CSSFontStyleOblique, CSSTextAlign, CSSTextDecoration};
use newcss::values::{CSSTextDecorationNone, CSSFloatNone, CSSPositionStatic}; use newcss::values::{CSSTextDecorationNone, CSSFloatNone, CSSPositionStatic};
use newcss::values::{CSSDisplayInlineBlock, CSSDisplayInlineTable}; use newcss::values::{CSSDisplayInlineBlock, CSSDisplayInlineTable};
use script::dom::node::{AbstractNode, LayoutView};
use servo_net::image::holder::ImageHolder; use servo_net::image::holder::ImageHolder;
use servo_net::local_image_cache::LocalImageCache; use servo_net::local_image_cache::LocalImageCache;
use servo_util::range::*; use servo_util::range::*;
@ -795,15 +794,14 @@ pub impl RenderBox {
} }
get_propagated_text_decoration(self.nearest_ancestor_element()) get_propagated_text_decoration(self.nearest_ancestor_element())
} }
}
impl DebugMethods for RenderBox { /// Dumps this node, for debugging.
fn dump(&self) { pub fn dump(&self) {
self.dump_indent(0); self.dump_indent(0);
} }
/// Dumps a render box for debugging, with indentation. /// Dumps a render box for debugging, with indentation.
fn dump_indent(&self, indent: uint) { pub fn dump_indent(&self, indent: uint) {
let mut string = ~""; let mut string = ~"";
for uint::range(0u, indent) |_i| { for uint::range(0u, indent) |_i| {
string += ~" "; string += ~" ";
@ -814,7 +812,7 @@ impl DebugMethods for RenderBox {
} }
/// Returns a debugging string describing this box. /// Returns a debugging string describing this box.
fn debug_str(&self) -> ~str { pub fn debug_str(&self) -> ~str {
let representation = match *self { let representation = match *self {
GenericRenderBoxClass(*) => ~"GenericRenderBox", GenericRenderBoxClass(*) => ~"GenericRenderBox",
ImageRenderBoxClass(*) => ~"ImageRenderBox", ImageRenderBoxClass(*) => ~"ImageRenderBox",

View file

@ -4,16 +4,12 @@
//! Creates CSS boxes from a DOM tree. //! Creates CSS boxes from a DOM tree.
use dom::element::*;
use dom::node::{AbstractNode, CommentNodeTypeId, DoctypeNodeTypeId};
use dom::node::{ElementNodeTypeId, LayoutView, TextNodeTypeId};
use layout::aux::LayoutAuxMethods; use layout::aux::LayoutAuxMethods;
use layout::block::BlockFlowData; use layout::block::BlockFlowData;
use layout::box::{GenericRenderBoxClass, ImageRenderBox, ImageRenderBoxClass, RenderBox}; use layout::box::{GenericRenderBoxClass, ImageRenderBox, ImageRenderBoxClass, RenderBox};
use layout::box::{RenderBoxBase, RenderBoxType, RenderBox_Generic, RenderBox_Image}; use layout::box::{RenderBoxBase, RenderBoxType, RenderBox_Generic, RenderBox_Image};
use layout::box::{RenderBox_Text, UnscannedTextRenderBox, UnscannedTextRenderBoxClass}; use layout::box::{RenderBox_Text, UnscannedTextRenderBox, UnscannedTextRenderBoxClass};
use layout::context::LayoutContext; use layout::context::LayoutContext;
use layout::debug::{BoxedMutDebugMethods, DebugMethods};
use layout::flow::{AbsoluteFlow, BlockFlow, FloatFlow, Flow_Absolute, Flow_Block, Flow_Float}; 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::{Flow_Inline, Flow_InlineBlock, Flow_Root, Flow_Table, FlowContext};
use layout::flow::{FlowContextType, FlowData, InlineBlockFlow, InlineFlow, TableFlow}; use layout::flow::{FlowContextType, FlowData, InlineBlockFlow, InlineFlow, TableFlow};
@ -21,6 +17,9 @@ use layout::inline::{InlineFlowData, InlineLayout};
use newcss::values::{CSSDisplay, CSSDisplayBlock, CSSDisplayInline, CSSDisplayInlineBlock}; use newcss::values::{CSSDisplay, CSSDisplayBlock, CSSDisplayInline, CSSDisplayInlineBlock};
use newcss::values::{CSSDisplayNone}; use newcss::values::{CSSDisplayNone};
use script::dom::element::*;
use script::dom::node::{AbstractNode, CommentNodeTypeId, DoctypeNodeTypeId};
use script::dom::node::{ElementNodeTypeId, LayoutView, TextNodeTypeId};
use servo_util::range::Range; use servo_util::range::Range;
use servo_util::tree::{TreeNodeRef, TreeUtils}; use servo_util::tree::{TreeNodeRef, TreeUtils};

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

@ -25,11 +25,9 @@
/// line breaks and mapping to CSS boxes, for the purpose of handling `getClientRects()` and /// line breaks and mapping to CSS boxes, for the purpose of handling `getClientRects()` and
/// similar methods. /// similar methods.
use dom::node::{AbstractNode, LayoutView};
use layout::block::BlockFlowData; use layout::block::BlockFlowData;
use layout::box::RenderBox; use layout::box::RenderBox;
use layout::context::LayoutContext; use layout::context::LayoutContext;
use layout::debug::DebugMethods;
use layout::display_list_builder::DisplayListBuilder; use layout::display_list_builder::DisplayListBuilder;
use layout::inline::{InlineFlowData}; use layout::inline::{InlineFlowData};
@ -38,6 +36,7 @@ use geom::point::Point2D;
use geom::rect::Rect; use geom::rect::Rect;
use gfx::display_list::DisplayList; use gfx::display_list::DisplayList;
use gfx::geometry::Au; use gfx::geometry::Au;
use script::dom::node::{AbstractNode, LayoutView};
use servo_util::tree::{TreeNode, TreeNodeRef, TreeUtils}; use servo_util::tree::{TreeNode, TreeNodeRef, TreeUtils};
/// The type of the formatting context and data specific to each context, such as line box /// The type of the formatting context and data specific to each context, such as line box
@ -372,15 +371,14 @@ impl<'self> FlowContext {
true true
} }
}
impl DebugMethods for FlowContext { /// Dumps the flow tree for debugging.
fn dump(&self) { pub fn dump(&self) {
self.dump_indent(0); self.dump_indent(0);
} }
/// Dumps the flow tree, for debugging, with indentation. /// Dumps the flow tree, for debugging, with indentation.
fn dump_indent(&self, indent: uint) { pub fn dump_indent(&self, indent: uint) {
let mut s = ~"|"; let mut s = ~"|";
for uint::range(0, indent) |_i| { for uint::range(0, indent) |_i| {
s += ~"---- "; s += ~"---- ";
@ -395,7 +393,7 @@ impl DebugMethods for FlowContext {
} }
} }
fn debug_str(&self) -> ~str { pub fn debug_str(&self) -> ~str {
let repr = match *self { let repr = match *self {
InlineFlow(inline) => { InlineFlow(inline) => {
let mut s = inline.boxes.foldl(~"InlineFlow(children=", |s, box| { let mut s = inline.boxes.foldl(~"InlineFlow(children=", |s, box| {

View file

@ -4,11 +4,9 @@
use core::cell::Cell; use core::cell::Cell;
use core; use core;
use dom::node::{AbstractNode, LayoutView};
use layout::box::{CannotSplit, GenericRenderBoxClass, ImageRenderBoxClass, RenderBox}; use layout::box::{CannotSplit, GenericRenderBoxClass, ImageRenderBoxClass, RenderBox};
use layout::box::{SplitDidFit, SplitDidNotFit, TextRenderBoxClass, UnscannedTextRenderBoxClass}; use layout::box::{SplitDidFit, SplitDidNotFit, TextRenderBoxClass, UnscannedTextRenderBoxClass};
use layout::context::LayoutContext; use layout::context::LayoutContext;
use layout::debug::{BoxedDebugMethods, BoxedMutDebugMethods, DebugMethods};
use layout::display_list_builder::DisplayListBuilder; use layout::display_list_builder::DisplayListBuilder;
use layout::flow::{FlowContext, FlowData, InlineFlow}; use layout::flow::{FlowContext, FlowData, InlineFlow};
use layout::text::{UnscannedMethods, adapt_textbox_with_range}; use layout::text::{UnscannedMethods, adapt_textbox_with_range};
@ -20,9 +18,8 @@ use gfx::geometry::Au;
use gfx::text::text_run::TextRun; use gfx::text::text_run::TextRun;
use gfx::text::util::*; use gfx::text::util::*;
use newcss::values::{CSSTextAlignCenter, CSSTextAlignJustify, CSSTextAlignLeft}; use newcss::values::{CSSTextAlignCenter, CSSTextAlignJustify, CSSTextAlignLeft};
use newcss::values::{CSSTextAlignRight}; use newcss::values::{CSSTextAlignRight, CSSTextDecoration, CSSTextDecorationUnderline};
use newcss::values::CSSTextDecorationUnderline; use script::dom::node::{AbstractNode, LayoutView};
use newcss::values::CSSTextDecoration;
use servo_util::range::Range; use servo_util::range::Range;
use std::deque::Deque; use std::deque::Deque;

View file

@ -2,20 +2,16 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/// The layout task. Performs layout on the DOM, builds display lists and sends them to be //! The layout task. Performs layout on the DOM, builds display lists and sends them to be
/// rendered. /// rendered.
use css::matching::MatchMethods; use css::matching::MatchMethods;
use css::select::new_css_select_ctx; use css::select::new_css_select_ctx;
use dom::event::ReflowEvent;
use dom::node::{AbstractNode, LayoutView, ScriptView};
use layout::aux::{LayoutData, LayoutAuxMethods}; use layout::aux::{LayoutData, LayoutAuxMethods};
use layout::box_builder::LayoutTreeBuilder; use layout::box_builder::LayoutTreeBuilder;
use layout::context::LayoutContext; use layout::context::LayoutContext;
use layout::debug::{BoxedMutDebugMethods, DebugMethods};
use layout::display_list_builder::{DisplayListBuilder, FlowDisplayListBuilderMethods}; use layout::display_list_builder::{DisplayListBuilder, FlowDisplayListBuilderMethods};
use layout::flow::FlowContext; use layout::flow::FlowContext;
use scripting::script_task::{ScriptMsg, SendEventMsg};
use util::task::spawn_listener; use util::task::spawn_listener;
use servo_util::time; use servo_util::time;
use servo_util::time::time; use servo_util::time::time;
@ -37,72 +33,34 @@ use gfx::render_task::{RenderMsg, RenderTask};
use newcss::select::SelectCtx; use newcss::select::SelectCtx;
use newcss::stylesheet::Stylesheet; use newcss::stylesheet::Stylesheet;
use newcss::types::OriginAuthor; use newcss::types::OriginAuthor;
use script::dom::event::ReflowEvent;
use script::dom::node::{AbstractNode, LayoutView};
use script::layout_interface::{AddStylesheetMsg, BuildData, BuildMsg, ContentBoxQuery};
use script::layout_interface::{ContentBoxResponse, ContentBoxesQuery, ContentBoxesResponse};
use script::layout_interface::{ExitMsg, LayoutQuery, LayoutResponse, LayoutTask};
use script::layout_interface::{MatchSelectorsDamage, Msg, NoDamage, QueryMsg, ReflowDamage};
use script::script_task::{ScriptMsg, SendEventMsg};
use servo_net::image_cache_task::{ImageCacheTask, ImageResponseMsg}; use servo_net::image_cache_task::{ImageCacheTask, ImageResponseMsg};
use servo_net::local_image_cache::LocalImageCache; use servo_net::local_image_cache::LocalImageCache;
use servo_util::tree::TreeUtils; use servo_util::tree::TreeUtils;
use std::net::url::Url;
pub type LayoutTask = SharedChan<Msg>; pub fn create_layout_task(render_task: RenderTask,
img_cache_task: ImageCacheTask,
pub enum LayoutQuery { opts: Opts,
ContentBox(AbstractNode<ScriptView>), profiler_chan: ProfilerChan)
ContentBoxes(AbstractNode<ScriptView>), -> LayoutTask {
} let chan = do spawn_listener::<Msg> |from_script| {
let mut layout = Layout::new(render_task.clone(),
pub type LayoutQueryResponse = Result<LayoutQueryResponse_, ()>; img_cache_task.clone(),
from_script,
pub enum LayoutQueryResponse_ { &opts,
ContentRect(Rect<Au>), profiler_chan.clone());
ContentRects(~[Rect<Au>])
}
pub enum Msg {
AddStylesheet(Stylesheet),
BuildMsg(~BuildData),
QueryMsg(LayoutQuery, Chan<LayoutQueryResponse>),
ExitMsg
}
// Dirty bits for layout.
pub enum Damage {
NoDamage, // Document is clean; do nothing.
ReflowDamage, // Reflow; don't perform CSS selector matching.
MatchSelectorsDamage, // Perform CSS selector matching and reflow.
}
impl Damage {
fn add(&mut self, new_damage: Damage) {
match (*self, new_damage) {
(NoDamage, _) => *self = new_damage,
(ReflowDamage, NoDamage) => *self = ReflowDamage,
(ReflowDamage, new_damage) => *self = new_damage,
(MatchSelectorsDamage, _) => *self = MatchSelectorsDamage
}
}
}
pub struct BuildData {
node: AbstractNode<ScriptView>,
url: Url,
script_chan: SharedChan<ScriptMsg>,
window_size: Size2D<uint>,
script_join_chan: Chan<()>,
damage: Damage,
}
pub fn LayoutTask(render_task: RenderTask,
img_cache_task: ImageCacheTask,
opts: Opts,
prof_chan: ProfilerChan)
-> LayoutTask {
SharedChan::new(do spawn_listener::<Msg> |from_script| {
let mut layout = Layout(render_task.clone(),
img_cache_task.clone(),
from_script,
&opts,
prof_chan.clone());
layout.start(); layout.start();
}) };
LayoutTask {
chan: SharedChan::new(chan),
}
} }
struct Layout { struct Layout {
@ -111,57 +69,54 @@ struct Layout {
local_image_cache: @mut LocalImageCache, local_image_cache: @mut LocalImageCache,
from_script: Port<Msg>, from_script: Port<Msg>,
font_ctx: @mut FontContext, font_ctx: @mut FontContext,
// This is used to root reader data
/// This is used to root reader data.
layout_refs: ~[@mut LayoutData], layout_refs: ~[@mut LayoutData],
css_select_ctx: @mut SelectCtx, css_select_ctx: @mut SelectCtx,
prof_chan: ProfilerChan, profiler_chan: ProfilerChan,
}
fn Layout(render_task: RenderTask,
image_cache_task: ImageCacheTask,
from_script: Port<Msg>,
opts: &Opts,
prof_chan: ProfilerChan)
-> Layout {
let fctx = @mut FontContext::new(opts.render_backend, true, prof_chan.clone());
Layout {
render_task: render_task,
image_cache_task: image_cache_task.clone(),
local_image_cache: @mut LocalImageCache(image_cache_task),
from_script: from_script,
font_ctx: fctx,
layout_refs: ~[],
css_select_ctx: @mut new_css_select_ctx(),
prof_chan: prof_chan.clone()
}
} }
impl Layout { impl Layout {
fn new(render_task: RenderTask,
image_cache_task: ImageCacheTask,
from_script: Port<Msg>,
opts: &Opts,
profiler_chan: ProfilerChan)
-> Layout {
let fctx = @mut FontContext::new(opts.render_backend, true, profiler_chan.clone());
Layout {
render_task: render_task,
image_cache_task: image_cache_task.clone(),
local_image_cache: @mut LocalImageCache(image_cache_task),
from_script: from_script,
font_ctx: fctx,
layout_refs: ~[],
css_select_ctx: @mut new_css_select_ctx(),
profiler_chan: profiler_chan,
}
}
fn start(&mut self) { fn start(&mut self) {
while self.handle_request() { while self.handle_request() {
// loop indefinitely // Loop indefinitely.
} }
} }
fn handle_request(&mut self) -> bool { fn handle_request(&mut self) -> bool {
match self.from_script.recv() { match self.from_script.recv() {
AddStylesheet(sheet) => { AddStylesheetMsg(sheet) => self.handle_add_stylesheet(sheet),
self.handle_add_stylesheet(sheet);
}
BuildMsg(data) => { BuildMsg(data) => {
let data = Cell(data); let data = Cell(data);
do profile(time::LayoutPerformCategory, self.prof_chan.clone()) { do profile(time::LayoutPerformCategory, self.profiler_chan.clone()) {
self.handle_build(data.take()); self.handle_build(data.take());
} }
} }
QueryMsg(query, chan) => { QueryMsg(query, chan) => {
let chan = Cell(chan); let chan = Cell(chan);
do profile(time::LayoutQueryCategory, self.prof_chan.clone()) { do profile(time::LayoutQueryCategory, self.profiler_chan.clone()) {
self.handle_query(query, chan.take()) self.handle_query(query, chan.take())
} }
} }
@ -212,7 +167,7 @@ impl Layout {
// Initialize layout data for each node. // Initialize layout data for each node.
// //
// FIXME: This is inefficient. We don't need an entire traversal to do this! // FIXME: This is inefficient. We don't need an entire traversal to do this!
do profile(time::LayoutAuxInitCategory, self.prof_chan.clone()) { do profile(time::LayoutAuxInitCategory, self.profiler_chan.clone()) {
node.initialize_style_for_subtree(&mut self.layout_refs); node.initialize_style_for_subtree(&mut self.layout_refs);
} }
@ -220,7 +175,7 @@ impl Layout {
match data.damage { match data.damage {
NoDamage | ReflowDamage => {} NoDamage | ReflowDamage => {}
MatchSelectorsDamage => { MatchSelectorsDamage => {
do profile(time::LayoutSelectorMatchCategory, self.prof_chan.clone()) { do profile(time::LayoutSelectorMatchCategory, self.profiler_chan.clone()) {
node.restyle_subtree(self.css_select_ctx); node.restyle_subtree(self.css_select_ctx);
} }
} }
@ -228,7 +183,7 @@ impl Layout {
// Construct the flow tree. // Construct the flow tree.
let layout_root: FlowContext = do profile(time::LayoutTreeBuilderCategory, let layout_root: FlowContext = do profile(time::LayoutTreeBuilderCategory,
self.prof_chan.clone()) { self.profiler_chan.clone()) {
let mut builder = LayoutTreeBuilder::new(); let mut builder = LayoutTreeBuilder::new();
let layout_root: FlowContext = match builder.construct_trees(&layout_ctx, *node) { let layout_root: FlowContext = match builder.construct_trees(&layout_ctx, *node) {
Ok(root) => root, Ok(root) => root,
@ -243,7 +198,7 @@ impl Layout {
// Perform the primary layout passes over the flow tree to compute the locations of all // Perform the primary layout passes over the flow tree to compute the locations of all
// the boxes. // the boxes.
do profile(time::LayoutMainCategory, self.prof_chan.clone()) { do profile(time::LayoutMainCategory, self.profiler_chan.clone()) {
for layout_root.traverse_postorder |flow| { for layout_root.traverse_postorder |flow| {
flow.bubble_widths(&mut layout_ctx); flow.bubble_widths(&mut layout_ctx);
}; };
@ -256,7 +211,7 @@ impl Layout {
} }
// Build the display list, and send it to the renderer. // Build the display list, and send it to the renderer.
do profile(time::LayoutDispListBuildCategory, self.prof_chan.clone()) { do profile(time::LayoutDispListBuildCategory, self.profiler_chan.clone()) {
let builder = DisplayListBuilder { let builder = DisplayListBuilder {
ctx: &layout_ctx, ctx: &layout_ctx,
}; };
@ -281,9 +236,9 @@ impl Layout {
/// Handles a query from the script task. This is the main routine that DOM functions like /// Handles a query from the script task. This is the main routine that DOM functions like
/// `getClientRects()` or `getBoundingClientRect()` ultimately invoke. /// `getClientRects()` or `getBoundingClientRect()` ultimately invoke.
fn handle_query(&self, query: LayoutQuery, reply_chan: Chan<LayoutQueryResponse>) { fn handle_query(&self, query: LayoutQuery, reply_chan: Chan<Result<LayoutResponse,()>>) {
match query { match query {
ContentBox(node) => { ContentBoxQuery(node) => {
// FIXME: Isolate this transmutation into a single "bridge" module. // FIXME: Isolate this transmutation into a single "bridge" module.
let node: AbstractNode<LayoutView> = unsafe { let node: AbstractNode<LayoutView> = unsafe {
transmute(node) transmute(node)
@ -308,14 +263,14 @@ impl Layout {
error!("no boxes for node"); error!("no boxes for node");
Err(()) Err(())
} }
Some(rect) => Ok(ContentRect(rect)) Some(rect) => Ok(ContentBoxResponse(rect))
} }
} }
}; };
reply_chan.send(response) reply_chan.send(response)
} }
ContentBoxes(node) => { ContentBoxesQuery(node) => {
// FIXME: Isolate this transmutation into a single "bridge" module. // FIXME: Isolate this transmutation into a single "bridge" module.
let node: AbstractNode<LayoutView> = unsafe { let node: AbstractNode<LayoutView> = unsafe {
transmute(node) transmute(node)
@ -329,7 +284,7 @@ impl Layout {
boxes.push(box.content_box()); boxes.push(box.content_box());
} }
Ok(ContentRects(boxes)) Ok(ContentBoxesResponse(boxes))
} }
}; };

View file

@ -17,11 +17,11 @@ extern mod geom;
extern mod gfx (name = "gfx"); extern mod gfx (name = "gfx");
extern mod glut; extern mod glut;
extern mod http_client; extern mod http_client;
extern mod hubbub;
extern mod js; extern mod js;
extern mod layers; extern mod layers;
extern mod newcss (name = "css"); extern mod newcss (name = "css");
extern mod opengles; extern mod opengles;
extern mod script;
extern mod servo_net (name = "net"); extern mod servo_net (name = "net");
extern mod servo_util (name = "util"); extern mod servo_util (name = "util");
extern mod sharegl; extern mod sharegl;
@ -48,58 +48,15 @@ pub use servo_util::url::make_url;
#[path="compositing/mod.rs"] #[path="compositing/mod.rs"]
pub mod compositing; pub mod compositing;
pub mod scripting {
pub mod script_task;
}
pub mod css { pub mod css {
priv mod select_handler; priv mod select_handler;
priv mod node_util; priv mod node_util;
priv mod node_void_ptr;
pub mod select; pub mod select;
pub mod matching; pub mod matching;
pub mod node_style; pub mod node_style;
} }
pub mod dom {
pub mod bindings {
pub mod document;
pub mod element;
pub mod event;
pub mod eventtarget;
pub mod node;
pub mod text;
pub mod utils;
pub mod conversions;
pub mod window;
pub mod proxyhandler;
pub mod clientrect;
pub mod clientrectlist;
pub mod domparser;
pub mod htmlcollection;
pub mod codegen {
pub mod ClientRectBinding;
pub mod ClientRectListBinding;
pub mod DOMParserBinding;
pub mod EventBinding;
pub mod EventTargetBinding;
pub mod HTMLCollectionBinding;
}
}
pub mod characterdata;
pub mod clientrect;
pub mod clientrectlist;
pub mod document;
pub mod domparser;
pub mod element;
pub mod event;
pub mod eventtarget;
pub mod htmlcollection;
pub mod node;
pub mod window;
}
pub mod engine; pub mod engine;
pub mod layout { pub mod layout {
@ -107,7 +64,6 @@ pub mod layout {
pub mod box; pub mod box;
pub mod box_builder; pub mod box_builder;
pub mod context; pub mod context;
pub mod debug;
pub mod display_list_builder; pub mod display_list_builder;
pub mod flow; pub mod flow;
pub mod layout_task; pub mod layout_task;
@ -116,11 +72,6 @@ pub mod layout {
mod aux; mod aux;
} }
pub mod html {
pub mod cssparse;
pub mod hubbub_html_parser;
}
pub mod windowing; pub mod windowing;
#[path="platform/mod.rs"] #[path="platform/mod.rs"]

View file

@ -5,9 +5,10 @@
use dom::bindings::utils::{CacheableWrapper, WrapperCache, BindingObject, DerivedWrapper}; use dom::bindings::utils::{CacheableWrapper, WrapperCache, BindingObject, DerivedWrapper};
use dom::bindings::codegen::ClientRectBinding; use dom::bindings::codegen::ClientRectBinding;
use dom::clientrect::ClientRect; use dom::clientrect::ClientRect;
use script_task::{task_from_context, global_script_context};
use js::jsapi::{JSObject, JSContext, JSVal}; use js::jsapi::{JSObject, JSContext, JSVal};
use js::glue::bindgen::RUST_OBJECT_TO_JSVAL; use js::glue::bindgen::RUST_OBJECT_TO_JSVAL;
use scripting::script_task::{task_from_context, global_script_context};
pub impl ClientRect { pub impl ClientRect {
pub fn init_wrapper(@mut self) { pub fn init_wrapper(@mut self) {

View file

@ -5,8 +5,9 @@
use dom::bindings::codegen::ClientRectListBinding; use dom::bindings::codegen::ClientRectListBinding;
use dom::bindings::utils::{WrapperCache, CacheableWrapper, BindingObject}; use dom::bindings::utils::{WrapperCache, CacheableWrapper, BindingObject};
use dom::clientrectlist::ClientRectList; use dom::clientrectlist::ClientRectList;
use script_task::{task_from_context, global_script_context};
use js::jsapi::{JSObject, JSContext}; use js::jsapi::{JSObject, JSContext};
use scripting::script_task::{task_from_context, global_script_context};
pub impl ClientRectList { pub impl ClientRectList {
fn init_wrapper(@mut self) { fn init_wrapper(@mut self) {

View file

@ -4147,7 +4147,7 @@ class CGBindingRoot(CGThing):
'dom::domparser::*', #XXXjdm 'dom::domparser::*', #XXXjdm
'dom::event::*', #XXXjdm 'dom::event::*', #XXXjdm
'dom::eventtarget::*', #XXXjdm 'dom::eventtarget::*', #XXXjdm
'scripting::script_task::task_from_context', 'script_task::task_from_context',
'dom::bindings::utils::EnumEntry', 'dom::bindings::utils::EnumEntry',
'dom::node::ScriptView', 'dom::node::ScriptView',
], ],

Some files were not shown because too many files have changed in this diff Show more