ref: 99ad10d49938ebfcfd65d45dec428078e8d10fbb
parent: 2e43df3f22dea66a0f404d3e1ab7a9ae3edad22e
author: Philip Silva <philip.silva@protonmail.com>
date: Sun Apr 18 12:25:45 EDT 2021
Fix colorHex for 3 digit colors - e.g. turn #fff into 0xffffffff instead of #f0f0f0ff
--- a/style/stylesheets.go
+++ b/style/stylesheets.go
@@ -397,9 +397,9 @@
if err != nil {
goto default_value
}
- r = uint32(rr) * 256 * 16
- g = uint32(gg) * 256 * 16
- b = uint32(bb) * 256 * 16
+ r = uint32(rr) * 256 * 0x11
+ g = uint32(gg) * 256 * 0x11
+ b = uint32(bb) * 256 * 0x11
} else if len(hexColor) == 6 {
rr, err := strconv.ParseInt(hexColor[0:2], 16, 32)
if err != nil {
--- a/style/stylesheets_test.go
+++ b/style/stylesheets_test.go
@@ -46,6 +46,19 @@
}
}
+func TestColorHex3(t *testing.T) {
+ m := d("#fff")
+
+ c, ok := m.colorHex("color")
+ if !ok {
+ t.Fail()
+ }
+
+ if uint32(c) != 0xffffffff {
+ t.Errorf("c=%x", c)
+ }
+}
+
func TestFetchNodeRules(t *testing.T) {
data := `<body>
<h2 id="foo">a header</h2>