/** * Asserts that the given child element is managed by this layout. * * @param elem the element to be tested */ public void assertIsChild(Element elem) { assert elem.getParentElement().getParentElement() == this.parentElem : "Element is not a child of this layout"; }
public Element getStyleElement(Element popup) { return popup.getParentElement(); }
/** * Gets an element's parent element. * * @param elem the element whose parent is to be retrieved * @return the parent element */ public static com.google.gwt.user.client.Element getParent(Element elem) { return asOld(elem.getParentElement()); }
/** * Collects parents going up the element tree, terminated at the tree root. */ private void collectElementChain(ArrayList<Element> chain, Element hRoot, Element hElem) { if ((hElem == null) || (hElem == hRoot)) { return; } collectElementChain(chain, hRoot, hElem.getParentElement()); chain.add(hElem); }
/** * Pop to the previous element in the stack. */ private void popElement() { currentElement = getCurrentElement().getParentElement(); }
/** * Checks that the parent of {@code rendered} has a single child. */ private static boolean isRenderedElementSingleChild(Element rendered) { return GWT.isProdMode() || rendered.getParentElement().getChildCount() == 1; }
private static boolean isElementChildOfWidget(Element element) { // Walk up the DOM hierarchy, looking for any widget with an event listener // set. Though it is not dependable in the general case that a widget will // have set its element's event listener at all times, it *is* dependable // if the widget is attached. Which it will be in this case. element = element.getParentElement(); BodyElement body = Document.get().getBody(); while ((element != null) && (body != element)) { if (Event.getEventListener(element) != null) { return true; } element = element.getParentElement().cast(); } return false; }
String fieldName = getFieldName(uiId, cursor); if (fieldName == null) { cursor = cursor.getParentElement(); continue; return table.get(key); cursor = cursor.getParentElement();
/** * Attaches the element to the dom temporarily. Keeps track of where it is * attached so that things can be put back latter. * * @return attachment record which can be used for reverting back to previous * DOM state */ public static TempAttachment attachToDom(Element element) { // TODO(rjrjr) This is copied from HTMLPanel. Reconcile ensureHiddenDiv(); // Hang on to the panel's original parent and sibling elements so that it // can be replaced. Element origParent = element.getParentElement(); Element origSibling = element.getNextSiblingElement(); // Attach the panel's element to the hidden div. hiddenDiv.appendChild(element); return new TempAttachment(origParent, origSibling, element); }
public Element attachChild(Element parent, Element child, Element before) { DivElement container = Document.get().createDivElement(); container.appendChild(child); container.getStyle().setPosition(Position.ABSOLUTE); container.getStyle().setOverflow(Overflow.HIDDEN); fillParent(child); Element beforeContainer = null; if (before != null) { beforeContainer = before.getParentElement(); assert beforeContainer.getParentElement() == parent : "Element to insert before must be a sibling"; } parent.insertBefore(container, beforeContainer); return container; }
/** * In DevMode, walks up the parents of the {@code rendered} element to ascertain that it is * attached to the document. Always returns <code>true</code> in ProdMode. */ private static boolean isAttachedToDom(Element rendered) { if (GWT.isProdMode()) { return true; } Element body = Document.get().getBody(); while (rendered != null && rendered.hasParentElement() && !body.equals(rendered)) { rendered = rendered.getParentElement(); } return body.equals(rendered); }
EventListener listener = DOM.getEventListener(curElem); while (curElem != null && listener == null) { curElem = curElem.getParentElement(); listener = (curElem == null) ? null : DOM.getEventListener(curElem);
public void removeChild(Element container, Element child) { container.removeFromParent(); // We want this code to be resilient to the child having already been // removed from its container (perhaps by widget code). if (child.getParentElement() == container) { child.removeFromParent(); } // Cleanup child styles set by fillParent(). Style style = child.getStyle(); style.clearPosition(); style.clearLeft(); style.clearTop(); style.clearWidth(); style.clearHeight(); } }
/** * Given a click event, return the Cell that was clicked, or null if the event * did not hit this table. The cell can also be null if the click event does * not occur on a specific cell. * * @param event A click event of indeterminate origin * @return The appropriate cell, or null */ public Cell getCellForEvent(ClickEvent event) { Element td = getEventTargetCell(Event.as(event.getNativeEvent())); if (td == null) { return null; } int row = TableRowElement.as(td.getParentElement()).getSectionRowIndex(); int column = TableCellElement.as(td).getCellIndex(); return new Cell(row, column); }
Element cellTarget = target; while ((cellTarget != null) && ((idxString = cellTarget.getAttribute("__idx")).length() == 0)) { cellTarget = cellTarget.getParentElement();
/** * Handle an event from a cell. Used by {@link #initEventSystem()}. * * @param event the event to handle. */ private static void handleNonBubblingEvent(Event event) { // Get the event target. EventTarget eventTarget = event.getEventTarget(); if (!Element.is(eventTarget)) { return; } Element target = eventTarget.cast(); // Get the event listener, which is the first widget that handles the // specified event type. String typeName = event.getType(); EventListener listener = DOM.getEventListener(target); while (target != null && listener == null) { target = target.getParentElement().cast(); if (target != null && isNonBubblingEventHandled(target, typeName)) { // The target handles the event, so this must be the event listener. listener = DOM.getEventListener(target); } } // Fire the event. if (listener != null) { DOM.dispatchEvent(event, target, listener); } }
com.google.gwt.dom.client.Element deckElem = container1.getParentElement(); int deckHeight = deckElem.getOffsetHeight(); if (growing) {
oldImg.getParentElement().replaceChild(imageElem, oldImg);
cur = cur.getParentElement();
/** * Get a set of elements containing all of the unique siblings of each of the matched set of * elements. */ public GQuery siblings() { JsNodeArray result = JsNodeArray.create(); for (Element e : elements) { allNextSiblingElements(e.getParentElement().getFirstChildElement(), result, e, null, null); } return new GQuery(unique(result)); }