Implements HTMLDocument that makes HTML rendering. Wine's implementation uses Gecko (Mozilla's engine) to render HTML.

MSHTML DOM Develop Hints

This is not a detailed development document, but just some hints for fresh person who are interested in mshtml.dll. If you have any questions, please feel free to ask ZhenboLi, the writer of this article.


0. Know a little C

1. Know how to compile wine

2. wine_gecko-*.msi is laying in ~/.cache/wine (maybe changed on your computer)

Easy Start

Go to wine-git/dlls/mshtml, open htmltablerow.c. Find the function 'HTMLTableRow_get_rowIndex'

Well, This is my first patch for mshtml. You can find that it is just a wrapper for Gecko.

How to find the Gecko function? nsiface.[h|idl] will help you.


Data Types

It is common that you have to do some transform between WinAPI's data type and Gecko's. Here are some examples.


Windows uses BSTR mostly. However, the example in that page doesn't work in wine's code. You may need the reference in UnicodeSupport.

Mostly, Gecko needs nsAString. In wine-git/dlls/mshtml/nsembed.c, you can find functions like nsAString_InitDepent, nsAString_GetData, etc. Also, there are some useful helpers like return_nsstr.Example.


A 4-bit variable can cause 4 day extra work. You need to care about many tiny stuffs, like signed or unsigned, floats and integers. For these patches, you need to write a good test case.


Windows uses VARIANT_BOOL, while Gecko uses cpp_bool. Remember to care about the code style, or your tiny patch would be reject many times. Example


VARIANT is an important data type in COM. You can find many useful tools in include/oleauto.h. VARIANT can cause much troubles (for example, VariantClear is needed sometimes), and to ask is always better than sending a bad patch to wine-patches.


IDL is used for describing an interface. While building wine, nsiface.h would be generated by nsiface.idl(That's why nsiface.h is in .gitignore).

You need to care about IDL when dealing some bugs or adding elements. The format for Gecko is different from MIDL, so you'd better Build Gecko, and a header file would be generated. More information at Understanding Interface Definition Language


Instead of wrapping different Gecko APIs, we need to set different attributes with the same helper. Here is an example.

Mostly, you need to add these things:

  • New styleid_t in htmlstyle.h like STYLEID_LIST_STYLE
  • New attribute name in htmlstyle.c like attrListStyle[]
  • New entry for style_tbl in htmlstyle.c like {attrListStyle, DISPID_IHTMLSTYLE_LISTSTYLE}

Then you can call helpers like set_style_attr in function body.

WARNING: There may be many tricky traps like px_format. Be careful.

Conformance Tests

ConformanceTests is the most challenging part at beginning. And WineTestBot is your most reliable friend. Most situations are simple, but sometimes you need to be very careful to avoid breaking other tests. Also, you need to know how WinAPI handle errors, like NULL pointers, invalid parameters, etc. Remember, don't leak memory in tests.

See Also

CategoryDLLs CategoryNetworking

MsHtml (last edited 2015-01-08 08:09:07 by ZhenboLi)