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:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@156176
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2013-09-20 Bem Jones-Bey <bjonesbe@adobe.com>
+
+ 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 <a1.gomes@sisa.samsung.com>
Making tests added in r156157 JS-only, given that other
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
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
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())
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())
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>;
}
}
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(); }
LayoutUnit m_shapeLineTop;
LayoutUnit m_lineHeight;
- SegmentList m_segments;
const RenderType* m_renderer;
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();
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
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;
SegmentRangeList m_segmentRanges;
bool m_needsLayout:1;
+ SegmentList m_segments;
};
}
}
}
-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;
- }
- return m_segments.size();
+ m_leftMarginBoxDelta = m_renderer->logicalWidth() + m_renderer->marginStart();
+ m_rightMarginBoxDelta = -m_renderer->logicalWidth() - m_renderer->marginEnd();
+ }
}
ShapeValue* ShapeOutsideInfo::shapeValue() const
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*);
private:
ShapeOutsideInfo(const RenderBox* renderer) : ShapeInfo<RenderBox>(renderer) { }
- LayoutUnit m_leftSegmentMarginBoxDelta;
- LayoutUnit m_rightSegmentMarginBoxDelta;
+ LayoutUnit m_leftMarginBoxDelta;
+ LayoutUnit m_rightMarginBoxDelta;
LayoutUnit m_lineTop;
};