can3p → Serenity

Thu, 17 Aug 2023 00:52

And this is why it's probably very different now since everything runs in it's own process etc. I've made a brief attempt to go through this part, here are the findings.

Thu, 17 Aug 2023 00:28

One more interesting bit from the video, here is more or less the snippet:

Core::EventLoop event_loop;

auto qt_event_loop_driver = Core::Timer::create_repeating(50, [&] {
    app->process_events()
})

qt_event_loop_driver->start();

return event_loop->exec()

There are multiple questions one may ask:

The answer to the second question is simple - there should be a global object somewhere and it's indeed there in form of EventLoopManager class that's implemented as a singleton per system.

So the whole sequence goes as the following:

Timer -> EventReceiver -> EventLoopManager

when an event loop is run it actually calls exec on EventLoopManager so even though it looks like you can have many event loops you actually cannot.

And EventLoopManager does the actual things described in the docs

Getting back to the first question: it was done most probably because the initial implementation had only one process and that was the easiest way to make resource loading work - make qt take a back seat and invoke it only to draw the window every now and then

Thu, 17 Aug 2023 00:12

Some hints in the first video on ladybird browser - https://www.youtube.com/watch?v=X38MTKHt3_I

What web engine does is it generates a bitmap given the html it loaded and parsed given the view port dimensions and that's all to it. The rendering engine uses a layout tree that was built during the parsing phase to actually render content in the image.

Now, the rendered content has to be put in the window somehow and that has to be hooked up with QT. That works with Webview class inheriting from QAbstractScrollArea and that one in turn allows to right the behavior for all kinds of nice events including paintEvent which is used to take the bitmap from the engine and render it on the window. How qt does that? No idea, most probably it has it's own render tree for all the widgets and this is where paintEvent stems from. Inside of it Andreas uses QPainter class and that one probably knows how to actually put stuff into graphics memory

Wed, 16 Aug 2023 23:05

I'm watching Andreas' hacking session and I'm apparently lacking something essential:

Dabdab.org (c) 2022 — 2023, hi@dabdab.org / Contact us / Twitter