use of org.loboevolution.html.dom.nodeimpl.NodeListImpl in project LoboEvolution by LoboEvolution.
the class ElementImpl method isVScrollable.
private boolean isVScrollable() {
String overflow;
AbstractCSSProperties currentStyle = ((HTMLElementImpl) this).getCurrentStyle();
overflow = currentStyle.getOverflow();
int heightChild = 0;
for (final Node child : (NodeListImpl) this.getChildNodes()) {
if (child instanceof HTMLElementImpl)
heightChild += ((HTMLElementImpl) child).getClientHeight();
}
return ("scroll".equals(overflow) || "auto".equals(overflow)) && (heightChild > this.getClientHeight());
}
use of org.loboevolution.html.dom.nodeimpl.NodeListImpl in project LoboEvolution by LoboEvolution.
the class ElementImpl method querySelector.
/**
* {@inheritDoc}
*/
@Override
public Element querySelector(String selectors) {
SelectorList selectorList = CSSUtilities.getSelectorList(selectors);
List<Element> elem = new ArrayList<>();
if (selectorList != null) {
NodeListImpl childNodes = (NodeListImpl) getDescendents(new ElementFilter(null), true);
childNodes.forEach(child -> {
for (Selector selector : selectorList) {
if (child instanceof Element && StyleSheetAggregator.selects(selector, child, null)) {
elem.add((Element) child);
}
}
});
}
return elem.size() > 0 ? elem.get(0) : null;
}
use of org.loboevolution.html.dom.nodeimpl.NodeListImpl in project LoboEvolution by LoboEvolution.
the class ElementImpl method querySelectorAll.
/**
* {@inheritDoc}
*/
@Override
public NodeList querySelectorAll(String selector) {
final ArrayList<Node> al = new ArrayList<>();
if (selector == null) {
return new NodeListImpl(al);
}
if (selector.isEmpty()) {
throw new DOMException(DOMException.NOT_FOUND_ERR, "The provided selector is empty.");
}
if (selector.trim().isEmpty()) {
throw new DOMException(DOMException.NOT_FOUND_ERR, "is not a valid selector.");
}
SelectorList selectorList = CSSUtilities.getSelectorList(selector);
if (selectorList != null) {
NodeListImpl childNodes = (NodeListImpl) getDescendents(new ElementFilter(null), true);
childNodes.forEach(child -> {
for (Selector select : selectorList) {
if (child instanceof Element && StyleSheetAggregator.selects(select, child, null)) {
al.add(child);
}
}
});
}
return new NodeListImpl(al);
}
use of org.loboevolution.html.dom.nodeimpl.NodeListImpl in project LoboEvolution by LoboEvolution.
the class HTMLTableRowElementImpl method getRowIndex.
/**
* {@inheritDoc}
*/
@Override
public int getRowIndex() {
if (index >= 0) {
return index;
} else {
AtomicInteger index = new AtomicInteger(-1);
if (getParentNode() != null) {
NodeListImpl childNodes = (NodeListImpl) getParentNode().getChildNodes();
childNodes.forEach(node -> {
if (node instanceof HTMLTableRowElement) {
index.incrementAndGet();
}
});
}
return index.get();
}
}
use of org.loboevolution.html.dom.nodeimpl.NodeListImpl in project LoboEvolution by LoboEvolution.
the class HTMLTextAreaElementImpl method getText.
private String getText() {
StringBuilder text = new StringBuilder();
if (hasChildNodes()) {
NodeListImpl children = (NodeListImpl) getChildNodes();
children.forEach(child -> {
if (child.getNodeType() == NodeType.TEXT_NODE) {
String nodeValue = child.getNodeValue();
String childText;
nodeValue = nodeValue.replace('\n', ' ');
nodeValue = nodeValue.replace('\r', ' ');
nodeValue = nodeValue.replace('\t', ' ');
childText = nodeValue;
text.append(childText).append(" ");
}
});
}
if (text.length() > 0) {
return text.substring(0, text.length() - 1);
} else {
return text.toString();
}
}
Aggregations