Skip to content

Commit

Permalink
[refactor] convert Box constants NOTHING/FLUX/CHILDREN_FLUX/DONE to e…
Browse files Browse the repository at this point in the history
…num `State`
  • Loading branch information
asolntsev committed Oct 11, 2024
1 parent 85bb516 commit 31c9726
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private void calcExtraSpaceBottom(LayoutContext c) {

@Override
protected void layoutChildren(LayoutContext c, int contentStart) {
setState(Box.CHILDREN_FLUX);
setState(State.CHILDREN_FLUX);
ensureChildren(c);

TableSectionBox section = getSection();
Expand All @@ -212,7 +212,7 @@ protected void layoutChildren(LayoutContext c, int contentStart) {
}
}

setState(Box.DONE);
setState(State.DONE);
}

private void alignBaselineAlignedCells(LayoutContext c) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ public void layout(LayoutContext c, int contentStart) {
if (! isReplaced())
layoutChildren(c, contentStart);
else {
setState(Box.DONE);
setState(State.DONE);
}
c.translate(-getTx(), -getTy());

Expand Down Expand Up @@ -966,7 +966,7 @@ public void ensureChildren(LayoutContext c) {
}

protected void layoutChildren(LayoutContext c, int contentStart) {
setState(Box.CHILDREN_FLUX);
setState(State.CHILDREN_FLUX);
ensureChildren(c);

if (getFirstLetterStyle() != null) {
Expand All @@ -992,7 +992,7 @@ protected void layoutChildren(LayoutContext c, int contentStart) {
c.getFirstLinesTracker().removeLast();
}

setState(Box.DONE);
setState(State.DONE);
}

protected void layoutInlineChildren(
Expand Down
20 changes: 11 additions & 9 deletions flying-saucer-core/src/main/java/org/xhtmlrenderer/render/Box.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import java.util.logging.Level;

import static java.util.Objects.requireNonNullElseGet;
import static org.xhtmlrenderer.render.Box.State.NOTHING;

public abstract class Box implements Styleable {
@Nullable
Expand Down Expand Up @@ -239,32 +240,33 @@ public List<Box> getChildren() {
return _boxes;
}

public static final int NOTHING = 0;
public static final int FLUX = 1;
public static final int CHILDREN_FLUX = 2;
public static final int DONE = 3;
public enum State {
NOTHING,
FLUX,
CHILDREN_FLUX,
DONE
}

private volatile int _state = NOTHING;
private volatile State _state = NOTHING;

public static final int DUMP_RENDER = 2;

public static final int DUMP_LAYOUT = 1;

public int getState() {
public State getState() {
return _state;
}

public void setState(int state) {
public void setState(State state) {
_state = state;
}

public static String stateToString(int state) {
public static String stateToString(State state) {
return switch (state) {
case NOTHING -> "NOTHING";
case FLUX -> "FLUX";
case CHILDREN_FLUX -> "CHILDREN_FLUX";
case DONE -> "DONE";
default -> "unknown";
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public InlineLayoutBox(LayoutContext c, Element elem, CalculatedStyle style, int
}

private InlineLayoutBox() {
setState(Box.DONE);
setState(State.DONE);
}

public InlineLayoutBox copyOf() {
Expand Down

0 comments on commit 31c9726

Please sign in to comment.