From c64de3a8fd8e08c12b1e51d6d6d059f809e739cb Mon Sep 17 00:00:00 2001 From: dAxpeDDa Date: Mon, 29 May 2023 19:59:59 +0200 Subject: [PATCH] Document possible errors for Web --- src/lib.rs | 2 ++ src/web.rs | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 98084704..e1365c52 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -321,6 +321,8 @@ impl Surface { /// /// - On X11, the window must be visible. /// - On macOS, Redox and Wayland, this function is unimplemented. + /// - On Web, this will fail if the content was supplied by + /// a different origin depending on the sites CORS rules. pub fn fetch(&mut self) -> Result, SoftBufferError> { self.surface_impl.fetch() } diff --git a/src/web.rs b/src/web.rs index d6c84174..95bcfa72 100644 --- a/src/web.rs +++ b/src/web.rs @@ -126,6 +126,10 @@ impl WebImpl { /// Extension methods for the Wasm target on [`Surface`](crate::Surface). pub trait SurfaceExtWeb: Sized { /// Creates a new instance of this struct, using the provided [`HtmlCanvasElement`]. + /// + /// # Errors + /// - If the canvas was already controlled by an `OffscreenCanvas`. + /// - If a another context then "2d" was already created for this canvas. fn from_canvas(canvas: HtmlCanvasElement) -> Result; }