Diff
Modified: trunk/Source/WebCore/ChangeLog (156175 => 156176)
--- trunk/Source/WebCore/ChangeLog 2013-09-20 17:10:14 UTC (rev 156175)
+++ trunk/Source/WebCore/ChangeLog 2013-09-20 17:16:01 UTC (rev 156176)
@@ -1,3 +1,33 @@
+2013-09-20 Bem Jones-Bey <[email protected]>
+
+ Simplify the ShapeOutsideInfo and ShapeInfo interfaces
+ https://bugs.webkit.org/show_bug.cgi?id=121685
+
+ Reviewed by Darin Adler.
+
+ With the creation ShapeInfo::computeSegmentsForLine, it became possible to
+ simplify the ShapeInfo classes. ShapeOutsideInfo has no need to save the
+ segments, and now that segment creation is in its own method, it doesn't have
+ to save the segments anymore. This also simplifies the public interface of
+ ShapeOutsideInfo, as it only has one method to do the computation.
+
+ Also, the methods in ShapeOutsideInfo have been renamed to reflect the fact
+ that ShapeOutsideInfo isn't really interested in segments.
+
+ No new tests, no new behavior.
+
+ * rendering/FloatingObjects.cpp:
+ (WebCore::FloatingObjects::logicalLeftOffset):
+ (WebCore::FloatingObjects::logicalRightOffset):
+ * rendering/LineWidth.cpp:
+ (WebCore::LineWidth::shrinkAvailableWidthForNewFloatIfNeeded):
+ * rendering/shapes/ShapeInfo.cpp:
+ * rendering/shapes/ShapeInfo.h:
+ * rendering/shapes/ShapeInsideInfo.h:
+ * rendering/shapes/ShapeOutsideInfo.cpp:
+ (WebCore::ShapeOutsideInfo::updateDeltasForContainingBlockLine):
+ * rendering/shapes/ShapeOutsideInfo.h:
+
2013-09-20 Antonio Gomes <[email protected]>
Making tests added in r156157 JS-only, given that other
Modified: trunk/Source/WebCore/rendering/FloatingObjects.cpp (156175 => 156176)
--- trunk/Source/WebCore/rendering/FloatingObjects.cpp 2013-09-20 17:10:14 UTC (rev 156175)
+++ trunk/Source/WebCore/rendering/FloatingObjects.cpp 2013-09-20 17:16:01 UTC (rev 156176)
@@ -288,8 +288,8 @@
const FloatingObject* outermostFloat = adapter.outermostFloat();
if (offsetMode == ShapeOutsideFloatShapeOffset && outermostFloat) {
if (ShapeOutsideInfo* shapeOutside = outermostFloat->renderer()->shapeOutsideInfo()) {
- shapeOutside->computeSegmentsForContainingBlockLine(m_renderer, outermostFloat, logicalTop, logicalHeight);
- offset += shapeOutside->rightSegmentMarginBoxDelta();
+ shapeOutside->updateDeltasForContainingBlockLine(m_renderer, outermostFloat, logicalTop, logicalHeight);
+ offset += shapeOutside->rightMarginBoxDelta();
}
}
#endif
@@ -314,8 +314,8 @@
const FloatingObject* outermostFloat = adapter.outermostFloat();
if (offsetMode == ShapeOutsideFloatShapeOffset && outermostFloat) {
if (ShapeOutsideInfo* shapeOutside = outermostFloat->renderer()->shapeOutsideInfo()) {
- shapeOutside->computeSegmentsForContainingBlockLine(m_renderer, outermostFloat, logicalTop, logicalHeight);
- offset += shapeOutside->leftSegmentMarginBoxDelta();
+ shapeOutside->updateDeltasForContainingBlockLine(m_renderer, outermostFloat, logicalTop, logicalHeight);
+ offset += shapeOutside->leftMarginBoxDelta();
}
}
#endif
Modified: trunk/Source/WebCore/rendering/LineWidth.cpp (156175 => 156176)
--- trunk/Source/WebCore/rendering/LineWidth.cpp 2013-09-20 17:10:14 UTC (rev 156175)
+++ trunk/Source/WebCore/rendering/LineWidth.cpp 2013-09-20 17:16:01 UTC (rev 156176)
@@ -107,23 +107,23 @@
if (previousFloat != newFloat && previousFloat->type() == newFloat->type()) {
previousShapeOutsideInfo = previousFloat->renderer()->shapeOutsideInfo();
if (previousShapeOutsideInfo)
- previousShapeOutsideInfo->computeSegmentsForContainingBlockLine(&m_block, previousFloat, m_block.logicalHeight(), logicalHeightForLine(&m_block, m_isFirstLine));
+ previousShapeOutsideInfo->updateDeltasForContainingBlockLine(&m_block, previousFloat, m_block.logicalHeight(), logicalHeightForLine(&m_block, m_isFirstLine));
break;
}
}
ShapeOutsideInfo* shapeOutsideInfo = newFloat->renderer()->shapeOutsideInfo();
if (shapeOutsideInfo)
- shapeOutsideInfo->computeSegmentsForContainingBlockLine(&m_block, newFloat, m_block.logicalHeight(), logicalHeightForLine(&m_block, m_isFirstLine));
+ shapeOutsideInfo->updateDeltasForContainingBlockLine(&m_block, newFloat, m_block.logicalHeight(), logicalHeightForLine(&m_block, m_isFirstLine));
#endif
if (newFloat->type() == FloatingObject::FloatLeft) {
float newLeft = newFloat->logicalRight(m_block.isHorizontalWritingMode());
#if ENABLE(CSS_SHAPES)
if (previousShapeOutsideInfo)
- newLeft -= previousShapeOutsideInfo->rightSegmentMarginBoxDelta();
+ newLeft -= previousShapeOutsideInfo->rightMarginBoxDelta();
if (shapeOutsideInfo)
- newLeft += shapeOutsideInfo->rightSegmentMarginBoxDelta();
+ newLeft += shapeOutsideInfo->rightMarginBoxDelta();
#endif
if (shouldIndentText() && m_block.style()->isLeftToRightDirection())
@@ -133,9 +133,9 @@
float newRight = newFloat->logicalLeft(m_block.isHorizontalWritingMode());
#if ENABLE(CSS_SHAPES)
if (previousShapeOutsideInfo)
- newRight -= previousShapeOutsideInfo->leftSegmentMarginBoxDelta();
+ newRight -= previousShapeOutsideInfo->leftMarginBoxDelta();
if (shapeOutsideInfo)
- newRight += shapeOutsideInfo->leftSegmentMarginBoxDelta();
+ newRight += shapeOutsideInfo->leftMarginBoxDelta();
#endif
if (shouldIndentText() && !m_block.style()->isLeftToRightDirection())
Modified: trunk/Source/WebCore/rendering/shapes/ShapeInfo.cpp (156175 => 156176)
--- trunk/Source/WebCore/rendering/shapes/ShapeInfo.cpp 2013-09-20 17:10:14 UTC (rev 156175)
+++ trunk/Source/WebCore/rendering/shapes/ShapeInfo.cpp 2013-09-20 17:16:01 UTC (rev 156176)
@@ -84,20 +84,6 @@
return segments;
}
-template<class RenderType>
-bool ShapeInfo<RenderType>::updateSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight)
-{
- ASSERT(lineHeight >= 0);
- m_shapeLineTop = lineTop - logicalTopOffset();
- m_lineHeight = lineHeight;
- m_segments.clear();
-
- if (lineOverlapsShapeBounds())
- m_segments = computeSegmentsForLine(lineTop, lineHeight);
-
- return m_segments.size();
-}
-
template class ShapeInfo<RenderBlock>;
template class ShapeInfo<RenderBox>;
}
Modified: trunk/Source/WebCore/rendering/shapes/ShapeInfo.h (156175 => 156176)
--- trunk/Source/WebCore/rendering/shapes/ShapeInfo.h 2013-09-20 17:10:14 UTC (rev 156175)
+++ trunk/Source/WebCore/rendering/shapes/ShapeInfo.h 2013-09-20 17:16:01 UTC (rev 156176)
@@ -84,8 +84,6 @@
}
SegmentList computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) const;
- virtual bool updateSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight);
- void clearSegments() { m_segments.clear(); }
LayoutUnit shapeLogicalTop() const { return computedShapeLogicalBoundingBox().y() + logicalTopOffset(); }
LayoutUnit shapeLogicalBottom() const { return computedShapeLogicalBoundingBox().maxY() + logicalTopOffset(); }
@@ -119,7 +117,6 @@
LayoutUnit m_shapeLineTop;
LayoutUnit m_lineHeight;
- SegmentList m_segments;
const RenderType* m_renderer;
Modified: trunk/Source/WebCore/rendering/shapes/ShapeInsideInfo.h (156175 => 156176)
--- trunk/Source/WebCore/rendering/shapes/ShapeInsideInfo.h 2013-09-20 17:10:14 UTC (rev 156175)
+++ trunk/Source/WebCore/rendering/shapes/ShapeInsideInfo.h 2013-09-20 17:16:01 UTC (rev 156176)
@@ -71,7 +71,7 @@
bool updateSegmentsForLine(LayoutSize lineOffset, LayoutUnit lineHeight)
{
m_segmentRanges.clear();
- bool result = ShapeInfo<RenderBlock>::updateSegmentsForLine(lineOffset.height(), lineHeight);
+ bool result = updateSegmentsForLine(lineOffset.height(), lineHeight);
for (size_t i = 0; i < m_segments.size(); i++) {
m_segments[i].logicalLeft -= lineOffset.width();
m_segments[i].logicalRight -= lineOffset.width();
@@ -79,10 +79,18 @@
return result;
}
- virtual bool updateSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) OVERRIDE
+ bool updateSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight)
{
+ ASSERT(lineHeight >= 0);
+ m_shapeLineTop = lineTop - logicalTopOffset();
+ m_lineHeight = lineHeight;
+ m_segments.clear();
m_segmentRanges.clear();
- return ShapeInfo<RenderBlock>::updateSegmentsForLine(lineTop, lineHeight);
+
+ if (lineOverlapsShapeBounds())
+ m_segments = computeSegmentsForLine(lineTop, lineHeight);
+
+ return m_segments.size();
}
bool hasSegments() const
@@ -103,6 +111,7 @@
ASSERT(m_segmentRanges.size() < m_segments.size());
return &m_segments[m_segmentRanges.size()];
}
+ void clearSegments() { m_segments.clear(); }
bool adjustLogicalLineTop(float minSegmentWidth);
LayoutUnit computeFirstFitPositionForFloat(const LayoutSize) const;
@@ -131,6 +140,7 @@
SegmentRangeList m_segmentRanges;
bool m_needsLayout:1;
+ SegmentList m_segments;
};
}
Modified: trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp (156175 => 156176)
--- trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp 2013-09-20 17:10:14 UTC (rev 156175)
+++ trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp 2013-09-20 17:16:01 UTC (rev 156176)
@@ -54,27 +54,28 @@
}
}
-bool ShapeOutsideInfo::computeSegmentsForContainingBlockLine(const RenderBlock* containingBlock, const FloatingObject* floatingObject, LayoutUnit lineTop, LayoutUnit lineHeight)
+void ShapeOutsideInfo::updateDeltasForContainingBlockLine(const RenderBlock* containingBlock, const FloatingObject* floatingObject, LayoutUnit lineTop, LayoutUnit lineHeight)
{
LayoutUnit shapeTop = floatingObject->logicalTop(containingBlock->isHorizontalWritingMode()) + std::max(LayoutUnit(), containingBlock->marginBeforeForChild(m_renderer));
LayoutUnit lineTopInShapeCoordinates = lineTop - shapeTop + logicalTopOffset();
- return updateSegmentsForLine(lineTopInShapeCoordinates, lineHeight);
-}
-bool ShapeOutsideInfo::updateSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight)
-{
- if (shapeSizeDirty() || m_lineTop != lineTop || m_lineHeight != lineHeight) {
- if (ShapeInfo<RenderBox>::updateSegmentsForLine(lineTop, lineHeight)) {
- m_leftSegmentMarginBoxDelta = m_segments[0].logicalLeft + m_renderer->marginStart();
- m_rightSegmentMarginBoxDelta = m_segments[m_segments.size()-1].logicalRight - m_renderer->logicalWidth() - m_renderer->marginEnd();
- } else {
- m_leftSegmentMarginBoxDelta = m_renderer->logicalWidth() + m_renderer->marginStart();
- m_rightSegmentMarginBoxDelta = -m_renderer->logicalWidth() - m_renderer->marginEnd();
+ if (shapeSizeDirty() || m_lineTop != lineTopInShapeCoordinates || m_lineHeight != lineHeight) {
+ m_lineTop = lineTopInShapeCoordinates;
+ m_shapeLineTop = lineTopInShapeCoordinates - logicalTopOffset();
+ m_lineHeight = lineHeight;
+
+ if (lineOverlapsShapeBounds()) {
+ SegmentList segments = computeSegmentsForLine(lineTopInShapeCoordinates, lineHeight);
+ if (segments.size()) {
+ m_leftMarginBoxDelta = segments[0].logicalLeft + m_renderer->marginStart();
+ m_rightMarginBoxDelta = segments[segments.size()-1].logicalRight - m_renderer->logicalWidth() - m_renderer->marginEnd();
+ return;
+ }
}
- m_lineTop = lineTop;
+
+ m_leftMarginBoxDelta = m_renderer->logicalWidth() + m_renderer->marginStart();
+ m_rightMarginBoxDelta = -m_renderer->logicalWidth() - m_renderer->marginEnd();
}
-
- return m_segments.size();
}
ShapeValue* ShapeOutsideInfo::shapeValue() const
Modified: trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.h (156175 => 156176)
--- trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.h 2013-09-20 17:10:14 UTC (rev 156175)
+++ trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.h 2013-09-20 17:16:01 UTC (rev 156176)
@@ -43,11 +43,10 @@
class ShapeOutsideInfo FINAL : public ShapeInfo<RenderBox>, public MappedInfo<RenderBox, ShapeOutsideInfo> {
public:
- LayoutUnit leftSegmentMarginBoxDelta() const { return m_leftSegmentMarginBoxDelta; }
- LayoutUnit rightSegmentMarginBoxDelta() const { return m_rightSegmentMarginBoxDelta; }
+ LayoutUnit leftMarginBoxDelta() const { return m_leftMarginBoxDelta; }
+ LayoutUnit rightMarginBoxDelta() const { return m_rightMarginBoxDelta; }
- bool computeSegmentsForContainingBlockLine(const RenderBlock*, const FloatingObject*, LayoutUnit lineTop, LayoutUnit lineHeight);
- virtual bool updateSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) OVERRIDE;
+ void updateDeltasForContainingBlockLine(const RenderBlock*, const FloatingObject*, LayoutUnit lineTop, LayoutUnit lineHeight);
static PassOwnPtr<ShapeOutsideInfo> createInfo(const RenderBox* renderer) { return adoptPtr(new ShapeOutsideInfo(renderer)); }
static bool isEnabledFor(const RenderBox*);
@@ -69,8 +68,8 @@
private:
ShapeOutsideInfo(const RenderBox* renderer) : ShapeInfo<RenderBox>(renderer) { }
- LayoutUnit m_leftSegmentMarginBoxDelta;
- LayoutUnit m_rightSegmentMarginBoxDelta;
+ LayoutUnit m_leftMarginBoxDelta;
+ LayoutUnit m_rightMarginBoxDelta;
LayoutUnit m_lineTop;
};