Search in sources :

Example 1 with AbstractCSSProperties

use of org.loboevolution.html.style.AbstractCSSProperties in project LoboEvolution by LoboEvolution.

the class ElementImpl method isVScrollable.

private boolean isVScrollable() {
    String overflow;
    AbstractCSSProperties currentStyle = ((HTMLElementImpl) this).getCurrentStyle();
    overflow = currentStyle.getOverflow();
    int heightChild = 0;
    for (final Node child : (NodeListImpl) this.getChildNodes()) {
        if (child instanceof HTMLElementImpl)
            heightChild += ((HTMLElementImpl) child).getClientHeight();
    }
    return ("scroll".equals(overflow) || "auto".equals(overflow)) && (heightChild > this.getClientHeight());
}
Also used : NodeListImpl(org.loboevolution.html.dom.nodeimpl.NodeListImpl) AbstractCSSProperties(org.loboevolution.html.style.AbstractCSSProperties)

Example 2 with AbstractCSSProperties

use of org.loboevolution.html.style.AbstractCSSProperties in project LoboEvolution by LoboEvolution.

the class ElementImpl method getClientLeft.

/**
 * {@inheritDoc}
 */
@Override
public int getClientLeft() {
    final HTMLDocumentImpl doc = (HTMLDocumentImpl) this.document;
    AbstractCSSProperties currentStyle = ((HTMLElementImpl) this).getCurrentStyle();
    return HtmlValues.getPixelSize(currentStyle.getBorderLeftWidth(), null, doc.getDefaultView(), 0);
}
Also used : AbstractCSSProperties(org.loboevolution.html.style.AbstractCSSProperties)

Example 3 with AbstractCSSProperties

use of org.loboevolution.html.style.AbstractCSSProperties in project LoboEvolution by LoboEvolution.

the class ElementImpl method getBoundingClientRect.

/**
 * {@inheritDoc}
 */
@Override
public DOMRect getBoundingClientRect() {
    AbstractCSSProperties currentStyle = ((HTMLElementImpl) this).getCurrentStyle();
    final HTMLDocumentImpl doc = (HTMLDocumentImpl) this.document;
    final Window win = doc.getDefaultView();
    final RenderState rs = doc.getRenderState();
    int width = calculateWidth(true, true);
    int height = calculateHeight(true, true);
    int top = HtmlValues.getPixelSize(currentStyle.getTop(), rs, win, 0);
    int left = HtmlValues.getPixelSize(currentStyle.getLeft(), rs, win, 0);
    for (Node n = getParentNode(); n != null; n = n.getParentNode()) {
        if (!(n instanceof HTMLBodyElement) && !(n instanceof TextImpl) && !(n instanceof HTMLDocumentImpl)) {
            HTMLElementImpl p = (HTMLElementImpl) n;
            AbstractCSSProperties pCurrentStyle = p.getCurrentStyle();
            String topTxt = pCurrentStyle.getTop();
            String leftTxt = pCurrentStyle.getLeft();
            int scrollTop = (int) p.getScrollTop();
            int scrollLeft = (int) p.getScrollLeft();
            if (Strings.isNotBlank(topTxt)) {
                top += HtmlValues.getPixelSize(topTxt, rs, win, 0);
            }
            if (Strings.isNotBlank(leftTxt)) {
                left += HtmlValues.getPixelSize(leftTxt, rs, win, 0);
            }
            top -= scrollTop;
            left -= scrollLeft;
        }
    }
    return new DOMRectImpl(width, height, top, 0, 0, left);
}
Also used : Window(org.loboevolution.html.node.js.Window) RenderState(org.loboevolution.html.renderstate.RenderState) HTMLBodyElement(org.loboevolution.html.dom.HTMLBodyElement) AbstractCSSProperties(org.loboevolution.html.style.AbstractCSSProperties) TextImpl(org.loboevolution.html.dom.nodeimpl.TextImpl) DOMRectImpl(org.loboevolution.html.js.geom.DOMRectImpl)

Example 4 with AbstractCSSProperties

use of org.loboevolution.html.style.AbstractCSSProperties in project LoboEvolution by LoboEvolution.

the class ElementImpl method getClientRects.

/**
 * {@inheritDoc}
 */
