Changeset 142984 in webkit


Ignore:
Timestamp:
Feb 15, 2013 5:00:03 AM (11 years ago)
Author:
mihnea@adobe.com
Message:

[CSS Regions] RenderRegion should inherit from RenderBlock
https://bugs.webkit.org/show_bug.cgi?id=74132

Reviewed by Julien Chaffraix.

Source/WebCore:

Change the base class for RenderRegion to be RenderBlock instead of RenderReplaced.
Per spec http://dev.w3.org/csswg/css3-regions/#the-flow-from-property, a region is a non-replaced block container.
This change is covered by the existing regions tests (in fast/region and fast/repaint).

The RenderFlowThread object is a self-painting layer (it requires layer and is positioned).
Because of that, the RenderFlowThread object is responsible for painting its children,
the collected objects. When the RenderRegion::paintObject is called during paint, it delegates painting
of content collected inside the flow thread to the associated RenderFlowThread object.
Since we do not want to paint the flow thread content multiple times (for each paint phase
in which the RenderRegion::paintObject is called), we allow RenderFlowThread painting only for
selection and foreground paint phases.

  • rendering/RenderBox.cpp: Clean-up the code from regions specific stuff, now that the regions are render blocks.

(WebCore::RenderBox::computePositionedLogicalWidth):
(WebCore::RenderBox::computePositionedLogicalHeight):

  • rendering/RenderLayerBacking.cpp: A region should always render content from its associated flow thread,

even when it does not have children of its own.
(WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer):

  • rendering/RenderMultiColumnSet.cpp: Make changes to match the new inheritance for RenderRegion.

(WebCore::RenderMultiColumnSet::paint):
(WebCore::RenderMultiColumnSet::paintColumnRules):

  • rendering/RenderMultiColumnSet.h:
  • rendering/RenderRegion.cpp:

(WebCore::RenderRegion::RenderRegion):
(WebCore::RenderRegion::paintObject):
(WebCore::RenderRegion::styleDidChange):
(WebCore::RenderRegion::layoutBlock):
(WebCore::RenderRegion::insertedIntoTree):
(WebCore::RenderRegion::willBeRemovedFromTree):
(WebCore::RenderRegion::computePreferredLogicalWidths): Use this method instead of min/maxPreferredLogicalWidth.
(WebCore::RenderRegion::updateLogicalHeight):

  • rendering/RenderRegion.h: For now, assume the region is not allowed to have children.

When we will implement the processing model for pseudo-elements http://dev.w3.org/csswg/css3-regions/#processing-model,
we will have to remove this function. By having this function return false i was able to leave some tests unchanged.

LayoutTests:

Fix tests that were failing after the inheritance change.

  • fast/regions/flows-dependency-dynamic-remove.html: As a block, an empty region can self collapse,

