Only attach descendants if parent was detached

If a layer is reparented, we also attach the children. We traverse down
the heirarchy and attach all descendants. However, we really only want
to attach descendants if they were initially detached because the layer
that's getting reparented detached them.

For example, Child called detachChildren and its Grandchild was
detached. Parent calls reparent. We want to attach Child if it was
detached and then proceed down its children. If Child wasn't detached,
we don't want to attach Grandchild since the layer that detached it
hasn't been reparented.

As cleanup, also moved DetachChildren test to their own file

Test: DetachChildren.ReparentParentLayerOfDetachedChildren
Change-Id: I53b6d9cb165b810e9c55da8a9ba86c7b53a13c0e
4 files changed