Changeset 267645 in webkit
- Timestamp:
- Sep 26, 2020, 7:48:39 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/canvas/canvas-color-serialization-expected.txt (modified) (1 diff)
-
LayoutTests/fast/canvas/canvas-color-serialization.html (modified) (2 diffs)
-
LayoutTests/fast/canvas/set-colors-expected.txt (modified) (2 diffs)
-
LayoutTests/fast/canvas/set-colors.html (modified) (2 diffs)
-
LayoutTests/inspector/canvas/recording-2d-full-expected.txt (modified) (2 diffs)
-
LayoutTests/inspector/canvas/resources/recording-2d.js (modified) (2 diffs)
-
LayoutTests/platform/ios/fast/canvas/set-colors-expected.txt (modified) (2 diffs)
-
LayoutTests/platform/mac/fast/canvas/set-colors-expected.txt (modified) (2 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/html/canvas/CanvasRenderingContext2D.idl (modified) (1 diff)
-
Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp (modified) (2 diffs)
-
Source/WebCore/html/canvas/CanvasStyle.cpp (modified) (5 diffs)
-
Source/WebCore/html/canvas/CanvasStyle.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r267644 r267645 1 2020-09-26 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Remove support for setting CMYKA fill and stroke colors in 2D canvas 4 https://bugs.webkit.org/show_bug.cgi?id=217002 5 6 Reviewed by Darin Adler. 7 8 Remove calls to `CanvasRenderingContext2D.setFillColor(c, m, y, k, a)` and 9 `CanvasRenderingContext2D.setStrokeColor(c, m, y, k, a)` in these layout tests. 10 11 * fast/canvas/canvas-color-serialization-expected.txt: 12 * fast/canvas/canvas-color-serialization.html: 13 * fast/canvas/set-colors-expected.txt: 14 * fast/canvas/set-colors.html: 15 * inspector/canvas/recording-2d-full-expected.txt: 16 * inspector/canvas/resources/recording-2d.js: 17 * platform/ios/fast/canvas/set-colors-expected.txt: 18 * platform/mac/fast/canvas/set-colors-expected.txt: 19 1 20 2020-09-26 Darin Adler <darin@apple.com> 2 21 -
trunk/LayoutTests/fast/canvas/canvas-color-serialization-expected.txt
r170933 r267645 25 25 PASS trySettingStrokeColorRGBA(255, 0, 0, 0.4) is 'rgba(255, 0, 0, 0.4)' 26 26 PASS trySettingShadowRGBA(255, 0, 0, 0.4) is 'rgba(255, 0, 0, 0.4)' 27 PASS trySettingFillColorCMYKA(0, 0, 0, 0, 0) is 'rgba(255, 255, 255, 0)'28 PASS trySettingStrokeColorCMYKA(0, 0, 0, 0, 0) is 'rgba(255, 255, 255, 0)'29 PASS trySettingShadowCMYKA(0, 0, 0, 0, 0) is 'rgba(255, 255, 255, 0)'30 PASS trySettingFillColorCMYKA(0, 0, 0, 0, 1) is '#ffffff'31 PASS trySettingStrokeColorCMYKA(0, 0, 0, 0, 1) is '#ffffff'32 PASS trySettingShadowCMYKA(0, 0, 0, 0, 1) is '#ffffff'33 PASS trySettingFillColorCMYKA(0, 1, 0, 0, 0) is 'rgba(255, 0, 255, 0)'34 PASS trySettingStrokeColorCMYKA(0, 1, 0, 0, 0) is 'rgba(255, 0, 255, 0)'35 PASS trySettingShadowCMYKA(0, 1, 0, 0, 0) is 'rgba(255, 0, 255, 0)'36 PASS trySettingFillColorCMYKA(0, 1, 0, 0, 1) is '#ff00ff'37 PASS trySettingStrokeColorCMYKA(0, 1, 0, 0, 1) is '#ff00ff'38 PASS trySettingShadowCMYKA(0, 1, 0, 0, 1) is '#ff00ff'39 PASS trySettingFillColorCMYKA(0, 0, 0, 1, 0) is 'rgba(0, 0, 0, 0)'40 PASS trySettingStrokeColorCMYKA(0, 0, 0, 1, 0) is 'rgba(0, 0, 0, 0)'41 PASS trySettingShadowCMYKA(0, 0, 0, 1, 0) is 'rgba(0, 0, 0, 0)'42 PASS trySettingFillColorCMYKA(0, 0, 0, 1, 1) is '#000000'43 PASS trySettingStrokeColorCMYKA(0, 0, 0, 1, 1) is '#000000'44 PASS trySettingShadowCMYKA(0, 0, 0, 1, 1) is '#000000'45 27 PASS trySettingFillColorGrayLevel(0) is '#000000' 46 28 PASS trySettingStrokeColorGrayLevel(0) is '#000000' -
trunk/LayoutTests/fast/canvas/canvas-color-serialization.html
r217390 r267645 82 82 } 83 83 84 function trySettingFillColorCMYKA(c, m, y, k, a) {85 ctx.fillStyle = '#666';86 ctx.setFillColor(c, m, y, k, a);87 return ctx.fillStyle;88 }89 90 function trySettingStrokeColorCMYKA(c, m, y, k, a) {91 ctx.strokeStyle = '#666';92 ctx.setStrokeColor(c, m, y, k, a);93 return ctx.strokeStyle;94 }95 96 function trySettingShadowCMYKA(c, m, y, k, a) {97 ctx.strokeStyle = '#666';98 ctx.setStrokeColor(c, m, y, k, a);99 return ctx.strokeStyle;100 }101 102 function trySettingCMYKA(c, m, y, k, a, expected) {103 shouldBe("trySettingFillColorCMYKA(" + c + ", " + m + ", " + y + ", " + k + ", " + a + ")", expected);104 shouldBe("trySettingStrokeColorCMYKA(" + c + ", " + m + ", " + y + ", " + k + ", " + a + ")", expected);105 shouldBe("trySettingShadowCMYKA(" + c + ", " + m + ", " + y + ", " + k + ", " + a + ")", expected);106 }107 108 84 function trySettingFillColorWithOverrideAlpha(color, alpha) { 109 85 ctx.fillStyle = '#666'; … … 199 175 trySettingRGBA(255, 0, 0, 0.0, "'rgba(255, 0, 0, 0)'"); 200 176 trySettingRGBA(255, 0, 0, 0.4, "'rgba(255, 0, 0, 0.4)'"); 201 202 trySettingCMYKA(0, 0, 0, 0, 0.0, "'rgba(255, 255, 255, 0)'");203 trySettingCMYKA(0, 0, 0, 0, 1.0, "'#ffffff'");204 trySettingCMYKA(0, 1, 0, 0, 0.0, "'rgba(255, 0, 255, 0)'");205 trySettingCMYKA(0, 1, 0, 0, 1.0, "'#ff00ff'");206 trySettingCMYKA(0, 0, 0, 1, 0.0, "'rgba(0, 0, 0, 0)'");207 trySettingCMYKA(0, 0, 0, 1, 1.0, "'#000000'");208 177 209 178 trySettingGrayLevel(0.0, "'#000000'"); -
trunk/LayoutTests/fast/canvas/set-colors-expected.txt
r158528 r267645 32 32 PASS testSetFillColor('0, 1, 0, 1') is green 33 33 PASS testSetFillColor('0, 1, 0, 0.8') is translucentGreen 34 FAIL testSetFillColor('0, 0, 0, 1, 1') should be #1a1a1a. Was #000000.35 FAIL testSetFillColor('0, 0, 0, 1, 0.8') should be rgba(25, 25, 25, 0.8). Was rgba(0, 0, 0, 0.8).36 PASS testSetFillColor('0, 0, 0, 1, 0') is transparent37 34 PASS testStrokeStyle('transparent') is transparent 38 35 PASS testStrokeStyle('blue') is blue … … 63 60 PASS testSetStrokeColor('0, 1, 0, 1') is green 64 61 PASS testSetStrokeColor('0, 1, 0, 0.8') is translucentGreen 65 FAIL testSetStrokeColor('0, 0, 0, 1, 1') should be #1a1a1a. Was #000000.66 FAIL testSetStrokeColor('0, 0, 0, 1, 0.8') should be rgba(25, 25, 25, 0.8). Was rgba(0, 0, 0, 0.8).67 PASS testSetStrokeColor('0, 0, 0, 1, 0') is transparent68 62 PASS successfullyParsed is true 69 63 -
trunk/LayoutTests/fast/canvas/set-colors.html
r217390 r267645 133 133 shouldBe("testSetFillColor('0, 1, 0, 1')", "green"); 134 134 shouldBe("testSetFillColor('0, 1, 0, 0.8')", "translucentGreen"); 135 shouldBe("testSetFillColor('0, 0, 0, 1, 1')", "'#1a1a1a'"); // This test is expected to fail on older versions of Mac OS X.136 shouldBe("testSetFillColor('0, 0, 0, 1, 0.8')", "'rgba(25, 25, 25, 0.8)'"); // Ditto.137 shouldBe("testSetFillColor('0, 0, 0, 1, 0')", "transparent");138 135 shouldBe("testStrokeStyle('transparent')", "transparent"); 139 136 shouldBe("testStrokeStyle('blue')", "blue"); … … 164 161 shouldBe("testSetStrokeColor('0, 1, 0, 1')", "green"); 165 162 shouldBe("testSetStrokeColor('0, 1, 0, 0.8')", "translucentGreen"); 166 shouldBe("testSetStrokeColor('0, 0, 0, 1, 1')", "'#1a1a1a'"); // This test is expected to fail on older versions of Mac OS X.167 shouldBe("testSetStrokeColor('0, 0, 0, 1, 0.8')", "'rgba(25, 25, 25, 0.8)'"); // Ditto.168 shouldBe("testSetStrokeColor('0, 0, 0, 1, 0')", "transparent");169 163 </script> 170 164 <script src="../../resources/js-test-post.js"></script> -
trunk/LayoutTests/inspector/canvas/recording-2d-full-expected.txt
r267000 r267645 696 696 1: (anonymous function) 697 697 2: executeFrameFunction 698 5: setFillColor(9, 10, 11, 12, 13)699 swizzleTypes: [Number, Number, Number, Number, Number]700 trace:701 0: setFillColor702 1: (anonymous function)703 2: executeFrameFunction704 698 50: (duration) 705 699 0: setLineCap("") … … 829 823 1: (anonymous function) 830 824 2: executeFrameFunction 831 5: setStrokeColor(9, 10, 11, 12, 13)832 swizzleTypes: [Number, Number, Number, Number, Number]833 trace:834 0: setStrokeColor835 1: (anonymous function)836 2: executeFrameFunction837 825 57: (duration) 838 826 0: setTransform(1, 2, 3, 4, 5, 6) -
trunk/LayoutTests/inspector/canvas/resources/recording-2d.js
r246016 r267645 274 274 ctx.setFillColor(3, 4); 275 275 ctx.setFillColor(5, 6, 7, 8); 276 ctx.setFillColor(9, 10, 11, 12, 13);277 276 }, 278 277 () => { … … 309 308 ctx.setStrokeColor(3, 4); 310 309 ctx.setStrokeColor(5, 6, 7, 8); 311 ctx.setStrokeColor(9, 10, 11, 12, 13);312 310 }, 313 311 () => { -
trunk/LayoutTests/platform/ios/fast/canvas/set-colors-expected.txt
r199788 r267645 32 32 PASS testSetFillColor('0, 1, 0, 1') is green 33 33 PASS testSetFillColor('0, 1, 0, 0.8') is translucentGreen 34 FAIL testSetFillColor('0, 0, 0, 1, 1') should be #1a1a1a. Was #1a1919.35 FAIL testSetFillColor('0, 0, 0, 1, 0.8') should be rgba(25, 25, 25, 0.8). Was rgba(26, 25, 25, 0.8).36 PASS testSetFillColor('0, 0, 0, 1, 0') is transparent37 34 PASS testStrokeStyle('transparent') is transparent 38 35 PASS testStrokeStyle('blue') is blue … … 63 60 PASS testSetStrokeColor('0, 1, 0, 1') is green 64 61 PASS testSetStrokeColor('0, 1, 0, 0.8') is translucentGreen 65 FAIL testSetStrokeColor('0, 0, 0, 1, 1') should be #1a1a1a. Was #1a1919.66 FAIL testSetStrokeColor('0, 0, 0, 1, 0.8') should be rgba(25, 25, 25, 0.8). Was rgba(26, 25, 25, 0.8).67 PASS testSetStrokeColor('0, 0, 0, 1, 0') is transparent68 62 PASS successfullyParsed is true 69 63 -
trunk/LayoutTests/platform/mac/fast/canvas/set-colors-expected.txt
r106179 r267645 32 32 PASS testSetFillColor('0, 1, 0, 1') is green 33 33 PASS testSetFillColor('0, 1, 0, 0.8') is translucentGreen 34 FAIL testSetFillColor('0, 0, 0, 1, 1') should be #1a1a1a. Was #1a1919.35 FAIL testSetFillColor('0, 0, 0, 1, 0.8') should be rgba(25, 25, 25, 0.8). Was rgba(26, 25, 25, 0.8).36 PASS testSetFillColor('0, 0, 0, 1, 0') is transparent37 34 PASS testStrokeStyle('transparent') is transparent 38 35 PASS testStrokeStyle('blue') is blue … … 63 60 PASS testSetStrokeColor('0, 1, 0, 1') is green 64 61 PASS testSetStrokeColor('0, 1, 0, 0.8') is translucentGreen 65 FAIL testSetStrokeColor('0, 0, 0, 1, 1') should be #1a1a1a. Was #1a1919.66 FAIL testSetStrokeColor('0, 0, 0, 1, 0.8') should be rgba(25, 25, 25, 0.8). Was rgba(26, 25, 25, 0.8).67 PASS testSetStrokeColor('0, 0, 0, 1, 0') is transparent68 62 PASS successfullyParsed is true 69 63 -
trunk/Source/WebCore/ChangeLog
r267639 r267645 1 2020-09-26 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Remove support for setting CMYKA fill and stroke colors in 2D canvas 4 https://bugs.webkit.org/show_bug.cgi?id=217002 5 6 Reviewed by Darin Adler. 7 8 Remove support for `setFillColor(c, m, y, k, a)` and `setStrokeColor(c, m, y, k, a)` on 9 `CanvasRenderingContext2D`, which was initially introduced in 2004 with <https://trac.webkit.org/r6730>. 10 Setting colors from CMYKA components is non-standard and unsupported in both Firefox and Chrome; 11 importantly, this is implemented in `CanvasStyle::applyStrokeColor` by calling directly into CoreGraphics 12 API using the platform `CGContextRef`, which is null when using the GPU Process; this subsequently causes 13 the web process to crash. 14 15 In lieu of adding new DisplayList items to support setting fill and stroke colors with CMYKA components, 16 we can take this opportunity to just drop support for this canvas API entirely. Fixes the following tests 17 when using the GPU Process to render canvas: 18 - fast/canvas/canvas-color-serialization.html 19 - fast/canvas/canvas-overloads-setFillColor.html 20 - fast/canvas/canvas-overloads-setStrokeColor.html 21 22 * html/canvas/CanvasRenderingContext2D.idl: 23 * html/canvas/CanvasRenderingContext2DBase.cpp: 24 * html/canvas/CanvasStyle.cpp: 25 (WebCore::CanvasStyle::isEquivalentColor const): 26 (WebCore::CanvasStyle::applyStrokeColor const): 27 (WebCore::CanvasStyle::applyFillColor const): 28 * html/canvas/CanvasStyle.h: 29 (WebCore::CanvasStyle::color const): 30 1 31 2020-09-26 Chris Dumez <cdumez@apple.com> 2 32 -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl
r267000 r267645 47 47 undefined setStrokeColor(unrestricted float grayLevel, optional float alpha = 1); 48 48 undefined setStrokeColor(unrestricted float r, unrestricted float g, unrestricted float b, unrestricted float a); 49 undefined setStrokeColor(unrestricted float c, unrestricted float m, unrestricted float y, unrestricted float k, unrestricted float a);50 49 undefined setFillColor(DOMString color, optional unrestricted float alpha); 51 50 undefined setFillColor(unrestricted float grayLevel, optional unrestricted float alpha = 1); 52 51 undefined setFillColor(unrestricted float r, unrestricted float g, unrestricted float b, unrestricted float a); 53 undefined setFillColor(unrestricted float c, unrestricted float m, unrestricted float y, unrestricted float k, unrestricted float a);54 52 55 53 // Non-standard functionality (CanvasImageData). -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
r264585 r267645 932 932 } 933 933 934 void CanvasRenderingContext2DBase::setStrokeColor(float c, float m, float y, float k, float a)935 {936 auto color = CMYKA { c, m, y, k, a };937 if (state().strokeStyle.isEquivalent(color))938 return;939 setStrokeStyle(CanvasStyle(color));940 }941 942 934 void CanvasRenderingContext2DBase::setFillColor(const String& color, Optional<float> alpha) 943 935 { … … 966 958 { 967 959 auto color = SRGBA { r, g, b, a }; 968 if (state().fillStyle.isEquivalent(color))969 return;970 setFillStyle(CanvasStyle(color));971 }972 973 void CanvasRenderingContext2DBase::setFillColor(float c, float m, float y, float k, float a)974 {975 auto color = CMYKA { c, m, y, k, a };976 960 if (state().fillStyle.isEquivalent(color)) 977 961 return; -
trunk/Source/WebCore/html/canvas/CanvasStyle.cpp
r264333 r267645 100 100 } 101 101 102 CanvasStyle::CanvasStyle(const CMYKA<float>& colorComponents)103 : m_style(CMYKAColor { convertToComponentBytes(toSRGBA(colorComponents)), colorComponents })104 {105 }106 107 102 CanvasStyle::CanvasStyle(CanvasGradient& gradient) 108 103 : m_style(makeRefPtr(gradient)) … … 149 144 return WTF::get<Color>(m_style) == WTF::get<Color>(other.m_style); 150 145 151 if (WTF::holds_alternative<CMYKAColor>(m_style) && WTF::holds_alternative<CMYKAColor>(other.m_style))152 return WTF::get<CMYKAColor>(m_style).components == WTF::get<CMYKAColor>(other.m_style).components;153 154 146 return false; 155 147 } … … 160 152 } 161 153 162 bool CanvasStyle::isEquivalent(const CMYKA<float>& components) const163 {164 return WTF::holds_alternative<CMYKAColor>(m_style) && WTF::get<CMYKAColor>(m_style).components == components;165 }166 167 154 void CanvasStyle::applyStrokeColor(GraphicsContext& context) const 168 155 { … … 170 157 [&context] (const Color& color) { 171 158 context.setStrokeColor(color); 172 },173 [&context] (const CMYKAColor& color) {174 // FIXME: Do this through platform-independent GraphicsContext API.175 // We'll need a fancier Color abstraction to support CMYKA correctly176 #if USE(CG)177 CGContextSetCMYKStrokeColor(context.platformContext(), color.components.cyan, color.components.magenta, color.components.yellow, color.components.black, color.components.alpha);178 #else179 context.setStrokeColor(color.colorConvertedToSRGBA);180 #endif181 159 }, 182 160 [&context] (const RefPtr<CanvasGradient>& gradient) { … … 201 179 context.setFillColor(color); 202 180 }, 203 [&context] (const CMYKAColor& color) {204 // FIXME: Do this through platform-independent GraphicsContext API.205 // We'll need a fancier Color abstraction to support CMYKA correctly206 #if USE(CG)207 CGContextSetCMYKFillColor(context.platformContext(), color.components.cyan, color.components.magenta, color.components.yellow, color.components.black, color.components.alpha);208 #else209 context.setFillColor(color.colorConvertedToSRGBA);210 #endif211 },212 181 [&context] (const RefPtr<CanvasGradient>& gradient) { 213 182 context.setFillGradient(gradient->gradient()); -
trunk/Source/WebCore/html/canvas/CanvasStyle.h
r263788 r267645 69 69 struct Invalid { }; 70 70 71 struct CMYKAColor {72 Color colorConvertedToSRGBA;73 CMYKA<float> components;74 };75 76 71 struct CurrentColor { 77 72 Optional<float> overrideAlpha; … … 80 75 CanvasStyle(CurrentColor); 81 76 82 Variant<Invalid, Color, CMYKAColor,RefPtr<CanvasGradient>, RefPtr<CanvasPattern>, CurrentColor> m_style;77 Variant<Invalid, Color, RefPtr<CanvasGradient>, RefPtr<CanvasPattern>, CurrentColor> m_style; 83 78 }; 84 79 … … 110 105 inline String CanvasStyle::color() const 111 106 { 112 return serializationForHTML(WTF:: holds_alternative<Color>(m_style) ? WTF::get<Color>(m_style) : WTF::get<CMYKAColor>(m_style).colorConvertedToSRGBA);107 return serializationForHTML(WTF::get<Color>(m_style)); 113 108 } 114 109
Note:
See TracChangeset
for help on using the changeset viewer.