Snippets code from my daily experience

March 11, 2008

XBL, CSS selectors priority and Firefox 3

Filed under: css,firefox,gecko,mozilla,xbl,xul — dafi @ 8:58 pm

I wrote a little XBL component to allow menuitems to have images centered, I added it to Firefox 2 browser context menu and worked fine immediately, after a while I installed component on Firefox 3 beta 4 and surprisingly the menuitem didn’t show the image 😦

I’ve asked help on Mozilla IRC and after about an hour the mistery was revealed.

The innocent CSS declaration shown below works fine on Firefox 2

.menuitem-image-center {
-moz-binding: url(‘chrome://morekomodo/content/bindings/menu.xml#menuitemImageCenterBinding’);
}

but requires a little modification on Firefox 3 beta 5pre (at this time the latest available)

.menuitem-image-center {
-moz-binding: url(‘chrome://morekomodo/content/bindings/menu.xml#menuitemImageCenterBinding’)
!important;
}

You must notice the selector without !important attribute works on Firefox 3 when applied on menus different from browser context menu.

I suspect the browser context menu should have some special treatment on new Firefox…

Context menu

February 15, 2008

RichScrollbar sunset

Filed under: extension,richscrollbar,xbl — dafi @ 6:21 pm

RichScrollbar extension, RSB for friends, is quite simple and not intrusive but technically is a big compromise.
It is written as  XBL component and runs inside chrome context and  browser content context.

Under Firefox 3 beta1 and beta2 RSB after some fix worked like a charm, when beta3 arrived RSB was broken.

Mark Finkle helped me to understand why RSB didn’t work and we discover FF3 fixed a security bug on XBL.

Now it is impossible to make RSB functional on browser windows, it works only on chrome dialogs.

I surrend, period! I have not enough technical knowledge to dig for a workaround.

I consider terminated the RSB development, the XBL documentation is poor and all my help requests haven’t received reply except Mark.

Honestly I’m sad, I love RSB and I prefer it to Mouse Gestures, I’ll continue to search for a fix but it is very difficult to find.

Mark helped me and I would say thank to him, great people work at Mozilla.

December 20, 2007

Firefox 3 and broken extensions

When I started Richscrollbar (RSB for friends) development I could not figure out a so difficult programming life cycle.

After all its task is simple, add extra buttons to browser scrollbars to speedup movements inside web page.

Gecko is affect by a bug that reduces RSB productivity dramatically but I’ve created it anyway.

Now I discover RSB totally doesn’t work with Firefox 3 beta 2, Mozilla guys changed API and I suspect introduced some regression.

Obviously it is impossibile to explain the problem to Mozilla, they are so busy to fight against the world.

After some frustrating debug I found the problems and fixed them.

Problem nr 1.

The nsIStyleSheetService.USER_AGENT has changed behaviour without documenting it (at least at this date)

I used USER_SHEET in Firefox 2 but under FF3 the same code simply doesn’t work.

I’ve replaced it with the other flag AGENT_SHEET and magically RSB started to work.

Where can I read the new behaviour? Damned Mozilla 😛

Problem nr 2.

An horizontal useless scrollbar is always visible only on tab window open at browser startup, if user opens new tab and/or windows this dumb doesn’t appear, sigh!

I found a reasonable workaround hiding the scrollbar inside the notificationbox component.

I hope to publish the fixed RSB on this weekend.

Create a free website or blog at WordPress.com.