Skip to content

Commit

Permalink
bridge: move a couple of BridgeContext null checks to a better place
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosame committed Sep 23, 2024
1 parent 9b7eeb5 commit b262f2a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1184,23 +1184,25 @@ public void addUIEventListeners(Document doc) {
}

public void removeUIEventListeners(Document doc) {
EventTarget evtTarget = (EventTarget) doc.getDocumentElement();
synchronized (eventListenerSet) {
for (EventListenerMememto elm : eventListenerSet) {
NodeEventTarget et = elm.getTarget();
if (et == evtTarget) {
EventListener el = elm.getListener();
boolean uc = elm.getUseCapture();
String t = elm.getEventType();
boolean n = elm.getNamespaced();
if (et == null || el == null || t == null) {
continue;
}
if (n) {
String ns = elm.getNamespaceURI();
et.removeEventListenerNS(ns, t, el, uc);
} else {
et.removeEventListener(t, el, uc);
Element evtTarget = doc.getDocumentElement();
if (evtTarget != null) {
synchronized (eventListenerSet) {
for (EventListenerMememto elm : eventListenerSet) {
NodeEventTarget et = elm.getTarget();
if (et == evtTarget) {
EventListener el = elm.getListener();
boolean uc = elm.getUseCapture();
String t = elm.getEventType();
boolean n = elm.getNamespaced();
if (el == null || t == null) {
continue;
}
if (n) {
String ns = elm.getNamespaceURI();
et.removeEventListenerNS(ns, t, el, uc);
} else {
et.removeEventListener(t, el, uc);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,29 +281,30 @@ public void addUIEventListeners(Document doc) {

@Override
public void removeUIEventListeners(Document doc) {
EventTarget evtTarget = (EventTarget) doc.getDocumentElement();
AbstractNode n = (AbstractNode) evtTarget;
XBLEventSupport es = (XBLEventSupport) n.initializeEventSupport();

synchronized (eventListenerSet) {
for (EventListenerMememto elm : eventListenerSet) {
NodeEventTarget et = elm.getTarget();
if (et == evtTarget) {
EventListener el = elm.getListener();
boolean uc = elm.getUseCapture();
String t = elm.getEventType();
boolean in = elm.getNamespaced();
if (et == null || el == null || t == null) {
continue;
}
if (elm instanceof ImplementationEventListenerMememto) {
String ns = elm.getNamespaceURI();
es.removeImplementationEventListenerNS(ns, t, el, uc);
} else if (in) {
String ns = elm.getNamespaceURI();
et.removeEventListenerNS(ns, t, el, uc);
} else {
et.removeEventListener(t, el, uc);
AbstractNode evtTarget = (AbstractNode) doc.getDocumentElement();
if (evtTarget != null) {
XBLEventSupport es = (XBLEventSupport) evtTarget.initializeEventSupport();

synchronized (eventListenerSet) {
for (EventListenerMememto elm : eventListenerSet) {
NodeEventTarget et = elm.getTarget();
if (et == evtTarget) {
EventListener el = elm.getListener();
boolean uc = elm.getUseCapture();
String t = elm.getEventType();
boolean in = elm.getNamespaced();
if (el == null || t == null) {
continue;
}
if (elm instanceof ImplementationEventListenerMememto) {
String ns = elm.getNamespaceURI();
es.removeImplementationEventListenerNS(ns, t, el, uc);
} else if (in) {
String ns = elm.getNamespaceURI();
et.removeEventListenerNS(ns, t, el, uc);
} else {
et.removeEventListener(t, el, uc);
}
}
}
}
Expand Down

0 comments on commit b262f2a

Please sign in to comment.