This bug can be worked around by saving the HTML to file and loading that in the gadget using SetGadgetText, but still.
This bug was also present with PB6.2, and probably before that.
Code: Select all
Macro ImageAsPNGDataURI(img,var,pngdepth)
UsePNGImageEncoder()
*mem = EncodeImage(img,#PB_ImagePlugin_PNG,0,pngdepth)
var = "data:image/png;base64,"+Base64Encoder(*mem,MemorySize(*mem))
FreeMemory(*mem)
EndMacro
Procedure.s WVG_LoadHTML(html.s)
Static win.i
Static wg.i
If wg=0
ww=1600 : wh=1200
win = OpenWindow(#PB_Any,0,0,ww,wh, "WebViewGadget")
wg = WebViewGadget(#PB_Any,0,0,ww,wh)
EndIf
SetWindowTitle(win,"HTML length: "+Str(Len(html)))
SetGadgetItemText(wg,#PB_WebView_HtmlCode,html)
EndProcedure
; this will work
h.s = "<body onload="+Chr(34)+"alert('loaded 1')"+Chr(34)+"></body>"
WVG_LoadHTML(h)
For a = 1 To 100 : WaitWindowEvent(50) : Next a
; this will not work
iw = 1200
ih = 1000
img.i = CreateImage(#PB_Any,iw,ih,32)
StartDrawing(ImageOutput(img))
DrawingMode(#PB_2DDrawing_AlphaBlend)
For a = 1 To 1000
bx = Random(iw)
by = Random(ih)
bw = Random(50,10)
bh = Random(50,10)
Box(bx,by,bw,bh,RGBA(Random(255),Random(255),Random(255),Random(255)))
Next a
For x = 0 To iw-1
For y = 0 To ih-1
Plot(x,y,RGBA(0,0,0,Random(128)))
Next y
Next x
StopDrawing()
ImageAsPNGDataURI(img,du.s,32)
FreeImage(img)
h.s = "<body onload="+Chr(34)+"alert('loaded 2')"+Chr(34)+"><img src='"+du+"' /></body>"
du="" ; free memory
WVG_LoadHTML(h)
Repeat
WaitWindowEvent(50)
Until GetAsyncKeyState_(#VK_ESCAPE)