| Differences between
and this patch
- a/Source/WebCore/ChangeLog +24 lines
Lines 1-5 a/Source/WebCore/ChangeLog_sec1
1
2014-04-03  Bem Jones-Bey  <bjonesbe@adobe.com>
1
2014-04-03  Bem Jones-Bey  <bjonesbe@adobe.com>
2
2
3
        Use more const refs in ShapeOutsideInfo and some misc cleanup
4
        https://bugs.webkit.org/show_bug.cgi?id=131192
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Use const refs for pretty much everything that can't be null. Also
9
        cleanup some code that got a bit messy when ShapeInfo was merged into
10
        ShapeOutsideInfo.
11
12
        No new tests, no behavior change.
13
14
        * rendering/shapes/ShapeOutsideInfo.cpp:
15
        (WebCore::ShapeOutsideInfo::shapeToRendererPoint):
16
        (WebCore::ShapeOutsideInfo::shapeToRendererSize):
17
        (WebCore::referenceBox):
18
        (WebCore::ShapeOutsideInfo::setReferenceBoxLogicalSize):
19
        (WebCore::getShapeImageAndRect):
20
        (WebCore::ShapeOutsideInfo::computedShape):
21
        (WebCore::ShapeOutsideInfo::logicalTopOffset):
22
        (WebCore::ShapeOutsideInfo::logicalLeftOffset):
23
        * rendering/shapes/ShapeOutsideInfo.h:
24
25
2014-04-03  Bem Jones-Bey  <bjonesbe@adobe.com>
26
3
        Merge ShapeInfo & ShapeOutsideInfo now that ShapeInsideInfo is no more
27
        Merge ShapeInfo & ShapeOutsideInfo now that ShapeInsideInfo is no more
4
        https://bugs.webkit.org/show_bug.cgi?id=131180
28
        https://bugs.webkit.org/show_bug.cgi?id=131180
5
29
- a/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp -28 / +31 lines
Lines 55-61 LayoutRect ShapeOutsideInfo::computedShapePhysicalBoundingBox() const a/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp_sec1
55
    return physicalBoundingBox;
55
    return physicalBoundingBox;
