niedziela, 22 listopada 2009

Perl, Ruby, Python Cookbook

There are cookbooks for almost any language here: PLEAC - Cookbooks

For example:
Ruby Cookbook
Python Cookbook
Perl Cookbook
C++ Cookbook

The Python Tutorial - often more helpful than library reference et. al. (i.e. Chapter 7: Input and Output).

sobota, 21 listopada 2009

Mozilla plugins refresh and stuff

To verify that Mozilla is aware of new .xpt files, you can look in the generated file, xpti.dat, where type libraries are listed. If you need to, you can call navigator.plugins.refresh() to find new XPT files and plug-in software.

Plug-in developers might find it useful for debugging purposes to turn off the exception catching mechanism currently implemented in Mozilla on Windows. To turn off Windows exception handling, add the following line into your prefs.js file: user_pref("plugin.dont_try_safe_calls", true);

wtorek, 17 listopada 2009

Mozilla Source Code Directory Structure

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

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

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.

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:

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 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:

nsIWebBrowser - embedders use this interface during initialization to associate the new WebBrowser instance with the embedder's chrome and to register any listeners. The interface may also be used at runtime to obtain the content DOM window and from that the rest of the DOM.

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?