-
Notifications
You must be signed in to change notification settings - Fork 27
High Level Overview
When WebWhirr is started, a filepath is passed to the parser (either through the command line or through a dialog).
First, the entire document is read into a single string. Then, this string is parsed one character at a time. As the parser encounters different characters, it enters different states. Then, depending on the current state and character, a different action is taken as needed. For example, if the "<" character is hit in the "text" state, the parser then enters the "end tag state," which signals that it is time for a tag somewhere to be closed.
The parser is also responsible for the creation of "nodes." There are two types of nodes, render nodes and paint nodes.
A render node corresponds to a tag in the HTML document--for example, each <p> tag gets its own "ParagraphNode." A render node contains all of the information necessary to paint that node. This is done through each render node's vector of paint nodes.
A paint node can either contain a character or another node. It also contains information about how to display its child--for example, if the paint node is a character within a BNode, it contains a flag that sets the painter to bold.
Once the parser has converted the document into a tree of RenderNodes, this tree is passed to the painter
The painter reads through the tree of render nodes and attempts to paint each paint node from each of the render nodes. If the paint node's child is another render node, the painter paints each of that node's paint nodes. If the paint node's child is a character (or other paintable item), the painter draws that character to the screen, changes where the next item will be drawn, and moves to the next paint node. It moves like this throughout the entire tree.