📜 ⬆️ ⬇️

WebView or a story about how the browser was written in KolibriOS

Perhaps everyone who is interested in KolibriOS knows that the only way to access the global network was and is and sow the day a text browser written by one of our developers from scratch. This browser is probably one of the “attractions” of the OS, and therefore it was decided to tell its story: how it appeared, developed, and what are the plans for the near future. Who cares, welcome under cat.

The post was created in close cooperation with the author of the Leency program, and therefore the narration comes from his face.

If I hadn’t been such a naive fool, I would never have taken up writing a browser! Another diamond (@grechnik), an experienced programmer, said that in life he would not have decided on such an adventure. But I was young and felt that I was on the verge of great discoveries. It is an indescribable feeling, as if the whole world is at my feet — all you have to do is stretch out your hand and it is all yours. Therefore, the first program I decided to write was a file manager for Windows Explorer, and the second was a browser. So to say, “Hello World” is a job for wimps, cool programmers start with browsers.
')
All this misfortune began on a warm July day in 2008, six months after Kostya Veliant dropped the HTML viewer source code to me, the possibilities of which, except for the lack of network support, were almost equal to the current at that time Hummingbird HTTPC.


This program was simply called "HTML Viewer in C--". I began by adapting the program code to the new version of the library (menuet.h-- → kolibri.h--), improved the design, added support for the control keys, and scrolled the wheel. Of the minuses - the text was displayed in the window one by one :)

Below is a screenshot of the first version of 0.00001, released June 20, 2008.


Already after 2 days there was an update to version 0.1 in the list of changes which was:



In version 0.2, the text was not displayed letter by letter, but by lines, added the collapse of two or more consecutive gaps into one.

The subsequent development of the program proceeded in an evolutionary way: tag support improved, the Back button earned, support for relative paths, several tag parameters, multi-level lists, and some other features appeared.

By the way, I note that all this time the program was not a browser, but only displayed HTML pages, hence the name HTMLv (HTML Viewer). The turning point happened in version 0.48.5, thanks to barsuk 'for:

“I took HTTPC, cut off the html display and screwed dynamic memory allocation for the web page. If you combine this with HTMLv, you’ll have a browser. ”

What was done. Clipped HTTPC was named the file uploader and renamed to the downloader. And here are the first screenshots of the pages loaded by the browser via the downloader:







The “HTMLv + downloader” bundle worked like hell: if the page address starts with 'http: //', then HTMLv started the downloader with the page address parameter. Downloader downloaded the file, HTMLv humbly waited. When the downloader finished, it saved the page in '/sys/.download' and closed. HTMLv fired this moment and opened the saved page.

Yes, it is wildly crutch, but it worked! It was the first real way to get on the Internet with a Hummingbird and had difficulty reading something there. This may seem ridiculous, but it was an important psychological moment - now in the Hummingbird there is a window to the open world.

By the way, about the hacks ... Whoever is familiar with Colibri, knows very well that there has always been a problem with fonts: there are only two system fonts: monospaced and ... nonmonospaced. 90% uses monospace and the size of the letter in it is 6x9 pixels. No bold and italic. But it is in the browser! Bold typeface is two lines of text superimposed on each other with an offset of one pixel along the X axis. With italic, everything is somewhat more interesting. The first version was implemented by lev in version 0.63: first, plain text was displayed in the window, then the screen was screened in memory and then displayed again in the window with offset |||| → //////

Noviki of the next versions dealt with the addition of the PKM menu, support for anchors, image caching system.

Here is the screen of the test page acid_0.1.html, which has long been used to test the browser.


But the farther, the more the impression that I was going the wrong way ...


It was necessary to do something with it. Remember the beginning of the article? “Because the first program I decided to write was a file manager for Windows Explorer, and the second was a browser. So, the Eolite code was rewritten in an evolutionary way: step by step, piece by piece and over time it became logical, readable and simple. The HTMLv code still remained unstructured and was difficult to modify and maintain, and the addition of a new feature inevitably led to many problems. Having realized this moment with grief, I undertook to put it in order. The first sign in this difficult task was HTMLv 0.99.

In HTMLv 0.99, drawing to the clipboard was implemented. Those. Previously, a line of text was displayed as follows: a rectangle of background color is drawn into the window, and text is displayed on top. Now, however, a “picture” was created in the memory, filled with a background color, text and lines were drawn into it, and in the end this finished image was displayed in the window. This increased speed and will give new opportunities in the future.

Version 0.99.1 gained support for tags and, as well as align = "center" and align = "right"

In version 0.99.31, a significant event happened:
From this version, the WebView component, which displays the contents of the page in HTMLv, is moved to a separate module and can be compiled as part of another project in C--. This was done to display the contents of the letter in the mail client Liza and in order to improve the structure of the code.

Starting from version 1.0 beta 1, the program has been renamed to WebView. This was not done in vain, because the program has grown noticeably in the last couple of versions. In the same version, alongside the new name, the program received:



In subsequent versions, support for tags and fixes of problems, as well as doping of the new functionality was improved. The following significant change was made in WebView 1.0 Beta 4: viewing the source code of the page in a browser with syntax highlighting.


The latest version for today is WebView 1.0 Beta 6.1. It was carried out significant work to optimize the program.

Today, the author is working on the implementation of tabs and the display of pictures when browsing the web.

A small video review:

Source: https://habr.com/ru/post/218417/


All Articles