Modified: trunk/Source/WebCore/ChangeLog (158345 => 158346)
--- trunk/Source/WebCore/ChangeLog 2013-10-31 05:37:06 UTC (rev 158345)
+++ trunk/Source/WebCore/ChangeLog 2013-10-31 05:51:52 UTC (rev 158346)
@@ -1,3 +1,12 @@
+2013-10-30 Andreas Kling <[email protected]>
+
+ Manage EllipsisBox objects with unique_ptr.
+ <https://webkit.org/b/123554>
+
+ Use smart pointers to store ellipsis boxes instead of new/delete.
+
+ Reviewed by Anders Carlsson.
+
2013-10-30 Alexey Proskuryakov <[email protected]>
[Gtk] Build is failing after r158317
Modified: trunk/Source/WebCore/rendering/RootInlineBox.cpp (158345 => 158346)
--- trunk/Source/WebCore/rendering/RootInlineBox.cpp 2013-10-31 05:37:06 UTC (rev 158345)
+++ trunk/Source/WebCore/rendering/RootInlineBox.cpp 2013-10-31 05:51:52 UTC (rev 158346)
@@ -49,7 +49,7 @@
COMPILE_ASSERT(sizeof(RootInlineBox) == sizeof(SameSizeAsRootInlineBox), RootInlineBox_should_stay_small);
-typedef WTF::HashMap<const RootInlineBox*, EllipsisBox*> EllipsisBoxMap;
+typedef WTF::HashMap<const RootInlineBox*, std::unique_ptr<EllipsisBox>> EllipsisBoxMap;
static EllipsisBoxMap* gEllipsisBoxMap = 0;
RootInlineBox::RootInlineBox(RenderBlockFlow& block)
@@ -73,9 +73,8 @@
void RootInlineBox::detachEllipsisBox()
{
if (hasEllipsisBox()) {
- EllipsisBox* box = gEllipsisBoxMap->take(this);
- box->setParent(0);
- delete box;
+ auto box = gEllipsisBoxMap->take(this);
+ box->setParent(nullptr);
setHasEllipsisBox(false);
}
}
@@ -129,12 +128,14 @@
float RootInlineBox::placeEllipsis(const AtomicString& ellipsisStr, bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, InlineBox* markupBox)
{
+ if (!gEllipsisBoxMap)
+ gEllipsisBoxMap = new EllipsisBoxMap();
+
// Create an ellipsis box.
- EllipsisBox* ellipsisBox = new EllipsisBox(blockFlow(), ellipsisStr, this, ellipsisWidth - (markupBox ? markupBox->logicalWidth() : 0), logicalHeight(), y(), !prevRootBox(), isHorizontal(), markupBox);
+ auto newEllipsisBox = std::make_unique<EllipsisBox>(blockFlow(), ellipsisStr, this, ellipsisWidth - (markupBox ? markupBox->logicalWidth() : 0), logicalHeight(), y(), !prevRootBox(), isHorizontal(), markupBox);
+ auto ellipsisBox = newEllipsisBox.get();
- if (!gEllipsisBoxMap)
- gEllipsisBoxMap = new EllipsisBoxMap();
- gEllipsisBoxMap->add(this, ellipsisBox);
+ gEllipsisBoxMap->add(this, std::move(newEllipsisBox));
setHasEllipsisBox(true);
// FIXME: Do we need an RTL version of this?