}  if (content instanceof DomToplevelNode || block.getStyle().requiresLayer()) { c.pushLayer(block);
    private static Box layout(LayoutContext c, Box block, Content content, StyleSetListener listener) {        //OK, first set up the current style. All depends on this...        CascadedStyle pushed = content.getStyle();        if (pushed != null) {            c.pushStyle(pushed);        }        boolean oldFirstLine = c.isFirstLine();        c.setFirstLine(true);        Rectangle oe = c.getExtents();        block.setStyle(new Style(c.getCurrentStyle(), (float) oe.getWidth()));                if (listener != null ) {            listener.onStyleSet(block);        }        if (c.getCurrentStyle().isIdent(CSSName.BACKGROUND_ATTACHMENT, IdentValue.FIXED)) {            c.getRootLayer().setFixedBackground(true);        }                if (content instanceof DomToplevelNode || block.getStyle().establishesBFC()) {            BlockFormattingContext bfc = new BlockFormattingContext(block, c);            c.pushBFC(bfc);        }                 if (content instanceof DomToplevelNode || block.getStyle().requiresLayer()) {            c.pushLayer(block);        }                // copy the extents        c.setExtents(new Rectangle(oe));        VerticalMarginCollapser.collapseVerticalMargins(c, block, content, (float) oe.getWidth());        BorderPropertySet border = c.getCurrentStyle().getBorder(c);        //note: percentages here refer to width of containing block        RectPropertySet margin = block.getStyle().getMarginWidth(c);        RectPropertySet padding = c.getCurrentStyle().getPaddingRect((float) oe.getWidth(), (float) oe.getWidth(), c);        // CLEAN: cast to int        block.leftPadding = (int) margin.left() + (int) border.left() + (int) padding.left();        block.rightPadding = (int) padding.right() + (int) border.right() + (int) margin.right();        block.contentWidth = (int) (c.getExtents().getWidth() - block.leftPadding - block.rightPadding);        CalculatedStyle style = c.getCurrentStyle();        // calculate the width and height as much as possible        if (!(block instanceof AnonymousBlockBox)) {            int setHeight = -1;//means height is not set by css            int setWidth = -1;//means width is not set by css            if (!block.getStyle().isAutoWidth()) {                setWidth = (int) style.getFloatPropertyProportionalWidth(CSSName.WIDTH, c.getExtents().width, c);                block.contentWidth = setWidth;                c.getExtents().width = block.getWidth();            }            if (!block.getStyle().isAutoHeight()) {                setHeight = (int) style.getFloatPropertyProportionalHeight(CSSName.HEIGHT, c.getExtents().height, c);                // CLEAN: cast to int                c.getExtents().height = (int) margin.top() + (int) border.top() + (int) padding.top() +                        setHeight + (int) padding.bottom() + (int) border.bottom() + (int) margin.bottom();                block.height = setHeight;            }            //check if replaced            JComponent cc = c.getNamespaceHandler().getCustomComponent(content.getElement(), c.getUac(), setWidth, setHeight);            if (cc != null) {                Rectangle bounds = cc.getBounds();                //block.x = bounds.x;                //block.y = bounds.y;                block.contentWidth = bounds.width;                block.height = bounds.height;                block.component = cc;            }        }                //block.x = c.getExtents().x;        //block.y = c.getExtents().y;                // save height incase fixed height        int original_height = block.height;        if (block.component == null) {            block.height = 0;        }        // do children's layout        boolean old_sub = c.isSubBlock();        c.setSubBlock(false);        // CLEAN: cast to int        int tx = (int) margin.left() + (int) border.left() + (int) padding.left();        int ty = (int) margin.top() + (int) border.top() + (int) padding.top();        block.tx = tx;        block.ty = ty;        c.translate(tx, ty);        // CLEAN: cast to int        c.shrinkExtents(tx + (int) margin.right() + (int) border.right() + (int) padding.right(), ty + (int) margin.bottom() + (int) border.bottom() + (int) padding.bottom());        if (block.component == null)            layoutChildren(c, block, content);//when this is really an anonymous, InlineLayout.layoutChildren is called        else {            Point origin = c.getOriginOffset();            block.component.setLocation((int) origin.getX(), (int) origin.getY());            if (c.isInteractive()) {                c.getCanvas().add(block.component);            }            block.setState(Box.DONE);        }        c.unshrinkExtents();        c.translate(-tx, -ty);        c.setSubBlock(old_sub);        // restore height incase fixed height        if (!block.getStyle().isAutoHeight()) {            // Uu.p("restoring original height");            block.height = original_height;        }        if (content instanceof DomToplevelNode || block.getStyle().establishesBFC()) {            c.popBFC();        }                if (content instanceof DomToplevelNode  || block.getStyle().requiresLayer()) {            c.popLayer();        }        // calculate the total outer width        //block.contentWidth = block.getWidth();        //block.width = margin.left + border.left + padding.left + block.contentWidth + padding.right + border.right + margin.right;        // CLEAN: cast to int        block.height = (int) margin.top() + (int) border.top() + (int) padding.top() + block.height + (int) padding.bottom() + (int) border.bottom() + (int) margin.bottom();        //restore the extents        c.setExtents(oe);                if (block.getStyle().isFloated()) {            c.getBlockFormattingContext().floatBox(c, (FloatedBlockBox) block);        }                if (block instanceof BlockBox && block.getStyle().isListItem() &&                ((BlockBox)block).getStructMetrics() == null) {            StrutMetrics strutMetrics = InlineBoxing.createDefaultStrutMetrics(c, block);            ((BlockBox)block).setStructMetrics(strutMetrics);        }        checkExceeds(block);        //and now, back to previous style        if (pushed != null) {            c.popStyle();        }        c.setFirstLine(oldFirstLine);        // Uu.p("BoxLayout: finished with block: " + block);        return block;    }