⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 176354 in webkit


Ignore:
Timestamp:
Nov 19, 2014, 3:40:23 PM (12 years ago)
Author:
hyatt@apple.com
Message:

Images/replaced elements that are as tall as a page should be on their own page
https://bugs.webkit.org/show_bug.cgi?id=138886 - <rdar://problem/18296371>

Reviewed by Dean Jackson.

Source/WebCore:

Added fast/multicol/tall-image-behavior.html (and RL/LR variants)

  • rendering/InlineFlowBox.cpp:

(WebCore::InlineFlowBox::computeReplacedAndTextLineTopAndBottom):

  • rendering/InlineFlowBox.h:

Add a new method that computes the line top and line bottom ignoring all margins,
overflow and line-height. This allows us to see if a line that is taller than a page
can be made to fit if we ignored margins and unused descent.

  • rendering/RenderBlockFlow.cpp:

(WebCore::RenderBlockFlow::adjustLinePositionForPagination):
Call the new helper function, computeReplacedAndTextLineTopAndBottom and push
to a new page if we see that we can fit on a page by ourselves without blank space
included.

LayoutTests:

  • fast/multicol/tall-image-behavior-lr.html: Added.
  • fast/multicol/tall-image-behavior-rl.html: Added.
  • fast/multicol/tall-image-behavior.html: Added.
  • platform/mac/fast/multicol/tall-image-behavior-expected.png: Added.
  • platform/mac/fast/multicol/tall-image-behavior-expected.txt: Added.
  • platform/mac/fast/multicol/tall-image-behavior-lr-expected.png: Added.
  • platform/mac/fast/multicol/tall-image-behavior-lr-expected.txt: Added.
  • platform/mac/fast/multicol/tall-image-behavior-rl-expected.png: Added.
  • platform/mac/fast/multicol/tall-image-behavior-rl-expected.txt: Added.
