mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Update bool pattern matching into if-else
This commit is contained in:
parent
65370f17c9
commit
abd577bfd4
5 changed files with 50 additions and 49 deletions
|
@ -6399,13 +6399,10 @@ class CGDictionary(CGThing):
|
|||
conversion = (
|
||||
"{\n"
|
||||
" rooted!(in(cx) let mut rval = UndefinedValue());\n"
|
||||
" match r#try!(get_dictionary_property(cx, object.handle(), \"%s\", rval.handle_mut())) {\n"
|
||||
" true => {\n"
|
||||
" if r#try!(get_dictionary_property(cx, object.handle(), \"%s\", rval.handle_mut())) {\n"
|
||||
"%s\n"
|
||||
" },\n"
|
||||
" false => {\n"
|
||||
" } else {\n"
|
||||
"%s\n"
|
||||
" },\n"
|
||||
" }\n"
|
||||
"}") % (member.identifier.name, indent(conversion), indent(default))
|
||||
|
||||
|
|
|
@ -188,9 +188,10 @@ impl Event {
|
|||
}
|
||||
|
||||
pub fn status(&self) -> EventStatus {
|
||||
match self.DefaultPrevented() {
|
||||
true => EventStatus::Canceled,
|
||||
false => EventStatus::NotCanceled,
|
||||
if self.DefaultPrevented() {
|
||||
EventStatus::Canceled
|
||||
} else {
|
||||
EventStatus::NotCanceled
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -320,9 +321,10 @@ pub enum EventBubbles {
|
|||
|
||||
impl From<bool> for EventBubbles {
|
||||
fn from(boolean: bool) -> Self {
|
||||
match boolean {
|
||||
true => EventBubbles::Bubbles,
|
||||
false => EventBubbles::DoesNotBubble,
|
||||
if boolean {
|
||||
EventBubbles::Bubbles
|
||||
} else {
|
||||
EventBubbles::DoesNotBubble
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -344,9 +346,10 @@ pub enum EventCancelable {
|
|||
|
||||
impl From<bool> for EventCancelable {
|
||||
fn from(boolean: bool) -> Self {
|
||||
match boolean {
|
||||
true => EventCancelable::Cancelable,
|
||||
false => EventCancelable::NotCancelable,
|
||||
if boolean {
|
||||
EventCancelable::Cancelable
|
||||
} else {
|
||||
EventCancelable::NotCancelable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -304,26 +304,26 @@ pub fn get_descriptor_permission_state(
|
|||
// The current solution is a workaround with a message box to warn about this,
|
||||
// if the feature is not allowed in non-secure contexcts,
|
||||
// and let the user decide to grant the permission or not.
|
||||
let state = match allowed_in_nonsecure_contexts(&permission_name) {
|
||||
true => PermissionState::Prompt,
|
||||
false => match PREFS
|
||||
let state = if allowed_in_nonsecure_contexts(&permission_name) {
|
||||
PermissionState::Prompt
|
||||
} else {
|
||||
if PREFS
|
||||
.get("dom.permissions.testing.allowed_in_nonsecure_contexts")
|
||||
.as_boolean()
|
||||
.unwrap_or(false)
|
||||
{
|
||||
true => PermissionState::Granted,
|
||||
false => {
|
||||
settings
|
||||
.as_window()
|
||||
.permission_state_invocation_results()
|
||||
.borrow_mut()
|
||||
.remove(&permission_name.to_string());
|
||||
prompt_user(&format!(
|
||||
"The {} {}",
|
||||
permission_name, NONSECURE_DIALOG_MESSAGE
|
||||
))
|
||||
},
|
||||
},
|
||||
PermissionState::Granted
|
||||
} else {
|
||||
settings
|
||||
.as_window()
|
||||
.permission_state_invocation_results()
|
||||
.borrow_mut()
|
||||
.remove(&permission_name.to_string());
|
||||
prompt_user(&format!(
|
||||
"The {} {}",
|
||||
permission_name, NONSECURE_DIALOG_MESSAGE
|
||||
))
|
||||
}
|
||||
};
|
||||
|
||||
// Step 3.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue