mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Rewrite CefBrowser::send_window_event with try_borrow
This commit is contained in:
parent
2e310f83ad
commit
3bfeaf08b1
2 changed files with 12 additions and 18 deletions
|
@ -17,7 +17,7 @@ use wrappers::CefWrap;
|
||||||
use compositing::windowing::{WindowNavigateMsg, WindowEvent};
|
use compositing::windowing::{WindowNavigateMsg, WindowEvent};
|
||||||
use glutin_app;
|
use glutin_app;
|
||||||
use libc::c_int;
|
use libc::c_int;
|
||||||
use std::cell::{Cell, RefCell, BorrowState};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::atomic::{AtomicIsize, Ordering};
|
use std::sync::atomic::{AtomicIsize, Ordering};
|
||||||
|
@ -183,24 +183,18 @@ impl ServoCefBrowserExtensions for CefBrowser {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_window_event(&self, event: WindowEvent) {
|
fn send_window_event(&self, event: WindowEvent) {
|
||||||
self.downcast().message_queue.borrow_mut().push(event);
|
let browser = self.downcast();
|
||||||
|
|
||||||
loop {
|
if let Ok(mut servo_browser) = browser.servo_browser.try_borrow_mut() {
|
||||||
match self.downcast().servo_browser.borrow_state() {
|
servo_browser.handle_event(event);
|
||||||
BorrowState::Unused => {
|
while let Some(event) = browser.message_queue.borrow_mut().pop() {
|
||||||
let event = match self.downcast().message_queue.borrow_mut().pop() {
|
servo_browser.handle_event(event);
|
||||||
None => return,
|
|
||||||
Some(event) => event,
|
|
||||||
};
|
|
||||||
self.downcast().servo_browser.borrow_mut().handle_event(event);
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
// We're trying to send an event while processing another one. This will
|
|
||||||
// cause general badness, so queue up that event instead of immediately
|
|
||||||
// processing it.
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// If we fail to borrow mutably, this means we're trying to send an
|
||||||
|
// event while processing another one. This will cause general badness,
|
||||||
|
// we just queue up that event instead of immediately processing it.
|
||||||
|
browser.message_queue.borrow_mut().push(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#![feature(borrow_state)]
|
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
#![feature(core_intrinsics)]
|
#![feature(core_intrinsics)]
|
||||||
#![feature(filling_drop)]
|
#![feature(filling_drop)]
|
||||||
#![feature(link_args)]
|
#![feature(link_args)]
|
||||||
#![feature(plugin)]
|
#![feature(plugin)]
|
||||||
|
#![feature(try_borrow)]
|
||||||
#![feature(unicode)]
|
#![feature(unicode)]
|
||||||
#![feature(unsafe_no_drop_flag)]
|
#![feature(unsafe_no_drop_flag)]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue