Changeset 35615 in webkit


Ignore:
Timestamp:
Aug 6, 2008 3:39:04 PM (16 years ago)
Author:
eric@webkit.org
Message:

Reviewed by hyatt.

Fix a large animation leak found on the buildbot
(m_animations and m_transitions were never deleted)
Drag RenderStyle (kicking and screaming) into the 21st century
of memory management with a little application of OwnPtr.

  • rendering/style/RenderStyle.cpp: (WebCore::FillLayer::cullEmptyLayers): (WebCore::RenderStyle::diff): (WebCore::RenderStyle::contentDataEquivalent): (WebCore::RenderStyle::setContent): (WebCore::BindingURI::BindingURI): (WebCore::RenderStyle::setBoxShadow): (WebCore::ShadowData::ShadowData): (WebCore::RenderStyle::counterDirectives): (WebCore::RenderStyle::accessCounterDirectives): (WebCore::RenderStyle::adjustAnimations): (WebCore::RenderStyle::adjustTransitions): (WebCore::RenderStyle::accessAnimations): (WebCore::RenderStyle::accessTransitions):
  • rendering/style/RenderStyle.h: (WebCore::RenderStyle::clearAnimations): (WebCore::RenderStyle::clearTransitions):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r35614 r35615  
     12008-08-06  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by hyatt.
     4
     5        Fix a large animation leak found on the buildbot
     6        (m_animations and m_transitions were never deleted)
     7        Drag RenderStyle (kicking and screaming) into the 21st century
     8        of memory management with a little application of OwnPtr.
     9
     10        * rendering/style/RenderStyle.cpp:
     11        (WebCore::FillLayer::cullEmptyLayers):
     12        (WebCore::RenderStyle::diff):
     13        (WebCore::RenderStyle::contentDataEquivalent):
     14        (WebCore::RenderStyle::setContent):
     15        (WebCore::BindingURI::BindingURI):
     16        (WebCore::RenderStyle::setBoxShadow):
     17        (WebCore::ShadowData::ShadowData):
     18        (WebCore::RenderStyle::counterDirectives):
     19        (WebCore::RenderStyle::accessCounterDirectives):
     20        (WebCore::RenderStyle::adjustAnimations):
     21        (WebCore::RenderStyle::adjustTransitions):
     22        (WebCore::RenderStyle::accessAnimations):
     23        (WebCore::RenderStyle::accessTransitions):
     24        * rendering/style/RenderStyle.h:
     25        (WebCore::RenderStyle::clearAnimations):
     26        (WebCore::RenderStyle::clearTransitions):
     27
    1282008-08-06  Brady Eidson  <beidson@apple.com>
    229
  • trunk/WebCore/rendering/style/RenderStyle.cpp

    r35568 r35615  
    423423void FillLayer::cullEmptyLayers()
    424424{
    425     FillLayer *next;
    426     for (FillLayer *p = this; p; p = next) {
     425    FillLayer* next;
     426    for (FillLayer* p = this; p; p = next) {
    427427        next = p->m_next;
    428428        if (next && !next->isImageSet() &&
     
    896896StyleRareNonInheritedData::~StyleRareNonInheritedData()
    897897{
    898     delete m_content;
    899     delete m_counterDirectives;
    900     delete m_boxShadow;
    901 #if ENABLE(XBL)
    902     delete bindingURI;
    903 #endif
    904898}
    905899
     
    15361530
    15371531    // If the counter directives change, trigger a relayout to re-calculate counter values and rebuild the counter node tree.
    1538     const CounterDirectiveMap* mapA = rareNonInheritedData->m_counterDirectives;
    1539     const CounterDirectiveMap* mapB = other->rareNonInheritedData->m_counterDirectives;
     1532    const CounterDirectiveMap* mapA = rareNonInheritedData->m_counterDirectives.get();
     1533    const CounterDirectiveMap* mapB = other->rareNonInheritedData->m_counterDirectives.get();
    15401534    if (!(mapA == mapB || (mapA && mapB && *mapA == *mapB)))
    15411535        return Layout;
     
    16261620bool RenderStyle::contentDataEquivalent(const RenderStyle* otherStyle) const
    16271621{
    1628     ContentData* c1 = rareNonInheritedData->m_content;
    1629     ContentData* c2 = otherStyle->rareNonInheritedData->m_content;
     1622    ContentData* c1 = rareNonInheritedData->m_content.get();
     1623    ContentData* c2 = otherStyle->rareNonInheritedData->m_content.get();
    16301624
    16311625    while (c1 && c2) {
     
    16681662        return; // The object is null. Nothing to do. Just bail.
    16691663
    1670     ContentData*& content = rareNonInheritedData.access()->m_content;
    1671     ContentData* lastContent = content;
     1664    OwnPtr<ContentData>& content = rareNonInheritedData.access()->m_content;
     1665    ContentData* lastContent = content.get();
    16721666    while (lastContent && lastContent->m_next)
    16731667        lastContent = lastContent->m_next;
    16741668
    16751669    bool reuseContent = !add;
    1676     ContentData* newContentData = 0;
     1670    ContentData* newContentData;
    16771671    if (reuseContent && content) {
    16781672        content->clear();
    1679         newContentData = content;
     1673        newContentData = content.release();
    16801674    } else
    16811675        newContentData = new ContentData;
     
    16841678        lastContent->m_next = newContentData;
    16851679    else
    1686         content = newContentData;
     1680        content.set(newContentData);
    16871681
    16881682    newContentData->m_content.m_image = image;
     
    16961690        return; // The string is null. Nothing to do. Just bail.
    16971691   
    1698     ContentData*& content = rareNonInheritedData.access()->m_content;
    1699     ContentData* lastContent = content;
     1692    OwnPtr<ContentData>& content = rareNonInheritedData.access()->m_content;
     1693    ContentData* lastContent = content.get();
    17001694    while (lastContent && lastContent->m_next)
    17011695        lastContent = lastContent->m_next;
     
    17181712    if (reuseContent && content) {
    17191713        content->clear();
    1720         newContentData = content;
     1714        newContentData = content.release();
    17211715    } else
    17221716        newContentData = new ContentData;
     
    17251719        lastContent->m_next = newContentData;
    17261720    else
    1727         content = newContentData;
     1721        content.set(newContentData);
    17281722   
    17291723    newContentData->m_content.m_text = s;
     
    17371731        return;
    17381732
    1739     ContentData*& content = rareNonInheritedData.access()->m_content;
    1740     ContentData* lastContent = content;
     1733    OwnPtr<ContentData>& content = rareNonInheritedData.access()->m_content;
     1734    ContentData* lastContent = content.get();
    17411735    while (lastContent && lastContent->m_next)
    17421736        lastContent = lastContent->m_next;
     
    17461740    if (reuseContent && content) {
    17471741        content->clear();
    1748         newContentData = content;
     1742        newContentData = content.release();
    17491743    } else
    17501744        newContentData = new ContentData;
     
    17531747        lastContent->m_next = newContentData;
    17541748    else
    1755         content = newContentData;
     1749        content.set(newContentData);
    17561750
    17571751    newContentData->m_content.m_counter = c;
     
    18211815#if ENABLE(XBL)
    18221816BindingURI::BindingURI(StringImpl* uri)
    1823 :m_next(0)
     1817    : m_next(0)
    18241818{
    18251819    m_uri = uri;
    1826     if (uri) uri->ref();
     1820    if (uri)
     1821        uri->ref();
    18271822}
    18281823
     
    18851880}
    18861881
    1887 void RenderStyle::setBoxShadow(ShadowData* val, bool add)
     1882void RenderStyle::setBoxShadow(ShadowData* shadowData, bool add)
    18881883{
    18891884    StyleRareNonInheritedData* rareData = rareNonInheritedData.access();
    18901885    if (!add) {
    1891         delete rareData->m_boxShadow;
    1892         rareData->m_boxShadow = val;
     1886        rareData->m_boxShadow.set(shadowData);
    18931887        return;
    18941888    }
    18951889
    1896     val->next = rareData->m_boxShadow;
    1897     rareData->m_boxShadow = val;
     1890    shadowData->next = rareData->m_boxShadow.release();
     1891    rareData->m_boxShadow.set(shadowData);
    18981892}
    18991893
    19001894ShadowData::ShadowData(const ShadowData& o)
    1901 :x(o.x), y(o.y), blur(o.blur), color(o.color)
     1895    : x(o.x)
     1896    , y(o.y)
     1897    , blur(o.blur)
     1898    , color(o.color)
    19021899{
    19031900    next = o.next ? new ShadowData(*o.next) : 0;
     
    19261923const CounterDirectiveMap* RenderStyle::counterDirectives() const
    19271924{
    1928     return rareNonInheritedData->m_counterDirectives;
     1925    return rareNonInheritedData->m_counterDirectives.get();
    19291926}
    19301927
    19311928CounterDirectiveMap& RenderStyle::accessCounterDirectives()
    19321929{
    1933     CounterDirectiveMap*& map = rareNonInheritedData.access()->m_counterDirectives;
     1930    OwnPtr<CounterDirectiveMap>& map = rareNonInheritedData.access()->m_counterDirectives;
    19341931    if (!map)
    1935         map = new CounterDirectiveMap;
    1936     return *map;
     1932        map.set(new CounterDirectiveMap);
     1933    return *map.get();
    19371934}
    19381935
     
    19661963void RenderStyle::adjustAnimations()
    19671964{
    1968     AnimationList* animationList = rareNonInheritedData->m_animations;
     1965    AnimationList* animationList = rareNonInheritedData->m_animations.get();
    19691966    if (!animationList)
    19701967        return;
    1971 
    1972     if (animationList->size() == 0) {
    1973         clearAnimations();
    1974         return;
    1975     }
    19761968
    19771969    // get rid of empty transitions and anything beyond them
     
    19821974        }
    19831975    }
    1984    
    1985     if (animationList->size() == 0) {
     1976
     1977    if (animationList->isEmpty()) {
    19861978        clearAnimations();
    19871979        return;
    19881980    }
    1989    
     1981
    19901982    // Repeat patterns into layers that don't have some properties set.
    19911983    animationList->fillUnsetProperties();
     
    19941986void RenderStyle::adjustTransitions()
    19951987{
    1996     AnimationList* transitionList = rareNonInheritedData->m_transitions;
     1988    AnimationList* transitionList = rareNonInheritedData->m_transitions.get();
    19971989    if (!transitionList)
    19981990        return;
    1999    
    2000     if (transitionList->size() == 0) {
    2001         clearTransitions();
    2002         return;
    2003     }
    20041991
    20051992    // get rid of empty transitions and anything beyond them
     
    20111998    }
    20121999
    2013     if (transitionList->size() == 0) {
     2000    if (transitionList->isEmpty()) {
    20142001        clearTransitions();
    20152002        return;
     
    20342021AnimationList* RenderStyle::accessAnimations()
    20352022{
    2036     AnimationList* list = rareNonInheritedData.access()->m_animations;
    2037     if (!list)
    2038         rareNonInheritedData.access()->m_animations = new AnimationList();
    2039     return rareNonInheritedData->m_animations;
     2023    if (!rareNonInheritedData.access()->m_animations)
     2024        rareNonInheritedData.access()->m_animations.set(new AnimationList());
     2025    return rareNonInheritedData->m_animations.get();
    20402026}
    20412027
    20422028AnimationList* RenderStyle::accessTransitions()
    20432029{
    2044     AnimationList* list = rareNonInheritedData.access()->m_transitions;
    2045     if (!list)
    2046         rareNonInheritedData.access()->m_transitions = new AnimationList();
    2047     return rareNonInheritedData->m_transitions;
     2030    if (!rareNonInheritedData.access()->m_transitions)
     2031        rareNonInheritedData.access()->m_transitions.set(new AnimationList());
     2032    return rareNonInheritedData->m_transitions.get();
    20482033}
    20492034
  • trunk/WebCore/rendering/style/RenderStyle.h

    r35571 r35615  
    14391439    DataRef<StyleTransformData> m_transform; // Transform properties (rotate, scale, skew, etc.)
    14401440
    1441     ContentData* m_content;
    1442     CounterDirectiveMap* m_counterDirectives;
     1441    OwnPtr<ContentData> m_content;
     1442    OwnPtr<CounterDirectiveMap> m_counterDirectives;
    14431443
    14441444    unsigned userDrag : 2; // EUserDrag
     
    14491449    unsigned m_appearance : 6; // EAppearance
    14501450    unsigned m_borderFit : 1; // EBorderFit
    1451     ShadowData* m_boxShadow;  // For box-shadow decorations.
     1451    OwnPtr<ShadowData> m_boxShadow;  // For box-shadow decorations.
    14521452   
    14531453    RefPtr<StyleReflection> m_boxReflect;
    14541454
    1455     AnimationList* m_animations;
    1456     AnimationList* m_transitions;
     1455    OwnPtr<AnimationList> m_animations;
     1456    OwnPtr<AnimationList> m_transitions;
    14571457
    14581458    FillLayer m_mask;
     
    14601460
    14611461#if ENABLE(XBL)
    1462     BindingURI* bindingURI; // The XBL binding URI list.
     1462    OwnPtr<BindingURI> bindingURI; // The XBL binding URI list.
    14631463#endif
    14641464   
     
    21082108    EBoxOrient boxOrient() const { return static_cast<EBoxOrient>(rareNonInheritedData->flexibleBox->orient); }
    21092109    EBoxAlignment boxPack() const { return static_cast<EBoxAlignment>(rareNonInheritedData->flexibleBox->pack); }
    2110     ShadowData* boxShadow() const { return rareNonInheritedData->m_boxShadow; }
     2110    ShadowData* boxShadow() const { return rareNonInheritedData->m_boxShadow.get(); }
    21112111    StyleReflection* boxReflect() const { return rareNonInheritedData->m_boxReflect.get(); }
    21122112    EBoxSizing boxSizing() const { return static_cast<EBoxSizing>(box->boxSizing); }
     
    21522152
    21532153    // Apple-specific property getter methods
    2154     const AnimationList* animations() const { return rareNonInheritedData->m_animations; }
    2155     const AnimationList* transitions() const { return rareNonInheritedData->m_transitions; }
     2154    const AnimationList* animations() const { return rareNonInheritedData->m_animations.get(); }
     2155    const AnimationList* transitions() const { return rareNonInheritedData->m_transitions.get(); }
    21562156
    21572157    AnimationList* accessAnimations();
     
    23632363#if ENABLE(XBL)
    23642364    void deleteBindingURIs() {
    2365         delete rareNonInheritedData->bindingURI;
    23662365        SET_VAR(rareNonInheritedData, bindingURI, (BindingURI*) 0);
    23672366    }
     
    24292428    void clearAnimations()
    24302429    {
    2431         if (rareNonInheritedData.access()->m_animations) {
    2432             delete rareNonInheritedData.access()->m_animations;
    2433             rareNonInheritedData.access()->m_animations = 0;
    2434         }
     2430        rareNonInheritedData.access()->m_animations.clear();
    24352431    }
    24362432    void clearTransitions()
    24372433    {
    2438         if (rareNonInheritedData.access()->m_transitions) {
    2439             delete rareNonInheritedData.access()->m_transitions;
    2440             rareNonInheritedData.access()->m_transitions = 0;
    2441         }
    2442     }
    2443 
    2444     void inheritAnimations(const AnimationList* parent) { clearAnimations(); if (parent) rareNonInheritedData.access()->m_animations = new AnimationList(*parent); }
    2445     void inheritTransitions(const AnimationList* parent) { clearTransitions(); if (parent) rareNonInheritedData.access()->m_transitions = new AnimationList(*parent); }
     2434        rareNonInheritedData.access()->m_transitions.clear();
     2435    }
     2436
     2437    void inheritAnimations(const AnimationList* parent) { rareNonInheritedData.access()->m_animations.set(parent ? new AnimationList(*parent) : 0); }
     2438    void inheritTransitions(const AnimationList* parent) { rareNonInheritedData.access()->m_transitions.set(parent ? new AnimationList(*parent) : 0); }
    24462439    void adjustAnimations();
    24472440    void adjustTransitions();
     
    24572450#endif
    24582451
    2459     const ContentData* contentData() const { return rareNonInheritedData->m_content; }
     2452    const ContentData* contentData() const { return rareNonInheritedData->m_content.get(); }
    24602453    bool contentDataEquivalent(const RenderStyle* otherStyle) const;
    24612454    void clearContent();
Note: See TracChangeset for help on using the changeset viewer.