// Should only ever collapse top margin and pick up collapsable
// bottom margins by looking back up the tree.
private void collapseMargins(LayoutContext c) {
if (! isTopMarginCalculated() || ! isBottomMarginCalculated()) {
recalcMargin(c);
RectPropertySet margin = getMargin(c);
if (! isTopMarginCalculated() && ! isBottomMarginCalculated() && isVerticalMarginsAdjoin(c)) {
MarginCollapseResult collapsedMargin =
_pendingCollapseCalculation != null ?
_pendingCollapseCalculation : new MarginCollapseResult();
collapseEmptySubtreeMargins(c, collapsedMargin);
setCollapsedBottomMargin(c, margin, collapsedMargin);
} else {
if (! isTopMarginCalculated()) {
MarginCollapseResult collapsedMargin =
_pendingCollapseCalculation != null ?
_pendingCollapseCalculation : new MarginCollapseResult();
collapseTopMargin(c, true, collapsedMargin);
if ((int) margin.top() != collapsedMargin.getMargin()) {
setMarginTop(c, collapsedMargin.getMargin());
}
}
if (! isBottomMarginCalculated()) {