From 859a0ffbd58d57a22aada6ce28647fa69dfad5c8 Mon Sep 17 00:00:00 2001 From: Andrei Volykhin Date: Wed, 21 May 2025 14:18:24 +0300 Subject: htmlmediaelement: Make dirty element on any intrinsic size changes (#37056) To properly compute (the video) element's content size for layout requires to dirty the element on any intrinstic size changes. Full list of the operations which cause layout invalidation: - media metadata update (NEW) - removing "src" attribute - video frame update - show poster image Testing: html/semantics/embedded-content/the-video-element/intrinsic_sizes.htm Fixes: https://github.com/servo/servo/issues/34434 Signed-off-by: Andrei Volykhin --- components/script/dom/htmlmediaelement.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'components/script/dom/htmlmediaelement.rs') diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index 391da272ef3..d1791620592 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -1369,7 +1369,6 @@ impl HTMLMediaElement { .lock() .unwrap() .render_poster_frame(image); - self.upcast::().dirty(NodeDamage::OtherNodeDamage); if pref!(media_testing_enabled) { self.owner_global() @@ -1618,7 +1617,6 @@ impl HTMLMediaElement { // TODO: 6. Abort the overall resource selection algorithm. }, PlayerEvent::VideoFrameUpdated => { - self.upcast::().dirty(NodeDamage::OtherNodeDamage); // Check if the frame was resized if let Some(frame) = self.video_renderer.lock().unwrap().current_frame { self.handle_resize(Some(frame.width as u32), Some(frame.height as u32)); @@ -2017,12 +2015,12 @@ impl HTMLMediaElement { pub(crate) fn clear_current_frame_data(&self) { self.handle_resize(None, None); self.video_renderer.lock().unwrap().current_frame = None; - self.upcast::().dirty(NodeDamage::OtherNodeDamage); } fn handle_resize(&self, width: Option, height: Option) { if let Some(video_elem) = self.downcast::() { video_elem.resize(width, height); + self.upcast::().dirty(NodeDamage::OtherNodeDamage); } } -- cgit v1.2.3