autocmd: implement new LoadStarting event
authorPatrick Steinhardt <ps@pks.im>
Sat, 14 Sep 2019 09:46:35 +0000 (11:46 +0200)
committerPatrick Steinhardt <ps@pks.im>
Mon, 11 Nov 2019 13:39:45 +0000 (14:39 +0100)
commit69ab0df7118ec9781362f1c3afc0a698836d8264
tree4f47b6a5c1cca1cc9196ea34511b148f39a5d415
parent9241283fb6ffe68779b50444a77502372aeaa314
autocmd: implement new LoadStarting event

The first autocommand event that is being triggered when loading a
website is the "LoadStarted" event. LoadStarted gets triggered when the
web view has started loading of the page, notably after the initial
request has been sent. Thus, this event comes too late to change
settings that would modify the initial request, like e.g. the user
agent.

Implement a new event LoadStarting that triggers immediately before
performing the initial load and thus before LoadStarted. As WebKit does
not provide any signal for this, we have to manually trigger this event
when executing any load or navigation actions. The best place to
piggy-back on WebKit itself is in fact `decide_navigation_action`, which
will get executed on clicks, history navigation and `load_uri`. Like
this, there is only a single location that needs to trigger the new
event.

This change enables one to modify configuration like the user agent for
certain websites, which was not possible with "LoadStarted".
doc/vimb.1
src/autocmd.c
src/autocmd.h
src/main.c