Skip to content

doc: explain how to create a WebView (#43712)#43787

Merged
mukilan merged 1 commit into
servo:mainfrom
TG199:doc-webview-creation-43712
Apr 2, 2026
Merged

doc: explain how to create a WebView (#43712)#43787
mukilan merged 1 commit into
servo:mainfrom
TG199:doc-webview-creation-43712

Conversation

@TG199
Copy link
Copy Markdown
Contributor

@TG199 TG199 commented Mar 31, 2026

Added a "Creating a WebView" section to the WebView doc comment explaining that WebViewBuilder is the correct way to create a WebView, with a usage example. Also expanded the WebViewBuilder doc comment to be more descriptive.
Fixes: #43712

@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Mar 31, 2026
Copy link
Copy Markdown
Contributor

@Narfinger Narfinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks you for improving the documentation! Looks good to me.

Comment thread components/servo/webview.rs Outdated
/// [`Servo`] instance and a [`RenderingContext`](crate::RenderingContext) to provide to the
/// builder:
///
/// ```rust,ignore
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might it be better to have a # fn foo(my_delegate: &WebViewDelegate) and then a no_run for this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh okay

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might it be better to have a # fn foo(my_delegate: &WebViewDelegate) and then a no_run for this?

I guess we'll still need a servo instance, url, and rendering context to make it compile, no?

Also, what is foo here? Do you mean to say a dummy implementation of WebViewDelegate? i.e

struct MyDelegate; 
impl WebViewDelegate for MyDelegate {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes something like that.
Basically if we can have

# fn foo(servo: &Servo, rendering_context: Rc<dyn RenderingContext>) {
struct MyDelegate; 
impl WebViewDelegate for MyDelegate {}

 let webview = WebViewBuilder::new(&servo, rendering_context)
url(url)
.delegate(Rc::new(my_delegate))
.build();
# }

As far as I understand the rustdoc documentation this should work because it is code that compiles.

But if there is something more to do then it might not be worth it and this way is fine.

@TG199
Copy link
Copy Markdown
Contributor Author

TG199 commented Mar 31, 2026

@delan

@mukilan
Copy link
Copy Markdown
Member

mukilan commented Apr 1, 2026

@TG199 I believe the scope of the issue was just to have single line to mention that WebViewBuilder can be used to create the webview, so the example is not strictly necessary to land this. It requires familiarity with Servo's webview API to create a working example, so it is fine to drop the example part for now.

@TG199
Copy link
Copy Markdown
Contributor Author

TG199 commented Apr 1, 2026

Okay, thanks

@TG199 TG199 force-pushed the doc-webview-creation-43712 branch from ace2268 to c623b17 Compare April 1, 2026 16:51
@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Apr 2, 2026
@mukilan mukilan added this pull request to the merge queue Apr 2, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Apr 2, 2026
Merged via the queue into servo:main with commit ed78dad Apr 2, 2026
30 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

api: Explain how to create a WebView

4 participants