use of org.loboevolution.html.style.AbstractCSSProperties 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.style.AbstractCSSProperties in project LoboEvolution by LoboEvolution.
the class ElementImpl method getClientLeft.
/**
* {@inheritDoc}
*/
@Override
public int getClientLeft() {
final HTMLDocumentImpl doc = (HTMLDocumentImpl) this.document;
AbstractCSSProperties currentStyle = ((HTMLElementImpl) this).getCurrentStyle();
return HtmlValues.getPixelSize(currentStyle.getBorderLeftWidth(), null, doc.getDefaultView(), 0);
}
use of org.loboevolution.html.style.AbstractCSSProperties 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.style.AbstractCSSProperties 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.style.AbstractCSSProperties in project LoboEvolution by LoboEvolution.
the class ElementImpl method calculateWidth.
protected int calculateWidth(boolean border, boolean padding) {
final HTMLDocumentImpl doc = (HTMLDocumentImpl) this.document;
final HtmlRendererContext htmlRendererContext = doc.getHtmlRendererContext();
final HtmlPanel htmlPanel = htmlRendererContext.getHtmlPanel();
final Dimension preferredSize = htmlPanel.getPreferredSize();
final AbstractCSSProperties currentStyle = ((HTMLElementImpl) this).getCurrentStyle();
String width = currentStyle.getWidth();
String paddingRight = currentStyle.getPaddingRight();
String paddingLeft = currentStyle.getPaddingLeft();
String borderLeftWidth = currentStyle.getBorderLeftWidth();
String borderRightWidth = currentStyle.getBorderRightWidth();
String boxSizing = currentStyle.getBoxSizing();
int sizeWidth = preferredSize.width;
if (this instanceof HTMLBodyElementImpl) {
width = String.valueOf(doc.getDefaultView().getInnerWidth());
}
final Node nodeObj = getParentNode();
if (nodeObj instanceof HTMLElementImpl) {
HTMLElementImpl elem = (HTMLElementImpl) nodeObj;
if (elem.getClientHeight() != -1) {
sizeWidth = elem.getClientWidth();
}
}
if (Strings.isBlank(width) || "auto".equalsIgnoreCase(width)) {
width = "100%";
}
int widthSize = HtmlValues.getPixelSize(width, null, doc.getDefaultView(), -1, sizeWidth);
if ("border-box".equals(boxSizing)) {
padding = false;
border = false;
}
if (padding) {
widthSize += HtmlValues.getPixelSize(paddingRight, null, doc.getDefaultView(), 0);
widthSize += HtmlValues.getPixelSize(paddingLeft, null, doc.getDefaultView(), 0);
}
if (border) {
widthSize += HtmlValues.getPixelSize(borderRightWidth, null, doc.getDefaultView(), 0);
widthSize += HtmlValues.getPixelSize(borderLeftWidth, null, doc.getDefaultView(), 0);
}
return widthSize;
}
Aggregations