use of org.loboevolution.http.HtmlRendererContext 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;
}
use of org.loboevolution.http.HtmlRendererContext in project LoboEvolution by LoboEvolution.
the class ElementImpl method setScrollTop.
/**
* {@inheritDoc}
*/
@Override
public void setScrollTop(double scrollTop) {
this.scrollTop = scrollTop;
final HTMLDocumentImpl doc = (HTMLDocumentImpl) this.document;
HtmlRendererContext htmlRendererContext = doc.getHtmlRendererContext();
if (scrollTop < 0 || !isVScrollable()) {
scrollTop = 0;
}
htmlRendererContext.setScrolly(scrollTop);
RBlock bodyBlock = (RBlock) this.getUINode();
if (bodyBlock != null && bodyBlock.getScroll() != null)
bodyBlock.getScroll().scrollBy(JScrollBar.VERTICAL, scrollTop);
}
use of org.loboevolution.http.HtmlRendererContext in project LoboEvolution by LoboEvolution.
the class LocationImpl method setHref.
/**
* {@inheritDoc}
*
* <p>
* setHref.
* </p>
*/
public void setHref(String uri) {
final HtmlRendererContext rcontext = this.window.getHtmlRendererContext();
if (rcontext != null) {
try {
URL url;
final Document document = this.window.getDocumentNode();
if (document instanceof HTMLDocumentImpl) {
final HTMLDocumentImpl docImpl = (HTMLDocumentImpl) document;
url = docImpl.getFullURL(uri);
} else {
url = new URL(uri);
}
rcontext.navigate(url, this.target);
} catch (final java.net.MalformedURLException mfu) {
logger.log(Level.WARNING, "setHref(): Malformed location: [" + uri + "].", mfu);
}
}
}
use of org.loboevolution.http.HtmlRendererContext in project LoboEvolution by LoboEvolution.
the class LocationImpl method reload.
/**
* <p>
* reload.
* </p>
*/
public void reload() {
// TODO: This is not really reload.
final Document document = this.window.getDocumentNode();
if (document instanceof HTMLDocumentImpl) {
final HTMLDocumentImpl docImpl = (HTMLDocumentImpl) document;
final HtmlRendererContext rcontext = docImpl.getHtmlRendererContext();
if (rcontext != null) {
rcontext.reload();
} else {
docImpl.warn("reload(): No renderer context in Location's document.");
}
}
}
use of org.loboevolution.http.HtmlRendererContext in project LoboEvolution by LoboEvolution.
the class WindowImpl method setOpener.
/**
* {@inheritDoc}
*/
@Override
public void setOpener(final Window opener) {
final HtmlRendererContext rcontext = this.rcontext;
if (rcontext != null) {
if (opener == null) {
rcontext.setOpener(null);
} else {
final WindowImpl win = (WindowImpl) opener;
rcontext.setOpener(win.rcontext);
}
}
}
Aggregations