which was not possible for a replaced element. I used '-webkit-margin-collapse: separate' to prevent
margins self collapsing for body and avoid recreating the expectations.
I want regions margins to be able to self collapse, just like the other block elements.

  • fast/regions/flows-dependency-same-flow.html: Ditto.
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r142983 r142984  
     12013-02-15  Mihnea Ovidenie  <mihnea@adobe.com>
     2
     3        [CSS Regions] RenderRegion should inherit from RenderBlock
     4        https://bugs.webkit.org/show_bug.cgi?id=74132
     5
     6        Reviewed by Julien Chaffraix.
     7
     8        Fix tests that were failing after the inheritance change.
     9
     10        * fast/regions/flows-dependency-dynamic-remove.html: As a block, an empty region can self collapse,
     11        which was not possible for a replaced element. I used '-webkit-margin-collapse: separate' to prevent
     12        margins self collapsing for body and avoid recreating the expectations.
     13        I want regions margins to be able to self collapse, just like the other block elements.
     14        * fast/regions/flows-dependency-same-flow.html: Ditto.
     15
    1162013-02-15  Andrey Lushnikov  <lushnikov@chromium.org>
    217
  • trunk/LayoutTests/fast/regions/flows-dependency-dynamic-remove.html

    r128155 r142984  
    22
    33<style>
     4body { -webkit-margin-collapse: separate; }
     5
    46.flowA { -webkit-flow-into: flowA; }
    57.flowB { -webkit-flow-into: flowB; }
  • trunk/LayoutTests/fast/regions/flows-dependency-same-flow.html

    r128155 r142984  
    22
    33<style>
     4body { -webkit-margin-collapse: separate; }
     5
    46.flowA { -webkit-flow-into: flowA; }
    57.flowB { -webkit-flow-into: flowB; }
  • trunk/Source/WebCore/ChangeLog

    r142983 r142984  
     12013-02-15  Mihnea Ovidenie  <mihnea@adobe.com>
     2
     3        [CSS Regions] RenderRegion should inherit from RenderBlock
     4        https://bugs.webkit.org/show_bug.cgi?id=74132
     5
     6        Reviewed by Julien Chaffraix.
     7
     8        Change the base class for RenderRegion to be RenderBlock instead of RenderReplaced.
     9        Per spec http://dev.w3.org/csswg/css3-regions/#the-flow-from-property, a region is a non-replaced block container.
     10        This change is covered by the existing regions tests (in fast/region and fast/repaint).
     11
     12        The RenderFlowThread object is a self-painting layer (it requires layer and is positioned).
     13        Because of that, the RenderFlowThread object is responsible for painting its children,
     14        the collected objects. When the RenderRegion::paintObject is called during paint, it delegates painting
     15        of content collected inside the flow thread to the associated RenderFlowThread object.
     16        Since we do not want to paint the flow thread content multiple times (for each paint phase
     17        in which the RenderRegion::paintObject is called), we allow RenderFlowThread painting only for
     18        selection and foreground paint phases.
     19
     20        * rendering/RenderBox.cpp: Clean-up the code from regions specific stuff, now that the regions are render blocks.
     21        (WebCore::RenderBox::computePositionedLogicalWidth):
     22        (WebCore::RenderBox::computePositionedLogicalHeight):
     23        * rendering/RenderLayerBacking.cpp: A region should always render content from its associated flow thread,
     24        even when it does not have children of its own.
     25        (WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer):
     26        * rendering/RenderMultiColumnSet.cpp: Make changes to match the new inheritance for RenderRegion.
     27        (WebCore::RenderMultiColumnSet::paint):
     28        (WebCore::RenderMultiColumnSet::paintColumnRules):
     29        * rendering/RenderMultiColumnSet.h:
     30        * rendering/RenderRegion.cpp:
     31        (WebCore::RenderRegion::RenderRegion):
     32        (WebCore::RenderRegion::paintObject):
     33        (WebCore::RenderRegion::styleDidChange):
     34        (WebCore::RenderRegion::layoutBlock):
     35        (WebCore::RenderRegion::insertedIntoTree):
     36        (WebCore::RenderRegion::willBeRemovedFromTree):
     37        (WebCore::RenderRegion::computePreferredLogicalWidths): Use this method instead of min/maxPreferredLogicalWidth.
     38        (WebCore::RenderRegion::updateLogicalHeight):
     39        * rendering/RenderRegion.h: For now, assume the region is not allowed to have children.
     40        When we will implement the processing model for pseudo-elements http://dev.w3.org/csswg/css3-regions/#processing-model,
     41        we will have to remove this function. By having this function return false i was able to leave some tests unchanged.
     42
    1432013-02-15  Andrey Lushnikov  <lushnikov@chromium.org>
    244
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r142962 r142984  
    29262926{
    29272927    if (isReplaced()) {
    2928         // FIXME: For regions with width auto, we want to compute width using the normal block sizing code.
    2929         // For now, regions are replaced elements and this code can be removed once the RenderRegion
    2930         // will inherit from RenderBlock instead of RenderReplaced.
    2931         // (see https://bugs.webkit.org/show_bug.cgi?id=74132 )
    2932         if (!isRenderRegion() || (isRenderRegion() && shouldComputeSizeAsReplaced())) {
    2933             computePositionedLogicalWidthReplaced(computedValues); // FIXME: Patch for regions when we add replaced element support.
    2934             return;
    2935         }
     2928        // FIXME: Positioned replaced elements inside a flow thread are not working properly
     2929        // with variable width regions (see https://bugs.webkit.org/show_bug.cgi?id=69896 ).
     2930        computePositionedLogicalWidthReplaced(computedValues);
     2931        return;
    29362932    }
    29372933
     
    32763272{
    32773273    if (isReplaced()) {
    3278         // FIXME: For regions with height auto, we want to compute width using the normal block sizing code.
    3279         // For now, regions are replaced elements and this code can be removed once the RenderRegion
    3280         // will inherit from RenderBlock instead of RenderReplaced.
    3281         // (see https://bugs.webkit.org/show_bug.cgi?id=74132 )
    3282         if (!isRenderRegion() || (isRenderRegion() && shouldComputeSizeAsReplaced())) {
    3283             computePositionedLogicalHeightReplaced(computedValues);
    3284             return;
    3285         }
     3274        computePositionedLogicalHeightReplaced(computedValues);
     3275        return;
    32863276    }
    32873277
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r142815 r142984  
    14011401    if (paintsBoxDecorations() || paintsChildren())
    14021402        return false;
    1403    
     1403
     1404    if (renderObject->isRenderRegion())
     1405        return false;
     1406
    14041407    if (renderObject->node() && renderObject->node()->isDocumentNode()) {
    14051408        // Look to see if the root object has a non-simple background
  • trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp

    r140244 r142984  
    2929#include "HitTestResult.h"
    3030#include "PaintInfo.h"
     31#include "RenderMultiColumnBlock.h"
    3132#include "RenderMultiColumnFlowThread.h"
    32 #include "RenderMultiColumnBlock.h"
    3333
    3434using std::min;
     
    206206}
    207207
    208 void RenderMultiColumnSet::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
     208void RenderMultiColumnSet::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    209209{
    210210    // FIXME: RenderRegions are replaced elements right now and so they only paint in the foreground phase.
     
    259259            currLogicalLeftOffset -= (inlineDirectionSize + colGap);
    260260        }
    261        
     261
    262262        // Now paint the column rule.
    263263        if (i < colCount - 1) {
  • trunk/Source/WebCore/rendering/RenderMultiColumnSet.h

    r140640 r142984  
    9595    virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues&) const OVERRIDE;
    9696
    97     virtual void paintReplaced(PaintInfo&, const LayoutPoint& paintOffset) OVERRIDE;
     97    virtual void paint(PaintInfo&, const LayoutPoint& paintOffset) OVERRIDE;
    9898    virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
    9999
  • trunk/Source/WebCore/rendering/RenderRegion.cpp

    r140948 r142984  
    3535#include "HitTestResult.h"
    3636#include "IntRect.h"
     37#include "LayoutRepainter.h"
    3738#include "PaintInfo.h"
    3839#include "Range.h"
     
    4546
    4647RenderRegion::RenderRegion(Element* element, RenderFlowThread* flowThread)
    47     : RenderReplaced(element, IntSize())
     48    : RenderBlock(element)
    4849    , m_flowThread(flowThread)
    4950    , m_parentNamedFlowThread(0)
     
    136137}
    137138
    138 void RenderRegion::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    139 {
     139void RenderRegion::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
     140{
     141    if (style()->visibility() != VISIBLE)
     142        return;
     143
     144    RenderBlock::paintObject(paintInfo, paintOffset);
     145
    140146    // Delegate painting of content in region to RenderFlowThread.
    141     if (!m_flowThread || !isValid())
     147    // RenderFlowThread is a self painting layer (being a positioned object) who is painting its children, the collected objects.
     148    // Since we do not want to paint the flow thread content multiple times (for each painting phase of the region object),
     149    // we allow the flow thread painting only for the selection and the foreground phase.
     150    if (!m_flowThread || !isValid() || (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection))
    142151        return;
    143152
     
    224233void RenderRegion::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
    225234{
    226     RenderReplaced::styleDidChange(diff, oldStyle);
     235    RenderBlock::styleDidChange(diff, oldStyle);
    227236
    228237    // If the region is not attached to any thread, there is no need to check
     
    238247}
    239248
    240 void RenderRegion::layout()
     249void RenderRegion::layoutBlock(bool relayoutChildren, LayoutUnit)
    241250{
    242251    StackStats::LayoutCheckPoint layoutCheckPoint;
    243     RenderReplaced::layout();
     252    RenderBlock::layoutBlock(relayoutChildren);
     253
    244254    if (m_flowThread && isValid()) {
    245255        LayoutRect oldRegionRect(flowThreadPortionRect());
     
    484494void RenderRegion::insertedIntoTree()
    485495{
    486     RenderReplaced::insertedIntoTree();
     496    RenderBlock::insertedIntoTree();
    487497
    488498    attachRegion();
     
    491501void RenderRegion::willBeRemovedFromTree()
    492502{
    493     RenderReplaced::willBeRemovedFromTree();
     503    RenderBlock::willBeRemovedFromTree();
    494504
    495505    detachRegion();
     
    571581}
    572582
    573 // FIXME: when RenderRegion will inherit from RenderBlock instead of RenderReplaced,
    574 // we should overwrite computePreferredLogicalWidths ( see https://bugs.webkit.org/show_bug.cgi?id=74132 )
    575 LayoutUnit RenderRegion::minPreferredLogicalWidth() const
    576 {
    577     if (!m_flowThread || !m_isValid)
    578         return RenderReplaced::minPreferredLogicalWidth();
    579 
    580     // FIXME: Currently, the code handles only the <length> case for min-width. It should also support other values, like percentage, calc
    581     // or viewport relative.
     583void RenderRegion::computePreferredLogicalWidths()
     584{
     585    ASSERT(preferredLogicalWidthsDirty());
     586    if (!m_flowThread || !m_isValid) {
     587        RenderBlock::computePreferredLogicalWidths();
     588        return;
     589    }
     590
     591    // FIXME: Currently, the code handles only the <length> case for min-width/max-width.
     592    // It should also support other values, like percentage, calc or viewport relative.
     593    m_minPreferredLogicalWidth = m_flowThread->minPreferredLogicalWidth();
     594    m_maxPreferredLogicalWidth = m_flowThread->maxPreferredLogicalWidth();
     595
    582596    RenderStyle* styleToUse = style();
    583     LayoutUnit minPreferredLogicalWidth = m_flowThread->minPreferredLogicalWidth();
    584 
    585     if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth().value() > 0)
    586         minPreferredLogicalWidth = std::max(minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value()));
    587 
    588     if (styleToUse->logicalMaxWidth().isFixed())
    589         minPreferredLogicalWidth = std::min(minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value()));
    590 
    591     return minPreferredLogicalWidth + borderAndPaddingLogicalWidth();
    592 }
    593 
    594 LayoutUnit RenderRegion::maxPreferredLogicalWidth() const
    595 {
    596     if (!m_flowThread || !m_isValid)
    597         return RenderReplaced::maxPreferredLogicalWidth();
    598 
    599     // FIXME: Currently, the code handles only the <length> case for max-width. It should also support other values, like percentage, calc
    600     // or viewport relative.
    601     RenderStyle* styleToUse = style();
    602     LayoutUnit maxPreferredLogicalWidth = m_flowThread->maxPreferredLogicalWidth();
    603 
    604     if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth().value() > 0)
    605         maxPreferredLogicalWidth = std::max(maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value()));
    606 
    607     if (styleToUse->logicalMaxWidth().isFixed())
    608         maxPreferredLogicalWidth = std::min(maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value()));
    609 
    610     return maxPreferredLogicalWidth + borderAndPaddingLogicalWidth();
     597    if (styleToUse->logicalMaxWidth().isFixed()) {
     598        m_minPreferredLogicalWidth = std::min(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value()));
     599        m_maxPreferredLogicalWidth = std::min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value()));
     600    }
     601
     602    LayoutUnit borderAndPadding = borderAndPaddingLogicalWidth();
     603    m_minPreferredLogicalWidth += borderAndPadding;
     604    m_maxPreferredLogicalWidth += borderAndPadding;
     605    setPreferredLogicalWidthsDirty(false);
    611606}
    612607
     
    619614void RenderRegion::updateLogicalHeight()
    620615{
    621     RenderReplaced::updateLogicalHeight();
     616    RenderBlock::updateLogicalHeight();
    622617
    623618    if (!hasAutoLogicalHeight())
  • trunk/Source/WebCore/rendering/RenderRegion.h

    r140948 r142984  
    3131#define RenderRegion_h
    3232
    33 #include "RenderReplaced.h"
     33#include "RenderBlock.h"
    3434#include "StyleInheritedData.h"
    3535
     
    4141class RenderNamedFlowThread;
    4242
    43 class RenderRegion : public RenderReplaced {
     43class RenderRegion : public RenderBlock {
    4444public:
    4545    explicit RenderRegion(Element*, RenderFlowThread*);
     
    4747    virtual bool isRenderRegion() const { return true; }
    4848
    49     virtual void paintReplaced(PaintInfo&, const LayoutPoint&);
    5049    virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
    5150
     
    6867    bool hasCustomRegionStyle() const { return m_hasCustomRegionStyle; }
    6968    void setHasCustomRegionStyle(bool hasCustomRegionStyle) { m_hasCustomRegionStyle = hasCustomRegionStyle; }
    70 
    71     virtual void layout();
    7269
    7370    RenderBoxRegionInfo* renderBoxRegionInfo(const RenderBox*) const;
     
    10198    LayoutUnit maxPageLogicalHeight() const;
    10299
    103     virtual LayoutUnit minPreferredLogicalWidth() const OVERRIDE;
    104     virtual LayoutUnit maxPreferredLogicalWidth() const OVERRIDE;
     100    virtual void computePreferredLogicalWidths() OVERRIDE;
    105101   
    106102    LayoutUnit logicalTopOfFlowThreadContentRect(const LayoutRect&) const;
     
    143139    virtual const char* renderName() const { return "RenderRegion"; }
    144140
    145     // FIXME: these functions should be revisited once RenderRegion inherits from RenderBlock
    146     // instead of RenderReplaced (see https://bugs.webkit.org/show_bug.cgi?id=74132 )
    147     // When width is auto, use normal block/box sizing code except when inline.
    148     virtual bool isInlineBlockOrInlineTable() const OVERRIDE { return isInline() && !shouldComputeSizeAsReplaced(); }
    149     virtual bool shouldComputeSizeAsReplaced() const OVERRIDE { return !style()->logicalWidth().isAuto() && !style()->logicalHeight().isAuto(); }
     141    virtual bool canHaveChildren() const OVERRIDE { return false; }
    150142
    151143    bool shouldHaveAutoLogicalHeight() const
     
    158150    virtual void insertedIntoTree() OVERRIDE;
    159151    virtual void willBeRemovedFromTree() OVERRIDE;
     152
     153    virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) OVERRIDE;
     154    virtual void paintObject(PaintInfo&, const LayoutPoint&) OVERRIDE;
    160155
    161156    virtual void installFlowThread();
Note: See TracChangeset for help on using the changeset viewer.