Changeset 143060 in webkit


Ignore:
Timestamp:
Feb 15, 2013 3:11:47 PM (11 years ago)
Author:
esprehn@chromium.org
Message:

RenderQuote should not mark renderers as needing layout during layout
https://bugs.webkit.org/show_bug.cgi?id=109876

Reviewed by Ojan Vafai.

Source/WebCore:

Marking RenderQuotes as needing pref width recalcs and layouts during a
layout is dangerous since an ancestor may mark itself as having completed
layout, but then some subtree still thinks it needs layout.

Instead, since the only time we create RenderQuote instances is inside
PseudoElement, we can call attachQuote inside PseudoElement::attach during
the regular tree mutating cycle. We can then use RenderQuote::styleDidChange
to update the kind of quotes on normal style changes.

This makes RenderQuote behave much more similarly to DOM nodes and means
we no longer need to set dirty bits during layout.

Test: fast/css-generated-content/quote-layout-focus-crash.html

  • dom/PseudoElement.cpp:

(WebCore::PseudoElement::attach): Now call attachQuote().

  • rendering/RenderQuote.cpp:

(WebCore::RenderQuote::~RenderQuote):
(WebCore::RenderQuote::willBeRemovedFromTree):
(WebCore::RenderQuote::styleDidChange):
(WebCore::RenderQuote::updateText):
(WebCore::RenderQuote::attachQuote):
(WebCore::RenderQuote::detachQuote):
(WebCore::RenderQuote::updateDepth):

  • rendering/RenderQuote.h:

(RenderQuote):