56
}
56
}
57
57
58
FloatPoint ShapeOutsideInfo::shapeToRendererPoint(FloatPoint point) const
58
FloatPoint ShapeOutsideInfo::shapeToRendererPoint(const FloatPoint& point) const
59
{
59
{
60
    FloatPoint result = FloatPoint(point.x() + logicalLeftOffset(), point.y() + logicalTopOffset());
60
    FloatPoint result = FloatPoint(point.x() + logicalLeftOffset(), point.y() + logicalTopOffset());
61
    if (m_renderer.style().isFlippedBlocksWritingMode())
61
    if (m_renderer.style().isFlippedBlocksWritingMode())
Lines 65-91 FloatPoint ShapeOutsideInfo::shapeToRendererPoint(FloatPoint point) const a/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp_sec2
65
    return result;
65
    return result;
66
}
66
}
67
67
68
FloatSize ShapeOutsideInfo::shapeToRendererSize(FloatSize size) const
68
FloatSize ShapeOutsideInfo::shapeToRendererSize(const FloatSize& size) const
69
{
69
{
70
    if (!m_renderer.style().isHorizontalWritingMode())
70
    if (!m_renderer.style().isHorizontalWritingMode())
71
        return size.transposedSize();
71
        return size.transposedSize();
72
    return size;
72
    return size;
73
}
73
}
74
74
75
static inline CSSBoxType referenceBox(ShapeValue* shapeValue)
75
static inline CSSBoxType referenceBox(const ShapeValue& shapeValue)
76
{
76
{
77
    if (shapeValue->cssBox() == BoxMissing) {
77
    if (shapeValue.cssBox() == BoxMissing) {
78
        if (shapeValue->type() == ShapeValue::Image)
78
        if (shapeValue.type() == ShapeValue::Image)
79
            return ContentBox;
79
            return ContentBox;
80
        return MarginBox;
80
        return MarginBox;
81
    }
81
    }
82
    return shapeValue->cssBox();
82
    return shapeValue.cssBox();
83
}
83
}
84
84
85
void ShapeOutsideInfo::setReferenceBoxLogicalSize(LayoutSize newReferenceBoxLogicalSize)
85
void ShapeOutsideInfo::setReferenceBoxLogicalSize(LayoutSize newReferenceBoxLogicalSize)
86
{
86
{
87
    bool isHorizontalWritingMode = m_renderer.containingBlock()->style().isHorizontalWritingMode();
87
    bool isHorizontalWritingMode = m_renderer.containingBlock()->style().isHorizontalWritingMode();
88
    switch (referenceBox(m_renderer.style().shapeOutside())) {
88
    switch (referenceBox(*m_renderer.style().shapeOutside())) {
89
    case MarginBox:
89
    case MarginBox:
90
        if (isHorizontalWritingMode)
90
        if (isHorizontalWritingMode)
91
            newReferenceBoxLogicalSize.expand(m_renderer.horizontalMarginExtent(), m_renderer.verticalMarginExtent());
91
            newReferenceBoxLogicalSize.expand(m_renderer.horizontalMarginExtent(), m_renderer.verticalMarginExtent());
Lines 132-148 static inline bool checkShapeImageOrigin(Document& document, CachedImage& cached a/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp_sec3
132
    return false;
132
    return false;
133
}
133
}
134
134
135
static void getShapeImageAndRect(const ShapeValue* shapeValue, const RenderBox* renderBox, const LayoutSize& referenceBoxSize, Image*& image, LayoutRect& rect)
135
static void getShapeImageAndRect(const ShapeValue& shapeValue, const RenderBox& renderBox, const LayoutSize& referenceBoxSize, Image*& image, LayoutRect& rect)
136
{
136
{
137
    ASSERT(shapeValue->isImageValid());
137
    ASSERT(shapeValue.isImageValid());
138
    StyleImage* styleImage = shapeValue->image();
138
    StyleImage* styleImage = shapeValue.image();
139
139
140
    const IntSize& imageSize = renderBox->calculateImageIntrinsicDimensions(styleImage, roundedIntSize(referenceBoxSize), RenderImage::ScaleByEffectiveZoom);
140
    const IntSize& imageSize = renderBox.calculateImageIntrinsicDimensions(styleImage, roundedIntSize(referenceBoxSize), RenderImage::ScaleByEffectiveZoom);
141
    styleImage->setContainerSizeForRenderer(renderBox, imageSize, renderBox->style().effectiveZoom());
141
    styleImage->setContainerSizeForRenderer(&renderBox, imageSize, renderBox.style().effectiveZoom());
142
142
143
    image = styleImage->cachedImage()->imageForRenderer(renderBox);
143
    image = styleImage->cachedImage()->imageForRenderer(&renderBox);
144
    if (renderBox->isRenderImage())
144
    if (renderBox.isRenderImage())
145
        rect = toRenderImage(renderBox)->replacedContentRect(renderBox->intrinsicSize());
145
        rect = toRenderImage(&renderBox)->replacedContentRect(renderBox.intrinsicSize());
146
    else
146
    else
147
        rect = LayoutRect(LayoutPoint(), imageSize);
147
        rect = LayoutRect(LayoutPoint(), imageSize);
148
}
148
}
Lines 159-186 const Shape& ShapeOutsideInfo::computedShape() const a/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp_sec4
159
    if (Shape* shape = m_shape.get())
159
    if (Shape* shape = m_shape.get())
160
        return *shape;
160
        return *shape;
161
161
162
    WritingMode writingMode = m_renderer.containingBlock()->style().writingMode();
162
    const RenderStyle& style = m_renderer.style();
163
    Length margin = m_renderer.style().shapeMargin();
163
    ASSERT(m_renderer.containingBlock());
164
    float shapeImageThreshold = m_renderer.style().shapeImageThreshold();
164
    const RenderStyle& containingBlockStyle = m_renderer.containingBlock()->style();
165
    const ShapeValue* shapeValue = this->m_renderer.style().shapeOutside();
166
    ASSERT(shapeValue);
167
165
168
    switch (shapeValue->type()) {
166
    WritingMode writingMode = containingBlockStyle.writingMode();
167
    Length margin = style.shapeMargin();
168
    float shapeImageThreshold = style.shapeImageThreshold();
169
    const ShapeValue& shapeValue = *style.shapeOutside();
170
171
    switch (shapeValue.type()) {
169
    case ShapeValue::Shape:
172
    case ShapeValue::Shape:
170
        ASSERT(shapeValue->shape());
173
        ASSERT(shapeValue.shape());
171
        m_shape = Shape::createShape(shapeValue->shape(), m_referenceBoxLogicalSize, writingMode, margin);
174
        m_shape = Shape::createShape(shapeValue.shape(), m_referenceBoxLogicalSize, writingMode, margin);
172
        break;
175
        break;
173
    case ShapeValue::Image: {
176
    case ShapeValue::Image: {
174
        Image* image;
177
        Image* image;
175
        LayoutRect imageRect;
178
        LayoutRect imageRect;
176
        getShapeImageAndRect(shapeValue, &m_renderer, m_referenceBoxLogicalSize, image, imageRect);
179
        getShapeImageAndRect(shapeValue, m_renderer, m_referenceBoxLogicalSize, image, imageRect);
177
        const LayoutRect& marginRect = getShapeImageMarginRect(m_renderer, m_referenceBoxLogicalSize);
180
        const LayoutRect& marginRect = getShapeImageMarginRect(m_renderer, m_referenceBoxLogicalSize);
178
        m_shape = Shape::createRasterShape(image, shapeImageThreshold, imageRect, marginRect, writingMode, margin);
181
        m_shape = Shape::createRasterShape(image, shapeImageThreshold, imageRect, marginRect, writingMode, margin);
179
        break;
182
        break;
180
    }
183
    }
181
    case ShapeValue::Box: {
184
    case ShapeValue::Box: {
182
        RoundedRect shapeRect = computeRoundedRectForBoxShape(referenceBox(m_renderer.style().shapeOutside()), m_renderer);
185
        RoundedRect shapeRect = computeRoundedRectForBoxShape(referenceBox(shapeValue), m_renderer);
183
        if (!m_renderer.containingBlock()->style().isHorizontalWritingMode())
186
        if (!containingBlockStyle.isHorizontalWritingMode())
184
            shapeRect = shapeRect.transposedRect();
187
            shapeRect = shapeRect.transposedRect();
185
        m_shape = Shape::createBoxShape(shapeRect, writingMode, margin);
188
        m_shape = Shape::createBoxShape(shapeRect, writingMode, margin);
186
        break;
189
        break;
Lines 222-228 static inline LayoutUnit borderAndPaddingBeforeInWritingMode(const RenderBox& re a/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp_sec5
222
225
223
LayoutUnit ShapeOutsideInfo::logicalTopOffset() const
226
LayoutUnit ShapeOutsideInfo::logicalTopOffset() const
224
{
227
{
225
    switch (referenceBox(m_renderer.style().shapeOutside())) {
228
    switch (referenceBox(*m_renderer.style().shapeOutside())) {
226
    case MarginBox: return -m_renderer.marginBefore(&m_renderer.containingBlock()->style());
229
    case MarginBox: return -m_renderer.marginBefore(&m_renderer.containingBlock()->style());
227
    case BorderBox: return LayoutUnit();
230
    case BorderBox: return LayoutUnit();
228
    case PaddingBox: return borderBeforeInWritingMode(m_renderer, m_renderer.containingBlock()->style().writingMode());
231
    case PaddingBox: return borderBeforeInWritingMode(m_renderer, m_renderer.containingBlock()->style().writingMode());
Lines 270-276 LayoutUnit ShapeOutsideInfo::logicalLeftOffset() const a/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp_sec6
270
    if (m_renderer.isRenderRegion())
273
    if (m_renderer.isRenderRegion())
271
        return LayoutUnit();
274
        return LayoutUnit();
272
    
275
    
273
    switch (referenceBox(m_renderer.style().shapeOutside())) {
276
    switch (referenceBox(*m_renderer.style().shapeOutside())) {
274
    case MarginBox: return -m_renderer.marginStart(&m_renderer.containingBlock()->style());
277
    case MarginBox: return -m_renderer.marginStart(&m_renderer.containingBlock()->style());
275
    case BorderBox: return LayoutUnit();
278
    case BorderBox: return LayoutUnit();
276
    case PaddingBox: return borderStartWithStyleForWritingMode(m_renderer, m_renderer.containingBlock()->style());
279
    case PaddingBox: return borderStartWithStyleForWritingMode(m_renderer, m_renderer.containingBlock()->style());
- a/Source/WebCore/rendering/shapes/ShapeOutsideInfo.h -2 / +2 lines
Lines 80-87 public: a/Source/WebCore/rendering/shapes/ShapeOutsideInfo.h_sec1
80
    bool isShapeDirty() { return !m_shape; }
80
    bool isShapeDirty() { return !m_shape; }
81
81
82
    LayoutRect computedShapePhysicalBoundingBox() const;
82
    LayoutRect computedShapePhysicalBoundingBox() const;
83
    FloatPoint shapeToRendererPoint(FloatPoint) const;
83
    FloatPoint shapeToRendererPoint(const FloatPoint&) const;
84
    FloatSize shapeToRendererSize(FloatSize) const;
84
    FloatSize shapeToRendererSize(const FloatSize&) const;
85
85
86
    const Shape& computedShape() const;
86
    const Shape& computedShape() const;
87
87

Return to Bug 131192