Skip to content

Commit

Permalink
#180 - FIX - Line boxes were causing overflow pages (and appearing on…
Browse files Browse the repository at this point in the history
… them) despite being in overflow hidden containers.

Also enable test demonstrating this scenario.
  • Loading branch information
danfickle committed Dec 27, 2018
1 parent ddadde8 commit a2e76a7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public void collectFloats(CssContext c, Layer layer) {
PageResult pgRes = getPageResult(i);
PageBox pageBox = getPageBox(i);

if (intersectsAggregateBounds(pgRes.getContentWindowOnDocument(pageBox, c), floater)) {
if (intersectsAggregateBounds(c, pgRes.getContentWindowOnDocument(pageBox, c), floater)) {
pgRes.addFloat(floater);
}

Expand Down Expand Up @@ -491,7 +491,7 @@ private void addLineBoxToShadowPage(CssContext c, Layer layer, LineBox container
PageBox pageBox = getPageBox(basePageNumber);
Rectangle shadowPageClip = pageResult.getShadowWindowOnDocument(pageBox, c, shadowPageNumber);

if (intersectsAggregateBounds(shadowPageClip, container)) {
if (intersectsAggregateBounds(c, shadowPageClip, container)) {
PageResult shadowPageResult = getOrCreateShadowPage(pageResult, shadowPageNumber);

shadowPageResult.addInline(container);
Expand All @@ -509,7 +509,7 @@ private void addLineBoxToAll(CssContext c, Layer layer, LineBox container, int b
PageBox pageBox = getPageBox(basePageNumber);
Rectangle pageClip = pageResult.getContentWindowOnDocument(pageBox, c);

if (intersectsAggregateBounds(pageClip, container)) {
if (intersectsAggregateBounds(c, pageClip, container)) {
pageResult.addInline(container);

// Recursively add all children of the line box to the inlines list.
Expand Down Expand Up @@ -629,7 +629,7 @@ private void addBoxToShadowPages(
Rectangle shadowPageClip = pageResult.getShadowWindowOnDocument(basePageBox, c, i);

boolean intersects = addToMethod.boundsBox() == AddToShadowPage.AGGREGATE_BOX ?
intersectsAggregateBounds(shadowPageClip, container) :
intersectsAggregateBounds(c, shadowPageClip, container) :
intersectsBorderBoxBounds(c, shadowPageClip, container);

if (intersects) {
Expand Down Expand Up @@ -689,7 +689,7 @@ private void addBlock(Box container, PageResult pageResult) {
}
}

private boolean intersectsAggregateBounds(Shape clip, Box box) {
private boolean intersectsAggregateBounds(CssContext c, Shape clip, Box box) {
if (clip == null) {
return true;
}
Expand All @@ -702,14 +702,7 @@ private boolean intersectsAggregateBounds(Shape clip, Box box) {

Rectangle bounds = info.getAggregateBounds();

AffineTransform ctm = box.getContainingLayer().getCurrentTransformMatrix();

if (ctm == null) {
return clip.intersects(bounds);
} else {
Shape boxShape = ctm.createTransformedShape(bounds);
return clip.intersects(boxShape.getBounds2D());
}
return boxIntersects(c, clip, box, bounds);
}

/**
Expand All @@ -719,20 +712,24 @@ private boolean intersectsAggregateBounds(Shape clip, Box box) {
private boolean intersectsBorderBoxBounds(CssContext c, Shape clip, Box box) {
Rectangle borderBoxBounds = box.getBorderBox(c);

return boxIntersects(c, clip, box, borderBoxBounds);
}

private boolean boxIntersects(CssContext c, Shape clip, Box box, Rectangle boxBounds) {
AffineTransform ctm = box.getContainingLayer().getCurrentTransformMatrix();
Area overflowClip = box.getAbsoluteClipBox(c);

if (ctm == null && overflowClip == null) {
return clip.intersects(borderBoxBounds);
return clip.intersects(boxBounds);
} else if (ctm != null && overflowClip == null) {
Shape boxShape = ctm.createTransformedShape(borderBoxBounds);
Shape boxShape = ctm.createTransformedShape(boxBounds);
Area boxArea = new Area(boxShape);
Area clipArea = new Area(clip);
boxArea.intersect(clipArea);

return !boxArea.isEmpty();
} else { // if (overflowClip != null)
Area boxArea = new Area(ctm == null ? borderBoxBounds : ctm.createTransformedShape(borderBoxBounds));
Area boxArea = new Area(ctm == null ? boxBounds : ctm.createTransformedShape(boxBounds));
boxArea.intersect(overflowClip);
boxArea.intersect(new Area(clip));

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ public void testHorizPageOverflowInlineBlock2() throws IOException {
* is absolute block and a case where content is a static block.
*/
@Test
@Ignore // Text is causing overflow pages and text appears on overflow pages in contravention of overflow hidden.
public void testHorizPageOverflowHidden() throws IOException {
assertTrue(run("horiz-page-overflow-hidden"));
}
Expand Down

0 comments on commit a2e76a7

Please sign in to comment.