mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #20533 - paulrouget:res, r=mbrubeck
Delegate resource reading to embedder Now the embedder provides the content of the files itself. Now, on Android, we can use regular assets instead of unzipping all the resources on the scared at startup. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [ ] `./mach build-geckolib` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #15635 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20533) <!-- Reviewable:end -->
This commit is contained in:
commit
d1378d6bad
52 changed files with 472 additions and 396 deletions
|
@ -30,6 +30,7 @@ use dom::processinginstruction::ProcessingInstruction;
|
|||
use dom::text::Text;
|
||||
use dom::virtualmethods::vtable_for;
|
||||
use dom_struct::dom_struct;
|
||||
use embedder_traits::resources::{self, Resource};
|
||||
use html5ever::{Attribute, ExpandedName, LocalName, QualName};
|
||||
use html5ever::buffer_queue::BufferQueue;
|
||||
use html5ever::tendril::{StrTendril, ByteTendril, IncompleteUtf8};
|
||||
|
@ -45,7 +46,6 @@ use profile_traits::time::{TimerMetadataReflowType, ProfilerCategory, profile};
|
|||
use script_thread::ScriptThread;
|
||||
use script_traits::DocumentActivity;
|
||||
use servo_config::prefs::PREFS;
|
||||
use servo_config::resource_files::read_resource_file;
|
||||
use servo_url::ServoUrl;
|
||||
use std::borrow::Cow;
|
||||
use std::cell::Cell;
|
||||
|
@ -671,16 +671,14 @@ impl FetchResponseListener for ParserContext {
|
|||
// Handle text/html
|
||||
if let Some(reason) = ssl_error {
|
||||
self.is_synthesized_document = true;
|
||||
let page_bytes = read_resource_file("badcert.html").unwrap();
|
||||
let page = String::from_utf8(page_bytes).unwrap();
|
||||
let page = resources::read_string(Resource::BadCertHTML);
|
||||
let page = page.replace("${reason}", &reason);
|
||||
parser.push_string_input_chunk(page);
|
||||
parser.parse_sync();
|
||||
}
|
||||
if let Some(reason) = network_error {
|
||||
self.is_synthesized_document = true;
|
||||
let page_bytes = read_resource_file("neterror.html").unwrap();
|
||||
let page = String::from_utf8(page_bytes).unwrap();
|
||||
let page = resources::read_string(Resource::NetErrorHTML);
|
||||
let page = page.replace("${reason}", &reason);
|
||||
parser.push_string_input_chunk(page);
|
||||
parser.parse_sync();
|
||||
|
|
|
@ -8,7 +8,6 @@ use dom::htmlheadelement::HTMLHeadElement;
|
|||
use dom::node::Node;
|
||||
use js::jsval::UndefinedValue;
|
||||
use servo_config::opts;
|
||||
use servo_config::resource_files::resources_dir_path;
|
||||
use std::fs::{File, read_dir};
|
||||
use std::io::Read;
|
||||
use std::path::PathBuf;
|
||||
|
@ -22,17 +21,7 @@ pub fn load_script(head: &HTMLHeadElement) {
|
|||
let cx = win.get_cx();
|
||||
rooted!(in(cx) let mut rval = UndefinedValue());
|
||||
|
||||
let path = if &**path_str == "" {
|
||||
if let Ok(mut p) = resources_dir_path() {
|
||||
p.push("user-agent-js");
|
||||
p
|
||||
} else {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
PathBuf::from(path_str)
|
||||
};
|
||||
|
||||
let path = PathBuf::from(path_str);
|
||||
let mut files = read_dir(&path).expect("Bad path passed to --userscripts")
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| e.path()).collect::<Vec<_>>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue