Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make sure floated relative renderables are laid out #44

Merged
merged 1 commit into from
Dec 28, 2014
Merged
Show file tree
Hide file tree
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
make sure floated relative renderables are laid out
fixes #43
  • Loading branch information
hrj committed Dec 28, 2014
commit e09045dd90aed23f9118efab57988a2f510e37d4
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,24 @@ public final void layout(final int availWidth, final int availHeight, final bool
}
}

/**
* Lays out children, and deals with "valid" state. Override doLayout method
* instead of this one.
*/
public final void layout(final int availWidth, final int availHeight, final boolean expandWidth, final boolean sizeOnly) {
// Must call doLayout regardless of validity state.
try {
this.doLayout(availWidth, availHeight, expandWidth, sizeOnly);
} finally {
this.layoutUpTreeCanBeInvalidated = true;
this.layoutDeepCanBeInvalidated = true;
}
}

protected abstract void doLayout(int availWidth, int availHeight, boolean sizeOnly);

protected abstract void doLayout(int availWidth, int availHeight, boolean expand, boolean sizeOnly);

protected final void sendGUIComponentsToParent() {
// Ensures that parent has all the components
// below this renderer node. (Parent expected to have removed them).
Expand Down
4 changes: 4 additions & 0 deletions src/HTML_Renderer/org/lobobrowser/html/renderer/RBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ public final void doLayout(final int availWidth, final int availHeight, final bo
this.doLayout(availWidth, availHeight, true, false, null, this.defaultOverflowX, this.defaultOverflowY, sizeOnly);
}

public void doLayout(int availWidth, int availHeight, boolean expand, boolean sizeOnly) {
this.doLayout(availWidth, availHeight, expand, expand, null, this.defaultOverflowX, this.defaultOverflowY, sizeOnly);
}

public void doLayout(final int availWidth, final int availHeight, final boolean expandWidth, final boolean expandHeight,
final FloatingBoundsSource floatBoundsSource,
final int defaultOverflowX, final int defaultOverflowY, final boolean sizeOnly) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,12 @@ private final void layoutFloat(final BoundableRenderable renderable, final boole
} else if (renderable instanceof RElement) {
final RElement e = (RElement) renderable;
e.layout(availWidth, availHeight, this.sizeOnly);
} else if (renderable instanceof RRelative) {
RRelative rRelative = (RRelative) renderable;
rRelative.layout(availWidth, availHeight, this.sizeOnly);
} else {
// TODO Check other types of renderabls
System.err.println("TODO: Unhandled renderable type");
}
}
final RFloatInfo floatInfo = new RFloatInfo(renderable.getModelNode(), renderable, leftFloat);
Expand Down
2 changes: 2 additions & 0 deletions src/HTML_Renderer/org/lobobrowser/html/renderer/RElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public interface RElement extends RCollection, UINode {
*/
public void layout(int availWidth, int availHeight, boolean sizeOnly);

public void layout(int availWidth, int availHeight, boolean expandWidth, boolean sizeOnly);

/**
* Vertical alignment for elements rendered in a line. Returns one of the
* constants defined in this class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,9 @@ public Component addComponent(final Component component) {
this.container.addComponent(component);
return super.addComponent(component);
}

@Override
protected void doLayout(int availWidth, int availHeight, boolean expand, boolean sizeOnly) {
this.child.doLayout(availWidth, availHeight, expand, expand, null, 0, 0, sizeOnly, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,10 @@ public boolean onMouseReleased(final MouseEvent event, final int x, final int y)
public void paint(final Graphics g) {
this.child.paintTranslated(g);
}


public void layout(int availWidth, int availHeight, boolean sizeOnly) {
child.layout(availWidth, availHeight, false, sizeOnly);
assignDimension();
}
}
6 changes: 6 additions & 0 deletions src/HTML_Renderer/org/lobobrowser/html/renderer/RTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -419,4 +419,10 @@ public LayoutValue(final int width, final int height) {
}
}

@Override
protected void doLayout(int availWidth, int availHeight, boolean expand, boolean sizeOnly) {
// TODO: Is it okay to ignore `expand`?
doLayout(availWidth, availHeight, sizeOnly);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,10 @@ public LayoutValue(final int width, final int height) {
this.height = height;
}
}

@Override
protected void doLayout(int availWidth, int availHeight, boolean expand, boolean sizeOnly) {
// TODO: Is it okay to ignore `expand`?
doLayout(availWidth, availHeight, sizeOnly);
}
}