Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,25 @@ public final class AtomicNodeTooLargeException extends RuntimeException {
public AtomicNodeTooLargeException(String message) {
super(message);
}

/**
* Creates an exception for a node whose required outer height exceeds a full
* page's capacity, with a diagnostic message that names the offending
* measurements but no user document content.
*
* @param path the node's layout path
* @param outerHeight the node's required outer (margin-box) height
* @param pageHeight the available full-page capacity
* @return the exception, ready to throw
* @since 2.0.0
*/
public static AtomicNodeTooLargeException forNode(String path, double outerHeight, double pageHeight) {
return new AtomicNodeTooLargeException(
"Node '" + path + "' requires outer height " + outerHeight
+ " but page capacity is " + pageHeight + ". "
+ "Reduce the node height, split content into multiple atomic blocks, "
+ "or increase the page size. Differences under 0.5 pt are tolerated as "
+ "rounding noise (v1.6.2+).");
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ private void compileSplittableLeaf(PreparedNode<DocumentNode> prepared,
state.newPage();
continue;
}
throw atomicTooLarge(path, pieceOuterHeight, fullPageOuterHeight);
throw AtomicNodeTooLargeException.forNode(path, pieceOuterHeight, fullPageOuterHeight);
}
if (tail != null && tail.equals(current)) {
throw new IllegalStateException("Split did not make progress for node '" + path
Expand All @@ -962,7 +962,7 @@ private void compileSplittableLeaf(PreparedNode<DocumentNode> prepared,
state.newPage();
continue;
}
throw atomicTooLarge(path, headOuterHeight, fullPageOuterHeight);
throw AtomicNodeTooLargeException.forNode(path, headOuterHeight, fullPageOuterHeight);
}

state.touchPage();
Expand Down Expand Up @@ -1326,23 +1326,14 @@ private String semanticName(DocumentNode node) {
private void admitAtomicBlock(double outerHeight, String path, CompilerState state) {
double fullPageHeight = state.activeInnerHeight();
if (outerHeight > fullPageHeight + CAPACITY_TOLERANCE) {
throw atomicTooLarge(path, outerHeight, fullPageHeight);
throw AtomicNodeTooLargeException.forNode(path, outerHeight, fullPageHeight);
}
if (outerHeight > state.remainingHeight() + EPS && state.usedHeight > EPS) {
state.newPage();
}
state.touchPage();
}

private AtomicNodeTooLargeException atomicTooLarge(String path, double outerHeight, double pageHeight) {
return new AtomicNodeTooLargeException(
"Node '" + path + "' requires outer height " + outerHeight
+ " but page capacity is " + pageHeight + ". "
+ "Reduce the node height, split content into multiple atomic blocks, "
+ "or increase the page size. Differences under 0.5 pt are tolerated as "
+ "rounding noise (v1.6.2+).");
}

/**
* Identifies the kind of fixed slot a child is being compiled into,
* so the validator can distinguish "child of a horizontal row band"
Expand Down
Loading