Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move tinyfiledialog call from script to embedder #23651

Closed
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Factored out permission_state_invocation_results API to GlobalScope

Instead of Window
  • Loading branch information
gatoWololo committed Jun 27, 2019
commit ab187586996a6f6307097fddc3ed55e7a304d338
@@ -4,6 +4,7 @@

use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::EventSourceBinding::EventSourceBinding::EventSourceMethods;
use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionState;
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use crate::dom::bindings::codegen::Bindings::WorkerGlobalScopeBinding::WorkerGlobalScopeMethods;
use crate::dom::bindings::conversions::{root_from_object, root_from_object_static};
@@ -125,6 +126,9 @@ pub struct GlobalScope {
/// The origin of the globalscope
origin: MutableOrigin,

/// A map for storing the previous permission state read results.
permission_state_invocation_results: DomRefCell<HashMap<String, PermissionState>>,

/// The microtask queue associated with this global.
///
/// It is refcounted because windows in the same script thread share the
@@ -198,6 +202,7 @@ impl GlobalScope {
resource_threads,
timers: OneshotTimers::new(timer_event_chan, scheduler_chan),
origin,
permission_state_invocation_results: Default::default(),
microtask_queue,
list_auto_close_worker: Default::default(),
event_source_tracker: DOMTracker::new(),
@@ -208,6 +213,12 @@ impl GlobalScope {
}
}

pub fn permission_state_invocation_results(
&self,
) -> &DomRefCell<HashMap<String, PermissionState>> {
&self.permission_state_invocation_results
}

pub fn track_worker(&self, closing_worker: Arc<AtomicBool>) {
self.list_auto_close_worker
.borrow_mut()
@@ -145,7 +145,6 @@ impl Permissions {
// (Revoke) Step 3.
let globalscope = self.global();
globalscope
.as_window()
.permission_state_invocation_results()
.borrow_mut()
.remove(&root_desc.name.to_string());
@@ -178,7 +177,6 @@ impl Permissions {
// (Revoke) Step 3.
let globalscope = self.global();
globalscope
.as_window()
.permission_state_invocation_results()
.borrow_mut()
.remove(&root_desc.name.to_string());
@@ -272,7 +270,6 @@ impl PermissionAlgorithm for Permissions {
let prompt = format!("{} {} ?", REQUEST_DIALOG_MESSAGE, perm_name.clone());

This comment has been minimized.

@jdm

jdm Jun 28, 2019

Member

Rather than doing string formatting for dialogs in this code, I think we should delegate that to the embedder and only send an enum value that represents the kind of prompt required.

let state = prompt_user_from_embedder(prompt, &globalscope);
globalscope
.as_window()
.permission_state_invocation_results()
.borrow_mut()
.insert(perm_name.to_string(), state);
@@ -312,7 +309,6 @@ pub fn get_descriptor_permission_state(
PermissionState::Granted
} else {
globalscope
.as_window()
.permission_state_invocation_results()
.borrow_mut()
.remove(&permission_name.to_string());
@@ -324,7 +320,6 @@ pub fn get_descriptor_permission_state(

// Step 3.
if let Some(prev_result) = globalscope
.as_window()
.permission_state_invocation_results()
.borrow()
.get(&permission_name.to_string())
@@ -334,7 +329,6 @@ pub fn get_descriptor_permission_state(

// Store the invocation result
globalscope
.as_window()
.permission_state_invocation_results()
.borrow_mut()
.insert(permission_name.to_string(), state);
@@ -10,7 +10,6 @@ use crate::dom::bindings::codegen::Bindings::DocumentBinding::{
use crate::dom::bindings::codegen::Bindings::FunctionBinding::Function;
use crate::dom::bindings::codegen::Bindings::HistoryBinding::HistoryBinding::HistoryMethods;
use crate::dom::bindings::codegen::Bindings::MediaQueryListBinding::MediaQueryListBinding::MediaQueryListMethods;
use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionState;
use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInit;
use crate::dom::bindings::codegen::Bindings::WindowBinding::{
self, FrameRequestCallback, WindowMethods,
@@ -265,9 +264,6 @@ pub struct Window {
#[ignore_malloc_size_of = "channels are hard"]
webvr_chan: Option<IpcSender<WebVRMsg>>,

/// A map for storing the previous permission state read results.
permission_state_invocation_results: DomRefCell<HashMap<String, PermissionState>>,

/// All of the elements that have an outstanding image request that was
/// initiated by layout during a reflow. They are stored in the script thread
/// to ensure that the element can be marked dirty when the image data becomes
@@ -435,12 +431,6 @@ impl Window {
Worklet::new(self, WorkletGlobalScopeType::Paint)
}

pub fn permission_state_invocation_results(
&self,
) -> &DomRefCell<HashMap<String, PermissionState>> {
&self.permission_state_invocation_results
}

pub fn pending_image_notification(&self, response: PendingImageResponse) {
//XXXjdm could be more efficient to send the responses to the layout thread,
// rather than making the layout thread talk to the image cache to
@@ -2141,7 +2131,6 @@ impl Window {
test_runner: Default::default(),
webgl_chan,
webvr_chan,
permission_state_invocation_results: Default::default(),
pending_layout_images: Default::default(),
unminified_js_dir: Default::default(),
test_worklet: Default::default(),
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.