aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorFernando Jiménez Moreno <ferjmoreno@gmail.com>2019-01-15 13:15:03 +0100
committerFernando Jiménez Moreno <ferjmoreno@gmail.com>2019-01-17 10:01:38 +0100
commit4b23c631ea9210fab34bb66d3edce9f63d5f99d1 (patch)
treec73a7031f2d16ecdfd255985cf4cf86402715e9c /components/script/dom
parentf5581a78ab5a2581922a719f54037ca2577ed1ad (diff)
downloadservo-4b23c631ea9210fab34bb66d3edce9f63d5f99d1.tar.gz
servo-4b23c631ea9210fab34bb66d3edce9f63d5f99d1.zip
No need to share a reference for HTMLMediaElement played TimeRange
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/htmlmediaelement.rs8
-rw-r--r--components/script/dom/timeranges.rs16
2 files changed, 8 insertions, 16 deletions
diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs
index 6faa718a0a9..97170befaf1 100644
--- a/components/script/dom/htmlmediaelement.rs
+++ b/components/script/dom/htmlmediaelement.rs
@@ -203,7 +203,7 @@ pub struct HTMLMediaElement {
resource_url: DomRefCell<Option<ServoUrl>>,
/// https://html.spec.whatwg.org/multipage/#dom-media-played
#[ignore_malloc_size_of = "Rc"]
- played: Rc<DomRefCell<TimeRangesContainer>>,
+ played: DomRefCell<TimeRangesContainer>,
/// https://html.spec.whatwg.org/multipage/#dom-media-texttracks
text_tracks_list: MutNullableDom<TextTrackList>,
/// Time of last timeupdate notification.
@@ -264,7 +264,7 @@ impl HTMLMediaElement {
volume: Cell::new(1.0),
seeking: Cell::new(false),
resource_url: DomRefCell::new(None),
- played: Rc::new(DomRefCell::new(TimeRangesContainer::new())),
+ played: DomRefCell::new(TimeRangesContainer::new()),
text_tracks_list: Default::default(),
next_timeupdate_event: Cell::new(time::get_time() + Duration::milliseconds(250)),
current_fetch_context: DomRefCell::new(None),
@@ -1654,7 +1654,7 @@ impl HTMLMediaElementMethods for HTMLMediaElement {
// https://html.spec.whatwg.org/multipage/#dom-media-played
fn Played(&self) -> DomRoot<TimeRanges> {
- TimeRanges::new(self.global().as_window(), self.played.clone())
+ TimeRanges::new(self.global().as_window(), self.played.borrow().clone())
}
// https://html.spec.whatwg.org/multipage/#dom-media-buffered
@@ -1665,7 +1665,7 @@ impl HTMLMediaElementMethods for HTMLMediaElement {
let _ = buffered.add(range.start as f64, range.end as f64);
}
}
- TimeRanges::new(self.global().as_window(), Rc::new(DomRefCell::new(buffered)))
+ TimeRanges::new(self.global().as_window(), buffered)
}
// https://html.spec.whatwg.org/multipage/#dom-media-texttracks
diff --git a/components/script/dom/timeranges.rs b/components/script/dom/timeranges.rs
index 645de7b5799..7b4d1978a60 100644
--- a/components/script/dom/timeranges.rs
+++ b/components/script/dom/timeranges.rs
@@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::TimeRangesBinding;
use crate::dom::bindings::codegen::Bindings::TimeRangesBinding::TimeRangesMethods;
use crate::dom::bindings::error::{Error, Fallible};
@@ -12,7 +11,6 @@ use crate::dom::bindings::root::DomRoot;
use crate::dom::window::Window;
use dom_struct::dom_struct;
use std::fmt;
-use std::rc::Rc;
#[derive(Clone, JSTraceable, MallocSizeOf)]
struct TimeRange {
@@ -128,22 +126,18 @@ impl TimeRangesContainer {
#[dom_struct]
pub struct TimeRanges {
reflector_: Reflector,
- #[ignore_malloc_size_of = "Rc"]
- ranges: Rc<DomRefCell<TimeRangesContainer>>,
+ ranges: TimeRangesContainer,
}
impl TimeRanges {
- fn new_inherited(ranges: Rc<DomRefCell<TimeRangesContainer>>) -> TimeRanges {
+ fn new_inherited(ranges: TimeRangesContainer) -> TimeRanges {
Self {
reflector_: Reflector::new(),
ranges,
}
}
- pub fn new(
- window: &Window,
- ranges: Rc<DomRefCell<TimeRangesContainer>>,
- ) -> DomRoot<TimeRanges> {
+ pub fn new(window: &Window, ranges: TimeRangesContainer) -> DomRoot<TimeRanges> {
reflect_dom_object(
Box::new(TimeRanges::new_inherited(ranges)),
window,
@@ -155,13 +149,12 @@ impl TimeRanges {
impl TimeRangesMethods for TimeRanges {
// https://html.spec.whatwg.org/multipage/#dom-timeranges-length
fn Length(&self) -> u32 {
- self.ranges.borrow().len()
+ self.ranges.len()
}
// https://html.spec.whatwg.org/multipage/#dom-timeranges-start
fn Start(&self, index: u32) -> Fallible<Finite<f64>> {
self.ranges
- .borrow()
.start(index)
.map(Finite::wrap)
.map_err(|_| Error::IndexSize)
@@ -170,7 +163,6 @@ impl TimeRangesMethods for TimeRanges {
// https://html.spec.whatwg.org/multipage/#dom-timeranges-end
fn End(&self, index: u32) -> Fallible<Finite<f64>> {
self.ranges
- .borrow()
.end(index)
.map(Finite::wrap)
.map_err(|_| Error::IndexSize)