Changeset 161626 in webkit


Ignore:
Timestamp:
Jan 10, 2014 2:38:18 AM (10 years ago)
Author:
abucur@adobe.com
Message:

[CSS Regions] Implement visual overflow computation for inline elements
https://bugs.webkit.org/show_bug.cgi?id=125291

Reviewed by David Hyatt.

Source/WebCore:

The patch implements visual overflow computation for inline elements per region. The algorithm
uses the container region of each root line box to determine the lines in a region generated by
a RenderInline. The overflow of a RenderInline inside a region is the smallest rectangle that fits
all the line boxes belonging to that region.

The patch also correctly flips for writing mode the overflow of a renderer before clipping with it.

Tests: fast/regions/overflow-in-variable-width-regions-inline-bt.html

fast/regions/overflow-in-variable-width-regions-inline-continuation.html
fast/regions/overflow-in-variable-width-regions-inline-lr.html
fast/regions/overflow-in-variable-width-regions-inline-rl.html
fast/regions/overflow-in-variable-width-regions-inline.html

  • rendering/RenderFlowThread.cpp:

(WebCore::RenderFlowThread::objectShouldPaintInFlowRegion):

  • rendering/RenderInline.cpp:

(WebCore::RenderInline::updateAlwaysCreateLineBoxes): Always create line boxes for RenderInline
(WebCore::RenderInline::linesVisualOverflowBoundingBoxInRegion):

  • rendering/RenderInline.h:
  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::calculateClipRects):

  • rendering/RenderRegion.cpp:

(WebCore::RenderRegion::visualOverflowRectForBox):
(WebCore::RenderRegion::visualOverflowRectForBoxForPropagation):

  • rendering/RenderRegion.h:

LayoutTests:

Tests for inline elements overflow correct painting inside regions.

  • fast/regions/overflow-in-variable-width-regions-inline-bt-expected.html: Added.
  • fast/regions/overflow-in-variable-width-regions-inline-bt.html: Added.
  • fast/regions/overflow-in-variable-width-regions-inline-continuation-expected.html: Added.
  • fast/regions/overflow-in-variable-width-regions-inline-continuation.html: Added.
  • fast/regions/overflow-in-variable-width-regions-inline-expected.html: Added.
  • fast/regions/overflow-in-variable-width-regions-inline-lr-expected.html: Added.
  • fast/regions/overflow-in-variable-width-regions-inline-lr.html: Added.
  • fast/regions/overflow-in-variable-width-regions-inline-rl-expected.html: Added.
  • fast/regions/overflow-in-variable-width-regions-inline-rl.html: Added.
  • fast/regions/overflow-in-variable-width-regions-inline.html: Added.
