/** * Automatically tries to create a proxy image from given element. * * @param element * @param alignImageToEvent if true, proxy image is aligned to start event, else next to mouse * cursor * @deprecated As of 7.2, call or override {@link #createDragImage(Element,boolean)} instead */ @Deprecated public void createDragImage( com.google.gwt.user.client.Element element, boolean alignImageToEvent) { Element cloneNode = (Element) element.cloneNode(true); // Set size explicitly for cloned node to avoid stretching #14617. cloneNode.getStyle().setWidth(element.getOffsetWidth(), Unit.PX); cloneNode.getStyle().setHeight(element.getOffsetHeight(), Unit.PX); syncContent(element, cloneNode); if (BrowserInfo.get().isIE()) { if (cloneNode.getTagName().toLowerCase().equals("tr")) { TableElement table = Document.get().createTableElement(); TableSectionElement tbody = Document.get().createTBodyElement(); table.appendChild(tbody); tbody.appendChild(cloneNode); cloneNode = table.cast(); } } if (alignImageToEvent) { int absoluteTop = element.getAbsoluteTop(); int absoluteLeft = element.getAbsoluteLeft(); int clientX = WidgetUtil.getTouchOrMouseClientX(startEvent); int clientY = WidgetUtil.getTouchOrMouseClientY(startEvent); int offsetX = absoluteLeft - clientX; int offsetY = absoluteTop - clientY; setDragImage(cloneNode, offsetX, offsetY); } else { setDragImage(cloneNode); } }
/** * Do additional content sync between <code>original</code> element and its <code>copy</code> if * needed. * * @since 7.2 * @param original original element * @param copy copy of original element */ private void syncContent(Element original, Element copy) { for (int i = 0; i < original.getChildCount(); i++) { Node child = original.getChild(i); if (child instanceof Element) { syncContent((Element) child, (Element) copy.getChild(i)); } } doSyncContent(original, copy); }