fix(cef): adopt slice-merged signatures from purego-cef
OnPaint, OnAcceleratedPaint, OnImeCompositionRangeChanged now receive []Rect slices instead of raw count+pointer pairs, matching the purego-cef generator's automatic count+pointer merging.
- commit
- 7d63e83d088e3dd7d66e11621b45eeef0ac579f3
- author
- brice · · 2026-03-19 16:10 UTC
- committer
- brice · · 2026-03-28 04:35 UTC
- parent
- 0458bb4
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +6 -14
M internal/infrastructure/cef/webview_handlers.go +6 -14
| @@ -90,23 +90,15 @@ func (h *handlerSet) OnPopupSize(_ purecef.Browser, _ *purecef.Rect) {} | |||
| 90 | 90 | ||
| 91 | 91 | // OnPaint receives the BGRA pixel buffer from CEF and forwards dirty rects | |
| 92 | 92 | // to the render pipeline for GPU upload. | |
| 93 | - | // NOTE: dirty rects are still count+pointer (uintptr) because the purego-cef | |
| 94 | - | // parser doesn't preserve the C type for this parameter yet. Decode manually. | |
| 95 | - | func (h *handlerSet) OnPaint(_ purecef.Browser, _ purecef.PaintElementType, dirtyrectscount int, dirtyrects uintptr, buffer unsafe.Pointer, width int32, height int32) { | |
| 96 | - | var rects []rect | |
| 97 | - | if dirtyrectscount > 0 && dirtyrects != 0 { | |
| 98 | - | // Each cef_rect_t is {x, y, width, height} as int32, but purecef.Rect | |
| 99 | - | // has a HostLayout padding prefix. Use unsafe.Slice on the raw pointer. | |
| 100 | - | cefRects := unsafe.Slice((*purecef.Rect)(unsafe.Pointer(dirtyrects)), dirtyrectscount) | |
| 101 | - | rects = make([]rect, dirtyrectscount) | |
| 102 | - | for i, dr := range cefRects { | |
| 103 | - | rects[i] = rect{X: dr.X, Y: dr.Y, Width: dr.Width, Height: dr.Height} | |
| 104 | - | } | |
| 93 | + | func (h *handlerSet) OnPaint(_ purecef.Browser, _ purecef.PaintElementType, dirtyRects []purecef.Rect, buffer unsafe.Pointer, width int32, height int32) { | |
| 94 | + | rects := make([]rect, len(dirtyRects)) | |
| 95 | + | for i, dr := range dirtyRects { | |
| 96 | + | rects[i] = rect{X: dr.X, Y: dr.Y, Width: dr.Width, Height: dr.Height} | |
| 105 | 97 | } | |
| 106 | 98 | h.wv.pipeline.handlePaint(buffer, width, height, rects) | |
| 107 | 99 | } | |
| 108 | 100 | ||
| 109 | - | func (h *handlerSet) OnAcceleratedPaint(_ purecef.Browser, _ purecef.PaintElementType, _ int, _ uintptr, _ *purecef.AcceleratedPaintInfo) { | |
| 101 | + | func (h *handlerSet) OnAcceleratedPaint(_ purecef.Browser, _ purecef.PaintElementType, _ []purecef.Rect, _ *purecef.AcceleratedPaintInfo) { | |
| 110 | 102 | } | |
| 111 | 103 | ||
| 112 | 104 | func (h *handlerSet) GetTouchHandleSize(_ purecef.Browser, _ purecef.HorizontalAlignment, _ *purecef.Size) { | |
| @@ -122,7 +114,7 @@ func (h *handlerSet) UpdateDragCursor(_ purecef.Browser, _ purecef.DragOperation | |||
| 122 | 114 | ||
| 123 | 115 | func (h *handlerSet) OnScrollOffsetChanged(_ purecef.Browser, _ float64, _ float64) {} | |
| 124 | 116 | ||
| 125 | - | func (h *handlerSet) OnImeCompositionRangeChanged(_ purecef.Browser, _ *purecef.Range, _ int, _ uintptr) { | |
| 117 | + | func (h *handlerSet) OnImeCompositionRangeChanged(_ purecef.Browser, _ *purecef.Range, _ []purecef.Rect) { | |
| 126 | 118 | } | |
| 127 | 119 | ||
| 128 | 120 | func (h *handlerSet) OnTextSelectionChanged(_ purecef.Browser, _ string, _ *purecef.Range) {} | |
| @@ -90,23 +90,15 @@ func (h *handlerSet) OnPopupSize(_ purecef.Browser, _ *purecef.Rect) {} | |||||
| 90 | 90 | ||||
| 91 | // OnPaint receives the BGRA pixel buffer from CEF and forwards dirty rects | 91 | // OnPaint receives the BGRA pixel buffer from CEF and forwards dirty rects | ||
| 92 | // to the render pipeline for GPU upload. | 92 | // to the render pipeline for GPU upload. | ||
| 93 | - | // NOTE: dirty rects are still count+pointer (uintptr) because the purego-cef | 93 | + | func (h *handlerSet) OnPaint(_ purecef.Browser, _ purecef.PaintElementType, dirtyRects []purecef.Rect, buffer unsafe.Pointer, width int32, height int32) { |
| 94 | - | // parser doesn't preserve the C type for this parameter yet. Decode manually. | 94 | + | rects := make([]rect, len(dirtyRects)) |
| 95 | - | func (h *handlerSet) OnPaint(_ purecef.Browser, _ purecef.PaintElementType, dirtyrectscount int, dirtyrects uintptr, buffer unsafe.Pointer, width int32, height int32) { | 95 | + | for i, dr := range dirtyRects { |
| 96 | - | var rects []rect | 96 | + | rects[i] = rect{X: dr.X, Y: dr.Y, Width: dr.Width, Height: dr.Height} |
| 97 | - | if dirtyrectscount > 0 && dirtyrects != 0 { | |||
| 98 | - | // Each cef_rect_t is {x, y, width, height} as int32, but purecef.Rect | |||
| 99 | - | // has a HostLayout padding prefix. Use unsafe.Slice on the raw pointer. | |||
| 100 | - | cefRects := unsafe.Slice((*purecef.Rect)(unsafe.Pointer(dirtyrects)), dirtyrectscount) | |||
| 101 | - | rects = make([]rect, dirtyrectscount) | |||
| 102 | - | for i, dr := range cefRects { | |||
| 103 | - | rects[i] = rect{X: dr.X, Y: dr.Y, Width: dr.Width, Height: dr.Height} | |||
| 104 | - | } | |||
| 105 | } | 97 | } | ||
| 106 | h.wv.pipeline.handlePaint(buffer, width, height, rects) | 98 | h.wv.pipeline.handlePaint(buffer, width, height, rects) | ||
| 107 | } | 99 | } | ||
| 108 | 100 | ||||
| 109 | - | func (h *handlerSet) OnAcceleratedPaint(_ purecef.Browser, _ purecef.PaintElementType, _ int, _ uintptr, _ *purecef.AcceleratedPaintInfo) { | 101 | + | func (h *handlerSet) OnAcceleratedPaint(_ purecef.Browser, _ purecef.PaintElementType, _ []purecef.Rect, _ *purecef.AcceleratedPaintInfo) { |
| 110 | } | 102 | } | ||
| 111 | 103 | ||||
| 112 | func (h *handlerSet) GetTouchHandleSize(_ purecef.Browser, _ purecef.HorizontalAlignment, _ *purecef.Size) { | 104 | func (h *handlerSet) GetTouchHandleSize(_ purecef.Browser, _ purecef.HorizontalAlignment, _ *purecef.Size) { | ||
| @@ -122,7 +114,7 @@ func (h *handlerSet) UpdateDragCursor(_ purecef.Browser, _ purecef.DragOperation | |||||
| 122 | 114 | ||||
| 123 | func (h *handlerSet) OnScrollOffsetChanged(_ purecef.Browser, _ float64, _ float64) {} | 115 | func (h *handlerSet) OnScrollOffsetChanged(_ purecef.Browser, _ float64, _ float64) {} | ||
| 124 | 116 | ||||
| 125 | - | func (h *handlerSet) OnImeCompositionRangeChanged(_ purecef.Browser, _ *purecef.Range, _ int, _ uintptr) { | 117 | + | func (h *handlerSet) OnImeCompositionRangeChanged(_ purecef.Browser, _ *purecef.Range, _ []purecef.Rect) { |
| 126 | } | 118 | } | ||
| 127 | 119 | ||||
| 128 | func (h *handlerSet) OnTextSelectionChanged(_ purecef.Browser, _ string, _ *purecef.Range) {} | 120 | func (h *handlerSet) OnTextSelectionChanged(_ purecef.Browser, _ string, _ *purecef.Range) {} | ||