servo: Parse unknown HTML elements into something sane

Source-Repo: https://github.com/servo/servo
Source-Revision: f5236ef7e3a88e7abeb2f2263950f14868e0427a
This commit is contained in:
Patrick Walton 2012-05-24 13:57:50 -07:00
Родитель a5930f9392
Коммит 5a7a496877
5 изменённых файлов: 12 добавлений и 6 удалений

Просмотреть файл

@ -24,6 +24,7 @@ class element {
}
enum element_subclass {
es_unknown,
es_div,
es_img(size<au>)
}

Просмотреть файл

@ -124,6 +124,7 @@ impl box_builder_priv for node {
alt *element.subclass {
es_div { bk_block }
es_img(size) { bk_intrinsic(@size) }
es_unknown { bk_inline }
}
}
}

Просмотреть файл

@ -29,7 +29,7 @@ impl inline_layout_methods for @box {
self.bounds.size = { mut width: available_width,
mut height: au(current_height) };
#debug["reflow_inline root=%? size=%?", self, self.bounds];
#debug["reflow_inline size=%?", self.bounds];
}
}

Просмотреть файл

@ -24,6 +24,7 @@ fn default_style_for_node_kind(kind: node_kind) -> computed_style {
alt *element.subclass {
es_div { computed_style({ mut display: di_block }) }
es_img(*) { computed_style({ mut display: di_inline }) }
es_unknown { computed_style({ mut display: di_inline }) }
}
}
}
@ -42,7 +43,6 @@ impl style_priv for node {
default_style_for_node_kind(self.rd { |n| *n.kind });
#debug("recomputing style; parent node:");
self.dump();
let the_layout_data = @layout_data({
mut computed_style: default_style,

Просмотреть файл

@ -1,8 +1,8 @@
#[doc="Constructs a DOM tree from an incoming token stream."]
import dom::rcu::writer_methods;
import dom::base::{element, es_div, es_img, methods, nk_element, nk_text};
import dom::base::{rd_tree_ops, wr_tree_ops};
import dom::base::{element, es_div, es_img, es_unknown, methods, nk_element};
import dom::base::{nk_text, rd_tree_ops, wr_tree_ops};
import dom = dom::base;
import parser = parser::html;
import html::token;
@ -29,7 +29,7 @@ fn link_up_attribute(scope: dom::node_scope, node: dom::node, key: str,
some(s) { dimensions.height = geom::px_to_au(s); }
}
}
es_div | es_img(*) {
es_div | es_img(*) | es_unknown {
// Drop on the floor.
}
}
@ -67,7 +67,11 @@ fn build_dom(scope: dom::node_scope,
cur = new_node;
}
parser::to_start_opening_tag(t) {
fail ("Unrecognized tag: " + t);
#debug["unknown element: %s", t];
let new_node =
scope.new_node(dom::nk_element(element(t, ~es_unknown)));
scope.add_child(cur, new_node);
cur = new_node;
}
parser::to_attr(key, value) {
#debug["attr: %? = %?", key, value];