Skip to content

Commit

Permalink
updated past_names_map to save time info
Browse files Browse the repository at this point in the history
  • Loading branch information
amj23897 committed Dec 6, 2019
1 parent 7b968a3 commit 16b9efc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion components/script/dom/bindings/trace.rs
Expand Up @@ -143,13 +143,15 @@ use style::values::specified::Length;
use tendril::fmt::UTF8;
use tendril::stream::LossyDecoder;
use tendril::{StrTendril, TendrilSink};
use time::{Duration, Timespec};
use time::{Duration, Timespec, Tm};
use uuid::Uuid;
use webgpu::{WebGPU, WebGPUAdapter};
use webrender_api::{DocumentId, ImageKey, RenderApiSender};
use webvr_traits::{WebVRGamepadData, WebVRGamepadHand, WebVRGamepadState};
use webxr_api::SwapChainId as WebXRSwapChainId;

unsafe_no_jsmanaged_fields!(Tm);

/// A trait to allow tracing (only) DOM objects.
pub unsafe trait JSTraceable {
/// Trace `self`.
Expand Down
10 changes: 6 additions & 4 deletions components/script/dom/htmlformelement.rs
Expand Up @@ -67,6 +67,8 @@ use style::str::split_html_space_chars;
use crate::dom::bindings::codegen::UnionTypes::RadioNodeListOrElement;
use crate::dom::radionodelist::RadioNodeList;
use std::collections::HashMap;
use time::{now, Tm, Duration};


#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)]
pub struct GenerationId(u32);
Expand All @@ -80,7 +82,7 @@ pub struct HTMLFormElement {
elements: DomOnceCell<HTMLFormControlsCollection>,
generation_id: Cell<GenerationId>,
controls: DomRefCell<Vec<Dom<Element>>>,
past_names_map: DomRefCell<HashMap<DOMString, Dom<Element>>>,
past_names_map: DomRefCell<HashMap<DOMString, (Dom<Element>, Tm)>>,
}

impl HTMLFormElement {
Expand Down Expand Up @@ -300,7 +302,7 @@ impl HTMLFormElementMethods for HTMLFormElement {
if candidates.len() == 0 {
if past_names_map.contains_key(&name) {
return Some(RadioNodeListOrElement::Element(DomRoot::from_ref(
&*past_names_map.get(&name).unwrap(),
&*past_names_map.get(&name).unwrap().0,
)));
}
return None;
Expand All @@ -315,7 +317,7 @@ impl HTMLFormElementMethods for HTMLFormElement {
let element_node = &candidates[0];
past_names_map.insert(
name,
Dom::from_ref(&*element_node.downcast::<Element>().unwrap()),
(Dom::from_ref(&*element_node.downcast::<Element>().unwrap()), now()),
);

return Some(RadioNodeListOrElement::Element(DomRoot::from_ref(
Expand All @@ -328,7 +330,7 @@ impl HTMLFormElementMethods for HTMLFormElement {
enum SourcedNameSource {
Id,
Name,
Past(std::time::Duration),
Past(Duration),
}

struct SourcedName {
Expand Down

0 comments on commit 16b9efc

Please sign in to comment.