Determining when an element is scrollable in Gecko

16 October, 2013 § 1 Comment

As a web developer, there are often times where it’s necessary to know if an element on a page is scrollable. One way of checking this would be to find the difference of element.scrollWidth and element.clientWidth. If the difference between these two properties is non-zero, then the element is scrollable. However, this doesn’t work for all cases.

In particular, element.scrollWidth and element.clientWidth clamp their values to integers. If the difference between the scrollWidth and clientWidth is less than zero, then the computed difference between the two will result in zero. This is less than good.

Starting in Firefox 16 [1], there is a new property element.scrollLeftMax which returns the difference of scrollWidth and clientWidth, including the fractional component. Also introduced is the companion element.scrollTopMax for use in determining vertical scrolling availability.

Hopefully these properties will find their way in to the other layout engines.

[1] These properties were implemented in bug 766937.

Student project: Australis-styled widgets

11 September, 2013 § 2 Comments

A couple weeks back, Gijs Kruitbosch and I began mentoring a group of students on a new student project focused on building some new Australis-styled widgets.

Team MSUThe team is comprised of students from Michigan State University’s Computer Science program. Pictured from left to right are Dan Poggi, Eric Proper, Eric Slenk, and Dave Thorpe.

The goal of the project will be to create four independent widgets using the Add-on SDK and new Australis widget API:

  1. A weather widget that can show the weather for a selected location as well as up to 5-7 additional locations. This will need to use a public and free weather API.
  2. A music playing widget that will play music located on the user’s local machine. The user can select a folder on their machine and the widget will play any media files that it can find within that folder or in that folder’s children. We may need to limit the recursive depth to 2 folders.
  3. A Bugzilla widget that will show the assigned bugs, review requests, etc. This will be based on Heather Arthur‘s excellent Bugzilla Todos dashboard.
  4. A Spartan Scoreboard widget that will show the date, opponent, and location of the next MSU sporting event, as well as the score of the previous game. It should also include a link to get more information.

Eric Proper, Eric Slenk, and David Thorpe have begun blogging about their progress. You can follow along and get more details on their respective blogs. Eric Proper has an amazing amount of detail already on his blog. I’m looking forward to seeing the blogs from Dan Poggi and Dave Thorpe.

We will be meeting weekly at 9:00am Eastern time on Thursdays throughout the Fall semester.

Backing up your contacts on FirefoxOS

25 July, 2013 § 19 Comments

I’ve been helping beta test B2G and subsequently FirefoxOS since October 2012.¬† Once in a while I’ve come across a bug that requires me to reset the phone back to its factory state. Unfortunately at this early stage there isn’t a built-in way to back up your data from a FirefoxOS phone. I’m sure it’s on a roadmap, but as with all v1 products you have to make some tough calls when it comes to feature prioritization.

This tutorial provides a step-by-step walk through of how to backup and restore your contacts on a B2G or FirefoxOS phone. It’s not supported so it may stop working in the future, but for now it works :)

To complete this tutorial you’ll need a B2G/FirefoxOS phone, a USB cable to connect your phone to your computer, and the Android Debug Bridge installed (referred to as `adb` later in the tutorial).

1. Start up your FirefoxOS phone and go to Settings.

step1

2. Go to Device Information

step2

3. Go to More Information

step3

4. Go to Developer

step4

5. Enable “Remote Debugging”. This will allow you to use ADB to pull data off of the phone.

step5

6. Connect your phone to the computer using the USB cable.

7. In your console, type `adb devices` to check that the phone has connected properly. You should see your phone listed as an attached device. At this point you can now use `adb shell` to browse through the system files on the phone.

8. Type `adb pull /data/local/indexedDB/chrome/3406066227csotncta.sqlite .` This will pull the contacts IndexedDB database off of your phone and in to your local working directory. If you are curious about the contents of the database, you can install the IndexedDB Browser add-on for Firefox which will let you open up the database.

2013-07-23_2109

And you are now done with backing up your contacts. If you need to reset your phone in the future, you can just follow these steps again but replace step 8 with the following: `adb push 3406066227csotncta.sqlite /data/local/indexedDB/chrome/3406066227csotncta.sqlite`. This will push your backed-up contacts database back on to the device.

Picking Up The Crumbs

17 June, 2013 § 24 Comments

A few days ago a new feature landed in Firefox Nightly that makes closing multiple tabs easier than it was before.

I often find myself in situations where I have multiple tabs that I opened only to look at for short periods of time. Sometimes I reach this state while reading articles on Hacker News or looking at funny pictures on Reddit. At the end of looking at the tabs, it would be nice if Firefox had a way to close these ephemeral tabs so you can get back to your previous work quicker.

Close Tabs to The Right

Well, Firefox now does! If you open lots of tabs from Reddit and then want to close all of the tabs to the right of Reddit, just right-click on the Reddit tab and choose “Close Tabs to the Right”. It’s easy and quick!

Why “close tabs to the right” and not “close tabs to the left”? When we open new tabs they appear on the end, and so naturally tabs that have a longer lifetime end up being promoted to the start-side of the bar. This leads us towards the situation where closing tabs “to the right” is a simple way of closing the ephemeral tabs.

Users who are using Firefox with a right-to-left locale such as Hebrew or Arabic should see the equivalent “Close Tabs to the Left” feature.

Huge thanks go out to Michael Brennan who contributed the patches and automated tests for this feature! Unless something drastic happens, this feature will find its way to Firefox Release in just over 12 weeks in Firefox 24.

XPCShell test output changes

13 June, 2013 § Leave a comment

Those of you using XPCShell tests may notice some slightly improved output from the test macros that landed recently on mozilla-central.

Previously, if you called do_check_null(null), you would get an output that was similar to:

[TEST-PASS] null == null

However, if you tried do_check_null("null"), you would get an output that was similar to:

[TEST-FAIL] null == null

This isn’t very helpful, and I ran into this exact issue while working on some code that uses observers. Since the data is passed as JSON, when JSON.stringify(null) is called the result is “null”. The test runner showing null == null as a failure isn’t too helpful :-P

With this recent change, all string arguments will be adorned with double-quotes.

This means that calling do_check_null("null") will now output:

[TEST-FAIL] "null" == null

The same change was made for all of the other do_check_* and do_print macros.

Where Am I?

You are currently browsing entries tagged with mozilla at JAWS.

Follow

Get every new post delivered to your Inbox.

Join 99 other followers