Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47391720 authored by Selim Cinek's avatar Selim Cinek Committed by Android (Google) Code Review
Browse files

Merge "ViewGroup now applies clipBounds to its children"

parents cbdf956b 19cadc20
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -719,6 +719,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    private static boolean sIgnoreMeasureCache = false;
    /**
     * Ignore the clipBounds of this view for the children.
     */
    static boolean sIgnoreClipBoundsForChildren = false;
    /**
     * This view does not want keystrokes. Use with TAKES_FOCUS_MASK when
     * calling setFlags.
@@ -2963,7 +2968,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    /**
     * Current clip bounds. to which all drawing of this view are constrained.
     */
    private Rect mClipBounds = null;
    Rect mClipBounds = null;
    private boolean mLastIsOpaque;
@@ -3511,6 +3516,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            // of whether a layout was requested on that View.
            sIgnoreMeasureCache = targetSdkVersion < KITKAT;
            // Older apps may need this to ignore the clip bounds
            sIgnoreClipBoundsForChildren = targetSdkVersion < L;
            sCompatibilityDone = true;
        }
    }
+14 −4
Original line number Diff line number Diff line
@@ -2962,14 +2962,24 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
            }
        }

        int saveCount = 0;
        int clipSaveCount = 0;
        final boolean clipToPadding = (flags & CLIP_TO_PADDING_MASK) == CLIP_TO_PADDING_MASK;
        boolean hasClipBounds = mClipBounds != null && !sIgnoreClipBoundsForChildren;
        boolean clippingNeeded = clipToPadding || hasClipBounds;

        if (clippingNeeded) {
            clipSaveCount = canvas.save();
        }

        if (clipToPadding) {
            saveCount = canvas.save();
            canvas.clipRect(mScrollX + mPaddingLeft, mScrollY + mPaddingTop,
                    mScrollX + mRight - mLeft - mPaddingRight,
                    mScrollY + mBottom - mTop - mPaddingBottom);
        }

        if (hasClipBounds) {
            canvas.clipRect(mClipBounds.left, mClipBounds.top, mClipBounds.right,
                    mClipBounds.bottom);
        }

        // We will draw our child's animation, let's reset the flag
@@ -3010,8 +3020,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
            onDebugDraw(canvas);
        }

        if (clipToPadding) {
            canvas.restoreToCount(saveCount);
        if (clippingNeeded) {
            canvas.restoreToCount(clipSaveCount);
        }

        // mGroupFlags might have been updated by drawChild()