diff --git a/src/main/java/com/demcha/compose/document/layout/LayoutCompiler.java b/src/main/java/com/demcha/compose/document/layout/LayoutCompiler.java index 5ee452f6..9edcca23 100644 --- a/src/main/java/com/demcha/compose/document/layout/LayoutCompiler.java +++ b/src/main/java/com/demcha/compose/document/layout/LayoutCompiler.java @@ -171,7 +171,7 @@ private void compileNode(PreparedNode prepared, if (definition.paginationPolicy(node) == PaginationPolicy.SPLITTABLE) { SplittableLeafCompiler.compile(prepared, definition, path, semanticName, parentPath, childIndex, depth, regionX, - availableWidth, state, prepareContext, fragmentContext, nodes, fragments); + availableWidth, new CompileContext(state, prepareContext, fragmentContext, nodes, fragments)); return; } diff --git a/src/main/java/com/demcha/compose/document/layout/SplittableLeafCompiler.java b/src/main/java/com/demcha/compose/document/layout/SplittableLeafCompiler.java index 7f7e8db8..054c685c 100644 --- a/src/main/java/com/demcha/compose/document/layout/SplittableLeafCompiler.java +++ b/src/main/java/com/demcha/compose/document/layout/SplittableLeafCompiler.java @@ -44,11 +44,7 @@ private SplittableLeafCompiler() { * @param depth the leaf's tree depth * @param regionX the content region's left edge * @param availableWidth the content width available to the leaf - * @param state the compiler cursor (mutated as pages advance) - * @param prepareContext the node preparation context (drives re-measurement of tails) - * @param fragmentContext the fragment emission context - * @param nodes accumulator for placed nodes (appended to) - * @param fragments accumulator for placed fragments (appended to) + * @param ctx the cursor + emission context (mutated as pages advance) * @throws AtomicNodeTooLargeException if a piece cannot fit on an empty page */ static void compile(PreparedNode prepared, @@ -60,11 +56,13 @@ static void compile(PreparedNode prepared, int depth, double regionX, double availableWidth, - CompilerState state, - PrepareContext prepareContext, - FragmentContext fragmentContext, - List nodes, - List fragments) { + CompileContext ctx) { + CompilerState state = ctx.state(); + PrepareContext prepareContext = ctx.prepareContext(); + FragmentContext fragmentContext = ctx.fragmentContext(); + List nodes = ctx.nodes(); + List fragments = ctx.fragments(); + Margin originalMargin = toMargin(prepared.node().margin()); Padding originalPadding = toPadding(prepared.node().padding()); diff --git a/src/test/java/com/demcha/compose/document/layout/SplittableLeafCompilerTest.java b/src/test/java/com/demcha/compose/document/layout/SplittableLeafCompilerTest.java index 8612208c..101e6204 100644 --- a/src/test/java/com/demcha/compose/document/layout/SplittableLeafCompilerTest.java +++ b/src/test/java/com/demcha/compose/document/layout/SplittableLeafCompilerTest.java @@ -44,7 +44,7 @@ private static PreparedNode leaf(double height) { private void compile(PreparedNode prepared) { SplittableLeafCompiler.compile(prepared, definition, "leaf", "leaf", null, 0, 1, - 10, 180, state, prepareContext, fragmentContext, nodes, fragments); + 10, 180, new CompileContext(state, prepareContext, fragmentContext, nodes, fragments)); } @Test