Samphan Raruenrom wrote:

I know nothing about XPCOM but I think my problem may be able to use
the approach. We, Thai developers, want to patch Mozilla and add ICU
for Mozilla to be able to word-wrap Thai text (serious problem for Thai).
However, ICU is too big to be incorporated into Mozilla so
the approach seems to be impossible.
https://bugzilla.mozilla.org/show_bug.cgi?id=7969
Currently, we have to make custom builds of Firefox with this patch,
update them every new Firefox releases.

I just have another idea, instead of putting the code in Mozilla core,
why not put it in an extension - Thai line-breaking extension.

The extension will do this :-
1) It'll implement the interface nsILineBreaker, using ICU for Thai line
breaking. Layout will use it instead of the existing one.
2) It'll register the new interface in the service NS_LWBRK_CONTRACTID,
so nsDocument::GetLineBreaker() will get the new implementation from
the extension instead.
(Sorry If I don't use the right words technically)

Is this possible? Is it possible to replace the interface implementation from
an extension?

Yes, it is certainly possible, and the technique you describe is correct (implement the interface and register for the correct contractID).

Note, however, that sometimes the "client" code which is supposed to get XPCOM components by contractid gets them through other methods (by implementation CID or whatnot). You should check the client (layout) code to make sure that it gets the service by contractID.

It appears that the layout code gets the service correctly: http://lxr.mozilla.org/mozilla/source/content/base/src/nsContentUtils.cpp#208

As does the editor code: http://lxr.mozilla.org/mozilla/source/editor/libeditor/text/nsWrapUtils.cpp#60

--BDS
_______________________________________________
Mozilla-xpcom mailing list
Mozilla-xpcom@mozilla.org
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to