mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Implement view-source protocol. Fixes #4181.
This follows the recommendation from issue #4181. A handler for 'view-source' delegates to the HTTP loader. In that loader I check for view-source, adjust the URL to be the URL to be viewed and modify the Content-Type header to be text/plain. This doesn't actually result in the source being viewed as rendering text/plain is not yet implemented.
This commit is contained in:
parent
f5ddbcf19f
commit
82c52a7a1c
3 changed files with 34 additions and 3 deletions
|
@ -190,6 +190,20 @@ pub fn parse_html(document: JSRef<Document>,
|
|||
let page = format!("<html><body><img src='{}' /></body></html>", url.serialize());
|
||||
parser.parse_chunk(page);
|
||||
},
|
||||
Some((ref t, ref st)) if t.as_slice().eq_ignore_ascii_case("text") &&
|
||||
st.as_slice().eq_ignore_ascii_case("plain") => {
|
||||
// FIXME: When servo/html5ever#109 is fixed remove <plaintext> usage and
|
||||
// replace with fix from that issue.
|
||||
|
||||
// text/plain documents require setting the tokenizer into PLAINTEXT mode.
|
||||
// This is done by using a <plaintext> element as the html5ever tokenizer
|
||||
// provides no other way to change to that state.
|
||||
// Spec for text/plain handling is:
|
||||
// https://html.spec.whatwg.org/multipage/browsers.html#read-text
|
||||
let page = format!("<pre>\u{000A}<plaintext>");
|
||||
parser.parse_chunk(page);
|
||||
parse_progress(&parser, url, &load_response);
|
||||
},
|
||||
_ => {
|
||||
for msg in load_response.progress_port.iter() {
|
||||
match msg {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue