use of com.google.gwt.dom.client.Element in project rstudio by rstudio.
the class FastSelectTable method getEventTargetCell.
protected Element getEventTargetCell(Event event) {
Element td = DOM.eventGetTarget(event);
for (; td != null; td = DOM.getParent(td)) {
// If it's a TD, it might be the one we're looking for.
if (td.getPropertyString("tagName").equalsIgnoreCase("td")) {
// Make sure it's directly a part of this table before returning
// it.
Element tr = td.getParentElement();
Element body = tr.getParentElement();
Element table = body.getParentElement();
if (table == getElement()) {
return td;
}
}
// If we run into this table's body, we're out of options.
if (td == getElement()) {
return null;
}
}
return null;
}
use of com.google.gwt.dom.client.Element in project rstudio by rstudio.
the class DomUtils method leftRelativeTo.
public static int leftRelativeTo(Element parent, Element child) {
int left = 0;
Element el = child;
while (el != null && el != parent) {
left += el.getOffsetLeft();
el = el.getOffsetParent();
}
return left;
}
use of com.google.gwt.dom.client.Element in project rstudio by rstudio.
the class NodeRelativePosition method toPositionHelper.
private static NodeRelativePosition toPositionHelper(Node here, int[] counter) {
switch(here.getNodeType()) {
case Node.TEXT_NODE:
Text text = (Text) here;
if (counter[0] <= text.getLength())
return new NodeRelativePosition(here, counter[0]);
counter[0] -= text.getLength();
return null;
case Node.ELEMENT_NODE:
Element el = (Element) here;
String tagName = el.getTagName().toLowerCase();
if (tagName.equals("br")) {
if (counter[0] <= 0)
return new NodeRelativePosition(here, 0);
counter[0] -= 1;
return null;
} else if (tagName.equals("script") || tagName.equals("style"))
return null;
break;
}
NodeList<Node> children = here.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
NodeRelativePosition result = toPositionHelper(children.getItem(i), counter);
if (result != null)
return result;
}
return null;
}
use of com.google.gwt.dom.client.Element in project rstudio by rstudio.
the class DomUtils method preventBackspaceCausingBrowserBack.
public static final boolean preventBackspaceCausingBrowserBack(NativeEvent event) {
if (Desktop.isDesktop())
return false;
if (event.getKeyCode() != KeyCodes.KEY_BACKSPACE)
return false;
EventTarget target = event.getEventTarget();
if (target == null)
return false;
Element elementTarget = Element.as(target);
if (!elementTarget.getNodeName().equals("BODY"))
return false;
event.preventDefault();
return true;
}
use of com.google.gwt.dom.client.Element in project rstudio by rstudio.
the class DomUtils method getInnerText.
private static void getInnerText(Node node, StringBuilder out, boolean pasteMode) {
if (node == null)
return;
for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
switch(child.getNodeType()) {
case Node.TEXT_NODE:
out.append(child.getNodeValue());
break;
case Node.ELEMENT_NODE:
Element childEl = (Element) child;
String tag = childEl.getTagName().toLowerCase();
// the _moz_dirty breaks are just spurious.
if (tag.equals("br") && (pasteMode || !childEl.hasAttribute("_moz_dirty")))
out.append("\n");
else if (tag.equals("script") || tag.equals("style"))
continue;
getInnerText(child, out, pasteMode);
break;
}
}
}
Aggregations