use of org.loboevolution.html.dom.domimpl.HTMLElementImpl in project LoboEvolution by LoboEvolution.
the class HtmlBlockPanel method getUINode.
private UINode getUINode(Node currentNode) {
UINode uiNode = null;
while (currentNode != null) {
if (currentNode instanceof HTMLElementImpl) {
HTMLElementImpl element = (HTMLElementImpl) currentNode;
uiNode = element.getUINode();
if (uiNode != null) {
break;
}
}
currentNode = currentNode.getParentNode();
}
return uiNode;
}
use of org.loboevolution.html.dom.domimpl.HTMLElementImpl in project LoboEvolution by LoboEvolution.
the class ImgControl method getValueSize.
private int getValueSize(String attribute, String styleAttribute, int availSize) {
String size;
if (Strings.isNotBlank(attribute)) {
size = attribute.toLowerCase().trim();
} else {
size = Strings.isNotBlank(styleAttribute) ? styleAttribute : "";
}
final HTMLElementImpl element = this.controlElement;
HTMLDocumentImpl doc = (HTMLDocumentImpl) element.getDocumentNode();
return HtmlValues.getPixelSize(size, null, doc.getDefaultView(), -1, availSize);
}
use of org.loboevolution.html.dom.domimpl.HTMLElementImpl in project LoboEvolution by LoboEvolution.
the class BaseElementRenderable method applyStyle.
/**
* <p>applyStyle.</p>
*
* @param availWidth a int.
* @param availHeight a int.
*/
protected void applyStyle(int availWidth, int availHeight) {
final Object rootNode = this.modelNode;
HTMLElementImpl rootElement;
boolean isRootBlock;
if (rootNode instanceof HTMLDocumentImpl) {
isRootBlock = true;
final HTMLDocumentImpl doc = (HTMLDocumentImpl) rootNode;
rootElement = (HTMLElementImpl) doc.getBody();
} else {
isRootBlock = false;
rootElement = (HTMLElementImpl) rootNode;
}
if (rootElement == null) {
clearStyle(isRootBlock);
return;
}
final RenderState rs = rootElement.getRenderState();
if (rs == null) {
throw new IllegalStateException("Element without render state: " + rootElement + "; parent=" + rootElement.getParentNode());
}
backgroundApplyStyle(rs);
final AbstractCSSProperties props = rootElement.getCurrentStyle();
if (props == null) {
clearStyle(isRootBlock);
} else {
insetsApplyStyle(rs, availWidth, availHeight, isRootBlock);
zIndexApplyStyle(props);
this.overflowX = rs.getOverflowX();
this.overflowY = rs.getOverflowY();
}
}
use of org.loboevolution.html.dom.domimpl.HTMLElementImpl in project LoboEvolution by LoboEvolution.
the class BaseElementRenderable method getDeclaredWidthImpl.
private int getDeclaredWidthImpl(RenderState renderState, int availWidth) {
Object rootNode = this.modelNode;
if (rootNode instanceof HTMLElementImpl) {
HTMLElementImpl element = (HTMLElementImpl) rootNode;
HTMLDocumentImpl doc = (HTMLDocumentImpl) element.getDocumentNode();
CSS3Properties props = element.getCurrentStyle();
if (props == null) {
return -1;
}
String widthText = props.getWidth();
final String textContent = element.getTextContent();
if ("inherit".equalsIgnoreCase(widthText)) {
widthText = element.getParentStyle().getWidth();
} else if ("initial".equalsIgnoreCase(widthText)) {
widthText = "100%";
}
int width = -1;
if (widthText != null) {
width = HtmlValues.getPixelSize(widthText, renderState, doc.getDefaultView(), -1, availWidth);
}
if (width == -1 && Strings.isNotBlank(textContent) && renderState.getDisplay() == RenderState.DISPLAY_INLINE_BLOCK) {
HtmlInsets paddingInsets = renderState.getPaddingInsets();
HtmlInsets marginInsets = renderState.getMarginInsets();
int right = 0;
int left = 0;
if (paddingInsets != null) {
right = right + paddingInsets.right;
left = left + paddingInsets.left;
}
if (marginInsets != null) {
right = right + marginInsets.right;
left = left + marginInsets.left;
}
final int multi = (right == 0 && left == 0) ? 12 : 4;
width = (textContent.length() + right + left) * multi;
}
if (props.getMaxWidth() != null) {
int maxWidth = HtmlValues.getPixelSize(props.getMaxWidth(), renderState, doc.getDefaultView(), -1, availWidth);
if (width == -1 || width > maxWidth) {
width = maxWidth;
}
}
if (props.getMinWidth() != null) {
int minWidth = HtmlValues.getPixelSize(props.getMinWidth(), element.getRenderState(), doc.getDefaultView(), 0, availWidth);
if (width == 0 || width < minWidth) {
width = minWidth;
}
}
return width;
} else {
return -1;
}
}
use of org.loboevolution.html.dom.domimpl.HTMLElementImpl in project LoboEvolution by LoboEvolution.
the class BaseElementRenderable method hasDeclaredWidth.
/**
* <p>hasDeclaredWidth.</p>
*
* @return a boolean.
*/
public final boolean hasDeclaredWidth() {
final Integer dw = this.declaredWidth;
if (INVALID_SIZE.equals(dw)) {
final Object rootNode = this.modelNode;
if (rootNode instanceof HTMLElementImpl) {
final HTMLElementImpl element = (HTMLElementImpl) rootNode;
final CSS3Properties props = element.getCurrentStyle();
if (props == null) {
return false;
}
return !Strings.isBlank(props.getWidth());
}
return false;
}
return true;
}
Aggregations