Migrate BidiRunList and BidiRun to automatic memory management
https://bugs.webkit.org/show_bug.cgi?id=156123
Reviewed by Simon Fraser.
BidiRunList, BidiRun, and BidiCharacterRun have all been doing manual
"new"s and "delete"s for years. This patch migrates those classes to
using std::unique_ptr.
No new tests because there is no behavior change.
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::drawBidiText):
* platform/text/BidiResolver.h:
(WebCore::BidiCharacterRun::BidiCharacterRun):
(WebCore::BidiCharacterRun::next):
(WebCore::BidiCharacterRun::takeNext):
(WebCore::BidiCharacterRun::setNext):
(WebCore::Subclass>::appendRunInternal):
* platform/text/BidiRunList.h:
(WebCore::BidiRunList::BidiRunList):
(WebCore::BidiRunList::firstRun):
(WebCore::BidiRunList<Run>::appendRun):
(WebCore::BidiRunList<Run>::prependRun):
(WebCore::BidiRunList<Run>::moveRunToEnd):
(WebCore::BidiRunList<Run>::moveRunToBeginning):
(WebCore::BidiRunList<Run>::replaceRunWithRuns):
(WebCore::BidiRunList<Run>::clear):
(WebCore::BidiRunList<Run>::reverseRuns):
(WebCore::BidiRunList<Run>::clearWithoutDestroyingRuns): Deleted.
(WebCore::BidiRunList<Run>::deleteRuns): Deleted.
* rendering/BidiRun.cpp:
(WebCore::BidiRun::takeNext):
* rendering/BidiRun.h:
(WebCore::BidiRun::next):
(WebCore::BidiRun::takeNext):
* rendering/InlineIterator.h:
(WebCore::addPlaceholderRunForIsolatedInline):
* rendering/RenderBlockLineLayout.cpp:
(WebCore::createRun):
(WebCore::RenderBlockFlow::handleTrailingSpaces):
(WebCore::RenderBlockFlow::layoutRunsAndFloatsInRange):
* rendering/line/LineBreaker.cpp:
(WebCore::LineBreaker::skipLeadingWhitespace):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@198970 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/rendering/RenderBlockLineLayout.cpp b/Source/WebCore/rendering/RenderBlockLineLayout.cpp
index 0e185241..8ed5be3 100644
--- a/Source/WebCore/rendering/RenderBlockLineLayout.cpp
+++ b/Source/WebCore/rendering/RenderBlockLineLayout.cpp
@@ -71,9 +71,9 @@
}
}
-inline BidiRun* createRun(int start, int end, RenderObject& obj, InlineBidiResolver& resolver)
+inline std::unique_ptr<BidiRun> createRun(int start, int end, RenderObject& obj, InlineBidiResolver& resolver)
{
- return new BidiRun(start, end, obj, resolver.context(), resolver.dir());
+ return std::make_unique<BidiRun>(start, end, obj, resolver.context(), resolver.dir());
}
void RenderBlockFlow::appendRunsForObject(BidiRunList<BidiRun>* runs, int start, int end, RenderObject& obj, InlineBidiResolver& resolver)
@@ -100,7 +100,7 @@
} else {
if (!haveNextMidpoint || (&obj != nextMidpoint.renderer())) {
if (runs)
- runs->addRun(createRun(start, end, obj, resolver));
+ runs->appendRun(createRun(start, end, obj, resolver));
return;
}
@@ -111,10 +111,10 @@
if (nextMidpoint.refersToEndOfPreviousNode())
return;
if (static_cast<int>(nextMidpoint.offset() + 1) > start && runs)
- runs->addRun(createRun(start, nextMidpoint.offset() + 1, obj, resolver));
+ runs->appendRun(createRun(start, nextMidpoint.offset() + 1, obj, resolver));
appendRunsForObject(runs, nextMidpoint.offset() + 1, end, obj, resolver);
} else if (runs)
- runs->addRun(createRun(start, end, obj, resolver));
+ runs->appendRun(createRun(start, end, obj, resolver));
}
}
@@ -1036,13 +1036,13 @@
while (BidiContext* parent = baseContext->parent())
baseContext = parent;
- BidiRun* newTrailingRun = new BidiRun(firstSpace, trailingSpaceRun->m_stop, trailingSpaceRun->renderer(), baseContext, U_OTHER_NEUTRAL);
+ std::unique_ptr<BidiRun> newTrailingRun = std::make_unique<BidiRun>(firstSpace, trailingSpaceRun->m_stop, trailingSpaceRun->renderer(), baseContext, U_OTHER_NEUTRAL);
trailingSpaceRun->m_stop = firstSpace;
+ trailingSpaceRun = newTrailingRun.get();
if (direction == LTR)
- bidiRuns.addRun(newTrailingRun);
+ bidiRuns.appendRun(WTFMove(newTrailingRun));
else
- bidiRuns.prependRun(newTrailingRun);
- trailingSpaceRun = newTrailingRun;
+ bidiRuns.prependRun(WTFMove(newTrailingRun));
return trailingSpaceRun;
}
if (!shouldReorder)
@@ -1321,7 +1321,7 @@
if (resolver.position().atEnd()) {
// FIXME: We shouldn't be creating any runs in nextLineBreak to begin with!
// Once BidiRunList is separated from BidiResolver this will not be needed.
- resolver.runs().deleteRuns();
+ resolver.runs().clear();
resolver.markCurrentRunEmpty(); // FIXME: This can probably be replaced by an ASSERT (or just removed).
layoutState.setCheckForFloatsFromLastLine(true);
resolver.setPosition(InlineIterator(resolver.position().root(), 0, 0), 0);
@@ -1362,7 +1362,7 @@
LayoutUnit oldLogicalHeight = logicalHeight();
RootInlineBox* lineBox = createLineBoxesFromBidiRuns(resolver.status().context->level(), bidiRuns, end, layoutState.lineInfo(), verticalPositionCache, trailingSpaceRun, wordMeasurements);
- bidiRuns.deleteRuns();
+ bidiRuns.clear();
resolver.markCurrentRunEmpty(); // FIXME: This can probably be replaced by an ASSERT (or just removed).
if (lineBox) {