Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: Source/core/rendering/exclusions/ExclusionShape.cpp

Issue 14892005: [CSS Exclusions] ExclusionShape bounding box methods should return LayoutRects (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: reverted LineSegment logicalLeft,Right type change Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 return point.transposedPoint(); 83 return point.transposedPoint();
84 } 84 }
85 85
86 static inline FloatSize physicalSizeToLogical(const FloatSize& size, WritingMode writingMode) 86 static inline FloatSize physicalSizeToLogical(const FloatSize& size, WritingMode writingMode)
87 { 87 {
88 if (isHorizontalWritingMode(writingMode)) 88 if (isHorizontalWritingMode(writingMode))
89 return size; 89 return size;
90 return size.transposedSize(); 90 return size.transposedSize();
91 } 91 }
92 92
93 PassOwnPtr<ExclusionShape> ExclusionShape::createExclusionShape(const BasicShape * basicShape, float logicalBoxWidth, float logicalBoxHeight, WritingMode writing Mode, Length margin, Length padding) 93 PassOwnPtr<ExclusionShape> ExclusionShape::createExclusionShape(const BasicShape * basicShape, const LayoutSize& logicalBoxSize, WritingMode writingMode, Length margin, Length padding)
94 { 94 {
95 ASSERT(basicShape); 95 ASSERT(basicShape);
96 96
97 bool horizontalWritingMode = isHorizontalWritingMode(writingMode); 97 bool horizontalWritingMode = isHorizontalWritingMode(writingMode);
98 float boxWidth = horizontalWritingMode ? logicalBoxWidth : logicalBoxHeight; 98 float boxWidth = horizontalWritingMode ? logicalBoxSize.width() : logicalBox Size.height();
99 float boxHeight = horizontalWritingMode ? logicalBoxHeight : logicalBoxWidth ; 99 float boxHeight = horizontalWritingMode ? logicalBoxSize.height() : logicalB oxSize.width();
100 OwnPtr<ExclusionShape> exclusionShape; 100 OwnPtr<ExclusionShape> exclusionShape;
101 101
102 switch (basicShape->type()) { 102 switch (basicShape->type()) {
103 103
104 case BasicShape::BASIC_SHAPE_RECTANGLE: { 104 case BasicShape::BASIC_SHAPE_RECTANGLE: {
105 const BasicShapeRectangle* rectangle = static_cast<const BasicShapeRecta ngle*>(basicShape); 105 const BasicShapeRectangle* rectangle = static_cast<const BasicShapeRecta ngle*>(basicShape);
106 FloatRect bounds( 106 FloatRect bounds(
107 floatValueForLength(rectangle->x(), boxWidth), 107 floatValueForLength(rectangle->x(), boxWidth),
108 floatValueForLength(rectangle->y(), boxHeight), 108 floatValueForLength(rectangle->y(), boxHeight),
109 floatValueForLength(rectangle->width(), boxWidth), 109 floatValueForLength(rectangle->width(), boxWidth),
110 floatValueForLength(rectangle->height(), boxHeight)); 110 floatValueForLength(rectangle->height(), boxHeight));
111 Length radiusXLength = rectangle->cornerRadiusX(); 111 Length radiusXLength = rectangle->cornerRadiusX();
112 Length radiusYLength = rectangle->cornerRadiusY(); 112 Length radiusYLength = rectangle->cornerRadiusY();
113 FloatSize cornerRadii( 113 FloatSize cornerRadii(
114 radiusXLength.isUndefined() ? 0 : floatValueForLength(radiusXLength, boxWidth), 114 radiusXLength.isUndefined() ? 0 : floatValueForLength(radiusXLength, boxWidth),
115 radiusYLength.isUndefined() ? 0 : floatValueForLength(radiusYLength, boxHeight)); 115 radiusYLength.isUndefined() ? 0 : floatValueForLength(radiusYLength, boxHeight));
116 FloatRect logicalBounds = physicalRectToLogical(bounds, logicalBoxHeight , writingMode); 116 FloatRect logicalBounds = physicalRectToLogical(bounds, logicalBoxSize.h eight(), writingMode);
117 117
118 exclusionShape = createExclusionRectangle(logicalBounds, physicalSizeToL ogical(cornerRadii, writingMode)); 118 exclusionShape = createExclusionRectangle(logicalBounds, physicalSizeToL ogical(cornerRadii, writingMode));
119 break; 119 break;
120 } 120 }
121 121
122 case BasicShape::BASIC_SHAPE_CIRCLE: { 122 case BasicShape::BASIC_SHAPE_CIRCLE: {
123 const BasicShapeCircle* circle = static_cast<const BasicShapeCircle*>(ba sicShape); 123 const BasicShapeCircle* circle = static_cast<const BasicShapeCircle*>(ba sicShape);
124 float centerX = floatValueForLength(circle->centerX(), boxWidth); 124 float centerX = floatValueForLength(circle->centerX(), boxWidth);
125 float centerY = floatValueForLength(circle->centerY(), boxHeight); 125 float centerY = floatValueForLength(circle->centerY(), boxHeight);
126 float radius = floatValueForLength(circle->radius(), std::min(boxHeight, boxWidth)); 126 float radius = floatValueForLength(circle->radius(), std::min(boxHeight, boxWidth));
127 FloatPoint logicalCenter = physicalPointToLogical(FloatPoint(centerX, ce nterY), logicalBoxHeight, writingMode); 127 FloatPoint logicalCenter = physicalPointToLogical(FloatPoint(centerX, ce nterY), logicalBoxSize.height(), writingMode);
128 128
129 exclusionShape = createExclusionCircle(logicalCenter, radius); 129 exclusionShape = createExclusionCircle(logicalCenter, radius);
130 break; 130 break;
131 } 131 }
132 132
133 case BasicShape::BASIC_SHAPE_ELLIPSE: { 133 case BasicShape::BASIC_SHAPE_ELLIPSE: {
134 const BasicShapeEllipse* ellipse = static_cast<const BasicShapeEllipse*> (basicShape); 134 const BasicShapeEllipse* ellipse = static_cast<const BasicShapeEllipse*> (basicShape);
135 float centerX = floatValueForLength(ellipse->centerX(), boxWidth); 135 float centerX = floatValueForLength(ellipse->centerX(), boxWidth);
136 float centerY = floatValueForLength(ellipse->centerY(), boxHeight); 136 float centerY = floatValueForLength(ellipse->centerY(), boxHeight);
137 float radiusX = floatValueForLength(ellipse->radiusX(), boxWidth); 137 float radiusX = floatValueForLength(ellipse->radiusX(), boxWidth);
138 float radiusY = floatValueForLength(ellipse->radiusY(), boxHeight); 138 float radiusY = floatValueForLength(ellipse->radiusY(), boxHeight);
139 FloatPoint logicalCenter = physicalPointToLogical(FloatPoint(centerX, ce nterY), logicalBoxHeight, writingMode); 139 FloatPoint logicalCenter = physicalPointToLogical(FloatPoint(centerX, ce nterY), logicalBoxSize.height(), writingMode);
140 FloatSize logicalRadii = physicalSizeToLogical(FloatSize(radiusX, radius Y), writingMode); 140 FloatSize logicalRadii = physicalSizeToLogical(FloatSize(radiusX, radius Y), writingMode);
141 141
142 exclusionShape = createExclusionEllipse(logicalCenter, logicalRadii); 142 exclusionShape = createExclusionEllipse(logicalCenter, logicalRadii);
143 break; 143 break;
144 } 144 }
145 145
146 case BasicShape::BASIC_SHAPE_POLYGON: { 146 case BasicShape::BASIC_SHAPE_POLYGON: {
147 const BasicShapePolygon* polygon = static_cast<const BasicShapePolygon*> (basicShape); 147 const BasicShapePolygon* polygon = static_cast<const BasicShapePolygon*> (basicShape);
148 const Vector<Length>& values = polygon->values(); 148 const Vector<Length>& values = polygon->values();
149 size_t valuesSize = values.size(); 149 size_t valuesSize = values.size();
150 ASSERT(!(valuesSize % 2)); 150 ASSERT(!(valuesSize % 2));
151 OwnPtr<Vector<FloatPoint> > vertices = adoptPtr(new Vector<FloatPoint>(v aluesSize / 2)); 151 OwnPtr<Vector<FloatPoint> > vertices = adoptPtr(new Vector<FloatPoint>(v aluesSize / 2));
152 for (unsigned i = 0; i < valuesSize; i += 2) { 152 for (unsigned i = 0; i < valuesSize; i += 2) {
153 FloatPoint vertex( 153 FloatPoint vertex(
154 floatValueForLength(values.at(i), boxWidth), 154 floatValueForLength(values.at(i), boxWidth),
155 floatValueForLength(values.at(i + 1), boxHeight)); 155 floatValueForLength(values.at(i + 1), boxHeight));
156 (*vertices)[i / 2] = physicalPointToLogical(vertex, logicalBoxHeight , writingMode); 156 (*vertices)[i / 2] = physicalPointToLogical(vertex, logicalBoxSize.h eight(), writingMode);
157 } 157 }
158 exclusionShape = createExclusionPolygon(vertices.release(), polygon->win dRule()); 158 exclusionShape = createExclusionPolygon(vertices.release(), polygon->win dRule());
159 break; 159 break;
160 } 160 }
161 161
162 default: 162 default:
163 ASSERT_NOT_REACHED(); 163 ASSERT_NOT_REACHED();
164 } 164 }
165 165
166 exclusionShape->m_logicalBoxWidth = logicalBoxWidth;
167 exclusionShape->m_logicalBoxHeight = logicalBoxHeight;
168 exclusionShape->m_writingMode = writingMode; 166 exclusionShape->m_writingMode = writingMode;
169 exclusionShape->m_margin = floatValueForLength(margin, 0); 167 exclusionShape->m_margin = floatValueForLength(margin, 0);
170 exclusionShape->m_padding = floatValueForLength(padding, 0); 168 exclusionShape->m_padding = floatValueForLength(padding, 0);
171 169
172 return exclusionShape.release(); 170 return exclusionShape.release();
173 } 171 }
174 172
175 } // namespace WebCore 173 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/exclusions/ExclusionShape.h ('k') | Source/core/rendering/exclusions/ExclusionShapeInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698