Tuesday, February 26, 2008

Creating a new tag

I've been searching around the code for places which would need to be edited in order to create a new HTML element. I found the WebKit/WebCore/html directory which contains classes for all the elements. I also found some of the classes in the WebKit/WebCore/rendering directory. HTML elements seem to derive from the HTMLElement base class. Next, I picked an HTML element which I would like to "clone." My approach is basically to create a simple element achieved by copying a current element and renaming the classes and files. I chose to grep for the HTMLHeadElement which is one the simplest elements. I found references in more places than just the WebKit/WebCore directory. However, because the WebOpenGL element will resemble the HTMLCanvasElement more closely, I decided to repeat the grep search for this element. The results showed that most files which had references to HTMLHeadElement also had references to HTMLCanvasElement, but, there were files unique to each set of results. Curious, I also searched for references to HTMLDivElement and HTMLParagraphElement. These results were closer to the results from HTMLHeadElement--there were more files in common. There were a set a files that were unique to the results from the HTMLCanvasElement which makes sense since it is quite a different tag from head, div, and p. As I mentioned my project is more like the HTMLCanvasElement so I've decided that I'm going to "clone" the HTMCanvasElement instead of the HTMLHeadElement.

Monday, February 11, 2008

It starts

So in order to get this project started the first thing I did was, well naturally, download WebKit. That took about two hours. Haha. Well I guess I have time to talk about what it is that I'm going to do (or plan to do) with WebKit. In short, the plan is to enable the OpenGL API for WebKit-based Web browsers. So, a developer would be able to write an OpenGL program but instead of the rendering happening in a window provided by the operating system it would happen inside the Web browser.
After the downloading came the compiling. I ran into some difficulties because the environment for Linux has to be setup differently. Specifically, I had to install the QT development libraries and set the appropriate environment variables. The WebKit installation instructions didn't provide any help when I first ran into compiling problems, but , as always, Google helped me find the way. I eventually came across a post which explained what I need to do. The compilation took about another hour.
After that I had similar problems running the bare-bones browser which comes with
WebKit. The solution, again, was in setting up the correct environment variables.
After ensuring everything was up and running I started looking at the code structure in order to figure out where I would have to insert code to create the new OpenGL HTML tag. I searched for the HTML Canvas code by greping for the clearRect method which is specific to the Canvas API. I found two main places where the code laid. The first is WebKit/WebCore/html which is where the code for each of the HTML elements lives. The second is /WebKit/WebCore/rendering which is where the code that actually does the rendering for the HTML Canvas tag lives. I looks like it is within these two directories that the majority of the WebOpenGL code will reside.