Skip to content

Commit

Permalink
#180 FIX for fixed position elements sometimes not being rendered.
Browse files Browse the repository at this point in the history
Some boxes can be layed out many times (to satisfy page constraints for example). If this happens we just mark our old layer for deletion and create a new layer. Not sure this is right, but doesn't break any correct tests.

Yes, this is a particularly hackish solution. This fix also brought up the correct response for positioning-absolute test, so I altered the html to match the expected output. (I hadn't noticed the missing box when I committed the expected test result previously).
  • Loading branch information
danfickle committed Jan 1, 2019
1 parent 42d6876 commit 7d55da4
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public class Layer {
private int _selectionEndX;
private int _selectionEndY;

private boolean _forDeletion;

/**
* @see {@link #getCurrentTransformMatrix()}
*/
Expand Down Expand Up @@ -149,6 +151,14 @@ public boolean hasLocalTransform() {
return _hasLocalTransform;
}

public void setForDeletion(boolean forDeletion) {
this._forDeletion = forDeletion;
}

public boolean isForDeletion() {
return this._forDeletion;
}

public Layer getParent() {
return _parent;
}
Expand Down Expand Up @@ -259,7 +269,9 @@ public List<Layer> collectLayers(int which) {

for (Layer child : children) {
if (! child.isStackingContext()) {
if (which == AUTO && child.isZIndexAuto()) {
if (child.isForDeletion()) {
// Do nothing...
} else if (which == AUTO && child.isZIndexAuto()) {
result.add(child);
} else if (which == NEGATIVE && child.getZIndex() < 0) {
result.add(child);
Expand All @@ -280,7 +292,9 @@ private List<Layer> getStackingContextLayers(int which) {
List<Layer> children = getChildren();

for (Layer target : children) {
if (target.isStackingContext()) {
if (target.isForDeletion()) {
// Do nothing...
} else if (target.isStackingContext()) {
if (!target.isZIndexAuto()) {
int zIndex = target.getZIndex();
if (which == NEGATIVE && zIndex < 0) {
Expand Down Expand Up @@ -894,6 +908,7 @@ public void detach() {
if (getParent() != null) {
getParent().remove(this);
}
setForDeletion(true);
}

public boolean isInline() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -845,8 +845,12 @@ public void layout(LayoutContext c, int contentStart) {
pushedLayer = true;
c.pushLayer(this);
} else if (style.requiresLayer()) {
// FIXME: HACK. Some boxes can be layed out many times (to satisfy page constraints for example).
// If this happens we just mark our old layer for deletion and create a new layer.
// Not sure this is right, but doesn't break any correct tests.
this.getLayer().setForDeletion(true);
pushedLayer = true;
c.pushLayer(this.getLayer());
c.pushLayer(this);
}

if (style.isFixedBackground()) {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
<div class="header" style="background-color: blue;"><div class="inner"></div><div class="inner float2">abcd</div></div>
<div class="footer" style="background-color: red;"><div class="inner"></div><div class="inner float2">dcba</div></div>

<div>PAGE 1</div>
<div style="margin-top: 40px;">PAGE 1</div>
<div style="width: 150%; height: 20px; background-color: pink; page-break-after: always;"></div>
<div>PAGE 2</div>
<div style="margin-top: 40px;">PAGE 2</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
<div id="t-2">DEF</div>
<div id="t-3">GHI</div>
<div id="t-4">JKL</div>
<div id="t-5">MNO</div>
<pb/>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,6 @@ public void testFixedOnOverflowPages() throws IOException {
* Tests that a nested float in a fixed element renders correctly.
*/
@Test
@Ignore // SERIOUS FAILURE - The footer element is not rendering.
// Appears to be an ordering issue of the layers as if header and footer swap element order
// everything works!
public void testFixedNestedFloat() throws IOException {
assertTrue(run("fixed-nested-float"));
}
Expand Down

0 comments on commit 7d55da4

Please sign in to comment.