⋯ 57 hidden lines@@ -58,13 +58,13 @@ func (h *handlerSet) OnProcessMessageReceived(_ purecef.Browser, _ purecef.Frame 58 58 59 func (h *handlerSet) GetAccessibilityHandler() purecef.AccessibilityHandler { return nil }59 func (h *handlerSet) GetAccessibilityHandler() purecef.AccessibilityHandler { return nil }60 60 61 - func (h *handlerSet) GetRootScreenRect(_ purecef.Browser, _ uintptr) int32 { return 0 }61 + func (h *handlerSet) GetRootScreenRect(_ purecef.Browser, _ *purecef.Rect) int32 { return 0 }62 62 63 // GetViewRect fills the rect struct with the pipeline dimensions. 63 // GetViewRect fills the rect struct with the pipeline dimensions. 64 // The rect pointer points to a cef_rect_t: {HostLayout padding, X, Y, Width, Height} all int32. 64 // The rect pointer points to a cef_rect_t: {HostLayout padding, X, Y, Width, Height} all int32. 65 // The HostLayout field occupies 0 bytes on most platforms but we use the Rect type alias to be safe. 65 // The HostLayout field occupies 0 bytes on most platforms but we use the Rect type alias to be safe. 66 - func (h *handlerSet) GetViewRect(_ purecef.Browser, rect uintptr) {66 + func (h *handlerSet) GetViewRect(_ purecef.Browser, rect *purecef.Rect) {67 - if rect == 0 { 67 + if rect == nil { 68 return 68 return 69 } 69 } 70 h.wv.pipeline.mu.Lock() 70 h.wv.pipeline.mu.Lock() ⋯ 1 hidden line@@ -72,41 +72,47 @@ func (h *handlerSet) GetViewRect(_ purecef.Browser, rect uintptr) { 72 ht := h.wv.pipeline.height 72 ht := h.wv.pipeline.height 73 h.wv.pipeline.mu.Unlock() 73 h.wv.pipeline.mu.Unlock() 74 74 75 - r := (*purecef.Rect)(unsafe.Pointer(rect)) 75 + rect.X = 0 76 - r.X = 0 76 + rect.Y = 0 77 - r.Y = 0 77 + rect.Width = w 78 - r.Width = w 78 + rect.Height = ht 79 - r.Height = ht 80 } 79 } 81 80 82 func (h *handlerSet) GetScreenPoint(_ purecef.Browser, _ int32, _ int32, _ unsafe.Pointer, _ unsafe.Pointer) int32 {81 func (h *handlerSet) GetScreenPoint(_ purecef.Browser, _ int32, _ int32, _ unsafe.Pointer, _ unsafe.Pointer) int32 {83 return 0 82 return 0 84 } 83 } 85 84 86 - func (h *handlerSet) GetScreenInfo(_ purecef.Browser, _ uintptr) int32 { return 0 }85 + func (h *handlerSet) GetScreenInfo(_ purecef.Browser, _ *purecef.ScreenInfo) int32 { return 0 }87 86 88 func (h *handlerSet) OnPopupShow(_ purecef.Browser, _ int32) {}87 func (h *handlerSet) OnPopupShow(_ purecef.Browser, _ int32) {}89 88 90 - func (h *handlerSet) OnPopupSize(_ purecef.Browser, _ uintptr) {}89 + func (h *handlerSet) OnPopupSize(_ purecef.Browser, _ *purecef.Rect) {}91 90 92 // 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 93 // to the render pipeline for GPU upload. 92 // to the render pipeline for GPU upload. 94 - func (h *handlerSet) OnPaint(_ purecef.Browser, _ purecef.PaintElementType, dirtyRects []purecef.Rect, buffer unsafe.Pointer, width int32, height int32) {93 + // NOTE: dirty rects are still count+pointer (uintptr) because the purego-cef 95 - // Convert purecef.Rect (which has HostLayout padding) to our local rect type. 94 + // parser doesn't preserve the C type for this parameter yet. Decode manually. 96 - 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) {97 - for i, dr := range dirtyRects { 96 + var rects []rect 98 - 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 + } 99 } 105 } 100 h.wv.pipeline.handlePaint(buffer, width, height, rects) 106 h.wv.pipeline.handlePaint(buffer, width, height, rects) 101 } 107 } 102 108 103 - func (h *handlerSet) OnAcceleratedPaint(_ purecef.Browser, _ purecef.PaintElementType, _ int, _ uintptr, _ uintptr) {109 + func (h *handlerSet) OnAcceleratedPaint(_ purecef.Browser, _ purecef.PaintElementType, _ int, _ uintptr, _ *purecef.AcceleratedPaintInfo) {104 } 110 } 105 111 106 - func (h *handlerSet) GetTouchHandleSize(_ purecef.Browser, _ purecef.HorizontalAlignment, _ uintptr) {112 + func (h *handlerSet) GetTouchHandleSize(_ purecef.Browser, _ purecef.HorizontalAlignment, _ *purecef.Size) {107 } 113 } 108 114 109 - func (h *handlerSet) OnTouchHandleStateChanged(_ purecef.Browser, _ uintptr) {}115 + func (h *handlerSet) OnTouchHandleStateChanged(_ purecef.Browser, _ *purecef.TouchHandleState) {}110 116 111 func (h *handlerSet) StartDragging(_ purecef.Browser, _ purecef.DragData, _ purecef.DragOperationsMask, _ int32, _ int32) int32 {117 func (h *handlerSet) StartDragging(_ purecef.Browser, _ purecef.DragData, _ purecef.DragOperationsMask, _ int32, _ int32) int32 {112 return 0 118 return 0 ⋯ 3 hidden lines@@ -116,10 +122,10 @@ func (h *handlerSet) UpdateDragCursor(_ purecef.Browser, _ purecef.DragOperation 116 122 117 func (h *handlerSet) OnScrollOffsetChanged(_ purecef.Browser, _ float64, _ float64) {}123 func (h *handlerSet) OnScrollOffsetChanged(_ purecef.Browser, _ float64, _ float64) {}118 124 119 - func (h *handlerSet) OnImeCompositionRangeChanged(_ purecef.Browser, _ uintptr, _ int, _ uintptr) {125 + func (h *handlerSet) OnImeCompositionRangeChanged(_ purecef.Browser, _ *purecef.Range, _ int, _ uintptr) {120 } 126 } 121 127 122 - func (h *handlerSet) OnTextSelectionChanged(_ purecef.Browser, _ string, _ uintptr) {}128 + func (h *handlerSet) OnTextSelectionChanged(_ purecef.Browser, _ string, _ *purecef.Range) {}123 129 124 func (h *handlerSet) OnVirtualKeyboardRequested(_ purecef.Browser, _ purecef.TextInputMode) {}130 func (h *handlerSet) OnVirtualKeyboardRequested(_ purecef.Browser, _ purecef.TextInputMode) {}125 131 ⋯ 50 hidden lines@@ -176,22 +182,22 @@ func (h *handlerSet) OnConsoleMessage(_ purecef.Browser, _ purecef.LogSeverity, 176 return 0 182 return 0 177 } 183 } 178 184 179 - func (h *handlerSet) OnAutoResize(_ purecef.Browser, _ uintptr) int32 { return 0 }185 + func (h *handlerSet) OnAutoResize(_ purecef.Browser, _ *purecef.Size) int32 { return 0 }180 186 181 // OnLoadingProgressChange updates the cached progress value. 187 // OnLoadingProgressChange updates the cached progress value. 182 func (h *handlerSet) OnLoadingProgressChange(_ purecef.Browser, progress float64) {188 func (h *handlerSet) OnLoadingProgressChange(_ purecef.Browser, progress float64) {183 h.wv.updateProgress(progress) 189 h.wv.updateProgress(progress) 184 } 190 } 185 191 186 - func (h *handlerSet) OnCursorChange(_ purecef.Browser, _ uintptr, _ purecef.CursorType, _ uintptr) int32 {192 + func (h *handlerSet) OnCursorChange(_ purecef.Browser, _ uintptr, _ purecef.CursorType, _ *purecef.CursorInfo) int32 {187 return 0 193 return 0 188 } 194 } 189 195 190 func (h *handlerSet) OnMediaAccessChange(_ purecef.Browser, _ int32, _ int32) {}196 func (h *handlerSet) OnMediaAccessChange(_ purecef.Browser, _ int32, _ int32) {}191 197 192 - func (h *handlerSet) OnContentsBoundsChange(_ purecef.Browser, _ uintptr) int32 { return 0 }198 + func (h *handlerSet) OnContentsBoundsChange(_ purecef.Browser, _ *purecef.Rect) int32 { return 0 }193 199 194 - func (h *handlerSet) GetRootWindowScreenRect(_ purecef.Browser, _ uintptr) int32 { return 0 }200 + func (h *handlerSet) GetRootWindowScreenRect(_ purecef.Browser, _ *purecef.Rect) int32 { return 0 }195 201 196 // =========================================================================== 202 // =========================================================================== 197 // LoadHandler (4 methods) 203 // LoadHandler (4 methods) ⋯ 56 hidden lines@@ -254,7 +260,7 @@ func (h *handlerSet) OnLoadError(_ purecef.Browser, _ purecef.Frame, _ purecef.E 254 // =========================================================================== 260 // =========================================================================== 255 261 256 // OnBeforePopup blocks all popups in Phase 1. 262 // OnBeforePopup blocks all popups in Phase 1. 257 - func (h *handlerSet) OnBeforePopup(_ purecef.Browser, _ purecef.Frame, _ int32, _ string, _ string, _ purecef.WindowOpenDisposition, _ int32, _ uintptr, _ *purecef.WindowInfo, _ unsafe.Pointer, _ *purecef.BrowserSettings, _ unsafe.Pointer, _ unsafe.Pointer) bool {263 + func (h *handlerSet) OnBeforePopup(_ purecef.Browser, _ purecef.Frame, _ int32, _ string, _ string, _ purecef.WindowOpenDisposition, _ int32, _ *purecef.PopupFeatures, _ *purecef.WindowInfo, _ unsafe.Pointer, _ *purecef.BrowserSettings, _ unsafe.Pointer, _ unsafe.Pointer) bool {258 return true // block 264 return true // block 259 } 265 } 260 266