libservo: Combine LoadStart, HeadParsed, and LoadComplete` messages (#35260)

These will be a single method in the upcoming `WebView` delegate, so it
makes sense to also combine the internal message to match this. In
addition, since `LoadStatus` is now exposed to the API if there is ever
the need to add more statuses or to move to an event-based version, the
API is already set up for this.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-02-03 23:31:17 +01:00 committed by GitHub
parent b8ab820e3c
commit fdfaf7b15c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 97 additions and 92 deletions

View file

@ -15,7 +15,7 @@ use jni::objects::{GlobalRef, JClass, JObject, JString, JValue, JValueOwned};
use jni::sys::{jboolean, jfloat, jint, jobject};
use jni::{JNIEnv, JavaVM};
use log::{debug, error, info, warn};
use servo::MediaSessionActionType;
use servo::{LoadStatus, MediaSessionActionType};
use simpleservo::{
DeviceIntRect, EventLoopWaker, InitOptions, InputMethodType, MediaSessionPlaybackState,
PromptResult, SERVO,
@ -496,18 +496,20 @@ impl HostTrait for HostCallbacks {
Some(default)
}
fn on_load_started(&self) {
debug!("on_load_started");
fn notify_load_status_changed(&self, load_status: LoadStatus) {
debug!("notify_load_status_changed: {load_status:?}");
let mut env = self.jvm.get_env().unwrap();
env.call_method(self.callbacks.as_obj(), "onLoadStarted", "()V", &[])
.unwrap();
}
fn on_load_ended(&self) {
debug!("on_load_ended");
let mut env = self.jvm.get_env().unwrap();
env.call_method(self.callbacks.as_obj(), "onLoadEnded", "()V", &[])
.unwrap();
match load_status {
LoadStatus::Started => {
env.call_method(self.callbacks.as_obj(), "onLoadStarted", "()V", &[])
.unwrap();
},
LoadStatus::HeadParsed => {},
LoadStatus::Complete => {
env.call_method(self.callbacks.as_obj(), "onLoadEnded", "()V", &[])
.unwrap();
},
};
}
fn on_shutdown_complete(&self) {