| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
| 9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
| 10 * disclaimer. | 10 * disclaimer. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 return point.transposedPoint(); | 87 return point.transposedPoint(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 static inline FloatSize physicalSizeToLogical(const FloatSize& size, WritingMode
writingMode) | 90 static inline FloatSize physicalSizeToLogical(const FloatSize& size, WritingMode
writingMode) |
| 91 { | 91 { |
| 92 if (isHorizontalWritingMode(writingMode)) | 92 if (isHorizontalWritingMode(writingMode)) |
| 93 return size; | 93 return size; |
| 94 return size.transposedSize(); | 94 return size.transposedSize(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 PassOwnPtr<Shape> Shape::createShape(const BasicShape* basicShape, const LayoutS
ize& logicalBoxSize, WritingMode writingMode, Length margin) | 97 PassOwnPtr<Shape> Shape::createShape(const BasicShape* basicShape, const LayoutS
ize& logicalBoxSize, WritingMode writingMode, float margin) |
| 98 { | 98 { |
| 99 ASSERT(basicShape); | 99 ASSERT(basicShape); |
| 100 | 100 |
| 101 bool horizontalWritingMode = isHorizontalWritingMode(writingMode); | 101 bool horizontalWritingMode = isHorizontalWritingMode(writingMode); |
| 102 float boxWidth = horizontalWritingMode ? logicalBoxSize.width().toFloat() :
logicalBoxSize.height().toFloat(); | 102 float boxWidth = horizontalWritingMode ? logicalBoxSize.width().toFloat() :
logicalBoxSize.height().toFloat(); |
| 103 float boxHeight = horizontalWritingMode ? logicalBoxSize.height().toFloat()
: logicalBoxSize.width().toFloat(); | 103 float boxHeight = horizontalWritingMode ? logicalBoxSize.height().toFloat()
: logicalBoxSize.width().toFloat(); |
| 104 OwnPtr<Shape> shape; | 104 OwnPtr<Shape> shape; |
| 105 | 105 |
| 106 switch (basicShape->type()) { | 106 switch (basicShape->type()) { |
| 107 | 107 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 162 |
| 163 shape = createInsetShape(FloatRoundedRect(logicalRect, cornerRadii)); | 163 shape = createInsetShape(FloatRoundedRect(logicalRect, cornerRadii)); |
| 164 break; | 164 break; |
| 165 } | 165 } |
| 166 | 166 |
| 167 default: | 167 default: |
| 168 ASSERT_NOT_REACHED(); | 168 ASSERT_NOT_REACHED(); |
| 169 } | 169 } |
| 170 | 170 |
| 171 shape->m_writingMode = writingMode; | 171 shape->m_writingMode = writingMode; |
| 172 shape->m_margin = floatValueForLength(margin, 0); | 172 shape->m_margin = margin; |
| 173 | 173 |
| 174 return shape.release(); | 174 return shape.release(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 PassOwnPtr<Shape> Shape::createRasterShape(Image* image, float threshold, const
LayoutRect& imageR, const LayoutRect& marginR, WritingMode writingMode, Length m
argin) | 177 PassOwnPtr<Shape> Shape::createRasterShape(Image* image, float threshold, const
LayoutRect& imageR, const LayoutRect& marginR, WritingMode writingMode, float ma
rgin) |
| 178 { | 178 { |
| 179 IntRect imageRect = pixelSnappedIntRect(imageR); | 179 IntRect imageRect = pixelSnappedIntRect(imageR); |
| 180 IntRect marginRect = pixelSnappedIntRect(marginR); | 180 IntRect marginRect = pixelSnappedIntRect(marginR); |
| 181 OwnPtr<RasterShapeIntervals> intervals = adoptPtr(new RasterShapeIntervals(m
arginRect.height(), -marginRect.y())); | 181 OwnPtr<RasterShapeIntervals> intervals = adoptPtr(new RasterShapeIntervals(m
arginRect.height(), -marginRect.y())); |
| 182 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(imageRect.size()); | 182 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(imageRect.size()); |
| 183 | 183 |
| 184 if (imageBuffer) { | 184 if (imageBuffer) { |
| 185 GraphicsContext* graphicsContext = imageBuffer->context(); | 185 GraphicsContext* graphicsContext = imageBuffer->context(); |
| 186 graphicsContext->drawImage(image, IntRect(IntPoint(), imageRect.size()))
; | 186 graphicsContext->drawImage(image, IntRect(IntPoint(), imageRect.size()))
; |
| 187 | 187 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 204 } else if (startX != -1 && (!alphaAboveThreshold || x == imageRe
ct.width() - 1)) { | 204 } else if (startX != -1 && (!alphaAboveThreshold || x == imageRe
ct.width() - 1)) { |
| 205 intervals->intervalAt(y + imageRect.y()).unite(IntShapeInter
val(startX + imageRect.x(), x + imageRect.x())); | 205 intervals->intervalAt(y + imageRect.y()).unite(IntShapeInter
val(startX + imageRect.x(), x + imageRect.x())); |
| 206 startX = -1; | 206 startX = -1; |
| 207 } | 207 } |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 } | 210 } |
| 211 | 211 |
| 212 OwnPtr<RasterShape> rasterShape = adoptPtr(new RasterShape(intervals.release
(), marginRect.size())); | 212 OwnPtr<RasterShape> rasterShape = adoptPtr(new RasterShape(intervals.release
(), marginRect.size())); |
| 213 rasterShape->m_writingMode = writingMode; | 213 rasterShape->m_writingMode = writingMode; |
| 214 rasterShape->m_margin = floatValueForLength(margin, 0); | 214 rasterShape->m_margin = margin; |
| 215 return rasterShape.release(); | 215 return rasterShape.release(); |
| 216 } | 216 } |
| 217 | 217 |
| 218 PassOwnPtr<Shape> Shape::createLayoutBoxShape(const RoundedRect& roundedRect, Wr
itingMode writingMode, const Length& margin) | 218 PassOwnPtr<Shape> Shape::createLayoutBoxShape(const RoundedRect& roundedRect, Wr
itingMode writingMode, float margin) |
| 219 { | 219 { |
| 220 FloatRect rect(0, 0, roundedRect.rect().width(), roundedRect.rect().height()
); | 220 FloatRect rect(0, 0, roundedRect.rect().width(), roundedRect.rect().height()
); |
| 221 FloatRoundedRect bounds(rect, roundedRect.radii()); | 221 FloatRoundedRect bounds(rect, roundedRect.radii()); |
| 222 OwnPtr<Shape> shape = createInsetShape(bounds); | 222 OwnPtr<Shape> shape = createInsetShape(bounds); |
| 223 shape->m_writingMode = writingMode; | 223 shape->m_writingMode = writingMode; |
| 224 shape->m_margin = floatValueForLength(margin, 0); | 224 shape->m_margin = margin; |
| 225 | 225 |
| 226 return shape.release(); | 226 return shape.release(); |
| 227 } | 227 } |
| 228 | 228 |
| 229 } // namespace WebCore | 229 } // namespace WebCore |
| OLD | NEW |