Changeset 95264 in webkit


Ignore:
Timestamp:
Sep 15, 2011 7:56:19 PM (13 years ago)
Author:
Alexandru Chiculita
Message:

[CSSRegions] Regions should not slice line box rendering
https://bugs.webkit.org/show_bug.cgi?id=66198

Source/WebCore:

Created a new LayoutState constructor for the RenderFlowThread. It will
set m_isPaginated to true and force a pageHeight if 1. The actual pageHeight is
not used, because pageLogicalHeightForOffset will actually redirect the call
to RenderFlowThread.

Removed some of the duplicate code that calculated the page logical offset.
Added new methods like logicalPageOffset, pageLogicalHeightForOffset,
pageRemainingLogicalHeightForOffset.

There are still some issues related to incremental layout and different region widths.
Those issues will be addressed in different patches.

Reviewed by David Hyatt.

Tests: fast/regions/text-region-breaks.html

fast/regions/text-region-split-horizontal-bt.html
fast/regions/text-region-split-vertical-rl.html
fast/regions/text-region-split-vertical.html
fast/regions/text-region-split.html

  • rendering/LayoutState.cpp:

(WebCore::LayoutState::LayoutState):

  • rendering/LayoutState.h:

(WebCore::LayoutState::LayoutState):
(WebCore::LayoutState::isPaginated):

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::positionNewFloats):
(WebCore::RenderBlock::adjustForRegionFittingIfNeeded):
(WebCore::RenderBlock::nextPageLogicalTopExcludingBoundaryPoint):
(WebCore::RenderBlock::nextPageLogicalTopIncludingBoundaryPoint):
(WebCore::inNormalFlow):
(WebCore::RenderBlock::applyBeforeBreak):
(WebCore::RenderBlock::applyAfterBreak):
(WebCore::RenderBlock::logicalPageOffset):
(WebCore::RenderBlock::pageLogicalHeightForOffset):
(WebCore::RenderBlock::pageRemainingLogicalHeightForOffset):
(WebCore::RenderBlock::adjustForUnsplittableChild):
(WebCore::RenderBlock::adjustLinePositionForPagination):

  • rendering/RenderBlock.h:
  • rendering/RenderFlowThread.cpp:

(WebCore::RenderFlowThread::layout):
(WebCore::RenderFlowThread::regionLogicalHeightForLine):
(WebCore::RenderFlowThread::regionRemainingLogicalHeightForLine):

  • rendering/RenderFlowThread.h:
  • rendering/RenderView.cpp:

(WebCore::RenderView::pushLayoutState):

  • rendering/RenderView.h:

(WebCore::LayoutStateMaintainer::LayoutStateMaintainer):
(WebCore::LayoutStateMaintainer::push):

LayoutTests:

Also updated the results for some older tests that now work correctly.

Reviewed by David Hyatt.

  • fast/regions/resources/helper.js:

(isDebugEnabled):
(assertEqualRects):
(testBoundingRects):
(assertRectContains):
(addPageLevelDebugBox):
(testContentToRegionsMapping):

  • fast/regions/text-region-breaks-expected.txt: Added.
  • fast/regions/text-region-breaks.html: Added.
  • fast/regions/text-region-split-expected.txt: Added.
  • fast/regions/text-region-split-horizontal-bt-expected.txt: Added.
  • fast/regions/text-region-split-horizontal-bt.html: Added.
  • fast/regions/text-region-split-vertical-expected.txt: Added.
  • fast/regions/text-region-split-vertical-rl-expected.txt: Added.
  • fast/regions/text-region-split-vertical-rl.html: Added.
  • fast/regions/text-region-split-vertical.html: Added.
  • fast/regions/text-region-split.html: Added.
  • fast/regions/webkit-flow-floats-inside-regions-bounds-expected.txt:
  • fast/regions/webkit-flow-inlines-inside-regions-bounds-expected.txt:
  • fast/regions/webkit-flow-inlines-inside-regions-bounds-vertical-expected.txt:
  • fast/regions/webkit-flow-inlines-inside-regions-bounds-vertical-rl-expected.txt:
  • fast/repaint/japanese-rl-selection-repaint-in-regions.html:
  • platform/mac/fast/repaint/japanese-rl-selection-repaint-in-regions-expected.png:
  • platform/mac/fast/repaint/japanese-rl-selection-repaint-in-regions-expected.txt:
