aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/resizeobserver.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/resizeobserver.rs')
-rw-r--r--components/script/dom/resizeobserver.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/components/script/dom/resizeobserver.rs b/components/script/dom/resizeobserver.rs
index 244c0adecc4..31e111cb2ad 100644
--- a/components/script/dom/resizeobserver.rs
+++ b/components/script/dom/resizeobserver.rs
@@ -75,10 +75,11 @@ impl ResizeObserver {
&self,
depth: &ResizeObservationDepth,
has_active: &mut bool,
+ can_gc: CanGc,
) {
for (observation, target) in self.observation_targets.borrow_mut().iter_mut() {
observation.state = Default::default();
- if let Some(size) = observation.is_active(target) {
+ if let Some(size) = observation.is_active(target, can_gc) {
let target_depth = calculate_depth_for_node(target);
if target_depth > *depth {
observation.state = ObservationState::Active(size).into();
@@ -251,9 +252,9 @@ impl ResizeObservation {
/// <https://drafts.csswg.org/resize-observer/#dom-resizeobservation-isactive>
/// Returning an optional calculated size, instead of a boolean,
/// to avoid recalculating the size in the subsequent broadcast.
- fn is_active(&self, target: &Element) -> Option<Rect<Au>> {
+ fn is_active(&self, target: &Element, can_gc: CanGc) -> Option<Rect<Au>> {
let last_reported_size = self.last_reported_sizes.borrow()[0];
- let box_size = calculate_box_size(target, &self.observed_box.borrow());
+ let box_size = calculate_box_size(target, &self.observed_box.borrow(), can_gc);
let is_active = box_size.width().to_f64_px() != last_reported_size.inline_size() ||
box_size.height().to_f64_px() != last_reported_size.block_size();
if is_active {
@@ -272,14 +273,18 @@ fn calculate_depth_for_node(target: &Element) -> ResizeObservationDepth {
}
/// <https://drafts.csswg.org/resize-observer/#calculate-box-size>
-fn calculate_box_size(target: &Element, observed_box: &ResizeObserverBoxOptions) -> Rect<Au> {
+fn calculate_box_size(
+ target: &Element,
+ observed_box: &ResizeObserverBoxOptions,
+ can_gc: CanGc,
+) -> Rect<Au> {
match observed_box {
ResizeObserverBoxOptions::Content_box => {
// Note: only taking first fragment,
// but the spec will expand to cover all fragments.
target
.upcast::<Node>()
- .content_boxes()
+ .content_boxes(can_gc)
.pop()
.unwrap_or_else(Rect::zero)
},