mirror of
https://github.com/servo/servo
synced 2026-04-30 19:37:43 +02:00
libservo: Merge file selection dialog into EmbedderControls (#39859)
in #39709, we introduced a single “form control” or “embedder control” delegate that requests the embedder’s input for <select> and <input type="color"> elements. this patch partially merges <input type="file"> elements into that new system, and renames “form controls” to “embedder controls” for consistency. internally we continue to use a separate code path where the embedder directly communicates with the file manager thread. subsequent work will make the messages asynchronous via the constellation and script thread, like other embedder controls. Testing: this is currently tricky to write an automated test for; we expect to write a WebDriver test for this once we make the communication asynchronous --------- Signed-off-by: delan azabani <dazabani@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
@@ -6,7 +6,7 @@ use std::default::Default;
|
||||
use std::iter;
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use embedder_traits::{FormControlRequest as EmbedderFormControl};
|
||||
use embedder_traits::{EmbedderControlRequest as EmbedderFormControl};
|
||||
use embedder_traits::{SelectElementOption, SelectElementOptionOrOptgroup};
|
||||
use euclid::{Point2D, Rect, Size2D};
|
||||
use html5ever::{LocalName, Prefix, QualName, local_name, ns};
|
||||
@@ -401,11 +401,13 @@ impl HTMLSelectElement {
|
||||
|
||||
let selected_index = self.list_of_options().position(|option| option.Selected());
|
||||
|
||||
self.owner_document().embedder_controls().show_form_control(
|
||||
ControlElement::Select(DomRoot::from_ref(self)),
|
||||
DeviceIntRect::from_untyped(&rect.to_box2d()),
|
||||
EmbedderFormControl::SelectElement(options, selected_index),
|
||||
);
|
||||
self.owner_document()
|
||||
.embedder_controls()
|
||||
.show_embedder_control(
|
||||
ControlElement::Select(DomRoot::from_ref(self)),
|
||||
DeviceIntRect::from_untyped(&rect.to_box2d()),
|
||||
EmbedderFormControl::SelectElement(options, selected_index),
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) fn handle_menu_response(&self, response: Option<usize>, can_gc: CanGc) {
|
||||
@@ -702,7 +704,7 @@ impl VirtualMethods for HTMLSelectElement {
|
||||
if could_have_had_embedder_control && !self.may_have_embedder_control() {
|
||||
self.owner_document()
|
||||
.embedder_controls()
|
||||
.hide_form_control(self.upcast());
|
||||
.hide_embedder_control(self.upcast());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -731,7 +733,7 @@ impl VirtualMethods for HTMLSelectElement {
|
||||
|
||||
self.owner_document()
|
||||
.embedder_controls()
|
||||
.hide_form_control(self.upcast());
|
||||
.hide_embedder_control(self.upcast());
|
||||
}
|
||||
|
||||
fn children_changed(&self, mutation: &ChildrenMutation) {
|
||||
@@ -758,7 +760,7 @@ impl VirtualMethods for HTMLSelectElement {
|
||||
if *event.upcast::<Event>().type_() != *"blur" {
|
||||
self.owner_document()
|
||||
.embedder_controls()
|
||||
.hide_form_control(self.upcast());
|
||||
.hide_embedder_control(self.upcast());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user