Location:
trunk
Files:
9 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r176350 r176354  
     12014-11-19  David Hyatt  <hyatt@apple.com>
     2
     3        Images/replaced elements that are as tall as a page should be on their own page
     4        https://bugs.webkit.org/show_bug.cgi?id=138886 - <rdar://problem/18296371>
     5
     6        Reviewed by Dean Jackson.
     7
     8        * fast/multicol/tall-image-behavior-lr.html: Added.
     9        * fast/multicol/tall-image-behavior-rl.html: Added.
     10        * fast/multicol/tall-image-behavior.html: Added.
     11        * platform/mac/fast/multicol/tall-image-behavior-expected.png: Added.
     12        * platform/mac/fast/multicol/tall-image-behavior-expected.txt: Added.
     13        * platform/mac/fast/multicol/tall-image-behavior-lr-expected.png: Added.
     14        * platform/mac/fast/multicol/tall-image-behavior-lr-expected.txt: Added.
     15        * platform/mac/fast/multicol/tall-image-behavior-rl-expected.png: Added.
     16        * platform/mac/fast/multicol/tall-image-behavior-rl-expected.txt: Added.
     17
    1182014-11-18  Ada Chan  <adachan@apple.com>
    219
  • trunk/Source/WebCore/ChangeLog

    r176350 r176354  
     12014-11-19  David Hyatt  <hyatt@apple.com>
     2
     3        Images/replaced elements that are as tall as a page should be on their own page
     4        https://bugs.webkit.org/show_bug.cgi?id=138886 - <rdar://problem/18296371>
     5
     6        Reviewed by Dean Jackson.
     7
     8        Added fast/multicol/tall-image-behavior.html (and RL/LR variants)
     9
     10        * rendering/InlineFlowBox.cpp:
     11        (WebCore::InlineFlowBox::computeReplacedAndTextLineTopAndBottom):
     12        * rendering/InlineFlowBox.h:
     13        Add a new method that computes the line top and line bottom ignoring all margins,
     14        overflow and line-height. This allows us to see if a line that is taller than a page
     15        can be made to fit if we ignored margins and unused descent.
     16
     17        * rendering/RenderBlockFlow.cpp:
     18        (WebCore::RenderBlockFlow::adjustLinePositionForPagination):
     19        Call the new helper function, computeReplacedAndTextLineTopAndBottom and push
     20        to a new page if we see that we can fit on a page by ourselves without blank space
     21        included.
     22
    1232014-11-18  Ada Chan  <adachan@apple.com>
    224
  • trunk/Source/WebCore/rendering/InlineFlowBox.cpp

    r174840 r176354  
    16371637}
    16381638
     1639void InlineFlowBox::computeReplacedAndTextLineTopAndBottom(LayoutUnit& lineTop, LayoutUnit& lineBottom) const
     1640{
     1641    for (const auto* box = firstChild(); box; box = box->nextOnLine()) {
     1642        if (is<InlineFlowBox>(*box))
     1643            downcast<InlineFlowBox>(*box).computeReplacedAndTextLineTopAndBottom(lineTop, lineBottom);
     1644        else {
     1645            if (box->logicalTop() < lineTop)
     1646                lineTop = box->logicalTop();
     1647            if (box->logicalBottom() > lineBottom)
     1648                lineBottom = box->logicalBottom();
     1649        }
     1650    }
     1651}
     1652
    16391653#ifndef NDEBUG
    16401654
  • trunk/Source/WebCore/rendering/InlineFlowBox.h

    r174746 r176354  
    292292    }
    293293
     294    void computeReplacedAndTextLineTopAndBottom(LayoutUnit& lineTop, LayoutUnit& lineBottom) const;
     295   
    294296private:
    295297    virtual bool isInlineFlowBox() const override final { return true; }
  • trunk/Source/WebCore/rendering/RenderBlockFlow.cpp

    r176285 r176354  
    16411641    // If lineHeight is greater than pageLogicalHeight, but logicalVisualOverflow.height() still fits, we are
    16421642    // still going to add a strut, so that the visible overflow fits on a single page.
    1643     if (!pageLogicalHeight || (hasUniformPageLogicalHeight && logicalVisualOverflow.height() > pageLogicalHeight)
    1644         || !hasNextPage(logicalOffset))
     1643    if (!pageLogicalHeight || !hasNextPage(logicalOffset)) {
    16451644        // FIXME: In case the line aligns with the top of the page (or it's slightly shifted downwards) it will not be marked as the first line in the page.
    16461645        // From here, the fix is not straightforward because it's not easy to always determine when the current line is the first in the page.
    16471646        return;
     1647    }
     1648
     1649    if (hasUniformPageLogicalHeight && logicalVisualOverflow.height() > pageLogicalHeight) {
     1650        // We are so tall that we are bigger than a page. Before we give up and just leave the line where it is, try drilling into the
     1651        // line and computing a new height that excludes anything we consider "blank space". We will discard margins, descent, and even overflow. If we are
     1652        // able to fit with the blank space and overflow excluded, we will give the line its own page with the highest non-blank element being aligned with the
     1653        // top of the page.
     1654        // FIXME: We are still honoring gigantic margins, which does leave open the possibility of blank pages caused by this heuristic. It remains to be seen whether or not
     1655        // this will be a real-world issue. For now we don't try to deal with this problem.
     1656        logicalOffset = intMaxForLayoutUnit;
     1657        logicalBottom = intMinForLayoutUnit;
     1658        lineBox->computeReplacedAndTextLineTopAndBottom(logicalOffset, logicalBottom);
     1659        lineHeight = logicalBottom - logicalOffset;
     1660        if (logicalOffset == intMaxForLayoutUnit || lineHeight > pageLogicalHeight)
     1661            return; // Give up. We're genuinely too big even after excluding blank space and overflow.
     1662        pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
     1663    }
     1664   
    16481665    LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logicalOffset, ExcludePageBoundary);
    16491666    overflowsRegion = (lineHeight > remainingLogicalHeight);
Note: See TracChangeset for help on using the changeset viewer.