Modified: trunk/Source/WebCore/rendering/FloatingObjects.cpp (225747 => 225748)
--- trunk/Source/WebCore/rendering/FloatingObjects.cpp 2017-12-11 18:09:32 UTC (rev 225747)
+++ trunk/Source/WebCore/rendering/FloatingObjects.cpp 2017-12-11 18:23:48 UTC (rev 225748)
@@ -43,7 +43,7 @@
COMPILE_ASSERT(sizeof(FloatingObject) == sizeof(SameSizeAsFloatingObject), FloatingObject_should_stay_small);
FloatingObject::FloatingObject(RenderBox& renderer)
- : m_renderer(renderer)
+ : m_renderer(makeWeakPtr(renderer))
, m_shouldPaint(true)
, m_isDescendant(false)
, m_isPlaced(false)
@@ -60,7 +60,7 @@
}
FloatingObject::FloatingObject(RenderBox& renderer, Type type, const LayoutRect& frameRect, const LayoutSize& marginOffset, bool shouldPaint, bool isDescendant)
- : m_renderer(renderer)
+ : m_renderer(makeWeakPtr(renderer))
, m_frameRect(frameRect)
, m_marginOffset(marginOffset)
, m_type(type)
@@ -124,8 +124,8 @@
public:
typedef FloatingObjectInterval IntervalType;
- ComputeFloatOffsetAdapter(const RenderBlockFlow& renderer, LayoutUnit lineTop, LayoutUnit lineBottom, LayoutUnit offset)
- : m_renderer(renderer)
+ ComputeFloatOffsetAdapter(RenderBlockFlow& renderer, LayoutUnit lineTop, LayoutUnit lineBottom, LayoutUnit offset)
+ : m_renderer(makeWeakPtr(renderer))
, m_lineTop(lineTop)
, m_lineBottom(lineBottom)
, m_offset(offset)
@@ -144,7 +144,7 @@
protected:
virtual bool updateOffsetIfNeeded(const FloatingObject&) = 0;
- const RenderBlockFlow& m_renderer;
+ WeakPtr<RenderBlockFlow> m_renderer;
LayoutUnit m_lineTop;
LayoutUnit m_lineBottom;
LayoutUnit m_offset;
@@ -154,7 +154,7 @@
template <FloatingObject::Type FloatTypeValue>
class ComputeFloatOffsetForFloatLayoutAdapter : public ComputeFloatOffsetAdapter<FloatTypeValue> {
public:
- ComputeFloatOffsetForFloatLayoutAdapter(const RenderBlockFlow& renderer, LayoutUnit lineTop, LayoutUnit lineBottom, LayoutUnit offset)
+ ComputeFloatOffsetForFloatLayoutAdapter(RenderBlockFlow& renderer, LayoutUnit lineTop, LayoutUnit lineBottom, LayoutUnit offset)
: ComputeFloatOffsetAdapter<FloatTypeValue>(renderer, lineTop, lineBottom, offset)
{
}
@@ -170,7 +170,7 @@
template <FloatingObject::Type FloatTypeValue>
class ComputeFloatOffsetForLineLayoutAdapter : public ComputeFloatOffsetAdapter<FloatTypeValue> {
public:
- ComputeFloatOffsetForLineLayoutAdapter(const RenderBlockFlow& renderer, LayoutUnit lineTop, LayoutUnit lineBottom, LayoutUnit offset)
+ ComputeFloatOffsetForLineLayoutAdapter(RenderBlockFlow& renderer, LayoutUnit lineTop, LayoutUnit lineBottom, LayoutUnit offset)
: ComputeFloatOffsetAdapter<FloatTypeValue>(renderer, lineTop, lineBottom, offset)
{
}
@@ -185,8 +185,8 @@
public:
typedef FloatingObjectInterval IntervalType;
- FindNextFloatLogicalBottomAdapter(const RenderBlockFlow& renderer, LayoutUnit belowLogicalHeight)
- : m_renderer(renderer)
+ FindNextFloatLogicalBottomAdapter(RenderBlockFlow& renderer, LayoutUnit belowLogicalHeight)
+ : m_renderer(makeWeakPtr(renderer))
, m_belowLogicalHeight(belowLogicalHeight)
{
}
@@ -199,7 +199,7 @@
LayoutUnit nextShapeLogicalBottom() const { return m_nextShapeLogicalBottom.value_or(nextLogicalBottom()); }
private:
- const RenderBlockFlow& m_renderer;
+ WeakPtr<RenderBlockFlow> m_renderer;
LayoutUnit m_belowLogicalHeight;
std::optional<LayoutUnit> m_nextLogicalBottom;
std::optional<LayoutUnit> m_nextShapeLogicalBottom;
@@ -213,14 +213,14 @@
// All the objects returned from the tree should be already placed.
ASSERT(floatingObject.isPlaced());
- ASSERT(rangesIntersect(m_renderer.logicalTopForFloat(floatingObject), m_renderer.logicalBottomForFloat(floatingObject), m_belowLogicalHeight, LayoutUnit::max()));
+ ASSERT(rangesIntersect(m_renderer->logicalTopForFloat(floatingObject), m_renderer->logicalBottomForFloat(floatingObject), m_belowLogicalHeight, LayoutUnit::max()));
- LayoutUnit floatBottom = m_renderer.logicalBottomForFloat(floatingObject);
+ LayoutUnit floatBottom = m_renderer->logicalBottomForFloat(floatingObject);
if (m_nextLogicalBottom && m_nextLogicalBottom.value() < floatBottom)
return;
if (ShapeOutsideInfo* shapeOutside = floatingObject.renderer().shapeOutsideInfo()) {
- LayoutUnit shapeBottom = m_renderer.logicalTopForFloat(floatingObject) + m_renderer.marginBeforeForChild(floatingObject.renderer()) + shapeOutside->shapeLogicalBottom();
+ LayoutUnit shapeBottom = m_renderer->logicalTopForFloat(floatingObject) + m_renderer->marginBeforeForChild(floatingObject.renderer()) + shapeOutside->shapeLogicalBottom();
// Use the shapeBottom unless it extends outside of the margin box, in which case it is clipped.
m_nextShapeLogicalBottom = std::min(shapeBottom, floatBottom);
} else
@@ -230,7 +230,7 @@
LayoutUnit FloatingObjects::findNextFloatLogicalBottomBelow(LayoutUnit logicalHeight)
{
- FindNextFloatLogicalBottomAdapter adapter(m_renderer, logicalHeight);
+ FindNextFloatLogicalBottomAdapter adapter(renderer(), logicalHeight);
if (const FloatingObjectTree* placedFloatsTree = this->placedFloatsTree())
placedFloatsTree->allOverlapsWithAdapter(adapter);
@@ -239,7 +239,7 @@
LayoutUnit FloatingObjects::findNextFloatLogicalBottomBelowForBlock(LayoutUnit logicalHeight)
{
- FindNextFloatLogicalBottomAdapter adapter(m_renderer, logicalHeight);
+ FindNextFloatLogicalBottomAdapter adapter(renderer(), logicalHeight);
if (const FloatingObjectTree* placedFloatsTree = this->placedFloatsTree())
placedFloatsTree->allOverlapsWithAdapter(adapter);
@@ -250,7 +250,7 @@
: m_leftObjectsCount(0)
, m_rightObjectsCount(0)
, m_horizontalWritingMode(renderer.isHorizontalWritingMode())
- , m_renderer(renderer)
+ , m_renderer(makeWeakPtr(const_cast<RenderBlockFlow&>(renderer)))
{
}
@@ -260,7 +260,7 @@
{
// Clear references to originating lines, since the lines are being deleted
for (auto it = m_set.begin(), end = m_set.end(); it != end; ++it) {
- ASSERT(!((*it)->originatingLine()) || &((*it)->originatingLine()->renderer()) == &m_renderer);
+ ASSERT(!((*it)->originatingLine()) || &((*it)->originatingLine()->renderer()) == &renderer());
(*it)->clearOriginatingLine();
}
}
@@ -383,7 +383,7 @@
LayoutUnit FloatingObjects::logicalLeftOffsetForPositioningFloat(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit *heightRemaining)
{
- ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatLeft> adapter(m_renderer, logicalTop, logicalTop, fixedOffset);
+ ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatLeft> adapter(renderer(), logicalTop, logicalTop, fixedOffset);
if (const FloatingObjectTree* placedFloatsTree = this->placedFloatsTree())
placedFloatsTree->allOverlapsWithAdapter(adapter);
@@ -395,7 +395,7 @@
LayoutUnit FloatingObjects::logicalRightOffsetForPositioningFloat(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit *heightRemaining)
{
- ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatRight> adapter(m_renderer, logicalTop, logicalTop, fixedOffset);
+ ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatRight> adapter(renderer(), logicalTop, logicalTop, fixedOffset);
if (const FloatingObjectTree* placedFloatsTree = this->placedFloatsTree())
placedFloatsTree->allOverlapsWithAdapter(adapter);
@@ -407,7 +407,7 @@
LayoutUnit FloatingObjects::logicalLeftOffset(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit logicalHeight)
{
- ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatLeft> adapter(m_renderer, logicalTop, logicalTop + logicalHeight, fixedOffset);
+ ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatLeft> adapter(renderer(), logicalTop, logicalTop + logicalHeight, fixedOffset);
if (const FloatingObjectTree* placedFloatsTree = this->placedFloatsTree())
placedFloatsTree->allOverlapsWithAdapter(adapter);
@@ -416,7 +416,7 @@
LayoutUnit FloatingObjects::logicalRightOffset(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit logicalHeight)
{
- ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatRight> adapter(m_renderer, logicalTop, logicalTop + logicalHeight, fixedOffset);
+ ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatRight> adapter(renderer(), logicalTop, logicalTop + logicalHeight, fixedOffset);
if (const FloatingObjectTree* placedFloatsTree = this->placedFloatsTree())
placedFloatsTree->allOverlapsWithAdapter(adapter);
@@ -426,7 +426,7 @@
template<>
inline bool ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatLeft>::updateOffsetIfNeeded(const FloatingObject& floatingObject)
{
- LayoutUnit logicalRight = m_renderer.logicalRightForFloat(floatingObject);
+ LayoutUnit logicalRight = m_renderer->logicalRightForFloat(floatingObject);
if (logicalRight > m_offset) {
m_offset = logicalRight;
return true;
@@ -437,7 +437,7 @@
template<>
inline bool ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatRight>::updateOffsetIfNeeded(const FloatingObject& floatingObject)
{
- LayoutUnit logicalLeft = m_renderer.logicalLeftForFloat(floatingObject);
+ LayoutUnit logicalLeft = m_renderer->logicalLeftForFloat(floatingObject);
if (logicalLeft < m_offset) {
m_offset = logicalLeft;
return true;
@@ -448,7 +448,7 @@
template <FloatingObject::Type FloatTypeValue>
LayoutUnit ComputeFloatOffsetForFloatLayoutAdapter<FloatTypeValue>::heightRemaining() const
{
- return this->m_outermostFloat ? this->m_renderer.logicalBottomForFloat(*this->m_outermostFloat) - this->m_lineTop : LayoutUnit::fromPixel(1);
+ return this->m_outermostFloat ? this->m_renderer->logicalBottomForFloat(*this->m_outermostFloat) - this->m_lineTop : LayoutUnit::fromPixel(1);
}
template <FloatingObject::Type FloatTypeValue>
@@ -460,7 +460,7 @@
// All the objects returned from the tree should be already placed.
ASSERT(floatingObject.isPlaced());
- ASSERT(rangesIntersect(m_renderer.logicalTopForFloat(floatingObject), m_renderer.logicalBottomForFloat(floatingObject), m_lineTop, m_lineBottom));
+ ASSERT(rangesIntersect(m_renderer->logicalTopForFloat(floatingObject), m_renderer->logicalBottomForFloat(floatingObject), m_lineTop, m_lineBottom));
bool floatIsNewExtreme = updateOffsetIfNeeded(floatingObject);
if (floatIsNewExtreme)
@@ -470,9 +470,9 @@
template<>
inline bool ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatLeft>::updateOffsetIfNeeded(const FloatingObject& floatingObject)
{
- LayoutUnit logicalRight = m_renderer.logicalRightForFloat(floatingObject);
+ LayoutUnit logicalRight = m_renderer->logicalRightForFloat(floatingObject);
if (ShapeOutsideInfo* shapeOutside = floatingObject.renderer().shapeOutsideInfo()) {
- ShapeOutsideDeltas shapeDeltas = shapeOutside->computeDeltasForContainingBlockLine(m_renderer, floatingObject, m_lineTop, m_lineBottom - m_lineTop);
+ ShapeOutsideDeltas shapeDeltas = shapeOutside->computeDeltasForContainingBlockLine(*m_renderer, floatingObject, m_lineTop, m_lineBottom - m_lineTop);
if (!shapeDeltas.lineOverlapsShape())
return false;
@@ -489,9 +489,9 @@
template<>
inline bool ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatRight>::updateOffsetIfNeeded(const FloatingObject& floatingObject)
{
- LayoutUnit logicalLeft = m_renderer.logicalLeftForFloat(floatingObject);
+ LayoutUnit logicalLeft = m_renderer->logicalLeftForFloat(floatingObject);
if (ShapeOutsideInfo* shapeOutside = floatingObject.renderer().shapeOutsideInfo()) {
- ShapeOutsideDeltas shapeDeltas = shapeOutside->computeDeltasForContainingBlockLine(m_renderer, floatingObject, m_lineTop, m_lineBottom - m_lineTop);
+ ShapeOutsideDeltas shapeDeltas = shapeOutside->computeDeltasForContainingBlockLine(*m_renderer, floatingObject, m_lineTop, m_lineBottom - m_lineTop);
if (!shapeDeltas.lineOverlapsShape())
return false;