| 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, Length padding) | 97 PassOwnPtr<Shape> Shape::createShape(const BasicShape* basicShape, const LayoutS
ize& logicalBoxSize, WritingMode writingMode, Length 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = floatValueForLength(margin, 0); |
| 173 shape->m_padding = floatValueForLength(padding, 0); | |
| 174 | 173 |
| 175 return shape.release(); | 174 return shape.release(); |
| 176 } | 175 } |
| 177 | 176 |
| 178 PassOwnPtr<Shape> Shape::createRasterShape(Image* image, float threshold, const
LayoutRect& imageR, const LayoutRect& marginR, WritingMode writingMode, Length m
argin, Length padding) | 177 PassOwnPtr<Shape> Shape::createRasterShape(Image* image, float threshold, const
LayoutRect& imageR, const LayoutRect& marginR, WritingMode writingMode, Length m
argin) |
| 179 { | 178 { |
| 180 IntRect imageRect = pixelSnappedIntRect(imageR); | 179 IntRect imageRect = pixelSnappedIntRect(imageR); |
| 181 IntRect marginRect = pixelSnappedIntRect(marginR); | 180 IntRect marginRect = pixelSnappedIntRect(marginR); |
| 182 OwnPtr<RasterShapeIntervals> intervals = adoptPtr(new RasterShapeIntervals(m
arginRect.height(), -marginRect.y())); | 181 OwnPtr<RasterShapeIntervals> intervals = adoptPtr(new RasterShapeIntervals(m
arginRect.height(), -marginRect.y())); |
| 183 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(imageRect.size()); | 182 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(imageRect.size()); |
| 184 | 183 |
| 185 if (imageBuffer) { | 184 if (imageBuffer) { |
| 186 GraphicsContext* graphicsContext = imageBuffer->context(); | 185 GraphicsContext* graphicsContext = imageBuffer->context(); |
| 187 graphicsContext->drawImage(image, IntRect(IntPoint(), imageRect.size()))
; | 186 graphicsContext->drawImage(image, IntRect(IntPoint(), imageRect.size()))
; |
| 188 | 187 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 206 intervals->appendInterval(y + imageRect.y(), startX + imageR
ect.x(), x + imageRect.x()); | 205 intervals->appendInterval(y + imageRect.y(), startX + imageR
ect.x(), x + imageRect.x()); |
| 207 startX = -1; | 206 startX = -1; |
| 208 } | 207 } |
| 209 } | 208 } |
| 210 } | 209 } |
| 211 } | 210 } |
| 212 | 211 |
| 213 OwnPtr<RasterShape> rasterShape = adoptPtr(new RasterShape(intervals.release
(), marginRect.size())); | 212 OwnPtr<RasterShape> rasterShape = adoptPtr(new RasterShape(intervals.release
(), marginRect.size())); |
| 214 rasterShape->m_writingMode = writingMode; | 213 rasterShape->m_writingMode = writingMode; |
| 215 rasterShape->m_margin = floatValueForLength(margin, 0); | 214 rasterShape->m_margin = floatValueForLength(margin, 0); |
| 216 rasterShape->m_padding = floatValueForLength(padding, 0); | |
| 217 return rasterShape.release(); | 215 return rasterShape.release(); |
| 218 } | 216 } |
| 219 | 217 |
| 220 PassOwnPtr<Shape> Shape::createBoxShape(const RoundedRect& roundedRect, WritingM
ode writingMode, const Length& margin, const Length& padding) | 218 PassOwnPtr<Shape> Shape::createLayoutBoxShape(const RoundedRect& roundedRect, Wr
itingMode writingMode, const Length& margin) |
| 221 { | 219 { |
| 222 FloatRect rect(0, 0, roundedRect.rect().width(), roundedRect.rect().height()
); | 220 FloatRect rect(0, 0, roundedRect.rect().width(), roundedRect.rect().height()
); |
| 223 FloatRoundedRect bounds(rect, roundedRect.radii()); | 221 FloatRoundedRect bounds(rect, roundedRect.radii()); |
| 224 OwnPtr<Shape> shape = createInsetShape(bounds); | 222 OwnPtr<Shape> shape = createInsetShape(bounds); |
| 225 shape->m_writingMode = writingMode; | 223 shape->m_writingMode = writingMode; |
| 226 shape->m_margin = floatValueForLength(margin, 0); | 224 shape->m_margin = floatValueForLength(margin, 0); |
| 227 shape->m_padding = floatValueForLength(padding, 0); | |
| 228 | 225 |
| 229 return shape.release(); | 226 return shape.release(); |
| 230 } | 227 } |
| 231 | 228 |
| 232 } // namespace WebCore | 229 } // namespace WebCore |
| OLD | NEW |