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

Pass the initial URL as an argument to Browser::new, not as a opts property #15636

Closed
paulrouget opened this issue Feb 19, 2017 · 15 comments
Closed

Comments

@paulrouget
Copy link
Contributor

@paulrouget paulrouget commented Feb 19, 2017

This issue is part of an effort to improve Servo's embedding story. See https://github.com/paulrouget/servoshell/projects/2

Starting Servo from a third party application requires setting the initial URL as an option:

let mut opts = opts::default_opts();
opts.url = ServoUrl::parse(url).ok();
opts::set_defaults(opts);

I would expect to be able to do that instead:

servo::Browser::new(window, url);
@yysung1123
Copy link
Contributor

@yysung1123 yysung1123 commented Feb 20, 2017

I would like to work on this!

@paulrouget
Copy link
Contributor Author

@paulrouget paulrouget commented Feb 20, 2017

That would be great, but I'd like first to get the confirmation from someone else that this is a valid proposal.

@Ms2ger or @jdm any opinion on this?

Ideally, Servo could run with its default options.

@Ms2ger
Copy link
Contributor

@Ms2ger Ms2ger commented Feb 20, 2017

I think the whole setup with InitLoadUrl is kinda weird, but I'd say the proposed change won't make anything worse, so let's go ahead and do it.

@paulrouget
Copy link
Contributor Author

@paulrouget paulrouget commented Feb 20, 2017

@deror1869107 It's yours :)

@yysung1123
Copy link
Contributor

@yysung1123 yysung1123 commented Feb 20, 2017

@paulrouget

Could I replace Servo::Browser::new with pub fn new(window: Rc<Window>, url: Option<ServoUrl>)?

@paulrouget
Copy link
Contributor Author

@paulrouget paulrouget commented Feb 20, 2017

Could I replace Servo::Browser::new with pub fn new(window: Rc, url: Option)?

I think so.

Does the ServoUrl need to be an Option? Is there any reason to support url:None?

@yysung1123
Copy link
Contributor

@yysung1123 yysung1123 commented Feb 20, 2017

If url is None, it would use default url from opts::get().

@paulrouget
Copy link
Contributor Author

@paulrouget paulrouget commented Feb 21, 2017

Any reason to keep url in opts?

@cbrewster
Copy link
Member

@cbrewster cbrewster commented Feb 21, 2017

@paulrouget we used the url in opts for browserhtml https://github.com/servo/servo/blob/master/resources/package-prefs.json#L5. This allows us to not need a script like the old runservo to provide the bhtml url to servo.

@paulrouget
Copy link
Contributor Author

@paulrouget paulrouget commented Feb 21, 2017

@cbrewster We can read the pref in main() instead. shell.homepage would be used if the url is not passed as an argument. I'm trying to decouple the "app" logic and the "web engine" logic. I think it's up to the app to set the initial URL, and I'm not sure the initial url should be part of opts.

So basically, I would suggest that we do:

  1. remove Opts::url
  2. move the logic of computing the initial url from opts.rs to /ports/servo/
  3. add a ServoUrl argument to Browser::new (not an Option, just ServoUrl)

Does it make sense?

@cbrewster
Copy link
Member

@cbrewster cbrewster commented Feb 21, 2017

@paulrouget sounds good!

@jdm
Copy link
Member

@jdm jdm commented Apr 12, 2017

#15699 was an attempt at fixing this; the work there had some review comments that needed to be addressed.

@sadmansk
Copy link
Contributor

@sadmansk sadmansk commented Apr 12, 2017

@jdm I could take over this issue if no one else is working on it.

@jdm
Copy link
Member

@jdm jdm commented Apr 12, 2017

Please do!

@jdm jdm added the C-assigned label Apr 12, 2017
@sadmansk
Copy link
Contributor

@sadmansk sadmansk commented Apr 15, 2017

@paulrouget do you want there to be a check if the ServoUrlparameter is None before calling InitLoadUrl? Currently I'm expecting a valid url to be passed into Browser::new(). I'll open the PR and add comments to the segments I have questions about.

@jdm jdm added the C-has open PR label May 23, 2017
bors-servo added a commit that referenced this issue Jun 12, 2017
Pass URL to Browser::new(), delegate url checking logic to 3rd party

<!-- Please describe your changes on the following line: -->
1. Move the logic of computing the initial url from `opts.rs` to `/ports/servo/main.rs`
2. Add a `ServoUrl` argument to `Browser::new`

Based on the requested changes by @paulrouget:
>We can read the pref in main() instead. shell.homepage would be used if the url is not passed as an argument. I'm trying to decouple the "app" logic and the "web engine" logic. I think it's up to the app to set the initial URL, and I'm not sure the initial url should be part of opts.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #15636

<!-- Either: -->
- [ ] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16477)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.