Skip to content
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

[v3.8.5] Mangle private properties in touch-manager.ts #17868

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pal/input/native/mouse-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ export class MouseInputSource {
this._windowManager = jsb.ISystemWindowManager.getInstance();
}

public dispatchMouseDownEvent (nativeMouseEvent: any): void { this._handleMouseDown(nativeMouseEvent); }
public dispatchMouseMoveEvent (nativeMouseEvent: any): void { this._handleMouseMove(nativeMouseEvent); }
public dispatchMouseUpEvent (nativeMouseEvent: any): void { this._handleMouseUp(nativeMouseEvent); }
public dispatchScrollEvent (nativeMouseEvent: any): void { this._boundedHandleMouseWheel(nativeMouseEvent); }
public dispatchMouseDownEvent (nativeMouseEvent: any): void { this._handleMouseDown(nativeMouseEvent as jsb.MouseEvent); }
public dispatchMouseMoveEvent (nativeMouseEvent: any): void { this._handleMouseMove(nativeMouseEvent as jsb.MouseEvent); }
public dispatchMouseUpEvent (nativeMouseEvent: any): void { this._handleMouseUp(nativeMouseEvent as jsb.MouseEvent); }
public dispatchScrollEvent (nativeMouseEvent: any): void { this._boundedHandleMouseWheel(nativeMouseEvent as jsb.MouseWheelEvent); }

private _getLocation (event: jsb.MouseEvent): Vec2 {
const window = this._windowManager.getWindow(event.windowId);
Expand Down
50 changes: 25 additions & 25 deletions pal/input/touch-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class TouchManager {
/**
* A map from touch ID to touch object.
*/
private _touchMap: Map<number, Touch> = new Map();
private readonly _maxTouches = 8;
private _touchMap$: Map<number, Touch> = new Map();
private readonly _maxTouches$ = 8;

constructor () {
}
Expand All @@ -45,24 +45,24 @@ class TouchManager {
* - If the number of touches doesn't exceed the max count, we create a touch object.
* - If the number of touches exceeds the max count, we discard the timeout touch to create a new one.
* - If the number of touches exceeds the max count and there is no timeout touch, we can't create any touch object.
* @param touchID
* @param x
* @param y
* @returns
* @param touchID The touch identifier
* @param x The x-axis coordinate of the current touch point.
* @param y The y-axis coordinate of the current touch point.
* @return The Touch instance or undefined.
*/
private _createTouch (touchID: number, x: number, y: number): Touch | undefined {
if (this._touchMap.has(touchID)) {
private _createTouch$ (touchID: number, x: number, y: number): Touch | undefined {
if (this._touchMap$.has(touchID)) {
logID(2301);
return undefined;
}
const checkResult = this._checkTouchMapSizeMoreThanMax(touchID);
const checkResult = this._checkTouchMapSizeMoreThanMax$(touchID);
if (checkResult) {
logID(2300);
return undefined;
}
const touch = new Touch(x, y, touchID);
this._touchMap.set(touchID, touch);
this._updateTouch(touch, x, y);
this._touchMap$.set(touchID, touch);
this._updateTouch$(touch, x, y);
return touch;
}

Expand All @@ -72,10 +72,10 @@ class TouchManager {
* @returns
*/
public releaseTouch (touchID: number): void {
if (!this._touchMap.has(touchID)) {
if (!this._touchMap$.has(touchID)) {
return;
}
this._touchMap.delete(touchID);
this._touchMap$.delete(touchID);
}

/**
Expand All @@ -84,7 +84,7 @@ class TouchManager {
* @returns
*/
public getTouch (touchID: number): Touch | undefined {
return this._touchMap.get(touchID);
return this._touchMap$.get(touchID);
}

/**
Expand All @@ -95,9 +95,9 @@ class TouchManager {
public getOrCreateTouch (touchID: number, x: number, y: number): Touch | undefined {
let touch = this.getTouch(touchID);
if (!touch) {
touch = this._createTouch(touchID, x, y);
touch = this._createTouch$(touchID, x, y);
} else {
this._updateTouch(touch, x, y);
this._updateTouch$(touch, x, y);
}
return touch;
}
Expand All @@ -108,7 +108,7 @@ class TouchManager {
*/
public getAllTouches (): Touch[] {
const touches: Touch[] = [];
this._touchMap.forEach((touch) => {
this._touchMap$.forEach((touch) => {
if (touch) {
touches.push(touch);
}
Expand All @@ -120,7 +120,7 @@ class TouchManager {
* Get the number of touches.
*/
public getTouchCount (): number {
return touchManager._touchMap.size;
return this._touchMap$.size;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be this here.

}

/**
Expand All @@ -129,30 +129,30 @@ class TouchManager {
* @param x The current location X
* @param y The current location Y
*/
private _updateTouch (touch: Touch, x: number, y: number): void {
private _updateTouch$ (touch: Touch, x: number, y: number): void {
touch.getLocation(tempVec2);
touch.setPrevPoint(tempVec2);
touch.setPoint(x, y);
}

private _checkTouchMapSizeMoreThanMax (touchID: number): boolean {
if (this._touchMap.has(touchID)) {
private _checkTouchMapSizeMoreThanMax$ (touchID: number): boolean {
if (this._touchMap$.has(touchID)) {
return false;
}
const maxSize = macro.ENABLE_MULTI_TOUCH ? this._maxTouches : 1;
if (this._touchMap.size < maxSize) {
const maxSize = macro.ENABLE_MULTI_TOUCH ? this._maxTouches$ : 1;
if (this._touchMap$.size < maxSize) {
return false;
}
// Handle when exceed the max number of touches
const now = performance.now();
this._touchMap.forEach((touch) => {
this._touchMap$.forEach((touch) => {
if (now - touch.lastModified > macro.TOUCH_TIMEOUT) {
logID(2302, touch.getID());
// TODO: need to handle touch cancel event when exceed the max number of touches ?
this.releaseTouch(touch.getID());
}
});
return maxSize >= this._touchMap.size;
return maxSize >= this._touchMap$.size;
}
}

Expand Down
Loading