mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Use counter instead of time for HTMLFormElement. (#35555)
* Use counter instead of time for HTMLFormElement. Fixes #25455 Signed-off-by: Narfinger <Narfinger@users.noreply.github.com> * Update components/script/dom/htmlformelement.rs to include suggestions Co-authored-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Narfinger <Narfinger@users.noreply.github.com> --------- Signed-off-by: Narfinger <Narfinger@users.noreply.github.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
4ab4e5dd47
commit
5aa662437b
1 changed files with 10 additions and 5 deletions
|
@ -4,7 +4,6 @@
|
|||
|
||||
use std::borrow::ToOwned;
|
||||
use std::cell::Cell;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use encoding_rs::{Encoding, UTF_8};
|
||||
|
@ -97,7 +96,10 @@ pub(crate) struct HTMLFormElement {
|
|||
controls: DomRefCell<Vec<Dom<Element>>>,
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
past_names_map: DomRefCell<HashMapTracedValues<Atom, (Dom<Element>, NoTrace<Instant>)>>,
|
||||
past_names_map: DomRefCell<HashMapTracedValues<Atom, (Dom<Element>, NoTrace<usize>)>>,
|
||||
|
||||
/// The current generation of past names, i.e., the number of name changes to the name.
|
||||
current_name_generation: Cell<usize>,
|
||||
|
||||
firing_submission_events: Cell<bool>,
|
||||
rel_list: MutNullableDom<DOMTokenList>,
|
||||
|
@ -125,6 +127,7 @@ impl HTMLFormElement {
|
|||
generation_id: Cell::new(GenerationId(0)),
|
||||
controls: DomRefCell::new(Vec::new()),
|
||||
past_names_map: DomRefCell::new(HashMapTracedValues::new()),
|
||||
current_name_generation: Cell::new(0),
|
||||
firing_submission_events: Cell::new(false),
|
||||
rel_list: Default::default(),
|
||||
relations: Cell::new(LinkRelations::empty()),
|
||||
|
@ -475,9 +478,11 @@ impl HTMLFormElementMethods<crate::DomTypeHolder> for HTMLFormElement {
|
|||
name,
|
||||
(
|
||||
Dom::from_ref(element_node.downcast::<Element>().unwrap()),
|
||||
NoTrace(Instant::now()),
|
||||
NoTrace(self.current_name_generation.get() + 1),
|
||||
),
|
||||
);
|
||||
self.current_name_generation
|
||||
.set(self.current_name_generation.get() + 1);
|
||||
|
||||
// Step 6
|
||||
Some(RadioNodeListOrElement::Element(DomRoot::from_ref(
|
||||
|
@ -515,7 +520,7 @@ impl HTMLFormElementMethods<crate::DomTypeHolder> for HTMLFormElement {
|
|||
enum SourcedNameSource {
|
||||
Id,
|
||||
Name,
|
||||
Past(Duration),
|
||||
Past(usize),
|
||||
}
|
||||
|
||||
impl SourcedNameSource {
|
||||
|
@ -587,7 +592,7 @@ impl HTMLFormElementMethods<crate::DomTypeHolder> for HTMLFormElement {
|
|||
let entry = SourcedName {
|
||||
name: key.clone(),
|
||||
element: DomRoot::from_ref(&*val.0),
|
||||
source: SourcedNameSource::Past(Instant::now().duration_since(val.1 .0)),
|
||||
source: SourcedNameSource::Past(self.current_name_generation.get() - val.1 .0),
|
||||
};
|
||||
sourced_names_vec.push(entry);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue