OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/paint/BoxBorderPainter.h" | 5 #include "core/paint/BoxBorderPainter.h" |
6 | 6 |
7 #include "core/paint/BoxPainter.h" | 7 #include "core/paint/BoxPainter.h" |
8 #include "core/paint/PaintInfo.h" | 8 #include "core/paint/PaintInfo.h" |
9 #include "core/style/BorderEdge.h" | 9 #include "core/style/BorderEdge.h" |
10 #include "platform/RuntimeEnabledFeatures.h" | 10 #include "platform/RuntimeEnabledFeatures.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 } | 160 } |
161 | 161 |
162 return sideRect; | 162 return sideRect; |
163 } | 163 } |
164 | 164 |
165 FloatRoundedRect calculateAdjustedInnerBorder(const FloatRoundedRect& innerBorde
r, BoxSide side) | 165 FloatRoundedRect calculateAdjustedInnerBorder(const FloatRoundedRect& innerBorde
r, BoxSide side) |
166 { | 166 { |
167 // Expand the inner border as necessary to make it a rounded rect (i.e. radi
i contained within each edge). | 167 // Expand the inner border as necessary to make it a rounded rect (i.e. radi
i contained within each edge). |
168 // This function relies on the fact we only get radii not contained within e
ach edge if one of the radii | 168 // This function relies on the fact we only get radii not contained within e
ach edge if one of the radii |
169 // for an edge is zero, so we can shift the arc towards the zero radius corn
er. | 169 // for an edge is zero, so we can shift the arc towards the zero radius corn
er. |
170 FloatRoundedRect::Radii newRadii = innerBorder.radii(); | 170 FloatRoundedRect::Radii newRadii = innerBorder.getRadii(); |
171 FloatRect newRect = innerBorder.rect(); | 171 FloatRect newRect = innerBorder.rect(); |
172 | 172 |
173 float overshoot; | 173 float overshoot; |
174 float maxRadii; | 174 float maxRadii; |
175 | 175 |
176 switch (side) { | 176 switch (side) { |
177 case BSTop: | 177 case BSTop: |
178 overshoot = newRadii.topLeft().width() + newRadii.topRight().width() - n
ewRect.width(); | 178 overshoot = newRadii.topLeft().width() + newRadii.topRight().width() - n
ewRect.width(); |
179 // FIXME: once we start pixel-snapping rounded rects after this point, t
he overshoot concept | 179 // FIXME: once we start pixel-snapping rounded rects after this point, t
he overshoot concept |
180 // should disappear. | 180 // should disappear. |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 ASSERT(edge.shouldRender()); | 722 ASSERT(edge.shouldRender()); |
723 const Color color(edge.color.red(), edge.color.green(), edge.color.blue(), a
lpha); | 723 const Color color(edge.color.red(), edge.color.green(), edge.color.blue(), a
lpha); |
724 | 724 |
725 FloatRect sideRect = m_outer.rect(); | 725 FloatRect sideRect = m_outer.rect(); |
726 const Path* path = nullptr; | 726 const Path* path = nullptr; |
727 | 727 |
728 // TODO(fmalita): find a way to consolidate these without sacrificing readab
ility. | 728 // TODO(fmalita): find a way to consolidate these without sacrificing readab
ility. |
729 switch (side) { | 729 switch (side) { |
730 case BSTop: { | 730 case BSTop: { |
731 bool usePath = m_isRounded && (borderStyleHasInnerDetail(edge.borderStyl
e()) | 731 bool usePath = m_isRounded && (borderStyleHasInnerDetail(edge.borderStyl
e()) |
732 || borderWillArcInnerEdge(m_inner.radii().topLeft(), m_inner.radii()
.topRight())); | 732 || borderWillArcInnerEdge(m_inner.getRadii().topLeft(), m_inner.getR
adii().topRight())); |
733 if (usePath) | 733 if (usePath) |
734 path = &borderInfo.roundedBorderPath; | 734 path = &borderInfo.roundedBorderPath; |
735 else | 735 else |
736 sideRect.setHeight(edge.width); | 736 sideRect.setHeight(edge.width); |
737 | 737 |
738 paintOneBorderSide(context, sideRect, BSTop, BSLeft, BSRight, path, bord
erInfo.antiAlias, | 738 paintOneBorderSide(context, sideRect, BSTop, BSLeft, BSRight, path, bord
erInfo.antiAlias, |
739 color, completedEdges); | 739 color, completedEdges); |
740 break; | 740 break; |
741 } | 741 } |
742 case BSBottom: { | 742 case BSBottom: { |
743 bool usePath = m_isRounded && (borderStyleHasInnerDetail(edge.borderStyl
e()) | 743 bool usePath = m_isRounded && (borderStyleHasInnerDetail(edge.borderStyl
e()) |
744 || borderWillArcInnerEdge(m_inner.radii().bottomLeft(), m_inner.radi
i().bottomRight())); | 744 || borderWillArcInnerEdge(m_inner.getRadii().bottomLeft(), m_inner.g
etRadii().bottomRight())); |
745 if (usePath) | 745 if (usePath) |
746 path = &borderInfo.roundedBorderPath; | 746 path = &borderInfo.roundedBorderPath; |
747 else | 747 else |
748 sideRect.shiftYEdgeTo(sideRect.maxY() - edge.width); | 748 sideRect.shiftYEdgeTo(sideRect.maxY() - edge.width); |
749 | 749 |
750 paintOneBorderSide(context, sideRect, BSBottom, BSLeft, BSRight, path, b
orderInfo.antiAlias, | 750 paintOneBorderSide(context, sideRect, BSBottom, BSLeft, BSRight, path, b
orderInfo.antiAlias, |
751 color, completedEdges); | 751 color, completedEdges); |
752 break; | 752 break; |
753 } | 753 } |
754 case BSLeft: { | 754 case BSLeft: { |
755 bool usePath = m_isRounded && (borderStyleHasInnerDetail(edge.borderStyl
e()) | 755 bool usePath = m_isRounded && (borderStyleHasInnerDetail(edge.borderStyl
e()) |
756 || borderWillArcInnerEdge(m_inner.radii().bottomLeft(), m_inner.radi
i().topLeft())); | 756 || borderWillArcInnerEdge(m_inner.getRadii().bottomLeft(), m_inner.g
etRadii().topLeft())); |
757 if (usePath) | 757 if (usePath) |
758 path = &borderInfo.roundedBorderPath; | 758 path = &borderInfo.roundedBorderPath; |
759 else | 759 else |
760 sideRect.setWidth(edge.width); | 760 sideRect.setWidth(edge.width); |
761 | 761 |
762 paintOneBorderSide(context, sideRect, BSLeft, BSTop, BSBottom, path, bor
derInfo.antiAlias, | 762 paintOneBorderSide(context, sideRect, BSLeft, BSTop, BSBottom, path, bor
derInfo.antiAlias, |
763 color, completedEdges); | 763 color, completedEdges); |
764 break; | 764 break; |
765 } | 765 } |
766 case BSRight: { | 766 case BSRight: { |
767 bool usePath = m_isRounded && (borderStyleHasInnerDetail(edge.borderStyl
e()) | 767 bool usePath = m_isRounded && (borderStyleHasInnerDetail(edge.borderStyl
e()) |
768 || borderWillArcInnerEdge(m_inner.radii().bottomRight(), m_inner.rad
ii().topRight())); | 768 || borderWillArcInnerEdge(m_inner.getRadii().bottomRight(), m_inner.
getRadii().topRight())); |
769 if (usePath) | 769 if (usePath) |
770 path = &borderInfo.roundedBorderPath; | 770 path = &borderInfo.roundedBorderPath; |
771 else | 771 else |
772 sideRect.shiftXEdgeTo(sideRect.maxX() - edge.width); | 772 sideRect.shiftXEdgeTo(sideRect.maxX() - edge.width); |
773 | 773 |
774 paintOneBorderSide(context, sideRect, BSRight, BSTop, BSBottom, path, bo
rderInfo.antiAlias, | 774 paintOneBorderSide(context, sideRect, BSRight, BSTop, BSBottom, path, bo
rderInfo.antiAlias, |
775 color, completedEdges); | 775 color, completedEdges); |
776 break; | 776 break; |
777 } | 777 } |
778 default: | 778 default: |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 // 3 / \ 3 | 1035 // 3 / \ 3 |
1036 // 0----------------3 | 1036 // 0----------------3 |
1037 // | 1037 // |
1038 switch (side) { | 1038 switch (side) { |
1039 case BSTop: | 1039 case BSTop: |
1040 quad[0] = FloatPoint(outerRect.minXMinYCorner()); | 1040 quad[0] = FloatPoint(outerRect.minXMinYCorner()); |
1041 quad[1] = FloatPoint(innerRect.minXMinYCorner()); | 1041 quad[1] = FloatPoint(innerRect.minXMinYCorner()); |
1042 quad[2] = FloatPoint(innerRect.maxXMinYCorner()); | 1042 quad[2] = FloatPoint(innerRect.maxXMinYCorner()); |
1043 quad[3] = FloatPoint(outerRect.maxXMinYCorner()); | 1043 quad[3] = FloatPoint(outerRect.maxXMinYCorner()); |
1044 | 1044 |
1045 if (!m_inner.radii().topLeft().isZero()) { | 1045 if (!m_inner.getRadii().topLeft().isZero()) { |
1046 findIntersection(quad[0], quad[1], | 1046 findIntersection(quad[0], quad[1], |
1047 FloatPoint( | 1047 FloatPoint( |
1048 quad[1].x() + m_inner.radii().topLeft().width(), | 1048 quad[1].x() + m_inner.getRadii().topLeft().width(), |
1049 quad[1].y()), | 1049 quad[1].y()), |
1050 FloatPoint( | 1050 FloatPoint( |
1051 quad[1].x(), | 1051 quad[1].x(), |
1052 quad[1].y() + m_inner.radii().topLeft().height()), | 1052 quad[1].y() + m_inner.getRadii().topLeft().height()), |
1053 quad[1]); | 1053 quad[1]); |
1054 } | 1054 } |
1055 | 1055 |
1056 if (!m_inner.radii().topRight().isZero()) { | 1056 if (!m_inner.getRadii().topRight().isZero()) { |
1057 findIntersection(quad[3], quad[2], | 1057 findIntersection(quad[3], quad[2], |
1058 FloatPoint( | 1058 FloatPoint( |
1059 quad[2].x() - m_inner.radii().topRight().width(), | 1059 quad[2].x() - m_inner.getRadii().topRight().width(), |
1060 quad[2].y()), | 1060 quad[2].y()), |
1061 FloatPoint( | 1061 FloatPoint( |
1062 quad[2].x(), | 1062 quad[2].x(), |
1063 quad[2].y() + m_inner.radii().topRight().height()), | 1063 quad[2].y() + m_inner.getRadii().topRight().height()), |
1064 quad[2]); | 1064 quad[2]); |
1065 } | 1065 } |
1066 break; | 1066 break; |
1067 | 1067 |
1068 case BSLeft: | 1068 case BSLeft: |
1069 quad[0] = FloatPoint(outerRect.minXMinYCorner()); | 1069 quad[0] = FloatPoint(outerRect.minXMinYCorner()); |
1070 quad[1] = FloatPoint(innerRect.minXMinYCorner()); | 1070 quad[1] = FloatPoint(innerRect.minXMinYCorner()); |
1071 quad[2] = FloatPoint(innerRect.minXMaxYCorner()); | 1071 quad[2] = FloatPoint(innerRect.minXMaxYCorner()); |
1072 quad[3] = FloatPoint(outerRect.minXMaxYCorner()); | 1072 quad[3] = FloatPoint(outerRect.minXMaxYCorner()); |
1073 | 1073 |
1074 if (!m_inner.radii().topLeft().isZero()) { | 1074 if (!m_inner.getRadii().topLeft().isZero()) { |
1075 findIntersection(quad[0], quad[1], | 1075 findIntersection(quad[0], quad[1], |
1076 FloatPoint( | 1076 FloatPoint( |
1077 quad[1].x() + m_inner.radii().topLeft().width(), | 1077 quad[1].x() + m_inner.getRadii().topLeft().width(), |
1078 quad[1].y()), | 1078 quad[1].y()), |
1079 FloatPoint( | 1079 FloatPoint( |
1080 quad[1].x(), | 1080 quad[1].x(), |
1081 quad[1].y() + m_inner.radii().topLeft().height()), | 1081 quad[1].y() + m_inner.getRadii().topLeft().height()), |
1082 quad[1]); | 1082 quad[1]); |
1083 } | 1083 } |
1084 | 1084 |
1085 if (!m_inner.radii().bottomLeft().isZero()) { | 1085 if (!m_inner.getRadii().bottomLeft().isZero()) { |
1086 findIntersection(quad[3], quad[2], | 1086 findIntersection(quad[3], quad[2], |
1087 FloatPoint( | 1087 FloatPoint( |
1088 quad[2].x() + m_inner.radii().bottomLeft().width(), | 1088 quad[2].x() + m_inner.getRadii().bottomLeft().width(), |
1089 quad[2].y()), | 1089 quad[2].y()), |
1090 FloatPoint( | 1090 FloatPoint( |
1091 quad[2].x(), | 1091 quad[2].x(), |
1092 quad[2].y() - m_inner.radii().bottomLeft().height()), | 1092 quad[2].y() - m_inner.getRadii().bottomLeft().height()), |
1093 quad[2]); | 1093 quad[2]); |
1094 } | 1094 } |
1095 break; | 1095 break; |
1096 | 1096 |
1097 case BSBottom: | 1097 case BSBottom: |
1098 quad[0] = FloatPoint(outerRect.minXMaxYCorner()); | 1098 quad[0] = FloatPoint(outerRect.minXMaxYCorner()); |
1099 quad[1] = FloatPoint(innerRect.minXMaxYCorner()); | 1099 quad[1] = FloatPoint(innerRect.minXMaxYCorner()); |
1100 quad[2] = FloatPoint(innerRect.maxXMaxYCorner()); | 1100 quad[2] = FloatPoint(innerRect.maxXMaxYCorner()); |
1101 quad[3] = FloatPoint(outerRect.maxXMaxYCorner()); | 1101 quad[3] = FloatPoint(outerRect.maxXMaxYCorner()); |
1102 | 1102 |
1103 if (!m_inner.radii().bottomLeft().isZero()) { | 1103 if (!m_inner.getRadii().bottomLeft().isZero()) { |
1104 findIntersection(quad[0], quad[1], | 1104 findIntersection(quad[0], quad[1], |
1105 FloatPoint( | 1105 FloatPoint( |
1106 quad[1].x() + m_inner.radii().bottomLeft().width(), | 1106 quad[1].x() + m_inner.getRadii().bottomLeft().width(), |
1107 quad[1].y()), | 1107 quad[1].y()), |
1108 FloatPoint( | 1108 FloatPoint( |
1109 quad[1].x(), | 1109 quad[1].x(), |
1110 quad[1].y() - m_inner.radii().bottomLeft().height()), | 1110 quad[1].y() - m_inner.getRadii().bottomLeft().height()), |
1111 quad[1]); | 1111 quad[1]); |
1112 } | 1112 } |
1113 | 1113 |
1114 if (!m_inner.radii().bottomRight().isZero()) { | 1114 if (!m_inner.getRadii().bottomRight().isZero()) { |
1115 findIntersection(quad[3], quad[2], | 1115 findIntersection(quad[3], quad[2], |
1116 FloatPoint( | 1116 FloatPoint( |
1117 quad[2].x() - m_inner.radii().bottomRight().width(), | 1117 quad[2].x() - m_inner.getRadii().bottomRight().width(), |
1118 quad[2].y()), | 1118 quad[2].y()), |
1119 FloatPoint( | 1119 FloatPoint( |
1120 quad[2].x(), | 1120 quad[2].x(), |
1121 quad[2].y() - m_inner.radii().bottomRight().height()), | 1121 quad[2].y() - m_inner.getRadii().bottomRight().height()), |
1122 quad[2]); | 1122 quad[2]); |
1123 } | 1123 } |
1124 break; | 1124 break; |
1125 | 1125 |
1126 case BSRight: | 1126 case BSRight: |
1127 quad[0] = FloatPoint(outerRect.maxXMinYCorner()); | 1127 quad[0] = FloatPoint(outerRect.maxXMinYCorner()); |
1128 quad[1] = FloatPoint(innerRect.maxXMinYCorner()); | 1128 quad[1] = FloatPoint(innerRect.maxXMinYCorner()); |
1129 quad[2] = FloatPoint(innerRect.maxXMaxYCorner()); | 1129 quad[2] = FloatPoint(innerRect.maxXMaxYCorner()); |
1130 quad[3] = FloatPoint(outerRect.maxXMaxYCorner()); | 1130 quad[3] = FloatPoint(outerRect.maxXMaxYCorner()); |
1131 | 1131 |
1132 if (!m_inner.radii().topRight().isZero()) { | 1132 if (!m_inner.getRadii().topRight().isZero()) { |
1133 findIntersection(quad[0], quad[1], | 1133 findIntersection(quad[0], quad[1], |
1134 FloatPoint( | 1134 FloatPoint( |
1135 quad[1].x() - m_inner.radii().topRight().width(), | 1135 quad[1].x() - m_inner.getRadii().topRight().width(), |
1136 quad[1].y()), | 1136 quad[1].y()), |
1137 FloatPoint( | 1137 FloatPoint( |
1138 quad[1].x(), | 1138 quad[1].x(), |
1139 quad[1].y() + m_inner.radii().topRight().height()), | 1139 quad[1].y() + m_inner.getRadii().topRight().height()), |
1140 quad[1]); | 1140 quad[1]); |
1141 } | 1141 } |
1142 | 1142 |
1143 if (!m_inner.radii().bottomRight().isZero()) { | 1143 if (!m_inner.getRadii().bottomRight().isZero()) { |
1144 findIntersection(quad[3], quad[2], | 1144 findIntersection(quad[3], quad[2], |
1145 FloatPoint( | 1145 FloatPoint( |
1146 quad[2].x() - m_inner.radii().bottomRight().width(), | 1146 quad[2].x() - m_inner.getRadii().bottomRight().width(), |
1147 quad[2].y()), | 1147 quad[2].y()), |
1148 FloatPoint( | 1148 FloatPoint( |
1149 quad[2].x(), | 1149 quad[2].x(), |
1150 quad[2].y() - m_inner.radii().bottomRight().height()), | 1150 quad[2].y() - m_inner.getRadii().bottomRight().height()), |
1151 quad[2]); | 1151 quad[2]); |
1152 } | 1152 } |
1153 break; | 1153 break; |
1154 } | 1154 } |
1155 | 1155 |
1156 if (firstMiter == secondMiter) { | 1156 if (firstMiter == secondMiter) { |
1157 graphicsContext.clipPolygon(4, quad, firstMiter == SoftMiter); | 1157 graphicsContext.clipPolygon(4, quad, firstMiter == SoftMiter); |
1158 return; | 1158 return; |
1159 } | 1159 } |
1160 | 1160 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 FloatPoint secondQuad[4]; | 1194 FloatPoint secondQuad[4]; |
1195 secondQuad[0] = quad[0]; | 1195 secondQuad[0] = quad[0]; |
1196 secondQuad[1] = FloatPoint(quad[0].x() - r1 * cx, quad[0].y() - r1 * cy)
; | 1196 secondQuad[1] = FloatPoint(quad[0].x() - r1 * cx, quad[0].y() - r1 * cy)
; |
1197 secondQuad[2] = quad[2]; | 1197 secondQuad[2] = quad[2]; |
1198 secondQuad[3] = quad[3]; | 1198 secondQuad[3] = quad[3]; |
1199 graphicsContext.clipPolygon(4, secondQuad, secondMiter == SoftMiter); | 1199 graphicsContext.clipPolygon(4, secondQuad, secondMiter == SoftMiter); |
1200 } | 1200 } |
1201 } | 1201 } |
1202 | 1202 |
1203 } // namespace blink | 1203 } // namespace blink |
OLD | NEW |