Search in sources :

Example 1 with HTMLElementImpl

use of org.loboevolution.html.dom.domimpl.HTMLElementImpl in project LoboEvolution by LoboEvolution.

the class HtmlBlockPanel method getUINode.

private UINode getUINode(Node currentNode) {
    UINode uiNode = null;
    while (currentNode != null) {
        if (currentNode instanceof HTMLElementImpl) {
            HTMLElementImpl element = (HTMLElementImpl) currentNode;
            uiNode = element.getUINode();
            if (uiNode != null) {
                break;
            }
        }
        currentNode = currentNode.getParentNode();
    }
    return uiNode;
}
Also used : HTMLElementImpl(org.loboevolution.html.dom.domimpl.HTMLElementImpl) UINode(org.loboevolution.html.dom.domimpl.UINode)

Example 2 with HTMLElementImpl

use of org.loboevolution.html.dom.domimpl.HTMLElementImpl in project LoboEvolution by LoboEvolution.

the class ImgControl method getValueSize.

private int getValueSize(String attribute, String styleAttribute, int availSize) {
    String size;
    if (Strings.isNotBlank(attribute)) {
        size = attribute.toLowerCase().trim();
    } else {
        size = Strings.isNotBlank(styleAttribute) ? styleAttribute : "";
    }
    final HTMLElementImpl element = this.controlElement;
    HTMLDocumentImpl doc = (HTMLDocumentImpl) element.getDocumentNode();
    return HtmlValues.getPixelSize(size, null, doc.getDefaultView(), -1, availSize);
}
Also used : HTMLElementImpl(org.loboevolution.html.dom.domimpl.HTMLElementImpl) HTMLDocumentImpl(org.loboevolution.html.dom.domimpl.HTMLDocumentImpl)

Example 3 with HTMLElementImpl

use of org.loboevolution.html.dom.domimpl.HTMLElementImpl in project LoboEvolution by LoboEvolution.

the class BaseElementRenderable method applyStyle.

/**
 * <p>applyStyle.</p>
 *
 * @param availWidth a int.
 * @param availHeight a int.
 */
protected void applyStyle(int availWidth, int availHeight) {
    final Object rootNode = this.modelNode;
    HTMLElementImpl rootElement;
    boolean isRootBlock;
    if (rootNode instanceof HTMLDocumentImpl) {
        isRootBlock = true;
        final HTMLDocumentImpl doc = (HTMLDocumentImpl) rootNode;
        rootElement = (HTMLElementImpl) doc.getBody();
    } else {
        isRootBlock = false;
        rootElement = (HTMLElementImpl) rootNode;
    }
    if (rootElement == null) {
        clearStyle(isRootBlock);
        return;
    }
    final RenderState rs = rootElement.getRenderState();
    if (rs == null) {
        throw new IllegalStateException("Element without render state: " + rootElement + "; parent=" + rootElement.getParentNode());
    }
    backgroundApplyStyle(rs);
    final AbstractCSSProperties props = rootElement.getCurrentStyle();
    if (props == null) {
        clearStyle(isRootBlock);
    } else {
        insetsApplyStyle(rs, availWidth, availHeight, isRootBlock);
        zIndexApplyStyle(props);
        this.overflowX = rs.getOverflowX();
        this.overflowY = rs.getOverflowY();
    }
}
Also used : HTMLElementImpl(org.loboevolution.html.dom.domimpl.HTMLElementImpl) HTMLDocumentImpl(org.loboevolution.html.dom.domimpl.HTMLDocumentImpl) RenderState(org.loboevolution.html.renderstate.RenderState) AbstractCSSProperties(org.loboevolution.html.style.AbstractCSSProperties)

Example 4 with HTMLElementImpl

use of org.loboevolution.html.dom.domimpl.HTMLElementImpl in project LoboEvolution by LoboEvolution.

the class BaseElementRenderable method getDeclaredWidthImpl.

