Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor display lists to use less memory. #476

Merged
merged 10 commits into from May 30, 2013

Separate the DOM and layout into separate crates.

  • Loading branch information
pcwalton committed May 29, 2013
commit bf82bc54f349dd0944c37129af28dec6b43041fe
@@ -192,14 +192,21 @@ DONE_gfx = $(B)src/components/gfx/libgfx.dummy

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)
AUTOGEN_SRC_servo = $(patsubst %.webidl, %Binding.rs, $(WEBIDL_servo))
SRC_servo = $(call rwildcard,$(S)src/components/main/,*.rs) $(AUTOGEN_SRC_servo)
DEPS_script = $(CRATE_script) $(SRC_script) $(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 -L $(B)src/components/script

SRC_servo = $(call rwildcard,$(S)src/components/main/,*.rs)
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)
include $(S)mk/check.mk
@@ -220,13 +227,16 @@ $(DONE_net): $(DEPS_net)
$(DONE_gfx): $(DEPS_gfx)
$(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

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
PYTHONDONTWRITEBYTECODE=1 $(CFG_PYTHON2) $(BINDINGS_SRC)/pythonpath.py \
-I$(BINDINGS_SRC)/parser -I$(BINDINGS_SRC)/ply \
@@ -241,13 +251,13 @@ $(CACHE_DIR)/.done:
@touch $@

$(BINDINGS_SRC)/ParserResults.pkl: $(globalgen_dependencies) \
$(WEBIDL_servo)
$(WEBIDL_script)
PYTHONDONTWRITEBYTECODE=1 $(CFG_PYTHON2) $(BINDINGS_SRC)/pythonpath.py \
-I$(BINDINGS_SRC)/parser -I$(BINDINGS_SRC)/ply \
-D$(BINDINGS_SRC) \
$(BINDINGS_SRC)/GlobalGen.py $(BINDINGS_SRC)/Bindings.conf . \
--cachedir=$(CACHE_DIR) \
$(WEBIDL_servo)
$(WEBIDL_script)

# Servo binaries

@@ -268,7 +278,7 @@ package: servo

else

bindings: $(AUTOGEN_SRC_servo)
bindings: $(AUTOGEN_SRC_script)

.PHONY: package
package:
@@ -452,6 +452,7 @@ done
make_dir ${CFG_BUILD_DIR}src/components/util
make_dir ${CFG_BUILD_DIR}src/components/net
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 src/test/html/ref
make_dir src/compiler/rust
@@ -34,5 +34,8 @@ clean-net:
clean-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
@@ -4,7 +4,7 @@

use compositing::resize_rate_limiter::ResizeRateLimiter;
use platform::{Application, Window};
use scripting::script_task::{LoadMsg, ScriptMsg};
use script::script_task::{LoadMsg, ScriptMsg};
use windowing::{ApplicationMethods, WindowMethods};

use azure::azure_hl::{DataSourceSurface, DrawTarget, SourceSurfaceMethods};
@@ -7,10 +7,9 @@
/// before sending the next. If the window is resized multiple times before an event is handled
/// then some events will never be sent.

use dom::event::ResizeEvent;
use scripting::script_task::{ScriptMsg, SendEventMsg};

use core::comm::{Port, SharedChan};
use script::dom::event::ResizeEvent;
use script::script_task::{ScriptMsg, SendEventMsg};

pub struct ResizeRateLimiter {
/// The channel we send resize events on
@@ -6,10 +6,10 @@

use css::node_util::NodeUtil;
use css::select_handler::NodeSelectHandler;
use dom::node::{AbstractNode, LayoutView};

use script::dom::node::{AbstractNode, LayoutView};
use newcss::complete::CompleteSelectResults;
use newcss::select::{SelectCtx, SelectResults};

use servo_util::tree::TreeUtils;

pub trait MatchMethods {
@@ -5,9 +5,9 @@
// Style retrieval from DOM elements.

use css::node_util::NodeUtil;
use dom::node::{AbstractNode, LayoutView};

use newcss::complete::CompleteStyle;
use script::dom::node::{AbstractNode, LayoutView};

/// Node mixin providing `style` method that returns a `NodeStyle`
pub trait StyledNode {
@@ -2,11 +2,11 @@
* 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/. */

use dom::node::{AbstractNode, LayoutView};
use layout::aux::LayoutAuxMethods;

use core::cast::transmute;
use newcss::complete::CompleteSelectResults;
use script::dom::node::{AbstractNode, LayoutView};

pub trait NodeUtil<'self> {
fn get_css_select_results(self) -> &'self CompleteSelectResults;

This file was deleted.

@@ -6,10 +6,9 @@
/// 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 newcss::select::SelectHandler;
use script::dom::node::{AbstractNode, LayoutView};

pub struct NodeSelectHandler {
node: AbstractNode<LayoutView>,
@@ -4,17 +4,17 @@

use compositing::CompositorTask;
use layout::layout_task;
use layout_interface::LayoutTask;
use layout_interface;
use scripting::script_task::{ExecuteMsg, LoadMsg, ScriptMsg, ScriptTask};
use scripting::script_task;
use util::task::spawn_listener;

use core::cell::Cell;
use core::comm::{Chan, Port, SharedChan};
use gfx::opts::Opts;
use gfx::render_task::RenderTask;
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::resource_task::ResourceTask;
use servo_net::resource_task;
@@ -4,10 +4,10 @@

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

use dom::node::{AbstractNode, LayoutView};
use layout::flow::FlowContext;

use newcss::complete::CompleteSelectResults;
use script::dom::node::{AbstractNode, LayoutView};
use servo_util::tree::TreeUtils;

/// Data that layout associates with a node.
@@ -5,7 +5,6 @@
//! The `RenderBox` type, which represents the leaves of the layout tree.

use css::node_style::StyledNode;
use dom::node::{AbstractNode, LayoutView};
use layout::context::LayoutContext;
use layout::display_list_builder::{DisplayListBuilder, ToGfxColor};
use layout::flow::FlowContext;
@@ -28,6 +27,7 @@ use newcss::values::{CSSFontSizeLength, CSSFontStyleItalic, CSSFontStyleNormal};
use newcss::values::{CSSFontStyleOblique, CSSTextAlign, CSSTextDecoration};
use newcss::values::{CSSTextDecorationNone, CSSFloatNone, CSSPositionStatic};
use newcss::values::{CSSDisplayInlineBlock, CSSDisplayInlineTable};
use script::dom::node::{AbstractNode, LayoutView};
use servo_net::image::holder::ImageHolder;
use servo_net::local_image_cache::LocalImageCache;
use servo_util::range::*;
@@ -4,9 +4,6 @@

//! 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::block::BlockFlowData;
use layout::box::{GenericRenderBoxClass, ImageRenderBox, ImageRenderBoxClass, RenderBox};
@@ -20,6 +17,9 @@ use layout::inline::{InlineFlowData, InlineLayout};

use newcss::values::{CSSDisplay, CSSDisplayBlock, CSSDisplayInline, CSSDisplayInlineBlock};
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::tree::{TreeNodeRef, TreeUtils};

@@ -25,7 +25,6 @@
/// line breaks and mapping to CSS boxes, for the purpose of handling `getClientRects()` and
/// similar methods.

use dom::node::{AbstractNode, LayoutView};
use layout::block::BlockFlowData;
use layout::box::RenderBox;
use layout::context::LayoutContext;
@@ -37,6 +36,7 @@ use geom::point::Point2D;
use geom::rect::Rect;
use gfx::display_list::DisplayList;
use gfx::geometry::Au;
use script::dom::node::{AbstractNode, LayoutView};
use servo_util::tree::{TreeNode, TreeNodeRef, TreeUtils};

/// The type of the formatting context and data specific to each context, such as line box
@@ -4,7 +4,6 @@

use core::cell::Cell;
use core;
use dom::node::{AbstractNode, LayoutView};
use layout::box::{CannotSplit, GenericRenderBoxClass, ImageRenderBoxClass, RenderBox};
use layout::box::{SplitDidFit, SplitDidNotFit, TextRenderBoxClass, UnscannedTextRenderBoxClass};
use layout::context::LayoutContext;
@@ -19,9 +18,8 @@ use gfx::geometry::Au;
use gfx::text::text_run::TextRun;
use gfx::text::util::*;
use newcss::values::{CSSTextAlignCenter, CSSTextAlignJustify, CSSTextAlignLeft};
use newcss::values::{CSSTextAlignRight};
use newcss::values::CSSTextDecorationUnderline;
use newcss::values::CSSTextDecoration;
use newcss::values::{CSSTextAlignRight, CSSTextDecoration, CSSTextDecorationUnderline};
use script::dom::node::{AbstractNode, LayoutView};
use servo_util::range::Range;
use std::deque::Deque;

@@ -7,18 +7,11 @@

use css::matching::MatchMethods;
use css::select::new_css_select_ctx;
use dom::event::ReflowEvent;
use dom::node::{AbstractNode, LayoutView};
use layout::aux::{LayoutData, LayoutAuxMethods};
use layout::box_builder::LayoutTreeBuilder;
use layout::context::LayoutContext;
use layout::display_list_builder::{DisplayListBuilder, FlowDisplayListBuilderMethods};
use layout::flow::FlowContext;
use layout_interface::{AddStylesheetMsg, BuildData, BuildMsg, ContentBoxQuery, ContentBoxResponse};
use layout_interface::{ContentBoxesQuery, ContentBoxesResponse, ExitMsg, LayoutQuery};
use layout_interface::{LayoutResponse, LayoutTask, MatchSelectorsDamage, Msg, NoDamage, QueryMsg};
use layout_interface::{ReflowDamage};
use scripting::script_task::{ScriptMsg, SendEventMsg};
use util::task::spawn_listener;
use servo_util::time;
use servo_util::time::time;
@@ -40,6 +33,13 @@ use gfx::render_task::{RenderMsg, RenderTask};
use newcss::select::SelectCtx;
use newcss::stylesheet::Stylesheet;
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::local_image_cache::LocalImageCache;
use servo_util::tree::TreeUtils;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.