Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upWIP - Added prompt user for url #17062
Conversation
highfive
commented
May 27, 2017
|
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @pcwalton (or someone else) soon. |
|
It's weird. The changes in Cargo.lock make it impossible for me to compile.
I'll see later what's going on. |
| sanitized_url = sanitize_url(user_input).unwrap(); | ||
| //Maybe need to change WindowEvent::LoadUrl() to accept a ServoUrl instead of a String? | ||
| self.event_queue.borrow_mut().push(WindowEvent::LoadUrl(sanitized_url.to_string())); | ||
| } |
This comment has been minimized.
This comment has been minimized.
paulrouget
May 27, 2017
Contributor
You can simplify all of this with a if let Some(…) expression. No match needed, an no need to have this intermediate user_input value.
This comment has been minimized.
This comment has been minimized.
| @@ -1402,6 +1424,10 @@ fn is_printable(key_code: VirtualKeyCode) -> bool { | |||
| } | |||
| } | |||
|
|
|||
| fn sanitize_url(url: String) -> Result<ServoUrl, ()> { | |||
| Ok(ServoUrl::parse(url.trim()).unwrap()) | |||
This comment has been minimized.
This comment has been minimized.
paulrouget
May 27, 2017
Contributor
sanitize_url should fail if ServoUrl::parse fails. Don't return Ok(…). See how to use Result::map_err https://doc.rust-lang.org/std/result/enum.Result.html#method.map_err.
Maybe rename sanitize_url to sanitize_and_parse_url .
This comment has been minimized.
This comment has been minimized.
paulrouget
May 27, 2017
Contributor
FYI, unwrap() on a failing Result will panic. See https://is.gd/RAdLog
| @@ -1268,12 +1269,33 @@ impl WindowMethods for Window { | |||
| self.event_queue.borrow_mut().push(WindowEvent::Reload); | |||
| } | |||
| } | |||
| //On windows 8.1 when pressing ctrl + anything, ch = Some('\u{unicode_value}') | |||
This comment has been minimized.
This comment has been minimized.
| if let Some(true) = PREFS.get("shell.builtin-key-shortcuts.enabled").as_boolean() { | ||
| let user_input: String; | ||
| //TODO: | ||
| // 1) make it work when clicking on "validate" button - Currently only works when pressing enter |
This comment has been minimized.
This comment has been minimized.
paulrouget
May 27, 2017
Contributor
Maybe it has to do with the fact we're blocking the main thread.
On Mac, the buttons work, but we get the beatchball.
Maybe this code should run in a different thread.
a5eb57e
to
010a9a0
| @@ -1402,6 +1419,10 @@ fn is_printable(key_code: VirtualKeyCode) -> bool { | |||
| } | |||
| } | |||
|
|
|||
| fn sanitize_and_parse_url(url: String) -> Result<ServoUrl, ()> { | |||
This comment has been minimized.
This comment has been minimized.
paulrouget
May 29, 2017
Contributor
Actually, we might want to use ParseError for now instead of an empty error.
| // 1) make it work when clicking on "validate" button - Currently only works when pressing enter | ||
| // 2) Erratic behavior - sometime the dialog reloads empty after pressing enter | ||
| // (windows 8.1) | ||
| if let Some(user_input) = tinyfiledialogs::input_box("Enter a URL", "URL:", "") { |
This comment has been minimized.
This comment has been minimized.
paulrouget
May 29, 2017
Contributor
The default value should be the current url, not "".
I'm wondering if we have any locales support. I'm not sure we want to keep english sentences in the code.
|
@jdm is tinyfiledialogs thread safe? It appears to work well here (osx) if I open a prompt from a different thread. But I'm not sure it's the right thing to do. |
|
I do not believe the library does anything special to ensure that it works from non-main threads. I suspect that at least one platform will not work as intended if used that way. |
Fix Cargo.lock corrupted problem Refactored event handler for CTRL + L Made sanitize_and_parse_url() handle correctly parse errors Made the prompt default to the current url Made sanitize_and_parse_url() return ParseError instead of empty error
|
Currently, in |
|
|
|
Closing due to inactivity. |
jklepatch commentedMay 27, 2017
•
edited by larsbergstrom
This is not ready yet, I would just like to have some feedback.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is