LayoutUnit FloatingObjects::lowestFloatLogicalBottom(FloatingObject::Type floatType) { bool isInHorizontalWritingMode = m_horizontalWritingMode; if (floatType != FloatingObject::FloatLeftRight) { if (hasLowestFloatLogicalBottomCached(isInHorizontalWritingMode, floatType)) return getCachedlowestFloatLogicalBottom(floatType); } else { if (hasLowestFloatLogicalBottomCached(isInHorizontalWritingMode, FloatingObject::FloatLeft) && hasLowestFloatLogicalBottomCached(isInHorizontalWritingMode, FloatingObject::FloatRight)) { return std::max(getCachedlowestFloatLogicalBottom(FloatingObject::FloatLeft), getCachedlowestFloatLogicalBottom(FloatingObject::FloatRight)); } } LayoutUnit lowestFloatBottom = 0; const FloatingObjectSet& floatingObjectSet = set(); FloatingObjectSetIterator end = floatingObjectSet.end(); if (floatType == FloatingObject::FloatLeftRight) { FloatingObject* lowestFloatingObjectLeft = nullptr; FloatingObject* lowestFloatingObjectRight = nullptr; 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(); LayoutUnit curFloatLogicalBottom = m_layoutObject->logicalBottomForFloat(floatingObject); if (curType & FloatingObject::FloatLeft && curFloatLogicalBottom > lowestFloatBottomLeft) { lowestFloatBottomLeft = curFloatLogicalBottom; lowestFloatingObjectLeft = &floatingObject; } if (curType & FloatingObject::FloatRight && curFloatLogicalBottom > lowestFloatBottomRight) { lowestFloatBottomRight = curFloatLogicalBottom; lowestFloatingObjectRight = &floatingObject; } } } lowestFloatBottom = std::max(lowestFloatBottomLeft, lowestFloatBottomRight); setCachedLowestFloatLogicalBottom(isInHorizontalWritingMode, FloatingObject::FloatLeft, lowestFloatingObjectLeft); setCachedLowestFloatLogicalBottom(isInHorizontalWritingMode, FloatingObject::FloatRight, lowestFloatingObjectRight); } else { FloatingObject* lowestFloatingObject = nullptr; for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) { FloatingObject& floatingObject = *it->get(); if (floatingObject.isPlaced() && floatingObject.type() == floatType) { if (m_layoutObject->logicalBottomForFloat(floatingObject) > lowestFloatBottom) { lowestFloatingObject = &floatingObject; lowestFloatBottom = m_layoutObject->logicalBottomForFloat(floatingObject); } } } setCachedLowestFloatLogicalBottom(isInHorizontalWritingMode, floatType, lowestFloatingObject); } return lowestFloatBottom; }
void FloatingObjects::computePlacedFloatsTree() { ASSERT(!m_placedFloatsTree.isInitialized()); if (m_set.isEmpty()) return; m_placedFloatsTree.initIfNeeded(m_layoutObject->view()->intervalArena()); FloatingObjectSetIterator it = m_set.begin(); FloatingObjectSetIterator end = m_set.end(); for (; it != end; ++it) { FloatingObject& floatingObject = *it->get(); if (floatingObject.isPlaced()) m_placedFloatsTree.add(intervalForFloatingObject(floatingObject)); } }