Location:
trunk
Files:
10 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r161623 r161626  
     12014-01-10  Andrei Bucur  <abucur@adobe.com>
     2
     3        [CSS Regions] Implement visual overflow computation for inline elements
     4        https://bugs.webkit.org/show_bug.cgi?id=125291
     5
     6        Reviewed by David Hyatt.
     7
     8        Tests for inline elements overflow correct painting inside regions.
     9
     10        * fast/regions/overflow-in-variable-width-regions-inline-bt-expected.html: Added.
     11        * fast/regions/overflow-in-variable-width-regions-inline-bt.html: Added.
     12        * fast/regions/overflow-in-variable-width-regions-inline-continuation-expected.html: Added.
     13        * fast/regions/overflow-in-variable-width-regions-inline-continuation.html: Added.
     14        * fast/regions/overflow-in-variable-width-regions-inline-expected.html: Added.
     15        * fast/regions/overflow-in-variable-width-regions-inline-lr-expected.html: Added.
     16        * fast/regions/overflow-in-variable-width-regions-inline-lr.html: Added.
     17        * fast/regions/overflow-in-variable-width-regions-inline-rl-expected.html: Added.
     18        * fast/regions/overflow-in-variable-width-regions-inline-rl.html: Added.
     19        * fast/regions/overflow-in-variable-width-regions-inline.html: Added.
     20
    1212014-01-09  Jer Noble  <jer.noble@apple.com>
    222
  • trunk/Source/WebCore/ChangeLog

    r161623 r161626  
     12014-01-10  Andrei Bucur  <abucur@adobe.com>
     2
     3        [CSS Regions] Implement visual overflow computation for inline elements
     4        https://bugs.webkit.org/show_bug.cgi?id=125291
     5
     6        Reviewed by David Hyatt.
     7
     8        The patch implements visual overflow computation for inline elements per region. The algorithm
     9        uses the container region of each root line box to determine the lines in a region generated by
     10        a RenderInline. The overflow of a RenderInline inside a region is the smallest rectangle that fits
     11        all the line boxes belonging to that region.
     12
     13        The patch also correctly flips for writing mode the overflow of a renderer before clipping with it.
     14
     15        Tests: fast/regions/overflow-in-variable-width-regions-inline-bt.html
     16               fast/regions/overflow-in-variable-width-regions-inline-continuation.html
     17               fast/regions/overflow-in-variable-width-regions-inline-lr.html
     18               fast/regions/overflow-in-variable-width-regions-inline-rl.html
     19               fast/regions/overflow-in-variable-width-regions-inline.html
     20
     21        * rendering/RenderFlowThread.cpp:
     22        (WebCore::RenderFlowThread::objectShouldPaintInFlowRegion):
     23        * rendering/RenderInline.cpp:
     24        (WebCore::RenderInline::updateAlwaysCreateLineBoxes): Always create line boxes for RenderInline
     25        (WebCore::RenderInline::linesVisualOverflowBoundingBoxInRegion):
     26        * rendering/RenderInline.h:
     27        * rendering/RenderLayer.cpp:
     28        (WebCore::RenderLayer::calculateClipRects):
     29        * rendering/RenderRegion.cpp:
     30        (WebCore::RenderRegion::visualOverflowRectForBox):
     31        (WebCore::RenderRegion::visualOverflowRectForBoxForPropagation):
     32        * rendering/RenderRegion.h:
     33
    1342014-01-09  Jer Noble  <jer.noble@apple.com>
    235
  • trunk/Source/WebCore/rendering/RenderFlowThread.cpp

    r161553 r161626  
    844844        return false;
    845845   
    846     return object->isBox();
     846    return object->isBox() || object->isRenderInline();
    847847}
    848848
  • trunk/Source/WebCore/rendering/RenderInline.cpp

    r161335 r161626  
    218218        || (checkFonts && (!parentStyle->font().fontMetrics().hasIdenticalAscentDescentAndLineGap(style().font().fontMetrics())
    219219        || parentStyle->lineHeight() != style().lineHeight()))
    220         || (flowThread && flowThread->isRenderNamedFlowThread() && toRenderNamedFlowThread(flowThread)->hasRegionsWithStyling());
     220        || (flowThread && flowThread->isRenderNamedFlowThread()); // FIXME: Enable the optimization once we make overflow computation for culled inlines in regions.
    221221
    222222    if (!alwaysCreateLineBoxes && checkFonts && document().styleSheetCollection().usesFirstLineRules()) {
     
    10411041}
    10421042
     1043LayoutRect RenderInline::linesVisualOverflowBoundingBoxInRegion(const RenderRegion* region) const
     1044{
     1045    ASSERT(alwaysCreateLineBoxes());
     1046    ASSERT(region);
     1047
     1048    if (!firstLineBox() || !lastLineBox())
     1049        return LayoutRect();
     1050
     1051    // Return the width of the minimal left side and the maximal right side.
     1052    LayoutUnit logicalLeftSide = LayoutUnit::max();
     1053    LayoutUnit logicalRightSide = LayoutUnit::min();
     1054    LayoutUnit logicalTop;
     1055    LayoutUnit logicalHeight;
     1056    InlineFlowBox* lastInlineInRegion = 0;
     1057    for (InlineFlowBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) {
     1058        const RootInlineBox& root = curr->root();
     1059        if (root.containingRegion() != region) {
     1060            if (lastInlineInRegion)
     1061                break;
     1062            continue;
     1063        }
     1064
     1065        if (!lastInlineInRegion)
     1066            logicalTop = curr->logicalTopVisualOverflow(root.lineTop());
     1067
     1068        lastInlineInRegion = curr;
     1069
     1070        logicalLeftSide = std::min(logicalLeftSide, curr->logicalLeftVisualOverflow());
     1071        logicalRightSide = std::max(logicalRightSide, curr->logicalRightVisualOverflow());
     1072    }
     1073
     1074    if (!lastInlineInRegion)
     1075        return LayoutRect();
     1076
     1077    logicalHeight = lastInlineInRegion->logicalBottomVisualOverflow(lastInlineInRegion->root().lineBottom()) - logicalTop;
     1078   
     1079    LayoutUnit logicalWidth = logicalRightSide - logicalLeftSide;
     1080   
     1081    LayoutRect rect(logicalLeftSide, logicalTop, logicalWidth, logicalHeight);
     1082    if (!style().isHorizontalWritingMode())
     1083        rect = rect.transposedRect();
     1084    return rect;
     1085}
     1086
    10431087LayoutRect RenderInline::clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const
    10441088{
  • trunk/Source/WebCore/rendering/RenderInline.h

    r161335 r161626  
    5555    IntRect linesBoundingBox() const;
    5656    LayoutRect linesVisualOverflowBoundingBox() const;
     57    LayoutRect linesVisualOverflowBoundingBoxInRegion(const RenderRegion*) const;
    5758
    5859    InlineFlowBox* createAndAppendInlineFlowBox();
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r161570 r161626  
    55005500
    55015501    RenderFlowThread* flowThread = clipRectsContext.region ? clipRectsContext.region->flowThread() : 0;
    5502     if (isSelfPaintingLayer() && flowThread && !renderer().isInFlowRenderFlowThread() && renderBox()) {
    5503         // FIXME: Handle the case where the renderer is not a RenderBox.
    5504         LayoutRect layerBoundsWithVisualOverflow = clipRectsContext.region->visualOverflowRectForBox(renderBox());
     5502    if (isSelfPaintingLayer() && flowThread && !renderer().isInFlowRenderFlowThread()) {
     5503        const RenderBoxModelObject& boxModelObject = toRenderBoxModelObject(renderer());
     5504        LayoutRect layerBoundsWithVisualOverflow = clipRectsContext.region->visualOverflowRectForBox(&boxModelObject);
    55055505
    55065506        // Layers are in physical coordinates so the origin must be moved to the physical top-left of the flowthread.
    5507         if (flowThread->style().isFlippedBlocksWritingMode()) {
     5507        if (&boxModelObject == flowThread && flowThread->style().isFlippedBlocksWritingMode()) {
    55085508            if (flowThread->style().isHorizontalWritingMode())
    55095509                layerBoundsWithVisualOverflow.moveBy(LayoutPoint(0, flowThread->height()));
    55105510            else
    55115511                layerBoundsWithVisualOverflow.moveBy(LayoutPoint(flowThread->width(), 0));
     5512        } else {
     5513            RenderBlock* rendererContainingBlock = boxModelObject.enclosingBox()->isRenderBlock() ? toRenderBlock(boxModelObject.enclosingBox()) : 0;
     5514            if (rendererContainingBlock)
     5515                rendererContainingBlock->flipForWritingMode(layerBoundsWithVisualOverflow);
    55125516        }
    55135517
     
    56615665    // e.g. an absolutely positioned box with bottom:0px and right:0px would have it's frameRect.x relative
    56625666    // to the flow thread, not the last region (in which it will end up because of bottom:0px)
    5663     if (region && renderer().isBox() && renderer().flowThreadContainingBlock()) {
     5667    if (region && renderer().flowThreadContainingBlock()) {
    56645668        LayoutRect b = layerBounds;
    5665         b.moveBy(region->visualOverflowRectForBox(toRenderBox(&renderer())).location());
     5669        b.moveBy(region->visualOverflowRectForBox(toRenderBoxModelObject(&renderer())).location());
    56665670        b.inflate(renderer().view().maximalOutlineSize());
    56675671        if (b.intersects(damageRect))
  • trunk/Source/WebCore/rendering/RenderRegion.cpp

    r161553 r161626  
    3939#include "Range.h"
    4040#include "RenderBoxRegionInfo.h"
     41#include "RenderInline.h"
    4142#include "RenderIterator.h"
    4243#include "RenderLayer.h"
     
    561562}
    562563
    563 LayoutRect RenderRegion::visualOverflowRectForBox(const RenderBox* box)
    564 {
    565     RefPtr<RenderOverflow> overflow;
    566     ensureOverflowForBox(box, overflow, true);
    567    
    568     ASSERT(overflow);
    569     return overflow->visualOverflowRect();
     564LayoutRect RenderRegion::visualOverflowRectForBox(const RenderBoxModelObject* box)
     565{
     566    if (box->isRenderInline()) {
     567        const RenderInline* inlineBox = toRenderInline(box);
     568        return inlineBox->linesVisualOverflowBoundingBoxInRegion(this);
     569    }
     570
     571    if (box->isBox()) {
     572        RefPtr<RenderOverflow> overflow;
     573        ensureOverflowForBox(toRenderBox(box), overflow, true);
     574
     575        ASSERT(overflow);
     576        return overflow->visualOverflowRect();
     577    }
     578
     579    ASSERT_NOT_REACHED();
     580    return LayoutRect();
    570581}
    571582
     
    591602}
    592603
    593 LayoutRect RenderRegion::visualOverflowRectForBoxForPropagation(const RenderBox* box)
     604LayoutRect RenderRegion::visualOverflowRectForBoxForPropagation(const RenderBoxModelObject* box)
    594605{
    595606    LayoutRect rect = visualOverflowRectForBox(box);
  • trunk/Source/WebCore/rendering/RenderRegion.h

    r161553 r161626  
    121121    void addVisualOverflowForBox(const RenderBox*, const LayoutRect&);
    122122    LayoutRect layoutOverflowRectForBox(const RenderBox*);
    123     LayoutRect visualOverflowRectForBox(const RenderBox*);
     123    LayoutRect visualOverflowRectForBox(const RenderBoxModelObject*);
    124124    LayoutRect layoutOverflowRectForBoxForPropagation(const RenderBox*);
    125     LayoutRect visualOverflowRectForBoxForPropagation(const RenderBox*);
     125    LayoutRect visualOverflowRectForBoxForPropagation(const RenderBoxModelObject*);
    126126
    127127    LayoutRect rectFlowPortionForBox(const RenderBox*, const LayoutRect&) const;
Note: See TracChangeset for help on using the changeset viewer.