use of org.loboevolution.html.dom.nodeimpl.ModelNode in project LoboEvolution by LoboEvolution.
the class RBlockViewport method isFloatLimitImpl.
private Boolean isFloatLimitImpl() {
final Object parent = getOriginalOrCurrentParent();
if (!(parent instanceof RBlock)) {
return Boolean.TRUE;
}
final RBlock blockParent = (RBlock) parent;
final Object grandParent = blockParent.getOriginalOrCurrentParent();
if (!(grandParent instanceof RBlockViewport)) {
// be a list item, for example.
return Boolean.TRUE;
}
final ModelNode node = this.modelNode;
if (!(node instanceof HTMLElementImpl)) {
// Can only be a document here.
return Boolean.TRUE;
}
final HTMLElementImpl element = (HTMLElementImpl) node;
final int position = getPosition(element);
if (position == RenderState.POSITION_ABSOLUTE || position == RenderState.POSITION_FIXED) {
return Boolean.TRUE;
}
element.getCurrentStyle();
final RenderState rs = element.getRenderState();
final int floatValue = rs == null ? RenderState.FLOAT_NONE : rs.getFloat();
if (floatValue != RenderState.FLOAT_NONE) {
return Boolean.TRUE;
}
final int overflowX = rs == null ? RenderState.OVERFLOW_NONE : rs.getOverflowX();
final int overflowY = rs == null ? RenderState.OVERFLOW_NONE : rs.getOverflowY();
if ((overflowX == RenderState.OVERFLOW_AUTO) || (overflowX == RenderState.OVERFLOW_SCROLL) || (overflowY == RenderState.OVERFLOW_AUTO) || (overflowY == RenderState.OVERFLOW_SCROLL)) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}
use of org.loboevolution.html.dom.nodeimpl.ModelNode in project LoboEvolution by LoboEvolution.
the class RBlockViewport method addAsSeqBlock.
private void addAsSeqBlock(BoundableRenderable block, boolean obeysFloats, boolean informLineDone, boolean addLine, boolean centerBlock) {
final Insets insets = this.paddingInsets;
final int insetsl = insets.left;
List<Renderable> sr = this.seqRenderables;
if (sr == null) {
sr = new ArrayList<>();
this.seqRenderables = sr;
}
final RLine prevLine = this.currentLine;
boolean initialAllowOverflow;
if (prevLine != null) {
initialAllowOverflow = prevLine.isAllowOverflow();
if (informLineDone) {
lineDone(prevLine);
}
if (prevLine.x + prevLine.width > this.maxX) {
this.maxX = prevLine.x + prevLine.width;
}
// Check height only with floats.
} else {
initialAllowOverflow = false;
}
final int prevLineHeight = prevLine == null ? 0 : prevLine.height;
int newLineY = prevLine == null ? insets.top : prevLine.y + prevLineHeight;
int blockX;
int blockY = prevLineHeight == 0 ? getNewBlockY(block, newLineY) : newLineY;
final int blockWidth = block.getWidth();
if (obeysFloats) {
// TODO: execution of fetchLeftOffset done twice with positionRElement.
final FloatingBounds floatBounds = this.floatBounds;
int actualAvailWidth;
if (floatBounds != null) {
final int blockOffset = fetchLeftOffset(newLineY);
blockX = blockOffset;
final int rightOffset = fetchRightOffset(newLineY);
actualAvailWidth = this.desiredWidth - rightOffset - blockOffset;
if (blockWidth > actualAvailWidth) {
blockY = floatBounds.getClearY(newLineY);
}
} else {
actualAvailWidth = this.availContentWidth;
blockX = insetsl;
}
if (centerBlock) {
final int roomX = actualAvailWidth - blockWidth;
if (roomX > 0) {
blockX += roomX / 2;
}
}
} else {
// Block does not obey alignment margins
blockX = insetsl;
}
block.setOrigin(blockX, blockY);
sr.add(block);
block.setParent(this);
if (blockX + blockWidth > this.maxX) {
this.maxX = blockX + blockWidth;
}
this.lastSeqBlock = block;
this.currentCollapsibleMargin = block instanceof RElement ? ((RElement) block).getMarginBottom() : 0;
if (addLine) {
newLineY = blockY + block.getHeight();
checkY(newLineY);
final int leftOffset = fetchLeftOffset(newLineY);
final int newMaxWidth = this.desiredWidth - fetchRightOffset(newLineY) - leftOffset;
final ModelNode lineNode = block.getModelNode().getParentModelNode();
final RLine newLine = new RLine(lineNode, this.container, leftOffset, newLineY, newMaxWidth, 0, initialAllowOverflow);
newLine.setParent(this);
sr.add(newLine);
this.currentLine = newLine;
}
}
use of org.loboevolution.html.dom.nodeimpl.ModelNode in project LoboEvolution by LoboEvolution.
the class BaseBoundableRenderable method resetCursorOnMouseOut.
private static void resetCursorOnMouseOut(final ModelNode nodeStart, final ModelNode limit) {
Optional<Cursor> foundCursorOpt = Optional.empty();
ModelNode node = limit;
while (node != null) {
if (node instanceof NodeImpl) {
final NodeImpl uiElement = (NodeImpl) node;
final RenderState rs = uiElement.getRenderState();
final Optional<Cursor> cursorOpt = rs.getCursor();
foundCursorOpt = cursorOpt;
if (cursorOpt.isPresent()) {
break;
}
}
node = node.getParentModelNode();
}
if (nodeStart instanceof NodeImpl) {
final NodeImpl uiElement = (NodeImpl) nodeStart;
final HtmlRendererContext rcontext = uiElement.getHtmlRendererContext();
rcontext.setCursor(foundCursorOpt);
}
}
use of org.loboevolution.html.dom.nodeimpl.ModelNode in project LoboEvolution by LoboEvolution.
the class BaseRCollection method onMouseOut.
/**
* {@inheritDoc}
*/
@Override
public void onMouseOut(final MouseEvent event, int x, int y, ModelNode limit) {
super.onMouseOut(event, x, y, limit);
final BoundableRenderable oldRenderable = this.renderableWithMouse;
if (oldRenderable != null) {
this.renderableWithMouse = null;
ModelNode newLimit;
if (isContainedByNode()) {
newLimit = this.modelNode;
} else {
newLimit = limit;
}
oldRenderable.onMouseOut(event, x - oldRenderable.getX(), y - oldRenderable.getY(), newLimit);
}
}
use of org.loboevolution.html.dom.nodeimpl.ModelNode in project LoboEvolution by LoboEvolution.
the class HtmlController method setMouseOnMouseOver.
private static void setMouseOnMouseOver(final BaseBoundableRenderable renderable, final ModelNode nodeStart, final ModelNode limit) {
ModelNode node = nodeStart;
while (node != null) {
if (node == limit) {
break;
}
if (node instanceof NodeImpl) {
final NodeImpl uiElement = (NodeImpl) node;
final HtmlRendererContext rcontext = uiElement.getHtmlRendererContext();
final RenderState rs = uiElement.getRenderState();
final Optional<Cursor> cursorOpt = rs.getCursor();
if (cursorOpt.isPresent()) {
rcontext.setCursor(cursorOpt);
break;
} else {
if (node.getParentModelNode() == limit) {
if (renderable instanceof RWord || renderable instanceof RBlank) {
rcontext.setCursor(Optional.of(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)));
}
}
}
}
node = node.getParentModelNode();
}
}
Aggregations