LayoutTests:

  • fast/block/float/float-not-removed-from-pre-block-expected.txt:
  • fast/css-generated-content/quote-layout-focus-crash-expected.txt: Added.
  • fast/css-generated-content/quote-layout-focus-crash.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r143046 r143060  
     12013-02-15  Elliott Sprehn  <esprehn@chromium.org>
     2
     3        RenderQuote should not mark renderers as needing layout during layout
     4        https://bugs.webkit.org/show_bug.cgi?id=109876
     5
     6        Reviewed by Ojan Vafai.
     7
     8        * fast/block/float/float-not-removed-from-pre-block-expected.txt:
     9        * fast/css-generated-content/quote-layout-focus-crash-expected.txt: Added.
     10        * fast/css-generated-content/quote-layout-focus-crash.html: Added.
     11
    1122013-02-15  Rik Cabanier  <cabanier@adobe.com>
    213
  • trunk/LayoutTests/fast/block/float/float-not-removed-from-pre-block-expected.txt

    r142885 r143060  
    11Bug 101970: Heap-use-after-free in WebCore::RenderLayerModelObject::hasSelfPaintingLayer
    22Test passes if it does not crash.
    3 
     3 
  • trunk/Source/WebCore/ChangeLog

    r143054 r143060  
     12013-02-15  Elliott Sprehn  <esprehn@chromium.org>
     2
     3        RenderQuote should not mark renderers as needing layout during layout
     4        https://bugs.webkit.org/show_bug.cgi?id=109876
     5
     6        Reviewed by Ojan Vafai.
     7
     8        Marking RenderQuotes as needing pref width recalcs and layouts during a
     9        layout is dangerous since an ancestor may mark itself as having completed
     10        layout, but then some subtree still thinks it needs layout.
     11
     12        Instead, since the only time we create RenderQuote instances is inside
     13        PseudoElement, we can call attachQuote inside PseudoElement::attach during
     14        the regular tree mutating cycle. We can then use RenderQuote::styleDidChange
     15        to update the kind of quotes on normal style changes.
     16
     17        This makes RenderQuote behave much more similarly to DOM nodes and means
     18        we no longer need to set dirty bits during layout.
     19
     20        Test: fast/css-generated-content/quote-layout-focus-crash.html
     21
     22        * dom/PseudoElement.cpp:
     23        (WebCore::PseudoElement::attach): Now call attachQuote().
     24        * rendering/RenderQuote.cpp:
     25        (WebCore::RenderQuote::~RenderQuote):
     26        (WebCore::RenderQuote::willBeRemovedFromTree):
     27        (WebCore::RenderQuote::styleDidChange):
     28        (WebCore::RenderQuote::updateText):
     29        (WebCore::RenderQuote::attachQuote):
     30        (WebCore::RenderQuote::detachQuote):
     31        (WebCore::RenderQuote::updateDepth):
     32        * rendering/RenderQuote.h:
     33        (RenderQuote):
     34
    1352013-02-15  Sheriff Bot  <webkit.review.bot@gmail.com>
    236
  • trunk/Source/WebCore/dom/PseudoElement.cpp

    r141524 r143060  
    3131#include "NodeRenderingContext.h"
    3232#include "RenderObject.h"
     33#include "RenderQuote.h"
    3334
    3435namespace WebCore {
     
    8384    for (const ContentData* content = style->contentData(); content; content = content->next()) {
    8485        RenderObject* child = content->createRenderer(document(), style);
    85         if (renderer->isChildAllowed(child, style))
     86        if (renderer->isChildAllowed(child, style)) {
    8687            renderer->addChild(child);
    87         else
     88            if (child->isQuote())
     89                toRenderQuote(child)->attachQuote();
     90        } else
    8891            child->destroy();
    8992    }
  • trunk/Source/WebCore/rendering/RenderQuote.cpp

    r142056 r143060  
    5555{
    5656    RenderText::willBeRemovedFromTree();
    57 
    5857    detachQuote();
     58}
     59
     60void RenderQuote::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
     61{
     62    RenderText::styleDidChange(diff, oldStyle);
     63    updateText();
    5964}
    6065
     
    246251void RenderQuote::updateText()
    247252{
    248     computePreferredLogicalWidths(0);
    249 }
    250 
    251 void RenderQuote::computePreferredLogicalWidths(float lead)
    252 {
    253 #ifndef NDEBUG
    254     // FIXME: We shouldn't be modifying the tree in computePreferredLogicalWidths.
    255     // Instead, we should properly hook the appropriate changes in the DOM and modify
    256     // the render tree then. When that's done, we also won't need to override
    257     // computePreferredLogicalWidths at all.
    258     // https://bugs.webkit.org/show_bug.cgi?id=104829
    259     SetLayoutNeededForbiddenScope layoutForbiddenScope(this, false);
    260 #endif
    261 
    262     if (!m_attached)
    263         attachQuote();
    264     setTextInternal(originalText());
    265 
    266     RenderText::computePreferredLogicalWidths(lead);
     253    setText(originalText());
    267254}
    268255
     
    286273    ASSERT(!m_attached);
    287274    ASSERT(!m_next && !m_previous);
    288 
    289     // FIXME: Don't set pref widths dirty during layout. See updateDepth() for
    290     // more detail.
    291     if (!isRooted()) {
    292         setNeedsLayoutAndPrefWidthsRecalc();
    293         return;
    294     }
     275    ASSERT(isRooted());
    295276
    296277    if (!view()->renderQuoteHead()) {
     
    371352        }
    372353    }
    373     // FIXME: Don't call setNeedsLayout or dirty our preferred widths during layout.
    374     // This is likely to fail anyway as one of our ancestor will call setNeedsLayout(false),
    375     // preventing the future layout to occur on |this|. The solution is to move that to a
    376     // pre-layout phase.
    377354    if (oldDepth != m_depth)
    378         setNeedsLayoutAndPrefWidthsRecalc();
     355        updateText();
    379356}
    380357
  • trunk/Source/WebCore/rendering/RenderQuote.h

    r142885 r143060  
    3737    virtual ~RenderQuote();
    3838    void attachQuote();
     39
     40    virtual void updateText() OVERRIDE;
     41
     42private:
    3943    void detachQuote();
    4044
    41 private:
    4245    virtual void willBeDestroyed() OVERRIDE;
    4346    virtual const char* renderName() const OVERRIDE { return "RenderQuote"; };
    4447    virtual bool isQuote() const OVERRIDE { return true; };
    4548    virtual PassRefPtr<StringImpl> originalText() const OVERRIDE;
    46 
    47     virtual void updateText() OVERRIDE;
    48     virtual void computePreferredLogicalWidths(float leadWidth) OVERRIDE;
     49    virtual void styleDidChange(StyleDifference, const RenderStyle*) OVERRIDE;
    4950
    5051    // We don't override insertedIntoTree to call attachQuote() as it would be attached
Note: See TracChangeset for help on using the changeset viewer.