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

Unified Diff: Source/core/rendering/RenderBlock.cpp

Issue 22463002: Optimize FloatIntervalSearchAdapter::collectIfNeeded (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Changes from review. Created 7 years, 4 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
« no previous file with comments | « Source/core/rendering/RenderBlock.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderBlock.cpp
diff --git a/Source/core/rendering/RenderBlock.cpp b/Source/core/rendering/RenderBlock.cpp
index 5c7a9d90b55bb66764259d87e17aec1720eae4fe..6bc811f8399bfc40fcabcea0af9f2c1d970453ff 100644
--- a/Source/core/rendering/RenderBlock.cpp
+++ b/Source/core/rendering/RenderBlock.cpp
@@ -4249,8 +4249,9 @@ static bool rangesIntersect(int floatTop, int floatBottom, int objectTop, int ob
template<>
bool RenderBlock::FloatIntervalSearchAdapter<RenderBlock::FloatingObject::FloatLeft>::updateOffsetIfNeeded(const FloatingObject* floatingObject) const
{
- if (m_renderer->logicalRightForFloat(floatingObject) > m_offset) {
- m_offset = m_renderer->logicalRightForFloat(floatingObject);
+ LayoutUnit logicalRight = m_renderer->logicalRightForFloat(floatingObject);
+ if (logicalRight > m_offset) {
+ m_offset = logicalRight;
return true;
}
return false;
@@ -4259,15 +4260,16 @@ bool RenderBlock::FloatIntervalSearchAdapter<RenderBlock::FloatingObject::FloatL
template<>
bool RenderBlock::FloatIntervalSearchAdapter<RenderBlock::FloatingObject::FloatRight>::updateOffsetIfNeeded(const FloatingObject* floatingObject) const
{
- if (m_renderer->logicalLeftForFloat(floatingObject) < m_offset) {
- m_offset = m_renderer->logicalLeftForFloat(floatingObject);
+ LayoutUnit logicalLeft = m_renderer->logicalLeftForFloat(floatingObject);
+ if (logicalLeft < m_offset) {
+ m_offset = logicalLeft;
return true;
}
return false;
}
template <RenderBlock::FloatingObject::Type FloatTypeValue>
-inline void RenderBlock::FloatIntervalSearchAdapter<FloatTypeValue>::collectIfNeeded(const IntervalType& interval) const
+inline void RenderBlock::FloatIntervalSearchAdapter<FloatTypeValue>::collectIfNeeded(const IntervalType& interval)
{
const FloatingObject* floatingObject = interval.data();
if (floatingObject->type() != FloatTypeValue || !rangesIntersect(interval.low(), interval.high(), m_lowValue, m_highValue))
@@ -4278,12 +4280,18 @@ inline void RenderBlock::FloatIntervalSearchAdapter<FloatTypeValue>::collectIfNe
ASSERT(rangesIntersect(m_renderer->pixelSnappedLogicalTopForFloat(floatingObject), m_renderer->pixelSnappedLogicalBottomForFloat(floatingObject), m_lowValue, m_highValue));
bool floatIsNewExtreme = updateOffsetIfNeeded(floatingObject);
- if (floatIsNewExtreme && m_heightRemaining)
- *m_heightRemaining = m_renderer->logicalBottomForFloat(floatingObject) - m_lowValue;
+ if (floatIsNewExtreme)
+ m_floatForHeight = floatingObject;
m_last = floatingObject;
}
+template <RenderBlock::FloatingObject::Type FloatTypeValue>
+LayoutUnit RenderBlock::FloatIntervalSearchAdapter<FloatTypeValue>::getHeightRemaining() const
+{
+ return m_floatForHeight ? m_renderer->logicalBottomForFloat(m_floatForHeight) - m_lowValue : LayoutUnit(1);
+}
+
LayoutUnit RenderBlock::textIndentOffset() const
{
LayoutUnit cw = 0;
@@ -4318,12 +4326,12 @@ LayoutUnit RenderBlock::logicalLeftFloatOffsetForLine(LayoutUnit logicalTop, Lay
{
LayoutUnit left = fixedOffset;
if (m_floatingObjects && m_floatingObjects->hasLeftObjects()) {
- if (heightRemaining)
- *heightRemaining = 1;
-
- FloatIntervalSearchAdapter<FloatingObject::FloatLeft> adapter(this, roundToInt(logicalTop), roundToInt(logicalTop + logicalHeight), left, heightRemaining);
+ FloatIntervalSearchAdapter<FloatingObject::FloatLeft> adapter(this, roundToInt(logicalTop), roundToInt(logicalTop + logicalHeight), left);
m_floatingObjects->placedFloatsTree().allOverlapsWithAdapter(adapter);
+ if (heightRemaining)
+ *heightRemaining = adapter.getHeightRemaining();
+
const FloatingObject* lastFloat = adapter.lastFloat();
if (offsetMode == ShapeOutsideFloatShapeOffset && lastFloat) {
if (ShapeOutsideInfo* shapeOutside = lastFloat->renderer()->shapeOutsideInfo()) {
@@ -4378,13 +4386,13 @@ LayoutUnit RenderBlock::logicalRightFloatOffsetForLine(LayoutUnit logicalTop, La
{
LayoutUnit right = fixedOffset;
if (m_floatingObjects && m_floatingObjects->hasRightObjects()) {
- if (heightRemaining)
- *heightRemaining = 1;
-
LayoutUnit rightFloatOffset = fixedOffset;
- FloatIntervalSearchAdapter<FloatingObject::FloatRight> adapter(this, roundToInt(logicalTop), roundToInt(logicalTop + logicalHeight), rightFloatOffset, heightRemaining);
+ FloatIntervalSearchAdapter<FloatingObject::FloatRight> adapter(this, roundToInt(logicalTop), roundToInt(logicalTop + logicalHeight), rightFloatOffset);
m_floatingObjects->placedFloatsTree().allOverlapsWithAdapter(adapter);
+ if (heightRemaining)
+ *heightRemaining = adapter.getHeightRemaining();
+
const FloatingObject* lastFloat = adapter.lastFloat();
if (offsetMode == ShapeOutsideFloatShapeOffset && lastFloat) {
if (ShapeOutsideInfo* shapeOutside = lastFloat->renderer()->shapeOutsideInfo()) {
« no previous file with comments | « Source/core/rendering/RenderBlock.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698