diff options
author | bors-servo <metajack+bors@gmail.com> | 2014-10-29 14:36:45 -0600 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2014-10-29 14:36:45 -0600 |
commit | 5858fccf873ce30896def4f58aa8c67d1ddd09f1 (patch) | |
tree | d440109063827508e28dcc06b594b435fb5f3ef6 /components/script/parse | |
parent | fec3d53b1ecd170fc63eb305b6bb3c6bc3bf186d (diff) | |
parent | 6a736c7f3c9456224aadde71ebbd62e844fd6877 (diff) | |
download | servo-5858fccf873ce30896def4f58aa8c67d1ddd09f1.tar.gz servo-5858fccf873ce30896def4f58aa8c67d1ddd09f1.zip |
auto merge of #3718 : juzer10/servo/master, r=jdm
We have created parser trait and declared parse_chunk function in this trait. We are yet to implement this parse_chunk for ServoHTMLParser struct.
Diffstat (limited to 'components/script/parse')
-rw-r--r-- | components/script/parse/html.rs | 9 | ||||
-rw-r--r-- | components/script/parse/mod.rs | 10 |
2 files changed, 15 insertions, 4 deletions
diff --git a/components/script/parse/html.rs b/components/script/parse/html.rs index 8eca823236a..28f13562619 100644 --- a/components/script/parse/html.rs +++ b/components/script/parse/html.rs @@ -18,6 +18,7 @@ use dom::servohtmlparser; use dom::servohtmlparser::ServoHTMLParser; use dom::types::*; use page::Page; +use parse::Parser; use encoding::all::UTF_8; use encoding::types::{Encoding, DecodeReplace}; @@ -486,14 +487,14 @@ pub fn parse_html(page: &Page, match input { InputString(s) => { - parser.tokenizer().borrow_mut().feed(s); + parser.parse_chunk(s); } InputUrl(url) => { let load_response = load_response.unwrap(); match load_response.metadata.content_type { Some((ref t, _)) if t.as_slice().eq_ignore_ascii_case("image") => { let page = format!("<html><body><img src='{:s}' /></body></html>", base_url.as_ref().unwrap().serialize()); - parser.tokenizer().borrow_mut().feed(page); + parser.parse_chunk(page); }, _ => { for msg in load_response.progress_port.iter() { @@ -501,7 +502,7 @@ pub fn parse_html(page: &Page, Payload(data) => { // FIXME: use Vec<u8> (html5ever #34) let data = UTF_8.decode(data.as_slice(), DecodeReplace).unwrap(); - parser.tokenizer().borrow_mut().feed(data); + parser.parse_chunk(data); } Done(Err(err)) => { fail!("Failed to load page URL {:s}, error: {:s}", url.serialize(), err); @@ -514,7 +515,7 @@ pub fn parse_html(page: &Page, } } - parser.tokenizer().borrow_mut().end(); + parser.finish(); task_state::exit(InHTMLParser); diff --git a/components/script/parse/mod.rs b/components/script/parse/mod.rs new file mode 100644 index 00000000000..6111f196053 --- /dev/null +++ b/components/script/parse/mod.rs @@ -0,0 +1,10 @@ +/* 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 mod html; + +pub trait Parser { + fn parse_chunk(&self,input: String); + fn finish(&self); +} |