Skip to content

Commit f69ac1e

Browse files
alonschfacebook-github-bot-7
authored andcommitted
Revert D2679408 (Only send layout update operation to nativehierarchymanager when layout actually changes)
Reviewed By: andreicoman11 Differential Revision: D2712224 fb-gh-sync-id: e6aebe6fcf54e9f36cac092cab801bb97a65dbfd
1 parent 30a5eb5 commit f69ac1e

File tree

2 files changed

+23
-29
lines changed

2 files changed

+23
-29
lines changed

ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNode.java

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import com.facebook.infer.annotation.Assertions;
1919
import com.facebook.react.bridge.ReadableMap;
2020
import com.facebook.react.bridge.ReadableMapKeySetIterator;
21-
import com.facebook.react.uimanager.events.EventDispatcher;
2221

2322
/**
2423
* Base node class for representing virtual tree of React nodes. Shadow nodes are used primarily
@@ -203,37 +202,18 @@ public void onCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue) {
203202
float absoluteX,
204203
float absoluteY,
205204
UIViewOperationQueue uiViewOperationQueue,
206-
NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer,
207-
EventDispatcher eventDispatcher) {
205+
NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer) {
208206
if (mNodeUpdated) {
209207
onCollectExtraUpdates(uiViewOperationQueue);
210208
}
211209

212210
if (hasNewLayout()) {
213-
float absoluteLeft = Math.round(absoluteX + getLayoutX());
214-
float absoluteTop = Math.round(absoluteY + getLayoutY());
215-
float absoluteRight = Math.round(absoluteX + getLayoutX() + getLayoutWidth());
216-
float absoluteBottom = Math.round(absoluteY + getLayoutY() + getLayoutHeight());
217-
// If the layout didn't change this should calculate exactly same values, it's fine to compare
218-
// floats with "==" in this case
219-
if (absoluteLeft != mAbsoluteLeft || absoluteTop != mAbsoluteTop ||
220-
absoluteRight != mAbsoluteRight || absoluteBottom != mAbsoluteBottom) {
221-
mAbsoluteLeft = absoluteLeft;
222-
mAbsoluteTop = absoluteTop;
223-
mAbsoluteRight = absoluteRight;
224-
mAbsoluteBottom = absoluteBottom;
225-
226-
nativeViewHierarchyOptimizer.handleUpdateLayout(this);
227-
if (mShouldNotifyOnLayout) {
228-
eventDispatcher.dispatchEvent(
229-
OnLayoutEvent.obtain(
230-
getReactTag(),
231-
getScreenX(),
232-
getScreenY(),
233-
getScreenWidth(),
234-
getScreenHeight()));
235-
}
236-
}
211+
mAbsoluteLeft = Math.round(absoluteX + getLayoutX());
212+
mAbsoluteTop = Math.round(absoluteY + getLayoutY());
213+
mAbsoluteRight = Math.round(absoluteX + getLayoutX() + getLayoutWidth());
214+
mAbsoluteBottom = Math.round(absoluteY + getLayoutY() + getLayoutHeight());
215+
216+
nativeViewHierarchyOptimizer.handleUpdateLayout(this);
237217
}
238218
}
239219

@@ -284,6 +264,10 @@ public void setShouldNotifyOnLayout(boolean shouldNotifyOnLayout) {
284264
mShouldNotifyOnLayout = shouldNotifyOnLayout;
285265
}
286266

267+
/* package */ boolean shouldNotifyOnLayout() {
268+
return mShouldNotifyOnLayout;
269+
}
270+
287271
/**
288272
* Adds a child that the native view hierarchy will have at this index in the native view
289273
* corresponding to this node.

ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,18 @@ protected void applyUpdatesRecursive(
698698
absoluteX,
699699
absoluteY,
700700
mOperationsQueue,
701-
mNativeViewHierarchyOptimizer,
702-
eventDispatcher);
701+
mNativeViewHierarchyOptimizer);
702+
703+
// notify JS about layout event if requested
704+
if (cssNode.shouldNotifyOnLayout()) {
705+
eventDispatcher.dispatchEvent(
706+
OnLayoutEvent.obtain(
707+
tag,
708+
cssNode.getScreenX(),
709+
cssNode.getScreenY(),
710+
cssNode.getScreenWidth(),
711+
cssNode.getScreenHeight()));
712+
}
703713
}
704714
cssNode.markUpdateSeen();
705715
}

0 commit comments

Comments
 (0)