private int getDeclaredWidthImpl(RenderState renderState, int availWidth) {
    Object rootNode = this.modelNode;
    if (rootNode instanceof HTMLElementImpl) {
        HTMLElementImpl element = (HTMLElementImpl) rootNode;
        HTMLDocumentImpl doc = (HTMLDocumentImpl) element.getDocumentNode();
        CSS3Properties props = element.getCurrentStyle();
        if (props == null) {
            return -1;
        }
        String widthText = props.getWidth();
        final String textContent = element.getTextContent();
        if ("inherit".equalsIgnoreCase(widthText)) {
            widthText = element.getParentStyle().getWidth();
        } else if ("initial".equalsIgnoreCase(widthText)) {
            widthText = "100%";
        }
        int width = -1;
        if (widthText != null) {
            width = HtmlValues.getPixelSize(widthText, renderState, doc.getDefaultView(), -1, availWidth);
        }
        if (width == -1 && Strings.isNotBlank(textContent) && renderState.getDisplay() == RenderState.DISPLAY_INLINE_BLOCK) {
            HtmlInsets paddingInsets = renderState.getPaddingInsets();
            HtmlInsets marginInsets = renderState.getMarginInsets();
            int right = 0;
            int left = 0;
            if (paddingInsets != null) {
                right = right + paddingInsets.right;
                left = left + paddingInsets.left;
            }
            if (marginInsets != null) {
                right = right + marginInsets.right;
                left = left + marginInsets.left;
            }
            final int multi = (right == 0 && left == 0) ? 12 : 4;
            width = (textContent.length() + right + left) * multi;
        }
        if (props.getMaxWidth() != null) {
            int maxWidth = HtmlValues.getPixelSize(props.getMaxWidth(), renderState, doc.getDefaultView(), -1, availWidth);
            if (width == -1 || width > maxWidth) {
                width = maxWidth;
            }
        }
        if (props.getMinWidth() != null) {
            int minWidth = HtmlValues.getPixelSize(props.getMinWidth(), element.getRenderState(), doc.getDefaultView(), 0, availWidth);
            if (width == 0 || width < minWidth) {
                width = minWidth;
            }
        }
        return width;
    } else {
        return -1;
    }
}
Also used : HTMLElementImpl(org.loboevolution.html.dom.domimpl.HTMLElementImpl) HTMLDocumentImpl(org.loboevolution.html.dom.domimpl.HTMLDocumentImpl) HtmlInsets(org.loboevolution.html.style.HtmlInsets) CSS3Properties(org.loboevolution.html.node.css.CSS3Properties)

Example 5 with HTMLElementImpl

use of org.loboevolution.html.dom.domimpl.HTMLElementImpl in project LoboEvolution by LoboEvolution.

the class BaseElementRenderable method hasDeclaredWidth.

/**
 * <p>hasDeclaredWidth.</p>
 *
 * @return a boolean.
 */
public final boolean hasDeclaredWidth() {
    final Integer dw = this.declaredWidth;
    if (INVALID_SIZE.equals(dw)) {
        final Object rootNode = this.modelNode;
        if (rootNode instanceof HTMLElementImpl) {
            final HTMLElementImpl element = (HTMLElementImpl) rootNode;
            final CSS3Properties props = element.getCurrentStyle();
            if (props == null) {
                return false;
            }
            return !Strings.isBlank(props.getWidth());
        }
        return false;
    }
    return true;
}
Also used : HTMLElementImpl(org.loboevolution.html.dom.domimpl.HTMLElementImpl) CSS3Properties(org.loboevolution.html.node.css.CSS3Properties)

Aggregations

HTMLElementImpl (org.loboevolution.html.dom.domimpl.HTMLElementImpl)39 HTMLDocumentImpl (org.loboevolution.html.dom.domimpl.HTMLDocumentImpl)13 Test (org.junit.Test)11 LoboUnitTest (org.loboevolution.driver.LoboUnitTest)11 AbstractCSSProperties (org.loboevolution.html.style.AbstractCSSProperties)6 HtmlInsets (org.loboevolution.html.style.HtmlInsets)4 CSS3Properties (org.loboevolution.html.node.css.CSS3Properties)3 RenderState (org.loboevolution.html.renderstate.RenderState)3 HtmlLength (org.loboevolution.html.style.HtmlLength)3 BorderInfo (org.loboevolution.info.BorderInfo)3 CSSStyleDeclarationImpl (com.gargoylesoftware.css.dom.CSSStyleDeclarationImpl)2 ModelNode (org.loboevolution.html.dom.nodeimpl.ModelNode)2 HtmlPanel (org.loboevolution.html.gui.HtmlPanel)2 ListStyle (org.loboevolution.html.style.ListStyle)2 HtmlRendererContext (org.loboevolution.http.HtmlRendererContext)2 CSSStyleSheetImpl (com.gargoylesoftware.css.dom.CSSStyleSheetImpl)1 java.awt (java.awt)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1