Skip to content

Commit

Permalink
naming
Browse files Browse the repository at this point in the history
  • Loading branch information
jprochazk committed May 29, 2024
1 parent 0b9911b commit 250c812
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions crates/eframe/src/web/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ pub(crate) fn focused_element() -> Option<web_sys::Element> {
}

pub(crate) fn has_focus<T: Clone + JsCast>(element: &T) -> bool {
fn inner<T: Clone + JsCast>(element: &T) -> Option<bool> {
fn try_has_focus<T: Clone + JsCast>(element: &T) -> Option<bool> {
let element = element.dyn_ref::<web_sys::Element>()?;
let focused_element = focused_element()?;
Some(element == &focused_element)
}
inner(element).unwrap_or(false)
try_has_focus(element).unwrap_or(false)
}

/// Current time in seconds (since undefined point in time).
Expand Down
4 changes: 2 additions & 2 deletions crates/eframe/src/web/text_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ impl Drop for TextAgent {

/// Returns `true` if the app is likely running on a mobile device.
fn is_mobile() -> bool {
fn inner() -> Option<bool> {
fn try_is_mobile() -> Option<bool> {
const MOBILE_DEVICE: [&str; 6] =
["Android", "iPhone", "iPad", "iPod", "webOS", "BlackBerry"];

let user_agent = web_sys::window()?.navigator().user_agent().ok()?;
let is_mobile = MOBILE_DEVICE.iter().any(|&name| user_agent.contains(name));
Some(is_mobile)
}
inner().unwrap_or(false)
try_is_mobile().unwrap_or(false)
}

0 comments on commit 250c812

Please sign in to comment.