示例#1
0
void RenderRegion::restoreRegionBoxesOriginalStyle()
{
    if (!hasCustomRegionStyle())
        return;

    for (RenderBoxRegionInfoMap::iterator iter = m_renderBoxRegionInfo.begin(), end = m_renderBoxRegionInfo.end(); iter != end; ++iter) {
        const RenderBox* box = iter->first;
        RenderBoxRegionStyleMap::iterator it = m_renderBoxRegionStyle.find(box);
        if (it == m_renderBoxRegionStyle.end())
            continue;

        // Restore the box style to the original style and store the box style in region for later use.
        RefPtr<RenderStyle> boxRegionStyle = box->style();
        (const_cast<RenderBox*>(box))->setStyleInternal(it->second);
        m_renderBoxRegionStyle.set(box, boxRegionStyle);
    }
}
示例#2
0
void RenderRegion::setRegionBoxesRegionStyle()
{
    if (!hasCustomRegionStyle())
        return;

    for (RenderBoxRegionInfoMap::iterator iter = m_renderBoxRegionInfo.begin(), end = m_renderBoxRegionInfo.end(); iter != end; ++iter) {
        const RenderBox* box = iter->first;
        if (!box->canHaveRegionStyle())
            continue;

        // Save original box style to be restored later, after paint.
        RefPtr<RenderStyle> boxOriginalStyle = box->style();

        // Set the style to be used for box as the style computed in region.
        (const_cast<RenderBox*>(box))->setStyleInternal(renderBoxRegionStyle(box));

        m_renderBoxRegionStyle.set(box, boxOriginalStyle);
    }
}
void RenderRegion::setRegionObjectsRegionStyle()
{
    if (!hasCustomRegionStyle())
        return;

    // Start from content nodes and recursively compute the style in region for the render objects below.
    // If the style in region was already computed, used that style instead of computing a new one.
    RenderNamedFlowThread* namedFlow = view()->flowThreadController()->ensureRenderFlowThreadWithName(style()->regionThread());
    const NamedFlowContentNodes& contentNodes = namedFlow->contentNodes();

    for (NamedFlowContentNodes::const_iterator iter = contentNodes.begin(), end = contentNodes.end(); iter != end; ++iter) {
        const Node* node = *iter;
        // The list of content nodes contains also the nodes with display:none.
        if (!node->renderer())
            continue;

        RenderObject* object = node->renderer();
        // If the content node does not flow any of its children in this region,
        // we do not compute any style for them in this region.
        if (!flowThread()->objectInFlowRegion(object, this))
            continue;

        // If the object has style in region, use that instead of computing a new one.
        RenderObjectRegionStyleMap::iterator it = m_renderObjectRegionStyle.find(object);
        RefPtr<RenderStyle> objectStyleInRegion;
        bool objectRegionStyleCached = false;
        if (it != m_renderObjectRegionStyle.end()) {
            objectStyleInRegion = it->value.style;
            ASSERT(it->value.cached);
            objectRegionStyleCached = true;
        } else
            objectStyleInRegion = computeStyleInRegion(object);

        setObjectStyleInRegion(object, objectStyleInRegion, objectRegionStyleCached);

        computeChildrenStyleInRegion(object);
    }
}
void RenderNamedFlowFragment::setRegionObjectsRegionStyle()
{
    if (!hasCustomRegionStyle())
        return;

    // Start from content nodes and recursively compute the style in region for the render objects below.
    // If the style in region was already computed, used that style instead of computing a new one.
    const RenderNamedFlowThread& namedFlow = view().flowThreadController().ensureRenderFlowThreadWithName(style().regionThread());
    const NamedFlowContentElements& contentElements = namedFlow.contentElements();

    for (const auto& element : contentElements) {
        // The list of content nodes contains also the nodes with display:none.
        if (!element->renderer())
            continue;

        RenderElement* object = element->renderer();
        // If the content node does not flow any of its children in this region,
        // we do not compute any style for them in this region.
        if (!flowThread()->objectInFlowRegion(object, this))
            continue;

        // If the object has style in region, use that instead of computing a new one.
        auto it = m_renderObjectRegionStyle.find(object);
        std::unique_ptr<RenderStyle> objectStyleInRegion;
        bool objectRegionStyleCached = false;
        if (it != m_renderObjectRegionStyle.end()) {
            objectStyleInRegion = RenderStyle::clonePtr(*it->value.style);
            ASSERT(it->value.cached);
            objectRegionStyleCached = true;
        } else
            objectStyleInRegion = computeStyleInRegion(*object, style());

        setObjectStyleInRegion(object, WTFMove(objectStyleInRegion), objectRegionStyleCached);

        computeChildrenStyleInRegion(*object);
    }
}