/** * Assert that the given {@link Node} is of type {@link Node#TEXT_NODE} and * automatically typecast it. */ public static Text as(Node node) { assert node.getNodeType() == Node.TEXT_NODE; return (Text) node; }
/** * Determine whether the given {@link Node} can be cast to an {@link Element}. * A <code>null</code> node will cause this method to return * <code>false</code>. */ public static boolean is(Node node) { return (node != null) && (node.getNodeType() == Node.ELEMENT_NODE); }
private void updateVisibility(Element container) { // If this element has an associated layer, re-run layout for it. Layer layer = getLayer(container); if (layer != null) { layout(layer); } // Walk all children, looking for elements with a '__layer' property. If one // exists, call layout() for that element. This is not cheap, but it's the // only way to correctly ensure that layout units get translated correctly. NodeList<Node> nodes = container.getChildNodes(); for (int i = 0; i < nodes.getLength(); ++i) { Node node = nodes.getItem(i); if (node.getNodeType() == Node.ELEMENT_NODE) { updateVisibility(node.<Element>cast()); } } } }
/** * A code representing the type of the underlying object. * @return A code representing the type of the underlying object */ public final short getNodeType() { return ot.getNodeType(); }
/** * Determine whether the given {@link Node} can be cast to an {@link Element}. * A <code>null</code> node will cause this method to return * <code>false</code>. */ public static boolean is(Node node) { return (node != null) && (node.getNodeType() == Node.ELEMENT_NODE); }
/** * A code representing the type of the underlying object. * @return A code representing the type of the underlying object */ public final short getNodeType() { return ot.getNodeType(); }
/** * Assert that the given {@link Node} is of type {@link Node#TEXT_NODE} and * automatically typecast it. */ public static Text as(Node node) { assert node.getNodeType() == Node.TEXT_NODE; return (Text) node; }
@Override public short getNodeType() { return node.getNodeType(); }
/** * Assert that the given {@link Node} is of type {@link Node#TEXT_NODE} and * automatically typecast it. */ public static Text as(Node node) { assert node.getNodeType() == Node.TEXT_NODE; return (Text) node; }
/** * Determine whether the given {@link Node} can be cast to an {@link Element}. * A <code>null</code> node will cause this method to return * <code>false</code>. */ public static boolean is(Node node) { return (node != null) && (node.getNodeType() == Node.ELEMENT_NODE); }
@PatchMethod static boolean is(JavaScriptObject object) { if (object == null) { return false; } short nodeType = object.<Node>cast().getNodeType(); return nodeType > 0; }
@PatchMethod static short getNodeType(JavaScriptObject jsObject) { Node node = jsObject.cast(); return node.getNodeType(); }
@PatchMethod static short getNodeType(JavaScriptObject jsObject) { Node node = jsObject.cast(); return node.getNodeType(); }
@PatchMethod static Element getParentElement(Object domImpl, Node elem) { Node parent = elem.getParentNode(); if (parent == null || !(parent.getNodeType() == Node.ELEMENT_NODE)) { return null; } return parent.cast(); }
/** * Returns the owner document element of an element. */ public static Document getOwnerDocument(Node n) { return n == null || !isElement(n) ? null : n.getNodeType() == Node.DOCUMENT_NODE ? n.<Document> cast() : n.getOwnerDocument(); }
public static NodeList<Element> veryQuickId(String id, Node ctx) { Document d = ctx.getNodeType() == Node.DOCUMENT_NODE ? ctx.<Document> cast() : ctx.getOwnerDocument(); return JsNodeArray.create(d.getElementById(id)); }
@PatchMethod static Element getFirstChildElement(Object domImpl, Element elem) { NodeList<Node> nodeList = elem.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.getItem(i); if (node.getNodeType() == Node.ELEMENT_NODE) { return node.cast(); } } return null; }
@PatchMethod static Element getFirstChildElement(Object domImpl, Element elem) { NodeList<Node> nodeList = elem.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.getItem(i); if (node.getNodeType() == Node.ELEMENT_NODE) { return node.cast(); } } return null; }
@PatchMethod static String getNodeValue(JavaScriptObject o) { Node n = o.cast(); switch (n.getNodeType()) { case com.google.gwt.xml.client.Node.ATTRIBUTE_NODE: return JavaScriptObjects.getString(n, XML_ATTR_VALUE); case Node.ELEMENT_NODE: Element e = n.cast(); return e.getInnerText(); default: return n.getNodeValue(); } }
private static void getSiblingNodes(JsNodeArray matchingElms, JsObjectArray<String> nextTag, JsRegexp nextRegExp, Node prevRef) { while (JsUtils.truth(prevRef = SelectorEngine.getNextSibling(prevRef)) && prevRef.getNodeType() != Node.ELEMENT_NODE) { } if (JsUtils.truth(prevRef)) { if (!JsUtils.truth(nextTag) || nextRegExp .test(prevRef.getNodeName())) { matchingElms.addNode(prevRef); } } }