Skip to content

Commit

Permalink
[v3.8.6] Optimize code size for pointer-event-dispatcher.ts. (#18220)
Browse files Browse the repository at this point in the history
addPointerEventProcessor, removePointerEventProcessor, dispatchEventMouse, dispatchEventTouch don't need to be public.
  • Loading branch information
dumganhar authored Jan 21, 2025
1 parent e652d6e commit d8eb4f6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cocos/2d/event/pointer-event-dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class PointerEventDispatcher implements IEventDispatcher {
return true;
}

public addPointerEventProcessor (pointerEventProcessor: NodeEventProcessor): void {
private addPointerEventProcessor (pointerEventProcessor: NodeEventProcessor): void {
if (this._inDispatchCount === 0) {
if (!this._pointerEventProcessorList.includes(pointerEventProcessor)) {
this._pointerEventProcessorList.push(pointerEventProcessor);
Expand All @@ -88,7 +88,7 @@ class PointerEventDispatcher implements IEventDispatcher {
js.array.remove(this._processorListToRemove, pointerEventProcessor);
}

public removePointerEventProcessor (pointerEventProcessor: NodeEventProcessor): void {
private removePointerEventProcessor (pointerEventProcessor: NodeEventProcessor): void {
if (this._inDispatchCount === 0) {
js.array.remove(this._pointerEventProcessorList, pointerEventProcessor);
this._isListDirty = true;
Expand All @@ -98,7 +98,7 @@ class PointerEventDispatcher implements IEventDispatcher {
js.array.remove(this._processorListToAdd, pointerEventProcessor);
}

public dispatchEventMouse (eventMouse: EventMouse): boolean {
private dispatchEventMouse (eventMouse: EventMouse): boolean {
this._inDispatchCount++;
this._sortPointerEventProcessorList();
const pointerEventProcessorList = this._pointerEventProcessorList;
Expand All @@ -122,7 +122,7 @@ class PointerEventDispatcher implements IEventDispatcher {
return dispatchToNextEventDispatcher;
}

public dispatchEventTouch (eventTouch: EventTouch): boolean {
private dispatchEventTouch (eventTouch: EventTouch): boolean {
this._inDispatchCount++;
this._sortPointerEventProcessorList();
const pointerEventProcessorList = this._pointerEventProcessorList;
Expand Down Expand Up @@ -236,7 +236,9 @@ class PointerEventDispatcher implements IEventDispatcher {
if (p1.cachedCameraPriority !== p2.cachedCameraPriority) {
return p2.cachedCameraPriority - p1.cachedCameraPriority;
}
let n1: Node | null = node1; let n2: Node | null = node2; let ex = false;
let n1: Node | null = node1;
let n2: Node | null = node2;
let ex = false;
while (n1!.parent?.uuid !== n2!.parent?.uuid) {
n1 = n1?.parent?.parent === null ? (ex = true) && node2 : n1 && n1.parent;
n2 = n2?.parent?.parent === null ? (ex = true) && node1 : n2 && n2.parent;
Expand Down

0 comments on commit d8eb4f6

Please sign in to comment.