Search in sources :

Example 1 with NodeImpl

use of org.loboevolution.html.dom.nodeimpl.NodeImpl in project LoboEvolution by LoboEvolution.

the class HtmlPanel method scrollToElementImpl.

private void scrollToElementImpl(String nameOrId) {
    final NodeImpl node = this.rootNode;
    if (node instanceof HTMLDocumentImpl) {
        final HTMLDocumentImpl doc = (HTMLDocumentImpl) node;
        final Element element = doc.getElementById(nameOrId);
        if (element != null) {
            this.scrollTo(element);
        }
    }
}
Also used : HTMLDocumentImpl(org.loboevolution.html.dom.domimpl.HTMLDocumentImpl) NodeImpl(org.loboevolution.html.dom.nodeimpl.NodeImpl) Element(org.loboevolution.html.node.Element)

Example 2 with NodeImpl

use of org.loboevolution.html.dom.nodeimpl.NodeImpl in project LoboEvolution by LoboEvolution.

the class RBlockViewport method layoutChildren.

private void layoutChildren(NodeImpl node) {
    final NodeListImpl nodeList = node.getNodeList();
    if (nodeList != null) {
        nodeList.forEach(nd -> {
            final NodeImpl child = (NodeImpl) nd;
            final NodeType nodeType = child.getNodeType();
            switch(nodeType) {
                case TEXT_NODE:
                    layoutText(child);
                    break;
                case ELEMENT_NODE:
                    this.currentLine.addStyleChanger(new RStyleChanger(child));
                    final String nodeName = child.getNodeName().toUpperCase();
                    MarkupLayout ml = RLayout.elementLayout.get(HTMLTag.get(nodeName));
                    if (ml == null) {
                        ml = miscLayout;
                    }
                    ml.layoutMarkup(this, (HTMLElementImpl) child);
                    this.currentLine.addStyleChanger(new RStyleChanger(node));
                    break;
                case DOCUMENT_FRAGMENT_NODE:
                    final DocumentFragmentImpl fragment = (DocumentFragmentImpl) child;
                    fragment.getNodeList().forEach(fragNode -> {
                        final NodeImpl fragChild = (NodeImpl) fragNode;
                        layoutChildren(fragChild);
                    });
                    break;
                case COMMENT_NODE:
                case PROCESSING_INSTRUCTION_NODE:
                default:
                    break;
            }
        });
    }
}
Also used : DocumentFragmentImpl(org.loboevolution.html.dom.domimpl.DocumentFragmentImpl) NodeListImpl(org.loboevolution.html.dom.nodeimpl.NodeListImpl) NodeImpl(org.loboevolution.html.dom.nodeimpl.NodeImpl) NodeType(org.loboevolution.type.NodeType)

Example 3 with NodeImpl

use of org.loboevolution.html.dom.nodeimpl.NodeImpl in project LoboEvolution by LoboEvolution.

the class BaseBoundableRenderable method resetCursorOnMouseOut.

private static void resetCursorOnMouseOut(final ModelNode nodeStart, final ModelNode limit) {
    Optional<Cursor> foundCursorOpt = Optional.empty();
    ModelNode node = limit;
    while (node != null) {
        if (node instanceof NodeImpl) {
            final NodeImpl uiElement = (NodeImpl) node;
            final RenderState rs = uiElement.getRenderState();
            final Optional<Cursor> cursorOpt = rs.getCursor();
            foundCursorOpt = cursorOpt;
            if (cursorOpt.isPresent()) {
                break;
            }
        }
        node = node.getParentModelNode();
    }
    if (nodeStart instanceof NodeImpl) {
        final NodeImpl uiElement = (NodeImpl) nodeStart;
        final HtmlRendererContext rcontext = uiElement.getHtmlRendererContext();
        rcontext.setCursor(foundCursorOpt);
    }
}
Also used : HtmlRendererContext(org.loboevolution.http.HtmlRendererContext) NodeImpl(org.loboevolution.html.dom.nodeimpl.NodeImpl) RenderState(org.loboevolution.html.renderstate.RenderState) Cursor(java.awt.Cursor) ModelNode(org.loboevolution.html.dom.nodeimpl.ModelNode)

