mirror of
https://github.com/servo/servo.git
synced 2025-08-02 04:00:32 +01:00
Make Metadata use ContentType
This commit is contained in:
parent
fe81ce942a
commit
19ffab82f1
5 changed files with 47 additions and 18 deletions
|
@ -38,7 +38,6 @@ use net_traits::{ProgressMsg, LoadResponse};
|
|||
use util::str::DOMString;
|
||||
use util::task_state;
|
||||
use util::task_state::IN_HTML_PARSER;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::borrow::Cow;
|
||||
use std::old_io::{Writer, IoResult};
|
||||
use url::Url;
|
||||
|
@ -49,6 +48,9 @@ use html5ever::serialize::TraversalScope::{IncludeNode, ChildrenOnly};
|
|||
use html5ever::tree_builder::{TreeSink, QuirksMode, NodeOrText, AppendNode, AppendText};
|
||||
use string_cache::QualName;
|
||||
|
||||
use hyper::header::ContentType;
|
||||
use hyper::mime::{Mime, TopLevel, SubLevel};
|
||||
|
||||
pub enum HTMLInput {
|
||||
InputString(String),
|
||||
InputUrl(LoadResponse),
|
||||
|
@ -297,12 +299,11 @@ pub fn parse_html(document: JSRef<Document>,
|
|||
}
|
||||
HTMLInput::InputUrl(load_response) => {
|
||||
match load_response.metadata.content_type {
|
||||
Some((ref t, _)) if t.as_slice().eq_ignore_ascii_case("image") => {
|
||||
Some(ContentType(Mime(TopLevel::Image, _, _))) => {
|
||||
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") => {
|
||||
Some(ContentType(Mime(TopLevel::Text, SubLevel::Plain, _))) => {
|
||||
// FIXME: When servo/html5ever#109 is fixed remove <plaintext> usage and
|
||||
// replace with fix from that issue.
|
||||
|
||||
|
|
|
@ -83,7 +83,6 @@ use js;
|
|||
use url::Url;
|
||||
|
||||
use libc;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::any::Any;
|
||||
use std::borrow::ToOwned;
|
||||
use std::cell::{Cell, RefCell};
|
||||
|
@ -96,6 +95,9 @@ use std::result::Result;
|
|||
use std::sync::mpsc::{channel, Sender, Receiver, Select};
|
||||
use time::Tm;
|
||||
|
||||
use hyper::header::ContentType;
|
||||
use hyper::mime::{Mime, TopLevel, SubLevel};
|
||||
|
||||
thread_local!(pub static STACK_ROOTS: Cell<Option<RootCollectionPtr>> = Cell::new(None));
|
||||
thread_local!(static SCRIPT_TASK_ROOT: RefCell<Option<*const ScriptTask>> = RefCell::new(None));
|
||||
|
||||
|
@ -1052,10 +1054,7 @@ impl ScriptTask {
|
|||
});
|
||||
|
||||
let content_type = match response.metadata.content_type {
|
||||
Some((ref t, ref st)) if t.as_slice().eq_ignore_ascii_case("text") &&
|
||||
st.as_slice().eq_ignore_ascii_case("plain") => {
|
||||
Some("text/plain".to_owned())
|
||||
}
|
||||
Some(ContentType(Mime(TopLevel::Text, SubLevel::Plain, _))) => Some("text/plain".to_owned()),
|
||||
_ => None
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue