Rewild Your Web
at main 159 lines 6.5 kB view raw
1--- original 2+++ modified 3@@ -0,0 +1,156 @@ 4+/* This Source Code Form is subject to the terms of the Mozilla Public 5+ * License, v. 2.0. If a copy of the MPL was not distributed with this 6+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ 7+ 8+// Servo extension: Embedded WebView methods and events for HTMLIFrameElement. 9+// These methods only work when the iframe has the "embed" attribute set, 10+// which creates a top-level embedded webview instead of a nested browsing context. 11+// All methods throw if called on an iframe without the embed attribute. 12+ 13+interface mixin EmbeddedWebView { 14+ // Navigation 15+ [Throws] undefined load(USVString url); 16+ [Throws] undefined reload(); 17+ 18+ // Zoom control 19+ [Throws] double getPageZoom(); 20+ [Throws] undefined setPageZoom(double zoom); 21+ 22+ // History navigation 23+ [Throws] boolean canGoBack(); 24+ [Throws] DOMString goBack(); // Returns TraversalId for tracking completion 25+ [Throws] boolean canGoForward(); 26+ [Throws] DOMString goForward(); // Returns TraversalId for tracking completion 27+ 28+ // Screenshot 29+ [Throws] Promise<Blob> takeScreenshot(optional ScreenshotOptions options = {}); 30+ 31+ // Embedder control responses (for select dropdowns, color pickers, etc.) 32+ // These are called by the parent shell in response to embedcontrolshow events 33+ [Throws] undefined respondToSelectControl(DOMString controlId, long selectedIndex); 34+ [Throws] undefined respondToColorPicker(DOMString controlId, DOMString? color); 35+ [Throws] undefined respondToContextMenu(DOMString controlId, DOMString? actionId); 36+ [Throws] undefined cancelEmbedderControl(DOMString controlId); 37+ 38+ // Simple dialog responses (for alert, confirm, prompt) 39+ // These are called by the parent shell in response to embeddialogshow events 40+ [Throws] undefined respondToAlert(DOMString controlId); 41+ [Throws] undefined respondToConfirm(DOMString controlId, boolean confirmed); 42+ [Throws] undefined respondToPrompt(DOMString controlId, DOMString? value); 43+ 44+ // Permission prompt response 45+ [Throws] undefined respondToPermissionPrompt(DOMString controlId, boolean allowed); 46+}; 47+ 48+ 49+ 50+// Options for taking a screenshot of an embedded webview. 51+dictionary ScreenshotOptions { 52+ DOMString type = "image/png"; // "image/png", "image/jpeg", "image/webp" 53+ double quality = 0.92; // 0.0 to 1.0, used for JPEG/WebP compression 54+}; 55+ 56+// Position and size of an embedder control in device pixels. 57+dictionary EmbedderControlPosition { 58+ double x = 0; 59+ double y = 0; 60+ double width = 0; 61+ double height = 0; 62+}; 63+ 64+// An option in a select element dropdown. 65+dictionary EmbedderSelectOption { 66+ unsigned long id = 0; 67+ DOMString label = ""; 68+ boolean disabled = false; 69+ DOMString? group = null; // Optgroup label if this option is in a group 70+}; 71+ 72+// Parameters for select element control. 73+dictionary EmbedderSelectParameters { 74+ sequence<EmbedderSelectOption> options; 75+ long selectedIndex = -1; 76+}; 77+ 78+// Parameters for color picker control. 79+dictionary EmbedderColorParameters { 80+ DOMString currentColor = "#000000"; 81+}; 82+ 83+// Parameters for file picker control. 84+dictionary EmbedderFileParameters { 85+ boolean multiple = false; // Allow multiple file selection 86+ sequence<DOMString> acceptTypes; // MIME types or extensions to accept (e.g., "image/*", ".pdf") 87+ DOMString? directory = null; // Suggested directory path 88+}; 89+ 90+// Parameters for input method control. 91+dictionary EmbedderInputMethodParameters { 92+ DOMString inputType = "text"; // "text", "password", "number", "email", "tel", "url", etc. 93+ DOMString? currentValue = null; // Current input value 94+ DOMString? placeholder = null; // Placeholder text 95+}; 96+ 97+// A context menu item. 98+dictionary EmbedderContextMenuItem { 99+ DOMString id = ""; 100+ DOMString label = ""; 101+ boolean disabled = false; 102+ boolean checked = false; 103+ DOMString? icon = null; // Optional icon URL 104+}; 105+ 106+// Parameters for context menu control. 107+dictionary EmbedderContextMenuParameters { 108+ sequence<EmbedderContextMenuItem> items; 109+ URL linkUrl; 110+ URL imageUrl; 111+ boolean forLink = false; 112+ boolean forImage = false; 113+ boolean forEditableText = false; 114+ boolean forSelection = false; 115+}; 116+ 117+// Parameters for permission prompt control. 118+dictionary EmbedderPermissionParameters { 119+ DOMString feature = ""; // Permission feature: "geolocation", "camera", "microphone", etc. 120+ DOMString featureName = ""; // Human-readable name: "Location", "Camera", "Microphone", etc. 121+}; 122+ 123+// Event detail for embedcontrolshow events. 124+// The controlType determines which parameters field is present. 125+dictionary EmbedderControlShowEventDetail { 126+ required DOMString controlType; // "select", "color", "file", "inputmethod", "contextmenu", "permission" 127+ required DOMString controlId; // Unique ID for response routing 128+ EmbedderControlPosition position; 129+ 130+ // Control-specific parameters (only one will be set based on controlType) 131+ EmbedderSelectParameters selectParameters; // For controlType "select" 132+ EmbedderColorParameters colorParameters; // For controlType "color" 133+ EmbedderFileParameters fileParameters; // For controlType "file" 134+ EmbedderInputMethodParameters inputMethodParameters; // For controlType "inputmethod" 135+ EmbedderContextMenuParameters contextMenuParameters; // For controlType "contextmenu" 136+ EmbedderPermissionParameters permissionParameters; // For controlType "permission" 137+}; 138+ 139+// Event detail for embedcontrolhide events. 140+dictionary EmbedderControlHideEventDetail { 141+ required DOMString controlId; 142+}; 143+ 144+// Event detail for embeddialogshow events (alert, confirm, prompt). 145+// The dialogType determines which fields are relevant. 146+dictionary EmbedderDialogShowEventDetail { 147+ required DOMString dialogType; // "alert", "confirm", "prompt" 148+ required DOMString controlId; // Unique ID for response routing 149+ required DOMString message; // The message to display 150+ DOMString? defaultValue; // Default value for prompt dialogs (null for alert/confirm) 151+}; 152+ 153+// Event detail for embednotificationshow events. 154+dictionary EmbedderNotificationShowEventDetail { 155+ required DOMString title; // Notification title 156+ DOMString body = ""; // Notification body text 157+ DOMString tag = ""; // Tag for deduplication/replacement 158+ DOMString? iconUrl = null; // Icon URL 159+};