aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlimageelement.rs
diff options
context:
space:
mode:
authortanishka <109246904+taniishkaaa@users.noreply.github.com>2024-11-05 03:57:41 +0530
committerGitHub <noreply@github.com>2024-11-04 22:27:41 +0000
commitcc6163dcddcc6918f11bb4b7f134929bd50023bd (patch)
treeece20b77deb203fbf7da3664952d44dff613de16 /components/script/dom/htmlimageelement.rs
parent072ff302d2142fa684b2d5e7024522384e1daf58 (diff)
downloadservo-cc6163dcddcc6918f11bb4b7f134929bd50023bd.tar.gz
servo-cc6163dcddcc6918f11bb4b7f134929bd50023bd.zip
Fix GC borrow hazards triggered by LoadBlocker::terminate (#34122)
* Fix GC borrow hazards triggered by LoadBlocker::terminate Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com> * Fix clippy warnings Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com> * Use borrow_mut() Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com> * Revert to previous code due to crown unrooted error Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com> * Update test expectations Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com> --------- Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
Diffstat (limited to 'components/script/dom/htmlimageelement.rs')
-rw-r--r--components/script/dom/htmlimageelement.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs
index f238d777558..d26557985e1 100644
--- a/components/script/dom/htmlimageelement.rs
+++ b/components/script/dom/htmlimageelement.rs
@@ -154,7 +154,7 @@ struct ImageRequest {
#[no_trace]
parsed_url: Option<ServoUrl>,
source_url: Option<USVString>,
- blocker: Option<LoadBlocker>,
+ blocker: DomRefCell<Option<LoadBlocker>>,
#[ignore_malloc_size_of = "Arc"]
#[no_trace]
image: Option<Arc<Image>>,
@@ -431,7 +431,7 @@ impl HTMLImageElement {
self.current_request.borrow_mut().final_url = Some(url);
self.current_request.borrow_mut().image = Some(image);
self.current_request.borrow_mut().state = State::CompletelyAvailable;
- LoadBlocker::terminate(&mut self.current_request.borrow_mut().blocker, can_gc);
+ LoadBlocker::terminate(&self.current_request.borrow().blocker, can_gc);
// Mark the node dirty
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
self.resolve_image_decode_promises();
@@ -537,7 +537,7 @@ impl HTMLImageElement {
ImageRequestPhase::Current => self.current_request.borrow_mut(),
ImageRequestPhase::Pending => self.pending_request.borrow_mut(),
};
- LoadBlocker::terminate(&mut request.blocker, can_gc);
+ LoadBlocker::terminate(&request.blocker, can_gc);
request.state = state;
request.image = None;
request.metadata = None;
@@ -821,8 +821,9 @@ impl HTMLImageElement {
request.image = None;
request.metadata = None;
let document = document_from_node(self);
- LoadBlocker::terminate(&mut request.blocker, can_gc);
- request.blocker = Some(LoadBlocker::new(&document, LoadType::Image(url.clone())));
+ LoadBlocker::terminate(&request.blocker, can_gc);
+ *request.blocker.borrow_mut() =
+ Some(LoadBlocker::new(&document, LoadType::Image(url.clone())));
}
/// Step 13-17 of html.spec.whatwg.org/multipage/#update-the-image-data
@@ -853,7 +854,7 @@ impl HTMLImageElement {
// Step 15 abort pending request
pending_request.image = None;
pending_request.parsed_url = None;
- LoadBlocker::terminate(&mut pending_request.blocker, can_gc);
+ LoadBlocker::terminate(&pending_request.blocker, can_gc);
// TODO: queue a task to restart animation, if restart-animation is set
return;
}
@@ -1311,7 +1312,7 @@ impl HTMLImageElement {
source_url: None,
image: None,
metadata: None,
- blocker: None,
+ blocker: DomRefCell::new(None),
final_url: None,
current_pixel_density: None,
}),
@@ -1321,7 +1322,7 @@ impl HTMLImageElement {
source_url: None,
image: None,
metadata: None,
- blocker: None,
+ blocker: DomRefCell::new(None),
final_url: None,
current_pixel_density: None,
}),