<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[198970] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/198970">198970</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2016-04-02 00:01:43 -0700 (Sat, 02 Apr 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>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):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContextcpp">trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformtextBidiResolverh">trunk/Source/WebCore/platform/text/BidiResolver.h</a></li>
<li><a href="#trunkSourceWebCoreplatformtextBidiRunListh">trunk/Source/WebCore/platform/text/BidiRunList.h</a></li>
<li><a href="#trunkSourceWebCorerenderingBidiRuncpp">trunk/Source/WebCore/rendering/BidiRun.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingBidiRunh">trunk/Source/WebCore/rendering/BidiRun.h</a></li>
<li><a href="#trunkSourceWebCorerenderingInlineIteratorh">trunk/Source/WebCore/rendering/InlineIterator.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockLineLayoutcpp">trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderinglineLineBreakercpp">trunk/Source/WebCore/rendering/line/LineBreaker.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (198969 => 198970)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-04-02 05:41:11 UTC (rev 198969)
+++ trunk/Source/WebCore/ChangeLog        2016-04-02 07:01:43 UTC (rev 198970)
</span><span class="lines">@@ -1,3 +1,50 @@
</span><ins>+2016-04-01 Myles C. Maxfield <mmaxfield@apple.com>
+
+ 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):
+
</ins><span class="cx"> 2016-04-01 Simon Fraser <simon.fraser@apple.com>
</span><span class="cx">
</span><span class="cx"> Backdrop Filter should repaint when changed via script
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (198969 => 198970)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp        2016-04-02 05:41:11 UTC (rev 198969)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp        2016-04-02 07:01:43 UTC (rev 198970)
</span><span class="lines">@@ -697,7 +697,7 @@
</span><span class="cx"> bidiRun = bidiRun->next();
</span><span class="cx"> }
</span><span class="cx">
</span><del>- bidiRuns.deleteRuns();
</del><ins>+ bidiRuns.clear();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void GraphicsContext::drawImage(Image& image, const FloatPoint& destination, const ImagePaintingOptions& imagePaintingOptions)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformtextBidiResolverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/text/BidiResolver.h (198969 => 198970)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/text/BidiResolver.h        2016-04-02 05:41:11 UTC (rev 198969)
+++ trunk/Source/WebCore/platform/text/BidiResolver.h        2016-04-02 07:01:43 UTC (rev 198970)
</span><span class="lines">@@ -155,10 +155,9 @@
</span><span class="cx"> WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><span class="cx"> BidiCharacterRun(int start, int stop, BidiContext* context, UCharDirection direction)
</span><del>- : m_override(context->override())
- , m_next(0)
- , m_start(start)
</del><ins>+ : m_start(start)
</ins><span class="cx"> , m_stop(stop)
</span><ins>+ , m_override(context->override())
</ins><span class="cx"> {
</span><span class="cx"> if (direction == U_OTHER_NEUTRAL)
</span><span class="cx"> direction = context->dir();
</span><span class="lines">@@ -183,16 +182,19 @@
</span><span class="cx"> bool reversed(bool visuallyOrdered) { return m_level % 2 && !visuallyOrdered; }
</span><span class="cx"> bool dirOverride(bool visuallyOrdered) { return m_override || visuallyOrdered; }
</span><span class="cx">
</span><del>- BidiCharacterRun* next() const { return m_next; }
- void setNext(BidiCharacterRun* next) { m_next = next; }
</del><ins>+ BidiCharacterRun* next() const { return m_next.get(); }
+ std::unique_ptr<BidiCharacterRun> takeNext() { return WTFMove(m_next); }
+ void setNext(std::unique_ptr<BidiCharacterRun>&& next) { m_next = WTFMove(next); }
</ins><span class="cx">
</span><del>- // Do not add anything apart from bitfields until after m_next. See https://bugs.webkit.org/show_bug.cgi?id=100173
</del><ins>+private:
+ std::unique_ptr<BidiCharacterRun> m_next;
+
+public:
+ int m_start;
+ int m_stop;
+ unsigned char m_level;
</ins><span class="cx"> bool m_override : 1;
</span><span class="cx"> bool m_hasHyphen : 1; // Used by BidiRun subclass which is a layering violation but enables us to save 8 bytes per object on 64-bit.
</span><del>- unsigned char m_level;
- BidiCharacterRun* m_next;
- int m_start;
- int m_stop;
</del><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> enum VisualDirectionOverride {
</span><span class="lines">@@ -341,7 +343,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (endOffset >= startOffset)
</span><del>- m_runs.addRun(new Run(startOffset, endOffset + 1, context(), m_direction));
</del><ins>+ m_runs.appendRun(std::make_unique<Run>(startOffset, endOffset + 1, context(), m_direction));
</ins><span class="cx">
</span><span class="cx"> m_eor.increment();
</span><span class="cx"> m_sor = m_eor;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformtextBidiRunListh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/text/BidiRunList.h (198969 => 198970)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/text/BidiRunList.h        2016-04-02 05:41:11 UTC (rev 198969)
+++ trunk/Source/WebCore/platform/text/BidiRunList.h        2016-04-02 07:01:43 UTC (rev 198970)
</span><span class="lines">@@ -32,9 +32,8 @@
</span><span class="cx"> WTF_MAKE_NONCOPYABLE(BidiRunList);
</span><span class="cx"> public:
</span><span class="cx"> BidiRunList()
</span><del>- : m_firstRun(0)
- , m_lastRun(0)
- , m_logicallyLastRun(0)
</del><ins>+ : m_lastRun(nullptr)
+ , m_logicallyLastRun(nullptr)
</ins><span class="cx"> , m_runCount(0)
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -42,18 +41,18 @@
</span><span class="cx"> // FIXME: Once BidiResolver no longer owns the BidiRunList,
</span><span class="cx"> // then ~BidiRunList should call deleteRuns() automatically.
</span><span class="cx">
</span><del>- Run* firstRun() const { return m_firstRun; }
</del><ins>+ Run* firstRun() const { return m_firstRun.get(); }
</ins><span class="cx"> Run* lastRun() const { return m_lastRun; }
</span><span class="cx"> Run* logicallyLastRun() const { return m_logicallyLastRun; }
</span><span class="cx"> unsigned runCount() const { return m_runCount; }
</span><span class="cx">
</span><del>- void addRun(Run*);
- void prependRun(Run*);
</del><ins>+ void appendRun(std::unique_ptr<Run>&&);
+ void prependRun(std::unique_ptr<Run>&&);
</ins><span class="cx">
</span><span class="cx"> void moveRunToEnd(Run*);
</span><span class="cx"> void moveRunToBeginning(Run*);
</span><span class="cx">
</span><del>- void deleteRuns();
</del><ins>+ void clear();
</ins><span class="cx"> void reverseRuns(unsigned start, unsigned end);
</span><span class="cx"> void reorderRunsFromLevels();
</span><span class="cx">
</span><span class="lines">@@ -62,35 +61,38 @@
</span><span class="cx"> void replaceRunWithRuns(Run* toReplace, BidiRunList<Run>& newRuns);
</span><span class="cx">
</span><span class="cx"> private:
</span><del>- void clearWithoutDestroyingRuns();
</del><span class="cx">
</span><del>- Run* m_firstRun;
</del><ins>+ // The runs form a singly-linked-list, where the links (Run::m_next) imply ownership (and are of type std::unique_ptr).
+ // The raw pointers below point into the singly-linked-list.
+ std::unique_ptr<Run> m_firstRun; // The head of the list
</ins><span class="cx"> Run* m_lastRun;
</span><span class="cx"> Run* m_logicallyLastRun;
</span><span class="cx"> unsigned m_runCount;
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> template <class Run>
</span><del>-inline void BidiRunList<Run>::addRun(Run* run)
</del><ins>+inline void BidiRunList<Run>::appendRun(std::unique_ptr<Run>&& run)
</ins><span class="cx"> {
</span><del>- if (!m_firstRun)
- m_firstRun = run;
- else
- m_lastRun->m_next = run;
- m_lastRun = run;
</del><ins>+ if (!m_firstRun) {
+ m_firstRun = WTFMove(run);
+ m_lastRun = m_firstRun.get();
+ } else {
+ m_lastRun->setNext(WTFMove(run));
+ m_lastRun = m_lastRun->next();
+ }
</ins><span class="cx"> m_runCount++;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <class Run>
</span><del>-inline void BidiRunList<Run>::prependRun(Run* run)
</del><ins>+inline void BidiRunList<Run>::prependRun(std::unique_ptr<Run>&& run)
</ins><span class="cx"> {
</span><del>- ASSERT(!run->m_next);
</del><ins>+ ASSERT(!run->next());
</ins><span class="cx">
</span><span class="cx"> if (!m_lastRun)
</span><del>- m_lastRun = run;
</del><ins>+ m_lastRun = run.get();
</ins><span class="cx"> else
</span><del>- run->m_next = m_firstRun;
- m_firstRun = run;
</del><ins>+ run->setNext(WTFMove(m_firstRun));
+ m_firstRun = WTFMove(run);
</ins><span class="cx"> m_runCount++;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -99,23 +101,25 @@
</span><span class="cx"> {
</span><span class="cx"> ASSERT(m_firstRun);
</span><span class="cx"> ASSERT(m_lastRun);
</span><del>- ASSERT(run->m_next);
</del><ins>+ ASSERT(run->next());
</ins><span class="cx">
</span><del>- Run* current = 0;
- Run* next = m_firstRun;
- while (next != run) {
- current = next;
- next = current->next();
</del><ins>+ Run* previous = nullptr;
+ Run* current = m_firstRun.get();
+ while (current != run) {
+ previous = current;
+ current = previous->next();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- if (!current)
- m_firstRun = run->next();
- else
- current->m_next = run->m_next;
-
- run->m_next = 0;
- m_lastRun->m_next = run;
- m_lastRun = run;
</del><ins>+ if (!previous) {
+ ASSERT(m_firstRun.get() == run);
+ std::unique_ptr<Run> originalFirstRun = WTFMove(m_firstRun);
+ m_firstRun = originalFirstRun->takeNext();
+ m_lastRun->setNext(WTFMove(originalFirstRun));
+ } else {
+ std::unique_ptr<Run> target = previous->takeNext();
+ previous->setNext(current->takeNext());
+ m_lastRun->setNext(WTFMove(target));
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <class Run>
</span><span class="lines">@@ -123,21 +127,22 @@
</span><span class="cx"> {
</span><span class="cx"> ASSERT(m_firstRun);
</span><span class="cx"> ASSERT(m_lastRun);
</span><del>- ASSERT(run != m_firstRun);
</del><ins>+ ASSERT(run != m_firstRun.get());
</ins><span class="cx">
</span><del>- Run* current = m_firstRun;
- Run* next = current->next();
- while (next != run) {
- current = next;
- next = current->next();
</del><ins>+ Run* previous = m_firstRun.get();
+ Run* current = previous->next();
+ while (current != run) {
+ previous = current;
+ current = previous->next();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- current->m_next = run->m_next;
</del><ins>+ std::unique_ptr<Run> target = previous->takeNext();
+ previous->setNext(run->takeNext());
</ins><span class="cx"> if (run == m_lastRun)
</span><del>- m_lastRun = current;
</del><ins>+ m_lastRun = previous;
</ins><span class="cx">
</span><del>- run->m_next = m_firstRun;
- m_firstRun = run;
</del><ins>+ target->setNext(WTFMove(m_firstRun));
+ m_firstRun = WTFMove(target);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <class Run>
</span><span class="lines">@@ -147,56 +152,42 @@
</span><span class="cx"> ASSERT(m_firstRun);
</span><span class="cx"> ASSERT(toReplace);
</span><span class="cx">
</span><del>- if (m_firstRun == toReplace)
- m_firstRun = newRuns.firstRun();
- else {
- // Find the run just before "toReplace" in the list of runs.
- Run* previousRun = m_firstRun;
- while (previousRun->next() != toReplace)
- previousRun = previousRun->next();
- ASSERT(previousRun);
- previousRun->setNext(newRuns.firstRun());
- }
</del><ins>+ m_runCount += newRuns.runCount() - 1; // We are adding the new runs and removing toReplace.
</ins><span class="cx">
</span><del>- newRuns.lastRun()->setNext(toReplace->next());
-
- // Fix up any of other pointers which may now be stale.
</del><ins>+ // Fix up any pointers which may end up stale.
</ins><span class="cx"> if (m_lastRun == toReplace)
</span><span class="cx"> m_lastRun = newRuns.lastRun();
</span><span class="cx"> if (m_logicallyLastRun == toReplace)
</span><span class="cx"> m_logicallyLastRun = newRuns.logicallyLastRun();
</span><del>- m_runCount += newRuns.runCount() - 1; // We added the new runs and removed toReplace.
</del><span class="cx">
</span><del>- delete toReplace;
- newRuns.clearWithoutDestroyingRuns();
</del><ins>+ if (m_firstRun.get() == toReplace) {
+ newRuns.m_lastRun->setNext(m_firstRun->takeNext());
+ m_firstRun = WTFMove(newRuns.m_firstRun);
+ } else {
+ // Find the run just before "toReplace" in the list of runs.
+ Run* previousRun = m_firstRun.get();
+ while (previousRun->next() != toReplace)
+ previousRun = previousRun->next();
+ ASSERT(previousRun);
+
+ std::unique_ptr<Run> target = previousRun->takeNext();
+ previousRun->setNext(WTFMove(newRuns.m_firstRun));
+ newRuns.m_lastRun->setNext(target->takeNext());
+ }
+
+ newRuns.clear();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <class Run>
</span><del>-void BidiRunList<Run>::clearWithoutDestroyingRuns()
</del><ins>+void BidiRunList<Run>::clear()
</ins><span class="cx"> {
</span><del>- m_firstRun = 0;
- m_lastRun = 0;
- m_logicallyLastRun = 0;
</del><ins>+ m_firstRun = nullptr;
+ m_lastRun = nullptr;
+ m_logicallyLastRun = nullptr;
</ins><span class="cx"> m_runCount = 0;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <class Run>
</span><del>-void BidiRunList<Run>::deleteRuns()
-{
- if (!m_firstRun)
- return;
-
- Run* curr = m_firstRun;
- while (curr) {
- Run* s = curr->next();
- delete curr;
- curr = s;
- }
-
- clearWithoutDestroyingRuns();
-}
-
-template <class Run>
</del><span class="cx"> void BidiRunList<Run>::reverseRuns(unsigned start, unsigned end)
</span><span class="cx"> {
</span><span class="cx"> if (start >= end)
</span><span class="lines">@@ -206,44 +197,35 @@
</span><span class="cx">
</span><span class="cx"> // Get the item before the start of the runs to reverse and put it in
</span><span class="cx"> // |beforeStart|. |curr| should point to the first run to reverse.
</span><del>- Run* curr = m_firstRun;
- Run* beforeStart = 0;
</del><ins>+ Run* curr = m_firstRun.get();
+ Run* beforeStart = nullptr;
</ins><span class="cx"> unsigned i = 0;
</span><del>- while (i < start) {
- i++;
</del><ins>+ for (; i < start; ++i) {
</ins><span class="cx"> beforeStart = curr;
</span><span class="cx"> curr = curr->next();
</span><span class="cx"> }
</span><del>-
</del><span class="cx"> Run* startRun = curr;
</span><del>- while (i < end) {
- i++;
</del><ins>+
+ for (; i < end; ++i)
</ins><span class="cx"> curr = curr->next();
</span><del>- }
- Run* endRun = curr;
- Run* afterEnd = curr->next();
</del><span class="cx">
</span><del>- i = start;
- curr = startRun;
- Run* newNext = afterEnd;
- while (i <= end) {
- // Do the reversal.
- Run* next = curr->next();
- curr->m_next = newNext;
- newNext = curr;
- curr = next;
- i++;
</del><ins>+ if (!curr->next())
+ m_lastRun = startRun;
+
+ // Standard "sliding window" of 3 pointers
+ std::unique_ptr<Run> previous = curr->takeNext();
+ std::unique_ptr<Run> current = beforeStart ? beforeStart->takeNext() : WTFMove(m_firstRun);
+ while (current) {
+ std::unique_ptr<Run> next = current->takeNext();
+ current->setNext(WTFMove(previous));
+ previous = WTFMove(current);
+ current = WTFMove(next);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- // Now hook up beforeStart and afterEnd to the startRun and endRun.
</del><span class="cx"> if (beforeStart)
</span><del>- beforeStart->m_next = endRun;
</del><ins>+ beforeStart->setNext(WTFMove(previous));
</ins><span class="cx"> else
</span><del>- m_firstRun = endRun;
-
- startRun->m_next = afterEnd;
- if (!afterEnd)
- m_lastRun = startRun;
</del><ins>+ m_firstRun = WTFMove(previous);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingBidiRuncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/BidiRun.cpp (198969 => 198970)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/BidiRun.cpp        2016-04-02 05:41:11 UTC (rev 198969)
+++ trunk/Source/WebCore/rendering/BidiRun.cpp        2016-04-02 07:01:43 UTC (rev 198970)
</span><span class="lines">@@ -53,4 +53,12 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+std::unique_ptr<BidiRun> BidiRun::takeNext()
+{
+ std::unique_ptr<BidiCharacterRun> next = BidiCharacterRun::takeNext();
+ BidiCharacterRun* raw = next.release();
+ std::unique_ptr<BidiRun> result = std::unique_ptr<BidiRun>(static_cast<BidiRun*>(raw));
+ return result;
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCorerenderingBidiRunh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/BidiRun.h (198969 => 198970)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/BidiRun.h        2016-04-02 05:41:11 UTC (rev 198969)
+++ trunk/Source/WebCore/rendering/BidiRun.h        2016-04-02 07:01:43 UTC (rev 198970)
</span><span class="lines">@@ -37,7 +37,8 @@
</span><span class="cx"> BidiRun(int start, int stop, RenderObject&, BidiContext*, UCharDirection);
</span><span class="cx"> ~BidiRun();
</span><span class="cx">
</span><del>- BidiRun* next() { return static_cast<BidiRun*>(m_next); }
</del><ins>+ BidiRun* next() { return static_cast<BidiRun*>(BidiCharacterRun::next()); }
+ std::unique_ptr<BidiRun> takeNext();
</ins><span class="cx"> RenderObject& renderer() { return m_renderer; }
</span><span class="cx"> InlineBox* box() { return m_box; }
</span><span class="cx"> void setBox(InlineBox& box) { m_box = &box; }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingInlineIteratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/InlineIterator.h (198969 => 198970)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/InlineIterator.h        2016-04-02 05:41:11 UTC (rev 198969)
+++ trunk/Source/WebCore/rendering/InlineIterator.h        2016-04-02 07:01:43 UTC (rev 198970)
</span><span class="lines">@@ -492,12 +492,12 @@
</span><span class="cx"> // of BidiResolver which knows nothing about RenderObjects.
</span><span class="cx"> static inline void addPlaceholderRunForIsolatedInline(InlineBidiResolver& resolver, RenderObject& obj, unsigned pos, RenderElement& root)
</span><span class="cx"> {
</span><del>- BidiRun* isolatedRun = new BidiRun(pos, 0, obj, resolver.context(), resolver.dir());
- resolver.runs().addRun(isolatedRun);
</del><ins>+ std::unique_ptr<BidiRun> isolatedRun = std::make_unique<BidiRun>(pos, 0, obj, resolver.context(), resolver.dir());
</ins><span class="cx"> // FIXME: isolatedRuns() could be a hash of object->run and then we could cheaply
</span><span class="cx"> // ASSERT here that we didn't create multiple objects for the same inline.
</span><span class="cx"> resolver.setMidpointForIsolatedRun(*isolatedRun, resolver.midpointState().currentMidpoint());
</span><span class="cx"> resolver.isolatedRuns().append(BidiIsolatedRun(obj, pos, root, *isolatedRun));
</span><ins>+ resolver.runs().appendRun(WTFMove(isolatedRun));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> class IsolateTracker {
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockLineLayoutcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (198969 => 198970)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp        2016-04-02 05:41:11 UTC (rev 198969)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp        2016-04-02 07:01:43 UTC (rev 198970)
</span><span class="lines">@@ -71,9 +71,9 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-inline BidiRun* createRun(int start, int end, RenderObject& obj, InlineBidiResolver& resolver)
</del><ins>+inline std::unique_ptr<BidiRun> createRun(int start, int end, RenderObject& obj, InlineBidiResolver& resolver)
</ins><span class="cx"> {
</span><del>- return new BidiRun(start, end, obj, resolver.context(), resolver.dir());
</del><ins>+ return std::make_unique<BidiRun>(start, end, obj, resolver.context(), resolver.dir());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void RenderBlockFlow::appendRunsForObject(BidiRunList<BidiRun>* runs, int start, int end, RenderObject& obj, InlineBidiResolver& resolver)
</span><span class="lines">@@ -100,7 +100,7 @@
</span><span class="cx"> } else {
</span><span class="cx"> if (!haveNextMidpoint || (&obj != nextMidpoint.renderer())) {
</span><span class="cx"> if (runs)
</span><del>- runs->addRun(createRun(start, end, obj, resolver));
</del><ins>+ runs->appendRun(createRun(start, end, obj, resolver));
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -111,10 +111,10 @@
</span><span class="cx"> if (nextMidpoint.refersToEndOfPreviousNode())
</span><span class="cx"> return;
</span><span class="cx"> if (static_cast<int>(nextMidpoint.offset() + 1) > start && runs)
</span><del>- runs->addRun(createRun(start, nextMidpoint.offset() + 1, obj, resolver));
</del><ins>+ runs->appendRun(createRun(start, nextMidpoint.offset() + 1, obj, resolver));
</ins><span class="cx"> appendRunsForObject(runs, nextMidpoint.offset() + 1, end, obj, resolver);
</span><span class="cx"> } else if (runs)
</span><del>- runs->addRun(createRun(start, end, obj, resolver));
</del><ins>+ runs->appendRun(createRun(start, end, obj, resolver));
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1036,13 +1036,13 @@
</span><span class="cx"> while (BidiContext* parent = baseContext->parent())
</span><span class="cx"> baseContext = parent;
</span><span class="cx">
</span><del>- BidiRun* newTrailingRun = new BidiRun(firstSpace, trailingSpaceRun->m_stop, trailingSpaceRun->renderer(), baseContext, U_OTHER_NEUTRAL);
</del><ins>+ std::unique_ptr<BidiRun> newTrailingRun = std::make_unique<BidiRun>(firstSpace, trailingSpaceRun->m_stop, trailingSpaceRun->renderer(), baseContext, U_OTHER_NEUTRAL);
</ins><span class="cx"> trailingSpaceRun->m_stop = firstSpace;
</span><ins>+ trailingSpaceRun = newTrailingRun.get();
</ins><span class="cx"> if (direction == LTR)
</span><del>- bidiRuns.addRun(newTrailingRun);
</del><ins>+ bidiRuns.appendRun(WTFMove(newTrailingRun));
</ins><span class="cx"> else
</span><del>- bidiRuns.prependRun(newTrailingRun);
- trailingSpaceRun = newTrailingRun;
</del><ins>+ bidiRuns.prependRun(WTFMove(newTrailingRun));
</ins><span class="cx"> return trailingSpaceRun;
</span><span class="cx"> }
</span><span class="cx"> if (!shouldReorder)
</span><span class="lines">@@ -1321,7 +1321,7 @@
</span><span class="cx"> if (resolver.position().atEnd()) {
</span><span class="cx"> // FIXME: We shouldn't be creating any runs in nextLineBreak to begin with!
</span><span class="cx"> // Once BidiRunList is separated from BidiResolver this will not be needed.
</span><del>- resolver.runs().deleteRuns();
</del><ins>+ resolver.runs().clear();
</ins><span class="cx"> resolver.markCurrentRunEmpty(); // FIXME: This can probably be replaced by an ASSERT (or just removed).
</span><span class="cx"> layoutState.setCheckForFloatsFromLastLine(true);
</span><span class="cx"> resolver.setPosition(InlineIterator(resolver.position().root(), 0, 0), 0);
</span><span class="lines">@@ -1362,7 +1362,7 @@
</span><span class="cx"> LayoutUnit oldLogicalHeight = logicalHeight();
</span><span class="cx"> RootInlineBox* lineBox = createLineBoxesFromBidiRuns(resolver.status().context->level(), bidiRuns, end, layoutState.lineInfo(), verticalPositionCache, trailingSpaceRun, wordMeasurements);
</span><span class="cx">
</span><del>- bidiRuns.deleteRuns();
</del><ins>+ bidiRuns.clear();
</ins><span class="cx"> resolver.markCurrentRunEmpty(); // FIXME: This can probably be replaced by an ASSERT (or just removed).
</span><span class="cx">
</span><span class="cx"> if (lineBox) {
</span></span></pre></div>
<a id="trunkSourceWebCorerenderinglineLineBreakercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/line/LineBreaker.cpp (198969 => 198970)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/line/LineBreaker.cpp        2016-04-02 05:41:11 UTC (rev 198969)
+++ trunk/Source/WebCore/rendering/line/LineBreaker.cpp        2016-04-02 07:01:43 UTC (rev 198970)
</span><span class="lines">@@ -62,7 +62,7 @@
</span><span class="cx"> if (object.isOutOfFlowPositioned()) {
</span><span class="cx"> setStaticPositions(m_block, downcast<RenderBox>(object), width.shouldIndentText());
</span><span class="cx"> if (object.style().isOriginalDisplayInlineType()) {
</span><del>- resolver.runs().addRun(new BidiRun(0, 1, object, resolver.context(), resolver.dir()));
</del><ins>+ resolver.runs().appendRun(std::make_unique<BidiRun>(0, 1, object, resolver.context(), resolver.dir()));
</ins><span class="cx"> lineInfo.incrementRunsFromLeadingWhitespace();
</span><span class="cx"> }
</span><span class="cx"> } else if (object.isFloating())
</span></span></pre>
</div>
</div>
</body>
</html>