mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
revert: feat: requestLayout performance improvements (#9122)
This reverts commit 4f5f0aae77.
This commit breaks back-navigation in certain cases, most prominently with Button pseudo classes. We plan to revisit this.
This commit is contained in:
committed by
Igor Randjelovic
parent
59af23744b
commit
eb0d000fe1
@@ -1,4 +1,3 @@
|
||||
|
||||
import { ViewBase } from '../view-base';
|
||||
|
||||
// Types.
|
||||
@@ -1362,8 +1361,6 @@ function inheritableCssPropertyValuesOn(style: Style): Array<{ property: Inherit
|
||||
type PropertyInterface = Property<ViewBase, any> | CssProperty<Style, any> | CssAnimationProperty<Style, any>;
|
||||
|
||||
export const initNativeView = profile('"properties".initNativeView', function initNativeView(view: ViewBase): void {
|
||||
const wasSuspended = view.suspendRequestLayout;
|
||||
view.suspendRequestLayout = true;
|
||||
if (view._suspendedUpdates) {
|
||||
applyPendingNativeSetters(view);
|
||||
} else {
|
||||
@@ -1371,14 +1368,6 @@ export const initNativeView = profile('"properties".initNativeView', function in
|
||||
}
|
||||
// Would it be faster to delete all members of the old object?
|
||||
view._suspendedUpdates = {};
|
||||
|
||||
// if the view requestLayout was not suspended before
|
||||
// it means we can request a layout if needed.
|
||||
// will be done after otherwise
|
||||
view.suspendRequestLayout = wasSuspended;
|
||||
if (!wasSuspended && view.isLayoutRequestNeeded) {
|
||||
view.requestLayout();
|
||||
}
|
||||
});
|
||||
|
||||
export function applyPendingNativeSetters(view: ViewBase): void {
|
||||
|
||||
@@ -431,10 +431,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
|
||||
if (this._isLoaded) {
|
||||
return;
|
||||
}
|
||||
// the view is going to be layed out after
|
||||
// no need for requestLayout which can be pretty slow because
|
||||
// called a lot and going all up the chain to the page
|
||||
this.suspendRequestLayout = true;
|
||||
|
||||
this._isLoaded = true;
|
||||
this._cssState.onLoaded();
|
||||
this._resumeNativeUpdates(SuspendType.Loaded);
|
||||
@@ -445,7 +442,6 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
|
||||
return true;
|
||||
});
|
||||
|
||||
this.suspendRequestLayout = false;
|
||||
this._emit('loaded');
|
||||
}
|
||||
|
||||
@@ -662,20 +658,6 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
|
||||
}
|
||||
}
|
||||
|
||||
_requestLayoutNeeded = false;
|
||||
|
||||
get isLayoutRequestNeeded() {
|
||||
return this._requestLayoutNeeded;
|
||||
}
|
||||
|
||||
_suspendRequestLayout = false;
|
||||
set suspendRequestLayout(value: boolean) {
|
||||
this._suspendRequestLayout = value;
|
||||
}
|
||||
get suspendRequestLayout() {
|
||||
return this._suspendRequestLayout;
|
||||
}
|
||||
|
||||
@profile
|
||||
public requestLayout(): void {
|
||||
// Default implementation for non View instances (like TabViewItem).
|
||||
|
||||
@@ -537,11 +537,6 @@ export class View extends ViewCommon {
|
||||
|
||||
@profile
|
||||
public requestLayout(): void {
|
||||
if (this._suspendRequestLayout) {
|
||||
this._requestLayoutNeeded = true;
|
||||
return;
|
||||
}
|
||||
this._requestLayoutNeeded = false;
|
||||
super.requestLayout();
|
||||
if (this.nativeViewProtected) {
|
||||
this.nativeViewProtected.requestLayout();
|
||||
|
||||
@@ -63,21 +63,9 @@ export class View extends ViewCommon implements ViewDefinition {
|
||||
this.once(View.loadedEvent, () => setupAccessibleView(this));
|
||||
}
|
||||
|
||||
requestLayoutIfNeeded() {
|
||||
if (this.isLayoutRequired) {
|
||||
this._requestLayoutNeeded = false;
|
||||
this.requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
public requestLayout(): void {
|
||||
if (this._suspendRequestLayout) {
|
||||
this._requestLayoutNeeded = true;
|
||||
return;
|
||||
}
|
||||
this._requestLayoutNeeded = false;
|
||||
this._privateFlags |= PFLAG_FORCE_LAYOUT;
|
||||
super.requestLayout();
|
||||
this._privateFlags |= PFLAG_FORCE_LAYOUT;
|
||||
|
||||
const nativeView = this.nativeViewProtected;
|
||||
if (nativeView && nativeView.setNeedsLayout) {
|
||||
|
||||
Reference in New Issue
Block a user