Example #1
0
void RenderFlowThread::resetRegionsOverrideLogicalContentHeight()
{
    ASSERT(view()->layoutState());
    ASSERT(view()->normalLayoutPhase());

    // We need to reset the override logical content height for regions with auto logical height
    // only if the flow thread content needs layout.
    if (!needsLayout())
        return;

    // FIXME: optimize this to iterate the region chain only if the flow thread has auto logical height
    // region.

    for (RenderRegionList::iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter) {
        RenderRegion* region = *iter;
        if (!region->hasAutoLogicalHeight())
            continue;

        region->clearOverrideLogicalContentHeight();
        // FIXME: We need to find a way to avoid marking all the regions ancestors for layout
        // as we are already inside layout.
        region->setNeedsLayout(true);
    }
    // Make sure we don't skip any region breaks when we do the layout again.
    // Using m_regionsInvalidated to force all the RenderFlowThread children do the layout again.
    m_regionsInvalidated = true;
}
void RenderFlowThread::computeOverflowStateForRegions(LayoutUnit oldClientAfterEdge)
{
    LayoutUnit height = oldClientAfterEdge;

    LayoutUnit offsetBreakAdjustment = 0;
    // Simulate a region break at height. If it points inside an auto logical height region,
    // then it may determine the region override logical content height.
    addForcedRegionBreak(height, this, false, &offsetBreakAdjustment);

    // During the normal layout phase of the flow thread all the auto-height regions have the overrideLogicalContentHeight set to max height.
    // We need to clear the overrideLogicalContentHeight for all the regions that didn't receive any content, starting with firstEmptyRegion.
    RenderRegion* firstEmptyRegion = 0;
    if (view()->normalLayoutPhase())
        firstEmptyRegion = regionAtBlockOffset(height + offsetBreakAdjustment);

    // FIXME: the visual overflow of middle region (if it is the last one to contain any content in a render flow thread)
    // might not be taken into account because the render flow thread height is greater that that regions height + its visual overflow
    // because of how computeLogicalHeight is implemented for RenderFlowThread (as a sum of all regions height).
    // This means that the middle region will be marked as fit (even if it has visual overflow flowing into the next region)
    if (hasRenderOverflow()
        && ( (isHorizontalWritingMode() && visualOverflowRect().maxY() > clientBoxRect().maxY())
            || (!isHorizontalWritingMode() && visualOverflowRect().maxX() > clientBoxRect().maxX())))
        height = isHorizontalWritingMode() ? visualOverflowRect().maxY() : visualOverflowRect().maxX();

    bool inEmptyRegionsSection = false;
    RenderRegion* lastReg = lastRegion();
    for (RenderRegionList::iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter) {
        RenderRegion* region = *iter;
        LayoutUnit flowMin = height - (isHorizontalWritingMode() ? region->flowThreadPortionRect().y() : region->flowThreadPortionRect().x());
        LayoutUnit flowMax = height - (isHorizontalWritingMode() ? region->flowThreadPortionRect().maxY() : region->flowThreadPortionRect().maxX());
        RenderRegion::RegionState previousState = region->regionState();
        RenderRegion::RegionState state = RenderRegion::RegionFit;
        if (flowMin <= 0)
            state = RenderRegion::RegionEmpty;
        if (flowMax > 0 && region == lastReg)
            state = RenderRegion::RegionOverset;
        region->setRegionState(state);
        // determine whether the NamedFlow object should dispatch a regionLayoutUpdate event
        // FIXME: currently it cannot determine whether a region whose regionOverset state remained either "fit" or "overset" has actually
        // changed, so it just assumes that the NamedFlow should dispatch the event
        if (previousState != state
            || state == RenderRegion::RegionFit
            || state == RenderRegion::RegionOverset)
            setDispatchRegionLayoutUpdateEvent(true);

        if (region == firstEmptyRegion)
            inEmptyRegionsSection = true;

        // Clear the overrideLogicalContentHeight value for autoheight regions that didn't receive any content.
        if (inEmptyRegionsSection && region->hasAutoLogicalHeight())
            region->clearOverrideLogicalContentHeight();
    }

    // With the regions overflow state computed we can also set the overset flag for the named flow.
    // If there are no valid regions in the chain, overset is true.
    m_overset = lastReg ? lastReg->regionState() == RenderRegion::RegionOverset : true;
}
void RenderFlowThread::resetRegionsOverrideLogicalContentHeight()
{
    ASSERT(view()->layoutState());
    ASSERT(view()->normalLayoutPhase());

    if (!hasAutoLogicalHeightRegions())
        return;

    for (RenderRegionList::iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter) {
        RenderRegion* region = *iter;
        if (!region->hasAutoLogicalHeight())
            continue;

        region->clearOverrideLogicalContentHeight();
        // FIXME: We need to find a way to avoid marking all the regions ancestors for layout
        // as we are already inside layout.
        region->setNeedsLayout(true);
    }
    // Make sure we don't skip any region breaks when we do the layout again.
    // Using m_regionsInvalidated to force all the RenderFlowThread children do the layout again.
    invalidateRegions();
}