@Override
public DOMRectList getClientRects() {
    DOMRectListImpl list = new DOMRectListImpl();
    AbstractCSSProperties style = ((HTMLElementImpl) this).getCurrentStyle();
    String display = Strings.isNotBlank(style.getDisplay()) ? style.getDisplay() : getAttribute("display");
    if (!"none".equals(display)) {
        for (Node n = getParentNode(); n != null; n = n.getPreviousSibling()) {
            if (!(n instanceof HTMLBodyElement) && !(n instanceof TextImpl) && !(n instanceof HTMLDocumentImpl)) {
                HTMLElementImpl p = (HTMLElementImpl) n;
                AbstractCSSProperties st = p.getStyle();
                display = st.getDisplay();
            }
        }
    }
    if (!"none".equals(display)) {
        list.add(getBoundingClientRect());
    }
    return list;
}
Also used : DOMRectListImpl(org.loboevolution.html.js.geom.DOMRectListImpl) HTMLBodyElement(org.loboevolution.html.dom.HTMLBodyElement) AbstractCSSProperties(org.loboevolution.html.style.AbstractCSSProperties) TextImpl(org.loboevolution.html.dom.nodeimpl.TextImpl)

Example 5 with AbstractCSSProperties

use of org.loboevolution.html.style.AbstractCSSProperties in project LoboEvolution by LoboEvolution.

the class ElementImpl method calculateWidth.

protected int calculateWidth(boolean border, boolean padding) {
    final HTMLDocumentImpl doc = (HTMLDocumentImpl) this.document;
    final HtmlRendererContext htmlRendererContext = doc.getHtmlRendererContext();
    final HtmlPanel htmlPanel = htmlRendererContext.getHtmlPanel();
    final Dimension preferredSize = htmlPanel.getPreferredSize();
    final AbstractCSSProperties currentStyle = ((HTMLElementImpl) this).getCurrentStyle();
    String width = currentStyle.getWidth();
    String paddingRight = currentStyle.getPaddingRight();
    String paddingLeft = currentStyle.getPaddingLeft();
    String borderLeftWidth = currentStyle.getBorderLeftWidth();
    String borderRightWidth = currentStyle.getBorderRightWidth();
    String boxSizing = currentStyle.getBoxSizing();
    int sizeWidth = preferredSize.width;
    if (this instanceof HTMLBodyElementImpl) {
        width = String.valueOf(doc.getDefaultView().getInnerWidth());
    }
    final Node nodeObj = getParentNode();
    if (nodeObj instanceof HTMLElementImpl) {
        HTMLElementImpl elem = (HTMLElementImpl) nodeObj;
        if (elem.getClientHeight() != -1) {
            sizeWidth = elem.getClientWidth();
        }
    }
    if (Strings.isBlank(width) || "auto".equalsIgnoreCase(width)) {
        width = "100%";
    }
    int widthSize = HtmlValues.getPixelSize(width, null, doc.getDefaultView(), -1, sizeWidth);
    if ("border-box".equals(boxSizing)) {
        padding = false;
        border = false;
    }
    if (padding) {
        widthSize += HtmlValues.getPixelSize(paddingRight, null, doc.getDefaultView(), 0);
        widthSize += HtmlValues.getPixelSize(paddingLeft, null, doc.getDefaultView(), 0);
    }
    if (border) {
        widthSize += HtmlValues.getPixelSize(borderRightWidth, null, doc.getDefaultView(), 0);
        widthSize += HtmlValues.getPixelSize(borderLeftWidth, null, doc.getDefaultView(), 0);
    }
    return widthSize;
}
Also used : HtmlRendererContext(org.loboevolution.http.HtmlRendererContext) HtmlPanel(org.loboevolution.html.gui.HtmlPanel) AbstractCSSProperties(org.loboevolution.html.style.AbstractCSSProperties)

Aggregations

AbstractCSSProperties (org.loboevolution.html.style.AbstractCSSProperties)43 HTMLElementImpl (org.loboevolution.html.dom.domimpl.HTMLElementImpl)6 SVGElement (org.loboevolution.html.dom.svg.SVGElement)6 HTMLDocumentImpl (org.loboevolution.html.dom.domimpl.HTMLDocumentImpl)5 HTMLBodyElement (org.loboevolution.html.dom.HTMLBodyElement)3 RenderState (org.loboevolution.html.renderstate.RenderState)3 Test (org.junit.Test)2 LoboUnitTest (org.loboevolution.driver.LoboUnitTest)2 NodeListImpl (org.loboevolution.html.dom.nodeimpl.NodeListImpl)2 TextImpl (org.loboevolution.html.dom.nodeimpl.TextImpl)2 HtmlPanel (org.loboevolution.html.gui.HtmlPanel)2 HtmlLength (org.loboevolution.html.style.HtmlLength)2 HtmlRendererContext (org.loboevolution.http.HtmlRendererContext)2 FontKey (org.loboevolution.laf.FontKey)2 ListValues (org.loboevolution.html.ListValues)1 HTMLDocument (org.loboevolution.html.dom.HTMLDocument)1 SVGTransformList (org.loboevolution.html.dom.svg.SVGTransformList)1 DOMRectImpl (org.loboevolution.html.js.geom.DOMRectImpl)1 DOMRectListImpl (org.loboevolution.html.js.geom.DOMRectListImpl)1 Window (org.loboevolution.html.node.js.Window)1