Chromium Code Reviews| 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 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 992 clipInternal(m_path, windingRuleString); | 992 clipInternal(m_path, windingRuleString); |
| 993 } | 993 } |
| 994 | 994 |
| 995 void CanvasRenderingContext2D::clip(DOMPath* domPath, const String& windingRuleS tring) | 995 void CanvasRenderingContext2D::clip(DOMPath* domPath, const String& windingRuleS tring) |
| 996 { | 996 { |
| 997 clipInternal(domPath->path(), windingRuleString); | 997 clipInternal(domPath->path(), windingRuleString); |
| 998 } | 998 } |
| 999 | 999 |
| 1000 bool CanvasRenderingContext2D::isPointInPath(const float x, const float y, const String& windingRuleString) | 1000 bool CanvasRenderingContext2D::isPointInPath(const float x, const float y, const String& windingRuleString) |
| 1001 { | 1001 { |
| 1002 return isPointInPathInternal(m_path, x, y, windingRuleString); | |
| 1003 } | |
| 1004 | |
| 1005 bool CanvasRenderingContext2D::isPointInPath(DOMPath* domPath, const float x, co nst float y, const String& windingRuleString) | |
| 1006 { | |
| 1007 return isPointInPathInternal(domPath->path(), x, y, windingRuleString); | |
|
Rik
2014/02/25 07:46:45
should you check if the pointer is valid?
| |
| 1008 } | |
| 1009 | |
| 1010 bool CanvasRenderingContext2D::isPointInPathInternal(const Path& path, const flo at x, const float y, const String& windingRuleString) | |
| 1011 { | |
| 1002 GraphicsContext* c = drawingContext(); | 1012 GraphicsContext* c = drawingContext(); |
| 1003 if (!c) | 1013 if (!c) |
| 1004 return false; | 1014 return false; |
| 1005 if (!state().m_invertibleCTM) | 1015 if (!state().m_invertibleCTM) |
| 1006 return false; | 1016 return false; |
| 1007 | 1017 |
| 1008 FloatPoint point(x, y); | 1018 FloatPoint point(x, y); |
| 1009 AffineTransform ctm = state().m_transform; | 1019 AffineTransform ctm = state().m_transform; |
| 1010 FloatPoint transformedPoint = ctm.inverse().mapPoint(point); | 1020 FloatPoint transformedPoint = ctm.inverse().mapPoint(point); |
| 1011 if (!std::isfinite(transformedPoint.x()) || !std::isfinite(transformedPoint. y())) | 1021 if (!std::isfinite(transformedPoint.x()) || !std::isfinite(transformedPoint. y())) |
| 1012 return false; | 1022 return false; |
| 1013 | 1023 |
| 1014 WindRule windRule = RULE_NONZERO; | 1024 WindRule windRule = RULE_NONZERO; |
| 1015 if (!parseWinding(windingRuleString, windRule)) | 1025 if (!parseWinding(windingRuleString, windRule)) |
| 1016 return false; | 1026 return false; |
| 1017 | 1027 |
| 1018 return m_path.contains(transformedPoint, windRule); | 1028 return path.contains(transformedPoint, windRule); |
| 1019 } | 1029 } |
| 1020 | 1030 |
| 1031 bool CanvasRenderingContext2D::isPointInStroke(const float x, const float y) | |
| 1032 { | |
| 1033 return isPointInStrokeInternal(m_path, x, y); | |
| 1034 } | |
| 1021 | 1035 |
| 1022 bool CanvasRenderingContext2D::isPointInStroke(const float x, const float y) | 1036 bool CanvasRenderingContext2D::isPointInStroke(DOMPath* domPath, const float x, const float y) |
| 1037 { | |
| 1038 return isPointInStrokeInternal(domPath->path(), x, y); | |
| 1039 } | |
| 1040 | |
| 1041 bool CanvasRenderingContext2D::isPointInStrokeInternal(const Path& path, const f loat x, const float y) | |
| 1023 { | 1042 { |
| 1024 GraphicsContext* c = drawingContext(); | 1043 GraphicsContext* c = drawingContext(); |
| 1025 if (!c) | 1044 if (!c) |
| 1026 return false; | 1045 return false; |
| 1027 if (!state().m_invertibleCTM) | 1046 if (!state().m_invertibleCTM) |
| 1028 return false; | 1047 return false; |
| 1029 | 1048 |
| 1030 FloatPoint point(x, y); | 1049 FloatPoint point(x, y); |
| 1031 AffineTransform ctm = state().m_transform; | 1050 AffineTransform ctm = state().m_transform; |
| 1032 FloatPoint transformedPoint = ctm.inverse().mapPoint(point); | 1051 FloatPoint transformedPoint = ctm.inverse().mapPoint(point); |
| 1033 if (!std::isfinite(transformedPoint.x()) || !std::isfinite(transformedPoint. y())) | 1052 if (!std::isfinite(transformedPoint.x()) || !std::isfinite(transformedPoint. y())) |
| 1034 return false; | 1053 return false; |
| 1035 | 1054 |
| 1036 StrokeData strokeData; | 1055 StrokeData strokeData; |
| 1037 strokeData.setThickness(lineWidth()); | 1056 strokeData.setThickness(lineWidth()); |
| 1038 strokeData.setLineCap(getLineCap()); | 1057 strokeData.setLineCap(getLineCap()); |
| 1039 strokeData.setLineJoin(getLineJoin()); | 1058 strokeData.setLineJoin(getLineJoin()); |
| 1040 strokeData.setMiterLimit(miterLimit()); | 1059 strokeData.setMiterLimit(miterLimit()); |
| 1041 strokeData.setLineDash(getLineDash(), lineDashOffset()); | 1060 strokeData.setLineDash(getLineDash(), lineDashOffset()); |
| 1042 return m_path.strokeContains(transformedPoint, strokeData); | 1061 return path.strokeContains(transformedPoint, strokeData); |
| 1043 } | 1062 } |
| 1044 | 1063 |
| 1045 void CanvasRenderingContext2D::clearRect(float x, float y, float width, float he ight) | 1064 void CanvasRenderingContext2D::clearRect(float x, float y, float width, float he ight) |
| 1046 { | 1065 { |
| 1047 if (!validateRectForCanvas(x, y, width, height)) | 1066 if (!validateRectForCanvas(x, y, width, height)) |
| 1048 return; | 1067 return; |
| 1049 GraphicsContext* context = drawingContext(); | 1068 GraphicsContext* context = drawingContext(); |
| 1050 if (!context) | 1069 if (!context) |
| 1051 return; | 1070 return; |
| 1052 if (!state().m_invertibleCTM) | 1071 if (!state().m_invertibleCTM) |
| (...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2437 const int focusRingWidth = 5; | 2456 const int focusRingWidth = 5; |
| 2438 const int focusRingOutline = 0; | 2457 const int focusRingOutline = 0; |
| 2439 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); | 2458 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); |
| 2440 | 2459 |
| 2441 c->restore(); | 2460 c->restore(); |
| 2442 | 2461 |
| 2443 didDraw(dirtyRect); | 2462 didDraw(dirtyRect); |
| 2444 } | 2463 } |
| 2445 | 2464 |
| 2446 } // namespace WebCore | 2465 } // namespace WebCore |
| OLD | NEW |