https://bugs.webkit.org/show_bug.cgi?id=121213
Reviewed by Darin Adler.
These classes were trying to be way too clever, and as a result were
hard to read and hard to debug. Replace the complex templated method
calls with virtual methods to make these classes much easier to
understand and maintain.
No new tests, no behavior change.
* rendering/shapes/ShapeInfo.cpp:
(WebCore::::computedShape):
(WebCore::::computeSegmentsForLine):
* rendering/shapes/ShapeInfo.h:
* rendering/shapes/ShapeInsideInfo.cpp:
(WebCore::ShapeInsideInfo::getShapeValue):
* rendering/shapes/ShapeInsideInfo.h:
(WebCore::ShapeInsideInfo::computeSegmentsForLine):
(WebCore::ShapeInsideInfo::ShapeInsideInfo):
* rendering/shapes/ShapeOutsideInfo.cpp:
(WebCore::ShapeOutsideInfo::computeSegmentsForLine):
(WebCore::ShapeOutsideInfo::getShapeValue):
* rendering/shapes/ShapeOutsideInfo.h:
(WebCore::ShapeOutsideInfo::ShapeOutsideInfo):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@155627
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2013-09-12 Bem Jones-Bey <bjonesbe@adobe.com>
+
+ [CSS Shapes] Remove unnecessarily complex template from ShapeInfo classes
+ https://bugs.webkit.org/show_bug.cgi?id=121213
+
+ Reviewed by Darin Adler.
+
+ These classes were trying to be way too clever, and as a result were
+ hard to read and hard to debug. Replace the complex templated method
+ calls with virtual methods to make these classes much easier to
+ understand and maintain.
+
+ No new tests, no behavior change.
+
+ * rendering/shapes/ShapeInfo.cpp:
+ (WebCore::::computedShape):
+ (WebCore::::computeSegmentsForLine):
+ * rendering/shapes/ShapeInfo.h:
+ * rendering/shapes/ShapeInsideInfo.cpp:
+ (WebCore::ShapeInsideInfo::getShapeValue):
+ * rendering/shapes/ShapeInsideInfo.h:
+ (WebCore::ShapeInsideInfo::computeSegmentsForLine):
+ (WebCore::ShapeInsideInfo::ShapeInsideInfo):
+ * rendering/shapes/ShapeOutsideInfo.cpp:
+ (WebCore::ShapeOutsideInfo::computeSegmentsForLine):
+ (WebCore::ShapeOutsideInfo::getShapeValue):
+ * rendering/shapes/ShapeOutsideInfo.h:
+ (WebCore::ShapeOutsideInfo::ShapeOutsideInfo):
+
2013-09-12 Zoltan Horvath <zoltan@webkit.org>
[CSS Shapes] Turn shape's logicalwidth/height into a LayoutSize
#include "Shape.h"
namespace WebCore {
-template<class RenderType, ShapeValue* (RenderStyle::*shapeGetter)() const, void (Shape::*intervalGetter)(LayoutUnit, LayoutUnit, SegmentList&) const>
-const Shape* ShapeInfo<RenderType, shapeGetter, intervalGetter>::computedShape() const
+template<class RenderType>
+const Shape* ShapeInfo<RenderType>::computedShape() const
{
if (Shape* shape = m_shape.get())
return shape;
WritingMode writingMode = m_renderer->style()->writingMode();
Length margin = m_renderer->style()->shapeMargin();
Length padding = m_renderer->style()->shapePadding();
- const ShapeValue* shapeValue = (m_renderer->style()->*shapeGetter)();
+ const ShapeValue* shapeValue = this->shapeValue();
ASSERT(shapeValue);
switch (shapeValue->type()) {
return m_shape.get();
}
-template<class RenderType, ShapeValue* (RenderStyle::*shapeGetter)() const, void (Shape::*intervalGetter)(LayoutUnit, LayoutUnit, SegmentList&) const>
-bool ShapeInfo<RenderType, shapeGetter, intervalGetter>::computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight)
+template<class RenderType>
+bool ShapeInfo<RenderType>::computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight)
{
ASSERT(lineHeight >= 0);
m_shapeLineTop = lineTop - logicalTopOffset();
m_segments.clear();
if (lineOverlapsShapeBounds())
- (computedShape()->*intervalGetter)(m_shapeLineTop, std::min(m_lineHeight, shapeLogicalBottom() - lineTop), m_segments);
+ getIntervals(m_shapeLineTop, std::min(m_lineHeight, shapeLogicalBottom() - lineTop), m_segments);
LayoutUnit logicalLeftOffset = this->logicalLeftOffset();
for (size_t i = 0; i < m_segments.size(); i++) {
return m_segments.size();
}
-template class ShapeInfo<RenderBlock, &RenderStyle::resolvedShapeInside, &Shape::getIncludedIntervals>;
-template class ShapeInfo<RenderBox, &RenderStyle::shapeOutside, &Shape::getExcludedIntervals>;
+template class ShapeInfo<RenderBlock>;
+template class ShapeInfo<RenderBox>;
}
#endif
}
};
-template<class RenderType, ShapeValue* (RenderStyle::*shapeGetter)() const, void (Shape::*intervalGetter)(LayoutUnit, LayoutUnit, SegmentList&) const>
+template<class RenderType>
class ShapeInfo {
WTF_MAKE_FAST_ALLOCATED;
public:
const Shape* computedShape() const;
virtual LayoutRect computedShapeLogicalBoundingBox() const = 0;
+ virtual ShapeValue* shapeValue() const = 0;
+ virtual void getIntervals(LayoutUnit, LayoutUnit, SegmentList&) const = 0;
LayoutUnit logicalTopOffset() const { return m_renderer->style()->boxSizing() == CONTENT_BOX ? m_renderer->borderAndPaddingBefore() : LayoutUnit(); };
LayoutUnit logicalLeftOffset() const { return (m_renderer->style()->boxSizing() == CONTENT_BOX && !m_renderer->isRenderRegion()) ? m_renderer->borderAndPaddingStart() : LayoutUnit(); }
return false;
}
+ShapeValue* ShapeInsideInfo::shapeValue() const
+{
+ return m_renderer->style()->resolvedShapeInside();
+}
+
}
#endif
typedef Vector<LineSegmentRange> SegmentRangeList;
-class ShapeInsideInfo : public ShapeInfo<RenderBlock, &RenderStyle::resolvedShapeInside, &Shape::getIncludedIntervals> {
+class ShapeInsideInfo FINAL : public ShapeInfo<RenderBlock> {
public:
static PassOwnPtr<ShapeInsideInfo> createInfo(const RenderBlock* renderer) { return adoptPtr(new ShapeInsideInfo(renderer)); }
bool computeSegmentsForLine(LayoutSize lineOffset, LayoutUnit lineHeight)
{
m_segmentRanges.clear();
- bool result = ShapeInfo<RenderBlock, &RenderStyle::resolvedShapeInside, &Shape::getIncludedIntervals>::computeSegmentsForLine(lineOffset.height(), lineHeight);
+ bool result = ShapeInfo<RenderBlock>::computeSegmentsForLine(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();
virtual bool computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) OVERRIDE
{
m_segmentRanges.clear();
- return ShapeInfo<RenderBlock, &RenderStyle::resolvedShapeInside, &Shape::getIncludedIntervals>::computeSegmentsForLine(lineTop, lineHeight);
+ return ShapeInfo<RenderBlock>::computeSegmentsForLine(lineTop, lineHeight);
}
bool hasSegments() const
protected:
virtual LayoutRect computedShapeLogicalBoundingBox() const OVERRIDE { return computedShape()->shapePaddingLogicalBoundingBox(); }
+ virtual ShapeValue* shapeValue() const OVERRIDE;
+ virtual void getIntervals(LayoutUnit lineTop, LayoutUnit lineHeight, SegmentList& segments) const OVERRIDE
+ {
+ return computedShape()->getIncludedIntervals(lineTop, lineHeight, segments);
+ }
private:
ShapeInsideInfo(const RenderBlock* renderer)
- : ShapeInfo<RenderBlock, &RenderStyle::resolvedShapeInside, &Shape::getIncludedIntervals> (renderer)
+ : ShapeInfo<RenderBlock> (renderer)
, m_needsLayout(false)
{ }
bool ShapeOutsideInfo::computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight)
{
if (shapeSizeDirty() || m_lineTop != lineTop || m_lineHeight != lineHeight) {
- if (ShapeInfo<RenderBox, &RenderStyle::shapeOutside, &Shape::getExcludedIntervals>::computeSegmentsForLine(lineTop, lineHeight)) {
+ if (ShapeInfo<RenderBox>::computeSegmentsForLine(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 {
return m_segments.size();
}
+ShapeValue* ShapeOutsideInfo::shapeValue() const
+{
+ return m_renderer->style()->shapeOutside();
+}
+
}
#endif
class RenderBox;
-class ShapeOutsideInfo : public ShapeInfo<RenderBox, &RenderStyle::shapeOutside, &Shape::getExcludedIntervals>, public MappedInfo<RenderBox, ShapeOutsideInfo> {
+class ShapeOutsideInfo FINAL : public ShapeInfo<RenderBox>, public MappedInfo<RenderBox, ShapeOutsideInfo> {
public:
LayoutUnit leftSegmentMarginBoxDelta() const { return m_leftSegmentMarginBoxDelta; }
LayoutUnit rightSegmentMarginBoxDelta() const { return m_rightSegmentMarginBoxDelta; }
protected:
virtual LayoutRect computedShapeLogicalBoundingBox() const OVERRIDE { return computedShape()->shapeMarginLogicalBoundingBox(); }
+ virtual ShapeValue* shapeValue() const OVERRIDE;
+ virtual void getIntervals(LayoutUnit lineTop, LayoutUnit lineHeight, SegmentList& segments) const OVERRIDE
+ {
+ return computedShape()->getExcludedIntervals(lineTop, lineHeight, segments);
+ }
private:
- ShapeOutsideInfo(const RenderBox* renderer) : ShapeInfo<RenderBox, &RenderStyle::shapeOutside, &Shape::getExcludedIntervals>(renderer) { }
+ ShapeOutsideInfo(const RenderBox* renderer) : ShapeInfo<RenderBox>(renderer) { }
LayoutUnit m_leftSegmentMarginBoxDelta;
LayoutUnit m_rightSegmentMarginBoxDelta;