Rewild Your Web
web
browser
dweb
1--- original
2+++ modified
3@@ -0,0 +1,150 @@
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+};
110+
111+// Parameters for permission prompt control.
112+dictionary EmbedderPermissionParameters {
113+ DOMString feature = ""; // Permission feature: "geolocation", "camera", "microphone", etc.
114+ DOMString featureName = ""; // Human-readable name: "Location", "Camera", "Microphone", etc.
115+};
116+
117+// Event detail for embedcontrolshow events.
118+// The controlType determines which parameters field is present.
119+dictionary EmbedderControlShowEventDetail {
120+ required DOMString controlType; // "select", "color", "file", "inputmethod", "contextmenu", "permission"
121+ required DOMString controlId; // Unique ID for response routing
122+ EmbedderControlPosition position;
123+
124+ // Control-specific parameters (only one will be set based on controlType)
125+ EmbedderSelectParameters selectParameters; // For controlType "select"
126+ EmbedderColorParameters colorParameters; // For controlType "color"
127+ EmbedderFileParameters fileParameters; // For controlType "file"
128+ EmbedderInputMethodParameters inputMethodParameters; // For controlType "inputmethod"
129+ EmbedderContextMenuParameters contextMenuParameters; // For controlType "contextmenu"
130+ EmbedderPermissionParameters permissionParameters; // For controlType "permission"
131+};
132+
133+// Event detail for embedcontrolhide events.
134+dictionary EmbedderControlHideEventDetail {
135+ required DOMString controlId;
136+};
137+
138+// Event detail for embeddialogshow events (alert, confirm, prompt).
139+// The dialogType determines which fields are relevant.
140+dictionary EmbedderDialogShowEventDetail {
141+ required DOMString dialogType; // "alert", "confirm", "prompt"
142+ required DOMString controlId; // Unique ID for response routing
143+ required DOMString message; // The message to display
144+ DOMString? defaultValue; // Default value for prompt dialogs (null for alert/confirm)
145+};
146+
147+// Event detail for embednotificationshow events.
148+dictionary EmbedderNotificationShowEventDetail {
149+ required DOMString title; // Notification title
150+ DOMString body = ""; // Notification body text
151+ DOMString tag = ""; // Tag for deduplication/replacement
152+ DOMString? iconUrl = null; // Icon URL
153+};