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 18 matching lines...) Expand all Loading... |
29 | 29 |
30 #include "config.h" | 30 #include "config.h" |
31 #include "core/rendering/shapes/Shape.h" | 31 #include "core/rendering/shapes/Shape.h" |
32 | 32 |
33 #include "core/css/BasicShapeFunctions.h" | 33 #include "core/css/BasicShapeFunctions.h" |
34 #include "core/fetch/ImageResource.h" | 34 #include "core/fetch/ImageResource.h" |
35 #include "core/rendering/shapes/BoxShape.h" | 35 #include "core/rendering/shapes/BoxShape.h" |
36 #include "core/rendering/shapes/PolygonShape.h" | 36 #include "core/rendering/shapes/PolygonShape.h" |
37 #include "core/rendering/shapes/RasterShape.h" | 37 #include "core/rendering/shapes/RasterShape.h" |
38 #include "core/rendering/shapes/RectangleShape.h" | 38 #include "core/rendering/shapes/RectangleShape.h" |
| 39 #include "core/rendering/style/RenderStyle.h" |
39 #include "platform/LengthFunctions.h" | 40 #include "platform/LengthFunctions.h" |
40 #include "platform/geometry/FloatRoundedRect.h" | |
41 #include "platform/geometry/FloatSize.h" | 41 #include "platform/geometry/FloatSize.h" |
42 #include "platform/graphics/ImageBuffer.h" | 42 #include "platform/graphics/ImageBuffer.h" |
43 #include "platform/graphics/WindRule.h" | 43 #include "platform/graphics/WindRule.h" |
44 #include "wtf/MathExtras.h" | 44 #include "wtf/MathExtras.h" |
45 #include "wtf/OwnPtr.h" | 45 #include "wtf/OwnPtr.h" |
46 | 46 |
47 namespace WebCore { | 47 namespace WebCore { |
48 | 48 |
49 static PassOwnPtr<Shape> createInsetShape(const FloatRoundedRect& bounds) | 49 static PassOwnPtr<Shape> createInsetShape(const FloatRoundedRect& bounds) |
50 { | 50 { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 return point.transposedPoint(); | 93 return point.transposedPoint(); |
94 } | 94 } |
95 | 95 |
96 static inline FloatSize physicalSizeToLogical(const FloatSize& size, WritingMode
writingMode) | 96 static inline FloatSize physicalSizeToLogical(const FloatSize& size, WritingMode
writingMode) |
97 { | 97 { |
98 if (isHorizontalWritingMode(writingMode)) | 98 if (isHorizontalWritingMode(writingMode)) |
99 return size; | 99 return size; |
100 return size.transposedSize(); | 100 return size.transposedSize(); |
101 } | 101 } |
102 | 102 |
103 static inline void ensureRadiiDoNotOverlap(FloatRect &bounds, FloatSize &radii) | 103 static inline void ensureRadiiDoNotOverlap(FloatRect& bounds, FloatSize& radii) |
104 { | 104 { |
105 float widthRatio = bounds.width() / (2 * radii.width()); | 105 float widthRatio = bounds.width() / (2 * radii.width()); |
106 float heightRatio = bounds.height() / (2 * radii.height()); | 106 float heightRatio = bounds.height() / (2 * radii.height()); |
107 float reductionRatio = std::min<float>(widthRatio, heightRatio); | 107 float reductionRatio = std::min<float>(widthRatio, heightRatio); |
108 if (reductionRatio < 1) { | 108 if (reductionRatio < 1) { |
109 radii.setWidth(reductionRatio * radii.width()); | 109 radii.setWidth(reductionRatio * radii.width()); |
110 radii.setHeight(reductionRatio * radii.height()); | 110 radii.setHeight(reductionRatio * radii.height()); |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 FloatRect rect(left, top, std::max<float>(boxWidth - left - right, 0), s
td::max<float>(boxHeight - top - bottom, 0)); | 234 FloatRect rect(left, top, std::max<float>(boxWidth - left - right, 0), s
td::max<float>(boxHeight - top - bottom, 0)); |
235 FloatRect logicalRect = physicalRectToLogical(rect, logicalBoxSize.heigh
t(), writingMode); | 235 FloatRect logicalRect = physicalRectToLogical(rect, logicalBoxSize.heigh
t(), writingMode); |
236 | 236 |
237 FloatSize boxSize(boxWidth, boxHeight); | 237 FloatSize boxSize(boxWidth, boxHeight); |
238 FloatRoundedRect::Radii cornerRadii( | 238 FloatRoundedRect::Radii cornerRadii( |
239 floatSizeForLengthSize(inset.topLeftRadius(), boxSize), | 239 floatSizeForLengthSize(inset.topLeftRadius(), boxSize), |
240 floatSizeForLengthSize(inset.topRightRadius(), boxSize), | 240 floatSizeForLengthSize(inset.topRightRadius(), boxSize), |
241 floatSizeForLengthSize(inset.bottomLeftRadius(), boxSize), | 241 floatSizeForLengthSize(inset.bottomLeftRadius(), boxSize), |
242 floatSizeForLengthSize(inset.bottomRightRadius(), boxSize)); | 242 floatSizeForLengthSize(inset.bottomRightRadius(), boxSize)); |
243 | 243 |
| 244 cornerRadii.scale(calcBorderRadiiConstraintScaleFor(logicalRect, cornerR
adii)); |
| 245 |
244 shape = createInsetShape(FloatRoundedRect(logicalRect, cornerRadii)); | 246 shape = createInsetShape(FloatRoundedRect(logicalRect, cornerRadii)); |
245 break; | 247 break; |
246 } | 248 } |
247 | 249 |
248 default: | 250 default: |
249 ASSERT_NOT_REACHED(); | 251 ASSERT_NOT_REACHED(); |
250 } | 252 } |
251 | 253 |
252 shape->m_writingMode = writingMode; | 254 shape->m_writingMode = writingMode; |
253 shape->m_margin = floatValueForLength(margin, 0); | 255 shape->m_margin = floatValueForLength(margin, 0); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 FloatRoundedRect bounds(rect, roundedRect.radii()); | 306 FloatRoundedRect bounds(rect, roundedRect.radii()); |
305 OwnPtr<Shape> shape = createInsetShape(bounds); | 307 OwnPtr<Shape> shape = createInsetShape(bounds); |
306 shape->m_writingMode = writingMode; | 308 shape->m_writingMode = writingMode; |
307 shape->m_margin = floatValueForLength(margin, 0); | 309 shape->m_margin = floatValueForLength(margin, 0); |
308 shape->m_padding = floatValueForLength(padding, 0); | 310 shape->m_padding = floatValueForLength(padding, 0); |
309 | 311 |
310 return shape.release(); | 312 return shape.release(); |
311 } | 313 } |
312 | 314 |
313 } // namespace WebCore | 315 } // namespace WebCore |
OLD | NEW |