-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsessionUtils.go
58 lines (52 loc) · 1.37 KB
/
sessionUtils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package rui
func sizeConstant(session Session, tag string) (SizeUnit, bool) {
if text, ok := session.Constant(tag); ok {
return StringToSizeUnit(text)
}
return AutoSize(), false
}
func updateCSSStyle(htmlID string, session Session) {
if !session.ignoreViewUpdates() {
if view := session.viewByHTMLID(htmlID); view != nil {
builder := viewCSSBuilder{buffer: allocStringBuilder()}
view.cssStyle(view, &builder)
//session.callFunc("updateCSSStyle", view.htmlID(), builder.finish())
session.updateProperty(view.htmlID(), "style", builder.finish())
}
}
}
func updateInnerHTML(htmlID string, session Session) {
if !session.ignoreViewUpdates() {
var view View
if htmlID == "ruiRootView" {
view = session.RootView()
} else {
view = session.viewByHTMLID(htmlID)
}
if view != nil {
session.callFunc("hideTooltip")
script := allocStringBuilder()
defer freeStringBuilder(script)
script.Grow(32 * 1024)
view.htmlSubviews(view, script)
session.updateInnerHTML(view.htmlID(), script.String())
}
}
}
func viewByHTMLID(id string, startView View) View {
if startView != nil {
if startView.htmlID() == id {
return startView
}
if container, ok := startView.(ParentView); ok {
for _, view := range container.Views() {
if view != nil {
if v := viewByHTMLID(id, view); v != nil {
return v
}
}
}
}
}
return nil
}