Skip to content

Commit 9ec3a26

Browse files
author
Dmitry Radchuk
committed
Add negative indexes support in grid layout
DEVSIX-8423
1 parent ae116f4 commit 9ec3a26

File tree

60 files changed

+538
-47
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+538
-47
lines changed

src/main/java/com/itextpdf/html2pdf/css/resolve/DefaultCssResolver.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,13 @@ private Map<String, String> resolveStyles(INode element, CssContext context) {
182182
CommonCssConstants.FONT_SIZE), inheritanceRules);
183183

184184
// If the parent has display: flex, the flex item is blockified
185-
// no matter what display value is set for it (except 'none' value).
185+
// no matter what display value is set for it (except 'none' and 'grid' values).
186186
// See CSS Flexible Box Layout Module Level 1,
187187
// W3C Candidate Recommendation, 19 November 2018: 4. Flex Items.
188188
final String currentElementDisplay = elementStyles.get(CssConstants.DISPLAY);
189189
if (isFlexItem(entry, currentElementDisplay) &&
190-
!CommonCssConstants.NONE.equals(currentElementDisplay)) {
190+
!CommonCssConstants.NONE.equals(currentElementDisplay) &&
191+
!CommonCssConstants.GRID.equals(currentElementDisplay)) {
191192
elementStyles.put(CssConstants.DISPLAY, CssConstants.BLOCK);
192193
}
193194
}

src/test/java/com/itextpdf/html2pdf/css/grid/GridItemPlacementTest.java

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,28 +153,63 @@ public void twoRowSpans3Test() throws IOException, InterruptedException {
153153
}
154154

