|
21 | 21 | import android.view.MotionEvent;
|
22 | 22 | import android.view.View;
|
23 | 23 | import android.view.ViewGroup;
|
| 24 | +import android.view.ViewParent; |
24 | 25 | import android.view.ViewStructure;
|
25 | 26 | import android.view.animation.Animation;
|
26 | 27 | import com.facebook.common.logging.FLog;
|
@@ -427,6 +428,53 @@ private void updateSubviewClipStatus(View subview) {
|
427 | 428 | }
|
428 | 429 | }
|
429 | 430 |
|
| 431 | + @Override |
| 432 | + public boolean getChildVisibleRect(View child, Rect r, android.graphics.Point offset) { |
| 433 | + // This is based on the Android ViewGroup implementation, modified to clip child rects |
| 434 | + // if overflow is set to ViewProps.HIDDEN. This effectively solves Issue #23870 which |
| 435 | + // appears to have been introduced by FLAG_CLIP_CHILDREN being forced false |
| 436 | + // regardless of whether clipping is desired. |
| 437 | + |
| 438 | + final RectF rect = new RectF(); |
| 439 | + rect.set(r); |
| 440 | + |
| 441 | + child.getMatrix().mapRect(rect); |
| 442 | + |
| 443 | + final int dx = child.getLeft() - getScrollX(); |
| 444 | + int dy = child.getTop() - getScrollY(); |
| 445 | + |
| 446 | + rect.offset(dx, dy); |
| 447 | + |
| 448 | + if (offset != null) { |
| 449 | + float[] position = new float[2]; |
| 450 | + position[0] = offset.x; |
| 451 | + position[1] = offset.y; |
| 452 | + child.getMatrix().mapPoints(position); |
| 453 | + offset.x = Math.round(position[0]) + dx; |
| 454 | + offset.y = Math.round(position[1]) + dy; |
| 455 | + } |
| 456 | + |
| 457 | + final int width = getRight() - getLeft(); |
| 458 | + final int height = getBottom() - getTop(); |
| 459 | + |
| 460 | + boolean rectIsVisible = true; |
| 461 | + |
| 462 | + ViewParent parent = getParent(); |
| 463 | + String overflow = getOverflow(); |
| 464 | + if (parent == null || |
| 465 | + (overflow != null && overflow.equals(ViewProps.HIDDEN))) { |
| 466 | + rectIsVisible = rect.intersect(0, 0, width, height); |
| 467 | + } |
| 468 | + |
| 469 | + r.set((int) Math.floor(rect.left), (int) Math.floor(rect.top), |
| 470 | + (int) Math.ceil(rect.right), (int) Math.ceil(rect.bottom)); |
| 471 | + |
| 472 | + if (rectIsVisible && parent != null) { |
| 473 | + rectIsVisible = parent.getChildVisibleRect(this, r, offset); |
| 474 | + } |
| 475 | + return rectIsVisible; |
| 476 | + } |
| 477 | + |
430 | 478 | @Override
|
431 | 479 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
432 | 480 | super.onSizeChanged(w, h, oldw, oldh);
|
|
0 commit comments