| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
| 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
| 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
| 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> |
| 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
| 8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. | 8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. |
| 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
| 10 * | 10 * |
| (...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1022 } | 1022 } |
| 1023 | 1023 |
| 1024 c->setFillRule(windRule); | 1024 c->setFillRule(windRule); |
| 1025 } | 1025 } |
| 1026 | 1026 |
| 1027 void CanvasRenderingContext2D::fill(const String& windingRuleString) | 1027 void CanvasRenderingContext2D::fill(const String& windingRuleString) |
| 1028 { | 1028 { |
| 1029 fillInternal(m_path, windingRuleString); | 1029 fillInternal(m_path, windingRuleString); |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 void CanvasRenderingContext2D::fill(Path2D* domPath, ExceptionState& exceptionSt
ate) | 1032 void CanvasRenderingContext2D::fill(Path2D* domPath) |
| 1033 { | 1033 { |
| 1034 fill(domPath, "nonzero", exceptionState); | 1034 fill(domPath, "nonzero"); |
| 1035 } | 1035 } |
| 1036 | 1036 |
| 1037 void CanvasRenderingContext2D::fill(Path2D* domPath, const String& windingRuleSt
ring, ExceptionState& exceptionState) | 1037 void CanvasRenderingContext2D::fill(Path2D* domPath, const String& windingRuleSt
ring) |
| 1038 { | 1038 { |
| 1039 if (!domPath) { | |
| 1040 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect
Type(1, "Path")); | |
| 1041 return; | |
| 1042 } | |
| 1043 | |
| 1044 fillInternal(domPath->path(), windingRuleString); | 1039 fillInternal(domPath->path(), windingRuleString); |
| 1045 } | 1040 } |
| 1046 | 1041 |
| 1047 void CanvasRenderingContext2D::strokeInternal(const Path& path) | 1042 void CanvasRenderingContext2D::strokeInternal(const Path& path) |
| 1048 { | 1043 { |
| 1049 if (path.isEmpty()) { | 1044 if (path.isEmpty()) { |
| 1050 return; | 1045 return; |
| 1051 } | 1046 } |
| 1052 GraphicsContext* c = drawingContext(); | 1047 GraphicsContext* c = drawingContext(); |
| 1053 if (!c) { | 1048 if (!c) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1070 c->strokePath(path); | 1065 c->strokePath(path); |
| 1071 didDraw(dirtyRect); | 1066 didDraw(dirtyRect); |
| 1072 } | 1067 } |
| 1073 } | 1068 } |
| 1074 | 1069 |
| 1075 void CanvasRenderingContext2D::stroke() | 1070 void CanvasRenderingContext2D::stroke() |
| 1076 { | 1071 { |
| 1077 strokeInternal(m_path); | 1072 strokeInternal(m_path); |
| 1078 } | 1073 } |
| 1079 | 1074 |
| 1080 void CanvasRenderingContext2D::stroke(Path2D* domPath, ExceptionState& exception
State) | 1075 void CanvasRenderingContext2D::stroke(Path2D* domPath) |
| 1081 { | 1076 { |
| 1082 if (!domPath) { | |
| 1083 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect
Type(1, "Path")); | |
| 1084 return; | |
| 1085 } | |
| 1086 | |
| 1087 strokeInternal(domPath->path()); | 1077 strokeInternal(domPath->path()); |
| 1088 } | 1078 } |
| 1089 | 1079 |
| 1090 void CanvasRenderingContext2D::clipInternal(const Path& path, const String& wind
ingRuleString) | 1080 void CanvasRenderingContext2D::clipInternal(const Path& path, const String& wind
ingRuleString) |
| 1091 { | 1081 { |
| 1092 GraphicsContext* c = drawingContext(); | 1082 GraphicsContext* c = drawingContext(); |
| 1093 if (!c) { | 1083 if (!c) { |
| 1094 return; | 1084 return; |
| 1095 } | 1085 } |
| 1096 if (!state().m_invertibleCTM) { | 1086 if (!state().m_invertibleCTM) { |
| 1097 return; | 1087 return; |
| 1098 } | 1088 } |
| 1099 | 1089 |
| 1100 WindRule newWindRule = RULE_NONZERO; | 1090 WindRule newWindRule = RULE_NONZERO; |
| 1101 if (!parseWinding(windingRuleString, newWindRule)) { | 1091 if (!parseWinding(windingRuleString, newWindRule)) { |
| 1102 return; | 1092 return; |
| 1103 } | 1093 } |
| 1104 | 1094 |
| 1105 realizeSaves(); | 1095 realizeSaves(); |
| 1106 c->canvasClip(path, newWindRule); | 1096 c->canvasClip(path, newWindRule); |
| 1107 } | 1097 } |
| 1108 | 1098 |
| 1109 void CanvasRenderingContext2D::clip(const String& windingRuleString) | 1099 void CanvasRenderingContext2D::clip(const String& windingRuleString) |
| 1110 { | 1100 { |
| 1111 clipInternal(m_path, windingRuleString); | 1101 clipInternal(m_path, windingRuleString); |
| 1112 } | 1102 } |
| 1113 | 1103 |
| 1114 void CanvasRenderingContext2D::clip(Path2D* domPath, ExceptionState& exceptionSt
ate) | 1104 void CanvasRenderingContext2D::clip(Path2D* domPath) |
| 1115 { | 1105 { |
| 1116 clip(domPath, "nonzero", exceptionState); | 1106 clip(domPath, "nonzero"); |
| 1117 } | 1107 } |
| 1118 | 1108 |
| 1119 void CanvasRenderingContext2D::clip(Path2D* domPath, const String& windingRuleSt
ring, ExceptionState& exceptionState) | 1109 void CanvasRenderingContext2D::clip(Path2D* domPath, const String& windingRuleSt
ring) |
| 1120 { | 1110 { |
| 1121 if (!domPath) { | |
| 1122 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect
Type(1, "Path")); | |
| 1123 return; | |
| 1124 } | |
| 1125 | |
| 1126 clipInternal(domPath->path(), windingRuleString); | 1111 clipInternal(domPath->path(), windingRuleString); |
| 1127 } | 1112 } |
| 1128 | 1113 |
| 1129 bool CanvasRenderingContext2D::isPointInPath(const float x, const float y, const
String& windingRuleString) | 1114 bool CanvasRenderingContext2D::isPointInPath(const float x, const float y, const
String& windingRuleString) |
| 1130 { | 1115 { |
| 1131 return isPointInPathInternal(m_path, x, y, windingRuleString); | 1116 return isPointInPathInternal(m_path, x, y, windingRuleString); |
| 1132 } | 1117 } |
| 1133 | 1118 |
| 1134 bool CanvasRenderingContext2D::isPointInPath(Path2D* domPath, const float x, con
st float y, ExceptionState& exceptionState) | 1119 bool CanvasRenderingContext2D::isPointInPath(Path2D* domPath, const float x, con
st float y) |
| 1135 { | 1120 { |
| 1136 return isPointInPath(domPath, x, y, "nonzero", exceptionState); | 1121 return isPointInPath(domPath, x, y, "nonzero"); |
| 1137 } | 1122 } |
| 1138 | 1123 |
| 1139 bool CanvasRenderingContext2D::isPointInPath(Path2D* domPath, const float x, con
st float y, const String& windingRuleString, ExceptionState& exceptionState) | 1124 bool CanvasRenderingContext2D::isPointInPath(Path2D* domPath, const float x, con
st float y, const String& windingRuleString) |
| 1140 { | 1125 { |
| 1141 if (!domPath) { | |
| 1142 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect
Type(1, "Path")); | |
| 1143 return false; | |
| 1144 } | |
| 1145 | |
| 1146 return isPointInPathInternal(domPath->path(), x, y, windingRuleString); | 1126 return isPointInPathInternal(domPath->path(), x, y, windingRuleString); |
| 1147 } | 1127 } |
| 1148 | 1128 |
| 1149 bool CanvasRenderingContext2D::isPointInPathInternal(const Path& path, const flo
at x, const float y, const String& windingRuleString) | 1129 bool CanvasRenderingContext2D::isPointInPathInternal(const Path& path, const flo
at x, const float y, const String& windingRuleString) |
| 1150 { | 1130 { |
| 1151 GraphicsContext* c = drawingContext(); | 1131 GraphicsContext* c = drawingContext(); |
| 1152 if (!c) | 1132 if (!c) |
| 1153 return false; | 1133 return false; |
| 1154 if (!state().m_invertibleCTM) | 1134 if (!state().m_invertibleCTM) |
| 1155 return false; | 1135 return false; |
| 1156 | 1136 |
| 1157 FloatPoint point(x, y); | 1137 FloatPoint point(x, y); |
| 1158 AffineTransform ctm = state().m_transform; | 1138 AffineTransform ctm = state().m_transform; |
| 1159 FloatPoint transformedPoint = ctm.inverse().mapPoint(point); | 1139 FloatPoint transformedPoint = ctm.inverse().mapPoint(point); |
| 1160 if (!std::isfinite(transformedPoint.x()) || !std::isfinite(transformedPoint.
y())) | 1140 if (!std::isfinite(transformedPoint.x()) || !std::isfinite(transformedPoint.
y())) |
| 1161 return false; | 1141 return false; |
| 1162 | 1142 |
| 1163 WindRule windRule = RULE_NONZERO; | 1143 WindRule windRule = RULE_NONZERO; |
| 1164 if (!parseWinding(windingRuleString, windRule)) | 1144 if (!parseWinding(windingRuleString, windRule)) |
| 1165 return false; | 1145 return false; |
| 1166 | 1146 |
| 1167 return path.contains(transformedPoint, windRule); | 1147 return path.contains(transformedPoint, windRule); |
| 1168 } | 1148 } |
| 1169 | 1149 |
| 1170 bool CanvasRenderingContext2D::isPointInStroke(const float x, const float y) | 1150 bool CanvasRenderingContext2D::isPointInStroke(const float x, const float y) |
| 1171 { | 1151 { |
| 1172 return isPointInStrokeInternal(m_path, x, y); | 1152 return isPointInStrokeInternal(m_path, x, y); |
| 1173 } | 1153 } |
| 1174 | 1154 |
| 1175 bool CanvasRenderingContext2D::isPointInStroke(Path2D* domPath, const float x, c
onst float y, ExceptionState& exceptionState) | 1155 bool CanvasRenderingContext2D::isPointInStroke(Path2D* domPath, const float x, c
onst float y) |
| 1176 { | 1156 { |
| 1177 if (!domPath) { | |
| 1178 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect
Type(1, "Path")); | |
| 1179 return false; | |
| 1180 } | |
| 1181 | |
| 1182 return isPointInStrokeInternal(domPath->path(), x, y); | 1157 return isPointInStrokeInternal(domPath->path(), x, y); |
| 1183 } | 1158 } |
| 1184 | 1159 |
| 1185 bool CanvasRenderingContext2D::isPointInStrokeInternal(const Path& path, const f
loat x, const float y) | 1160 bool CanvasRenderingContext2D::isPointInStrokeInternal(const Path& path, const f
loat x, const float y) |
| 1186 { | 1161 { |
| 1187 GraphicsContext* c = drawingContext(); | 1162 GraphicsContext* c = drawingContext(); |
| 1188 if (!c) | 1163 if (!c) |
| 1189 return false; | 1164 return false; |
| 1190 if (!state().m_invertibleCTM) | 1165 if (!state().m_invertibleCTM) |
| 1191 return false; | 1166 return false; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1203 strokeData.setMiterLimit(miterLimit()); | 1178 strokeData.setMiterLimit(miterLimit()); |
| 1204 strokeData.setLineDash(getLineDash(), lineDashOffset()); | 1179 strokeData.setLineDash(getLineDash(), lineDashOffset()); |
| 1205 return path.strokeContains(transformedPoint, strokeData); | 1180 return path.strokeContains(transformedPoint, strokeData); |
| 1206 } | 1181 } |
| 1207 | 1182 |
| 1208 void CanvasRenderingContext2D::scrollPathIntoView() | 1183 void CanvasRenderingContext2D::scrollPathIntoView() |
| 1209 { | 1184 { |
| 1210 scrollPathIntoViewInternal(m_path); | 1185 scrollPathIntoViewInternal(m_path); |
| 1211 } | 1186 } |
| 1212 | 1187 |
| 1213 void CanvasRenderingContext2D::scrollPathIntoView(Path2D* path2d, ExceptionState
& exceptionState) | 1188 void CanvasRenderingContext2D::scrollPathIntoView(Path2D* path2d) |
| 1214 { | 1189 { |
| 1215 if (!path2d) { | |
| 1216 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect
Type(1, "Path2D")); | |
| 1217 return; | |
| 1218 } | |
| 1219 | |
| 1220 scrollPathIntoViewInternal(path2d->path()); | 1190 scrollPathIntoViewInternal(path2d->path()); |
| 1221 } | 1191 } |
| 1222 | 1192 |
| 1223 void CanvasRenderingContext2D::scrollPathIntoViewInternal(const Path& path) | 1193 void CanvasRenderingContext2D::scrollPathIntoViewInternal(const Path& path) |
| 1224 { | 1194 { |
| 1225 if (!state().m_invertibleCTM || path.isEmpty()) | 1195 if (!state().m_invertibleCTM || path.isEmpty()) |
| 1226 return; | 1196 return; |
| 1227 | 1197 |
| 1228 canvas()->document().updateLayoutIgnorePendingStylesheets(); | 1198 canvas()->document().updateLayoutIgnorePendingStylesheets(); |
| 1229 | 1199 |
| (...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2434 c->setAlphaAsFloat(1.0); | 2404 c->setAlphaAsFloat(1.0); |
| 2435 c->clearShadow(); | 2405 c->clearShadow(); |
| 2436 c->setCompositeOperation(CompositeSourceOver, blink::WebBlendModeNormal); | 2406 c->setCompositeOperation(CompositeSourceOver, blink::WebBlendModeNormal); |
| 2437 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); | 2407 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); |
| 2438 c->restore(); | 2408 c->restore(); |
| 2439 | 2409 |
| 2440 didDraw(dirtyRect); | 2410 didDraw(dirtyRect); |
| 2441 } | 2411 } |
| 2442 | 2412 |
| 2443 } // namespace WebCore | 2413 } // namespace WebCore |
| OLD | NEW |