Changeset 35615 in webkit
- Timestamp:
- Aug 6, 2008 3:39:04 PM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r35614 r35615 1 2008-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 1 28 2008-08-06 Brady Eidson <beidson@apple.com> 2 29 -
trunk/WebCore/rendering/style/RenderStyle.cpp
r35568 r35615 423 423 void FillLayer::cullEmptyLayers() 424 424 { 425 FillLayer *next;426 for (FillLayer *p = this; p; p = next) {425 FillLayer* next; 426 for (FillLayer* p = this; p; p = next) { 427 427 next = p->m_next; 428 428 if (next && !next->isImageSet() && … … 896 896 StyleRareNonInheritedData::~StyleRareNonInheritedData() 897 897 { 898 delete m_content;899 delete m_counterDirectives;900 delete m_boxShadow;901 #if ENABLE(XBL)902 delete bindingURI;903 #endif904 898 } 905 899 … … 1536 1530 1537 1531 // 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(); 1540 1534 if (!(mapA == mapB || (mapA && mapB && *mapA == *mapB))) 1541 1535 return Layout; … … 1626 1620 bool RenderStyle::contentDataEquivalent(const RenderStyle* otherStyle) const 1627 1621 { 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(); 1630 1624 1631 1625 while (c1 && c2) { … … 1668 1662 return; // The object is null. Nothing to do. Just bail. 1669 1663 1670 ContentData*& content = rareNonInheritedData.access()->m_content;1671 ContentData* lastContent = content ;1664 OwnPtr<ContentData>& content = rareNonInheritedData.access()->m_content; 1665 ContentData* lastContent = content.get(); 1672 1666 while (lastContent && lastContent->m_next) 1673 1667 lastContent = lastContent->m_next; 1674 1668 1675 1669 bool reuseContent = !add; 1676 ContentData* newContentData = 0;1670 ContentData* newContentData; 1677 1671 if (reuseContent && content) { 1678 1672 content->clear(); 1679 newContentData = content ;1673 newContentData = content.release(); 1680 1674 } else 1681 1675 newContentData = new ContentData; … … 1684 1678 lastContent->m_next = newContentData; 1685 1679 else 1686 content = newContentData;1680 content.set(newContentData); 1687 1681 1688 1682 newContentData->m_content.m_image = image; … … 1696 1690 return; // The string is null. Nothing to do. Just bail. 1697 1691 1698 ContentData*& content = rareNonInheritedData.access()->m_content;1699 ContentData* lastContent = content ;1692 OwnPtr<ContentData>& content = rareNonInheritedData.access()->m_content; 1693 ContentData* lastContent = content.get(); 1700 1694 while (lastContent && lastContent->m_next) 1701 1695 lastContent = lastContent->m_next; … … 1718 1712 if (reuseContent && content) { 1719 1713 content->clear(); 1720 newContentData = content ;1714 newContentData = content.release(); 1721 1715 } else 1722 1716 newContentData = new ContentData; … … 1725 1719 lastContent->m_next = newContentData; 1726 1720 else 1727 content = newContentData;1721 content.set(newContentData); 1728 1722 1729 1723 newContentData->m_content.m_text = s; … … 1737 1731 return; 1738 1732 1739 ContentData*& content = rareNonInheritedData.access()->m_content;1740 ContentData* lastContent = content ;1733 OwnPtr<ContentData>& content = rareNonInheritedData.access()->m_content; 1734 ContentData* lastContent = content.get(); 1741 1735 while (lastContent && lastContent->m_next) 1742 1736 lastContent = lastContent->m_next; … … 1746 1740 if (reuseContent && content) { 1747 1741 content->clear(); 1748 newContentData = content ;1742 newContentData = content.release(); 1749 1743 } else 1750 1744 newContentData = new ContentData; … … 1753 1747 lastContent->m_next = newContentData; 1754 1748 else 1755 content = newContentData;1749 content.set(newContentData); 1756 1750 1757 1751 newContentData->m_content.m_counter = c; … … 1821 1815 #if ENABLE(XBL) 1822 1816 BindingURI::BindingURI(StringImpl* uri) 1823 :m_next(0)1817 : m_next(0) 1824 1818 { 1825 1819 m_uri = uri; 1826 if (uri) uri->ref(); 1820 if (uri) 1821 uri->ref(); 1827 1822 } 1828 1823 … … 1885 1880 } 1886 1881 1887 void RenderStyle::setBoxShadow(ShadowData* val, bool add)1882 void RenderStyle::setBoxShadow(ShadowData* shadowData, bool add) 1888 1883 { 1889 1884 StyleRareNonInheritedData* rareData = rareNonInheritedData.access(); 1890 1885 if (!add) { 1891 delete rareData->m_boxShadow; 1892 rareData->m_boxShadow = val; 1886 rareData->m_boxShadow.set(shadowData); 1893 1887 return; 1894 1888 } 1895 1889 1896 val->next = rareData->m_boxShadow;1897 rareData->m_boxShadow = val;1890 shadowData->next = rareData->m_boxShadow.release(); 1891 rareData->m_boxShadow.set(shadowData); 1898 1892 } 1899 1893 1900 1894 ShadowData::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) 1902 1899 { 1903 1900 next = o.next ? new ShadowData(*o.next) : 0; … … 1926 1923 const CounterDirectiveMap* RenderStyle::counterDirectives() const 1927 1924 { 1928 return rareNonInheritedData->m_counterDirectives ;1925 return rareNonInheritedData->m_counterDirectives.get(); 1929 1926 } 1930 1927 1931 1928 CounterDirectiveMap& RenderStyle::accessCounterDirectives() 1932 1929 { 1933 CounterDirectiveMap*& map = rareNonInheritedData.access()->m_counterDirectives;1930 OwnPtr<CounterDirectiveMap>& map = rareNonInheritedData.access()->m_counterDirectives; 1934 1931 if (!map) 1935 map = new CounterDirectiveMap;1936 return *map ;1932 map.set(new CounterDirectiveMap); 1933 return *map.get(); 1937 1934 } 1938 1935 … … 1966 1963 void RenderStyle::adjustAnimations() 1967 1964 { 1968 AnimationList* animationList = rareNonInheritedData->m_animations ;1965 AnimationList* animationList = rareNonInheritedData->m_animations.get(); 1969 1966 if (!animationList) 1970 1967 return; 1971 1972 if (animationList->size() == 0) {1973 clearAnimations();1974 return;1975 }1976 1968 1977 1969 // get rid of empty transitions and anything beyond them … … 1982 1974 } 1983 1975 } 1984 1985 if (animationList-> size() == 0) {1976 1977 if (animationList->isEmpty()) { 1986 1978 clearAnimations(); 1987 1979 return; 1988 1980 } 1989 1981 1990 1982 // Repeat patterns into layers that don't have some properties set. 1991 1983 animationList->fillUnsetProperties(); … … 1994 1986 void RenderStyle::adjustTransitions() 1995 1987 { 1996 AnimationList* transitionList = rareNonInheritedData->m_transitions ;1988 AnimationList* transitionList = rareNonInheritedData->m_transitions.get(); 1997 1989 if (!transitionList) 1998 1990 return; 1999 2000 if (transitionList->size() == 0) {2001 clearTransitions();2002 return;2003 }2004 1991 2005 1992 // get rid of empty transitions and anything beyond them … … 2011 1998 } 2012 1999 2013 if (transitionList-> size() == 0) {2000 if (transitionList->isEmpty()) { 2014 2001 clearTransitions(); 2015 2002 return; … … 2034 2021 AnimationList* RenderStyle::accessAnimations() 2035 2022 { 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(); 2040 2026 } 2041 2027 2042 2028 AnimationList* RenderStyle::accessTransitions() 2043 2029 { 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(); 2048 2033 } 2049 2034 -
trunk/WebCore/rendering/style/RenderStyle.h
r35571 r35615 1439 1439 DataRef<StyleTransformData> m_transform; // Transform properties (rotate, scale, skew, etc.) 1440 1440 1441 ContentData*m_content;1442 CounterDirectiveMap*m_counterDirectives;1441 OwnPtr<ContentData> m_content; 1442 OwnPtr<CounterDirectiveMap> m_counterDirectives; 1443 1443 1444 1444 unsigned userDrag : 2; // EUserDrag … … 1449 1449 unsigned m_appearance : 6; // EAppearance 1450 1450 unsigned m_borderFit : 1; // EBorderFit 1451 ShadowData*m_boxShadow; // For box-shadow decorations.1451 OwnPtr<ShadowData> m_boxShadow; // For box-shadow decorations. 1452 1452 1453 1453 RefPtr<StyleReflection> m_boxReflect; 1454 1454 1455 AnimationList*m_animations;1456 AnimationList*m_transitions;1455 OwnPtr<AnimationList> m_animations; 1456 OwnPtr<AnimationList> m_transitions; 1457 1457 1458 1458 FillLayer m_mask; … … 1460 1460 1461 1461 #if ENABLE(XBL) 1462 BindingURI*bindingURI; // The XBL binding URI list.1462 OwnPtr<BindingURI> bindingURI; // The XBL binding URI list. 1463 1463 #endif 1464 1464 … … 2108 2108 EBoxOrient boxOrient() const { return static_cast<EBoxOrient>(rareNonInheritedData->flexibleBox->orient); } 2109 2109 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(); } 2111 2111 StyleReflection* boxReflect() const { return rareNonInheritedData->m_boxReflect.get(); } 2112 2112 EBoxSizing boxSizing() const { return static_cast<EBoxSizing>(box->boxSizing); } … … 2152 2152 2153 2153 // 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(); } 2156 2156 2157 2157 AnimationList* accessAnimations(); … … 2363 2363 #if ENABLE(XBL) 2364 2364 void deleteBindingURIs() { 2365 delete rareNonInheritedData->bindingURI;2366 2365 SET_VAR(rareNonInheritedData, bindingURI, (BindingURI*) 0); 2367 2366 } … … 2429 2428 void clearAnimations() 2430 2429 { 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(); 2435 2431 } 2436 2432 void clearTransitions() 2437 2433 { 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); } 2446 2439 void adjustAnimations(); 2447 2440 void adjustTransitions(); … … 2457 2450 #endif 2458 2451 2459 const ContentData* contentData() const { return rareNonInheritedData->m_content ; }2452 const ContentData* contentData() const { return rareNonInheritedData->m_content.get(); } 2460 2453 bool contentDataEquivalent(const RenderStyle* otherStyle) const; 2461 2454 void clearContent();
Note: See TracChangeset
for help on using the changeset viewer.