use of org.loboevolution.html.dom.HTMLBodyElement 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.dom.HTMLBodyElement in project LoboEvolution by LoboEvolution.
the class ElementImpl method getClientRects.
/**
* {@inheritDoc}
*/
@Override
public DOMRectList getClientRects() {
DOMRectListImpl list = new DOMRectListImpl();
AbstractCSSProperties style = ((HTMLElementImpl) this).getCurrentStyle();
String display = Strings.isNotBlank(style.getDisplay()) ? style.getDisplay() : getAttribute("display");
if (!"none".equals(display)) {
for (Node n = getParentNode(); n != null; n = n.getPreviousSibling()) {
if (!(n instanceof HTMLBodyElement) && !(n instanceof TextImpl) && !(n instanceof HTMLDocumentImpl)) {
HTMLElementImpl p = (HTMLElementImpl) n;
AbstractCSSProperties st = p.getStyle();
display = st.getDisplay();
}
}
}
if (!"none".equals(display)) {
list.add(getBoundingClientRect());
}
return list;
}
use of org.loboevolution.html.dom.HTMLBodyElement in project LoboEvolution by LoboEvolution.
the class LinkRenderState method linkColor.
private Color linkColor() {
if (rcontext != null) {
boolean visited = rcontext.isVisitedLink(element);
String vlink = null;
String link = null;
HTMLDocument doc = (HTMLDocument) element.getDocumentNode();
if (doc != null) {
HTMLBodyElement body = (HTMLBodyElement) doc.getBody();
if (body != null) {
vlink = body.getVLink();
link = body.getLink();
}
}
vlink = (vlink == null) ? COLOR_VISITED : vlink;
link = (link == null) ? DEFAULT_COLOR : link;
String colorText = visited ? vlink : link;
AbstractCSSProperties props = this.getCssProperties();
String color = props == null ? null : props.getColor();
return ColorFactory.getInstance().getColor(color == null ? colorText : color);
}
return Color.BLUE;
}
Aggregations