Monday, April 4, 2011

Modifying Firefox Source Code - Tabs

Made a few modifications to Minefield as requested from OSD600. The first modification was to make new tabs appear next to your current tab rather than at the end of list. This was easy, considering we did this in class. Here's my diff:
diff -r 4e4c7457e8f7 browser/base/content/tabbrowser.xml
--- a/browser/base/content/tabbrowser.xml Sat Apr 02 11:48:22 2011 -0400
+++ b/browser/base/content/tabbrowser.xml Sun Apr 03 23:42:38 2011 -0400
@@ -1327,27 +1327,25 @@
// activeness in the tab switcher.
b.docShell.isActive = false;

// Check if we're opening a tab related to the current tab and
// move it to after the current tab.
// aReferrerURI is null or undefined if the tab is opened from
// an external application or bookmark, i.e. somewhere other
// than the current tab.
- if ((aRelatedToCurrent == null ? aReferrerURI : aRelatedToCurrent) &&
- Services.prefs.getBoolPref("browser.tabs.insertRelatedAfterCurrent")) {
+
let newTabPos = (this._lastRelatedTab ||
this.selectedTab)._tPos + 1;
if (this._lastRelatedTab)
this._lastRelatedTab.owner = null;
else
t.owner = this.selectedTab;
this.moveTabTo(t, newTabPos);
this._lastRelatedTab = t;
- }

return t;
]]>







Sure I could have just commented those lines out, but what are the odds I'm going to change it back?
The next mod was to change the controls for changing tabs by number. The original controls is to use Ctrl + #; I changed it to Alt + #. This isn't an efficient patch however, this is what Dave would call "repairing with a hammer" haha:
diff -r 4e4c7457e8f7 browser/base/content/browser-sets.inc
--- a/browser/base/content/browser-sets.inc Sat Apr 02 11:48:22 2011 -0400
+++ b/browser/base/content/browser-sets.inc Sun Apr 03 23:42:38 2011 -0400
@@ -354,21 +354,17 @@
#endif
#ifdef XP_UNIX

#endif




-#ifdef XP_GNOME
#define NUM_SELECT_TAB_MODIFIER alt
-#else
-#define NUM_SELECT_TAB_MODIFIER accel
-#endif

#expand
...

That's not the full diff, some of the tags didn't render as text. But the part I changed remains: change NUM_SELECT_TAB_MODIFIER from accel to alt.
I learned a few shortcuts while reading the source as well. For example, Ctrl+k will put focus on the Google search bar at the top right, and Alt+Home will redirect you to your home page.

No comments:

Post a Comment