Changeset 158954 in webkit
- Timestamp:
- Nov 8, 2013 2:01:33 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r158945 r158954 1 2013-11-08 Bem Jones-Bey <bjonesbe@adobe.com> 2 3 RenderBlockFlow::nextFloatLogicalBottomBelow should not use ShapeOutsideFloatOffsetMode 4 https://bugs.webkit.org/show_bug.cgi?id=123931 5 6 Reviewed by Sam Weinig. 7 8 Rewrite nextFloatLogicalBottomBelow to use the placed floats tree for 9 the search and to not need ShapeOutsideFloatOffsetMode anymore. This 10 moves almost all of the logic into FloatingObjects, making a small 11 reduction in the amount that RenderBlockFlow needs to know about the 12 implementation of FloatingObjects. 13 14 In addition, change ComputeFloatOffsetAdapter to take in LayoutUnits 15 and roundToInt itself so that all of it's callers can be simplified. 16 17 No new tests, no new behavior. 18 19 * rendering/FloatingObjects.cpp: 20 (WebCore::rangesIntersect): 21 (WebCore::ComputeFloatOffsetAdapter::ComputeFloatOffsetAdapter): 22 (WebCore::FindNextFloatLogicalBottomAdapter::FindNextFloatLogicalBottomAdapter): 23 (WebCore::FindNextFloatLogicalBottomAdapter::lowValue): 24 (WebCore::FindNextFloatLogicalBottomAdapter::highValue): 25 (WebCore::FindNextFloatLogicalBottomAdapter::nextLogicalBottom): 26 (WebCore::FindNextFloatLogicalBottomAdapter::nextShapeLogicalBottom): 27 (WebCore::FindNextFloatLogicalBottomAdapter::collectIfNeeded): 28 (WebCore::FloatingObjects::findNextFloatLogicalBottomBelow): 29 (WebCore::FloatingObjects::findNextFloatLogicalBottomBelowForBlock): 30 (WebCore::FloatingObjects::logicalLeftOffsetForPositioningFloat): 31 (WebCore::FloatingObjects::logicalRightOffsetForPositioningFloat): 32 (WebCore::FloatingObjects::logicalLeftOffset): 33 (WebCore::FloatingObjects::logicalRightOffset): 34 * rendering/FloatingObjects.h: 35 * rendering/LineWidth.cpp: 36 (WebCore::LineWidth::fitBelowFloats): 37 * rendering/RenderBlockFlow.cpp: 38 (WebCore::RenderBlockFlow::nextFloatLogicalBottomBelow): 39 (WebCore::RenderBlockFlow::nextFloatLogicalBottomBelowForBlock): 40 (WebCore::RenderBlockFlow::getClearDelta): 41 * rendering/RenderBlockFlow.h: 42 1 43 2013-11-08 Alexey Proskuryakov <ap@apple.com> 2 44 -
trunk/Source/WebCore/rendering/FloatingObjects.cpp
r158856 r158954 101 101 } 102 102 103 inline static bool rangesIntersect(int floatTop, int floatBottom, int objectTop, int objectBottom) 104 { 105 if (objectTop >= floatBottom || objectBottom < floatTop) 106 return false; 107 108 // The top of the object overlaps the float 109 if (objectTop >= floatTop) 110 return true; 111 112 // The object encloses the float 113 if (objectTop < floatTop && objectBottom > floatBottom) 114 return true; 115 116 // The bottom of the object overlaps the float 117 if (objectBottom > objectTop && objectBottom > floatTop && objectBottom <= floatBottom) 118 return true; 119 120 return false; 121 } 122 103 123 template <FloatingObject::Type FloatTypeValue> 104 124 class ComputeFloatOffsetAdapter { … … 106 126 typedef FloatingObjectInterval IntervalType; 107 127 108 ComputeFloatOffsetAdapter(const RenderBlockFlow* renderer, int lineTop, int lineBottom, LayoutUnit offset)128 ComputeFloatOffsetAdapter(const RenderBlockFlow* renderer, LayoutUnit lineTop, LayoutUnit lineBottom, LayoutUnit offset) 109 129 : m_renderer(renderer) 110 , m_lineTop( lineTop)111 , m_lineBottom( lineBottom)130 , m_lineTop(roundToInt(lineTop)) 131 , m_lineBottom(roundToInt(lineBottom)) 112 132 , m_offset(offset) 113 133 , m_outermostFloat(0) … … 132 152 const FloatingObject* m_outermostFloat; 133 153 }; 154 155 class FindNextFloatLogicalBottomAdapter { 156 public: 157 typedef FloatingObjectInterval IntervalType; 158 159 FindNextFloatLogicalBottomAdapter(const RenderBlockFlow& renderer, LayoutUnit belowLogicalHeight) 160 : m_renderer(renderer) 161 , m_belowLogicalHeight(floorToInt(belowLogicalHeight)) 162 , m_aboveLogicalHeight(roundToInt(LayoutUnit::max())) 163 , m_nextLogicalBottom(LayoutUnit::max()) 164 , m_nextShapeLogicalBottom(LayoutUnit::max()) 165 { 166 } 167 168 int lowValue() const { return m_belowLogicalHeight; } 169 int highValue() const { return m_aboveLogicalHeight; } 170 void collectIfNeeded(const IntervalType&); 171 172 LayoutUnit nextLogicalBottom() { return m_nextLogicalBottom == LayoutUnit::max() ? LayoutUnit() : m_nextLogicalBottom; } 173 LayoutUnit nextShapeLogicalBottom() { return m_nextShapeLogicalBottom == LayoutUnit::max() ? nextLogicalBottom() : m_nextShapeLogicalBottom; } 174 175 private: 176 const RenderBlockFlow& m_renderer; 177 int m_belowLogicalHeight; 178 int m_aboveLogicalHeight; 179 LayoutUnit m_nextLogicalBottom; 180 LayoutUnit m_nextShapeLogicalBottom; 181 }; 182 183 inline void FindNextFloatLogicalBottomAdapter::collectIfNeeded(const IntervalType& interval) 184 { 185 const FloatingObject* floatingObject = interval.data(); 186 if (!rangesIntersect(interval.low(), interval.high(), m_belowLogicalHeight, m_aboveLogicalHeight)) 187 return; 188 189 // All the objects returned from the tree should be already placed. 190 ASSERT(floatingObject->isPlaced()); 191 ASSERT(rangesIntersect(m_renderer.pixelSnappedLogicalTopForFloat(floatingObject), m_renderer.pixelSnappedLogicalBottomForFloat(floatingObject), m_belowLogicalHeight, m_aboveLogicalHeight)); 192 193 LayoutUnit floatBottom = m_renderer.logicalBottomForFloat(floatingObject); 194 if (m_nextLogicalBottom < floatBottom) 195 return; 196 197 #if ENABLE(CSS_SHAPES) 198 if (ShapeOutsideInfo* shapeOutside = floatingObject->renderer().shapeOutsideInfo()) { 199 LayoutUnit shapeBottom = m_renderer.logicalTopForFloat(floatingObject) + m_renderer.marginBeforeForChild(floatingObject->renderer()) + shapeOutside->shapeLogicalBottom(); 200 // Use the shapeBottom unless it extends outside of the margin box, in which case it is clipped. 201 m_nextShapeLogicalBottom = min(shapeBottom, floatBottom); 202 } else 203 m_nextShapeLogicalBottom = floatBottom; 204 #endif 205 m_nextLogicalBottom = floatBottom; 206 } 207 208 LayoutUnit FloatingObjects::findNextFloatLogicalBottomBelow(LayoutUnit logicalHeight) 209 { 210 FindNextFloatLogicalBottomAdapter adapter(*m_renderer, logicalHeight); 211 placedFloatsTree().allOverlapsWithAdapter(adapter); 212 213 return adapter.nextShapeLogicalBottom(); 214 } 215 216 LayoutUnit FloatingObjects::findNextFloatLogicalBottomBelowForBlock(LayoutUnit logicalHeight) 217 { 218 FindNextFloatLogicalBottomAdapter adapter(*m_renderer, logicalHeight); 219 placedFloatsTree().allOverlapsWithAdapter(adapter); 220 221 return adapter.nextLogicalBottom(); 222 } 134 223 135 224 FloatingObjects::FloatingObjects(const RenderBlockFlow* renderer, bool horizontalWritingMode) … … 306 395 LayoutUnit FloatingObjects::logicalLeftOffsetForPositioningFloat(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit *heightRemaining) 307 396 { 308 int logicalTopAsInt = roundToInt(logicalTop); 309 ComputeFloatOffsetAdapter<FloatingObject::FloatLeft> adapter(m_renderer, logicalTopAsInt, logicalTopAsInt, fixedOffset); 397 ComputeFloatOffsetAdapter<FloatingObject::FloatLeft> adapter(m_renderer, logicalTop, logicalTop, fixedOffset); 310 398 placedFloatsTree().allOverlapsWithAdapter(adapter); 311 399 … … 318 406 LayoutUnit FloatingObjects::logicalRightOffsetForPositioningFloat(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit *heightRemaining) 319 407 { 320 int logicalTopAsInt = roundToInt(logicalTop); 321 ComputeFloatOffsetAdapter<FloatingObject::FloatRight> adapter(m_renderer, logicalTopAsInt, logicalTopAsInt, fixedOffset); 408 ComputeFloatOffsetAdapter<FloatingObject::FloatRight> adapter(m_renderer, logicalTop, logicalTop, fixedOffset); 322 409 placedFloatsTree().allOverlapsWithAdapter(adapter); 323 410 … … 330 417 LayoutUnit FloatingObjects::logicalLeftOffset(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit logicalHeight) 331 418 { 332 ComputeFloatOffsetAdapter<FloatingObject::FloatLeft> adapter(m_renderer, roundToInt(logicalTop), roundToInt(logicalTop + logicalHeight), fixedOffset);419 ComputeFloatOffsetAdapter<FloatingObject::FloatLeft> adapter(m_renderer, logicalTop, logicalTop + logicalHeight, fixedOffset); 333 420 placedFloatsTree().allOverlapsWithAdapter(adapter); 334 421 … … 338 425 LayoutUnit FloatingObjects::logicalRightOffset(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit logicalHeight) 339 426 { 340 ComputeFloatOffsetAdapter<FloatingObject::FloatRight> adapter(m_renderer, roundToInt(logicalTop), roundToInt(logicalTop + logicalHeight), fixedOffset);427 ComputeFloatOffsetAdapter<FloatingObject::FloatRight> adapter(m_renderer, logicalTop, logicalTop + logicalHeight, fixedOffset); 341 428 placedFloatsTree().allOverlapsWithAdapter(adapter); 342 429 343 430 return min(fixedOffset, adapter.shapeOffset()); 344 }345 346 inline static bool rangesIntersect(int floatTop, int floatBottom, int objectTop, int objectBottom)347 {348 if (objectTop >= floatBottom || objectBottom < floatTop)349 return false;350 351 // The top of the object overlaps the float352 if (objectTop >= floatTop)353 return true;354 355 // The object encloses the float356 if (objectTop < floatTop && objectBottom > floatBottom)357 return true;358 359 // The bottom of the object overlaps the float360 if (objectBottom > objectTop && objectBottom > floatTop && objectBottom <= floatBottom)361 return true;362 363 return false;364 431 } 365 432 -
trunk/Source/WebCore/rendering/FloatingObjects.h
r158855 r158954 33 33 class RenderBlockFlow; 34 34 class RenderBox; 35 36 // FIXME this should be removed once RenderBlockFlow::nextFloatLogicalBottomBelow doesn't need it anymore. (Bug 123931)37 enum ShapeOutsideFloatOffsetMode { ShapeOutsideFloatShapeOffset, ShapeOutsideFloatMarginBoxOffset };38 35 39 36 class FloatingObject { … … 150 147 LayoutUnit logicalRightOffsetForPositioningFloat(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit* heightRemaining); 151 148 149 LayoutUnit findNextFloatLogicalBottomBelow(LayoutUnit logicalHeight); 150 LayoutUnit findNextFloatLogicalBottomBelowForBlock(LayoutUnit logicalHeight); 151 152 152 private: 153 153 void computePlacedFloatsTree(); -
trunk/Source/WebCore/rendering/LineWidth.cpp
r158163 r158954 182 182 float newLineRight = m_right; 183 183 while (true) { 184 floatLogicalBottom = m_block.nextFloatLogicalBottomBelow(lastFloatLogicalBottom , ShapeOutsideFloatShapeOffset);184 floatLogicalBottom = m_block.nextFloatLogicalBottomBelow(lastFloatLogicalBottom); 185 185 if (floatLogicalBottom <= lastFloatLogicalBottom) 186 186 break; -
trunk/Source/WebCore/rendering/RenderBlockFlow.cpp
r158855 r158954 2277 2277 } 2278 2278 2279 LayoutUnit RenderBlockFlow::nextFloatLogicalBottomBelow(LayoutUnit logicalHeight , ShapeOutsideFloatOffsetMode offsetMode) const2279 LayoutUnit RenderBlockFlow::nextFloatLogicalBottomBelow(LayoutUnit logicalHeight) const 2280 2280 { 2281 2281 if (!m_floatingObjects) 2282 2282 return logicalHeight; 2283 2283 2284 LayoutUnit bottom = LayoutUnit::max(); 2285 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 2286 auto end = floatingObjectSet.end(); 2287 for (auto it = floatingObjectSet.begin(); it != end; ++it) { 2288 FloatingObject* floatingObject = it->get(); 2289 LayoutUnit floatBottom = logicalBottomForFloat(floatingObject); 2290 #if ENABLE(CSS_SHAPES) 2291 ShapeOutsideInfo* shapeOutside = floatingObject->renderer().shapeOutsideInfo(); 2292 if (offsetMode == ShapeOutsideFloatShapeOffset && shapeOutside) { 2293 LayoutUnit shapeBottom = logicalTopForFloat(floatingObject) + marginBeforeForChild(floatingObject->renderer()) + shapeOutside->shapeLogicalBottom(); 2294 // Use the shapeBottom unless it extends outside of the margin box, in which case it is clipped. 2295 if (shapeBottom < floatBottom) 2296 floatBottom = shapeBottom; 2297 } 2298 #endif 2299 if (floatBottom > logicalHeight) 2300 bottom = min(floatBottom, bottom); 2301 } 2302 2303 return bottom == LayoutUnit::max() ? LayoutUnit() : bottom; 2284 return m_floatingObjects->findNextFloatLogicalBottomBelow(logicalHeight); 2285 } 2286 2287 LayoutUnit RenderBlockFlow::nextFloatLogicalBottomBelowForBlock(LayoutUnit logicalHeight) const 2288 { 2289 if (!m_floatingObjects) 2290 return logicalHeight; 2291 2292 return m_floatingObjects->findNextFloatLogicalBottomBelowForBlock(logicalHeight); 2304 2293 } 2305 2294 … … 2553 2542 } 2554 2543 2555 newLogicalTop = nextFloatLogicalBottomBelow (newLogicalTop);2544 newLogicalTop = nextFloatLogicalBottomBelowForBlock(newLogicalTop); 2556 2545 ASSERT(newLogicalTop >= logicalTop); 2557 2546 if (newLogicalTop < logicalTop) -
trunk/Source/WebCore/rendering/RenderBlockFlow.h
r158855 r158954 424 424 425 425 LayoutUnit lowestFloatLogicalBottom(FloatingObject::Type = FloatingObject::FloatLeftRight) const; 426 LayoutUnit nextFloatLogicalBottomBelow(LayoutUnit, ShapeOutsideFloatOffsetMode = ShapeOutsideFloatMarginBoxOffset) const; 426 LayoutUnit nextFloatLogicalBottomBelow(LayoutUnit) const; 427 LayoutUnit nextFloatLogicalBottomBelowForBlock(LayoutUnit) const; 427 428 428 429 LayoutUnit addOverhangingFloats(RenderBlockFlow& child, bool makeChildPaintOtherFloats);
Note: See TracChangeset
for help on using the changeset viewer.