This is a step list explaining how to implement a new
HTML attribute
for WebKit.
I’m going to use
QtWebKit
for this execise but this approach is generic enough to be used for any other backend.
Here is a note for building Qt and QtWebKit on Ubuntu Linux.
First, check if we could build WebKit and test the build with MiniBrowser.
Build WebKit
1 |
|
Test WebKit
1 |
|
Now let’s start implementing the new attribute.
I’m going to add this new attribute to
the HTML object element
The code we are going to modify lives here:
Source/WebCore/html
Add token for the new attribute
In file
HTMLAttributeNames.in
add line:
1 |
|
Add rule for the new attribute
In file
HTMLObjectElement.idl
add line:
1 |
|
Add code to support the new attribute
In file
HTMLObjectElement.h
add:
1 |
|
In file
HTMLObjectElement.cpp
add a new method HTMLObjectElement::setAltSrcAttr :
1 |
|
and change HTMLObjectElement::parseAttribute method to support the new attribute:
1 |
|
Test
Create a new file index.html
1 |
|
and place it somewhere
1 |
|
Build and install WebKit with all our changes.
1 |
|
Run MiniBrowser.
1 |
|
You should see this console output:
1 |
|