mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 09:45:41 +00:00
servo: Add about:mozilla and parse it
Source-Repo: https://github.com/servo/servo Source-Revision: 7bf5361a9aa05066fcbe775a366e99c42113be86
This commit is contained in:
parent
9007c3de72
commit
6965fb2286
@ -15,6 +15,7 @@ enum token {
|
||||
to_start_opening_tag(str),
|
||||
to_end_opening_tag,
|
||||
to_end_tag(str),
|
||||
to_self_close_tag,
|
||||
to_text(str),
|
||||
to_attr(str, str),
|
||||
to_doctype,
|
||||
@ -131,10 +132,13 @@ impl methods for parser {
|
||||
coe_eof { ret to_eof; }
|
||||
}
|
||||
|
||||
ret alt self.state {
|
||||
let token = alt self.state {
|
||||
ps_normal { self.parse_in_normal_state(ch) }
|
||||
ps_tag { self.parse_in_tag_state(ch) }
|
||||
}
|
||||
};
|
||||
|
||||
#debug["token=%?", token];
|
||||
ret token;
|
||||
}
|
||||
|
||||
fn parse_in_normal_state(c: u8) -> token {
|
||||
@ -195,8 +199,13 @@ impl methods for parser {
|
||||
ret to_end_opening_tag;
|
||||
}
|
||||
|
||||
if ch == ('/' as u8) {
|
||||
self.state = ps_normal;
|
||||
ret to_self_close_tag;
|
||||
}
|
||||
|
||||
if !ch.is_alpha() {
|
||||
fail "expected alphabetical in tag";
|
||||
fail #fmt("expected alphabetical in tag but found %c", ch as char);
|
||||
}
|
||||
|
||||
// Parse an attribute.
|
||||
|
@ -47,7 +47,6 @@ fn build_dom(scope: dom::node_scope,
|
||||
let mut cur = scope.new_node(dom::nk_element(element("html", ~es_div)));
|
||||
loop {
|
||||
let token = stream.recv();
|
||||
#debug["token=%?", token];
|
||||
alt token {
|
||||
parser::to_eof { break; }
|
||||
parser::to_start_opening_tag("div") {
|
||||
@ -80,7 +79,7 @@ fn build_dom(scope: dom::node_scope,
|
||||
parser::to_end_opening_tag {
|
||||
#debug("end opening tag");
|
||||
}
|
||||
parser::to_end_tag(_) {
|
||||
parser::to_end_tag(_) | parser::to_self_close_tag {
|
||||
// TODO: Assert that the closing tag has the right name.
|
||||
// TODO: Fail more gracefully (i.e. according to the HTML5
|
||||
// spec) if we close more tags than we open.
|
||||
|
54
servo/src/test/about-mozilla.html
Normal file
54
servo/src/test/about-mozilla.html
Normal file
@ -0,0 +1,54 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>The Book of Mozilla, 11:9</title>
|
||||
<style type="text/css">
|
||||
html {
|
||||
background: maroon;
|
||||
color: white;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#moztext {
|
||||
margin-top: 15%;
|
||||
font-size: 1.1em;
|
||||
font-family: serif;
|
||||
text-align: center;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
#from {
|
||||
font-size: 1.95em;
|
||||
font-family: serif;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
em {
|
||||
font-size: 1.3em;
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p id="moztext">
|
||||
Mammon slept. And the <em>beast reborn</em> spread over the earth and its numbers
|
||||
grew legion. And they proclaimed the times and <em>sacrificed</em> crops unto the
|
||||
fire, with the <em>cunning of foxes</em>. And they built a new world in their own
|
||||
image as promised by the <em><a href="http://www.mozilla.org/about/mozilla-manifesto.html">
|
||||
sacred words</a></em>, and <em><a href="http://wiki.mozilla.org/About:mozilla">spoke
|
||||
</a></em> of the beast with their children. Mammon awoke, and lo! it was
|
||||
<em>naught</em> but a follower.
|
||||
</p>
|
||||
|
||||
<p id="from">
|
||||
from <strong>The Book of Mozilla,</strong> 11:9<br/><small>(10th Edition)</small>
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user