aboutsummaryrefslogtreecommitdiffstats
path: root/ports/servoshell/egl/android
diff options
context:
space:
mode:
authorJonathan Schwender <55576758+jschwe@users.noreply.github.com>2024-09-24 06:29:53 +0200
committerGitHub <noreply@github.com>2024-09-24 04:29:53 +0000
commit88ffe9f7a56ef0981805a7b8264f870947cebcf5 (patch)
treebe2cfad7fefaaea0b5f303c292f9fc6ff6462513 /ports/servoshell/egl/android
parentff86771b481bb241d85a913ca923b5d31ed8352c (diff)
downloadservo-88ffe9f7a56ef0981805a7b8264f870947cebcf5.tar.gz
servo-88ffe9f7a56ef0981805a7b8264f870947cebcf5.zip
ohos: Bundle resource files in hap (#33513)
Bundle resource files into the .hap, so they are available as files in the application sandbox, instead of included into the shared library. This should slightly reduce the binary size in debug and release mode. Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>
Diffstat (limited to 'ports/servoshell/egl/android')
-rw-r--r--ports/servoshell/egl/android/resources.rs56
-rw-r--r--ports/servoshell/egl/android/simpleservo.rs4
2 files changed, 58 insertions, 2 deletions
diff --git a/ports/servoshell/egl/android/resources.rs b/ports/servoshell/egl/android/resources.rs
new file mode 100644
index 00000000000..fb9d837aeb6
--- /dev/null
+++ b/ports/servoshell/egl/android/resources.rs
@@ -0,0 +1,56 @@
+/* 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 https://mozilla.org/MPL/2.0/. */
+use std::path::PathBuf;
+
+use servo::embedder_traits::resources::{Resource, ResourceReaderMethods};
+
+pub(crate) struct ResourceReaderInstance;
+
+impl ResourceReaderInstance {
+ pub(crate) fn new() -> ResourceReaderInstance {
+ ResourceReaderInstance
+ }
+}
+
+impl ResourceReaderMethods for ResourceReaderInstance {
+ fn read(&self, res: Resource) -> Vec<u8> {
+ Vec::from(match res {
+ Resource::Preferences => &include_bytes!("../../../../resources/prefs.json")[..],
+ Resource::HstsPreloadList => {
+ &include_bytes!("../../../../resources/hsts_preload.json")[..]
+ },
+ Resource::BadCertHTML => &include_bytes!("../../../../resources/badcert.html")[..],
+ Resource::NetErrorHTML => &include_bytes!("../../../../resources/neterror.html")[..],
+ Resource::UserAgentCSS => &include_bytes!("../../../../resources/user-agent.css")[..],
+ Resource::ServoCSS => &include_bytes!("../../../../resources/servo.css")[..],
+ Resource::PresentationalHintsCSS => {
+ &include_bytes!("../../../../resources/presentational-hints.css")[..]
+ },
+ Resource::QuirksModeCSS => &include_bytes!("../../../../resources/quirks-mode.css")[..],
+ Resource::RippyPNG => &include_bytes!("../../../../resources/rippy.png")[..],
+ Resource::DomainList => &include_bytes!("../../../../resources/public_domains.txt")[..],
+ Resource::BluetoothBlocklist => {
+ &include_bytes!("../../../../resources/gatt_blocklist.txt")[..]
+ },
+ Resource::MediaControlsCSS => {
+ &include_bytes!("../../../../resources/media-controls.css")[..]
+ },
+ Resource::MediaControlsJS => {
+ &include_bytes!("../../../../resources/media-controls.js")[..]
+ },
+ Resource::CrashHTML => &include_bytes!("../../../../resources/crash.html")[..],
+ Resource::DirectoryListingHTML => {
+ &include_bytes!("../../../../resources/directory-listing.html")[..]
+ },
+ })
+ }
+
+ fn sandbox_access_files(&self) -> Vec<PathBuf> {
+ vec![]
+ }
+
+ fn sandbox_access_files_dirs(&self) -> Vec<PathBuf> {
+ vec![]
+ }
+}
diff --git a/ports/servoshell/egl/android/simpleservo.rs b/ports/servoshell/egl/android/simpleservo.rs
index d5b9a73ebc8..194203d9102 100644
--- a/ports/servoshell/egl/android/simpleservo.rs
+++ b/ports/servoshell/egl/android/simpleservo.rs
@@ -27,8 +27,8 @@ use servo::webrender_traits::RenderingContext;
use servo::{self, gl, Servo};
use surfman::{Connection, SurfaceType};
+use crate::egl::android::resources::ResourceReaderInstance;
use crate::egl::host_trait::HostTrait;
-use crate::egl::resources::ResourceReaderInstance;
use crate::egl::servo_glue::{
Coordinates, ServoEmbedderCallbacks, ServoGlue, ServoWindowCallbacks,
};
@@ -173,7 +173,7 @@ pub fn init(
);
SERVO.with(|s| {
- let mut servo_glue = ServoGlue::new(rendering_context, servo.servo, window_callbacks);
+ let mut servo_glue = ServoGlue::new(rendering_context, servo.servo, window_callbacks, None);
let _ = servo_glue.process_event(EmbedderEvent::NewWebView(url, servo.browser_id));
*s.borrow_mut() = Some(servo_glue);
});