Title: [223018] trunk/Source/WebCore
- Revision
- 223018
- Author
- [email protected]
- Date
- 2017-10-06 21:15:03 -0700 (Fri, 06 Oct 2017)
Log Message
RenderTable should not hold a collection of raw pointers to RenderTableCaption
https://bugs.webkit.org/show_bug.cgi?id=178026
<rdar://problem/34863090>
Reviewed by Simon Fraser.
Similar to sections, RenderTable should not store captions as raw pointers. Their lifetimes are
not guaranteed to be sync with the RenderTable's.
Covered by existing tests.
* rendering/RenderTable.cpp:
(WebCore::RenderTable::addCaption):
(WebCore::RenderTable::removeCaption):
(WebCore::RenderTable::addOverflowFromChildren):
* rendering/RenderTable.h:
* rendering/RenderTableCaption.cpp:
(WebCore::RenderTableCaption::insertedIntoTree):
(WebCore::RenderTableCaption::willBeRemovedFromTree):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (223017 => 223018)
--- trunk/Source/WebCore/ChangeLog 2017-10-07 02:36:59 UTC (rev 223017)
+++ trunk/Source/WebCore/ChangeLog 2017-10-07 04:15:03 UTC (rev 223018)
@@ -1,3 +1,25 @@
+2017-10-06 Zalan Bujtas <[email protected]>
+
+ RenderTable should not hold a collection of raw pointers to RenderTableCaption
+ https://bugs.webkit.org/show_bug.cgi?id=178026
+ <rdar://problem/34863090>
+
+ Reviewed by Simon Fraser.
+
+ Similar to sections, RenderTable should not store captions as raw pointers. Their lifetimes are
+ not guaranteed to be sync with the RenderTable's.
+
+ Covered by existing tests.
+
+ * rendering/RenderTable.cpp:
+ (WebCore::RenderTable::addCaption):
+ (WebCore::RenderTable::removeCaption):
+ (WebCore::RenderTable::addOverflowFromChildren):
+ * rendering/RenderTable.h:
+ * rendering/RenderTableCaption.cpp:
+ (WebCore::RenderTableCaption::insertedIntoTree):
+ (WebCore::RenderTableCaption::willBeRemovedFromTree):
+
2017-10-06 Daniel Bates <[email protected]>
Spelling error annotation should encompass hyphen in misspelled word that wraps across multiple lines
Modified: trunk/Source/WebCore/rendering/RenderTable.cpp (223017 => 223018)
--- trunk/Source/WebCore/rendering/RenderTable.cpp 2017-10-07 02:36:59 UTC (rev 223017)
+++ trunk/Source/WebCore/rendering/RenderTable.cpp 2017-10-07 04:15:03 UTC (rev 223018)
@@ -218,15 +218,15 @@
section.addChild(WTFMove(child));
}
-void RenderTable::addCaption(const RenderTableCaption* caption)
+void RenderTable::addCaption(RenderTableCaption& caption)
{
- ASSERT(m_captions.find(caption) == notFound);
- m_captions.append(const_cast<RenderTableCaption*>(caption));
+ ASSERT(m_captions.find(&caption) == notFound);
+ m_captions.append(makeWeakPtr(caption));
}
-void RenderTable::removeCaption(const RenderTableCaption* oldCaption)
+void RenderTable::removeCaption(RenderTableCaption& oldCaption)
{
- bool removed = m_captions.removeFirst(oldCaption);
+ bool removed = m_captions.removeFirst(&oldCaption);
ASSERT_UNUSED(removed, removed);
}
@@ -686,7 +686,7 @@
// Add overflow from our caption.
for (unsigned i = 0; i < m_captions.size(); i++)
- addOverflowFromChild(m_captions[i]);
+ addOverflowFromChild(m_captions[i].get());
// Add overflow from our sections.
for (RenderTableSection* section = topSection(); section; section = sectionBelow(section))
Modified: trunk/Source/WebCore/rendering/RenderTable.h (223017 => 223018)
--- trunk/Source/WebCore/rendering/RenderTable.h 2017-10-07 02:36:59 UTC (rev 223017)
+++ trunk/Source/WebCore/rendering/RenderTable.h 2017-10-07 04:15:03 UTC (rev 223018)
@@ -256,8 +256,8 @@
const BorderValue& tableStartBorderAdjoiningCell(const RenderTableCell&) const;
const BorderValue& tableEndBorderAdjoiningCell(const RenderTableCell&) const;
- void addCaption(const RenderTableCaption*);
- void removeCaption(const RenderTableCaption*);
+ void addCaption(RenderTableCaption&);
+ void removeCaption(RenderTableCaption&);
void addColumn(const RenderTableCol*);
void removeColumn(const RenderTableCol*);
@@ -325,7 +325,7 @@
mutable Vector<LayoutUnit> m_columnPos;
mutable Vector<ColumnStruct> m_columns;
- mutable Vector<RenderTableCaption*> m_captions;
+ mutable Vector<WeakPtr<RenderTableCaption>> m_captions;
mutable Vector<WeakPtr<RenderTableCol>> m_columnRenderers;
unsigned effectiveIndexOfColumn(const RenderTableCol&) const;
Modified: trunk/Source/WebCore/rendering/RenderTableCaption.cpp (223017 => 223018)
--- trunk/Source/WebCore/rendering/RenderTableCaption.cpp 2017-10-07 02:36:59 UTC (rev 223017)
+++ trunk/Source/WebCore/rendering/RenderTableCaption.cpp 2017-10-07 04:15:03 UTC (rev 223018)
@@ -36,13 +36,13 @@
void RenderTableCaption::insertedIntoTree()
{
RenderBlockFlow::insertedIntoTree();
- table()->addCaption(this);
+ table()->addCaption(*this);
}
void RenderTableCaption::willBeRemovedFromTree()
{
RenderBlockFlow::willBeRemovedFromTree();
- table()->removeCaption(this);
+ table()->removeCaption(*this);
}
RenderTable* RenderTableCaption::table() const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes