mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
CamelCase everything in dom/base
This commit is contained in:
parent
876e1307e3
commit
09ee4b18ef
7 changed files with 45 additions and 44 deletions
|
@ -7,6 +7,7 @@ export ControlMsg, PingMsg;
|
|||
export content;
|
||||
|
||||
import result::extensions;
|
||||
import dom::base::NodeScope;
|
||||
import dom::rcu::writer_methods;
|
||||
import dom::style;
|
||||
import dom = dom::base;
|
||||
|
@ -24,7 +25,7 @@ enum PingMsg {
|
|||
}
|
||||
|
||||
#[doc="Sends a ping to layout and waits for the response."]
|
||||
fn join_layout(scope: dom::node_scope, to_layout: chan<layout_task::Msg>) {
|
||||
fn join_layout(scope: NodeScope, to_layout: chan<layout_task::Msg>) {
|
||||
|
||||
if scope.is_reader_forked() {
|
||||
comm::listen {
|
||||
|
@ -39,7 +40,7 @@ fn join_layout(scope: dom::node_scope, to_layout: chan<layout_task::Msg>) {
|
|||
fn content(to_layout: chan<layout_task::Msg>) -> chan<ControlMsg> {
|
||||
task::spawn_listener::<ControlMsg> {
|
||||
|from_master|
|
||||
let scope = dom::node_scope();
|
||||
let scope = dom::NodeScope();
|
||||
let rt = js::rust::rt();
|
||||
loop {
|
||||
alt from_master.recv() {
|
||||
|
|
|
@ -5,12 +5,12 @@ import layout::base::layout_data;
|
|||
import util::tree;
|
||||
import dvec::{dvec, extensions};
|
||||
|
||||
enum node_data = {
|
||||
enum NodeData = {
|
||||
tree: tree::fields<Node>,
|
||||
kind: ~node_kind,
|
||||
kind: ~NodeKind,
|
||||
};
|
||||
|
||||
enum node_kind {
|
||||
enum NodeKind {
|
||||
Element(ElementData),
|
||||
Text(str)
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ enum node_kind {
|
|||
class ElementData {
|
||||
let tag_name: str;
|
||||
let kind: ~ElementKind;
|
||||
let attrs: dvec<~attr>;
|
||||
let attrs: dvec<~Attr>;
|
||||
|
||||
new(-tag_name: str, -kind: ~ElementKind) {
|
||||
self.tag_name = tag_name;
|
||||
|
@ -39,7 +39,7 @@ class ElementData {
|
|||
}
|
||||
}
|
||||
|
||||
class attr {
|
||||
class Attr {
|
||||
let name: str;
|
||||
let value: str;
|
||||
|
||||
|
@ -61,20 +61,21 @@ enum ElementKind {
|
|||
the primary box. Note that there may be multiple boxes per DOM node.
|
||||
"]
|
||||
|
||||
type Node = rcu::handle<node_data, layout_data>;
|
||||
type Node = rcu::handle<NodeData, layout_data>;
|
||||
|
||||
type node_scope = rcu::scope<node_data, layout_data>;
|
||||
type NodeScope = rcu::scope<NodeData, layout_data>;
|
||||
|
||||
fn node_scope() -> node_scope { rcu::scope() }
|
||||
fn NodeScope() -> NodeScope {
|
||||
rcu::scope()
|
||||
}
|
||||
|
||||
impl methods for node_scope {
|
||||
fn new_node(-k: node_kind) -> Node {
|
||||
self.handle(node_data({tree: tree::empty(),
|
||||
kind: ~k}))
|
||||
impl NodeScope for NodeScope {
|
||||
fn new_node(-k: NodeKind) -> Node {
|
||||
self.handle(NodeData({tree: tree::empty(), kind: ~k}))
|
||||
}
|
||||
}
|
||||
|
||||
impl of tree::rd_tree_ops<Node> for node_scope {
|
||||
impl of tree::rd_tree_ops<Node> for NodeScope {
|
||||
fn each_child(node: Node, f: fn(Node) -> bool) {
|
||||
tree::each_child(self, node, f)
|
||||
}
|
||||
|
@ -88,7 +89,7 @@ impl of tree::rd_tree_ops<Node> for node_scope {
|
|||
}
|
||||
}
|
||||
|
||||
impl of tree::wr_tree_ops<Node> for node_scope {
|
||||
impl of tree::wr_tree_ops<Node> for NodeScope {
|
||||
fn add_child(node: Node, child: Node) {
|
||||
tree::add_child(self, node, child)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#[doc="Fundamental layout structures and algorithms."]
|
||||
|
||||
import dom::base::{Element, ElementKind, HTMLDivElement, HTMLImageElement, node_data, node_kind};
|
||||
import dom::base::{Node};
|
||||
import dom::base::{Element, ElementKind, HTMLDivElement, HTMLImageElement, Node, NodeData};
|
||||
import dom::base::{NodeKind};
|
||||
import dom::rcu;
|
||||
import dom::rcu::reader_methods;
|
||||
import gfx::geometry;
|
||||
|
@ -121,7 +121,7 @@ impl layout_methods for @box {
|
|||
|
||||
// Debugging
|
||||
|
||||
impl node_methods_priv for Node {
|
||||
impl PrivateNodeMethods for Node {
|
||||
#[doc="Dumps the node tree, for debugging, with indentation."]
|
||||
fn dump_indent(indent: uint) {
|
||||
let mut s = "";
|
||||
|
@ -137,7 +137,7 @@ impl node_methods_priv for Node {
|
|||
}
|
||||
}
|
||||
|
||||
impl node_methods for Node {
|
||||
impl NodeMethods for Node {
|
||||
#[doc="Dumps the subtree rooted at this node, for debugging."]
|
||||
fn dump() {
|
||||
self.dump_indent(0u);
|
||||
|
@ -146,8 +146,8 @@ impl node_methods for Node {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
import dom::base::{ElementData, HTMLDivElement, HTMLImageElement, methods, Element, node_data};
|
||||
import dom::base::{Node, node_kind, wr_tree_ops};
|
||||
import dom::base::{Element, ElementData, HTMLDivElement, HTMLImageElement, Node, NodeKind};
|
||||
import dom::base::{NodeScope, wr_tree_ops};
|
||||
import dom::rcu::scope;
|
||||
import box_builder::{box_builder_methods};
|
||||
|
||||
|
|
|
@ -4,9 +4,8 @@ import dom::base::{ElementData, HTMLDivElement, HTMLImageElement, Element, Text,
|
|||
import dom::style::{display_type, di_block, di_inline, di_none};
|
||||
import dom::rcu::reader_methods;
|
||||
import gfx::geometry;
|
||||
import layout::base::{appearance, bk_block, bk_inline, bk_intrinsic};
|
||||
import layout::base::{bk_text, box, box_kind, btree, node_methods, ntree};
|
||||
import layout::base::{rd_tree_ops, wr_tree_ops};
|
||||
import layout::base::{NodeMethods, appearance, bk_block, bk_inline, bk_intrinsic, bk_text, box};
|
||||
import layout::base::{box_kind, btree, ntree, rd_tree_ops, wr_tree_ops};
|
||||
import layout::style::style::{style_methods};
|
||||
import layout::text::text_box;
|
||||
import util::tree;
|
||||
|
|
|
@ -202,21 +202,21 @@ impl matching_methods for Node {
|
|||
}
|
||||
|
||||
mod test {
|
||||
import dom::base::{node_scope, methods, Element, attr, HTMLDivElement, HTMLImageElement};
|
||||
import dom::base::{UnknownElement, HTMLHeadElement, wr_tree_ops};
|
||||
import dom::base::{Attr, Element, HTMLDivElement, HTMLHeadElement, HTMLImageElement};
|
||||
import dom::base::{NodeScope, UnknownElement, wr_tree_ops};
|
||||
import dvec::{dvec, extensions};
|
||||
import io::println;
|
||||
|
||||
fn new_node_from_attr(scope: node_scope, -name: str, -val: str) -> Node {
|
||||
fn new_node_from_attr(scope: NodeScope, -name: str, -val: str) -> Node {
|
||||
let elmt = ElementData("div", ~HTMLDivElement);
|
||||
let attr = ~attr(name, val);
|
||||
let attr = ~Attr(name, val);
|
||||
elmt.attrs.push(attr);
|
||||
ret scope.new_node(Element(elmt));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_match_pipe1() {
|
||||
let scope = node_scope();
|
||||
let scope = NodeScope();
|
||||
let node = new_node_from_attr(scope, "lang", "en-us");
|
||||
|
||||
let sel = element("*", [starts_with("lang", "en")]);
|
||||
|
@ -226,7 +226,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_match_pipe2() {
|
||||
let scope = node_scope();
|
||||
let scope = NodeScope();
|
||||
let node = new_node_from_attr(scope, "lang", "en");
|
||||
|
||||
let sel = element("*", [starts_with("lang", "en")]);
|
||||
|
@ -236,7 +236,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_not_match_pipe() {
|
||||
let scope = node_scope();
|
||||
let scope = NodeScope();
|
||||
let node = new_node_from_attr(scope, "lang", "english");
|
||||
|
||||
let sel = element("*", [starts_with("lang", "en")]);
|
||||
|
@ -246,7 +246,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_match_includes() {
|
||||
let scope = node_scope();
|
||||
let scope = NodeScope();
|
||||
let node = new_node_from_attr(scope, "mad", "hatter cobler cooper");
|
||||
|
||||
let sel = element("div", [includes("mad", "hatter")]);
|
||||
|
@ -256,7 +256,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_match_exists() {
|
||||
let scope = node_scope();
|
||||
let scope = NodeScope();
|
||||
let node = new_node_from_attr(scope, "mad", "hatter cobler cooper");
|
||||
|
||||
let sel1 = element("div", [exists("mad")]);
|
||||
|
@ -268,7 +268,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_match_exact() {
|
||||
let scope = node_scope();
|
||||
let scope = NodeScope();
|
||||
let node1 = new_node_from_attr(scope, "mad", "hatter cobler cooper");
|
||||
let node2 = new_node_from_attr(scope, "mad", "hatter");
|
||||
|
||||
|
@ -280,7 +280,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn match_tree() {
|
||||
let scope = node_scope();
|
||||
let scope = NodeScope();
|
||||
|
||||
let root = new_node_from_attr(scope, "class", "blue");
|
||||
let child1 = new_node_from_attr(scope, "id", "green");
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#[doc="High-level interface to CSS selector matching."]
|
||||
|
||||
import dom::style::{display_type, di_block, di_inline, di_none, stylesheet};
|
||||
import dom::base::{Element, HTMLDivElement, HTMLHeadElement, HTMLImageElement, Node, Text};
|
||||
import dom::base::node_kind;
|
||||
import dom::base::{Element, HTMLDivElement, HTMLHeadElement, HTMLImageElement, Node, NodeKind};
|
||||
import dom::base::{Text};
|
||||
import dom::rcu::reader_methods;
|
||||
import layout::base::*; // FIXME: resolve bug requires *
|
||||
import matching::matching_methods;
|
||||
|
@ -13,7 +13,7 @@ type computed_style = {mut display : display_type,
|
|||
mut back_color : Color};
|
||||
|
||||
#[doc="Returns the default style for the given node kind."]
|
||||
fn default_style_for_node_kind(kind: node_kind) -> computed_style {
|
||||
fn default_style_for_node_kind(kind: NodeKind) -> computed_style {
|
||||
alt kind {
|
||||
Text(*) {
|
||||
{mut display: di_inline,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#[doc="Constructs a DOM tree from an incoming token stream."]
|
||||
|
||||
import dom::rcu::writer_methods;
|
||||
import dom::base::{attr, ElementKind, HTMLDivElement, HTMLHeadElement, HTMLImageElement};
|
||||
import dom::base::{UnknownElement, methods, Element, ElementData, Node, Text, rd_tree_ops};
|
||||
import dom::base::{Attr, Element, ElementData, ElementKind, HTMLDivElement, HTMLHeadElement};
|
||||
import dom::base::{HTMLImageElement, Node, NodeScope, Text, UnknownElement, rd_tree_ops};
|
||||
import dom::base::{wr_tree_ops};
|
||||
import dom = dom::base;
|
||||
import dvec::extensions;
|
||||
|
@ -12,13 +12,13 @@ import gfx::geometry::au;
|
|||
import parser = parser::lexer::html;
|
||||
import parser::token;
|
||||
|
||||
fn link_up_attribute(scope: dom::node_scope, node: Node, -key: str, -value: str) {
|
||||
fn link_up_attribute(scope: NodeScope, node: Node, -key: str, -value: str) {
|
||||
// TODO: Implement atoms so that we don't always perform string comparisons.
|
||||
scope.rd(node) {
|
||||
|node_contents|
|
||||
alt *node_contents.kind {
|
||||
Element(element) {
|
||||
element.attrs.push(~attr(copy key, copy value));
|
||||
element.attrs.push(~Attr(copy key, copy value));
|
||||
alt *element.kind {
|
||||
HTMLImageElement(img) if key == "width" {
|
||||
alt int::from_str(value) {
|
||||
|
@ -65,7 +65,7 @@ fn build_element_kind(tag_name: str) -> ~ElementKind {
|
|||
}
|
||||
}
|
||||
|
||||
fn build_dom(scope: dom::node_scope, stream: port<token>) -> Node {
|
||||
fn build_dom(scope: NodeScope, stream: port<token>) -> Node {
|
||||
// The current reference node.
|
||||
let mut cur = scope.new_node(Element(ElementData("html", ~HTMLDivElement)));
|
||||
loop {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue