Changeset 93627 in webkit


Ignore:
Timestamp:
Aug 23, 2011 12:44:43 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

[CSSRegions] RenderFlowThread layout should use the attached region sizes
https://bugs.webkit.org/show_bug.cgi?id=66143

Source/WebCore:

When RenderFlowThread is doing the layout it also sets the current RenderFlowThread on
the RenderView. RenderFlowThread cannot be nested inside a single RenderView, so there's no
need to put that on the LayoutState.

The right offset used to layout the inlines inside a RenderFlowThread
is now adjusted to fit inside the current region.

Patch by Alexandru Chiculita <Alexandru Chiculita> on 2011-08-23
Reviewed by David Hyatt.

Tests: fast/regions/webkit-flow-floats-inside-regions-bounds.html

fast/regions/webkit-flow-inlines-inside-regions-bounds-vertical-rl.html
fast/regions/webkit-flow-inlines-inside-regions-bounds-vertical.html
fast/regions/webkit-flow-inlines-inside-regions-bounds.html

  • rendering/LayoutState.cpp:

(WebCore::LayoutState::LayoutState):

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::layoutBlock):
(WebCore::RenderBlock::adjustForRegionFittingIfNeeded):
(WebCore::RenderBlock::logicalRightOffsetForLine):

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

(WebCore::RenderFlowThread::RenderFlowThread):
(WebCore::CurrentRenderFlowThreadMaintainer::CurrentRenderFlowThreadMaintainer):
(WebCore::CurrentRenderFlowThreadMaintainer::~CurrentRenderFlowThreadMaintainer):
(WebCore::RenderFlowThread::layout):
(WebCore::RenderFlowThread::renderRegionForLine):
(WebCore::RenderFlowThread::regionLogicalWidthForLine):

  • rendering/RenderFlowThread.h:

(WebCore::RegionFittingDisabler::RegionFittingDisabler):
(WebCore::RegionFittingDisabler::~RegionFittingDisabler):

  • rendering/RenderRegion.cpp:

(WebCore::RenderRegion::layout):

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

(WebCore::RenderView::RenderView):

  • rendering/RenderView.h:

(WebCore::RenderView::hasRenderFlowThread):
(WebCore::RenderView::currentRenderFlowThread):
(WebCore::RenderView::setCurrentRenderFlowThread):
(WebCore::RenderView::pushLayoutState):

LayoutTests:

Patch by Alexandru Chiculita <Alexandru Chiculita> on 2011-08-23
Reviewed by David Hyatt.

  • fast/regions/webkit-flow-floats-inside-regions-bounds-expected.txt: Added.
  • fast/regions/webkit-flow-floats-inside-regions-bounds.html: Added.
  • fast/regions/webkit-flow-inlines-inside-regions-bounds-expected.txt: Added.
  • fast/regions/webkit-flow-inlines-inside-regions-bounds-vertical-expected.txt: Added.
  • fast/regions/webkit-flow-inlines-inside-regions-bounds-vertical-rl-expected.txt: Added.
  • fast/regions/webkit-flow-inlines-inside-regions-bounds-vertical-rl.html: Added.
  • fast/regions/webkit-flow-inlines-inside-regions-bounds-vertical.html: Added.
  • fast/regions/webkit-flow-inlines-inside-regions-bounds.html: Added.
Location:
trunk
Files:
8 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r93626 r93627  
     12011-08-23  Alexandru Chiculita  <achicu@adobe.com>
     2
     3        [CSSRegions] RenderFlowThread layout should use the attached region sizes
     4        https://bugs.webkit.org/show_bug.cgi?id=66143
     5
     6        Reviewed by David Hyatt.
     7
     8        * fast/regions/webkit-flow-floats-inside-regions-bounds-expected.txt: Added.
     9        * fast/regions/webkit-flow-floats-inside-regions-bounds.html: Added.
     10        * fast/regions/webkit-flow-inlines-inside-regions-bounds-expected.txt: Added.
     11        * fast/regions/webkit-flow-inlines-inside-regions-bounds-vertical-expected.txt: Added.
     12        * fast/regions/webkit-flow-inlines-inside-regions-bounds-vertical-rl-expected.txt: Added.
     13        * fast/regions/webkit-flow-inlines-inside-regions-bounds-vertical-rl.html: Added.
     14        * fast/regions/webkit-flow-inlines-inside-regions-bounds-vertical.html: Added.
     15        * fast/regions/webkit-flow-inlines-inside-regions-bounds.html: Added.
     16
    1172011-08-23  Alexandru Chiculita  <achicu@adobe.com>
    218
  • trunk/Source/WebCore/ChangeLog

    r93626 r93627  
     12011-08-23  Alexandru Chiculita  <achicu@adobe.com>
     2
     3        [CSSRegions] RenderFlowThread layout should use the attached region sizes
     4        https://bugs.webkit.org/show_bug.cgi?id=66143
     5
     6        When RenderFlowThread is doing the layout it also sets the current RenderFlowThread on
     7        the RenderView. RenderFlowThread cannot be nested inside a single RenderView, so there's no
     8        need to put that on the LayoutState.
     9
     10        The right offset used to layout the inlines inside a RenderFlowThread
     11        is now adjusted to fit inside the current region.
     12
     13        Reviewed by David Hyatt.
     14
     15        Tests: fast/regions/webkit-flow-floats-inside-regions-bounds.html
     16               fast/regions/webkit-flow-inlines-inside-regions-bounds-vertical-rl.html
     17               fast/regions/webkit-flow-inlines-inside-regions-bounds-vertical.html
     18               fast/regions/webkit-flow-inlines-inside-regions-bounds.html
     19
     20        * rendering/LayoutState.cpp:
     21        (WebCore::LayoutState::LayoutState):
     22        * rendering/RenderBlock.cpp:
     23        (WebCore::RenderBlock::layoutBlock):
     24        (WebCore::RenderBlock::adjustForRegionFittingIfNeeded):
     25        (WebCore::RenderBlock::logicalRightOffsetForLine):
     26        * rendering/RenderBlock.h:
     27        * rendering/RenderFlowThread.cpp:
     28        (WebCore::RenderFlowThread::RenderFlowThread):
     29        (WebCore::CurrentRenderFlowThreadMaintainer::CurrentRenderFlowThreadMaintainer):
     30        (WebCore::CurrentRenderFlowThreadMaintainer::~CurrentRenderFlowThreadMaintainer):
     31        (WebCore::RenderFlowThread::layout):
     32        (WebCore::RenderFlowThread::renderRegionForLine):
     33        (WebCore::RenderFlowThread::regionLogicalWidthForLine):
     34        * rendering/RenderFlowThread.h:
     35        (WebCore::RegionFittingDisabler::RegionFittingDisabler):
     36        (WebCore::RegionFittingDisabler::~RegionFittingDisabler):
     37        * rendering/RenderRegion.cpp:
     38        (WebCore::RenderRegion::layout):
     39        * rendering/RenderRegion.h:
     40        * rendering/RenderView.cpp:
     41        (WebCore::RenderView::RenderView):
     42        * rendering/RenderView.h:
     43        (WebCore::RenderView::hasRenderFlowThread):
     44        (WebCore::RenderView::currentRenderFlowThread):
     45        (WebCore::RenderView::setCurrentRenderFlowThread):
     46        (WebCore::RenderView::pushLayoutState):
     47
    1482011-08-23  Alexandru Chiculita  <achicu@adobe.com>
    249
  • trunk/Source/WebCore/rendering/LayoutState.cpp

    r93556 r93627  
    8383    // If we establish a new page height, then cache the offset to the top of the first page.
    8484    // We can compare this later on to figure out what part of the page we're actually on,
    85     if (pageLogicalHeight || m_columnInfo) {
     85    if (pageLogicalHeight || m_columnInfo || renderer->isRenderFlowThread()) {
    8686        m_pageLogicalHeight = pageLogicalHeight;
    8787        m_pageOffset = LayoutSize(m_layoutOffset.width() + renderer->borderLeft() + renderer->paddingLeft(),
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r93626 r93627  
    4242#include "RenderCombineText.h"
    4343#include "RenderDeprecatedFlexibleBox.h"
     44#include "RenderFlowThread.h"
    4445#include "RenderImage.h"
    4546#include "RenderInline.h"
     
    12231224    }
    12241225
    1225     LayoutStateMaintainer statePusher(view(), this, locationOffset(), hasColumns() || hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode(), pageLogicalHeight, pageLogicalHeightChanged, colInfo);
     1226    RenderView* renderView = view();
     1227    LayoutStateMaintainer statePusher(renderView, this, locationOffset(), hasColumns() || hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode(), pageLogicalHeight, pageLogicalHeightChanged, colInfo);
     1228
     1229    bool disableRegionFitting = renderView->hasRenderFlowThread() && (hasColumns() || (isPositioned() && !isRenderFlowThread()) || isFloating());
     1230    RegionFittingDisabler regionFittingDisabler(renderView->currentRenderFlowThread(), disableRegionFitting);
    12261231
    12271232    // We use four values, maxTopPos, maxTopNeg, maxBottomPos, and maxBottomNeg, to track
     
    13061311    statePusher.pop();
    13071312
    1308     if (view()->layoutState()->m_pageLogicalHeight)
    1309         setPageLogicalOffset(view()->layoutState()->pageLogicalOffset(logicalTop()));
     1313    if (renderView->layoutState()->m_pageLogicalHeight)
     1314        setPageLogicalOffset(renderView->layoutState()->pageLogicalOffset(logicalTop()));
    13101315
    13111316    updateLayerTransform();
     
    35613566}
    35623567
     3568void RenderBlock::adjustForRegionFittingIfNeeded(LayoutUnit logicalTop, LayoutUnit& rightOffset) const
     3569{
     3570    RenderView* renderView = view();
     3571    if (!renderView->hasRenderFlowThread())
     3572        return;
     3573   
     3574    RenderFlowThread* flowThread = renderView->currentRenderFlowThread();
     3575    if (!flowThread->isRegionFittingEnabled() || !flowThread->hasValidRegions())
     3576        return;
     3577
     3578    LayoutState* layoutState = renderView->layoutState();
     3579    IntSize delta = layoutState->m_layoutOffset - layoutState->m_pageOffset;
     3580    int offset = isHorizontalWritingMode() ? delta.height() : delta.width();
     3581    LayoutUnit regionWidth = flowThread->regionLogicalWidthForLine(offset + logicalTop);
     3582    rightOffset -= flowThread->logicalWidth() - regionWidth;
     3583}
     3584
    35633585LayoutUnit RenderBlock::logicalRightOffsetForLine(LayoutUnit logicalTop, LayoutUnit fixedOffset, bool applyTextIndent, LayoutUnit* heightRemaining) const
    35643586{
    35653587    LayoutUnit right = fixedOffset;
     3588    adjustForRegionFittingIfNeeded(logicalTop, right);
    35663589
    35673590    if (m_floatingObjects && m_floatingObjects->hasRightObjects()) {
     
    35693592            *heightRemaining = 1;
    35703593
    3571         FloatIntervalSearchAdapter<FloatingObject::FloatRight> adapter(this, logicalTop, right, heightRemaining);
     3594        LayoutUnit rightFloatOffset = fixedOffset;
     3595        FloatIntervalSearchAdapter<FloatingObject::FloatRight> adapter(this, logicalTop, rightFloatOffset, heightRemaining);
    35723596        m_floatingObjects->placedFloatsTree().allOverlapsWithAdapter(adapter);
     3597        right = min(right, rightFloatOffset);
    35733598    }
    35743599   
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r93626 r93627  
    313313    virtual void paintObject(PaintInfo&, const LayoutPoint&);
    314314
     315    void adjustForRegionFittingIfNeeded(LayoutUnit logicalTop, LayoutUnit& rightOffset) const;
     316
    315317    LayoutUnit logicalRightOffsetForLine(LayoutUnit position, LayoutUnit fixedOffset, bool applyTextIndent = true, LayoutUnit* logicalHeightRemaining = 0) const;
    316318    LayoutUnit logicalLeftOffsetForLine(LayoutUnit position, LayoutUnit fixedOffset, bool applyTextIndent = true, LayoutUnit* logicalHeightRemaining = 0) const;
  • trunk/Source/WebCore/rendering/RenderFlowThread.cpp

    r93556 r93627  
    4545    : RenderBlock(node)
    4646    , m_flowThread(flowThread)
     47    , m_hasValidRegions(false)
    4748    , m_regionsInvalidated(false)
     49    , m_regionFittingDisableCount(0)
    4850{
    4951    setIsAnonymous(false);
     
    271273}
    272274
     275class CurrentRenderFlowThreadMaintainer {
     276    WTF_MAKE_NONCOPYABLE(CurrentRenderFlowThreadMaintainer);
     277public:
     278    CurrentRenderFlowThreadMaintainer(RenderFlowThread* renderFlowThread)
     279        : m_renderFlowThread(renderFlowThread)
     280    {
     281        RenderView* view = m_renderFlowThread->view();
     282        ASSERT(!view->currentRenderFlowThread());
     283        view->setCurrentRenderFlowThread(m_renderFlowThread);
     284    }
     285    ~CurrentRenderFlowThreadMaintainer()
     286    {
     287        RenderView* view = m_renderFlowThread->view();
     288        ASSERT(view->currentRenderFlowThread() == m_renderFlowThread);
     289        view->setCurrentRenderFlowThread(0);
     290    }
     291private:
     292    RenderFlowThread* m_renderFlowThread;
     293};
     294
    273295void RenderFlowThread::layout()
    274296{
     297    CurrentRenderFlowThreadMaintainer currentFlowThreadSetter(this);
     298
    275299    if (m_regionsInvalidated) {
    276300        m_regionsInvalidated = false;
     
    284308
    285309                ASSERT(!region->needsLayout());
     310               
     311                m_hasValidRegions = true;
    286312
    287313                IntRect regionRect;
     
    437463}
    438464
     465RenderRegion* RenderFlowThread::renderRegionForLine(LayoutUnit position, bool extendLastRegion) const
     466{
     467    ASSERT(!m_regionsInvalidated);
     468   
     469    // All the regions should start at 0.
     470    ASSERT(position >= 0);
     471   
     472    // If no region matches the position and extendLastRegion is true, it will return
     473    // the last valid region. It is similar to auto extending the size of the last region.
     474    RenderRegion* lastValidRegion = 0;
     475   
     476    // FIXME: The regions are always in order, optimize this search.
     477    bool useHorizontalWritingMode = isHorizontalWritingMode();
     478    for (RenderRegionList::const_iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter) {
     479        RenderRegion* region = *iter;
     480        if (!region->isValid())
     481            continue;
     482
     483        LayoutRect regionRect = region->regionRect();
     484
     485        if (useHorizontalWritingMode) {
     486            if (regionRect.y() <= position && position < regionRect.maxY())
     487                return region;
     488            continue;
     489        }
     490
     491        if (regionRect.x() <= position && position < regionRect.maxX())
     492            return region;
     493       
     494        if (extendLastRegion)
     495            lastValidRegion = region;
     496    }
     497
     498    return lastValidRegion;
     499}
     500
     501LayoutUnit RenderFlowThread::regionLogicalWidthForLine(LayoutUnit position) const
     502{
     503    const bool extendLastRegion = true;
     504    RenderRegion* region = renderRegionForLine(position, extendLastRegion);
     505    if (!region)
     506        return 0;
     507
     508    return isHorizontalWritingMode() ? region->regionRect().width() : region->regionRect().height();
     509}
     510
     511
    439512} // namespace WebCore
  • trunk/Source/WebCore/rendering/RenderFlowThread.h

    r93556 r93627  
    8686
    8787    bool hasRegions() const { return m_regionList.size(); }
     88    bool hasValidRegions() const { ASSERT(!m_regionsInvalidated); return m_hasValidRegions; }
    8889
    8990    void invalidateRegions() { m_regionsInvalidated = true; setNeedsLayout(true); }
     
    9798    void repaintRectangleInRegions(const LayoutRect&, bool immediate);
    9899
     100    LayoutUnit regionLogicalWidthForLine(LayoutUnit position) const;
     101
     102    bool isRegionFittingEnabled() const { return !m_regionFittingDisableCount; }
     103    void disableRegionFitting() { m_regionFittingDisableCount++; }
     104    void enableRegionFitting() { ASSERT(m_regionFittingDisableCount > 0); m_regionFittingDisableCount--; }
     105
    99106private:
    100107    virtual const char* renderName() const { return "RenderFlowThread"; }
     108
     109    RenderRegion* renderRegionForLine(LayoutUnit position, bool extendLastRegion = false) const;
    101110
    102111    bool dependsOn(RenderFlowThread* otherRenderFlowThread) const;
     
    123132    RenderFlowThreadCountedSet m_layoutBeforeThreadsSet;
    124133
     134    bool m_hasValidRegions;
    125135    bool m_regionsInvalidated;
     136    unsigned m_regionFittingDisableCount;
    126137};
    127138
     
    141152void toRenderFlowThread(const RenderFlowThread*);
    142153
     154class RegionFittingDisabler {
     155    WTF_MAKE_NONCOPYABLE(RegionFittingDisabler);
     156public:
     157    RegionFittingDisabler(RenderFlowThread* flowThread, bool disable)
     158    {
     159        if (flowThread && disable) {
     160            m_flowThread = flowThread;
     161            m_flowThread->disableRegionFitting();
     162        } else
     163            m_flowThread = 0;
     164    }
     165
     166    ~RegionFittingDisabler()
     167    {
     168        if (m_flowThread)
     169            m_flowThread->enableRegionFitting();
     170    }
     171private:
     172    RenderFlowThread* m_flowThread;
     173};
     174
     175
    143176} // namespace WebCore
    144177
  • trunk/Source/WebCore/rendering/RenderRegion.cpp

    r93556 r93627  
    8383}
    8484
     85void RenderRegion::layout()
     86{
     87    RenderReplaced::layout();
     88    if (m_flowThread && isValid())
     89        m_flowThread->invalidateRegions();
     90}
     91
    8592void RenderRegion::attachRegion()
    8693{
  • trunk/Source/WebCore/rendering/RenderRegion.h

    r93556 r93627  
    5959    void setIsValid(bool valid) { m_isValid = valid; }
    6060
     61    virtual void layout();
     62
    6163private:
    6264    virtual const char* renderName() const { return "RenderRegion"; }
  • trunk/Source/WebCore/rendering/RenderView.cpp

    r93556 r93627  
    5656    , m_layoutState(0)
    5757    , m_layoutStateDisableCount(0)
     58    , m_currentRenderFlowThread(0)
    5859{
    5960    // Clear our anonymous bit, set because RenderObject assumes
  • trunk/Source/WebCore/rendering/RenderView.h

    r93556 r93627  
    182182    const RenderFlowThreadList* renderFlowThreadList() const { return m_renderFlowThreadList.get(); }
    183183
     184    bool hasRenderFlowThread() const { return m_currentRenderFlowThread; }
     185    RenderFlowThread* currentRenderFlowThread() const { return m_currentRenderFlowThread; }
     186    void setCurrentRenderFlowThread(RenderFlowThread* flowThread) { m_currentRenderFlowThread = flowThread; }
     187
    184188    void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
    185189   
     
    197201    {
    198202        // We push LayoutState even if layoutState is disabled because it stores layoutDelta too.
    199         if (!doingFullRepaint() || renderer->hasColumns() || m_layoutState->isPaginated()) {
     203        if (!doingFullRepaint() || renderer->hasColumns() || m_layoutState->isPaginated() || hasRenderFlowThread()) {
    200204            m_layoutState = new (renderArena()) LayoutState(m_layoutState, renderer, offset, pageHeight, pageHeightChanged, colInfo);
    201205            return true;
     
    266270#endif
    267271    OwnPtr<RenderFlowThreadList> m_renderFlowThreadList;
     272    RenderFlowThread* m_currentRenderFlowThread;
    268273};
    269274
Note: See TracChangeset for help on using the changeset viewer.