Update Servo::get_events to return drain type (#31181)

* Update Servo::get_events to return drain type to prevent constant allocation

* Remove type alias for tlwc

* Fix libsimpleservo
This commit is contained in:
Ngo Iok Ui (Wu Yu Wei) 2024-01-26 19:25:12 +09:00 committed by GitHub
parent 21dbf0ad3a
commit 266a082206
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 12 deletions

View file

@ -462,7 +462,7 @@ impl App {
// Take any new embedder messages from Servo itself.
embedder_messages = self.servo.as_mut().unwrap().get_events();
if embedder_messages.is_empty() {
if embedder_messages.len() == 0 {
break;
}
}

View file

@ -7,6 +7,7 @@ use std::fs::File;
use std::io::Write;
use std::rc::Rc;
use std::time::Duration;
use std::vec::Drain;
use std::{env, thread};
use arboard::Clipboard;
@ -292,7 +293,7 @@ where
/// Returns true if the caller needs to manually present a new frame.
pub fn handle_servo_events(
&mut self,
events: Vec<(Option<WebViewId>, EmbedderMsg)>,
events: Drain<'_, (Option<WebViewId>, EmbedderMsg)>,
) -> ServoEventResponse {
let mut need_present = false;
let mut history_changed = false;