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

Side by Side Diff: Source/core/html/canvas/CanvasRenderingContext2D.cpp

Issue 178673002: Rename Path to Path2D (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@path
Patch Set: Merge to head which includes isPoint and addPath changes. Created 6 years, 9 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) 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 26 matching lines...) Expand all
37 #include "bindings/v8/ExceptionMessages.h" 37 #include "bindings/v8/ExceptionMessages.h"
38 #include "bindings/v8/ExceptionState.h" 38 #include "bindings/v8/ExceptionState.h"
39 #include "bindings/v8/ExceptionStatePlaceholder.h" 39 #include "bindings/v8/ExceptionStatePlaceholder.h"
40 #include "core/accessibility/AXObjectCache.h" 40 #include "core/accessibility/AXObjectCache.h"
41 #include "core/css/CSSFontSelector.h" 41 #include "core/css/CSSFontSelector.h"
42 #include "core/css/parser/BisonCSSParser.h" 42 #include "core/css/parser/BisonCSSParser.h"
43 #include "core/css/StylePropertySet.h" 43 #include "core/css/StylePropertySet.h"
44 #include "core/css/resolver/StyleResolver.h" 44 #include "core/css/resolver/StyleResolver.h"
45 #include "core/dom/ExceptionCode.h" 45 #include "core/dom/ExceptionCode.h"
46 #include "core/fetch/ImageResource.h" 46 #include "core/fetch/ImageResource.h"
47 #include "core/frame/ImageBitmap.h"
47 #include "core/html/HTMLCanvasElement.h" 48 #include "core/html/HTMLCanvasElement.h"
48 #include "core/html/HTMLImageElement.h" 49 #include "core/html/HTMLImageElement.h"
49 #include "core/html/HTMLMediaElement.h" 50 #include "core/html/HTMLMediaElement.h"
50 #include "core/html/HTMLVideoElement.h" 51 #include "core/html/HTMLVideoElement.h"
51 #include "core/html/ImageData.h" 52 #include "core/html/ImageData.h"
52 #include "core/html/TextMetrics.h" 53 #include "core/html/TextMetrics.h"
53 #include "core/html/canvas/CanvasGradient.h" 54 #include "core/html/canvas/CanvasGradient.h"
54 #include "core/html/canvas/CanvasPattern.h" 55 #include "core/html/canvas/CanvasPattern.h"
55 #include "core/html/canvas/CanvasStyle.h" 56 #include "core/html/canvas/CanvasStyle.h"
56 #include "core/html/canvas/DOMPath.h" 57 #include "core/html/canvas/Path2D.h"
57 #include "core/frame/ImageBitmap.h"
58 #include "core/rendering/RenderImage.h" 58 #include "core/rendering/RenderImage.h"
59 #include "core/rendering/RenderLayer.h" 59 #include "core/rendering/RenderLayer.h"
60 #include "core/rendering/RenderTheme.h" 60 #include "core/rendering/RenderTheme.h"
61 #include "platform/fonts/FontCache.h" 61 #include "platform/fonts/FontCache.h"
62 #include "platform/geometry/FloatQuad.h" 62 #include "platform/geometry/FloatQuad.h"
63 #include "platform/graphics/GraphicsContextStateSaver.h" 63 #include "platform/graphics/GraphicsContextStateSaver.h"
64 #include "platform/graphics/DrawLooper.h" 64 #include "platform/graphics/DrawLooper.h"
65 #include "platform/text/TextRun.h" 65 #include "platform/text/TextRun.h"
66 #include "platform/weborigin/SecurityOrigin.h" 66 #include "platform/weborigin/SecurityOrigin.h"
67 #include "wtf/CheckedArithmetic.h" 67 #include "wtf/CheckedArithmetic.h"
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 if (state().m_fillStyle && state().m_fillStyle->isEquivalentCMYKA(c, m, y, k , a)) 819 if (state().m_fillStyle && state().m_fillStyle->isEquivalentCMYKA(c, m, y, k , a))
820 return; 820 return;
821 setFillStyle(CanvasStyle::createFromCMYKAChannels(c, m, y, k, a)); 821 setFillStyle(CanvasStyle::createFromCMYKAChannels(c, m, y, k, a));
822 } 822 }
823 823
824 void CanvasRenderingContext2D::beginPath() 824 void CanvasRenderingContext2D::beginPath()
825 { 825 {
826 m_path.clear(); 826 m_path.clear();
827 } 827 }
828 828
829 PassRefPtr<DOMPath> CanvasRenderingContext2D::currentPath() 829 PassRefPtr<Path2D> CanvasRenderingContext2D::currentPath()
830 { 830 {
831 return DOMPath::create(m_path); 831 return Path2D::create(m_path);
832 } 832 }
833 833
834 void CanvasRenderingContext2D::setCurrentPath(DOMPath* path) 834 void CanvasRenderingContext2D::setCurrentPath(Path2D* path)
835 { 835 {
836 if (!path) 836 if (!path)
837 return; 837 return;
838 m_path = path->path(); 838 m_path = path->path();
839 } 839 }
840 840
841 static bool validateRectForCanvas(float& x, float& y, float& width, float& heigh t) 841 static bool validateRectForCanvas(float& x, float& y, float& width, float& heigh t)
842 { 842 {
843 if (!std::isfinite(x) | !std::isfinite(y) | !std::isfinite(width) | !std::is finite(height)) 843 if (!std::isfinite(x) | !std::isfinite(y) | !std::isfinite(width) | !std::is finite(height))
844 return false; 844 return false;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 } 925 }
926 926
927 c->setFillRule(windRule); 927 c->setFillRule(windRule);
928 } 928 }
929 929
930 void CanvasRenderingContext2D::fill(const String& windingRuleString) 930 void CanvasRenderingContext2D::fill(const String& windingRuleString)
931 { 931 {
932 fillInternal(m_path, windingRuleString); 932 fillInternal(m_path, windingRuleString);
933 } 933 }
934 934
935 void CanvasRenderingContext2D::fill(DOMPath* domPath, ExceptionState& exceptionS tate) 935 void CanvasRenderingContext2D::fill(Path2D* domPath, ExceptionState& exceptionSt ate)
936 { 936 {
937 fill(domPath, "nonzero", exceptionState); 937 fill(domPath, "nonzero", exceptionState);
938 } 938 }
939 939
940 void CanvasRenderingContext2D::fill(DOMPath* domPath, const String& windingRuleS tring, ExceptionState& exceptionState) 940 void CanvasRenderingContext2D::fill(Path2D* domPath, const String& windingRuleSt ring, ExceptionState& exceptionState)
941 { 941 {
942 if (!domPath) { 942 if (!domPath) {
943 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Path")); 943 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Path"));
944 return; 944 return;
945 } 945 }
946 946
947 fillInternal(domPath->path(), windingRuleString); 947 fillInternal(domPath->path(), windingRuleString);
948 } 948 }
949 949
950 void CanvasRenderingContext2D::strokeInternal(const Path& path) 950 void CanvasRenderingContext2D::strokeInternal(const Path& path)
(...skipping 22 matching lines...) Expand all
973 c->strokePath(path); 973 c->strokePath(path);
974 didDraw(dirtyRect); 974 didDraw(dirtyRect);
975 } 975 }
976 } 976 }
977 977
978 void CanvasRenderingContext2D::stroke() 978 void CanvasRenderingContext2D::stroke()
979 { 979 {
980 strokeInternal(m_path); 980 strokeInternal(m_path);
981 } 981 }
982 982
983 void CanvasRenderingContext2D::stroke(DOMPath* domPath, ExceptionState& exceptio nState) 983 void CanvasRenderingContext2D::stroke(Path2D* domPath, ExceptionState& exception State)
984 { 984 {
985 if (!domPath) { 985 if (!domPath) {
986 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Path")); 986 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Path"));
987 return; 987 return;
988 } 988 }
989 989
990 strokeInternal(domPath->path()); 990 strokeInternal(domPath->path());
991 } 991 }
992 992
993 void CanvasRenderingContext2D::clipInternal(const Path& path, const String& wind ingRuleString) 993 void CanvasRenderingContext2D::clipInternal(const Path& path, const String& wind ingRuleString)
(...skipping 13 matching lines...) Expand all
1007 1007
1008 realizeSaves(); 1008 realizeSaves();
1009 c->canvasClip(path, newWindRule); 1009 c->canvasClip(path, newWindRule);
1010 } 1010 }
1011 1011
1012 void CanvasRenderingContext2D::clip(const String& windingRuleString) 1012 void CanvasRenderingContext2D::clip(const String& windingRuleString)
1013 { 1013 {
1014 clipInternal(m_path, windingRuleString); 1014 clipInternal(m_path, windingRuleString);
1015 } 1015 }
1016 1016
1017 void CanvasRenderingContext2D::clip(DOMPath* domPath, ExceptionState& exceptionS tate) 1017 void CanvasRenderingContext2D::clip(Path2D* domPath, ExceptionState& exceptionSt ate)
1018 { 1018 {
1019 clip(domPath, "nonzero", exceptionState); 1019 clip(domPath, "nonzero", exceptionState);
1020 } 1020 }
1021 1021
1022 void CanvasRenderingContext2D::clip(DOMPath* domPath, const String& windingRuleS tring, ExceptionState& exceptionState) 1022 void CanvasRenderingContext2D::clip(Path2D* domPath, const String& windingRuleSt ring, ExceptionState& exceptionState)
1023 { 1023 {
1024 if (!domPath) { 1024 if (!domPath) {
1025 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Path")); 1025 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Path"));
1026 return; 1026 return;
1027 } 1027 }
1028 1028
1029 clipInternal(domPath->path(), windingRuleString); 1029 clipInternal(domPath->path(), windingRuleString);
1030 } 1030 }
1031 1031
1032 bool CanvasRenderingContext2D::isPointInPath(const float x, const float y, const String& windingRuleString) 1032 bool CanvasRenderingContext2D::isPointInPath(const float x, const float y, const String& windingRuleString)
1033 { 1033 {
1034 return isPointInPathInternal(m_path, x, y, windingRuleString); 1034 return isPointInPathInternal(m_path, x, y, windingRuleString);
1035 } 1035 }
1036 1036
1037 bool CanvasRenderingContext2D::isPointInPath(DOMPath* domPath, const float x, co nst float y, ExceptionState& exceptionState) 1037 bool CanvasRenderingContext2D::isPointInPath(Path2D* domPath, const float x, con st float y, ExceptionState& exceptionState)
1038 { 1038 {
1039 return isPointInPath(domPath, x, y, "nonzero", exceptionState); 1039 return isPointInPath(domPath, x, y, "nonzero", exceptionState);
1040 } 1040 }
1041 1041
1042 bool CanvasRenderingContext2D::isPointInPath(DOMPath* domPath, const float x, co nst float y, const String& windingRuleString, ExceptionState& exceptionState) 1042 bool CanvasRenderingContext2D::isPointInPath(Path2D* domPath, const float x, con st float y, const String& windingRuleString, ExceptionState& exceptionState)
1043 { 1043 {
1044 if (!domPath) { 1044 if (!domPath) {
1045 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Path")); 1045 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Path"));
1046 return false; 1046 return false;
1047 } 1047 }
1048 1048
1049 return isPointInPathInternal(domPath->path(), x, y, windingRuleString); 1049 return isPointInPathInternal(domPath->path(), x, y, windingRuleString);
1050 } 1050 }
1051 1051
1052 bool CanvasRenderingContext2D::isPointInPathInternal(const Path& path, const flo at x, const float y, const String& windingRuleString) 1052 bool CanvasRenderingContext2D::isPointInPathInternal(const Path& path, const flo at x, const float y, const String& windingRuleString)
(...skipping 15 matching lines...) Expand all
1068 return false; 1068 return false;
1069 1069
1070 return path.contains(transformedPoint, windRule); 1070 return path.contains(transformedPoint, windRule);
1071 } 1071 }
1072 1072
1073 bool CanvasRenderingContext2D::isPointInStroke(const float x, const float y) 1073 bool CanvasRenderingContext2D::isPointInStroke(const float x, const float y)
1074 { 1074 {
1075 return isPointInStrokeInternal(m_path, x, y); 1075 return isPointInStrokeInternal(m_path, x, y);
1076 } 1076 }
1077 1077
1078 bool CanvasRenderingContext2D::isPointInStroke(DOMPath* domPath, const float x, const float y, ExceptionState& exceptionState) 1078 bool CanvasRenderingContext2D::isPointInStroke(Path2D* domPath, const float x, c onst float y, ExceptionState& exceptionState)
1079 { 1079 {
1080 if (!domPath) { 1080 if (!domPath) {
1081 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Path")); 1081 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Path"));
1082 return false; 1082 return false;
1083 } 1083 }
1084 1084
1085 return isPointInStrokeInternal(domPath->path(), x, y); 1085 return isPointInStrokeInternal(domPath->path(), x, y);
1086 } 1086 }
1087 1087
1088 bool CanvasRenderingContext2D::isPointInStrokeInternal(const Path& path, const f loat x, const float y) 1088 bool CanvasRenderingContext2D::isPointInStrokeInternal(const Path& path, const f loat x, const float y)
(...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 const int focusRingWidth = 5; 2516 const int focusRingWidth = 5;
2517 const int focusRingOutline = 0; 2517 const int focusRingOutline = 0;
2518 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); 2518 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor);
2519 2519
2520 c->restore(); 2520 c->restore();
2521 2521
2522 didDraw(dirtyRect); 2522 didDraw(dirtyRect);
2523 } 2523 }
2524 2524
2525 } // namespace WebCore 2525 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/canvas/CanvasRenderingContext2D.h ('k') | Source/core/html/canvas/CanvasRenderingContext2D.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698