this.layout_context = c;
    public void startLayout(Graphics g) {        this.removeAll();        if (g == null) {            return;        }        if (doc == null) {            return;        }                // set up CSS        Context c = newContext((Graphics2D) g);        //getContext().setMaxWidth(0);                getRenderingContext().getTextRenderer().setupGraphics(c.getGraphics());        //TODO: maybe temporary hack        if (c.getBlockFormattingContext() != null) c.popBFC();//we set one for the top level before        body_box = Boxing.layout(c, new DomToplevelNode(doc));        if (!c.isStylesAllPopped()) {            XRLog.layout(Level.SEVERE, "mismatch in style popping and pushing");        }        XRLog.layout(Level.FINEST, "is a fixed child: " + body_box.isChildrenExceedBounds());                // if there is a fixed child then we need to set opaque to false        // so that the entire viewport will be repainted. this is slower        // but that's the hit you get from using fixed layout        if (body_box.isChildrenExceedBounds()) {            setOpaque(false);        } else {            setOpaque(true);        }        getRenderingContext().setRootBox(body_box);        XRLog.layout(Level.FINEST, "after layout: " + body_box);        intrinsic_size = new Dimension(getContext().getMaxWidth(), body_box.height);        if (enclosingScrollPane != null) {            XRLog.layout(Level.FINEST, "enclosing scroll pane = " + this.enclosingScrollPane);            int view_height = this.enclosingScrollPane.getViewport().getHeight();                        // resize the outter most box incase it is too small for the viewport            if (intrinsic_size.getHeight() < view_height) {                if (body_box != null) {                    body_box.height = view_height;                }            }        }        if (!intrinsic_size.equals(this.getSize())) {            this.setPreferredSize(intrinsic_size);            this.revalidate();        }        this.fireDocumentLoaded();    }