Dirctory structure: Mozilla Source Code Directory Structure
Another: Source code directories overview
Interesting:
browser - Firefox
xulrunner - xulrunner
widget - a cross-platform API, with implementations on each platform, for dealing with operating system/environment widgets, i.e., code related to creation and handling of windows, popups, and other native widgets and to converting the system's messages related to painting and events into the messages used by other parts of Mozilla (e.g. view/ and content/, the latter of which converts many of the messages to yet another API, the DOM event API).
gfx - contains interfaces that abstract the capabilities of platform specific graphics toolkits, along with implementations on various platforms. These interfaces provide methods for things like drawing images, text, and basic shapes. It also contains basic data structures such as points and rectangles used here and in other parts of Mozilla.
It is also the home of the new graphics architecture based on cairo (via a C++ wrapper called thebes). See NewGFXAPIs and GFXEvolution.
Not so interesting:
view - view manager. Contains cross-platform code used for painting, scrolling, event handling, z-ordering, and opacity. Soon to become obsolete, gradually.
docshell - Implementation of the docshell, the main object managing things related to a document window. Each frame has its own docshell. Contains methods for loading URIs, managing URI content listeners, etc. It is the outermost layer of the embedding API used to embed a Gecko browser into an application.
webshell - Mostly obsolete, and being merged into docshell/.
IRC: irc.mozilla.org, channel #developers
wtorek, 17 listopada 2009
poniedziałek, 16 listopada 2009
How to: Set Breakpoints on a Memory Allocation Number
When you get this:Just set _crtBreakAlloc to the allocation number (130 in the example). There are three possibilities:To enable memory leak detection use this:_CRTDBG_MAP_ALLOC makes dumps more readable. With it:Without it:MSDN Article: How to: Set Breakpoints on a Memory Allocation Number
MSDN Article: Memory Leak Detection Enabling
MSDN Article: Memory Leak Detection Enabling
niedziela, 15 listopada 2009
Syntax highlighter test
Syntax highlighter test: Worked!
This is an example of my GreaseMonkey script BloggerHighlightAid.user.js in connection with SyntaxHighlighter. My script interprets every <blockquote/> element in the post as a C++ listing - very handy. For it to work properly one must enable “Show HTML literally”and "Convert newlines to <br />" in post options.
This is an example of my GreaseMonkey script BloggerHighlightAid.user.js in connection with SyntaxHighlighter. My script interprets every <blockquote/> element in the post as a C++ listing - very handy. For it to work properly one must enable “Show HTML literally”and "Convert newlines to <br />" in post options.
Gecko window creation and destruction
My current assumptions on this matter:
1. Instantiate your own implementation of nsIWebBrowserChrome.2. Create nsIWebBrowser:3. Tell nsIWebBrowser what chrome it's in:4. Query nsIBaseWindow from nsIWebBrowser:5. Create native window: hWnd.
6. Tell nsIBaseWindow to create browser window - a child of hWnd:7. Add listeners of your choice (if you want):8. Update size of browser window based on native window (see Resizing browser window):9. Show native window:
1. Instantiate your own implementation of nsIWebBrowserChrome.2. Create nsIWebBrowser:3. Tell nsIWebBrowser what chrome it's in:4. Query nsIBaseWindow from nsIWebBrowser:5. Create native window: hWnd.
6. Tell nsIBaseWindow to create browser window - a child of hWnd:7. Add listeners of your choice (if you want):8. Update size of browser window based on native window (see Resizing browser window):9. Show native window:
sobota, 14 listopada 2009
Some interesting Gecko interfaces
Interfaces reference: Mozilla Embedding API Reference
Interfaces reference: XPCOM API Reference
Mandatory: you have to implement those on one object - the Chrome.
nsIWebBrowserChrome - this interface must be implemented by the embedder in a class that also implements
Interfaces reference: XPCOM API Reference
Mandatory: you have to implement those on one object - the Chrome.
nsIWebBrowserChrome - this interface must be implemented by the embedder in a class that also implements
nsIEmbeddingSiteWindow. It corresponds to the top-level, outermost window containing an embedded Gecko WebBrowser (aka. Chrome).nsIEmbeddingSiteWindow - this interface is implemented by the embedder to provide Gecko with the means to call up to the host to resize the window, hide or show it and set/get its title.
nsIInterfaceRequestor - implements GetInterface(). Don't know why this is mandatory, but I know that without it the browser shows, but on first interaction crashes.
Those are provided:
nsIBaseWindow - window manipulations (size/visibility) for the browser.
Optional: window creation. Dunno when they are used:
nsIWindowCreator - this is a embedder-provided callback interface used by Gecko to create new browser windows in certain specific circumstances, like in utilizing PSM. A WindowWatcher component must also be available, and must be notified of the
nsIWindowCreator during application initialization.nsIWindowWatcher - this interface keeps track of Gecko/DOM Windows. It is a service that maintains a list of open top-level windows, and allows some operations on them.
This component must be initialized at application startup by calling
setWindowCreator.Optional:
nsIWebBrowserChromeFocus - this interface represents focus up-calls from Gecko to the embedding chrome. It is is implemented by the same embedder-provided object that implements nsIEmbeddingSiteWindow.
Listeners: those are optional too.
nsIWebProgressListener
nsISHistoryListener
nsIContextMenuListener
nsITooltipListener
To play with listeners you have to (I think...) implement nsISupportsWeakReference. Easiest way to do it is to use class nsSupportsWeakReference.
Interesting:
nsIDOMWindow
nsIDOMDocument
nsIEmbeddingSiteWindow2 - ???
nsIObserver - use this to observe i.e. profile directory changes or something... (WinEmbed example shows how).
Obsolete:
nsIWebBrowserSiteWindow - it was replaced by nsIEmbeddingSiteWindow.
"A new interface has been checked in called nsIWebBrowserSiteWindow. This
is a cut-down version of the nsIBaseWindow containing only the methods
that an embedding client needs to implement."
Question:
There are those two methods:Why both? What is the difference?
piątek, 13 listopada 2009
nsCOMPtr: AddRef, Release and QueryInterface
Here's the ultimate tutorial for nsCOMPtr: Using nsCOMPtr - Getting Started Guide
Vars:Assignment:Output parameters (GetFoo() adds reference itself, so tell nsFoo not to):Return values (CreateFoo() adds reference itself, so tell nsFoo not to):Four ways to QueryInterface:QueryInterface and GetInterface:
Helper: do_GetInterface( )
Caution: most frequent leaks are caused by assigning a raw pointer you have already A ddRefed:
Vars:Assignment:Output parameters (GetFoo() adds reference itself, so tell nsFoo not to):Return values (CreateFoo() adds reference itself, so tell nsFoo not to):Four ways to QueryInterface:
getInterface is very similar to QueryInterface. The main difference is that interfaces returned from getInterface are not required to provide a way back to the object implementing nsIInterfaceRequestor. The semantics of QueryInterface dictate that given an interface A that you QueryInterface on to get to interface B, you must be able to QueryInterface on B to get back to A. nsIInterfaceRequestor, however, allows you to obtain an interface C from A that may (or most likely) will not have the ability to get back to A.C
Gecko SDK strings
Gecko string reference: Mozilla internal string guide
When embedding Gecko one should use nsEmbedString and nsEmbedCString I think. But the're just typedef's for nsString and nsCString.
nsString is a UTF16 string (Gecko's "native").
nsCString is a single-byte string (ASCII).
(They extend nsAString and nsACString, which are abstract themselves.)
They both have a get() method to get their null-terminated contents.
How to convert them? UTF16 -> ASCII:The other way, ASCII -> UTF16:See code: xulrunner-1.9.1.3-source\mozilla-1.9.1\embedding\tests\winEmbed\winEmbed.cpp, function UpdateStatusBarText() and OpenWebPage()
When embedding Gecko one should use nsEmbedString and nsEmbedCString I think. But the're just typedef's for nsString and nsCString.
nsString is a UTF16 string (Gecko's "native").
nsCString is a single-byte string (ASCII).
(They extend nsAString and nsACString, which are abstract themselves.)
They both have a get() method to get their null-terminated contents.
How to convert them? UTF16 -> ASCII:The other way, ASCII -> UTF16:See code: xulrunner-1.9.1.3-source\mozilla-1.9.1\embedding\tests\winEmbed\winEmbed.cpp, function UpdateStatusBarText() and OpenWebPage()
Subskrybuj:
Posty (Atom)