155155
@Test
156-
public void invalid1Test() throws IOException, InterruptedException {
157-
runTest("invalid1");
156+
public void spanToNegativeStartTest() throws IOException, InterruptedException {
157+
runTest("spanToNegativeStartTest");
158158
}
159159

160160
@Test
161-
public void invalid2Test() throws IOException, InterruptedException {
162-
runTest("invalid2");
161+
public void spanToNegativeStartWithExplicitTemplatesTest() throws IOException, InterruptedException {
162+
runTest("spanToNegativeStartWithExplicitTemplatesTest");
163163
}
164164

165165
@Test
166-
public void invalid3Test() throws IOException, InterruptedException {
167-
runTest("invalid3");
166+
public void spanToNegativeStartWithoutTemplatesTest() throws IOException, InterruptedException {
167+
runTest("spanToNegativeStartWithoutTemplatesTest");
168168
}
169169

170170
@Test
171-
public void invalid4Test() throws IOException, InterruptedException {
172-
runTest("invalid4");
171+
public void spanToNegativeStartWithoutTemplatesTest2() throws IOException, InterruptedException {
172+
runTest("spanToNegativeStartWithoutTemplatesTest2");
173173
}
174174

175175
@Test
176-
public void invalid5Test() throws IOException, InterruptedException {
177-
runTest("invalid5");
176+
public void spanToNegativeStartWithSingleTemplateTest() throws IOException, InterruptedException {
177+
runTest("spanToNegativeStartWithSingleTemplateTest");
178+
}
179+
180+
@Test
181+
public void columnSpanExpandsStartToNegativeTest() throws IOException, InterruptedException {
182+
runTest("columnSpanExpandsStartToNegativeTest");
183+
}
184+
185+
@Test
186+
public void negativeIndexOutOfTemplateTest() throws IOException, InterruptedException {
187+
runTest("negativeIndexOutOfTemplateTest");
188+
}
189+
190+
@Test
191+
public void negativeIndexWithImplicitLinesTest() throws IOException, InterruptedException {
192+
runTest("negativeIndexWithImplicitLinesTest");
193+
}
194+
195+
@Test
196+
public void negativeIndexWithoutTemplateTest() throws IOException, InterruptedException {
197+
runTest("negativeIndexWithoutTemplateTest");
198+
}
199+
200+
@Test
201+
public void negativeIndexShorthandTest() throws IOException, InterruptedException {
202+
runTest("negativeIndexShorthandTest");
203+
}
204+
205+
@Test
206+
public void negativeAndPositiveIndexShorthandTest() throws IOException, InterruptedException {
207+
runTest("negativeAndPositiveIndexShorthandTest");
208+
}
209+
210+
@Test
211+
public void spanToNegativeIndexWithoutTemplateTest() throws IOException, InterruptedException {
212+
runTest("spanToNegativeIndexWithoutTemplateTest");
178213
}
179214

180215
@Test

src/test/java/com/itextpdf/html2pdf/css/grid/GridTemplateColumnTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ public void templateColumnBasicTest2() throws IOException, InterruptedException
141141
runTest("template-cols-without-other-props-2");
142142
}
143143

144+
@Test
145+
public void templateColumnWithFlexAndGapsTest() throws IOException, InterruptedException {
146+
runTest("template-cols-with-flex-and-gaps");
147+
}
148+
144149
private void runTest(String testName) throws IOException, InterruptedException {
145150
convertToPdfAndCompare(testName,
146151
SOURCE_FOLDER, DESTINATION_FOLDER, false,

src/test/java/com/itextpdf/html2pdf/css/grid/GridTemplateNestedTest.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,9 @@ This file is part of the iText (R) project.
2424

2525
import com.itextpdf.html2pdf.ConverterProperties;
2626
import com.itextpdf.html2pdf.ExtendedHtmlConversionITextTest;
27-
import com.itextpdf.io.logs.IoLogMessageConstant;
28-
import com.itextpdf.test.annotations.LogMessage;
29-
import com.itextpdf.test.annotations.LogMessages;
3027

3128
import java.io.IOException;
3229
import org.junit.jupiter.api.BeforeAll;
33-
import org.junit.jupiter.api.Disabled;
3430
import org.junit.jupiter.api.Tag;
3531
import org.junit.jupiter.api.Test;
3632

@@ -57,7 +53,6 @@ public void templateNestedAreasWithBorderTest() throws IOException, InterruptedE
5753
runTest("grid-nested-areas-with-border");
5854
}
5955

60-
@Disabled("DEVSIX-8423")
6156
@Test
6257
public void templateNestedArticlesTest() throws IOException, InterruptedException {
6358
runTest("grid-nested-articles");
@@ -88,7 +83,6 @@ public void templateNestedMixedContentTest() throws IOException, InterruptedExce
8883
runTest("grid-nested-mixed-content");
8984
}
9085

91-
@Disabled("DEVSIX-8423")
9286
@Test
9387
public void templateNestedParagraphsTest() throws IOException, InterruptedException {
9488
runTest("grid-nested-paragraphs");
@@ -114,28 +108,21 @@ public void templateNestedTableMixedContentTest() throws IOException, Interrupte
114108
runTest("grid-nested-table-with-mixed-content");
115109
}
116110

117-
@Disabled("DEVSIX-8423")
118111
@Test
119112
public void templateNested2LevelsWithAreasTest() throws IOException, InterruptedException {
120113
runTest("grid-nested-2-levels-areas");
121114
}
122115

123-
@Disabled("DEVSIX-8423")
124-
@LogMessages(messages = {
125-
@LogMessage(messageTemplate = IoLogMessageConstant.CLIP_ELEMENT, count = 4)
126-
})
127116
@Test
128117
public void templateNested3LevelsFormsTest() throws IOException, InterruptedException {
129118
runTest("grid-nested-3-forms");
130119
}
131120

132-
@Disabled("DEVSIX-8423")
133121
@Test
134122
public void templateNested3LevelsTest() throws IOException, InterruptedException {
135123
runTest("grid-nested-3-levels");
136124
}
137125

138-
@Disabled("DEVSIX-8423")
139126
@Test
140127
public void templateNested3LevelsMultipleTest() throws IOException, InterruptedException {
141128
runTest("grid-nested-3-levels-multiple");

src/test/java/com/itextpdf/html2pdf/css/grid/GridTemplatesTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ public void basicColumnRowStartEndTest() throws IOException, InterruptedExceptio
136136
runTest("basicColumnRowStartEndTest");
137137
}
138138

139+
@Test
140+
public void basicColumnRowStartEnd1Test() throws IOException, InterruptedException {
141+
runTest("basicColumnRowStartEnd1Test");
142+
}
143+
139144
@Test
140145
public void basicColumnRowStartEnd2Test() throws IOException, InterruptedException {
141146
runTest("basicColumnRowStartEnd2Test");

src/test/java/com/itextpdf/html2pdf/css/w3c/css_grid/abspos/GridPaintPositionedChildren001Test.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ This file is part of the iText (R) project.
2323
package com.itextpdf.html2pdf.css.w3c.css_grid.abspos;
2424

2525
import com.itextpdf.html2pdf.css.w3c.W3CCssTest;
26-
import org.junit.jupiter.api.Disabled;
2726

28-
@Disabled("DEVSIX-8423")
2927
public class GridPaintPositionedChildren001Test extends W3CCssTest {
3028
@Override
3129
protected String getHtmlFileName() {

src/test/java/com/itextpdf/html2pdf/css/w3c/css_grid/abspos/PositionedGridItems025Test.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ This file is part of the iText (R) project.
2626
import com.itextpdf.io.logs.IoLogMessageConstant;
2727
import com.itextpdf.test.annotations.LogMessage;
2828
import com.itextpdf.test.annotations.LogMessages;
29-
import org.junit.jupiter.api.Disabled;
3029

31-
@Disabled("DEVSIX-8423")
3230
@LogMessages(messages = {
3331
@LogMessage(messageTemplate = IoLogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED, count = 2)
3432
})

src/test/java/com/itextpdf/html2pdf/css/w3c/css_grid/abspos/PositionedGridItemsNegativeIndices001Test.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ This file is part of the iText (R) project.
2323
package com.itextpdf.html2pdf.css.w3c.css_grid.abspos;
2424

2525
import com.itextpdf.html2pdf.css.w3c.W3CCssTest;
26-
import org.junit.jupiter.api.Disabled;
2726

28-
@Disabled("DEVSIX-8423")
2927
public class PositionedGridItemsNegativeIndices001Test extends W3CCssTest {
3028
@Override
3129
protected String getHtmlFileName() {

src/test/java/com/itextpdf/html2pdf/css/w3c/css_grid/grid_definition/GridAutoRepeatMaxSize002Test.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ This file is part of the iText (R) project.
2626
import com.itextpdf.html2pdf.logs.Html2PdfLogMessageConstant;
2727
import com.itextpdf.test.annotations.LogMessage;
2828
import com.itextpdf.test.annotations.LogMessages;
29-
import org.junit.jupiter.api.Disabled;
3029

31-
@Disabled("DEVSIX-8423")
3230
@LogMessages(messages = {
3331
@LogMessage(messageTemplate = Html2PdfLogMessageConstant.NO_WORKER_FOUND_FOR_TAG, count = 3)})
3432
public class GridAutoRepeatMaxSize002Test extends W3CCssTest {

src/test/java/com/itextpdf/html2pdf/css/w3c/css_grid/grid_definition/GridAutoRepeatMinMaxSize001Test.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ This file is part of the iText (R) project.
2626
import com.itextpdf.html2pdf.logs.Html2PdfLogMessageConstant;
2727
import com.itextpdf.test.annotations.LogMessage;
2828
import com.itextpdf.test.annotations.LogMessages;
29-
import org.junit.jupiter.api.Disabled;
3029

31-
@Disabled("DEVSIX-8423")
3230
@LogMessages(messages = {
3331
@LogMessage(messageTemplate = Html2PdfLogMessageConstant.NO_WORKER_FOUND_FOR_TAG, count = 3)})
3432
public class GridAutoRepeatMinMaxSize001Test extends W3CCssTest {

0 commit comments

Comments
 (0)