Changeset 95469 in webkit


Ignore:
Timestamp:
Sep 19, 2011, 1:52:37 PM (14 years ago)
Author:
inferno@chromium.org
Message:

Merge 95461 - Child not placed correctly when beforeChild (table part)
has both :before, :after content.
BUG=95520
Review URL: http://codereview.chromium.org/7946014

Location:
branches/chromium/874/Source/WebCore/rendering
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/chromium/874/Source/WebCore/rendering/RenderBlock.cpp

    r94541 r95469  
    683683{
    684684    // Make sure we don't append things after :after-generated content if we have it.
    685     if (!beforeChild) {
    686         RenderObject* lastRenderer = lastChild();
    687         while (lastRenderer && lastRenderer->isAnonymous() && !isAfterContent(lastRenderer))
    688             lastRenderer = lastRenderer->lastChild();
    689         if (lastRenderer && isAfterContent(lastRenderer))
    690             beforeChild = lastRenderer;
    691     }
     685    if (!beforeChild)
     686        beforeChild = findAfterContentRenderer();
    692687
    693688    // If the requested beforeChild is not one of our children, then this is because
    694689    // there is an anonymous container within this object that contains the beforeChild.
    695690    if (beforeChild && beforeChild->parent() != this) {
    696         RenderObject* anonymousChild = beforeChild->parent();
    697         ASSERT(anonymousChild);
    698 
    699         while (anonymousChild->parent() != this)
    700             anonymousChild = anonymousChild->parent();
    701 
    702         ASSERT(anonymousChild->isAnonymous());
    703 
    704         if (anonymousChild->isAnonymousBlock()) {
     691        RenderObject* beforeChildAnonymousContainer = anonymousContainer(beforeChild);
     692        ASSERT(beforeChildAnonymousContainer);
     693        ASSERT(beforeChildAnonymousContainer->isAnonymous());
     694
     695        if (beforeChildAnonymousContainer->isAnonymousBlock()) {
    705696            // Insert the child into the anonymous block box instead of here.
    706697            if (newChild->isInline() || beforeChild->parent()->firstChild() != beforeChild)
     
    711702        }
    712703
    713         ASSERT(anonymousChild->isTable());
     704        ASSERT(beforeChildAnonymousContainer->isTable());
    714705        if ((newChild->isTableCol() && newChild->style()->display() == TABLE_COLUMN_GROUP)
    715706                || (newChild->isRenderBlock() && newChild->style()->display() == TABLE_CAPTION)
     
    718709                || newChild->isTableCell()) {
    719710            // Insert into the anonymous table.
    720             anonymousChild->addChild(newChild, beforeChild);
     711            beforeChildAnonymousContainer->addChild(newChild, beforeChild);
    721712            return;
    722713        }
    723714
    724715        // Go on to insert before the anonymous table.
    725         beforeChild = anonymousChild;
     716        beforeChild = beforeChildAnonymousContainer;
    726717    }
    727718
  • branches/chromium/874/Source/WebCore/rendering/RenderObject.cpp

    r94543 r95469  
    284284        return;
    285285
     286    RenderObject* beforeContent = 0;
     287    bool beforeChildHasBeforeAndAfterContent = false;
     288    if (beforeChild && (beforeChild->isTable() || beforeChild->isTableSection() || beforeChild->isTableRow())) {
     289        beforeContent = beforeChild->findBeforeContentRenderer();
     290        RenderObject* afterContent = beforeChild->findAfterContentRenderer();
     291        if (beforeContent && afterContent) {
     292            beforeChildHasBeforeAndAfterContent = true;
     293            beforeContent->destroy();
     294        }
     295    }
     296
    286297    bool needsTable = false;
    287298
     
    322333        children->insertChildNode(this, newChild, beforeChild);
    323334    }
     335
    324336    if (newChild->isText() && newChild->style()->textTransform() == CAPITALIZE) {
    325337        RefPtr<StringImpl> textToTransform = toRenderText(newChild)->originalText();
     
    327339            toRenderText(newChild)->setText(textToTransform.release(), true);
    328340    }
     341
     342    if (beforeChildHasBeforeAndAfterContent)
     343        children->updateBeforeAfterContent(this, BEFORE);
    329344}
    330345
  • branches/chromium/874/Source/WebCore/rendering/RenderObject.h

    r94543 r95469  
    337337    static inline bool isAfterContent(const RenderObject* obj) { return obj && obj->isAfterContent(); }
    338338    static inline bool isBeforeOrAfterContent(const RenderObject* obj) { return obj && obj->isBeforeOrAfterContent(); }
     339
     340    inline RenderObject* findBeforeContentRenderer() const
     341    {
     342        RenderObject* renderer = beforePseudoElementRenderer();
     343        return isBeforeContent(renderer) ? renderer : 0;
     344    }
     345
     346    inline RenderObject* findAfterContentRenderer() const
     347    {
     348        RenderObject* renderer = afterPseudoElementRenderer();
     349        return isAfterContent(renderer) ? renderer : 0;
     350    }
     351
     352    inline RenderObject* anonymousContainer(RenderObject* child)
     353    {
     354         RenderObject* container = child;
     355         while (container->parent() != this)
     356             container = container->parent();
     357
     358         ASSERT(container->isAnonymous());
     359         return container;
     360    }
    339361
    340362    bool childrenInline() const { return m_childrenInline; }
  • branches/chromium/874/Source/WebCore/rendering/RenderTable.cpp

    r94543 r95469  
    108108{
    109109    // Make sure we don't append things after :after-generated content if we have it.
    110     if (!beforeChild && isAfterContent(lastChild()))
    111         beforeChild = lastChild();
     110    if (!beforeChild) {
     111        if (RenderObject* afterContentRenderer = findAfterContentRenderer())
     112            beforeChild = anonymousContainer(afterContentRenderer);
     113    }
    112114
    113115    bool wrapInAnonymousSection = !child->isPositioned();
  • branches/chromium/874/Source/WebCore/rendering/RenderTableRow.cpp

    r94543 r95469  
    8484{
    8585    // Make sure we don't append things after :after-generated content if we have it.
    86     if (!beforeChild && isAfterContent(lastChild()))
    87         beforeChild = lastChild();
     86    if (!beforeChild) {
     87        if (RenderObject* afterContentRenderer = findAfterContentRenderer())
     88            beforeChild = anonymousContainer(afterContentRenderer);
     89    }
    8890
    8991    if (!child->isTableCell()) {
  • branches/chromium/874/Source/WebCore/rendering/RenderTableSection.cpp

    r94543 r95469  
    9999{
    100100    // Make sure we don't append things after :after-generated content if we have it.
    101     if (!beforeChild && isAfterContent(lastChild()))
    102         beforeChild = lastChild();
     101    if (!beforeChild) {
     102        if (RenderObject* afterContentRenderer = findAfterContentRenderer())
     103            beforeChild = anonymousContainer(afterContentRenderer);
     104    }
    103105
    104106    if (!child->isTableRow()) {
Note: See TracChangeset for help on using the changeset viewer.