haikuwebkit/LayoutTests/printing/break-inside-avoid.html

59 lines
2.1 KiB
HTML
Raw Permalink Normal View History

Support break-after, break-before and break-inside. https://bugs.webkit.org/show_bug.cgi?id=148814 Reviewed by Dean Jackson. Source/WebCore: New tests added in printing/, fast/multicol/, and fast/regions. * css/CSSComputedStyleDeclaration.cpp: (WebCore::convertToPageBreak): (WebCore::convertToColumnBreak): (WebCore::convertToRegionBreak): For backwards compatibility, keep support for all the old properties in computed style. This means we have to convert the break-* property values into keywords that make sense for the legacy properties. This mainly involves mapping "page", "column", "region" to "always" (similar rule for the avoid-* versions as well). (WebCore::ComputedStyleExtractor::propertyValue): Add support for the three new break-* properties. * css/CSSParser.cpp: (WebCore::isValidKeywordPropertyAndValue): (WebCore::isKeywordPropertyID): (WebCore::CSSParser::parseValue): Add support for the new break properties. * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::operator BreakBetween): (WebCore::CSSPrimitiveValue::operator BreakInside): Add converters for the new BreakBetween and BreakInside enums. Remove the EPageBreak enum, since it is no longer used. * css/CSSPropertyNames.in: * css/CSSValueKeywords.in: Add the new properties and the new values supported by the properties to the keywords lists. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertFontSynthesis): (WebCore::StyleBuilderConverter::convertPageBreakBetween): (WebCore::StyleBuilderConverter::convertPageBreakInside): (WebCore::StyleBuilderConverter::convertColumnBreakBetween): (WebCore::StyleBuilderConverter::convertColumnBreakInside): (WebCore::StyleBuilderConverter::convertRegionBreakBetween): (WebCore::StyleBuilderConverter::convertRegionBreakInside): In order to map the legacy properties into the new break-* values we have custom converter functions. * rendering/RenderBlock.cpp: (WebCore::RenderBlock::paintChild): (WebCore::RenderBlock::childBoxIsUnsplittableForFragmentation): (WebCore::RenderBlock::computeRegionRangeForBoxChild): * rendering/RenderBlockFlow.cpp: (WebCore::RenderBlockFlow::applyBeforeBreak): (WebCore::RenderBlockFlow::applyAfterBreak): Patch the block code to check the correct new break-* constants. For avoidance, this means checking both the general avoid value and the specific value (e.g., avoid-page). In place of "always", we check the specific value (e.g., column) and then for page specifically, we also treat "left", "right", "recto" and "verso" as "always break" for now. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::changeRequiresLayout): Make sure changes to the break properties trigger relayout. * rendering/style/RenderStyle.h: Add getters and setters for the break-* properties and remove all occurrences of the legacy page, column and region values from the RenderStyle. * rendering/style/RenderStyleConstants.cpp: (WebCore::alwaysPageBreak): We have a helper function here for mapping several constant values to "page". * rendering/style/RenderStyleConstants.h: Definitions of the new BreakBetween and BreakInside enums. * rendering/style/StyleMultiColData.cpp: (WebCore::StyleMultiColData::StyleMultiColData): (WebCore::StyleMultiColData::operator==): * rendering/style/StyleMultiColData.h: Remove the column-specific break data. * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Remove the region-specific break data and replace it with generic break data that is now used by all three pagination models. LayoutTests: * TestExpectations: * fast/multicol/standardized-break-properties-expected.txt: Added. * fast/multicol/standardized-break-properties.html: Added. * fast/multicol/vertical-lr/standardized-break-properties-expected.txt: Added. * fast/multicol/vertical-lr/standardized-break-properties.html: Added. * fast/multicol/vertical-rl/standardized-break-properties-expected.txt: Added. * fast/multicol/vertical-rl/standardized-break-properties.html: Added. * fast/regions/text-break-properties-expected.txt: Added. * fast/regions/text-break-properties.html: Added. * printing/allowed-breaks-expected.txt: Added. * printing/allowed-breaks.html: Added. * printing/break-after-avoid-expected.txt: Added. * printing/break-after-avoid-page-expected.txt: Added. * printing/break-after-avoid-page.html: Added. * printing/break-after-avoid.html: Added. * printing/break-always-expected.txt: Added. * printing/break-always.html: Added. * printing/break-avoid-expected.txt: Added. * printing/break-avoid-page-expected.txt: Added. * printing/break-avoid-page.html: Added. * printing/break-avoid.html: Added. * printing/break-display-none-expected.txt: Added. * printing/break-display-none.html: Added. * printing/break-inside-avoid-expected.txt: Added. * printing/break-inside-avoid-page-expected.txt: Added. * printing/break-inside-avoid-page.html: Added. * printing/break-inside-avoid.html: Added. * printing/script-tests/allowed-breaks.js: Added. (test): * printing/script-tests/break-after-avoid-page.js: Added. (test): * printing/script-tests/break-after-avoid.js: Added. (test): * printing/script-tests/break-always.js: Added. (test): * printing/script-tests/break-avoid-page.js: Added. (test): * printing/script-tests/break-avoid.js: Added. (test): * printing/script-tests/break-display-none.js: Added. (test): * printing/script-tests/break-inside-avoid-page.js: Added. (test): * printing/script-tests/break-inside-avoid.js: Added. (test): Canonical link: https://commits.webkit.org/171770@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195892 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-30 15:28:48 +00:00
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
<script src="resources/paged-media-test-utils.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<div id="sandbox"></div>
<script>
description("Test for page-break-inside:avoid");
function test()
{
createBlockWithRatioToPageHeight("page1-1", 0.5).style.breakBefore = "page";
// block 'page1-2' should be splitted.
createBlockWithNumberOfLines("page1-2", 20);
createBlockWithRatioToPageHeight("page2", 0.1);
createBlockWithRatioToPageHeight("page3", 0.5).style.breakBefore = "page";
// We should place block 'page4' in the next page because of 'page-break-inside: avoid'.
createBlockWithNumberOfLines("page4", 20).style.breakInside = "avoid";
createBlockWithRatioToPageHeight("page5", 0.8).style.breakBefore = "page";
// block 'page5-2' is a very large block, occupying more than 2 pages.
// We don't define from where this large block starts. Maybe from the next page.
createBlockWithNumberOfLines("page5or6", 20 * 2 + 10).style.breakInside = "avoid";
createBlockWithRatioToPageHeight("page8", 0.1);
createBlockWithRatioToPageHeight("page9-1", 0.1).style.breakBefore = "page";
createBlockWithRatioToPageHeight("page9-2", 0.1).style.breakAfter = "page";
// Make sure page-break only happens once, not twice.
createBlockWithNumberOfLines("page10", 20).style.breakInside = "avoid";
pageNumberForElementShouldBe('page1-1', 1);
pageNumberForElementShouldBe('page1-2', 1);
pageNumberForElementShouldBe('page2', 2);
pageNumberForElementShouldBe('page3', 3);
pageNumberForElementShouldBe('page4', 4);
pageNumberForElementShouldBe('page5', 5);
pageNumberForElementShouldBe('page8', 8);
pageNumberForElementShouldBe('page9-1', 9);
pageNumberForElementShouldBe('page9-2', 9);
pageNumberForElementShouldBe('page10', 10);
document.body.removeChild(document.getElementById("sandbox"));
}
var successfullyParsed = true;
</script>
Support break-after, break-before and break-inside. https://bugs.webkit.org/show_bug.cgi?id=148814 Reviewed by Dean Jackson. Source/WebCore: New tests added in printing/, fast/multicol/, and fast/regions. * css/CSSComputedStyleDeclaration.cpp: (WebCore::convertToPageBreak): (WebCore::convertToColumnBreak): (WebCore::convertToRegionBreak): For backwards compatibility, keep support for all the old properties in computed style. This means we have to convert the break-* property values into keywords that make sense for the legacy properties. This mainly involves mapping "page", "column", "region" to "always" (similar rule for the avoid-* versions as well). (WebCore::ComputedStyleExtractor::propertyValue): Add support for the three new break-* properties. * css/CSSParser.cpp: (WebCore::isValidKeywordPropertyAndValue): (WebCore::isKeywordPropertyID): (WebCore::CSSParser::parseValue): Add support for the new break properties. * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::operator BreakBetween): (WebCore::CSSPrimitiveValue::operator BreakInside): Add converters for the new BreakBetween and BreakInside enums. Remove the EPageBreak enum, since it is no longer used. * css/CSSPropertyNames.in: * css/CSSValueKeywords.in: Add the new properties and the new values supported by the properties to the keywords lists. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertFontSynthesis): (WebCore::StyleBuilderConverter::convertPageBreakBetween): (WebCore::StyleBuilderConverter::convertPageBreakInside): (WebCore::StyleBuilderConverter::convertColumnBreakBetween): (WebCore::StyleBuilderConverter::convertColumnBreakInside): (WebCore::StyleBuilderConverter::convertRegionBreakBetween): (WebCore::StyleBuilderConverter::convertRegionBreakInside): In order to map the legacy properties into the new break-* values we have custom converter functions. * rendering/RenderBlock.cpp: (WebCore::RenderBlock::paintChild): (WebCore::RenderBlock::childBoxIsUnsplittableForFragmentation): (WebCore::RenderBlock::computeRegionRangeForBoxChild): * rendering/RenderBlockFlow.cpp: (WebCore::RenderBlockFlow::applyBeforeBreak): (WebCore::RenderBlockFlow::applyAfterBreak): Patch the block code to check the correct new break-* constants. For avoidance, this means checking both the general avoid value and the specific value (e.g., avoid-page). In place of "always", we check the specific value (e.g., column) and then for page specifically, we also treat "left", "right", "recto" and "verso" as "always break" for now. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::changeRequiresLayout): Make sure changes to the break properties trigger relayout. * rendering/style/RenderStyle.h: Add getters and setters for the break-* properties and remove all occurrences of the legacy page, column and region values from the RenderStyle. * rendering/style/RenderStyleConstants.cpp: (WebCore::alwaysPageBreak): We have a helper function here for mapping several constant values to "page". * rendering/style/RenderStyleConstants.h: Definitions of the new BreakBetween and BreakInside enums. * rendering/style/StyleMultiColData.cpp: (WebCore::StyleMultiColData::StyleMultiColData): (WebCore::StyleMultiColData::operator==): * rendering/style/StyleMultiColData.h: Remove the column-specific break data. * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): * rendering/style/StyleRareNonInheritedData.h: Remove the region-specific break data and replace it with generic break data that is now used by all three pagination models. LayoutTests: * TestExpectations: * fast/multicol/standardized-break-properties-expected.txt: Added. * fast/multicol/standardized-break-properties.html: Added. * fast/multicol/vertical-lr/standardized-break-properties-expected.txt: Added. * fast/multicol/vertical-lr/standardized-break-properties.html: Added. * fast/multicol/vertical-rl/standardized-break-properties-expected.txt: Added. * fast/multicol/vertical-rl/standardized-break-properties.html: Added. * fast/regions/text-break-properties-expected.txt: Added. * fast/regions/text-break-properties.html: Added. * printing/allowed-breaks-expected.txt: Added. * printing/allowed-breaks.html: Added. * printing/break-after-avoid-expected.txt: Added. * printing/break-after-avoid-page-expected.txt: Added. * printing/break-after-avoid-page.html: Added. * printing/break-after-avoid.html: Added. * printing/break-always-expected.txt: Added. * printing/break-always.html: Added. * printing/break-avoid-expected.txt: Added. * printing/break-avoid-page-expected.txt: Added. * printing/break-avoid-page.html: Added. * printing/break-avoid.html: Added. * printing/break-display-none-expected.txt: Added. * printing/break-display-none.html: Added. * printing/break-inside-avoid-expected.txt: Added. * printing/break-inside-avoid-page-expected.txt: Added. * printing/break-inside-avoid-page.html: Added. * printing/break-inside-avoid.html: Added. * printing/script-tests/allowed-breaks.js: Added. (test): * printing/script-tests/break-after-avoid-page.js: Added. (test): * printing/script-tests/break-after-avoid.js: Added. (test): * printing/script-tests/break-always.js: Added. (test): * printing/script-tests/break-avoid-page.js: Added. (test): * printing/script-tests/break-avoid.js: Added. (test): * printing/script-tests/break-display-none.js: Added. (test): * printing/script-tests/break-inside-avoid-page.js: Added. (test): * printing/script-tests/break-inside-avoid.js: Added. (test): Canonical link: https://commits.webkit.org/171770@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195892 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-30 15:28:48 +00:00
<script>runPrintingTest(test);</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>