use of org.loboevolution.html.node.js.Window in project LoboEvolution by LoboEvolution.
the class ElementImpl method getBoundingClientRect.
/**
* {@inheritDoc}
*/
@Override
public DOMRect getBoundingClientRect() {
AbstractCSSProperties currentStyle = ((HTMLElementImpl) this).getCurrentStyle();
final HTMLDocumentImpl doc = (HTMLDocumentImpl) this.document;
final Window win = doc.getDefaultView();
final RenderState rs = doc.getRenderState();
int width = calculateWidth(true, true);
int height = calculateHeight(true, true);
int top = HtmlValues.getPixelSize(currentStyle.getTop(), rs, win, 0);
int left = HtmlValues.getPixelSize(currentStyle.getLeft(), rs, win, 0);
for (Node n = getParentNode(); n != null; n = n.getParentNode()) {
if (!(n instanceof HTMLBodyElement) && !(n instanceof TextImpl) && !(n instanceof HTMLDocumentImpl)) {
HTMLElementImpl p = (HTMLElementImpl) n;
AbstractCSSProperties pCurrentStyle = p.getCurrentStyle();
String topTxt = pCurrentStyle.getTop();
String leftTxt = pCurrentStyle.getLeft();
int scrollTop = (int) p.getScrollTop();
int scrollLeft = (int) p.getScrollLeft();
if (Strings.isNotBlank(topTxt)) {
top += HtmlValues.getPixelSize(topTxt, rs, win, 0);
}
if (Strings.isNotBlank(leftTxt)) {
left += HtmlValues.getPixelSize(leftTxt, rs, win, 0);
}
top -= scrollTop;
left -= scrollLeft;
}
}
return new DOMRectImpl(width, height, top, 0, 0, left);
}
use of org.loboevolution.html.node.js.Window in project LoboEvolution by LoboEvolution.
the class LoboUnitTest method checkSelectorsTest.
/**
* <p>checkSelectorsTest.</p>
*
* @param html a {@link java.lang.String} object.
* @param result1 a {@link java.lang.String} object.
* @param result2 a {@link java.lang.String} object.
*/
public void checkSelectorsTest(final String html, final String result1, final String result2) {
HTMLDocumentImpl doc = loadHtml(html);
Window window = doc.getDefaultView();
HTMLElement div = (HTMLElement) doc.getElementById("myId");
HTMLElement div2 = (HTMLElement) doc.getElementById("myId2");
ComputedCSSStyleDeclaration computedStyle = (ComputedCSSStyleDeclaration) window.getComputedStyle(div);
ComputedCSSStyleDeclaration computedStyle2 = (ComputedCSSStyleDeclaration) window.getComputedStyle(div2);
assertEquals(result1, computedStyle.getColor());
assertEquals(result2, computedStyle2.getColor());
}
use of org.loboevolution.html.node.js.Window in project LoboEvolution by LoboEvolution.
the class LoboUnitTest method checkHtmlAlert.
/**
* <p>checkHtmlAlert.</p>
*
* @param html a {@link java.lang.String} object.
* @param messages an array of {@link java.lang.String} objects.
*/
public void checkHtmlAlert(final String html, final String[] messages) {
Window window = null;
List<String> alerts = null;
try {
HTMLDocumentImpl doc = loadHtml(html);
window = doc.getDefaultView();
alerts = Arrays.asList(messages);
assertEquals(alerts, window.getMsg());
} catch (AssertionError e) {
throw new AssertionError("Result expected: " + alerts + " Result: " + window.getMsg());
} catch (Exception ex) {
logger.severe(ex.getMessage());
}
}
use of org.loboevolution.html.node.js.Window in project LoboEvolution by LoboEvolution.
the class DelayedPair method helperGetPixelSize.
private Integer helperGetPixelSize(final String spec, final RenderState rs, final int errorValue, final int avail) {
if (spec != null) {
Window window = null;
ModelNode node = getModelNode();
if (node instanceof HTMLDocument) {
HTMLDocumentImpl doc = (HTMLDocumentImpl) node;
window = doc.getDefaultView();
}
return "auto".equals(spec) ? null : HtmlValues.getPixelSize(spec, rs, window, errorValue, avail);
} else {
return null;
}
}
Aggregations