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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 ASSERT(basicShape); | 100 ASSERT(basicShape); |
101 | 101 |
102 bool horizontalWritingMode = isHorizontalWritingMode(writingMode); | 102 bool horizontalWritingMode = isHorizontalWritingMode(writingMode); |
103 float boxWidth = horizontalWritingMode ? logicalBoxSize.width().toFloat() :
logicalBoxSize.height().toFloat(); | 103 float boxWidth = horizontalWritingMode ? logicalBoxSize.width().toFloat() :
logicalBoxSize.height().toFloat(); |
104 float boxHeight = horizontalWritingMode ? logicalBoxSize.height().toFloat()
: logicalBoxSize.width().toFloat(); | 104 float boxHeight = horizontalWritingMode ? logicalBoxSize.height().toFloat()
: logicalBoxSize.width().toFloat(); |
105 OwnPtr<Shape> shape; | 105 OwnPtr<Shape> shape; |
106 | 106 |
107 switch (basicShape->type()) { | 107 switch (basicShape->type()) { |
108 | 108 |
109 case BasicShape::BasicShapeCircleType: { | 109 case BasicShape::BasicShapeCircleType: { |
110 const BasicShapeCircle* circle = static_cast<const BasicShapeCircle*>(ba
sicShape); | 110 const BasicShapeCircle* circle = toBasicShapeCircle(basicShape); |
111 FloatPoint center = floatPointForCenterCoordinate(circle->centerX(), cir
cle->centerY(), FloatSize(boxWidth, boxHeight)); | 111 FloatPoint center = floatPointForCenterCoordinate(circle->centerX(), cir
cle->centerY(), FloatSize(boxWidth, boxHeight)); |
112 float radius = circle->floatValueForRadiusInBox(FloatSize(boxWidth, boxH
eight)); | 112 float radius = circle->floatValueForRadiusInBox(FloatSize(boxWidth, boxH
eight)); |
113 FloatPoint logicalCenter = physicalPointToLogical(center, logicalBoxSize
.height().toFloat(), writingMode); | 113 FloatPoint logicalCenter = physicalPointToLogical(center, logicalBoxSize
.height().toFloat(), writingMode); |
114 | 114 |
115 shape = createCircleShape(logicalCenter, radius); | 115 shape = createCircleShape(logicalCenter, radius); |
116 break; | 116 break; |
117 } | 117 } |
118 | 118 |
119 case BasicShape::BasicShapeEllipseType: { | 119 case BasicShape::BasicShapeEllipseType: { |
120 const BasicShapeEllipse* ellipse = static_cast<const BasicShapeEllipse*>
(basicShape); | 120 const BasicShapeEllipse* ellipse = toBasicShapeEllipse(basicShape); |
121 FloatPoint center = floatPointForCenterCoordinate(ellipse->centerX(), el
lipse->centerY(), FloatSize(boxWidth, boxHeight)); | 121 FloatPoint center = floatPointForCenterCoordinate(ellipse->centerX(), el
lipse->centerY(), FloatSize(boxWidth, boxHeight)); |
122 float radiusX = ellipse->floatValueForRadiusInBox(ellipse->radiusX(), ce
nter.x(), boxWidth); | 122 float radiusX = ellipse->floatValueForRadiusInBox(ellipse->radiusX(), ce
nter.x(), boxWidth); |
123 float radiusY = ellipse->floatValueForRadiusInBox(ellipse->radiusY(), ce
nter.y(), boxHeight); | 123 float radiusY = ellipse->floatValueForRadiusInBox(ellipse->radiusY(), ce
nter.y(), boxHeight); |
124 FloatPoint logicalCenter = physicalPointToLogical(center, logicalBoxSize
.height().toFloat(), writingMode); | 124 FloatPoint logicalCenter = physicalPointToLogical(center, logicalBoxSize
.height().toFloat(), writingMode); |
125 | 125 |
126 shape = createEllipseShape(logicalCenter, FloatSize(radiusX, radiusY)); | 126 shape = createEllipseShape(logicalCenter, FloatSize(radiusX, radiusY)); |
127 break; | 127 break; |
128 } | 128 } |
129 | 129 |
130 case BasicShape::BasicShapePolygonType: { | 130 case BasicShape::BasicShapePolygonType: { |
131 const BasicShapePolygon* polygon = static_cast<const BasicShapePolygon*>
(basicShape); | 131 const BasicShapePolygon* polygon = toBasicShapePolygon(basicShape); |
132 const Vector<Length>& values = polygon->values(); | 132 const Vector<Length>& values = polygon->values(); |
133 size_t valuesSize = values.size(); | 133 size_t valuesSize = values.size(); |
134 ASSERT(!(valuesSize % 2)); | 134 ASSERT(!(valuesSize % 2)); |
135 OwnPtr<Vector<FloatPoint> > vertices = adoptPtr(new Vector<FloatPoint>(v
aluesSize / 2)); | 135 OwnPtr<Vector<FloatPoint> > vertices = adoptPtr(new Vector<FloatPoint>(v
aluesSize / 2)); |
136 for (unsigned i = 0; i < valuesSize; i += 2) { | 136 for (unsigned i = 0; i < valuesSize; i += 2) { |
137 FloatPoint vertex( | 137 FloatPoint vertex( |
138 floatValueForLength(values.at(i), boxWidth), | 138 floatValueForLength(values.at(i), boxWidth), |
139 floatValueForLength(values.at(i + 1), boxHeight)); | 139 floatValueForLength(values.at(i + 1), boxHeight)); |
140 (*vertices)[i / 2] = physicalPointToLogical(vertex, logicalBoxSize.h
eight().toFloat(), writingMode); | 140 (*vertices)[i / 2] = physicalPointToLogical(vertex, logicalBoxSize.h
eight().toFloat(), writingMode); |
141 } | 141 } |
142 shape = createPolygonShape(vertices.release(), polygon->windRule()); | 142 shape = createPolygonShape(vertices.release(), polygon->windRule()); |
143 break; | 143 break; |
144 } | 144 } |
145 | 145 |
146 case BasicShape::BasicShapeInsetType: { | 146 case BasicShape::BasicShapeInsetType: { |
147 const BasicShapeInset& inset = *static_cast<const BasicShapeInset*>(basi
cShape); | 147 const BasicShapeInset& inset = *toBasicShapeInset(basicShape); |
148 float left = floatValueForLength(inset.left(), boxWidth); | 148 float left = floatValueForLength(inset.left(), boxWidth); |
149 float top = floatValueForLength(inset.top(), boxHeight); | 149 float top = floatValueForLength(inset.top(), boxHeight); |
150 float right = floatValueForLength(inset.right(), boxWidth); | 150 float right = floatValueForLength(inset.right(), boxWidth); |
151 float bottom = floatValueForLength(inset.bottom(), boxHeight); | 151 float bottom = floatValueForLength(inset.bottom(), boxHeight); |
152 FloatRect rect(left, top, std::max<float>(boxWidth - left - right, 0), s
td::max<float>(boxHeight - top - bottom, 0)); | 152 FloatRect rect(left, top, std::max<float>(boxWidth - left - right, 0), s
td::max<float>(boxHeight - top - bottom, 0)); |
153 FloatRect logicalRect = physicalRectToLogical(rect, logicalBoxSize.heigh
t().toFloat(), writingMode); | 153 FloatRect logicalRect = physicalRectToLogical(rect, logicalBoxSize.heigh
t().toFloat(), writingMode); |
154 | 154 |
155 FloatSize boxSize(boxWidth, boxHeight); | 155 FloatSize boxSize(boxWidth, boxHeight); |
156 FloatSize topLeftRadius = physicalSizeToLogical(floatSizeForLengthSize(i
nset.topLeftRadius(), boxSize), writingMode); | 156 FloatSize topLeftRadius = physicalSizeToLogical(floatSizeForLengthSize(i
nset.topLeftRadius(), boxSize), writingMode); |
157 FloatSize topRightRadius = physicalSizeToLogical(floatSizeForLengthSize(
inset.topRightRadius(), boxSize), writingMode); | 157 FloatSize topRightRadius = physicalSizeToLogical(floatSizeForLengthSize(
inset.topRightRadius(), boxSize), writingMode); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 FloatRect rect(0, 0, roundedRect.rect().width(), roundedRect.rect().height()
); | 222 FloatRect rect(0, 0, roundedRect.rect().width(), roundedRect.rect().height()
); |
223 FloatRoundedRect bounds(rect, roundedRect.radii()); | 223 FloatRoundedRect bounds(rect, roundedRect.radii()); |
224 OwnPtr<Shape> shape = createInsetShape(bounds); | 224 OwnPtr<Shape> shape = createInsetShape(bounds); |
225 shape->m_writingMode = writingMode; | 225 shape->m_writingMode = writingMode; |
226 shape->m_margin = margin; | 226 shape->m_margin = margin; |
227 | 227 |
228 return shape.release(); | 228 return shape.release(); |
229 } | 229 } |
230 | 230 |
231 } // namespace WebCore | 231 } // namespace WebCore |
OLD | NEW |