Browse Source

LibWeb: Let canvas {fill,stroke}Style default to black, not transparent

I don't know if the original author simply missed this or thought the
default color of Gfx::Color is black, but this meant that drawing on a
canvas without explicitly setting a fillStyle or strokeStyle first would
be drawn in transparent color and therefore be invisible.

In the spec this is indicated by a small comment in the IDL definition:

    attribute ... strokeStyle; // (default black)
    attribute ... fillStyle; // (default black)

I'm starting to question whether Gfx::Color actually *should* have a
default constructor.
Linus Groh 3 years ago
parent
commit
b32893eb54
1 changed files with 2 additions and 2 deletions
  1. 2 2
      Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h

+ 2 - 2
Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h

@@ -81,8 +81,8 @@ private:
     WeakPtr<HTMLCanvasElement> m_element;
     WeakPtr<HTMLCanvasElement> m_element;
 
 
     Gfx::AffineTransform m_transform;
     Gfx::AffineTransform m_transform;
-    Gfx::Color m_fill_style;
-    Gfx::Color m_stroke_style;
+    Gfx::Color m_fill_style { Gfx::Color::Black };
+    Gfx::Color m_stroke_style { Gfx::Color::Black };
     float m_line_width { 1 };
     float m_line_width { 1 };
 
 
     Gfx::Path m_path;
     Gfx::Path m_path;