Location:
trunk
Files:
10 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r95263 r95264  
     12011-09-15  Alexandru Chiculita  <achicu@adobe.com>
     2
     3        [CSSRegions] Regions should not slice line box rendering
     4        https://bugs.webkit.org/show_bug.cgi?id=66198
     5
     6        Also updated the results for some older tests that now work correctly.
     7
     8        Reviewed by David Hyatt.
     9
     10        * fast/regions/resources/helper.js:
     11        (isDebugEnabled):
     12        (assertEqualRects):
     13        (testBoundingRects):
     14        (assertRectContains):
     15        (addPageLevelDebugBox):
     16        (testContentToRegionsMapping):
     17        * fast/regions/text-region-breaks-expected.txt: Added.
     18        * fast/regions/text-region-breaks.html: Added.
     19        * fast/regions/text-region-split-expected.txt: Added.
     20        * fast/regions/text-region-split-horizontal-bt-expected.txt: Added.
     21        * fast/regions/text-region-split-horizontal-bt.html: Added.
     22        * fast/regions/text-region-split-vertical-expected.txt: Added.
     23        * fast/regions/text-region-split-vertical-rl-expected.txt: Added.
     24        * fast/regions/text-region-split-vertical-rl.html: Added.
     25        * fast/regions/text-region-split-vertical.html: Added.
     26        * fast/regions/text-region-split.html: Added.
     27        * fast/regions/webkit-flow-floats-inside-regions-bounds-expected.txt:
     28        * fast/regions/webkit-flow-inlines-inside-regions-bounds-expected.txt:
     29        * fast/regions/webkit-flow-inlines-inside-regions-bounds-vertical-expected.txt:
     30        * fast/regions/webkit-flow-inlines-inside-regions-bounds-vertical-rl-expected.txt:
     31        * fast/repaint/japanese-rl-selection-repaint-in-regions.html:
     32        * platform/mac/fast/repaint/japanese-rl-selection-repaint-in-regions-expected.png:
     33        * platform/mac/fast/repaint/japanese-rl-selection-repaint-in-regions-expected.txt:
     34
    1352011-09-15  Keishi Hattori  <keishi@webkit.org>
    236
  • trunk/LayoutTests/fast/regions/resources/helper.js

    r93728 r95264  
     1function isDebugEnabled()
     2{
     3    // Add #debug at the end of the url to visually debug the test case.
     4    return window.location.hash == "#debug";
     5}
     6
    17function rectToArray(rect) {
    28    return [rect.top, rect.left, rect.bottom, rect.right, rect.width, rect.height];
     
    2329        return;
    2430
    25     results.push("FAIL(" + name + " bounding rect was: [" + actualRect.join(", ") + "], expected: [" + expectedRect.join(", ") + "]");
     31    results.push("FAIL(" + name + ") bounding rect was: [" + actualRect.join(", ") + "], expected: [" + expectedRect.join(", ") + "]");
    2632}
    2733
     
    4450    return !results.length;
    4551}
     52
     53function assertRectContains(results, name, containerRect, insideRect, tolerance) {
     54    // make the container rect bigger with tolerance
     55    var left = containerRect.left - tolerance;
     56    var right = containerRect.right + tolerance;
     57    var top = containerRect.top - tolerance;
     58    var bottom = containerRect.bottom + tolerance;
     59    var pass = left <= insideRect.left && insideRect.right <= right
     60               && top <= insideRect.top && insideRect.bottom <= bottom;
     61    if (!pass)
     62        results.push("FAIL(" + name + ") outside bounding rect was: [" + rectToArray(containerRect).join(", ") + "], and inside was: [" + rectToArray(insideRect).join(", ") + "]");
     63    return pass;
     64}
     65
     66function addPageLevelDebugBox(rect, color) {
     67    var el = document.createElement("div");
     68    el.style.position = "absolute";
     69    el.style.left = rect.left + "px";
     70    el.style.top = rect.top + "px";
     71    el.style.width = rect.width + "px";
     72    el.style.height = rect.height + "px";
     73    el.style.backgroundColor = color;
     74    document.body.appendChild(el);
     75}
     76
     77function testContentToRegionsMapping(tolerance)
     78{
     79    if (tolerance === undefined)
     80        tolerance = 0;
     81       
     82    var debug = isDebugEnabled();
     83    var drawnRegions = {};
     84   
     85    var elements = document.getElementsByClassName("check");
     86    var results = [];
     87    for (var i = 0; i < elements.length; ++i) {
     88        var el = elements[i];
     89        var regionId = el.className.split(" ")[1];
     90        var region = document.getElementById(regionId);
     91        var regionRect = region.getBoundingClientRect();
     92        var contentRect = el.getClientRects();
     93        if (debug && !drawnRegions[regionId]) {
     94            addPageLevelDebugBox(regionRect, "rgba(255,0,0,0.3)");
     95            drawnRegions[regionId] = true;
     96        }
     97        for (var j = 0; j < contentRect.length; ++j) {
     98            var passed = assertRectContains(results, el.className, regionRect, contentRect[j], tolerance);
     99            if (debug)
     100                addPageLevelDebugBox(contentRect[j], passed ? "rgba(0,255,0,0.3)" : "rgba(255,0,255,0.5)");
     101        }
     102    }
     103
     104    document.write("<p>" + (results.length ? results.join("<br />") : "PASS") + "</p>");
     105
     106    return !results.length && !debug;
     107}
  • trunk/LayoutTests/fast/regions/webkit-flow-floats-inside-regions-bounds-expected.txt

    r93627 r95264  
    1212    layer at (0,0) size 300x400
    1313      RenderFlowThread at (0,0) size 300x400
    14         RenderBlock {DIV} at (0,0) size 300x474
    15           RenderBlock {DIV} at (5,5) size 290x464 [border: (1px solid #0000FF)]
    16             RenderBlock {DIV} at (11,11) size 268x442 [border: (1px solid #008000)]
     14        RenderBlock {DIV} at (0,0) size 300x631
     15          RenderBlock {DIV} at (5,5) size 290x621 [border: (1px solid #0000FF)]
     16            RenderBlock {DIV} at (11,11) size 268x599 [border: (1px solid #008000)]
    1717              RenderBlock {P} at (1,17) size 266x36
    1818                RenderText {#text} at (0,0) size 166x36
    1919                  text run at (0,0) width 166: "This line of text should"
    2020                  text run at (0,18) width 155: "not get out of the region."
    21               RenderBlock (floating) {DIV} at (95,69) size 72x37 [border: (1px solid #FF0000)]
     21              RenderBlock (floating) {DIV} at (95,84) size 72x37 [border: (1px solid #FF0000)]
    2222                RenderText {#text} at (1,1) size 44x18
    2323                  text run at (1,1) width 44: "Float 1"
    24               RenderBlock (anonymous) at (1,69) size 266x108
     24              RenderBlock (anonymous) at (1,84) size 266x108
    2525                RenderText {#text} at (0,0) size 266x108
    26                   text run at (0,0) width 94: "This line of"
    27                   text run at (0,18) width 94: "text should not"
    28                   text run at (0,36) width 94: "get out of the"
    29                   text run at (0,54) width 266: "region. This line of text should not get out"
    30                   text run at (0,72) width 266: "of the region. This line of text should not"
    31                   text run at (0,90) width 131: "get out of the region."
    32               RenderBlock {P} at (1,193) size 266x0
    33               RenderBlock {P} at (1,193) size 266x126
    34                 RenderText {#text} at (0,0) size 266x126
     26                  text run at (0,0) width 166: "This line of text should"
     27                  text run at (0,18) width 94: "not get out of"
     28                  text run at (0,36) width 94: "the region."
     29                  text run at (0,54) width 266: "This line of text should not get out of the"
     30                  text run at (0,72) width 266: "region. This line of text should not get out"
     31                  text run at (0,90) width 84: "of the region."
     32              RenderBlock {P} at (1,208) size 266x0
     33              RenderBlock {P} at (1,208) size 266x164
     34                RenderText {#text} at (0,0) size 266x164
    3535                  text run at (0,0) width 266: "This line of text should not get out of the"
    3636                  text run at (0,18) width 266: "region. This line of text should not get out"
    3737                  text run at (0,36) width 266: "of the region. This line of text should not"
    38                   text run at (0,54) width 266: "get out of the region. This line of text"
    39                   text run at (0,72) width 86: "should not"
    40                   text run at (0,90) width 86: "get out of the"
    41                   text run at (0,108) width 44: "region."
    42               RenderBlock {P} at (1,335) size 266x90
    43                 RenderText {#text} at (0,0) size 86x90
    44                   text run at (0,0) width 86: "This line of"
    45                   text run at (0,18) width 86: "text should"
    46                   text run at (0,36) width 86: "not get out of"
    47                   text run at (0,54) width 19: "the"
    48                   text run at (0,72) width 44: "region."
     38                  text run at (0,56) width 86: "get out of the"
     39                  text run at (0,74) width 86: "region. This"
     40                  text run at (0,92) width 86: "line of text"
     41                  text run at (0,110) width 86: "should not"
     42                  text run at (0,128) width 86: "get out of the"
     43                  text run at (0,146) width 44: "region."
     44              RenderBlock {P} at (1,384) size 266x198
     45                RenderText {#text} at (0,0) size 44x198
     46                  text run at (0,0) width 28: "This"
     47                  text run at (0,18) width 23: "line"
     48                  text run at (0,36) width 13: "of"
     49                  text run at (0,54) width 23: "text"
     50                  text run at (0,72) width 42: "should"
     51                  text run at (0,90) width 20: "not"
     52                  text run at (0,108) width 19: "get"
     53                  text run at (0,126) width 20: "out"
     54                  text run at (0,144) width 13: "of"
     55                  text run at (0,162) width 19: "the"
     56                  text run at (0,180) width 44: "region."
    4957  Regions for flow 'flow1'
    5058    RenderRegion {DIV} #region1 with index 0
  • trunk/LayoutTests/fast/regions/webkit-flow-inlines-inside-regions-bounds-expected.txt

    r93627 r95264  
    1212    layer at (0,0) size 300x400
    1313      RenderFlowThread at (0,0) size 300x400
    14         RenderBlock {DIV} at (0,0) size 300x386
    15           RenderBlock {DIV} at (5,5) size 290x376 [border: (1px solid #0000FF)]
    16             RenderBlock {DIV} at (11,11) size 268x354 [border: (1px solid #008000)]
    17               RenderBlock {P} at (1,17) size 266x126
    18                 RenderText {#text} at (0,0) size 266x126
     14        RenderBlock {DIV} at (0,0) size 300x349
     15          RenderBlock {DIV} at (5,5) size 290x339 [border: (1px solid #0000FF)]
     16            RenderBlock {DIV} at (11,11) size 268x317 [border: (1px solid #008000)]
     17              RenderBlock {P} at (1,17) size 266x121
     18                RenderText {#text} at (0,0) size 266x121
    1919                  text run at (0,0) width 166: "This line of text should"
    2020                  text run at (0,18) width 166: "not get out of the region."
    2121                  text run at (0,36) width 166: "This line of text should"
    22                   text run at (0,54) width 166: "not get out of the region."
    23                   text run at (0,72) width 266: "This line of text should not get out of the"
    24                   text run at (0,90) width 266: "region. This line of text should not get out"
    25                   text run at (0,108) width 84: "of the region."
    26               RenderBlock {P} at (1,159) size 266x90
     22                  text run at (0,67) width 266: "not get out of the region. This line of text"
     23                  text run at (0,85) width 266: "should not get out of the region. This line"
     24                  text run at (0,103) width 245: "of text should not get out of the region."
     25              RenderBlock {P} at (1,154) size 266x90
    2726                RenderText {#text} at (0,0) size 266x90
    2827                  text run at (0,0) width 266: "This line of text should not get out of the"
     
    3130                  text run at (0,54) width 266: "get out of the region. This line of text"
    3231                  text run at (0,72) width 201: "should not get out of the region."
    33               RenderBlock {P} at (1,265) size 266x72
    34                 RenderText {#text} at (0,0) size 86x72
    35                   text run at (0,0) width 86: "This line of"
    36                   text run at (0,18) width 86: "text should"
    37                   text run at (0,36) width 86: "not get out of"
    38                   text run at (0,54) width 67: "the region."
     32              RenderBlock {P} at (1,264) size 266x36
     33                RenderText {#text} at (0,0) size 266x36
     34                  text run at (0,0) width 266: "This line of text should not get out of the"
     35                  text run at (0,18) width 44: "region."
    3936  Regions for flow 'flow1'
    4037    RenderRegion {DIV} #region1 with index 0
  • trunk/LayoutTests/fast/regions/webkit-flow-inlines-inside-regions-bounds-vertical-expected.txt

    r93627 r95264  
    1212    layer at (0,0) size 620x180
    1313      RenderFlowThread at (0,0) size 620x180
    14         RenderBlock {DIV} at (0,0) size 584x180
    15           RenderBlock {DIV} at (5,5) size 574x170 [border: (1px solid #0000FF)]
    16             RenderBlock {DIV} at (11,11) size 552x148 [border: (1px solid #008000)]
    17               RenderBlock {P} at (17,1) size 270x146
    18                 RenderText {#text} at (0,0) size 270x146
     14        RenderBlock {DIV} at (0,0) size 605x180
     15          RenderBlock {DIV} at (5,5) size 595x170 [border: (1px solid #0000FF)]
     16            RenderBlock {DIV} at (11,11) size 573x148 [border: (1px solid #008000)]
     17              RenderBlock {P} at (17,1) size 275x146
     18                RenderText {#text} at (0,0) size 275x146
    1919                  text run at (0,0) width 66: "This line"
    2020                  text run at (18,0) width 66: "of text"
     
    2626                  text run at (126,0) width 66: "of text"
    2727                  text run at (144,0) width 66: "should not"
    28                   text run at (162,0) width 66: "get out of"
    29                   text run at (180,0) width 146: "the region. This line of"
    30                   text run at (198,0) width 146: "text should not get out"
    31                   text run at (216,0) width 146: "of the region. This line"
    32                   text run at (234,0) width 146: "of text should not get"
    33                   text run at (252,0) width 108: "out of the region."
    34               RenderBlock {P} at (303,1) size 162x146
     28                  text run at (167,0) width 146: "get out of the region."
     29                  text run at (185,0) width 146: "This line of text should"
     30                  text run at (203,0) width 146: "not get out of the"
     31                  text run at (221,0) width 146: "region. This line of"
     32                  text run at (239,0) width 146: "text should not get out"
     33                  text run at (257,0) width 84: "of the region."
     34              RenderBlock {P} at (308,1) size 162x146
    3535                RenderText {#text} at (0,0) size 162x146
    3636                  text run at (0,0) width 146: "This line of text should"
     
    4343                  text run at (126,0) width 146: "line of text should not"
    4444                  text run at (144,0) width 131: "get out of the region."
    45               RenderBlock {P} at (481,1) size 54x146
    46                 RenderText {#text} at (0,0) size 54x146
    47                   text run at (0,0) width 146: "This line of text should"
    48                   text run at (18,0) width 86: "not get out of"
    49                   text run at (36,0) width 67: "the region."
     45              RenderBlock {P} at (484,1) size 72x146
     46                RenderText {#text} at (0,0) size 72x86
     47                  text run at (0,0) width 86: "This line of"
     48                  text run at (18,0) width 86: "text should"
     49                  text run at (36,0) width 86: "not get out of"
     50                  text run at (54,0) width 67: "the region."
    5051  Regions for flow 'flow1'
    5152    RenderRegion {DIV} #region1 with index 0
  • trunk/LayoutTests/fast/regions/webkit-flow-inlines-inside-regions-bounds-vertical-rl-expected.txt

    r93627 r95264  
    1212    layer at (180,0) size 620x180
    1313      RenderFlowThread at (0,0) size 620x180
    14         RenderBlock {DIV} at (0,0) size 584x180
    15           RenderBlock {DIV} at (5,5) size 574x170 [border: (1px solid #0000FF)]
    16             RenderBlock {DIV} at (11,11) size 552x148 [border: (1px solid #008000)]
    17               RenderBlock {P} at (17,1) size 270x146
    18                 RenderText {#text} at (0,0) size 270x146
     14        RenderBlock {DIV} at (0,0) size 605x180
     15          RenderBlock {DIV} at (5,5) size 595x170 [border: (1px solid #0000FF)]
     16            RenderBlock {DIV} at (11,11) size 573x148 [border: (1px solid #008000)]
     17              RenderBlock {P} at (17,1) size 275x146
     18                RenderText {#text} at (0,0) size 275x146
    1919                  text run at (0,0) width 66: "This line"
    2020                  text run at (18,0) width 66: "of text"
     
    2626                  text run at (126,0) width 66: "of text"
    2727                  text run at (144,0) width 66: "should not"
    28                   text run at (162,0) width 66: "get out of"
    29                   text run at (180,0) width 146: "the region. This line of"
    30                   text run at (198,0) width 146: "text should not get out"
    31                   text run at (216,0) width 146: "of the region. This line"
    32                   text run at (234,0) width 146: "of text should not get"
    33                   text run at (252,0) width 108: "out of the region."
    34               RenderBlock {P} at (303,1) size 162x146
     28                  text run at (167,0) width 146: "get out of the region."
     29                  text run at (185,0) width 146: "This line of text should"
     30                  text run at (203,0) width 146: "not get out of the"
     31                  text run at (221,0) width 146: "region. This line of"
     32                  text run at (239,0) width 146: "text should not get out"
     33                  text run at (257,0) width 84: "of the region."
     34              RenderBlock {P} at (308,1) size 162x146
    3535                RenderText {#text} at (0,0) size 162x146
    3636                  text run at (0,0) width 146: "This line of text should"
     
    4343                  text run at (126,0) width 146: "line of text should not"
    4444                  text run at (144,0) width 131: "get out of the region."
    45               RenderBlock {P} at (481,1) size 54x146
    46                 RenderText {#text} at (0,0) size 54x146
    47                   text run at (0,0) width 146: "This line of text should"
    48                   text run at (18,0) width 86: "not get out of"
    49                   text run at (36,0) width 67: "the region."
     45              RenderBlock {P} at (484,1) size 72x146
     46                RenderText {#text} at (0,0) size 72x86
     47                  text run at (0,0) width 86: "This line of"
     48                  text run at (18,0) width 86: "text should"
     49                  text run at (36,0) width 86: "not get out of"
     50                  text run at (54,0) width 67: "the region."
    5051  Regions for flow 'flow1'
    5152    RenderRegion {DIV} #region1 with index 0
  • trunk/LayoutTests/platform/mac/fast/repaint/japanese-rl-selection-repaint-in-regions-expected.txt

    r93442 r95264  
    1010    layer at (400,0) size 400x400
    1111      RenderFlowThread at (0,0) size 400x400
    12         RenderBlock {DIV} at (0,0) size 480x400
    13           RenderText {#text} at (5,0) size 469x388
     12        RenderBlock {DIV} at (0,0) size 496x400
     13          RenderText {#text} at (5,0) size 485x388
    1414            text run at (5,0) width 381: "\x{305B}\x{3063}\x{304B}\x{304F}\x{898B}\x{3064}\x{3051}\x{305F}\x{3059}\x{3070}\x{3089}\x{3057}\x{3044}\x{8A18}\x{4E8B}\x{304C}\x{3069}\x{3053}"
    1515            text run at (37,0) width 381: "\x{306B}\x{3042}\x{3063}\x{305F}\x{304B}\x{5FD8}\x{308C}\x{3066}\x{3057}\x{307E}\x{3063}\x{305F}\x{7D4C}\x{9A13}\x{306F}\x{3042}\x{308A}\x{307E}"
     
    2424            text run at (325,0) width 381: "\x{30DA}\x{30FC}\x{30B8}\x{306E}\x{30B3}\x{30F3}\x{30C6}\x{30F3}\x{30C4}\x{304B}\x{3089}\x{3082}\x{691C}\x{7D22}\x{3059}\x{308B}\x{3053}\x{3068}"
    2525            text run at (357,0) width 381: "\x{304C}\x{3067}\x{304D}\x{307E}\x{3059}\x{3002}\x{305B}\x{3063}\x{304B}\x{304F}\x{898B}\x{3064}\x{3051}\x{305F}\x{3059}\x{3070}\x{3089}\x{3057}"
    26             text run at (389,0) width 381: "\x{3044}\x{8A18}\x{4E8B}\x{304C}\x{3069}\x{3053}\x{306B}\x{3042}\x{3063}\x{305F}\x{304B}\x{5FD8}\x{308C}\x{3066}\x{3057}\x{307E}\x{3063}\x{305F}"
    27             text run at (421,0) width 388: "\x{7D4C}\x{9A13}\x{306F}\x{3042}\x{308A}\x{307E}\x{3059}\x{304B} \x{306A}\x{3089}\x{30BF}\x{30A4}\x{30C8}\x{30EB}\x{3068}\x{30A2}\x{30C9}\x{30EC}"
    28             text run at (453,0) width 191: "\x{30B9}\x{3060}\x{3051}\x{3067}\x{306A}\x{304F}\x{3001}\x{8A2A}\x{554F}"
     26            text run at (405,0) width 381: "\x{3044}\x{8A18}\x{4E8B}\x{304C}\x{3069}\x{3053}\x{306B}\x{3042}\x{3063}\x{305F}\x{304B}\x{5FD8}\x{308C}\x{3066}\x{3057}\x{307E}\x{3063}\x{305F}"
     27            text run at (437,0) width 388: "\x{7D4C}\x{9A13}\x{306F}\x{3042}\x{308A}\x{307E}\x{3059}\x{304B} \x{306A}\x{3089}\x{30BF}\x{30A4}\x{30C8}\x{30EB}\x{3068}\x{30A2}\x{30C9}\x{30EC}"
     28            text run at (469,0) width 191: "\x{30B9}\x{3060}\x{3051}\x{3067}\x{306A}\x{304F}\x{3001}\x{8A2A}\x{554F}"
    2929  Regions for flow 'thread'
    3030    RenderRegion {DIV} with index 0
  • trunk/Source/WebCore/ChangeLog

    r95262 r95264  
     12011-09-15  Alexandru Chiculita  <achicu@adobe.com>
     2
     3        [CSSRegions] Regions should not slice line box rendering
     4        https://bugs.webkit.org/show_bug.cgi?id=66198
     5
     6        Created a new LayoutState constructor for the RenderFlowThread. It will
     7        set m_isPaginated to true and force a pageHeight if 1. The actual pageHeight is
     8        not used, because pageLogicalHeightForOffset will actually redirect the call
     9        to RenderFlowThread.
     10
     11        Removed some of the duplicate code that calculated the page logical offset.
     12        Added new methods like logicalPageOffset, pageLogicalHeightForOffset,
     13        pageRemainingLogicalHeightForOffset.
     14
     15        There are still some issues related to incremental layout and different region widths.
     16        Those issues will be addressed in different patches.
     17
     18        Reviewed by David Hyatt.
     19
     20        Tests: fast/regions/text-region-breaks.html
     21               fast/regions/text-region-split-horizontal-bt.html
     22               fast/regions/text-region-split-vertical-rl.html
     23               fast/regions/text-region-split-vertical.html
     24               fast/regions/text-region-split.html
     25
     26        * rendering/LayoutState.cpp:
     27        (WebCore::LayoutState::LayoutState):
     28        * rendering/LayoutState.h:
     29        (WebCore::LayoutState::LayoutState):
     30        (WebCore::LayoutState::isPaginated):
     31        * rendering/RenderBlock.cpp:
     32        (WebCore::RenderBlock::positionNewFloats):
     33        (WebCore::RenderBlock::adjustForRegionFittingIfNeeded):
     34        (WebCore::RenderBlock::nextPageLogicalTopExcludingBoundaryPoint):
     35        (WebCore::RenderBlock::nextPageLogicalTopIncludingBoundaryPoint):
     36        (WebCore::inNormalFlow):
     37        (WebCore::RenderBlock::applyBeforeBreak):
     38        (WebCore::RenderBlock::applyAfterBreak):
     39        (WebCore::RenderBlock::logicalPageOffset):
     40        (WebCore::RenderBlock::pageLogicalHeightForOffset):
     41        (WebCore::RenderBlock::pageRemainingLogicalHeightForOffset):
     42        (WebCore::RenderBlock::adjustForUnsplittableChild):
     43        (WebCore::RenderBlock::adjustLinePositionForPagination):
     44        * rendering/RenderBlock.h:
     45        * rendering/RenderFlowThread.cpp:
     46        (WebCore::RenderFlowThread::layout):
     47        (WebCore::RenderFlowThread::regionLogicalHeightForLine):
     48        (WebCore::RenderFlowThread::regionRemainingLogicalHeightForLine):
     49        * rendering/RenderFlowThread.h:
     50        * rendering/RenderView.cpp:
     51        (WebCore::RenderView::pushLayoutState):
     52        * rendering/RenderView.h:
     53        (WebCore::LayoutStateMaintainer::LayoutStateMaintainer):
     54        (WebCore::LayoutStateMaintainer::push):
     55
    1562011-09-15  Kentaro Hara  <haraken@google.com>
    257
  • trunk/Source/WebCore/rendering/LayoutState.cpp

    r94092 r95264  
    2929#include "ColumnInfo.h"
    3030#include "RenderArena.h"
     31#include "RenderFlowThread.h"
    3132#include "RenderInline.h"
    3233#include "RenderLayer.h"
     
    8384    // If we establish a new page height, then cache the offset to the top of the first page.
    8485    // We can compare this later on to figure out what part of the page we're actually on,
    85     if (pageLogicalHeight || m_columnInfo || renderer->isRenderFlowThread()) {
     86    if (pageLogicalHeight || m_columnInfo) {
    8687        m_pageLogicalHeight = pageLogicalHeight;
    8788        m_pageOffset = LayoutSize(m_layoutOffset.width() + renderer->borderLeft() + renderer->paddingLeft(),
     
    104105    m_layoutDelta = m_next->m_layoutDelta;
    105106   
     107    m_isPaginated = m_pageLogicalHeight || m_columnInfo;
     108   
    106109    // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present.
     110}
     111
     112LayoutState::LayoutState(LayoutState* prev, RenderFlowThread* flowThread)
     113    : m_clipped(false)
     114    , m_isPaginated(true)
     115    , m_pageLogicalHeight(1) // Use a fake height here. That value is not important, just needs to be non-zero.
     116    , m_pageLogicalHeightChanged(false)
     117    , m_columnInfo(0)
     118    , m_next(prev)
     119#ifndef NDEBUG
     120    , m_renderer(flowThread)
     121#endif
     122{
    107123}
    108124
    109125LayoutState::LayoutState(RenderObject* root)
    110126    : m_clipped(false)
     127    , m_isPaginated(false)
    111128    , m_pageLogicalHeight(0)
    112129    , m_pageLogicalHeightChanged(false)
  • trunk/Source/WebCore/rendering/LayoutState.h

    r89945 r95264  
    3636class RenderBox;
    3737class RenderObject;
     38class RenderFlowThread;
    3839
    3940class LayoutState {
     
    4243    LayoutState()
    4344        : m_clipped(false)
     45        , m_isPaginated(false)
    4446        , m_pageLogicalHeight(0)
    4547        , m_pageLogicalHeightChanged(false)
     
    5355
    5456    LayoutState(LayoutState*, RenderBox*, const LayoutSize& offset, LayoutUnit pageHeight, bool pageHeightChanged, ColumnInfo*);
     57    LayoutState(LayoutState*, RenderFlowThread*);
    5558    LayoutState(RenderObject*);
    5659
     
    6568    void clearPaginationInformation();
    6669    bool isPaginatingColumns() const { return m_columnInfo; }
    67     bool isPaginated() const { return m_pageLogicalHeight || m_columnInfo; }
     70    bool isPaginated() const { return m_isPaginated; }
    6871   
    6972    // The page logical offset is the object's offset from the top of the page in the page progression
     
    8285public:
    8386    bool m_clipped;
     87    bool m_isPaginated;
    8488    LayoutRect m_clipRect;
    8589   
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r94912 r95264  
    33883388
    33893389            if (!childBox->needsLayout())
    3390                 childBox->markForPaginationRelayoutIfNeeded();;
     3390                childBox->markForPaginationRelayoutIfNeeded();
    33913391            childBox->layoutIfNeeded();
    33923392
     
    35773577        return;
    35783578
    3579     LayoutState* layoutState = renderView->layoutState();
    3580     IntSize delta = layoutState->m_layoutOffset - layoutState->m_pageOffset;
    3581     int offset = isHorizontalWritingMode() ? delta.height() : delta.width();
    3582     LayoutUnit regionWidth = flowThread->regionLogicalWidthForLine(offset + logicalTop);
     3579    LayoutUnit regionWidth = flowThread->regionLogicalWidthForLine(logicalPageOffset() + logicalTop);
    35833580    rightOffset -= flowThread->logicalWidth() - regionWidth;
    35843581}
     
    61106107LayoutUnit RenderBlock::nextPageLogicalTopExcludingBoundaryPoint(LayoutUnit logicalOffset) const
    61116108{
    6112     LayoutState* layoutState = view()->layoutState();
    6113     if (!layoutState->m_pageLogicalHeight)
     6109    LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
     6110    if (!pageLogicalHeight)
    61146111        return logicalOffset;
    61156112   
    61166113    // The logicalOffset is in our coordinate space.  We can add in our pushed offset.
    6117     LayoutUnit pageLogicalHeight = layoutState->m_pageLogicalHeight;
    6118     LayoutSize delta = layoutState->m_layoutOffset - layoutState->m_pageOffset;
    6119     LayoutUnit offset = isHorizontalWritingMode() ? delta.height() : delta.width();
    6120     LayoutUnit remainingLogicalHeight = layoutMod(pageLogicalHeight - layoutMod(offset + logicalOffset, pageLogicalHeight), pageLogicalHeight);
     6114    LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logicalOffset);
    61216115    return logicalOffset + (remainingLogicalHeight ? remainingLogicalHeight : pageLogicalHeight);
    61226116}
     
    61246118LayoutUnit RenderBlock::nextPageLogicalTopIncludingBoundaryPoint(LayoutUnit logicalOffset) const
    61256119{
    6126     LayoutState* layoutState = view()->layoutState();
    6127     if (!layoutState->m_pageLogicalHeight)
     6120    LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
     6121    if (!pageLogicalHeight)
    61286122        return logicalOffset;
    61296123   
    61306124    // The logicalOffset is in our coordinate space.  We can add in our pushed offset.
    6131     LayoutUnit pageLogicalHeight = layoutState->m_pageLogicalHeight;
    6132     LayoutSize delta = layoutState->m_layoutOffset - layoutState->m_pageOffset;
    6133     LayoutUnit offset = isHorizontalWritingMode() ? delta.height() : delta.width();
    6134     LayoutUnit remainingLogicalHeight = layoutMod(pageLogicalHeight - layoutMod(offset + logicalOffset, pageLogicalHeight), pageLogicalHeight);
     6125    LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logicalOffset);
    61356126    return logicalOffset + remainingLogicalHeight;
    61366127}
     
    61396130{
    61406131    RenderBlock* curr = child->containingBlock();
    6141     RenderBlock* initialBlock = child->view();
     6132    RenderView* renderView = child->view();
     6133    RenderBlock* initialBlock = renderView->hasRenderFlowThread() ? static_cast<RenderBlock*>(renderView->currentRenderFlowThread()) : renderView;
    61426134    while (curr && curr != initialBlock) {
    61436135        if (curr->hasColumns())
     
    61556147    bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns();
    61566148    bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->m_pageLogicalHeight; // FIXME: Once columns can print we have to check this.
    6157     bool checkBeforeAlways = (checkColumnBreaks && child->style()->columnBreakBefore() == PBALWAYS) || (checkPageBreaks && child->style()->pageBreakBefore() == PBALWAYS);
     6149    bool checkRegionBreaks = view()->hasRenderFlowThread();
     6150    bool checkBeforeAlways = (checkColumnBreaks && child->style()->columnBreakBefore() == PBALWAYS) || (checkPageBreaks && child->style()->pageBreakBefore() == PBALWAYS)
     6151                             || (checkRegionBreaks && child->style()->regionBreakBefore() == PBALWAYS);
    61586152    if (checkBeforeAlways && inNormalFlow(child)) {
    61596153        if (checkColumnBreaks)
     
    61696163    bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns();
    61706164    bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->m_pageLogicalHeight; // FIXME: Once columns can print we have to check this.
    6171     bool checkAfterAlways = (checkColumnBreaks && child->style()->columnBreakAfter() == PBALWAYS) || (checkPageBreaks && child->style()->pageBreakAfter() == PBALWAYS);
     6165    bool checkRegionBreaks = view()->hasRenderFlowThread();
     6166    bool checkAfterAlways = (checkColumnBreaks && child->style()->columnBreakAfter() == PBALWAYS) || (checkPageBreaks && child->style()->pageBreakAfter() == PBALWAYS)
     6167                            || (checkRegionBreaks && child->style()->regionBreakAfter() == PBALWAYS);
    61726168    if (checkAfterAlways && inNormalFlow(child)) {
    61736169        marginInfo.setMarginAfterQuirk(true); // Cause margins to be discarded for any following content.
     
    61796175}
    61806176
     6177LayoutUnit RenderBlock::logicalPageOffset() const
     6178{
     6179    LayoutState* layoutState = view()->layoutState();
     6180    LayoutSize offsetDelta = layoutState->m_layoutOffset - layoutState->m_pageOffset;
     6181    return isHorizontalWritingMode() ? offsetDelta.height() : offsetDelta.width();
     6182}
     6183
     6184LayoutUnit RenderBlock::pageLogicalHeightForOffset(LayoutUnit offset) const
     6185{
     6186    RenderView* renderView = view();
     6187    if (!renderView->hasRenderFlowThread())
     6188        return renderView->layoutState()->m_pageLogicalHeight;
     6189    return renderView->currentRenderFlowThread()->regionLogicalHeightForLine(logicalPageOffset() + offset);
     6190}
     6191
     6192LayoutUnit RenderBlock::pageRemainingLogicalHeightForOffset(LayoutUnit offset, bool includeBoundaryPoint) const
     6193{
     6194    RenderView* renderView = view();
     6195    offset += logicalPageOffset();
     6196   
     6197    if (!renderView->hasRenderFlowThread()) {
     6198        LayoutUnit pageLogicalHeight = renderView->layoutState()->m_pageLogicalHeight;
     6199        LayoutUnit remainingHeight = pageLogicalHeight - layoutMod(offset, pageLogicalHeight);
     6200        if (includeBoundaryPoint) {
     6201            // If includeBoundaryPoint is true the line exactly on the top edge of a
     6202            // column will act as being part of the previous column.
     6203            remainingHeight = layoutMod(remainingHeight, pageLogicalHeight);
     6204        }
     6205        return remainingHeight;
     6206    }
     6207   
     6208    return renderView->currentRenderFlowThread()->regionRemainingLogicalHeightForLine(offset, includeBoundaryPoint);
     6209}
     6210
    61816211LayoutUnit RenderBlock::adjustForUnsplittableChild(RenderBox* child, LayoutUnit logicalOffset, bool includeMargins)
    61826212{
    6183     bool isUnsplittable = child->isReplaced() || child->hasUnsplittableScrollingOverflow() || child->style()->columnBreakInside() == PBAVOID;
     6213    bool isUnsplittable = child->isReplaced() || child->hasUnsplittableScrollingOverflow() || child->style()->columnBreakInside() == PBAVOID
     6214                            || child->style()->regionBreakInside() == PBAVOID;
    61846215    if (!isUnsplittable)
    61856216        return logicalOffset;
     
    61886219    if (layoutState->m_columnInfo)
    61896220        layoutState->m_columnInfo->updateMinimumColumnHeight(childLogicalHeight);
    6190     LayoutUnit pageLogicalHeight = layoutState->m_pageLogicalHeight;
    6191     if (!pageLogicalHeight || childLogicalHeight > pageLogicalHeight)
     6221    LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
     6222    if (!pageLogicalHeight || (childLogicalHeight > pageLogicalHeight && !view()->hasRenderFlowThread()))
    61926223        return logicalOffset;
    6193     LayoutSize delta = layoutState->m_layoutOffset - layoutState->m_pageOffset;
    6194     LayoutUnit offset = isHorizontalWritingMode() ? delta.height() : delta.width();
    6195     LayoutUnit remainingLogicalHeight = layoutMod(pageLogicalHeight - layoutMod(offset + logicalOffset, pageLogicalHeight), pageLogicalHeight);
     6224    LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logicalOffset);
    61966225    if (remainingLogicalHeight < childLogicalHeight)
    61976226        return logicalOffset + remainingLogicalHeight;
     
    62206249    // Technically if the location we move the line to has a different line width than our old position, then we need to dirty the
    62216250    // line and all following lines.
    6222     LayoutState* layoutState = view()->layoutState();
    6223     LayoutUnit pageLogicalHeight = layoutState->m_pageLogicalHeight;
    62246251    LayoutRect logicalVisualOverflow = lineBox->logicalVisualOverflowRect(lineBox->lineTop(), lineBox->lineBottom());
    62256252    LayoutUnit logicalOffset = min(lineBox->lineTopWithLeading(), logicalVisualOverflow.y());
    62266253    LayoutUnit lineHeight = max(lineBox->lineBottomWithLeading(), logicalVisualOverflow.maxY()) - logicalOffset;
     6254    RenderView* renderView = view();
     6255    LayoutState* layoutState = renderView->layoutState();
    62276256    if (layoutState->m_columnInfo)
    62286257        layoutState->m_columnInfo->updateMinimumColumnHeight(lineHeight);
    62296258    logicalOffset += delta;
    62306259    lineBox->setPaginationStrut(0);
    6231     if (!pageLogicalHeight || lineHeight > pageLogicalHeight)
     6260    LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
     6261    if (!pageLogicalHeight || (lineHeight > pageLogicalHeight && !renderView->hasRenderFlowThread()))
    62326262        return;
    6233     LayoutSize offsetDelta = layoutState->m_layoutOffset - layoutState->m_pageOffset;
    6234     LayoutUnit offset = isHorizontalWritingMode() ? offsetDelta.height() : offsetDelta.width();
    6235     LayoutUnit remainingLogicalHeight = pageLogicalHeight - layoutMod(offset + logicalOffset, pageLogicalHeight);
     6263    const bool includeBoundaryPoint = false;
     6264    LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logicalOffset, includeBoundaryPoint);
    62366265    if (remainingLogicalHeight < lineHeight) {
    62376266        LayoutUnit totalLogicalHeight = lineHeight + max<LayoutUnit>(0, logicalOffset);
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r94877 r95264  
    812812    int applyBeforeBreak(RenderBox* child, int logicalOffset); // If the child has a before break, then return a new yPos that shifts to the top of the next page/column.
    813813    int applyAfterBreak(RenderBox* child, int logicalOffset, MarginInfo& marginInfo); // If the child has an after break, then return a new offset that shifts to the top of the next page/column.
     814
     815    LayoutUnit logicalPageOffset() const;
     816    LayoutUnit pageLogicalHeightForOffset(LayoutUnit offset) const;
     817    LayoutUnit pageRemainingLogicalHeightForOffset(LayoutUnit offset, bool includeBoundaryPoint = true) const;
     818
    814819    LayoutUnit adjustForUnsplittableChild(RenderBox* child, LayoutUnit logicalOffset, bool includeMargins = false); // If the child is unsplittable and can't fit on the current page, return the top of the next page/column.
    815820    void adjustLinePositionForPagination(RootInlineBox*, LayoutUnit& deltaOffset); // Computes a deltaOffset value that put a line at the top of the next page if it doesn't fit on the current page.
  • trunk/Source/WebCore/rendering/RenderFlowThread.cpp

    r93728 r95264  
    301301void RenderFlowThread::layout()
    302302{
    303     CurrentRenderFlowThreadMaintainer currentFlowThreadSetter(this);
    304 
    305303    if (m_regionsInvalidated) {
    306304        m_regionsInvalidated = false;
     
    331329    }
    332330
     331    CurrentRenderFlowThreadMaintainer currentFlowThreadSetter(this);
     332    LayoutStateMaintainer statePusher(view(), this);
    333333    RenderBlock::layout();
     334    statePusher.pop();
    334335}
    335336
     
    515516}
    516517
     518LayoutUnit RenderFlowThread::regionLogicalHeightForLine(LayoutUnit position) const
     519{
     520    RenderRegion* region = renderRegionForLine(position);
     521    if (!region)
     522        return 0;
     523
     524    return isHorizontalWritingMode() ? region->regionRect().height() : region->regionRect().width();
     525}
     526
     527LayoutUnit RenderFlowThread::regionRemainingLogicalHeightForLine(LayoutUnit position, bool includeBoundaryPoint) const
     528{
     529    RenderRegion* region = renderRegionForLine(position);
     530    if (!region)
     531        return 0;
     532
     533    LayoutUnit regionLogicalBottom = isHorizontalWritingMode() ? region->regionRect().maxY() : region->regionRect().maxX();
     534    LayoutUnit remainingHeight = regionLogicalBottom - position;
     535    if (includeBoundaryPoint) {
     536        // If includeBoundaryPoint is true the line exactly on the top edge of a
     537        // region will act as being part of the previous region.
     538        LayoutUnit regionHeight = isHorizontalWritingMode() ? region->regionRect().height() : region->regionRect().width();
     539        remainingHeight = layoutMod(remainingHeight, regionHeight);
     540    }
     541    return remainingHeight;
     542}
    517543
    518544RenderRegion* RenderFlowThread::mapFromFlowToRegion(TransformState& transformState) const
  • trunk/Source/WebCore/rendering/RenderFlowThread.h

    r93728 r95264  
    9999
    100100    LayoutUnit regionLogicalWidthForLine(LayoutUnit position) const;
     101    LayoutUnit regionLogicalHeightForLine(LayoutUnit position) const;
     102    LayoutUnit regionRemainingLogicalHeightForLine(LayoutUnit position, bool includeBoundaryPoint = true) const;
    101103
    102104    bool isRegionFittingEnabled() const { return !m_regionFittingDisableCount; }
  • trunk/Source/WebCore/rendering/RenderView.cpp

    r94889 r95264  
    128128    state.m_pageLogicalHeight = m_pageLogicalHeight;
    129129    state.m_pageLogicalHeightChanged = m_pageLogicalHeightChanged;
     130    state.m_isPaginated = state.m_pageLogicalHeight;
    130131    m_pageLogicalHeightChanged = false;
    131132    m_layoutState = &state;
     
    718719}
    719720
     721void RenderView::pushLayoutState(RenderFlowThread* flowThread)
     722{
     723    m_layoutState = new (renderArena()) LayoutState(m_layoutState, flowThread);
     724}
     725
    720726bool RenderView::shouldDisableLayoutStateForSubtree(RenderObject* renderer) const
    721727{
  • trunk/Source/WebCore/rendering/RenderView.h

    r93627 r95264  
    198198
    199199    // These functions may only be accessed by LayoutStateMaintainer.
     200    void pushLayoutState(RenderFlowThread*);
    200201    bool pushLayoutState(RenderBox* renderer, const LayoutSize& offset, LayoutUnit pageHeight = 0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0)
    201202    {
     
    314315    }
    315316   
     317    LayoutStateMaintainer(RenderView* view, RenderFlowThread* flowThread)
     318        : m_view(view)
     319        , m_disabled(false)
     320        , m_didStart(false)
     321        , m_didEnd(false)
     322        , m_didCreateLayoutState(false)
     323    {
     324        push(flowThread);
     325    }
     326   
    316327    ~LayoutStateMaintainer()
    317328    {
     
    326337        if (m_disabled && m_didCreateLayoutState)
    327338            m_view->disableLayoutState();
     339        m_didStart = true;
     340    }
     341   
     342    void push(RenderFlowThread* flowThread)
     343    {
     344        ASSERT(!m_didStart);
     345        m_view->pushLayoutState(flowThread);
     346        m_didCreateLayoutState = true;
    328347        m_didStart = true;
    329348    }
Note: See TracChangeset for help on using the changeset viewer.