Commit 185cbb3d authored by Felipe Erias's avatar Felipe Erias Committed by Commit Bot

Support JIS B5 and JIS B4 page sizes

Add support for the values "jis-b5" and "jis-b4" in the "size" property
of the "@page" rule, as specified in the CSS standard:

https://www.w3.org/TR/css-page-3/#typedef-page-size-page-size

These values represent two Japanese standard paper sizes:
  - JIS B5 is 182mm wide by 257mm high
  - JIS-B4 is 257mm wide by 364mm high

Test: printing/page-format-data.html

Bug: 1047642
Change-Id: Iec39bb535d21ea5a6ee1696b744166e1247be35f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2059029Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Reviewed-by: default avatarEric Willigers <ericwilligers@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743031}
parent 146b111f
...@@ -926,6 +926,8 @@ ...@@ -926,6 +926,8 @@
"invisible" "invisible"
"skip-activation" "skip-activation"
"skip-viewport-activation" "skip-viewport-activation"
"jis-b5"
"jis-b4"
# at-rules # at-rules
"@charset" "@charset"
......
...@@ -477,6 +477,8 @@ ...@@ -477,6 +477,8 @@
"-webkit-isolate", "-webkit-isolate",
"-webkit-isolate-override", "-webkit-isolate-override",
"-webkit-plaintext", "-webkit-plaintext",
"jis-b5",
"jis-b4",
"landscape", "landscape",
"ledger", "ledger",
"legal", "legal",
......
...@@ -2378,7 +2378,9 @@ message PropertyAndValue { ...@@ -2378,7 +2378,9 @@ message PropertyAndValue {
SMOOTH = 757; SMOOTH = 757;
JUMP_START = 758; JUMP_START = 758;
NO_DRAG = 759; NO_DRAG = 759;
INVALID_VALUE = 760; JIS_B5 = 760;
JIS_B4 = 761;
INVALID_VALUE = 762;
}; };
optional ValueId value_id = 4; optional ValueId value_id = 4;
......
...@@ -956,6 +956,8 @@ const std::string Converter::kValueLookupTable[] = { ...@@ -956,6 +956,8 @@ const std::string Converter::kValueLookupTable[] = {
"smooth", "smooth",
"jump-start", "jump-start",
"no-drag", "no-drag",
"jis-b5",
"jis-b4",
"INVALID_VALUE", "INVALID_VALUE",
}; };
......
...@@ -5610,8 +5610,8 @@ const CSSValue* ShapeRendering::CSSValueFromComputedStyleInternal( ...@@ -5610,8 +5610,8 @@ const CSSValue* ShapeRendering::CSSValueFromComputedStyleInternal(
static CSSValue* ConsumePageSize(CSSParserTokenRange& range) { static CSSValue* ConsumePageSize(CSSParserTokenRange& range) {
return css_property_parser_helpers::ConsumeIdent< return css_property_parser_helpers::ConsumeIdent<
CSSValueID::kA3, CSSValueID::kA4, CSSValueID::kA5, CSSValueID::kB4, CSSValueID::kA3, CSSValueID::kA4, CSSValueID::kA5, CSSValueID::kB4,
CSSValueID::kB5, CSSValueID::kLedger, CSSValueID::kLegal, CSSValueID::kB5, CSSValueID::kJisB5, CSSValueID::kJisB4,
CSSValueID::kLetter>(range); CSSValueID::kLedger, CSSValueID::kLegal, CSSValueID::kLetter>(range);
} }
static float MmToPx(float mm) { static float MmToPx(float mm) {
...@@ -5632,6 +5632,10 @@ static FloatSize GetPageSizeFromName(const CSSIdentifierValue& page_size_name) { ...@@ -5632,6 +5632,10 @@ static FloatSize GetPageSizeFromName(const CSSIdentifierValue& page_size_name) {
return FloatSize(MmToPx(176), MmToPx(250)); return FloatSize(MmToPx(176), MmToPx(250));
case CSSValueID::kB4: case CSSValueID::kB4:
return FloatSize(MmToPx(250), MmToPx(353)); return FloatSize(MmToPx(250), MmToPx(353));
case CSSValueID::kJisB5:
return FloatSize(MmToPx(182), MmToPx(257));
case CSSValueID::kJisB4:
return FloatSize(MmToPx(257), MmToPx(364));
case CSSValueID::kLetter: case CSSValueID::kLetter:
return FloatSize(InchToPx(8.5), InchToPx(11)); return FloatSize(InchToPx(8.5), InchToPx(11));
case CSSValueID::kLegal: case CSSValueID::kLegal:
......
...@@ -36,6 +36,10 @@ Test b5 ...@@ -36,6 +36,10 @@ Test b5
PASS internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4) is mmSize(176, 250) + pxMargins(1, 2, 3, 4) PASS internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4) is mmSize(176, 250) + pxMargins(1, 2, 3, 4)
Test b4 Test b4
PASS internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4) is mmSize(250, 353) + pxMargins(1, 2, 3, 4) PASS internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4) is mmSize(250, 353) + pxMargins(1, 2, 3, 4)
Test jis-b5
PASS internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4) is mmSize(182, 257) + pxMargins(1, 2, 3, 4)
Test jis-b4
PASS internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4) is mmSize(257, 364) + pxMargins(1, 2, 3, 4)
Test letter Test letter
PASS internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4) is inchSize(8.5, 11) + pxMargins(1, 2, 3, 4) PASS internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4) is inchSize(8.5, 11) + pxMargins(1, 2, 3, 4)
Test legal Test legal
......
...@@ -102,6 +102,14 @@ ...@@ -102,6 +102,14 @@
appendStyle("@page {size:b4;}"); appendStyle("@page {size:b4;}");
shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "mmSize(250, 353) + pxMargins(1, 2, 3, 4)"); shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "mmSize(250, 353) + pxMargins(1, 2, 3, 4)");
debug("Test jis-b5");
appendStyle("@page {size:jis-b5;}");
shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "mmSize(182, 257) + pxMargins(1, 2, 3, 4)");
debug("Test jis-b4");
appendStyle("@page {size:jis-b4;}");
shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "mmSize(257, 364) + pxMargins(1, 2, 3, 4)");
debug("Test letter"); debug("Test letter");
appendStyle("@page {size:letter;}"); appendStyle("@page {size:letter;}");
shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "inchSize(8.5, 11) + pxMargins(1, 2, 3, 4)"); shouldBe("internals.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4)", "inchSize(8.5, 11) + pxMargins(1, 2, 3, 4)");
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
@page page_widht_height { size: 10cm 15cm; } @page page_widht_height { size: 10cm 15cm; }
@page page_size_orientation { size: ledger landscape; } @page page_size_orientation { size: ledger landscape; }
@page page_orientation_size { size: a4 portrait; } @page page_orientation_size { size: a4 portrait; }
@page page_jis_size_orientation { size: jis-b5 portrait; }
@page page_orientation_jis_size { size: jis-b4 landscape; }
@page err_empty_size { } @page err_empty_size { }
@page err_unknow_page_size { } @page err_unknow_page_size { }
@page err_length_and_page_size { } @page err_length_and_page_size { }
......
...@@ -51,6 +51,12 @@ ...@@ -51,6 +51,12 @@
@page page_orientation_size { @page page_orientation_size {
size: portrait a4; size: portrait a4;
} }
@page page_jis_size_orientation {
size: jis-b5 portrait;
}
@page page_orientation_jis_size {
size: landscape jis-b4;
}
@page err_empty_size { @page err_empty_size {
size:; size:;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment