Search in sources :

Example 1 with HTMLBodyElement

use of org.loboevolution.html.dom.HTMLBodyElement 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 2 with HTMLBodyElement

use of org.loboevolution.html.dom.HTMLBodyElement 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 3 with HTMLBodyElement

use of org.loboevolution.html.dom.HTMLBodyElement in project LoboEvolution by LoboEvolution.

the class LinkRenderState method linkColor.

private Color linkColor() {
    if (rcontext != null) {
        boolean visited = rcontext.isVisitedLink(element);
        String vlink = null;
        String link = null;
        HTMLDocument doc = (HTMLDocument) element.getDocumentNode();
        if (doc != null) {
            HTMLBodyElement body = (HTMLBodyElement) doc.getBody();
            if (body != null) {
                vlink = body.getVLink();
                link = body.getLink();
            }
        }
        vlink = (vlink == null) ? COLOR_VISITED : vlink;
        link = (link == null) ? DEFAULT_COLOR : link;
        String colorText = visited ? vlink : link;
        AbstractCSSProperties props = this.getCssProperties();
        String color = props == null ? null : props.getColor();
        return ColorFactory.getInstance().getColor(color == null ? colorText : color);
    }
    return Color.BLUE;
}
Also used : HTMLDocument(org.loboevolution.html.dom.HTMLDocument) HTMLBodyElement(org.loboevolution.html.dom.HTMLBodyElement) AbstractCSSProperties(org.loboevolution.html.style.AbstractCSSProperties)

Aggregations

HTMLBodyElement (org.loboevolution.html.dom.HTMLBodyElement)3 AbstractCSSProperties (org.loboevolution.html.style.AbstractCSSProperties)3 TextImpl (org.loboevolution.html.dom.nodeimpl.TextImpl)2 HTMLDocument (org.loboevolution.html.dom.HTMLDocument)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 RenderState (org.loboevolution.html.renderstate.RenderState)1