Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1378)

Unified Diff: Source/core/layout/FloatingObjects.cpp

Issue 763173003: Convert RenderBlockFlow code to use FloatingObject references (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: more usage of const with floatingObject Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/layout/FloatingObjects.cpp
diff --git a/Source/core/layout/FloatingObjects.cpp b/Source/core/layout/FloatingObjects.cpp
index e66ab9afcd87c414ec3412e2c6eba190166a192e..ac45359431c805db60f5959af84c121f67f4c62c 100644
--- a/Source/core/layout/FloatingObjects.cpp
+++ b/Source/core/layout/FloatingObjects.cpp
@@ -212,9 +212,9 @@ LayoutUnit FloatingObjects::lowestFloatLogicalBottom(FloatingObject::Type floatT
LayoutUnit lowestFloatBottomLeft = 0;
LayoutUnit lowestFloatBottomRight = 0;
for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
- FloatingObject* floatingObject = it->get();
- if (floatingObject->isPlaced()) {
- FloatingObject::Type curType = floatingObject->type();
+ const FloatingObject& floatingObject = *it->get();
+ if (floatingObject.isPlaced()) {
+ FloatingObject::Type curType = floatingObject.type();
LayoutUnit curFloatLogicalBottom = m_layoutObject->logicalBottomForFloat(floatingObject);
if (curType & FloatingObject::FloatLeft)
lowestFloatBottomLeft = std::max(lowestFloatBottomLeft, curFloatLogicalBottom);
@@ -227,8 +227,8 @@ LayoutUnit FloatingObjects::lowestFloatLogicalBottom(FloatingObject::Type floatT
setCachedLowestFloatLogicalBottom(isInHorizontalWritingMode, FloatingObject::FloatRight, lowestFloatBottomRight);
} else {
for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
- FloatingObject* floatingObject = it->get();
- if (floatingObject->isPlaced() && floatingObject->type() == floatType)
+ const FloatingObject& floatingObject = *it->get();
+ if (floatingObject.isPlaced() && floatingObject.type() == floatType)
lowestFloatBottom = std::max(lowestFloatBottom, m_layoutObject->logicalBottomForFloat(floatingObject));
}
setCachedLowestFloatLogicalBottom(isInHorizontalWritingMode, floatType, lowestFloatBottom);
@@ -295,39 +295,39 @@ inline void FloatingObjects::decreaseObjectsCount(FloatingObject::Type type)
m_rightObjectsCount--;
}
-inline FloatingObjectInterval FloatingObjects::intervalForFloatingObject(FloatingObject* floatingObject)
+inline FloatingObjectInterval FloatingObjects::intervalForFloatingObject(FloatingObject& floatingObject)
{
if (m_horizontalWritingMode)
- return FloatingObjectInterval(floatingObject->frameRect().pixelSnappedY(), floatingObject->frameRect().pixelSnappedMaxY(), floatingObject);
- return FloatingObjectInterval(floatingObject->frameRect().pixelSnappedX(), floatingObject->frameRect().pixelSnappedMaxX(), floatingObject);
+ return FloatingObjectInterval(floatingObject.frameRect().pixelSnappedY(), floatingObject.frameRect().pixelSnappedMaxY(), &floatingObject);
+ return FloatingObjectInterval(floatingObject.frameRect().pixelSnappedX(), floatingObject.frameRect().pixelSnappedMaxX(), &floatingObject);
}
-void FloatingObjects::addPlacedObject(FloatingObject* floatingObject)
+void FloatingObjects::addPlacedObject(FloatingObject& floatingObject)
{
- ASSERT(!floatingObject->isInPlacedTree());
+ ASSERT(!floatingObject.isInPlacedTree());
- floatingObject->setIsPlaced(true);
+ floatingObject.setIsPlaced(true);
if (m_placedFloatsTree.isInitialized())
m_placedFloatsTree.add(intervalForFloatingObject(floatingObject));
#if ENABLE(ASSERT)
- floatingObject->setIsInPlacedTree(true);
+ floatingObject.setIsInPlacedTree(true);
#endif
markLowestFloatLogicalBottomCacheAsDirty();
}
-void FloatingObjects::removePlacedObject(FloatingObject* floatingObject)
+void FloatingObjects::removePlacedObject(FloatingObject& floatingObject)
{
- ASSERT(floatingObject->isPlaced() && floatingObject->isInPlacedTree());
+ ASSERT(floatingObject.isPlaced() && floatingObject.isInPlacedTree());
if (m_placedFloatsTree.isInitialized()) {
bool removed = m_placedFloatsTree.remove(intervalForFloatingObject(floatingObject));
ASSERT_UNUSED(removed, removed);
}
- floatingObject->setIsPlaced(false);
+ floatingObject.setIsPlaced(false);
#if ENABLE(ASSERT)
- floatingObject->setIsInPlacedTree(false);
+ floatingObject.setIsInPlacedTree(false);
#endif
markLowestFloatLogicalBottomCacheAsDirty();
}
@@ -338,7 +338,7 @@ FloatingObject* FloatingObjects::add(PassOwnPtr<FloatingObject> floatingObject)
increaseObjectsCount(newObject->type());
m_set.add(adoptPtr(newObject));
if (newObject->isPlaced())
- addPlacedObject(newObject);
+ addPlacedObject(*newObject);
markLowestFloatLogicalBottomCacheAsDirty();
return newObject;
}
@@ -349,7 +349,7 @@ void FloatingObjects::remove(FloatingObject* toBeRemoved)
OwnPtr<FloatingObject> floatingObject = m_set.take(toBeRemoved);
ASSERT(floatingObject->isPlaced() || !floatingObject->isInPlacedTree());
if (floatingObject->isPlaced())
- removePlacedObject(floatingObject.get());
+ removePlacedObject(*floatingObject);
markLowestFloatLogicalBottomCacheAsDirty();
ASSERT(!floatingObject->originatingLine());
}
@@ -363,8 +363,8 @@ void FloatingObjects::computePlacedFloatsTree()
FloatingObjectSetIterator it = m_set.begin();
FloatingObjectSetIterator end = m_set.end();
for (; it != end; ++it) {
- FloatingObject* floatingObject = it->get();
- if (floatingObject->isPlaced())
+ FloatingObject& floatingObject = *it->get();
+ if (floatingObject.isPlaced())
m_placedFloatsTree.add(intervalForFloatingObject(floatingObject));
}
}
@@ -438,7 +438,7 @@ inline static bool rangesIntersect(int floatTop, int floatBottom, int objectTop,
template<>
inline bool ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatLeft>::updateOffsetIfNeeded(const FloatingObject& floatingObject)
{
- LayoutUnit logicalRight = m_layoutObject->logicalRightForFloat(&floatingObject);
+ LayoutUnit logicalRight = m_layoutObject->logicalRightForFloat(floatingObject);
if (logicalRight > m_offset) {
m_offset = logicalRight;
return true;
@@ -449,7 +449,7 @@ inline bool ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatLeft>::
template<>
inline bool ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatRight>::updateOffsetIfNeeded(const FloatingObject& floatingObject)
{
- LayoutUnit logicalLeft = m_layoutObject->logicalLeftForFloat(&floatingObject);
+ LayoutUnit logicalLeft = m_layoutObject->logicalLeftForFloat(floatingObject);
if (logicalLeft < m_offset) {
m_offset = logicalLeft;
return true;
@@ -460,30 +460,30 @@ inline bool ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatRight>:
template <FloatingObject::Type FloatTypeValue>
LayoutUnit ComputeFloatOffsetForFloatLayoutAdapter<FloatTypeValue>::heightRemaining() const
{
- return this->m_outermostFloat ? this->m_layoutObject->logicalBottomForFloat(this->m_outermostFloat) - this->m_lineTop : LayoutUnit(1);
+ return this->m_outermostFloat ? this->m_layoutObject->logicalBottomForFloat(*(this->m_outermostFloat)) - this->m_lineTop : LayoutUnit(1);
Julien - ping for review 2015/06/10 15:15:44 I don't think the parentheses are needed here due
Sunil Ratnu 2015/06/11 05:49:43 Done.
}
template <FloatingObject::Type FloatTypeValue>
inline void ComputeFloatOffsetAdapter<FloatTypeValue>::collectIfNeeded(const IntervalType& interval)
{
- const FloatingObject* floatingObject = interval.data();
- if (floatingObject->type() != FloatTypeValue || !rangesIntersect(interval.low(), interval.high(), m_lineTop, m_lineBottom))
+ const FloatingObject& floatingObject = *(interval.data());
+ if (floatingObject.type() != FloatTypeValue || !rangesIntersect(interval.low(), interval.high(), m_lineTop, m_lineBottom))
return;
// Make sure the float hasn't changed since it was added to the placed floats tree.
- ASSERT(floatingObject->isPlaced());
+ ASSERT(floatingObject.isPlaced());
ASSERT(interval.low() == m_layoutObject->pixelSnappedLogicalTopForFloat(floatingObject));
ASSERT(interval.high() == m_layoutObject->pixelSnappedLogicalBottomForFloat(floatingObject));
- bool floatIsNewExtreme = updateOffsetIfNeeded(*floatingObject);
+ bool floatIsNewExtreme = updateOffsetIfNeeded(floatingObject);
if (floatIsNewExtreme)
- m_outermostFloat = floatingObject;
+ m_outermostFloat = &floatingObject;
}
template<>
inline bool ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatLeft>::updateOffsetIfNeeded(const FloatingObject& floatingObject)
{
- LayoutUnit logicalRight = m_layoutObject->logicalRightForFloat(&floatingObject);
+ LayoutUnit logicalRight = m_layoutObject->logicalRightForFloat(floatingObject);
if (ShapeOutsideInfo* shapeOutside = floatingObject.layoutObject()->shapeOutsideInfo()) {
ShapeOutsideDeltas shapeDeltas = shapeOutside->computeDeltasForContainingBlockLine(*m_layoutObject, floatingObject, m_lineTop, m_lineBottom - m_lineTop);
if (!shapeDeltas.lineOverlapsShape())
@@ -502,7 +502,7 @@ inline bool ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatLeft>::u
template<>
inline bool ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatRight>::updateOffsetIfNeeded(const FloatingObject& floatingObject)
{
- LayoutUnit logicalLeft = m_layoutObject->logicalLeftForFloat(&floatingObject);
+ LayoutUnit logicalLeft = m_layoutObject->logicalLeftForFloat(floatingObject);
if (ShapeOutsideInfo* shapeOutside = floatingObject.layoutObject()->shapeOutsideInfo()) {
ShapeOutsideDeltas shapeDeltas = shapeOutside->computeDeltasForContainingBlockLine(*m_layoutObject, floatingObject, m_lineTop, m_lineBottom - m_lineTop);
if (!shapeDeltas.lineOverlapsShape())

Powered by Google App Engine
This is Rietveld 408576698