Diff
Modified: trunk/Source/WebCore/ChangeLog (158717 => 158718)
--- trunk/Source/WebCore/ChangeLog 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/ChangeLog 2013-11-06 04:47:12 UTC (rev 158718)
@@ -1,3 +1,20 @@
+2013-11-05 Andreas Kling <[email protected]>
+
+ Apply more unique_ptr to line box management.
+ <https://webkit.org/b/123857>
+
+ Make all of the functions that return newly-created line boxes
+ return them packed up in std::unique_ptrs.
+
+ There is one exception in RenderBlockLineLayout where the function
+ createInlineBoxForRenderer() is inconsistent about the ownership of
+ the returned object. This will be addressed by a subsequent patch.
+
+ We now "release" the line boxes into their various home structures,
+ so the pointer smartness doesn't go end-to-end just yet.
+
+ Reviewed by Anders Carlsson.
+
2013-11-05 Ryosuke Niwa <[email protected]>
getComputedStyle(x).lineHeight is affected by zooming
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.h (158717 => 158718)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.h 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.h 2013-11-06 04:47:12 UTC (rev 158718)
@@ -461,7 +461,7 @@
void layoutLineBoxes(bool relayoutChildren, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom);
void layoutSimpleLines(LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom);
- virtual RootInlineBox* createRootInlineBox(); // Subclassed by SVG and Ruby.
+ virtual std::unique_ptr<RootInlineBox> createRootInlineBox(); // Subclassed by RenderSVGText.
InlineFlowBox* createLineBoxes(RenderObject*, const LineInfo&, InlineBox* childBox, bool startsNewSegment);
RootInlineBox* constructLine(BidiRunList<BidiRun>&, const LineInfo&);
void setMarginsForRubyRun(BidiRun*, RenderRubyRun&, RenderObject*, const LineInfo&);
Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (158717 => 158718)
--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp 2013-11-06 04:47:12 UTC (rev 158718)
@@ -283,15 +283,16 @@
}
}
-RootInlineBox* RenderBlockFlow::createRootInlineBox()
+std::unique_ptr<RootInlineBox> RenderBlockFlow::createRootInlineBox()
{
- return new RootInlineBox(*this);
+ return std::make_unique<RootInlineBox>(*this);
}
RootInlineBox* RenderBlockFlow::createAndAppendRootInlineBox()
{
- RootInlineBox* rootBox = createRootInlineBox();
- m_lineBoxes.appendLineBox(rootBox);
+ auto newRootBox = createRootInlineBox();
+ RootInlineBox* rootBox = newRootBox.get();
+ m_lineBoxes.appendLineBox(std::move(newRootBox));
if (UNLIKELY(AXObjectCache::accessibilityEnabled()) && m_lineBoxes.firstLineBox() == rootBox) {
if (AXObjectCache* cache = document().existingAXObjectCache())
@@ -310,11 +311,14 @@
if (obj->isText())
return toRenderText(obj)->createInlineTextBox();
- if (obj->isBox())
- return toRenderBox(obj)->createInlineBox();
+ if (obj->isBox()) {
+ // FIXME: This is terrible. This branch returns an *owned* pointer!
+ return toRenderBox(obj)->createInlineBox().release();
+ }
if (obj->isLineBreak()) {
- InlineBox* inlineBox = toRenderLineBreak(obj)->createInlineBox();
+ // FIXME: This is terrible. This branch returns an *owned* pointer!
+ InlineBox* inlineBox = toRenderLineBreak(obj)->createInlineBox().release();
// We only treat a box as text for a <br> if we are on a line by ourself or in strict mode
// (Note the use of strict mode. In "almost strict" mode, we don't treat the box for <br> as text.)
inlineBox->setBehavesLikeText(isOnlyRun || obj->document().inNoQuirksMode() || obj->isLineBreakOpportunity());
@@ -1792,8 +1796,9 @@
if (layoutState.checkForFloatsFromLastLine()) {
LayoutUnit bottomVisualOverflow = lastRootBox()->logicalBottomVisualOverflow();
LayoutUnit bottomLayoutOverflow = lastRootBox()->logicalBottomLayoutOverflow();
- TrailingFloatsRootInlineBox* trailingFloatsLineBox = new TrailingFloatsRootInlineBox(*this);
- m_lineBoxes.appendLineBox(trailingFloatsLineBox);
+ auto newLineBox = std::make_unique<TrailingFloatsRootInlineBox>(*this);
+ auto trailingFloatsLineBox = newLineBox.get();
+ m_lineBoxes.appendLineBox(std::move(newLineBox));
trailingFloatsLineBox->setConstructed();
GlyphOverflowAndFallbackFontsMap textBoxDataMap;
VerticalPositionCache verticalPositionCache;
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (158717 => 158718)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2013-11-06 04:47:12 UTC (rev 158718)
@@ -1939,9 +1939,9 @@
return offset;
}
-InlineBox* RenderBox::createInlineBox()
+std::unique_ptr<InlineBox> RenderBox::createInlineBox()
{
- return new InlineBox(*this);
+ return std::make_unique<InlineBox>(*this);
}
void RenderBox::dirtyLineBoxes(bool fullLayout)
Modified: trunk/Source/WebCore/rendering/RenderBox.h (158717 => 158718)
--- trunk/Source/WebCore/rendering/RenderBox.h 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/rendering/RenderBox.h 2013-11-06 04:47:12 UTC (rev 158718)
@@ -373,7 +373,7 @@
void positionLineBox(InlineBox*);
- virtual InlineBox* createInlineBox();
+ virtual std::unique_ptr<InlineBox> createInlineBox();
void dirtyLineBoxes(bool fullLayout);
// For inline replaced elements, this function returns the inline box that owns us. Enables
Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (158717 => 158718)
--- trunk/Source/WebCore/rendering/RenderInline.cpp 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp 2013-11-06 04:47:12 UTC (rev 158718)
@@ -1342,16 +1342,17 @@
m_lineBoxes.deleteLineBoxTree();
}
-InlineFlowBox* RenderInline::createInlineFlowBox()
+std::unique_ptr<InlineFlowBox> RenderInline::createInlineFlowBox()
{
- return new InlineFlowBox(*this);
+ return std::make_unique<InlineFlowBox>(*this);
}
InlineFlowBox* RenderInline::createAndAppendInlineFlowBox()
{
setAlwaysCreateLineBoxes();
- InlineFlowBox* flowBox = createInlineFlowBox();
- m_lineBoxes.appendLineBox(flowBox);
+ auto newFlowBox = createInlineFlowBox();
+ auto flowBox = newFlowBox.get();
+ m_lineBoxes.appendLineBox(std::move(newFlowBox));
return flowBox;
}
Modified: trunk/Source/WebCore/rendering/RenderInline.h (158717 => 158718)
--- trunk/Source/WebCore/rendering/RenderInline.h 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/rendering/RenderInline.h 2013-11-06 04:47:12 UTC (rev 158718)
@@ -146,7 +146,7 @@
return IntRect(0, 0, boundingBox.width(), boundingBox.height());
}
- virtual InlineFlowBox* createInlineFlowBox(); // Subclassed by SVG and Ruby
+ virtual std::unique_ptr<InlineFlowBox> createInlineFlowBox(); // Subclassed by RenderSVGInline
virtual void dirtyLinesFromChangedChild(RenderObject* child) OVERRIDE FINAL { m_lineBoxes.dirtyLinesFromChangedChild(this, child); }
Modified: trunk/Source/WebCore/rendering/RenderLineBoxList.cpp (158717 => 158718)
--- trunk/Source/WebCore/rendering/RenderLineBoxList.cpp 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/rendering/RenderLineBoxList.cpp 2013-11-06 04:47:12 UTC (rev 158718)
@@ -50,16 +50,19 @@
}
#endif
-void RenderLineBoxList::appendLineBox(InlineFlowBox* box)
+void RenderLineBoxList::appendLineBox(std::unique_ptr<InlineFlowBox> box)
{
checkConsistency();
-
- if (!m_firstLineBox)
- m_firstLineBox = m_lastLineBox = box;
- else {
- m_lastLineBox->setNextLineBox(box);
- box->setPreviousLineBox(m_lastLineBox);
- m_lastLineBox = box;
+
+ InlineFlowBox* boxPtr = box.release();
+
+ if (!m_firstLineBox) {
+ m_firstLineBox = boxPtr;
+ m_lastLineBox = boxPtr;
+ } else {
+ m_lastLineBox->setNextLineBox(boxPtr);
+ boxPtr->setPreviousLineBox(m_lastLineBox);
+ m_lastLineBox = boxPtr;
}
checkConsistency();
Modified: trunk/Source/WebCore/rendering/RenderLineBoxList.h (158717 => 158718)
--- trunk/Source/WebCore/rendering/RenderLineBoxList.h 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/rendering/RenderLineBoxList.h 2013-11-06 04:47:12 UTC (rev 158718)
@@ -54,7 +54,7 @@
void checkConsistency() const;
- void appendLineBox(InlineFlowBox*);
+ void appendLineBox(std::unique_ptr<InlineFlowBox>);
void deleteLineBoxTree();
void deleteLineBoxes();
Modified: trunk/Source/WebCore/rendering/RenderLineBreak.cpp (158717 => 158718)
--- trunk/Source/WebCore/rendering/RenderLineBreak.cpp 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/rendering/RenderLineBreak.cpp 2013-11-06 04:47:12 UTC (rev 158718)
@@ -67,9 +67,9 @@
return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction, linePositionMode) - fontMetrics.height()) / 2;
}
-InlineBox* RenderLineBreak::createInlineBox()
+std::unique_ptr<InlineBox> RenderLineBreak::createInlineBox()
{
- return new InlineBox(*this);
+ return std::make_unique<InlineBox>(*this);
}
void RenderLineBreak::setInlineBoxWrapper(InlineBox* inlineBox)
Modified: trunk/Source/WebCore/rendering/RenderLineBreak.h (158717 => 158718)
--- trunk/Source/WebCore/rendering/RenderLineBreak.h 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/rendering/RenderLineBreak.h 2013-11-06 04:47:12 UTC (rev 158718)
@@ -39,7 +39,7 @@
virtual bool isWBR() const OVERRIDE { return m_isWBR; }
- InlineBox* createInlineBox();
+ std::unique_ptr<InlineBox> createInlineBox();
InlineBox* inlineBoxWrapper() const { return m_inlineBoxWrapper; }
void setInlineBoxWrapper(InlineBox*);
void deleteInlineBoxWrapper();
Modified: trunk/Source/WebCore/rendering/RenderListMarker.cpp (158717 => 158718)
--- trunk/Source/WebCore/rendering/RenderListMarker.cpp 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/rendering/RenderListMarker.cpp 2013-11-06 04:47:12 UTC (rev 158718)
@@ -1148,11 +1148,11 @@
}
}
-InlineBox* RenderListMarker::createInlineBox()
+std::unique_ptr<InlineBox> RenderListMarker::createInlineBox()
{
- InlineBox* result = RenderBox::createInlineBox();
- result->setBehavesLikeText(isText());
- return result;
+ auto box = RenderBox::createInlineBox();
+ box->setBehavesLikeText(isText());
+ return box;
}
bool RenderListMarker::isImage() const
Modified: trunk/Source/WebCore/rendering/RenderListMarker.h (158717 => 158718)
--- trunk/Source/WebCore/rendering/RenderListMarker.h 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/rendering/RenderListMarker.h 2013-11-06 04:47:12 UTC (rev 158718)
@@ -60,7 +60,7 @@
virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) OVERRIDE;
- virtual InlineBox* createInlineBox() OVERRIDE;
+ virtual std::unique_ptr<InlineBox> createInlineBox() OVERRIDE;
virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE;
virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE;
Modified: trunk/Source/WebCore/rendering/RenderText.cpp (158717 => 158718)
--- trunk/Source/WebCore/rendering/RenderText.cpp 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/rendering/RenderText.cpp 2013-11-06 04:47:12 UTC (rev 158718)
@@ -1023,9 +1023,9 @@
m_linesDirty = false;
}
-InlineTextBox* RenderText::createTextBox()
+std::unique_ptr<InlineTextBox> RenderText::createTextBox()
{
- return new InlineTextBox(*this);
+ return std::make_unique<InlineTextBox>(*this);
}
void RenderText::positionLineBox(InlineBox* box)
Modified: trunk/Source/WebCore/rendering/RenderText.h (158717 => 158718)
--- trunk/Source/WebCore/rendering/RenderText.h 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/rendering/RenderText.h 2013-11-06 04:47:12 UTC (rev 158718)
@@ -145,7 +145,7 @@
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
- virtual InlineTextBox* createTextBox(); // Subclassed by RenderSVGInlineText.
+ virtual std::unique_ptr<InlineTextBox> createTextBox(); // Subclassed by RenderSVGInlineText.
#if ENABLE(IOS_TEXT_AUTOSIZING)
float candidateComputedTextSize() const { return m_candidateComputedTextSize; }
Modified: trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp (158717 => 158718)
--- trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp 2013-11-06 04:47:12 UTC (rev 158718)
@@ -44,14 +44,14 @@
{
auto textBox = renderText.createTextBox();
if (!m_first) {
- m_first = textBox;
- m_last = textBox;
+ m_first = textBox.get();
+ m_last = textBox.get();
} else {
- m_last->setNextTextBox(textBox);
+ m_last->setNextTextBox(textBox.get());
textBox->setPreviousTextBox(m_last);
- m_last = textBox;
+ m_last = textBox.get();
}
- return textBox;
+ return textBox.release();
}
void RenderTextLineBoxes::extract(InlineTextBox& box)
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGInline.cpp (158717 => 158718)
--- trunk/Source/WebCore/rendering/svg/RenderSVGInline.cpp 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGInline.cpp 2013-11-06 04:47:12 UTC (rev 158718)
@@ -38,11 +38,11 @@
setAlwaysCreateLineBoxes();
}
-InlineFlowBox* RenderSVGInline::createInlineFlowBox()
+std::unique_ptr<InlineFlowBox> RenderSVGInline::createInlineFlowBox()
{
- InlineFlowBox* box = new SVGInlineFlowBox(*this);
+ auto box = std::make_unique<SVGInlineFlowBox>(*this);
box->setHasVirtualLogicalHeight();
- return box;
+ return std::move(box);
}
FloatRect RenderSVGInline::objectBoundingBox() const
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGInline.h (158717 => 158718)
--- trunk/Source/WebCore/rendering/svg/RenderSVGInline.h 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGInline.h 2013-11-06 04:47:12 UTC (rev 158718)
@@ -55,7 +55,7 @@
virtual const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const OVERRIDE FINAL;
virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const OVERRIDE FINAL;
- virtual InlineFlowBox* createInlineFlowBox() OVERRIDE FINAL;
+ virtual std::unique_ptr<InlineFlowBox> createInlineFlowBox() OVERRIDE FINAL;
virtual void willBeDestroyed() OVERRIDE FINAL;
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE FINAL;
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp (158717 => 158718)
--- trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp 2013-11-06 04:47:12 UTC (rev 158718)
@@ -106,11 +106,11 @@
textRenderer->subtreeStyleDidChange(this);
}
-InlineTextBox* RenderSVGInlineText::createTextBox()
+std::unique_ptr<InlineTextBox> RenderSVGInlineText::createTextBox()
{
- InlineTextBox* box = new SVGInlineTextBox(*this);
+ auto box = std::make_unique<SVGInlineTextBox>(*this);
box->setHasVirtualLogicalHeight();
- return box;
+ return std::move(box);
}
LayoutRect RenderSVGInlineText::localCaretRect(InlineBox* box, int caretOffset, LayoutUnit*)
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.h (158717 => 158718)
--- trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.h 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.h 2013-11-06 04:47:12 UTC (rev 158718)
@@ -62,7 +62,7 @@
virtual VisiblePosition positionForPoint(const LayoutPoint&) OVERRIDE;
virtual LayoutRect localCaretRect(InlineBox*, int caretOffset, LayoutUnit* extraWidthToEndOfLine = 0) OVERRIDE;
virtual IntRect linesBoundingBox() const OVERRIDE;
- virtual InlineTextBox* createTextBox() OVERRIDE;
+ virtual std::unique_ptr<InlineTextBox> createTextBox() OVERRIDE;
float m_scalingFactor;
Font m_scaledFont;
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp (158717 => 158718)
--- trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp 2013-11-06 04:47:12 UTC (rev 158718)
@@ -441,11 +441,11 @@
clearNeedsLayout();
}
-RootInlineBox* RenderSVGText::createRootInlineBox()
+std::unique_ptr<RootInlineBox> RenderSVGText::createRootInlineBox()
{
- RootInlineBox* box = new SVGRootInlineBox(*this);
+ auto box = std::make_unique<SVGRootInlineBox>(*this);
box->setHasVirtualLogicalHeight();
- return box;
+ return std::move(box);
}
bool RenderSVGText::nodeAtFloatPoint(const HitTestRequest& request, HitTestResult& result, const FloatPoint& pointInParent, HitTestAction hitTestAction)
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGText.h (158717 => 158718)
--- trunk/Source/WebCore/rendering/svg/RenderSVGText.h 2013-11-06 04:40:02 UTC (rev 158717)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGText.h 2013-11-06 04:47:12 UTC (rev 158718)
@@ -90,7 +90,7 @@
virtual const AffineTransform& localToParentTransform() const { return m_localTransform; }
virtual AffineTransform localTransform() const { return m_localTransform; }
- virtual RootInlineBox* createRootInlineBox();
+ virtual std::unique_ptr<RootInlineBox> createRootInlineBox() OVERRIDE;
virtual RenderBlock* firstLineBlock() const;
virtual void updateFirstLetter();