···11--- original
22+++ modified
33-@@ -0,0 +1,1075 @@
33+@@ -0,0 +1,1088 @@
44+/* This Source Code Form is subject to the terms of the Mozilla Public
55+ * License, v. 2.0. If a copy of the MPL was not distributed with this
66+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
···199199+ let mut permission_parameters = None;
200200+
201201+ match &request {
202202-+ EmbedderControlRequest::SelectElement(options, selected) => {
203203-+ let select_options: Vec<EmbedderSelectOption> = options
202202++ EmbedderControlRequest::SelectElement(select_request) => {
203203++ if select_request.allow_select_multiple {
204204++ error!("Unsupported: multiple select options");
205205++ return;
206206++ }
207207++ let select_options: Vec<EmbedderSelectOption> = select_request
208208++ .options
204209+ .iter()
205210+ .flat_map(|opt_or_group| match opt_or_group {
206211+ embedder_traits::SelectElementOptionOrOptgroup::Option(opt) => {
···225230+ .collect(),
226231+ })
227232+ .collect();
233233++ // For now we know there's a one selected option at most.
234234++ let selectedIndex = if select_request.selected_options.is_empty() {
235235++ -1
236236++ } else {
237237++ select_request.selected_options[0] as i32
238238++ };
228239+ select_parameters = Some(EmbedderSelectParameters {
229240+ options: Some(select_options),
230230-+ selectedIndex: selected.map(|i| i as i32).unwrap_or(-1),
241241++ selectedIndex,
231242+ });
232243+ },
233244+ EmbedderControlRequest::ColorPicker(color) => {
···743754+ &self,
744755+ options: &ScreenshotOptions,
745756+ ) -> Fallible<Rc<Promise>> {
746746-+ let can_gc = CanGc::note();
757757++ let can_gc = CanGc::deprecated_note();
747758+
748759+ // Must be an embedded webview
749760+ let Some(webview_id) = self.embedded_webview_id() else {
···788799+ }
789800+
790801+ /// Respond to a select control request.
802802++ /// TODO: support multiple selection.
791803+ pub(crate) fn embedded_respond_to_select_control(
792804+ &self,
793805+ control_id: DOMString,
···795807+ ) -> Fallible<()> {
796808+ let id = self.parse_control_id(&control_id)?;
797809+ let response = if selected_index < 0 {
798798-+ EmbedderControlResponse::SelectElement(None)
810810++ EmbedderControlResponse::SelectElement(vec![])
799811+ } else {
800800-+ EmbedderControlResponse::SelectElement(Some(selected_index as usize))
812812++ EmbedderControlResponse::SelectElement(vec![selected_index as usize])
801813+ };
802814+ self.send_control_response(id, response)
803815+ }
···859871+ }
860872+
861873+ /// Cancel an embedder control request.
874874++ /// TODO: check if sending back SelectElement is correct
862875+ pub(crate) fn embedded_cancel_embedder_control(&self, control_id: DOMString) -> Fallible<()> {
863876+ let id = self.parse_control_id(&control_id)?;
864864-+ let response = EmbedderControlResponse::SelectElement(None);
877877++ let response = EmbedderControlResponse::SelectElement(vec![]);
865878+ self.send_control_response(id, response)
866879+ }
867880+
···99 use servo_constellation_traits::EmbedderToConstellationMessage;
1010 use tokio::sync::mpsc::UnboundedSender as TokioSender;
1111 use tokio::sync::oneshot::Sender;
1212-@@ -968,6 +968,14 @@
1212+@@ -971,6 +971,14 @@
1313 ///
1414 /// [`window.open`]: https://developer.mozilla.org/en-US/docs/Web/API/Window/open
1515 fn request_create_new(&self, _parent_webview: WebView, _request: CreateNewWebViewRequest) {}
···2424 /// Content in a [`WebView`] is requesting permission to access a feature requiring
2525 /// permission from the user. The embedder should allow or deny the request, either by
2626 /// reading a cached value or querying the user for permission via the user interface.
2727-@@ -1026,6 +1034,25 @@
2727+@@ -1029,6 +1037,25 @@
2828 _tree_update: accesskit::TreeUpdate,
2929 ) {
3030 }
···198198 /// Indicates whether this pipeline is currently running animations.
199199 ChangeRunningAnimationsState(AnimationState),
200200 /// Requests that a new 2D canvas thread be created. (This is done in the constellation because
201201-@@ -676,6 +805,10 @@
201201+@@ -677,6 +806,10 @@
202202 ScriptNewIFrame(IFrameLoadInfoWithData),
203203 /// Script has opened a new auxiliary browsing context.
204204 CreateAuxiliaryWebView(AuxiliaryWebViewCreationRequest),
···209209 /// Mark a new document as active
210210 ActivateDocument,
211211 /// Set the document state for a pipeline (used by screenshot / reftests)
212212-@@ -725,6 +858,112 @@
212212+@@ -726,6 +859,112 @@
213213 RespondToScreenshotReadinessRequest(ScreenshotReadinessResponse),
214214 /// Request the constellation to force garbage collection in all `ScriptThread`'s.
215215 TriggerGarbageCollection,
···1717+#[derive(Clone, Debug, Deserialize, Serialize)]
1818 pub enum EmbedderControlRequest {
1919 /// Indicates that the user has activated a `<select>` element.
2020- SelectElement(Vec<SelectElementOptionOrOptgroup>, Option<usize>),
2020+ SelectElement(SelectElementRequest),
2121@@ -44,6 +44,8 @@
2222 InputMethod(InputMethodRequest),
2323 /// Indicates that the the user has triggered the display of a context menu.
···5454 pub struct FilePickerRequest {
5555 pub origin: ImmutableOrigin,
5656 pub current_paths: Vec<PathBuf>,
5757-@@ -160,6 +162,16 @@
5757+@@ -160,8 +162,18 @@
5858 pub accept_current_paths_for_testing: bool,
5959 }
6060···6969+}
7070+
7171 /// Response from the embedder to an [`EmbedderControlRequest`].
7272- #[derive(Debug, Deserialize, Serialize)]
7373- pub enum EmbedderControlResponse {
7474-@@ -167,6 +179,7 @@
7272+-#[derive(Debug, Deserialize, Serialize)]
7373++#[derive(Clone, Debug, Deserialize, Serialize)]
7474+ pub struct SelectElementRequest {
7575+ pub options: Vec<SelectElementOptionOrOptgroup>,
7676+ pub selected_options: Vec<usize>,
7777+@@ -174,6 +186,7 @@
7578 ColorPicker(Option<RgbColor>),
7679 FilePicker(Option<Vec<SelectedFile>>),
7780 ContextMenu(Option<ContextMenuAction>),
···7982 }
80838184 /// Response to file selection request
8282-@@ -181,7 +194,7 @@
8585+@@ -188,7 +201,7 @@
8386 }
84878588 /// Request from Servo to the embedder with the details of the simple dialog to be displayed.
+2-2
patches/components/shared/script/lib.rs.patch
···3636 }
37373838 /// When a pipeline is closed, should its browsing context be discarded too?
3939-@@ -289,6 +298,15 @@
3939+@@ -291,6 +300,15 @@
4040 SendImageKeysBatch(PipelineId, Vec<ImageKey>),
4141 /// Preferences were updated in the parent process.
4242 PreferencesUpdated(Vec<(String, PrefValue)>),
···5252 /// Notify the `ScriptThread` that the Servo renderer is no longer waiting on
5353 /// asynchronous image uploads for the given `Pipeline`. These are mainly used
5454 /// by canvas to perform uploads while the display list is being built.
5555-@@ -325,6 +343,24 @@
5555+@@ -327,6 +345,24 @@
5656 SetAccessibilityActive(PipelineId, bool),
5757 /// Force a garbage collection in this script thread.
5858 TriggerGarbageCollection,