mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Avoid borrow panic when Path2D.addPath is called with self (#36847)
Fixes: #36842 Signed-off-by: Taym <haddadi.taym@gmail.com>
This commit is contained in:
parent
3936b1d22b
commit
7ea5951e34
3 changed files with 20 additions and 2 deletions
|
@ -65,8 +65,14 @@ impl Path2DMethods<crate::DomTypeHolder> for Path2D {
|
|||
/// <https://html.spec.whatwg.org/multipage/#dom-path2d-addpath>
|
||||
fn AddPath(&self, other: &Path2D) {
|
||||
// Step 7. Add all the subpaths in c to a.
|
||||
let mut dest = self.path.borrow_mut();
|
||||
dest.extend(other.path.borrow().iter().copied());
|
||||
if std::ptr::eq(&self.path, &other.path) {
|
||||
// Note: this is not part of the spec, but it is a workaround to
|
||||
// avoids borrow conflict when path is same as other.path
|
||||
self.path.borrow_mut().extend_from_within(..);
|
||||
} else {
|
||||
let mut dest = self.path.borrow_mut();
|
||||
dest.extend(other.path.borrow().iter().copied());
|
||||
}
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-context-2d-closepath>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue