webview-get-style debugging

This commit is contained in:
2026-07-30 13:19:01 +02:00
parent 97313c1357
commit 6a4dd25dfe
+30 -27
View File
@@ -1026,40 +1026,43 @@
; styles))) ; styles)))
) )
(let* ((js-code (with-selector sel (let* ((js-code (with-selector sel
(λ (id el) (λ (id el)
(let ((cl (eval cl)) (let ((cl (eval cl))
(r '())) (r '()))
(send cl forEach (send cl forEach
(λ (st) (λ (st)
(send console log st) (send console log st)
(let ((stl (send window getComputedStyle el))) (let ((stl (send window getComputedStyle el)))
(set! (js-ref r st) (js-ref stl st))))) (set! (js-ref r st) (js-ref stl st)))))
(send console log r) (send console log r)
(return (list (list 'id id) (return (list (list 'id id)
(list 'style (send Object entries r)))))) (list 'style (send Object entries r))))))
)) ))
(r (webview-call-js wv js-code)) (r (webview-call-js wv js-code))
) )
; (format ; (format
; (js-code ; (js-code
; "function(id, el) {" ; "function(id, el) {"
; " let cl = ~a;" ; " let cl = ~a;"
; " let r = {};" ; " let r = {};"
; " cl.forEach(function(st) {" ; " cl.forEach(function(st) {"
; " let stl = window.getComputedStyle(el);" ; " let stl = window.getComputedStyle(el);"
; " r[st] = stl[st];" ; " r[st] = stl[st];"
; " });" ; " });"
; " return { id: id, style: r };" ; " return { id: id, style: r };"
; "}") cl)) ; "}") cl))
; ))) ; )))
(displayln (format "~a: ~a" r js-code)) (displayln (format "~a: ~a" r js-code))
(if (eq? r #f) (if (eq? r #f)
#f #f
(let ((h (hash-ref r 'with-ids))) (let ((h (hash-ref r 'with-ids)))
(let ((l (map (λ (e) (let ((l (map (λ (e)
(cons (let ((id-rec (car e))
(string->symbol (hash-ref e 'id)) (style-rec (cadr e)))
(hash-ref e 'style))) h))) (cons (string->symbol (cadr id-rec))
(make-hash (map (λ (e) (cons (car e) (cadr e))) (cadr style-rec)))
)
)) h)))
(if (symbol? selector) (if (symbol? selector)
(cdr (car l)) (cdr (car l))
l)))) l))))