Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/main/java/org/fit/cssbox/layout/ElementBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -650,15 +650,15 @@ public boolean hasPseudoElement(Selector.PseudoElementType pseudo)
*/
public float getContentWidth()
{
return content.width;
return content==null?0:content.width;
}

/**
* @return the height of the content without any margins and borders
*/
public float getContentHeight()
{
return content.height;
return content==null?0:content.height;
}

/**
Expand Down Expand Up @@ -821,18 +821,22 @@ public float getContentY()

public float getAbsoluteContentX()
{
return absbounds.x + emargin.left + border.left + padding.left;
return (absbounds==null?0:absbounds.x) + (emargin==null?0:emargin.left)
+ (border==null?0:border.left) + (padding==null?0:padding.left);
}

public float getAbsoluteContentY()
{
return absbounds.y + emargin.top + border.top + padding.top;
return (absbounds==null?0:absbounds.y) + (emargin==null?0:emargin.top)
+ (border==null?0:border.top) + (padding==null?0:padding.top);
}

public float totalWidth()
{
return emargin.left + border.left + padding.left + content.width +
padding.right + border.right + emargin.right;
return (emargin==null?0:emargin.left) + (border==null?0:border.left)
+ (padding==null?0:padding.left) + getContentWidth()
+ (padding==null?0:padding.right) + (border==null?0:border.right)
+ (emargin==null?0:emargin.right);
}

//totalHeight() differs for inline and block boxes
Expand Down Expand Up @@ -1162,7 +1166,7 @@ protected int countInlineExpansionPoints(int start, int end, boolean atLineStart

/**
* Extends the total width of inline childs boxes by the given offset considering the 'expandability' of every child.
* @param ofs the additional width in pixels (positive or negative)
* @param dif the additional width in pixels (positive or negative)
* @param start the first child to be processed
* @param end the last child (the first one not to be processed)
* @param atLineStart is the start box at the start of a line?
Expand Down