Diff
diff --git a/cstyle/transformers/scrollbar/main.go b/cstyle/transformers/scrollbar/main.go
index 0965bca..701f057 100644
--- a/cstyle/transformers/scrollbar/main.go
+++ b/cstyle/transformers/scrollbar/main.go
@@ -5,0 +6 @@ import (
+ "grim/utils"
@@ -13 +14 @@ func Init() cstyle.Transformer {
- style := n.ComputedStyle
+ style := n.Styles()
@@ -21 +22 @@ func Init() cstyle.Transformer {
- style := n.ComputedStyle
+ style := n.Styles()
@@ -24 +25 @@ func Init() cstyle.Transformer {
- if n.ComputedStyle["overflow-y"] == "" {
+ if n.GetStyle("overflow-y") == "" {
@@ -29 +30 @@ func Init() cstyle.Transformer {
- n.ComputedStyle["overflow-y"] = val
+ n.SetStyle("overflow-y", val)
@@ -32 +33 @@ func Init() cstyle.Transformer {
- n.ComputedStyle["overflow-x"] = overflowProps[0]
+ n.SetStyle("overflow-x", overflowProps[0])
@@ -36 +37 @@ func Init() cstyle.Transformer {
- n.ComputedStyle["position"] = "relative"
+ n.SetStyle("position", "relative")
@@ -42 +43 @@ func Init() cstyle.Transformer {
- if n.ComputedStyle["scrollbar-width"] == "thin" {
+ if n.GetStyle("scrollbar-width") == "thin" {
@@ -47 +48 @@ func Init() cstyle.Transformer {
- if n.ComputedStyle["scrollbar-width"] == "none" {
+ if n.GetStyle("scrollbar-width") == "none" {
@@ -53 +54 @@ func Init() cstyle.Transformer {
- splitStr := strings.Split(n.ComputedStyle["scrollbar-color"], " ")
+ splitStr := strings.Split(n.GetStyle("scrollbar-color"), " ")
@@ -70 +71 @@ func Init() cstyle.Transformer {
- if n.ComputedStyle["overflow-x"] == "scroll" || n.ComputedStyle["overflow-x"] == "auto" {
+ if n.GetStyle("overflow-x") == "scroll" || n.GetStyle("overflow-x") == "auto" {
@@ -73,7 +74,7 @@ func Init() cstyle.Transformer {
- scrollbar.ComputedStyle["position"] = "absolute"
- scrollbar.ComputedStyle["bottom"] = "0px"
- scrollbar.ComputedStyle["left"] = "0"
- scrollbar.ComputedStyle["width"] = "100%"
- scrollbar.ComputedStyle["height"] = trackWidth
- scrollbar.ComputedStyle["background"] = backgroundColor
- scrollbar.ComputedStyle["z-index"] = "99999"
+ scrollbar.SetStyle("position", "absolute")
+ scrollbar.SetStyle("bottom", "0px")
+ scrollbar.SetStyle("left", "0")
+ scrollbar.SetStyle("width", "100%")
+ scrollbar.SetStyle("height", trackWidth)
+ scrollbar.SetStyle("background", backgroundColor)
+ scrollbar.SetStyle("z-index", "99999")
@@ -83,9 +84,9 @@ func Init() cstyle.Transformer {
- thumb.ComputedStyle["position"] = "absolute"
- thumb.ComputedStyle["left"] = strconv.Itoa(n.ScrollLeft) + "px"
- thumb.ComputedStyle["top"] = thumbMargin
- thumb.ComputedStyle["height"] = thumbWidth
- thumb.ComputedStyle["width"] = "20px"
- thumb.ComputedStyle["background"] = thumbColor
- thumb.ComputedStyle["cursor"] = "pointer"
- thumb.ComputedStyle["border-radius"] = "10px"
- thumb.ComputedStyle["z-index"] = "99999"
+ thumb.SetStyle("position", "absolute")
+ thumb.SetStyle("left", strconv.Itoa(n.ScrollLeft)+"px")
+ thumb.SetStyle("top", thumbMargin)
+ thumb.SetStyle("height", thumbWidth)
+ thumb.SetStyle("width", "20px")
+ thumb.SetStyle("background", thumbColor)
+ thumb.SetStyle("cursor", "pointer")
+ thumb.SetStyle("border-radius", "10px")
+ thumb.SetStyle("z-index", "99999")
@@ -94,2 +95,2 @@ func Init() cstyle.Transformer {
- scrollbar.ComputedStyle[k] = v
- thumb.ComputedStyle[k] = v
+ scrollbar.SetStyle(k, v)
+ thumb.SetStyle(k, v)
@@ -99 +100 @@ func Init() cstyle.Transformer {
- scrollbar.ComputedStyle[k] = v
+ scrollbar.SetStyle(k, v)
@@ -103 +104 @@ func Init() cstyle.Transformer {
- thumb.ComputedStyle[k] = v
+ thumb.SetStyle(k, v)
@@ -113 +114 @@ func Init() cstyle.Transformer {
- if n.ComputedStyle["overflow-y"] == "scroll" || n.ComputedStyle["overflow-y"] == "auto" {
+ if n.GetStyle("overflow-y") == "scroll" || n.GetStyle("overflow-y") == "auto" {
@@ -116,7 +117,7 @@ func Init() cstyle.Transformer {
- scrollbar.ComputedStyle["position"] = "absolute"
- scrollbar.ComputedStyle["top"] = "0"
- scrollbar.ComputedStyle["right"] = "0"
- scrollbar.ComputedStyle["width"] = trackWidth
- scrollbar.ComputedStyle["height"] = "100%"
- scrollbar.ComputedStyle["background"] = backgroundColor
- scrollbar.ComputedStyle["z-index"] = "99999"
+ scrollbar.SetStyle("position", "absolute")
+ scrollbar.SetStyle("top", "0")
+ scrollbar.SetStyle("right", "0")
+ scrollbar.SetStyle("width", trackWidth)
+ scrollbar.SetStyle("height", "100%")
+ scrollbar.SetStyle("background", backgroundColor)
+ scrollbar.SetStyle("z-index", "99999")
@@ -127,2 +128,2 @@ func Init() cstyle.Transformer {
- thumb.ComputedStyle["position"] = "absolute"
- thumb.ComputedStyle["top"] = strconv.Itoa(n.ScrollTop) + "px"
+ thumb.SetStyle("position", "absolute")
+ thumb.SetStyle("top", strconv.Itoa(n.ScrollTop)+"px")
@@ -130,8 +131,8 @@ func Init() cstyle.Transformer {
- thumb.ComputedStyle["right"] = "3px"
- thumb.ComputedStyle["width"] = thumbWidth
- thumb.ComputedStyle["height"] = "20px"
- thumb.ComputedStyle["background"] = thumbColor
- thumb.ComputedStyle["cursor"] = "pointer"
- thumb.ComputedStyle["margin-left"] = thumbMargin
- thumb.ComputedStyle["border-radius"] = "10px"
- thumb.ComputedStyle["z-index"] = "99999"
+ thumb.SetStyle("right", "3px")
+ thumb.SetStyle("width", thumbWidth)
+ thumb.SetStyle("height", "20px")
+ thumb.SetStyle("background", thumbColor)
+ thumb.SetStyle("cursor", "pointer")
+ thumb.SetStyle("margin-left", thumbMargin)
+ thumb.SetStyle("border-radius", "10px")
+ thumb.SetStyle("z-index", "99999")
@@ -140,2 +141,2 @@ func Init() cstyle.Transformer {
- scrollbar.ComputedStyle[k] = v
- thumb.ComputedStyle[k] = v
+ scrollbar.SetStyle(k, v)
+ thumb.SetStyle(k, v)
@@ -145 +146 @@ func Init() cstyle.Transformer {
- scrollbar.ComputedStyle[k] = v
+ scrollbar.SetStyle(k, v)
@@ -149 +150 @@ func Init() cstyle.Transformer {
- thumb.ComputedStyle[k] = v
+ thumb.SetStyle(k, v)
@@ -152 +153 @@ func Init() cstyle.Transformer {
- // scrollbar.AppendChild(&thumb)
+ scrollbar.AppendChild(&thumb)
@@ -156 +157 @@ func Init() cstyle.Transformer {
- n.ComputedStyle["width"] = "calc(" + style["width"] + "-" + trackWidth + ")"
+ n.SetStyle("width", "calc("+style["width"]+"-"+trackWidth+")")
@@ -159,6 +160,7 @@ func Init() cstyle.Transformer {
- pr := n.ComputedStyle["padding-right"]
- // !ISSUE: remove appendchild
- if pr == "" && n.ComputedStyle["padding"] != "" {
- n.ComputedStyle["padding-right"] = "calc(" + n.StyleSheets.Styles["padding"] + " + " + trackWidth + ")"
- } else if pr != "" {
- n.ComputedStyle["padding-right"] = "calc(" + n.StyleSheets.Styles["padding-right"] + " + " + trackWidth + ")"
+ pr := n.GetStyle("padding-right")
+
+ if pr == "" && n.GetStyle("padding") != "" {
+ n.SetStyle("padding-right", "calc("+n.StyleSheets.Styles["padding"]+" + "+trackWidth+")")
+ } else if n.GetStyle("padding") != "" {
+ _, r, _, _ := utils.ConvertMarginToIndividualProperties(n.GetStyle("padding"))
+ n.SetStyle("padding-right", "calc("+r+" + "+trackWidth+")")
@@ -166 +168 @@ func Init() cstyle.Transformer {
- n.ComputedStyle["padding-right"] = trackWidth
+ n.SetStyle("padding-right", trackWidth)
@@ -168 +170 @@ func Init() cstyle.Transformer {
- // n.AppendChild(&scrollbar)
+ n.AppendChild(&scrollbar)