Creating a web browser using the Mozilla engine (also known as Gecko) can be done using the Mozilla API called XULRunner, which allows you to embed the Gecko layout engine in your own application. Here is some sample code that demonstrates how you can create a basic web browser using XULRunner:
#include <xul/xul.h>
#include <xul/gfx/gfx_utils.h>
int main(int argc, char* argv[]) {
xul::init(argc, argv);
xul::run_ui_loop();
//create window
xul::window* window = xul::create_window("Example browser", xul::rect(50, 50, 800, 600));
xul::browser* browser = xul::create_browser(window, xul::rect(0, 0, 800, 600));
browser->set_url("http://www.example.com");
//show window and run the UI loop
window->show();
xul::run_ui_loop();
//clean up
browser->destroy();
window->destroy();
xul::term();
return 0;
}
This is just a skeleton code and you should check the complete documentation and requirements before compiling and running your code. XULRunner also has many more features and functionalities available, like setting up custom event handlers, styling the UI, and many more. It’s also important to mention that the XULRunner is not maintained anymore, instead of it, Mozilla recommends using their new API called web-extensions which is based on javascript, but you still could use it on some versions of firefox.