-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement AddEventListenerOptions: once #22100
Conversation
Heads up! This PR modifies the following files:
|
@bors-servo try=wpt |
Implement AddEventListenerOptions: once Fixes #13242 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22100) <!-- Reviewable:end -->
☀️ Test successful - linux-rel-css, linux-rel-wpt |
|
||
impl std::cmp::PartialEq for EventListenerEntry { | ||
fn eq(&self, other: &Self) -> bool { | ||
self.phase == other.phase && self.listener == other.listener |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is once
ignored?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because removing an eventlistener without specifying once: true still needs to find the ones that are once
components/script/dom/eventtarget.rs
Outdated
|
||
let listener = EventListenerType::Additive(listener); | ||
for entry in handlers.get_mut(ty) { | ||
if let Some(position) = entry.iter().position(|e| e.listener == listener && e.once) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can probably use drain
here, which will result in slightly more performant code.
components/script/dom/eventtarget.rs
Outdated
}); | ||
} | ||
}, | ||
} | ||
} | ||
|
||
pub fn remove_listener_if_once(&self, ty: &Atom, listener: Rc<EventListener>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make listener
be a &Rc<EventListener>
and you will be able to avoid a cloning operation in the caller.
This should improve the behaviour of html/webappapis/dynamic-markup-insertion/opening-the-input-stream/bailout-exception-vs-return-xml.window.js; otherwise it ends up endlessly loading new iframes. |
There, anything else ? :p |
@bors-servo r+ |
📌 Commit 4b45958 has been approved by |
Implement AddEventListenerOptions: once Fixes #13242 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22100) <!-- Reviewable:end -->
💔 Test failed - status-taskcluster |
Ran rustfmt |
@bors-servo r+ |
📌 Commit 50c8327 has been approved by |
Implement AddEventListenerOptions: once Fixes #13242 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22100) <!-- Reviewable:end -->
☀️ Test successful - android-mac, arm32, arm64, linux-rel-css, linux-rel-wpt, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, magicleap, status-taskcluster |
Fixes #13242
This change is