Examples of BlockBox


Examples of org.xhtmlrenderer.render.BlockBox

  }

  private void layout(int width) {
    Rectangle rect = new Rectangle(0, 0, width, DEFAULT_HEIGHT);
    sharedContext.set_TempCanvas(rect);
    BlockBox root = BoxBuilder.createRootBox(layoutContext, doc);
    root.setContainingBlock(new ViewportBox(rect));
    root.layout(layoutContext);
    this.root = root;
  }
View Full Code Here

Examples of org.xhtmlrenderer.render.BlockBox

        if (c.isPrint()) {
            relayoutDataList = new RelayoutDataList(localChildren.size());
        }

        int pageCount = NO_PAGE_TRIM;
        BlockBox previousChildBox = null;
        for (Iterator i = localChildren.iterator(); i.hasNext();) {
            BlockBox child = (BlockBox) i.next();
            offset++;

            RelayoutData relayoutData = null;

            boolean mayCheckKeepTogether = false;
            if (c.isPrint()) {
                relayoutData = relayoutDataList.get(offset);
                relayoutData.setLayoutState(c.copyStateForRelayout());
                relayoutData.setChildOffset(childOffset);
                pageCount = c.getRootLayer().getPages().size();
               
                child.setNeedPageClear(false);
               
                if ((child.getStyle().isAvoidPageBreakInside() || child.getStyle().isKeepWithInline())
                        && c.isMayCheckKeepTogether()) {
                    mayCheckKeepTogether = true;
                    c.setMayCheckKeepTogether(false);
                }
            }

            layoutBlockChild(
                    c, block, child, false, childOffset, NO_PAGE_TRIM, relayoutData.getLayoutState());

            if (c.isPrint()) {
                if (mayCheckKeepTogether) {
                    c.setMayCheckKeepTogether(true);
                    boolean tryToAvoidPageBreak =
                        child.getStyle().isAvoidPageBreakInside() && child.crossesPageBreak(c);
                    boolean needPageClear = child.isNeedPageClear();
                    boolean keepWithInline = child.isNeedsKeepWithInline(c);
                    if (tryToAvoidPageBreak || needPageClear || keepWithInline) {
                        c.restoreStateForRelayout(relayoutData.getLayoutState());
                        child.reset(c);
                        layoutBlockChild(
                                c, block, child, true, childOffset, pageCount, relayoutData.getLayoutState());
   
                        if (tryToAvoidPageBreak && child.crossesPageBreak(c) && ! keepWithInline) {
                            c.restoreStateForRelayout(relayoutData.getLayoutState());
                            child.reset(c);
                            layoutBlockChild(
                                    c, block, child, false, childOffset, pageCount, relayoutData.getLayoutState());
                       
                    }
                }
                c.getRootLayer().ensureHasPage(c, child);
            }

            Dimension relativeOffset = child.getRelativeOffset();
            if (relativeOffset == null) {
                childOffset = child.getY() + child.getHeight();
            } else {
                // Box will have been positioned by this point so calculate
                // relative to where it would have been if it hadn't been
                // moved
                childOffset = child.getY() - relativeOffset.height + child.getHeight();
            }

            if (childOffset > block.getHeight()) {
                block.setHeight(childOffset);
            }

            if (c.isPrint()) {
                if (child.getStyle().isForcePageBreakAfter()) {
                    block.forcePageBreakAfter(c, child.getStyle().getIdent(CSSName.PAGE_BREAK_AFTER));
                    childOffset = block.getHeight();
                }

                if (previousChildBox != null) {
                    relayoutDataList.markRun(offset, previousChildBox, child);
View Full Code Here

Examples of org.xhtmlrenderer.render.BlockBox

            PageBox startPageBox = c.getRootLayer().getFirstPage(c, startBox);
            childOffset += startPageBox.getBottom() - startBox.getAbsY();
        }

        for (int i = start; i <= end; i++) {
            BlockBox child = (BlockBox) localChildren.get(i);

            RelayoutData relayoutData = relayoutDataList.get(i);
           
            int pageCount = c.getRootLayer().getPages().size();

            //TODO:handle run-ins. For now, treat them as blocks

            c.restoreStateForRelayout(relayoutData.getLayoutState());
            relayoutData.setChildOffset(childOffset);
            boolean mayCheckKeepTogether = false;
            if ((child.getStyle().isAvoidPageBreakInside() || child.getStyle().isKeepWithInline())
                    && c.isMayCheckKeepTogether()) {
                mayCheckKeepTogether = true;
                c.setMayCheckKeepTogether(false);
            }           
            layoutBlockChild(
                    c, block, child, false, childOffset, NO_PAGE_TRIM, relayoutData.getLayoutState());

            if (mayCheckKeepTogether) {
                c.setMayCheckKeepTogether(true);
                boolean tryToAvoidPageBreak =
                    child.getStyle().isAvoidPageBreakInside() && child.crossesPageBreak(c);
                boolean needPageClear = child.isNeedPageClear();
                boolean keepWithInline = child.isNeedsKeepWithInline(c);
                if (tryToAvoidPageBreak || needPageClear || keepWithInline) {
                    c.restoreStateForRelayout(relayoutData.getLayoutState());
                    child.reset(c);
                    layoutBlockChild(
                            c, block, child, true, childOffset, pageCount, relayoutData.getLayoutState());
   
                    if (tryToAvoidPageBreak && child.crossesPageBreak(c) && ! keepWithInline) {
                        c.restoreStateForRelayout(relayoutData.getLayoutState());
                        child.reset(c);
                        layoutBlockChild(
                                c, block, child, false, childOffset, pageCount, relayoutData.getLayoutState());
                    }
                }
            }

            c.getRootLayer().ensureHasPage(c, child);

            Dimension relativeOffset = child.getRelativeOffset();
            if (relativeOffset == null) {
                childOffset = child.getY() + child.getHeight();
            } else {
                childOffset = child.getY() - relativeOffset.height + child.getHeight();
            }

            if (child.getStyle().isForcePageBreakAfter()) {
                block.forcePageBreakAfter(c, child.getStyle().getIdent(CSSName.PAGE_BREAK_AFTER));
                childOffset = block.getHeight();
            }
        }

        return childOffset;
View Full Code Here

Examples of org.xhtmlrenderer.render.BlockBox

        _pdfEncryption = pdfEncryption;
    }

    public void layout() {
        LayoutContext c = newLayoutContext();
        BlockBox root = BoxBuilder.createRootBox(c, _doc);
        root.setContainingBlock(new ViewportBox(getInitialExtents(c)));
        root.layout(c);
        Dimension dim = root.getLayer().getPaintingDimension(c);
        root.getLayer().trimEmptyPages(c, dim.height);
        root.getLayer().layoutPages(c);
        _root = root;
    }
View Full Code Here

Examples of org.xhtmlrenderer.render.BlockBox

  private void layout(int width) {
    Rectangle rect = new Rectangle(0, 0, width, DEFAULT_HEIGHT);
    sharedContext.set_TempCanvas(rect);
    LayoutContext c = newLayoutContext();
    BlockBox root = BoxBuilder.createRootBox(c, doc);
    root.setContainingBlock(new ViewportBox(rect));
    root.layout(c);
    this.root = root;
  }
View Full Code Here

Examples of org.xhtmlrenderer.render.BlockBox

                this.layout_context = c;
            }
           
            long start = System.currentTimeMillis();
           
            BlockBox root = (BlockBox)getRootBox();
            if (root != null && isPendingResize()) {
                root.reset(c);
            } else {
                root = BoxBuilder.createRootBox(c, doc);
                setRootBox(root);           
            }
           
            root.setContainingBlock(new ViewportBox(getInitialExtents(c)));
            root.layout(c);
           
            long end = System.currentTimeMillis();
           
            XRLog.layout(Level.INFO, "Layout took " + (end - start) + "ms");
           
            /*
            System.out.println(root.dump(c, "", BlockBox.DUMP_LAYOUT));
            */
           
    // 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 (root.getLayer().containsFixedContent()) {
                super.setOpaque(false);
            } else {
                super.setOpaque(true);
            }
           
            XRLog.layout(Level.FINEST, "after layout: " + root);
           
            Dimension intrinsic_size = root.getLayer().getPaintingDimension(c);
           
            if (c.isPrint()) {
                root.getLayer().trimEmptyPages(c, intrinsic_size.height);
                root.getLayer().layoutPages(c);
            }
           
            setPreferredSize(intrinsic_size);
            revalidate();
           
            // if doc is shorter than viewport
            // then stretch canvas to fill viewport exactly
            // then adjust the body element accordingly
            if (enclosingScrollPane != null) {
                if (intrinsic_size.height < enclosingScrollPane.getViewport().getHeight()) {
                    //Uu.p("int height is less than viewport height");
                    // XXX Not threadsafe
                    if (enclosingScrollPane.getViewport().getHeight() != this.getHeight()) {
                        this.setPreferredSize(new Dimension(
                                intrinsic_size.width, enclosingScrollPane.getViewport().getHeight()));
                        this.revalidate();
                    }
                    //Uu.p("need to do the body hack");
                    if (root != null && ! c.isPrint()) {
                        intrinsic_size.height = root.getHeight();
                    }
                }
               
                // turn on simple scrolling mode if there's any fixed elements
                if (root.getLayer().containsFixedContent()) {
                    // Uu.p("is fixed");
                    enclosingScrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE);
                } else {
                    // Uu.p("is not fixed");
                    enclosingScrollPane.getViewport().setScrollMode(default_scroll_mode);
View Full Code Here

Examples of org.xhtmlrenderer.render.BlockBox

                anonStyle = table.getStyle().deriveStyle(cascadedStyle);
            } else {
                anonStyle = table.getStyle().createAnonymousStyle(IdentValue.BLOCK);
            }

            BlockBox anonBox = new BlockBox();
            anonBox.setStyle(anonStyle);
            anonBox.setAnonymous(true);
            anonBox.setFromCaptionedTable(true);
            anonBox.setElement(table.getElement());

            anonBox.setChildrenContentType(BlockBox.CONTENT_BLOCK);
            anonBox.addAllChildren(topCaptions);
            anonBox.addChild(table);
            anonBox.addAllChildren(bottomCaptions);

            if (table.getStyle().isFloated()) {
                anonBox.setFloatedBoxData(new FloatedBoxData());
                table.setFloatedBoxData(null);

                CascadedStyle original = c.getSharedContext().getCss().getCascadedStyle(
                        table.getElement(), false);
                CascadedStyle modified = CascadedStyle.createLayoutStyle(
View Full Code Here

Examples of org.xhtmlrenderer.render.BlockBox

                        //TODO: counter functions may be called with non-ordered list-style-types, e.g. disc
                        content = cFunc.evaluate();
                        contentFunction = null;
                        function = null;
                    } else if (mode == CONTENT_LIST_MARGIN_BOX && isElementFunction(value.getFunction())) {
                        BlockBox target = getRunningBlock(c, value);
                        if (target != null) {
                            result.add(target.copyOf());
                            info.setContainsBlockLevelContent(true);
                        }
                    } else {
                        contentFunction =
                                c.getContentFunctionFactory().lookupFunction(c, value.getFunction());
View Full Code Here

Examples of org.xhtmlrenderer.render.BlockBox

                    ((PropertyValue)params.get(1)).getStringValue());
        }
        if (position == null) {
            position = PageElementPosition.FIRST;
        }
        BlockBox target = c.getRootDocumentLayer().getRunningBlock(ident, c.getPage(), position);
        return target;
    }
View Full Code Here

Examples of org.xhtmlrenderer.render.BlockBox

                iB.setStyle(anon);
                iB.applyTextTransform();
                iB.setElement(null);
            }

            BlockBox result = createBlockBox(style, info, true);
            result.setStyle(style);
            result.setInlineContent(inlineBoxes);
            result.setElement(element);
            result.setChildrenContentType(BlockBox.CONTENT_INLINE);
            result.setPseudoElementOrClass(peName);

            if (! style.isLayedOutInInlineContext()) {
                info.setContainsBlockLevelContent(true);
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.