Example 4 with NodeImpl

use of org.loboevolution.html.dom.nodeimpl.NodeImpl in project LoboEvolution by LoboEvolution.

the class Geolocation method geoError.

private void geoError(final Function error, Exception e) {
    final NodeImpl node = (NodeImpl) window.getDocumentNode();
    PositionError pError = null;
    if (e instanceof UnknownHostException) {
        pError = new PositionError(PositionError.POSITION_UNAVAILABLE);
    } else if (e instanceof TimeoutException) {
        pError = new PositionError(PositionError.TIMEOUT);
    }
    Executor.executeFunction(node, error, null, new Object[] { pError });
}
Also used : NodeImpl(org.loboevolution.html.dom.nodeimpl.NodeImpl) UnknownHostException(java.net.UnknownHostException) TimeoutException(java.util.concurrent.TimeoutException)

Example 5 with NodeImpl

use of org.loboevolution.html.dom.nodeimpl.NodeImpl in project LoboEvolution by LoboEvolution.

the class HtmlController method setMouseOnMouseOver.

private static void setMouseOnMouseOver(final BaseBoundableRenderable renderable, final ModelNode nodeStart, final ModelNode limit) {
    ModelNode node = nodeStart;
    while (node != null) {
        if (node == limit) {
            break;
        }
        if (node instanceof NodeImpl) {
            final NodeImpl uiElement = (NodeImpl) node;
            final HtmlRendererContext rcontext = uiElement.getHtmlRendererContext();
            final RenderState rs = uiElement.getRenderState();
            final Optional<Cursor> cursorOpt = rs.getCursor();
            if (cursorOpt.isPresent()) {
                rcontext.setCursor(cursorOpt);
                break;
            } else {
                if (node.getParentModelNode() == limit) {
                    if (renderable instanceof RWord || renderable instanceof RBlank) {
                        rcontext.setCursor(Optional.of(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)));
                    }
                }
            }
        }
        node = node.getParentModelNode();
    }
}
Also used : HtmlRendererContext(org.loboevolution.http.HtmlRendererContext) NodeImpl(org.loboevolution.html.dom.nodeimpl.NodeImpl) RenderState(org.loboevolution.html.renderstate.RenderState) ModelNode(org.loboevolution.html.dom.nodeimpl.ModelNode)

Aggregations

NodeImpl (org.loboevolution.html.dom.nodeimpl.NodeImpl)9 RenderState (org.loboevolution.html.renderstate.RenderState)3 ModelNode (org.loboevolution.html.dom.nodeimpl.ModelNode)2 HtmlRendererContext (org.loboevolution.http.HtmlRendererContext)2 CSSErrorHandler (com.gargoylesoftware.css.parser.CSSErrorHandler)1 CSSException (com.gargoylesoftware.css.parser.CSSException)1 CSSOMParser (com.gargoylesoftware.css.parser.CSSOMParser)1 CSSParseException (com.gargoylesoftware.css.parser.CSSParseException)1 CSS3Parser (com.gargoylesoftware.css.parser.javacc.CSS3Parser)1 Cursor (java.awt.Cursor)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 TimeoutException (java.util.concurrent.TimeoutException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 HTMLHtmlElement (org.loboevolution.html.dom.HTMLHtmlElement)1 DocumentFragmentImpl (org.loboevolution.html.dom.domimpl.DocumentFragmentImpl)1 HTMLDocumentImpl (org.loboevolution.html.dom.domimpl.HTMLDocumentImpl)1 HTMLInputElementImpl (org.loboevolution.html.dom.domimpl.HTMLInputElementImpl)1 NodeListImpl (org.loboevolution.html.dom.nodeimpl.NodeListImpl)1 Element (org.loboevolution.html.node.Element)1