Merging mozilla-central once more to hopefully clear windows unit tests
authorBen Turner <bent.mozilla@gmail.com>
Sun, 20 Sep 2009 10:47:21 -0700
changeset 35935 1eda83c8ac45bc9a8af28327d40b9145d7aaef96
parent 35934 4ed2794d25e1c0aa65ef14b750b999365ec502c5 (current diff)
parent 32889 9061f43b86bde33c076e9e1144821ab8c66e9307 (diff)
child 35936 dceadb5a4be7b8ecd895c2c8cd477b7cb444528b
push idunknown
push userunknown
push dateunknown
milestone1.9.3a1pre
Merging mozilla-central once more to hopefully clear windows unit tests
accessible/tests/mochitest/test_accessnode_invalidation.html
browser/components/preferences/securityWarnings.js
browser/components/preferences/securityWarnings.xul
browser/locales/en-US/chrome/browser/preferences/securityWarnings.dtd
build/unix/mozilla-config.in
build/unix/nspr_my_config.mk.in
build/unix/nspr_my_overrides.mk.in
config/autoconf.mk.in
configure.in
js/src/xpconnect/shell/Makefile.in
modules/plugin/base/src/Makefile.in
netwerk/build/Makefile.in
toolkit/library/libxul-config.mk
toolkit/toolkit-tiers.mk
--- a/accessible/src/base/nsAccessible.h
+++ b/accessible/src/base/nsAccessible.h
@@ -198,19 +198,18 @@ public:
                                    PRBool aDeepestChild,
                                    nsIAccessible **aChild);
 
   //////////////////////////////////////////////////////////////////////////////
   // Initializing and cache methods
 
   /**
    * Set accessible parent.
-   * XXX: shouldn't be virtual, bug 496783
    */
-  virtual void SetParent(nsIAccessible *aParent);
+  void SetParent(nsIAccessible *aParent);
 
   /**
    * Set first accessible child.
    */
   void SetFirstChild(nsIAccessible *aFirstChild);
 
   /**
    * Set next sibling accessible.
--- a/accessible/src/html/nsHTMLTextAccessible.cpp
+++ b/accessible/src/html/nsHTMLTextAccessible.cpp
@@ -227,19 +227,20 @@ nsHTMLLIAccessible::nsHTMLLIAccessible(n
       mBulletAccessible->Init();
   }
 }
 
 nsresult
 nsHTMLLIAccessible::Shutdown()
 {
   if (mBulletAccessible) {
-    // Ensure that weak pointer to this is nulled out
+    // Ensure that pointer to this is nulled out.
     mBulletAccessible->Shutdown();
   }
+
   nsresult rv = nsLinkableAccessible::Shutdown();
   mBulletAccessible = nsnull;
   return rv;
 }
 
 nsresult
 nsHTMLLIAccessible::GetRoleInternal(PRUint32 *aRole)
 {
@@ -278,47 +279,44 @@ void nsHTMLLIAccessible::CacheChildren()
   if (!mWeakShell || mAccChildCount != eChildCountUninitialized) {
     return;
   }
 
   nsAccessibleWrap::CacheChildren();
 
   if (mBulletAccessible) {
     mBulletAccessible->SetNextSibling(mFirstChild);
-    mBulletAccessible->SetParent(this); // Set weak parent;
+    mBulletAccessible->SetParent(this);
     SetFirstChild(mBulletAccessible);
     ++ mAccChildCount;
   }
 }
 
 
 // nsHTMLListBulletAccessible
 nsHTMLListBulletAccessible::
   nsHTMLListBulletAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell,
                              const nsAString& aBulletText) :
-    nsLeafAccessible(aDomNode, aShell), mWeakParent(nsnull),
-    mBulletText(aBulletText)
+    nsLeafAccessible(aDomNode, aShell), mBulletText(aBulletText)
 {
   mBulletText += ' '; // Otherwise bullets are jammed up against list text
 }
 
 NS_IMETHODIMP
 nsHTMLListBulletAccessible::GetUniqueID(void **aUniqueID)
 {
   // Since mDOMNode is same as for list item, use |this| pointer as the unique Id
   *aUniqueID = static_cast<void*>(this);
   return NS_OK;
 }
 
 nsresult
 nsHTMLListBulletAccessible::Shutdown()
 {
   mBulletText.Truncate();
-  mWeakParent = nsnull;
-
   return nsLeafAccessible::Shutdown();
 }
 
 NS_IMETHODIMP
 nsHTMLListBulletAccessible::GetName(nsAString &aName)
 {
   // Native anonymous content, ARIA can't be used.
   aName = mBulletText;
@@ -338,27 +336,22 @@ nsHTMLListBulletAccessible::GetStateInte
   nsresult rv = nsLeafAccessible::GetStateInternal(aState, aExtraState);
   NS_ENSURE_A11Y_SUCCESS(rv, rv);
 
   *aState &= ~nsIAccessibleStates::STATE_FOCUSABLE;
   *aState |= nsIAccessibleStates::STATE_READONLY;
   return NS_OK;
 }
 
-void
-nsHTMLListBulletAccessible::SetParent(nsIAccessible *aParent)
+NS_IMETHODIMP
+nsHTMLListBulletAccessible::GetParent(nsIAccessible **aParent)
 {
-  mParent = nsnull;
-  mWeakParent = aParent;
-}
+  NS_ENSURE_ARG_POINTER(aParent);
 
-NS_IMETHODIMP
-nsHTMLListBulletAccessible::GetParent(nsIAccessible **aParentAccessible)
-{
-  NS_IF_ADDREF(*aParentAccessible = mWeakParent);
+  NS_IF_ADDREF(*aParent = mParent);
   return NS_OK;
 }
 
 nsresult
 nsHTMLListBulletAccessible::AppendTextTo(nsAString& aText, PRUint32 aStartOffset,
                                          PRUint32 aLength)
 {
   PRUint32 maxLength = mBulletText.Length() - aStartOffset;
--- a/accessible/src/html/nsHTMLTextAccessible.h
+++ b/accessible/src/html/nsHTMLTextAccessible.h
@@ -104,40 +104,34 @@ public:
   nsHTMLListBulletAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell,
                              const nsAString& aBulletText);
 
   // nsIAccessNode
   NS_IMETHOD GetUniqueID(void **aUniqueID);
 
   // nsIAccessible
   NS_IMETHOD GetName(nsAString& aName);
-
-  // Don't cache via unique ID -- bullet accessible shares the same dom node as
-  // this LI accessible. Also, don't cache via mParent/SetParent(), prevent
-  // circular reference since li holds onto us.
-  NS_IMETHOD GetParent(nsIAccessible **aParentAccessible);
+  NS_IMETHOD GetParent(nsIAccessible **aParent);
 
   // nsAccessNode
   virtual nsresult Shutdown();
 
   // nsAccessible
   virtual nsresult GetRoleInternal(PRUint32 *aRole);
   virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
-  virtual void SetParent(nsIAccessible *aParent);
   virtual nsresult AppendTextTo(nsAString& aText, PRUint32 aStartOffset,
                                 PRUint32 aLength);
 
 protected:
   // XXX: Ideally we'd get the bullet text directly from the bullet frame via
   // nsBulletFrame::GetListItemText(), but we'd need an interface for getting
   // text from contentless anonymous frames. Perhaps something like
   // nsIAnonymousFrame::GetText() ? However, in practice storing the bullet text
   // here should not be a problem if we invalidate the right parts of
   // the accessibility cache when mutation events occur.
-  nsIAccessible *mWeakParent;
   nsString mBulletText;
 };
 
 class nsHTMLListAccessible : public nsHyperTextAccessibleWrap
 {
 public:
   nsHTMLListAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell):
     nsHyperTextAccessibleWrap(aDOMNode, aShell) { }
--- a/accessible/tests/mochitest/Makefile.in
+++ b/accessible/tests/mochitest/Makefile.in
@@ -63,17 +63,16 @@ include $(topsrcdir)/config/rules.mk
 		namerules.xml \
  		nsIAccessible_selects.js \
 		nsIAccessibleEditableText.js \
 		relations.js \
 		role.js \
 		states.js \
 		table.js \
 		value.js \
-		test_accessnode_invalidation.html \
 		test_actions.xul \
 		test_actions_anchors.html \
 		test_actions_aria.html \
 		test_actions_inputs.html \
 		test_actions_tree.xul \
 		test_actions_treegrid.xul \
 		test_aria_activedescendant.html \
 		test_aria_role_article.html \
@@ -98,16 +97,18 @@ include $(topsrcdir)/config/rules.mk
 		test_events_draganddrop.html \
 		test_events_flush.html \
 		test_events_focus.xul \
 		test_events_mutation.html \
 		test_events_tree.xul \
 		test_events_valuechange.html \
 		test_groupattrs.xul \
 		test_groupattrs.html \
+		test_invalidate_accessnode.html \
+		test_invalidate_elmli.html \
 		test_name.html \
 		test_name.xul \
 		test_name_button.html \
 		test_name_link.html \
 		test_name_markup.html \
 		test_name_nsRootAcc.xul \
 		test_nsIAccessible_applicationAccessible.html \
 	$(warning test_nsIAccessible_comboboxes.xul temporarily disabled) \
--- a/accessible/tests/mochitest/events.js
+++ b/accessible/tests/mochitest/events.js
@@ -29,27 +29,36 @@ var gA11yEventDumpID = "";
  *                    called
  * @param aArg1       [in, optional] argument passed into the function
  * @param aArg2       [in, optional] argument passed into the function
  */
 function waitForEvent(aEventType, aTarget, aFunc, aContext, aArg1, aArg2)
 {
   var handler = {
     handleEvent: function handleEvent(aEvent) {
-      if (!aTarget || aTarget == aEvent.DOMNode) {
-        unregisterA11yEventListener(aEventType, this);
+
+      if (aTarget) {
+        if (aTarget instanceof nsIAccessible &&
+            aTarget != aEvent.accessible)
+          return;
 
-        window.setTimeout(
-          function ()
-          {
-            aFunc.call(aContext, aArg1, aArg2);
-          },
-          0
-        );
+        if (aTarget instanceof nsIDOMNode &&
+            aTarget != aEvent.DOMNode)
+          return;
       }
+
+      unregisterA11yEventListener(aEventType, this);
+
+      window.setTimeout(
+        function ()
+        {
+          aFunc.call(aContext, aArg1, aArg2);
+        },
+        0
+      );
     }
   };
 
   registerA11yEventListener(aEventType, handler);
 }
 
 /**
  * Register accessibility event listener.
@@ -87,16 +96,22 @@ function unregisterA11yEventListener(aEv
 
 /**
  * Return value of invoke method of invoker object. Indicates invoker was unable
  * to prepare action.
  */
 const INVOKER_ACTION_FAILED = 1;
 
 /**
+ * Return value of eventQueue.onFinish. Indicates eventQueue should not finish
+ * tests.
+ */
+const DO_NOT_FINISH_TEST = 1;
+
+/**
  * Common invoker checker (see eventSeq of eventQueue).
  */
 function invokerChecker(aEventType, aTarget)
 {
   this.type = aEventType;
   this.target = aTarget;
 }
 
@@ -140,18 +155,18 @@ function invokerChecker(aEventType, aTar
  *     // Array of checker objects defining unexpected events on invoker's
  *     // action.
  *     unexpectedEventSeq getter() {},
  *
  *     // The ID of invoker.
  *     getID: function(){} // returns invoker ID
  *   };
  *
- * @param  aEventType     [optional] the default event type (isn't used if
- *                        invoker defines eventSeq property).
+ * @param  aEventType  [in, optional] the default event type (isn't used if
+ *                      invoker defines eventSeq property).
  */
 function eventQueue(aEventType)
 {
   // public
 
   /**
    * Add invoker object into queue.
    */
@@ -235,18 +250,20 @@ function eventQueue(aEventType)
 
     this.clearEventHandler();
 
     // Check if need to stop the test.
     if (testFailed || this.mIndex == this.mInvokers.length - 1) {
       gA11yEventApplicantsCount--;
       listenA11yEvents(false);
 
-      this.onFinish();
-      SimpleTest.finish();
+      var res = this.onFinish();
+      if (res != DO_NOT_FINISH_TEST)
+        SimpleTest.finish();
+
       return;
     }
 
     // Start processing of next invoker.
     invoker = this.getNextInvoker();
 
     this.setEventHandler(invoker);
 
@@ -516,16 +533,64 @@ function eventQueue(aEventType)
 
   this.mInvokers = new Array();
   this.mIndex = -1;
 
   this.mEventSeq = null;
   this.mEventSeqIdx = -1;
 }
 
+
+/**
+ * Deal with action sequence. Used when you need to execute couple of actions
+ * each after other one.
+ */
+function sequence()
+{
+  /**
+   * Append new sequence item.
+   *
+   * @param  aProcessor  [in] object implementing interface
+   *                      {
+   *                        // execute item action
+   *                        process: function() {},
+   *                        // callback, is called when item was processed
+   *                        onProcessed: function() {}
+   *                      };
+   * @param  aEventType  [in] event type of expected event on item action
+   * @param  aTarget     [in] event target of expected event on item action
+   * @param  aItemID     [in] identifier of item
+   */
+  this.append = function sequence_append(aProcessor, aEventType, aTarget,
+                                         aItemID)
+  {
+    var item = new sequenceItem(aProcessor, aEventType, aTarget, aItemID);
+    this.items.push(item);
+  }
+
+  /**
+   * Process next sequence item.
+   */
+  this.processNext = function sequence_processNext()
+  {
+    this.idx++;
+    if (this.idx >= this.items.length) {
+      ok(false, "End of sequence: nothing to process!");
+      SimpleTest.finish();
+      return;
+    }
+
+    this.items[this.idx].startProcess();
+  }
+
+  this.items = new Array();
+  this.idx = -1;
+}
+
+
 ////////////////////////////////////////////////////////////////////////////////
 // Private implementation details.
 ////////////////////////////////////////////////////////////////////////////////
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // General
 
@@ -632,8 +697,47 @@ function dumpInfoToDOM(aInfo, aDumpNode)
 
   var containerTagName = document instanceof nsIDOMHTMLDocument ?
     "div" : "description";
   var container = document.createElement(containerTagName);
 
   container.textContent = aInfo;
   dumpElm.appendChild(container);
 }
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Sequence
+
+/**
+ * Base class of sequence item.
+ */
+function sequenceItem(aProcessor, aEventType, aTarget, aItemID)
+{
+  // private
+  
+  this.startProcess = function sequenceItem_startProcess()
+  {
+    this.queue.invoke();
+  }
+  
+  var item = this;
+  
+  this.queue = new eventQueue();
+  this.queue.onFinish = function()
+  {
+    aProcessor.onProcessed();
+    return DO_NOT_FINISH_TEST;
+  }
+  
+  var invoker = {
+    invoke: function invoker_invoke() {
+      return aProcessor.process();
+    },
+    getID: function invoker_getID()
+    {
+      return aItemID;
+    },
+    eventSeq: [ new invokerChecker(aEventType, aTarget) ]
+  };
+  
+  this.queue.push(invoker);
+}
--- a/accessible/tests/mochitest/role.js
+++ b/accessible/tests/mochitest/role.js
@@ -33,16 +33,17 @@ const ROLE_OUTLINEITEM = nsIAccessibleRo
 const ROLE_PARAGRAPH = nsIAccessibleRole.ROLE_PARAGRAPH;
 const ROLE_PASSWORD_TEXT = nsIAccessibleRole.ROLE_PASSWORD_TEXT;
 const ROLE_PROGRESSBAR = nsIAccessibleRole.ROLE_PROGRESSBAR;
 const ROLE_PUSHBUTTON = nsIAccessibleRole.ROLE_PUSHBUTTON;
 const ROLE_ROW = nsIAccessibleRole.ROLE_ROW;
 const ROLE_ROWHEADER = nsIAccessibleRole.ROLE_ROWHEADER;
 const ROLE_SECTION = nsIAccessibleRole.ROLE_SECTION;
 const ROLE_SLIDER = nsIAccessibleRole.ROLE_SLIDER;
+const ROLE_STATICTEXT = nsIAccessibleRole.ROLE_STATICTEXT;
 const ROLE_TABLE = nsIAccessibleRole.ROLE_TABLE;
 const ROLE_TEXT_CONTAINER = nsIAccessibleRole.ROLE_TEXT_CONTAINER;
 const ROLE_TEXT_LEAF = nsIAccessibleRole.ROLE_TEXT_LEAF;
 const ROLE_TOGGLE_BUTTON = nsIAccessibleRole.ROLE_TOGGLE_BUTTON;
 const ROLE_TREE_TABLE = nsIAccessibleRole.ROLE_TREE_TABLE;
 
 ////////////////////////////////////////////////////////////////////////////////
 // Public methods
rename from accessible/tests/mochitest/test_accessnode_invalidation.html
rename to accessible/tests/mochitest/test_invalidate_accessnode.html
new file mode 100644
--- /dev/null
+++ b/accessible/tests/mochitest/test_invalidate_elmli.html
@@ -0,0 +1,168 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+  <title>Test HTML li and listitem bullet accessible cache</title>
+  <link rel="stylesheet" type="text/css"
+        href="chrome://mochikit/content/tests/SimpleTest/test.css" />
+
+  <script type="application/javascript"
+          src="chrome://mochikit/content/MochiKit/packed.js"></script>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+  <script type="application/javascript"
+          src="chrome://mochikit/content/a11y/accessible/common.js"></script>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/a11y/accessible/role.js"></script>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/a11y/accessible/events.js"></script>
+
+  <script type="application/javascript">
+
+    ////////////////////////////////////////////////////////////////////////////
+    // Helpers
+
+    function testDefunctAccessible(aAcc, aNodeOrId)
+    {
+      if (aNodeOrId)
+        ok(!isAccessible(aNodeOrId),
+           "Accessible for " + aNodeOrId + " wasn't properly shut down!");
+
+      ok(!aAcc.firstChild, "There is first child for shut down accessible!");
+      ok(!aAcc.lastChild, "There is last child for shut down accessible!");
+      ok(!aAcc.children.length, "There are children for shut down accessible!");
+
+      // nextSibling
+      var success = false;
+      try {
+        aAcc.nextSibling;
+      } catch (e) {
+        success = (e.result == Components.results.NS_ERROR_FAILURE);
+      }
+
+      ok(success, "There is next sibling for shut down accessible!");
+
+      // previousSibling
+      var success = false;
+      try {
+        aAcc.previousSibling;
+      } catch (e) {
+        success = (e.result == Components.results.NS_ERROR_FAILURE);
+      }
+
+      ok(success, "There is previous sibling for shut down accessible!");
+
+      // parent
+      var success = false;
+      try {
+        aAcc.parent;
+      } catch (e) {
+        success = (e.result == Components.results.NS_ERROR_FAILURE);
+      }
+
+      ok(success, "There is parent for shut down accessible!");
+    }
+
+    function testLiAccessibleTree()
+    {
+      // Test accessible tree.
+      var accTree = {
+        role: ROLE_LISTITEM,
+        children: [
+          {
+            role: ROLE_STATICTEXT,
+            children: []
+          },
+          {
+            role: ROLE_TEXT_LEAF,
+            children: []
+          }
+        ]
+      };
+
+      testAccessibleTree("li", accTree);
+    }
+
+    ////////////////////////////////////////////////////////////////////////////
+    // Sequence item processors
+
+    function hideProcessor()
+    {
+      this.liNode = getNode("li");
+      this.li = getAccessible(this.liNode);
+      this.bullet = this.li.firstChild;
+
+      this.process = function hideProcessor_process()
+      {
+        this.liNode.style.display = "none";
+      }
+
+      this.onProcessed = function hideProcessor_onProcessed()
+      {
+        window.setTimeout(
+          function(aArg1, aArg2)
+          {
+            testDefunctAccessible(aArg1, aArg2);
+            gSequence.processNext();
+          },
+          0, this.li, this.liNode
+        );
+      }
+    };
+
+    function showProcessor()
+    {
+      this.liNode = getNode("li");
+
+      this.process = function showProcessor_process()
+      {
+        this.liNode.style.display = "list-item";
+      }
+
+      this.onProcessed = function showProcessor_onProcessed()
+      {
+        testLiAccessibleTree();
+        SimpleTest.finish();
+      }
+    };
+
+    ////////////////////////////////////////////////////////////////////////////
+    // Test
+
+    var gSequence = null;
+
+    function doTest()
+    {
+      testLiAccessibleTree();
+
+      gSequence = new sequence();
+
+      gSequence.append(new hideProcessor(), EVENT_HIDE, getAccessible("li"),
+                       "hide HTML li");
+      gSequence.append(new showProcessor(), EVENT_SHOW, getNode("li"),
+                       "show HTML li");
+
+      gSequence.processNext(); // SimpleTest.finish() will be called in the end
+    }
+
+    SimpleTest.waitForExplicitFinish();
+    addA11yLoadEvent(doTest);
+  </script>
+</head>
+<body>
+
+  <a target="_blank"
+     title="setParent shouldn't be virtual"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=496783">Mozilla Bug 496783</a>
+
+  <p id="display"></p>
+  <div id="content" style="display: none"></div>
+  <pre id="test">
+  </pre>
+
+  <ul>
+    <li id="li">item1</li>
+  </ul>
+</body>
+</html>
--- a/browser/app/Makefile.in
+++ b/browser/app/Makefile.in
@@ -100,24 +100,24 @@ LOCAL_INCLUDES += -I$(topsrcdir)/toolkit
 ifdef BUILD_STATIC_LIBS
 ifdef _MSC_VER
 STATIC_COMPONENTS_LINKER_PATH = -LIBPATH:$(DEPTH)/staticlib
 else
 STATIC_COMPONENTS_LINKER_PATH = -L$(DEPTH)/staticlib
 endif
 LIBS += $(DEPTH)/toolkit/xre/$(LIB_PREFIX)xulapp_s.$(LIB_SUFFIX)
 else
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 LIBS += $(DIST)/bin/XUL
 else
 EXTRA_DSO_LIBS += xul
 endif
 endif
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 TK_LIBS := $(TK_LIBS)
 endif
 
 ifdef MOZ_ENABLE_LIBXUL
 APP_XPCOM_LIBS = $(XPCOM_GLUE_LDOPTS)
 else
 MOZILLA_INTERNAL_API = 1
 APP_XPCOM_LIBS = $(XPCOM_LIBS)
@@ -303,17 +303,17 @@ libs::
 	touch $(DIST)/bin/.autoreg
 
 libs:: $(srcdir)/profile/prefs.js
 	$(INSTALL) $(IFLAGS1) $^ $(DIST)/bin/defaults/profile
 
 libs:: $(srcdir)/blocklist.xml
 	$(INSTALL) $(IFLAGS1) $^ $(DIST)/bin
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 
 APP_NAME = $(MOZ_APP_DISPLAYNAME)
 
 ifdef MOZ_DEBUG
 APP_NAME := $(APP_NAME)Debug
 endif
 
 AB_CD = $(MOZ_UI_LOCALE)
--- a/browser/base/Makefile.in
+++ b/browser/base/Makefile.in
@@ -63,21 +63,21 @@ PRE_RELEASE_SUFFIX := $(shell $(PYTHON) 
                         $(shell cat $(srcdir)/../config/version.txt))
 
 DEFINES += \
 	-DMOZ_APP_VERSION=$(MOZ_APP_VERSION) \
 	-DAPP_LICENSE_BLOCK=$(abs_srcdir)/content/overrides/app-license.html \
 	-DPRE_RELEASE_SUFFIX="$(PRE_RELEASE_SUFFIX)" \
 	$(NULL)
 
-ifneq (,$(filter windows gtk2 mac cocoa, $(MOZ_WIDGET_TOOLKIT)))
+ifneq (,$(filter windows gtk2 cocoa, $(MOZ_WIDGET_TOOLKIT)))
 DEFINES += -DHAVE_SHELL_SERVICE=1
 endif
 
 ifdef MOZ_UPDATER
 DEFINES += -DMOZ_UPDATER=1
 endif
 
-ifneq (,$(filter windows mac cocoa gtk2, $(MOZ_WIDGET_TOOLKIT)))
+ifneq (,$(filter windows cocoa gtk2, $(MOZ_WIDGET_TOOLKIT)))
 ifneq ($(OS_ARCH),WINCE)
 DEFINES += -DCONTEXT_COPY_IMAGE_CONTENTS=1
 endif
 endif
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -445,17 +445,17 @@ var PlacesCommandHook = {
 
     StarUI.showEditBookmarkPopup(itemId, aBrowser, "overlap");
   },
 
   /**
    * Adds a bookmark to the page loaded in the current tab. 
    */
   bookmarkCurrentPage: function PCH_bookmarkCurrentPage(aShowEditUI, aParent) {
-    this.bookmarkPage(getBrowser().selectedBrowser, aParent, aShowEditUI);
+    this.bookmarkPage(gBrowser.selectedBrowser, aParent, aShowEditUI);
   },
 
   /**
    * Adds a bookmark to the page targeted by a link.
    * @param aParent
    *        The folder in which to create a new bookmark if aURL isn't
    *        bookmarked.
    * @param aURL (string)
@@ -479,29 +479,28 @@ var PlacesCommandHook = {
    * tabs currently open in the browser.  The URIs will appear in the
    * list in the order in which their corresponding tabs appeared.  However,
    * only the first instance of each URI will be returned.
    *
    * @returns a list of nsIURI objects representing unique locations open
    */
   _getUniqueTabInfo: function BATC__getUniqueTabInfo() {
     var tabList = [];
-    var seenURIs = [];
+    var seenURIs = {};
 
-    var browsers = getBrowser().browsers;
+    var browsers = gBrowser.browsers;
     for (var i = 0; i < browsers.length; ++i) {
-      var webNav = browsers[i].webNavigation;
-      var uri = webNav.currentURI;
+      let uri = browsers[i].currentURI;
 
       // skip redundant entries
       if (uri.spec in seenURIs)
         continue;
 
       // add to the set of seen URIs
-      seenURIs[uri.spec] = true;
+      seenURIs[uri.spec] = null;
       tabList.push(uri);
     }
     return tabList;
   },
 
   /**
    * Adds a folder with bookmarks to all of the currently open tabs in this 
    * window.
@@ -1161,17 +1160,17 @@ var PlacesStarButton = {
   _starred: false,
   _batching: false,
 
   updateState: function PSB_updateState() {
     var starIcon = document.getElementById("star-button");
     if (!starIcon)
       return;
 
-    var uri = getBrowser().currentURI;
+    var uri = gBrowser.currentURI;
     this._starred = uri && (PlacesUtils.getMostRecentBookmarkForURI(uri) != -1 ||
                             PlacesUtils.getMostRecentFolderForFeedURI(uri) != -1);
     if (this._starred) {
       starIcon.setAttribute("starred", "true");
       starIcon.setAttribute("tooltiptext", gNavigatorBundle.getString("starButtonOn.tooltip"));
     }
     else {
       starIcon.removeAttribute("starred");
--- a/browser/base/content/pageinfo/pageInfo.js
+++ b/browser/base/content/pageinfo/pageInfo.js
@@ -868,20 +868,27 @@ function makePreview(row)
       var image = imageRequest.image;
       if (image)
         numFrames = image.numFrames;
     }
   }
   if (!mimeType)
     mimeType = getContentTypeFromHeaders(cacheEntryDescriptor);
 
+  // if we have a data url, get the MIME type from the url
+  if (!mimeType && /^data:/.test(url)) {
+    let dataMimeType = /^data:(image\/[^;,]+)/i.exec(url);
+    if (dataMimeType)
+      mimeType = dataMimeType[1].toLowerCase();
+  }
+
   var imageType;
   if (mimeType) {
     // We found the type, try to display it nicely
-    var imageMimeType = /^image\/(.*)/.exec(mimeType);
+    let imageMimeType = /^image\/(.*)/i.exec(mimeType);
     if (imageMimeType) {
       imageType = imageMimeType[1].toUpperCase();
       if (numFrames > 1)
         imageType = gBundle.getFormattedString("mediaAnimatedImageType",
                                                [imageType, numFrames]);
       else
         imageType = gBundle.getFormattedString("mediaImageType", [imageType]);
     }
--- a/browser/base/content/test/Makefile.in
+++ b/browser/base/content/test/Makefile.in
@@ -135,17 +135,17 @@ include $(topsrcdir)/config/rules.mk
                  browser_sanitizeDialog.js \
                  browser_tabs_owner.js \
                  browser_bug491431.js \
                  browser_bug304198.js \
                  browser_drag.js \
                  browser_relatedTabs.js \
     $(NULL)
 
-ifeq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 _BROWSER_FILES += browser_bug462289.js
 else
 _BROWSER_FILES += browser_customize.js
 endif
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
 
--- a/browser/components/build/Makefile.in
+++ b/browser/components/build/Makefile.in
@@ -44,17 +44,17 @@ endif
 
 SHARED_LIBRARY_LIBS = \
 	../feeds/src/$(LIB_PREFIX)browser_feeds_s.$(LIB_SUFFIX) \
 	../places/src/$(LIB_PREFIX)browserplaces_s.$(LIB_SUFFIX) \
 	../privatebrowsing/src/$(LIB_PREFIX)privatebrowsing_s.$(LIB_SUFFIX) \
 	../about/$(LIB_PREFIX)browserabout_s.$(LIB_SUFFIX) \
 	$(NULL)
 
-ifneq (,$(filter windows mac cocoa gtk2, $(MOZ_WIDGET_TOOLKIT)))
+ifneq (,$(filter windows cocoa gtk2, $(MOZ_WIDGET_TOOLKIT)))
 SHARED_LIBRARY_LIBS += ../shell/src/$(LIB_PREFIX)shellservice_s.$(LIB_SUFFIX)
 endif
 
 EXTRA_DSO_LDOPTS += $(call EXPAND_LIBNAME_PATH,unicharutil_external_s,$(LIBXUL_DIST)/lib)
 
 # migration requires mozreg, which doesn't build on WINCE; only include
 # it on non-CE
 ifndef WINCE
@@ -67,17 +67,17 @@ endif
 # stuff in MOZ_COMPONENT_LIBS.
 EXTRA_DSO_LDOPTS += \
 	$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \
 	$(MOZ_COMPONENT_LIBS) \
 	$(NULL)
 
 # Mac: Need to link with CoreFoundation for Mac Migrators (PList reading code)
 # GTK2: Need to link with glib for GNOME shell service
-ifneq (,$(filter mac cocoa gtk2,$(MOZ_WIDGET_TOOLKIT)))
+ifneq (,$(filter cocoa gtk2,$(MOZ_WIDGET_TOOLKIT)))
 EXTRA_DSO_LDOPTS += \
   $(TK_LIBS) \
   $(NULL)
 endif
 
 ifndef MOZ_ENABLE_LIBXUL
 ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
 # Doesn't work, couldn't figure out why
--- a/browser/components/migration/src/Makefile.in
+++ b/browser/components/migration/src/Makefile.in
@@ -67,17 +67,17 @@ endif
 
 ifeq ($(OS_ARCH)_$(GNU_CXX),WINNT_)
 DEFINES += -DPSTOREC_DLL=\"$(subst \,\\,$(WINDIR))\\system32\\pstorec.dll\"
 
 CPPSRCS += nsIEProfileMigrator.cpp \
            $(NULL)
 endif
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 CPPSRCS += nsSafariProfileMigrator.cpp \
            nsMacIEProfileMigrator.cpp \
            nsOmniWebProfileMigrator.cpp \
            nsCaminoProfileMigrator.cpp \
            nsICabProfileMigrator.cpp \
            $(NULL)
 endif            
 
--- a/browser/components/places/content/utils.js
+++ b/browser/components/places/content/utils.js
@@ -913,18 +913,17 @@ var PlacesUIUtils = {
     if (where == "window") {
       window.openDialog(getBrowserURL(), "_blank",
                         "chrome,all,dialog=no", urls.join("|"));
       return;
     }
 
     var loadInBackground = where == "tabshifted" ? true : false;
     var replaceCurrentTab = where == "tab" ? false : true;
-    browserWindow.getBrowser().loadTabs(urls, loadInBackground,
-                                        replaceCurrentTab);
+    browserWindow.gBrowser.loadTabs(urls, loadInBackground, replaceCurrentTab);
   },
 
   openContainerNodeInTabs: function PU_openContainerInTabs(aNode, aEvent) {
     var urlsToOpen = PlacesUtils.getURLsForContainerNode(aNode);
     if (!this._confirmOpenInTabs(urlsToOpen.length))
       return;
 
     this._openTabset(urlsToOpen, aEvent);
--- a/browser/components/preferences/Makefile.in
+++ b/browser/components/preferences/Makefile.in
@@ -49,15 +49,15 @@ endif
 
 include $(topsrcdir)/config/rules.mk
 
 DEFINES += \
 	-DMOZ_APP_NAME=$(MOZ_APP_NAME) \
 	-DMOZ_APP_DISPLAYNAME=$(MOZ_APP_DISPLAYNAME) \
 	$(NULL)
 
-ifneq (,$(filter windows gtk2 mac cocoa, $(MOZ_WIDGET_TOOLKIT)))
+ifneq (,$(filter windows gtk2 cocoa, $(MOZ_WIDGET_TOOLKIT)))
 DEFINES += -DHAVE_SHELL_SERVICE=1
 endif
 
 ifdef MOZ_UPDATER
 DEFINES += -DMOZ_UPDATER=1
 endif
--- a/browser/components/preferences/jar.mn
+++ b/browser/components/preferences/jar.mn
@@ -25,14 +25,12 @@ browser.jar:
 *   content/browser/preferences/permissions.js
 *   content/browser/preferences/permissionsutils.js
 *   content/browser/preferences/preferences.xul
 *   content/browser/preferences/privacy.xul
 *   content/browser/preferences/privacy.js
 *   content/browser/preferences/sanitize.xul
 *   content/browser/preferences/security.xul
 *   content/browser/preferences/security.js
-*   content/browser/preferences/securityWarnings.xul
-*   content/browser/preferences/securityWarnings.js
 *   content/browser/preferences/selectBookmark.xul
 *   content/browser/preferences/selectBookmark.js
 *   content/browser/preferences/tabs.xul
 *   content/browser/preferences/tabs.js
--- a/browser/components/preferences/security.js
+++ b/browser/components/preferences/security.js
@@ -239,25 +239,11 @@ var gSecurityPane = {
    * Shows the sites where the user has saved passwords and the associated login
    * information.
    */
   showPasswords: function ()
   {
     document.documentElement.openWindow("Toolkit:PasswordManager",
                                         "chrome://passwordmgr/content/passwordManager.xul",
                                         "", null);
-  },
-
-
-  // WARNING MESSAGES
-
-  /**
-   * Displays the security warnings dialog which allows changing the
-   * "submitting unencrypted information", "moving from secure to unsecure",
-   * etc. dialogs that every user immediately disables when he sees them.
-   */
-  showWarningMessageSettings: function ()
-  {
-    document.documentElement.openSubDialog("chrome://browser/content/preferences/securityWarnings.xul",
-                                           "", null);
   }
 
 };
--- a/browser/components/preferences/security.xul
+++ b/browser/components/preferences/security.xul
@@ -136,25 +136,11 @@
         <spacer flex="1"/>
         <button id="showPasswords"
                 label="&savedPasswords.label;" accesskey="&savedPasswords.accesskey;"
                 oncommand="gSecurityPane.showPasswords();"
                 preference="pref.privacy.disable_button.view_passwords"/>
       </hbox>
     </groupbox>
 
-    <!-- Warning Messages -->
-    <hbox class="bottomBox">
-      <groupbox id="warningMessagesGroup" orient="horizontal" flex="1"
-                align="center">
-        <caption label="&warnings.label;"/>
-
-        <description control="warningSettings" flex="1">&chooseWarnings.label;</description>
-        <button id="warningSettings"
-                label="&warningSettings.label;"
-                accesskey="&warningSettings.accesskey;"
-                oncommand="gSecurityPane.showWarningMessageSettings();"/>
-      </groupbox>
-    </hbox>
-
   </prefpane>
 
 </overlay>
deleted file mode 100644
--- a/browser/components/preferences/securityWarnings.js
+++ /dev/null
@@ -1,44 +0,0 @@
-# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is the Firefox Preferences System.
-#
-# The Initial Developer of the Original Code is
-# Gavin Sharp.
-# Portions created by the Initial Developer are Copyright (C) 2006
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#   Gavin Sharp <gavin@gavinsharp.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-function secWarningSyncTo(aEvent) {
-  var prefName = aEvent.target.getAttribute("preference") + ".show_once";
-  var prefOnce = document.getElementById(prefName);
-  prefOnce.value = false;
-  return undefined;    
-}
deleted file mode 100644
--- a/browser/components/preferences/securityWarnings.xul
+++ /dev/null
@@ -1,115 +0,0 @@
-<?xml version="1.0"?>
-
-# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is the Firefox Preferences System.
-#
-# The Initial Developer of the Original Code is
-# Gavin Sharp.
-# Portions created by the Initial Developer are Copyright (C) 2006
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#   Gavin Sharp <gavin@gavinsharp.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-<!DOCTYPE prefwindow SYSTEM "chrome://browser/locale/preferences/securityWarnings.dtd">
-
-<?xml-stylesheet href="chrome://global/skin/"?>
-
-<prefwindow id="SecurityWarnings" type="child"
-            xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-            title="&securityWarnings.title;"
-            dlgbuttons="accept,cancel">
-
-  <prefpane id="SecurityWarningsPane">
-    <preferences>
-      <preference id="security.warn_entering_secure"
-                  name="security.warn_entering_secure"
-                  type="bool"/>
-      <preference id="security.warn_entering_secure.show_once"
-                  name="security.warn_entering_secure.show_once"
-                  type="bool"/>
-      <preference id="security.warn_entering_weak"
-                  name="security.warn_entering_weak"
-                  type="bool"/>
-      <preference id="security.warn_entering_weak.show_once"
-                  name="security.warn_entering_weak.show_once"
-                  type="bool"/>
-      <preference id="security.warn_leaving_secure"
-                  name="security.warn_leaving_secure"
-                  type="bool"/>
-      <preference id="security.warn_leaving_secure.show_once"
-                  name="security.warn_leaving_secure.show_once"
-                  type="bool"/>
-      <preference id="security.warn_submit_insecure"
-                  name="security.warn_submit_insecure"
-                  type="bool"/>
-      <preference id="security.warn_submit_insecure.show_once"
-                  name="security.warn_submit_insecure.show_once"
-                  type="bool"/>
-      <preference id="security.warn_viewing_mixed"
-                  name="security.warn_viewing_mixed"
-                  type="bool"/>
-      <preference id="security.warn_viewing_mixed.show_once"
-                  name="security.warn_viewing_mixed.show_once"
-                  type="bool"/>
-    </preferences>
-    
-    <script type="application/x-javascript" src="chrome://browser/content/preferences/securityWarnings.js"/>
-
-    <description value="&security.warn_when;"/>
-    <vbox class="indent">
-      <checkbox id="warn_entering_secure"
-                onsynctopreference="secWarningSyncTo(event);"
-                label="&security.warn_entering_secure.label;"
-                accesskey="&security.warn_entering_secure.accesskey;"
-                preference="security.warn_entering_secure"/>
-      <checkbox id="warn_entering_weak"
-                onsynctopreference="secWarningSyncTo(event);"
-                label="&security.warn_entering_weak.label;"
-                accesskey="&security.warn_entering_weak.accesskey;"
-                preference="security.warn_entering_weak"/>
-      <checkbox id="warn_leaving_secure"
-                onsynctopreference="secWarningSyncTo(event);"
-                label="&security.warn_leaving_secure.label;"
-                accesskey="&security.warn_leaving_secure.accesskey;"
-                preference="security.warn_leaving_secure"/>
-      <checkbox id="warn_submit_insecure"
-                onsynctopreference="secWarningSyncTo(event);"
-                label="&security.warn_submit_insecure.label;"
-                accesskey="&security.warn_submit_insecure.accesskey;"
-                preference="security.warn_submit_insecure"/>
-      <checkbox id="warn_viewing_mixed"
-                onsynctopreference="secWarningSyncTo(event);"
-                label="&security.warn_viewing_mixed.label;"
-                accesskey="&security.warn_viewing_mixed.accesskey;"
-                preference="security.warn_viewing_mixed"/>
-    </vbox>
-  </prefpane>
-</prefwindow>
--- a/browser/components/privatebrowsing/src/nsPrivateBrowsingService.js
+++ b/browser/components/privatebrowsing/src/nsPrivateBrowsingService.js
@@ -182,17 +182,17 @@ PrivateBrowsingService.prototype = {
 
       // save view-source windows URIs and close them
       let viewSrcWindowsEnum = Cc["@mozilla.org/appshell/window-mediator;1"].
                                getService(Ci.nsIWindowMediator).
                                getEnumerator("navigator:view-source");
       while (viewSrcWindowsEnum.hasMoreElements()) {
         let win = viewSrcWindowsEnum.getNext();
         if (this._inPrivateBrowsing) {
-          let plainURL = win.getBrowser().currentURI.spec;
+          let plainURL = win.gBrowser.currentURI.spec;
           if (plainURL.indexOf("view-source:") == 0) {
             plainURL = plainURL.substr(12);
             this._viewSrcURLs.push(plainURL);
           }
         }
         win.close();
       }
 
--- a/browser/components/safebrowsing/content/test/Makefile.in
+++ b/browser/components/safebrowsing/content/test/Makefile.in
@@ -42,17 +42,17 @@ srcdir		= @srcdir@
 VPATH		= @srcdir@
 relativesrcdir  = browser/components/safebrowsing/content/test
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 # The browser chrome test for bug 415846 doesn't run on Mac because of its
 # bizarre special-and-unique snowflake of a help menu.
-ifeq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT)))
 _NON_MAC_BROWSER_TESTS = browser_bug415846.js
 endif
 
 _BROWSER_FILES = browser_bug400731.js \
                  $(_NON_MAC_BROWSER_TESTS) \
     $(NULL)
 
 libs::	$(_BROWSER_FILES)
--- a/browser/components/sessionstore/nsISessionStore.idl
+++ b/browser/components/sessionstore/nsISessionStore.idl
@@ -51,17 +51,17 @@ interface nsIDOMNode;
  *
  * * "Browser windows" are those DOM windows having loaded
  * chrome://browser/content/browser.xul . From overlays you can just pass the
  * global |window| object to the API, though (or |top| from a sidebar).
  * From elsewhere you can get browser windows through the nsIWindowMediator
  * by looking for "navigator:browser" windows.
  *
  * * "Tabbrowser tabs" are all the child nodes of a browser window's
- * |getBrowser().tabContainer| such as e.g. |getBrowser().selectedTab|.
+ * |gBrowser.tabContainer| such as e.g. |gBrowser.selectedTab|.
  */
 
 [scriptable, uuid(70592a0d-87d3-459c-8db7-dcb8d47af78e)]
 interface nsISessionStore : nsISupports
 {
   /**
    * Initialize the service
    */
--- a/browser/components/sessionstore/src/nsSessionStore.js
+++ b/browser/components/sessionstore/src/nsSessionStore.js
@@ -943,17 +943,17 @@ SessionStoreService.prototype = {
     if (!aTab.ownerDocument || !aTab.ownerDocument.defaultView.__SSi ||
         !aWindow.getBrowser)
       throw (Components.returnCode = Cr.NS_ERROR_INVALID_ARG);
     
     var tabState = this._collectTabData(aTab, true);
     var sourceWindow = aTab.ownerDocument.defaultView;
     this._updateTextAndScrollDataForTab(sourceWindow, aTab.linkedBrowser, tabState, true);
     
-    var newTab = aWindow.getBrowser().addTab();
+    var newTab = aWindow.gBrowser.addTab();
     this.restoreHistoryPrecursor(aWindow, [newTab], [tabState], 0, 0, 0);
     
     return newTab;
   },
 
   getClosedTabCount: function sss_getClosedTabCount(aWindow) {
     if (!aWindow.__SSi && aWindow.__SS_dyingCache)
       return aWindow.__SS_dyingCache._closedTabs.length;
@@ -1113,17 +1113,17 @@ SessionStoreService.prototype = {
 /* ........ Saving Functionality .............. */
 
   /**
    * Store all session data for a window
    * @param aWindow
    *        Window reference
    */
   _saveWindowHistory: function sss_saveWindowHistory(aWindow) {
-    var tabbrowser = aWindow.getBrowser();
+    var tabbrowser = aWindow.gBrowser;
     var tabs = tabbrowser.mTabs;
     var tabsData = this._windows[aWindow.__SSi].tabs = [];
     
     for (var i = 0; i < tabs.length; i++)
       tabsData.push(this._collectTabData(tabs[i]));
     
     this._windows[aWindow.__SSi].selected = tabbrowser.mTabBox.selectedIndex + 1;
   },
@@ -1394,17 +1394,17 @@ SessionStoreService.prototype = {
 
   /**
    * go through all tabs and store the current scroll positions
    * and innerHTML content of WYSIWYG editors
    * @param aWindow
    *        Window reference
    */
   _updateTextAndScrollData: function sss_updateTextAndScrollData(aWindow) {
-    var browsers = aWindow.getBrowser().browsers;
+    var browsers = aWindow.gBrowser.browsers;
     for (var i = 0; i < browsers.length; i++) {
       try {
         var tabData = this._windows[aWindow.__SSi].tabs[i];
         if (browsers[i].__SS_data &&
             browsers[i].__SS_data._tabStillLoading)
           continue; // ignore incompletely initialized tabs
         this._updateTextAndScrollDataForTab(aWindow, browsers[i], tabData);
       }
@@ -1912,17 +1912,17 @@ SessionStoreService.prototype = {
    *        Index of selected tab
    * @param aIx
    *        Index of the next tab to check readyness for
    * @param aCount
    *        Counter for number of times delaying b/c browser or history aren't ready
    */
   restoreHistoryPrecursor:
     function sss_restoreHistoryPrecursor(aWindow, aTabs, aTabData, aSelectTab, aIx, aCount) {
-    var tabbrowser = aWindow.getBrowser();
+    var tabbrowser = aWindow.gBrowser;
     
     // make sure that all browsers and their histories are available
     // - if one's not, resume this check in 100ms (repeat at most 10 times)
     for (var t = aIx; t < aTabs.length; t++) {
       try {
         if (!tabbrowser.getBrowserForTab(aTabs[t]).webNavigation.sessionHistory) {
           throw new Error();
         }
@@ -2026,17 +2026,17 @@ SessionStoreService.prototype = {
     }
     if (aTabs.length == 0) {
       return; // no more tabs to restore
     }
     
     var tab = aTabs.shift();
     var tabData = aTabData.shift();
 
-    var browser = aWindow.getBrowser().getBrowserForTab(tab);
+    var browser = aWindow.gBrowser.getBrowserForTab(tab);
     var history = browser.webNavigation.sessionHistory;
     
     if (history.count > 0) {
       history.PurgeHistory(history.count);
     }
     history.QueryInterface(Ci.nsISHistoryInternal);
     
     if (!tabData.entries) {
@@ -2722,17 +2722,17 @@ SessionStoreService.prototype = {
    */
   _updateCrashReportURL: function sss_updateCrashReportURL(aWindow) {
     if (!Ci.nsICrashReporter) {
       // if breakpad isn't built, don't bother next time at all
       this._updateCrashReportURL = function(aWindow) {};
       return;
     }
     try {
-      var currentURI = aWindow.getBrowser().currentURI.clone();
+      var currentURI = aWindow.gBrowser.currentURI.clone();
       // if the current URI contains a username/password, remove it
       try { 
         currentURI.userPass = ""; 
       } 
       catch (ex) { } // ignore failures on about: URIs
 
       var cr = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsICrashReporter);
       cr.annotateCrashReport("URL", currentURI.spec);
--- a/browser/components/shell/public/Makefile.in
+++ b/browser/components/shell/public/Makefile.in
@@ -46,13 +46,13 @@ MODULE = shellservice
 XPIDL_MODULE  = shellservice
 
 XPIDLSRCS = nsIShellService.idl
 
 ifneq (,$(filter WINCE WINNT,$(OS_ARCH)))
 XPIDLSRCS += nsIWindowsShellService.idl
 endif
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 XPIDLSRCS += nsIMacShellService.idl
 endif
 
 include $(topsrcdir)/config/rules.mk
--- a/browser/components/shell/src/Makefile.in
+++ b/browser/components/shell/src/Makefile.in
@@ -48,17 +48,17 @@ FORCE_USE_PIC = 1
 ifndef MOZ_MEMORY
 USE_STATIC_LIBS = 1
 endif
 
 
 ifneq (,$(filter WINCE WINNT,$(OS_ARCH)))
 CPPSRCS = nsWindowsShellService.cpp
 else
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 CPPSRCS = nsMacShellService.cpp
 else
 ifeq ($(MOZ_WIDGET_TOOLKIT), gtk2)
 CPPSRCS = nsGNOMEShellService.cpp
 endif
 endif
 endif
 
--- a/browser/fuel/test/browser_Browser.js
+++ b/browser/fuel/test/browser_Browser.js
@@ -74,48 +74,46 @@ function test() {
     gPageA.moveToEnd();
     is(gPageA.index, 2, "Checking index after moving tab");
 
     // check event
     is(gTabMoveCount, 1, "Checking event handler for tab move");
 
     let browser = gBrowser.getBrowserAtIndex(gPageB.index);
     browser.addProgressListener({
-      onStateChange: function(webProgress, request, stateFlags, status) {
+      onStateChange: function (webProgress, request, stateFlags, status) {
+        info("onStateChange: " + stateFlags);
+
         const complete = Ci.nsIWebProgressListener.STATE_IS_WINDOW +
                          Ci.nsIWebProgressListener.STATE_IS_NETWORK +
                          Ci.nsIWebProgressListener.STATE_STOP;
         if ((stateFlags & complete) == complete) {
           browser.removeProgressListener(this);
           onPageBLoadComplete();
         }
       },
 
-      onLocationChange: function() { return 0; },
-      onProgressChange: function() { return 0; },
-      onStatusChange: function() { return 0; },
-      onSecurityChange: function() { return 0; },
-      QueryInterface: function(iid) {
-        if (iid.equals(Ci.nsISupportsWeakReference) ||
-           iid.equals(Ci.nsIWebProgressListener) ||
-           iid.equals(Ci.nsISupports))
-           return this;
-
-        throw Components.results.NS_ERROR_NO_INTERFACE;
-      }
+      onLocationChange: function () 0,
+      onProgressChange: function () 0,
+      onStatusChange: function () 0,
+      onSecurityChange: function () 0,
+      QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference,
+                                             Ci.nsIWebProgressListener,
+                                             Ci.nsISupports])
     });
 
     // test loading new content with a frame into a tab
     // the event will be checked in onPageBLoadComplete
     gPageB.events.addListener("load", onPageBLoadWithFrames);
     gPageB.load(makeURI("chrome://mochikit/content/browser/browser/fuel/test/ContentWithFrames.html"));
   }
 
   function onPageBLoadWithFrames(event) {
     gPageLoadCount++;
+    info("onPageBLoadWithFrames: " + gPageLoadCount);
   }
 
   function onPageBLoadComplete() {
     gPageB.events.removeListener("load", onPageBLoadWithFrames);
     // check page load with frame event
     is(gPageLoadCount, 1, "Checking load count after loading new content with a frame");
 
     // test loading new content into a tab
--- a/browser/installer/Makefile.in
+++ b/browser/installer/Makefile.in
@@ -98,17 +98,17 @@ ifdef MOZ_PKG_MANIFEST_P
 MOZ_PKG_MANIFEST = package-manifest
 
 $(MOZ_PKG_MANIFEST): $(MOZ_PKG_MANIFEST_P)
 	$(PERL) $(topsrcdir)/config/preprocessor.pl $(DEFINES) $(ACDEFINES) $< > $@
 
 GARBAGE += $(MOZ_PKG_MANIFEST)
 endif
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 MOZ_PKG_MAC_DSSTORE=branding/dsstore
 MOZ_PKG_MAC_BACKGROUND=branding/background.png
 MOZ_PKG_MAC_ICON=branding/disk.icns
 MOZ_PKG_MAC_EXTRA=--symlink "/Applications:/ "
 endif
 
 ifndef LIBXUL_SDK
 INSTALL_SDK = 1
--- a/browser/locales/en-US/chrome/browser/preferences/security.dtd
+++ b/browser/locales/en-US/chrome/browser/preferences/security.dtd
@@ -27,16 +27,8 @@
 
 <!ENTITY  useMasterPassword.label        "Use a master password">
 <!ENTITY  useMasterPassword.accesskey    "U">
 <!ENTITY  changeMasterPassword.label     "Change Master Password…">
 <!ENTITY  changeMasterPassword.accesskey "M">
 
 <!ENTITY  savedPasswords.label            "Saved Passwords…">
 <!ENTITY  savedPasswords.accesskey        "P">
-
-
-<!ENTITY  warnings.label                "Warning Messages">
-
-<!ENTITY  chooseWarnings.label          "Choose which warning messages you want to see while browsing the web">
-
-<!ENTITY  warningSettings.label         "Settings…">
-<!ENTITY  warningSettings.accesskey     "S">
deleted file mode 100644
--- a/browser/locales/en-US/chrome/browser/preferences/securityWarnings.dtd
+++ /dev/null
@@ -1,13 +0,0 @@
-<!ENTITY securityWarnings.title                   "Security Warnings">
-
-<!ENTITY security.warn_when                       "Show a warning dialog when:">
-<!ENTITY security.warn_entering_secure.label      "I am about to view an encrypted page.">
-<!ENTITY security.warn_entering_secure.accesskey  "v">
-<!ENTITY security.warn_entering_weak.label        "I am about to view a page that uses low-grade encryption.">
-<!ENTITY security.warn_entering_weak.accesskey    "g">
-<!ENTITY security.warn_leaving_secure.label       "I leave an encrypted page for one that isn't encrypted.">
-<!ENTITY security.warn_leaving_secure.accesskey   "l">
-<!ENTITY security.warn_submit_insecure.label      "I submit information that's not encrypted.">
-<!ENTITY security.warn_submit_insecure.accesskey  "s">
-<!ENTITY security.warn_viewing_mixed.label        "I'm about to view an encrypted page that contains some unencrypted information.">
-<!ENTITY security.warn_viewing_mixed.accesskey    "u">
--- a/browser/locales/jar.mn
+++ b/browser/locales/jar.mn
@@ -54,17 +54,16 @@
     locale/browser/preferences/fonts.dtd              (%chrome/browser/preferences/fonts.dtd)
     locale/browser/preferences/main.dtd               (%chrome/browser/preferences/main.dtd)
     locale/browser/preferences/languages.dtd          (%chrome/browser/preferences/languages.dtd)
     locale/browser/preferences/permissions.dtd        (%chrome/browser/preferences/permissions.dtd)
     locale/browser/preferences/preferences.dtd        (%chrome/browser/preferences/preferences.dtd)
     locale/browser/preferences/preferences.properties (%chrome/browser/preferences/preferences.properties)
     locale/browser/preferences/privacy.dtd            (%chrome/browser/preferences/privacy.dtd)
     locale/browser/preferences/security.dtd           (%chrome/browser/preferences/security.dtd)
-    locale/browser/preferences/securityWarnings.dtd   (%chrome/browser/preferences/securityWarnings.dtd)
     locale/browser/preferences/tabs.dtd               (%chrome/browser/preferences/tabs.dtd)
     locale/browser/sidebar/sidebar.properties      (%chrome/browser/sidebar/sidebar.properties)
 % locale browser-region @AB_CD@ %locale/browser-region/
     locale/browser-region/region.properties        (%chrome/browser-region/region.properties)
 # the following files are browser-specific overrides
 *   locale/browser/netError.dtd                (%chrome/overrides/netError.dtd)
 *   locale/browser/appstrings.properties       (%chrome/overrides/appstrings.properties)
 *   locale/browser/downloads/settingsChange.dtd  (%chrome/overrides/settingsChange.dtd)
--- a/browser/themes/Makefile.in
+++ b/browser/themes/Makefile.in
@@ -45,17 +45,17 @@ include $(DEPTH)/config/autoconf.mk
 #
 # Theme Selection
 #
 # Windows                 Winstripe
 # GNOME/Linux             Gnomestripe
 # MacOS X                 Pinstripe
 #
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 DIRS = pinstripe
 else
 DIRS = winstripe
 endif
 ifneq (,$(filter gtk2 qt,$(MOZ_WIDGET_TOOLKIT)))
 DIRS = gnomestripe
 endif
 
deleted file mode 100755
--- a/build/unix/mozilla-config.in
+++ /dev/null
@@ -1,142 +0,0 @@
-#!/bin/sh
-
-prefix=%prefix%
-exec_prefix=%exec_prefix%
-exec_prefix_set=no
-
-usage()
-{
-	cat <<EOF
-Usage: $0 [OPTIONS] [LIBRARIES]
-Options:
-	[--prefix[=DIR]]
-	[--exec-prefix[=DIR]]
-	[--version]
-	[--defines]
-	[--libs] [libraries]
-	[--cflags] [components]
-        [--idlflags]
-Components:
-    *
-Libraries:
-    xpcom
-    nspr
-    js
-    jsj
-    gfx
-EOF
-	exit $1
-}
-
-if test $# -eq 0; then
-	usage 1 1>&2
-fi
-
-while test $# -gt 0; do
-  case "$1" in
-  -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
-  *) optarg= ;;
-  esac
-
-  case $1 in
-    --prefix=*)
-      prefix=$optarg
-      if test $exec_prefix_set = no ; then
-        exec_prefix=$optarg
-      fi
-      ;;
-    --prefix)
-      echo_prefix=yes
-      ;;
-    --exec-prefix=*)
-      exec_prefix=$optarg
-      exec_prefix_set=yes
-      ;;
-    --exec-prefix)
-      echo_exec_prefix=yes
-      ;;
-    --version)
-      echo %MOZILLA_VERSION%
-      exit 0
-      ;;
-    --cflags)
-      if test "%includedir%" != /usr/include ; then
-        includes="-I%includedir%"
-      fi
-      echo_cflags=yes
-      ;;
-    --defines)
-      echo_defines=yes
-      ;;
-    --libs)
-      echo_libs=yes
-      ;;
-    --idlflags)
-      echo_idlflags=yes
-      ;;
-    xpcom|js|nspr|gfx|jsj)
-      echo_components="$echo_components $1"
-      echo_libraries="$echo_libraries $1"
-      ;;
-    xpconnect)
-      echo_components="$echo_components $1"
-      ;;
-    "")
-      usage 1 1>&2
-      ;;
-    *)
-      echo_components="$echo_components $1"
-      ;;
-  esac
-  shift
-done
-
-if test "$echo_prefix" = "yes"; then
-	echo $prefix
-fi
-if test "$echo_exec_prefix" = "yes"; then
-	echo $exec_prefix
-fi
-
-if test "$echo_defines" = "yes"; then
-    echo %DEFS%
-fi
-
-if test "$echo_cflags" = "yes"; then
-    nspr_cflags="%FULL_NSPR_CFLAGS%"
-    for n in $echo_components; do
-	component_includes="$component_includes -I%includedir%/$n"
-    done
-    echo $component_includes $includes $nspr_cflags
-fi
-
-if test "$echo_idlflags" = "yes"; then
-    echo "-I%idldir%"
-fi
-
-_nspr_libs="%FULL_NSPR_LIBS%"
-_xpcom_libs="-lxpcom $_nspr_libs"
-_js_libs="-ljs"
-
-if test "$echo_libs" = "yes"; then
-    for l in $echo_libraries; do
-	case "$l" in
-	gfx) 
-	    libs="$libs -lgkgfx $_xpcom_libs"
-	    ;;
-	xpcom)
-	    libs="$libs $_xpcom_libs"
-	    ;;
-	nspr)
-	    libs="$libs $_nspr_libs"
-	    ;;
-	js)
-	    libs="$libs $_js_libs"
-	    ;;
-	jsj)
-	    libs="$libs -ljsj $_js_libs $_xpcom_libs"
-	    ;;
-        esac
-    done
-    echo -L%libdir% $libs
-fi
deleted file mode 100644
--- a/build/unix/nspr_my_config.mk.in
+++ /dev/null
@@ -1,8 +0,0 @@
-USE_PTHREADS=@MOZ_NSPRENV_USE_PTHREADS@
-BUILD_OPT=@MOZ_NSPRENV_BUILD_OPT@
-NS_USE_GCC=@MOZ_NSPRENV_NS_USE_GCC@
-NO_MDUPDATE=@MOZ_NSPRENV_NO_MDUPDATE@
-NS_USE_NATIVE=@MOZ_NSPRENV_NS_USE_NATIVE@
-MOZILLA_CLIENT=@MOZ_NSPRENV_MOZILLA_CLIENT@
-CLASSIC_NSPR=@MOZ_NSPRENV_CLASSIC_NSPR@
-GC_LEAK_DETECTOR=@MOZ_NSPRENV_GC_LEAK_DETECTOR@
deleted file mode 100644
--- a/build/unix/nspr_my_overrides.mk.in
+++ /dev/null
@@ -1,12 +0,0 @@
-DIST=@MOZ_NSPRENV_DIST@
-MOZ_NSPRENV_OVERRIDE_MAKE=@MOZ_NSPRENV_OVERRIDE_MAKE@
-MOZ_NSPRENV_OVERRIDE_DSO_LDOPTS=@MOZ_NSPRENV_OVERRIDE_DSO_LDOPTS@
-
-ifdef MOZ_NSPRENV_OVERRIDE_MAKE
-MAKE=$(MOZ_NSPRENV_OVERRIDE_MAKE)
-endif
-
-ifdef MOZ_NSPRENV_OVERRIDE_DSO_LDOPTS
-DSO_LDOPTS=$(MOZ_NSPRENV_OVERRIDE_DSO_LDOPTS)
-endif
-
--- a/chrome/src/Makefile.in
+++ b/chrome/src/Makefile.in
@@ -61,17 +61,17 @@ EXTRA_DSO_LDOPTS = \
                 $(MOZ_UNICHARUTIL_LIBS) \
                 $(MOZ_COMPONENT_LIBS) \
                 $(NULL)
 
 ifneq (,$(filter gtk2,$(MOZ_WIDGET_TOOLKIT)))
 EXTRA_DSO_LDOPTS += $(MOZ_GTK2_LIBS)
 endif
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 EXTRA_DSO_LDOPTS += $(TK_LIBS)
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 ifneq (,$(filter gtk2,$(MOZ_WIDGET_TOOLKIT)))
 CXXFLAGS          += $(MOZ_GTK2_CFLAGS)
 endif
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -228,18 +228,16 @@ MOZ_NATIVE_PNG	= @SYSTEM_PNG@
 MOZ_TREE_CAIRO = @MOZ_TREE_CAIRO@
 
 MOZ_UPDATE_XTERM = @MOZ_UPDATE_XTERM@
 MOZ_MATHML = @MOZ_MATHML@
 MOZ_PERMISSIONS = @MOZ_PERMISSIONS@
 MOZ_XTF = @MOZ_XTF@
 MOZ_NO_INSPECTOR_APIS = @MOZ_NO_INSPECTOR_APIS@
 MOZ_SVG = @MOZ_SVG@
-MOZ_ENABLE_CANVAS = @MOZ_ENABLE_CANVAS@
-MOZ_ENABLE_CANVAS3D = @MOZ_ENABLE_CANVAS3D@
 MOZ_CAIRO_CFLAGS = @MOZ_CAIRO_CFLAGS@
 MOZ_SMIL = @MOZ_SMIL@
 MOZ_XSLT_STANDALONE = @MOZ_XSLT_STANDALONE@
 
 MOZ_PREF_EXTENSIONS = @MOZ_PREF_EXTENSIONS@
 
 MOZ_CAIRO_LIBS = @MOZ_CAIRO_LIBS@
 
--- a/config/static-rules.mk
+++ b/config/static-rules.mk
@@ -15,11 +15,11 @@ nsStaticComponents.cpp: $(topsrcdir)/con
 	> $(_TARGET)
 
 GARBAGE += nsStaticComponents.cpp
 
 ifeq ($(OS_ARCH),IRIX)
 LDFLAGS	+= -Wl,-LD_LAYOUT:lgot_buffer=80
 endif
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 LIBS	+= -framework QuickTime -framework IOKit -lcrypto
 endif
--- a/configure.in
+++ b/configure.in
@@ -4455,18 +4455,16 @@ dnl ====================================
 MOZ_ARG_HEADER(Application)
 
 BUILD_STATIC_LIBS=
 ENABLE_TESTS=1
 MOZ_ACTIVEX_SCRIPTING_SUPPORT=
 MOZ_BRANDING_DIRECTORY=
 MOZ_OFFICIAL_BRANDING=
 MOZ_DBGRINFO_MODULES=
-MOZ_ENABLE_CANVAS=1
-MOZ_ENABLE_CANVAS3D=1
 MOZ_FEEDS=1
 MOZ_IMG_DECODERS_DEFAULT="png gif jpeg bmp icon"
 MOZ_IMG_ENCODERS_DEFAULT="png jpeg"
 MOZ_JAVAXPCOM=
 MOZ_JSDEBUGGER=1
 MOZ_JSLOADER=1
 MOZ_MATHML=1
 MOZ_MORK=1
@@ -5778,34 +5776,16 @@ MOZ_ARG_DISABLE_BOOL(mathml,
 [  --disable-mathml        Disable MathML support],
     MOZ_MATHML=,
     MOZ_MATHML=1 )
 if test "$MOZ_MATHML"; then
   AC_DEFINE(MOZ_MATHML)
 fi
 
 dnl ========================================================
-dnl Canvas
-dnl ========================================================
-if test -n "$MOZ_ENABLE_CANVAS"; then
-    AC_DEFINE(MOZ_ENABLE_CANVAS)
-fi
-AC_SUBST(MOZ_ENABLE_CANVAS)
-
-MOZ_ARG_DISABLE_BOOL(webgl,
-[  --disable-webgl         Disable WebGL context (canvas 3d)],
-    MOZ_ENABLE_CANVAS3D=,
-    MOZ_ENABLE_CANVAS3D=1 )
-
-if test -n "$MOZ_ENABLE_CANVAS3D"; then
-    AC_DEFINE(MOZ_ENABLE_CANVAS3D)
-fi
-AC_SUBST(MOZ_ENABLE_CANVAS3D)
-
-dnl ========================================================
 dnl SVG
 dnl ========================================================
 MOZ_ARG_DISABLE_BOOL(svg,
 [  --disable-svg            Disable SVG support],
     MOZ_SVG=,
     MOZ_SVG=1 )
 if test -n "$MOZ_SVG"; then
   AC_DEFINE(MOZ_SVG)
@@ -7394,17 +7374,17 @@ if test "$MOZ_TREE_CAIRO"; then
         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
         FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
         MOZ_ENABLE_CAIRO_FT=1
         CAIRO_FT_CFLAGS="$FT2_CFLAGS"
     fi
     if test "$MOZ_WIDGET_TOOLKIT" = "qt"; then
         QPAINTER_SURFACE_FEATURE="#define CAIRO_HAS_QPAINTER_SURFACE 1"
     fi
-    if test "$MOZ_WIDGET_TOOLKIT" = "mac" -o "$MOZ_WIDGET_TOOLKIT" = "cocoa"; then
+    if test "$MOZ_WIDGET_TOOLKIT" = "cocoa"; then
         QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
         QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
         QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
     fi
     if test "$MOZ_WIDGET_TOOLKIT" = "windows"; then
         WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
         if test -z "$WINCE"; then
             WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
--- a/content/canvas/public/Makefile.in
+++ b/content/canvas/public/Makefile.in
@@ -38,26 +38,21 @@
 DEPTH		= ../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= content
+XPIDL_MODULE = content_canvas
 
 EXPORTS		= \
 		nsICanvasRenderingContextInternal.h \
 		nsICanvasElement.h \
 		WebGLArray.h \
 		$(NULL)
 
-ifdef MOZ_ENABLE_CANVAS3D
-
-XPIDL_MODULE = content_canvas
-
 XPIDLSRCS	= \
 		nsICanvasGLPrivate.idl \
 		$(NULL)
 
-endif
-
 include $(topsrcdir)/config/rules.mk
--- a/content/canvas/src/Makefile.in
+++ b/content/canvas/src/Makefile.in
@@ -52,20 +52,20 @@ CPPSRCS	= \
 	CanvasUtils.cpp \
 	nsCanvasRenderingContext2D.cpp \
 	$(NULL)
 
 # Canvas 3D Pieces
 
 # only allow on platforms/toolkits we know are good
 ifneq (,$(NS_OSSO)$(WINCE)$(filter-out windows cocoa gtk2,$(MOZ_WIDGET_TOOLKIT)))
-MOZ_ENABLE_CANVAS3D=
+DISABLE_WEBGL=1
 endif
 
-ifdef MOZ_ENABLE_CANVAS3D
+ifndef DISABLE_WEBGL
 
 CPPSRCS += \
 	WebGLContext.cpp \
 	WebGLContextGL.cpp \
 	WebGLContextUtils.cpp \
 	WebGLContextValidate.cpp \
 	NativeJSContext.cpp \
 	glwrap.cpp \
@@ -85,17 +85,17 @@ ifdef WINCE
 CPPSRCS += nsGLPbufferEGL.cpp
 DEFINES += -DUSE_EGL
 else
 CPPSRCS += nsGLPbufferWGL.cpp
 DEFINES += -DUSE_WGL
 endif
 endif
 
-ifneq (,$(filter $(MOZ_WIDGET_TOOLKIT),mac cocoa))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 CPPSRCS += nsGLPbufferCGL.cpp
 DEFINES += -DUSE_CGL
 endif
 
 else
 
 CPPSRCS += WebGLContextNotSupported.cpp
 
--- a/content/canvas/src/glwrap.cpp
+++ b/content/canvas/src/glwrap.cpp
@@ -46,16 +46,17 @@
 #include "prlink.h"
 
 #include "glwrap.h"
 
 #define MAX_SYMBOL_LENGTH 128
 #define MAX_SYMBOL_NAMES 5
 
 #ifdef MOZ_X11
+#define GLX_GLXEXT_LEGACY
 #include <GL/glx.h>
 #endif
 
 bool
 LibrarySymbolLoader::OpenLibrary(const char *library)
 {
     PRLibSpec lspec;
     lspec.type = PR_LibSpec_Pathname;
--- a/content/canvas/src/nsGLPbuffer.h
+++ b/content/canvas/src/nsGLPbuffer.h
@@ -53,16 +53,17 @@
 #include "gfxDDrawSurface.h"
 #endif
 
 #if defined(XP_WIN)
 #include "gfxWindowsSurface.h"
 #endif
 
 #if defined(XP_UNIX) && defined(MOZ_X11)
+#define GLX_GLXEXT_LEGACY
 #include "GL/glx.h"
 #endif
 
 #ifdef XP_MACOSX
 #include "gfxQuartzImageSurface.h"
 #include <OpenGL/CGLTypes.h>
 #endif
 
--- a/content/canvas/src/nsGLPbufferWGL.cpp
+++ b/content/canvas/src/nsGLPbufferWGL.cpp
@@ -50,33 +50,61 @@ using namespace mozilla;
 static PRUint32 gActiveBuffers = 0;
 
 class WGLWrap
     : public LibrarySymbolLoader
 {
 public:
     WGLWrap() : fCreatePbuffer(0) { }
 
+    bool InitEarly();
     bool Init();
 
 public:
+    // early init
+    typedef HANDLE (WINAPI * PFNWGLCREATECONTEXTPROC) (HDC hDC);
+    PFNWGLCREATECONTEXTPROC fCreateContext;
+    typedef BOOL (WINAPI * PFNWGLMAKECURRENTPROC) (HDC hDC, HANDLE hglrc);
+    PFNWGLMAKECURRENTPROC fMakeCurrent;
+    typedef PROC (WINAPI * PFNWGLGETPROCADDRESSPROC) (LPCSTR proc);
+    PFNWGLGETPROCADDRESSPROC fGetProcAddress;
+    typedef BOOL (WINAPI * PFNWGLDELETECONTEXTPROC) (HANDLE hglrc);
+    PFNWGLDELETECONTEXTPROC fDeleteContext;
+
     typedef HANDLE (WINAPI * PFNWGLCREATEPBUFFERPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList);
     PFNWGLCREATEPBUFFERPROC fCreatePbuffer;
     typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERPROC) (HANDLE hPbuffer);
     PFNWGLDESTROYPBUFFERPROC fDestroyPbuffer;
     typedef HDC (WINAPI * PFNWGLGETPBUFFERDCPROC) (HANDLE hPbuffer);
     PFNWGLGETPBUFFERDCPROC fGetPbufferDC;
 
     typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
     PFNWGLCHOOSEPIXELFORMATPROC fChoosePixelFormat;
     typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int *piValues);
     PFNWGLGETPIXELFORMATATTRIBIVPROC fGetPixelFormatAttribiv;
 };
 
 bool
+WGLWrap::InitEarly()
+{
+    if (fCreateContext)
+        return true;
+
+    SymLoadStruct symbols[] = {
+        { (PRFuncPtr*) &fCreateContext, { "wglCreateContext", NULL } },
+        { (PRFuncPtr*) &fMakeCurrent, { "wglMakeCurrent", NULL } },
+        { (PRFuncPtr*) &fGetProcAddress, { "wglGetProcAddress", NULL } },
+        { (PRFuncPtr*) &fDeleteContext, { "wglDeleteContext", NULL } },
+        { NULL, { NULL } }
+    };
+
+    return LoadSymbols(&symbols[0], false);
+}
+
+bool
 WGLWrap::Init()
 {
     if (fCreatePbuffer)
         return true;
 
     SymLoadStruct symbols[] = {
         { (PRFuncPtr*) &fCreatePbuffer, { "wglCreatePbufferARB", "wglCreatePbufferEXT", NULL } },
         { (PRFuncPtr*) &fDestroyPbuffer, { "wglDestroyPbufferARB", "wglDestroyPbufferEXT", NULL } },
@@ -103,17 +131,20 @@ PRBool
 nsGLPbufferWGL::Init(WebGLContext *priv)
 {
     // XXX lookup SYSTEM32 path!
     char *opengl32 = "C:\\WINDOWS\\SYSTEM32\\OPENGL32.DLL";
 
     if (!gWGLWrap.OpenLibrary(opengl32))
         return PR_FALSE;
 
-    gWGLWrap.SetLookupFunc((LibrarySymbolLoader::PlatformLookupFunction) wglGetProcAddress);
+    if (!gWGLWrap.InitEarly())
+        return PR_FALSE;
+
+    gWGLWrap.SetLookupFunc((LibrarySymbolLoader::PlatformLookupFunction) gWGLWrap.fGetProcAddress);
 
     mPriv = priv;
     
     WNDCLASS wc;
     PIXELFORMATDESCRIPTOR pfd;
 
     if (!GetClassInfo(GetModuleHandle(NULL), "GLEW", &wc)) {
         ZeroMemory(&wc, sizeof(WNDCLASS));
@@ -151,39 +182,39 @@ nsGLPbufferWGL::Init(WebGLContext *priv)
 
     // set the pixel format for the dc
     if (!SetPixelFormat(mGlewDC, pixelformat, &pfd)) {
         LogMessage("Canvas 3D: SetPixelFormat failed");
         return PR_FALSE;
     }
 
     // create rendering context
-    mGlewWglContext = wglCreateContext(mGlewDC);
+    mGlewWglContext = gWGLWrap.fCreateContext(mGlewDC);
     if (!mGlewWglContext) {
         LogMessage("Canvas 3D: wglCreateContext failed");
         return PR_FALSE;
     }
 
-    if (!wglMakeCurrent(mGlewDC, (HGLRC) mGlewWglContext)) {
+    if (!gWGLWrap.fMakeCurrent(mGlewDC, (HGLRC) mGlewWglContext)) {
         LogMessage("Canvas 3D: wglMakeCurrent failed");
         return PR_FALSE;
     }
 
     // grab all the wgl extension pieces that we couldn't grab before
     // we had a context
     if (!gWGLWrap.Init())
         return PR_FALSE;
 
     // XXX look up system32 dir
     if (!mGLWrap.OpenLibrary(opengl32)) {
         LogMessage("Canvas 3D: Failed to open opengl32.dll (only looked in c:\\windows\\system32, fixme)");
         return PR_FALSE;
     }
 
-    mGLWrap.SetLookupFunc((LibrarySymbolLoader::PlatformLookupFunction) wglGetProcAddress);
+    mGLWrap.SetLookupFunc((LibrarySymbolLoader::PlatformLookupFunction) gWGLWrap.fGetProcAddress);
 
     if (!mGLWrap.Init(GLES20Wrap::TRY_NATIVE_GL)) {
         LogMessage("Canvas 3D: GLWrap init failed");
         return PR_FALSE;
     }
 
     return PR_TRUE;
 }
@@ -219,17 +250,17 @@ nsGLPbufferWGL::Resize(PRInt32 width, PR
         return PR_FALSE;
     }
 
     // clear the surface
     memset (mThebesSurface->Data(),
             0,
             height * mThebesSurface->Stride());
 
-    if (!wglMakeCurrent(mGlewDC, (HGLRC) mGlewWglContext)) {
+    if (!gWGLWrap.fMakeCurrent(mGlewDC, (HGLRC) mGlewWglContext)) {
         fprintf (stderr, "Error: %d\n", GetLastError());
         LogMessage("Canvas 3D: wglMakeCurrent failed");
         return PR_FALSE;
     }
 
     PRBool ignoreAA = PR_FALSE;
     int attribs[] = {
         WGL_SUPPORT_OPENGL_ARB, LOCAL_GL_TRUE,
@@ -345,17 +376,17 @@ TRY_FIND_AGAIN:
     int pbattribs = 0;
     mPbuffer = gWGLWrap.fCreatePbuffer(mGlewDC, chosenFormat, width, height, &pbattribs);
     if (!mPbuffer) {
         LogMessage("Canvas 3D: Failed to create pbuffer");
         return PR_FALSE;
     }
 
     mPbufferDC = gWGLWrap.fGetPbufferDC(mPbuffer);
-    mPbufferContext = wglCreateContext(mPbufferDC);
+    mPbufferContext = gWGLWrap.fCreateContext(mPbufferDC);
 
     mWindowsSurface = new gfxWindowsSurface(gfxIntSize(width, height), gfxASurface::ImageFormatARGB32);
     if (mWindowsSurface && mWindowsSurface->CairoStatus() == 0)
         mThebesSurface = mWindowsSurface->GetImageSurface();
 
     mWidth = width;
     mHeight = height;
 
@@ -365,28 +396,28 @@ TRY_FIND_AGAIN:
 
 void
 nsGLPbufferWGL::Destroy()
 {
     sCurrentContextToken = nsnull;
     mThebesSurface = nsnull;
 
     if (mPbuffer) {
-        wglDeleteContext((HGLRC) mPbufferContext);
+        gWGLWrap.fDeleteContext((HGLRC) mPbufferContext);
         gWGLWrap.fDestroyPbuffer(mPbuffer);
         mPbuffer = nsnull;
     }
 }
 
 nsGLPbufferWGL::~nsGLPbufferWGL()
 {
     Destroy();
 
     if (mGlewWglContext) {
-        wglDeleteContext((HGLRC) mGlewWglContext);
+        gWGLWrap.fDeleteContext((HGLRC) mGlewWglContext);
         mGlewWglContext = nsnull;
     }
 
     if (mGlewWindow) {
         DestroyWindow(mGlewWindow);
         mGlewWindow = nsnull;
     }
 
@@ -396,17 +427,17 @@ nsGLPbufferWGL::~nsGLPbufferWGL()
 }
 
 void
 nsGLPbufferWGL::MakeContextCurrent()
 {
     if (sCurrentContextToken == mPbufferContext)
         return;
 
-    wglMakeCurrent (mPbufferDC, (HGLRC) mPbufferContext);
+    gWGLWrap.fMakeCurrent (mPbufferDC, (HGLRC) mPbufferContext);
     sCurrentContextToken = mPbufferContext;
 }
 
 void
 nsGLPbufferWGL::SwapBuffers()
 {
     MakeContextCurrent();
     mGLWrap.fReadPixels (0, 0, mWidth, mHeight, LOCAL_GL_BGRA, LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV, mThebesSurface->Data());
--- a/content/xbl/builtin/Makefile.in
+++ b/content/xbl/builtin/Makefile.in
@@ -40,17 +40,17 @@ topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 ifneq (,$(filter OS2 WINNT WINCE,$(OS_ARCH)))
 DIRS	= win
 else
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 DIRS	= mac
 else
 ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
 DIRS	= gtk2
 else
 DIRS	= unix
 endif
 endif
--- a/docshell/build/Makefile.in
+++ b/docshell/build/Makefile.in
@@ -91,17 +91,17 @@ LOCAL_INCLUDES	= \
 		-I$(srcdir) \
 		-I$(srcdir)/../base \
 		-I$(srcdir)/../shistory/src \
 		-I$(topsrcdir)/uriloader/base \
 		-I$(topsrcdir)/uriloader/prefetch \
 		-I$(topsrcdir)/uriloader/exthandler \
 		$(NULL)
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 LOCAL_INCLUDES += -I$(topsrcdir)/uriloader/exthandler/mac
 EXTRA_DSO_LDOPTS += \
         $(TK_LIBS) \
         $(NULL)
 endif
 
 ifeq ($(OS_ARCH),WINNT)
 OS_LIBS		+= $(call EXPAND_LIBNAME, shell32 ole32)
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -425,23 +425,19 @@
 #include "nsIDOMSVGTSpanElement.h"
 #include "nsIDOMSVGURIReference.h"
 #include "nsIDOMSVGUseElement.h"
 #include "nsIDOMSVGUnitTypes.h"
 #include "nsIDOMSVGZoomAndPan.h"
 #include "nsIDOMSVGZoomEvent.h"
 #endif // MOZ_SVG
 
-#ifdef MOZ_ENABLE_CANVAS
 #include "nsIDOMCanvasRenderingContext2D.h"
-#ifdef MOZ_ENABLE_CANVAS3D
 #include "nsICanvasRenderingContextWebGL.h"
 #include "WebGLArray.h"
-#endif
-#endif
 
 #include "nsIImageDocument.h"
 
 // Storage includes
 #include "nsDOMStorage.h"
 
 // Drag and drop
 #include "nsIDOMDataTransfer.h"
@@ -1143,26 +1139,24 @@ static nsDOMClassInfoData sClassInfoData
   NS_DEFINE_CLASSINFO_DATA(SVGUnitTypes, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(SVGZoomEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 #endif // MOZ_SVG
 
   NS_DEFINE_CLASSINFO_DATA(HTMLCanvasElement, nsHTMLElementSH,
                            ELEMENT_SCRIPTABLE_FLAGS)
-#ifdef MOZ_ENABLE_CANVAS
   NS_DEFINE_CLASSINFO_DATA(CanvasRenderingContext2D, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(CanvasGradient, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(CanvasPattern, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(TextMetrics, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
-#endif // MOZ_ENABLE_CANVAS
 
   NS_DEFINE_CLASSINFO_DATA(SmartCardEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(PageTransitionEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(WindowUtils, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
@@ -1313,17 +1307,16 @@ static nsDOMClassInfoData sClassInfoData
 #ifdef MOZ_MATHML
   NS_DEFINE_CLASSINFO_DATA_WITH_NAME(MathMLElement, Element, nsElementSH,
                                      ELEMENT_SCRIPTABLE_FLAGS)
 #endif
 
   NS_DEFINE_CLASSINFO_DATA(Worker, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
-#ifdef MOZ_ENABLE_CANVAS3D
   NS_DEFINE_CLASSINFO_DATA(CanvasRenderingContextWebGL, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(WebGLBuffer, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(WebGLTexture, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(WebGLProgram, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
@@ -1342,17 +1335,16 @@ static nsDOMClassInfoData sClassInfoData
   NS_DEFINE_CLASSINFO_DATA(WebGLShortArray, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(WebGLUnsignedShortArray, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(WebGLIntArray, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(WebGLUnsignedIntArray, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
-#endif
 };
 
 // Objects that shuld be constructable through |new Name();|
 struct nsContractIDMapData
 {
   PRInt32 mDOMClassInfoID;
   const char *mContractID;
 };
@@ -1377,25 +1369,25 @@ struct nsConstructorFuncMapData
 };
 
 #define NS_DEFINE_CONSTRUCTOR_FUNC_DATA(_class, _func)                        \
   { eDOMClassInfo_##_class##_id, _func },
 
 static const nsConstructorFuncMapData kConstructorFuncMap[] =
 {
   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(Worker, nsDOMWorker::NewWorker)
-#ifdef MOZ_ENABLE_CANVAS3D
+
+  // WebGL Array Types
   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(WebGLFloatArray, NS_NewCanvasFloatArray)
   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(WebGLByteArray, NS_NewCanvasByteArray)
   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(WebGLUnsignedByteArray, NS_NewCanvasUnsignedByteArray)
   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(WebGLShortArray, NS_NewCanvasShortArray)
   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(WebGLUnsignedShortArray, NS_NewCanvasUnsignedShortArray)
   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(WebGLIntArray, NS_NewCanvasIntArray)
   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(WebGLUnsignedIntArray, NS_NewCanvasUnsignedIntArray)
-#endif
 };
 
 nsIXPConnect *nsDOMClassInfo::sXPConnect = nsnull;
 nsIScriptSecurityManager *nsDOMClassInfo::sSecMan = nsnull;
 PRBool nsDOMClassInfo::sIsInitialized = PR_FALSE;
 PRBool nsDOMClassInfo::sDisableDocumentAllSupport = PR_FALSE;
 PRBool nsDOMClassInfo::sDisableGlobalScopePollutionSupport = PR_FALSE;
 
@@ -3386,33 +3378,31 @@ nsDOMClassInfo::Init()
   DOM_CLASSINFO_MAP_END
 #endif // MOZ_SVG
 
   DOM_CLASSINFO_MAP_BEGIN(HTMLCanvasElement, nsIDOMHTMLCanvasElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLCanvasElement)
     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
-#ifdef MOZ_ENABLE_CANVAS
   DOM_CLASSINFO_MAP_BEGIN(CanvasRenderingContext2D, nsIDOMCanvasRenderingContext2D)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCanvasRenderingContext2D)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(CanvasGradient, nsIDOMCanvasGradient)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCanvasGradient)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(CanvasPattern, nsIDOMCanvasPattern)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCanvasPattern)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(TextMetrics, nsIDOMTextMetrics)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMTextMetrics)
   DOM_CLASSINFO_MAP_END
-#endif // MOZ_ENABLE_CANVAS
 
   DOM_CLASSINFO_MAP_BEGIN(XSLTProcessor, nsIXSLTProcessor)
     DOM_CLASSINFO_MAP_ENTRY(nsIXSLTProcessor)
     DOM_CLASSINFO_MAP_ENTRY(nsIXSLTProcessorObsolete) // XXX DEPRECATED
     DOM_CLASSINFO_MAP_ENTRY(nsIXSLTProcessorPrivate)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(XPathEvaluator, nsIDOMXPathEvaluator)
@@ -3636,17 +3626,16 @@ nsDOMClassInfo::Init()
 #endif
 
   DOM_CLASSINFO_MAP_BEGIN(Worker, nsIWorker)
     DOM_CLASSINFO_MAP_ENTRY(nsIWorker)
     DOM_CLASSINFO_MAP_ENTRY(nsIAbstractWorker)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
   DOM_CLASSINFO_MAP_END
 
-#ifdef MOZ_ENABLE_CANVAS3D
   DOM_CLASSINFO_MAP_BEGIN(CanvasRenderingContextWebGL, nsICanvasRenderingContextWebGL)
     DOM_CLASSINFO_MAP_ENTRY(nsICanvasRenderingContextWebGL)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(WebGLBuffer, nsIWebGLBuffer)
     DOM_CLASSINFO_MAP_ENTRY(nsIWebGLBuffer)
   DOM_CLASSINFO_MAP_END
 
@@ -3692,17 +3681,16 @@ nsDOMClassInfo::Init()
 
   DOM_CLASSINFO_MAP_BEGIN(WebGLIntArray, nsIWebGLIntArray)
     DOM_CLASSINFO_MAP_ENTRY(nsIWebGLIntArray)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(WebGLUnsignedIntArray, nsIWebGLUnsignedIntArray)
     DOM_CLASSINFO_MAP_ENTRY(nsIWebGLUnsignedIntArray)
   DOM_CLASSINFO_MAP_END
-#endif
 
 #ifdef NS_DEBUG
   {
     PRUint32 i = NS_ARRAY_LENGTH(sClassInfoData);
 
     if (i != eDOMClassInfoIDCount) {
       NS_ERROR("The number of items in sClassInfoData doesn't match the "
                "number of nsIDOMClassInfo ID's, this is bad! Fix it!");
--- a/dom/base/nsDOMClassInfoID.h
+++ b/dom/base/nsDOMClassInfoID.h
@@ -349,22 +349,20 @@ enum nsDOMClassInfoID {
   eDOMClassInfo_SVGTransform_id,
   eDOMClassInfo_SVGTransformList_id,
   eDOMClassInfo_SVGUnitTypes_id,
   eDOMClassInfo_SVGZoomEvent_id,
 #endif // MOZ_SVG
 
   // Canvas
   eDOMClassInfo_HTMLCanvasElement_id,
-#ifdef MOZ_ENABLE_CANVAS
   eDOMClassInfo_CanvasRenderingContext2D_id,
   eDOMClassInfo_CanvasGradient_id,
   eDOMClassInfo_CanvasPattern_id,
   eDOMClassInfo_TextMetrics_id,
-#endif
 
   // SmartCard Events
   eDOMClassInfo_SmartCardEvent_id,
   
   // PageTransition Events
   eDOMClassInfo_PageTransitionEvent_id,
 
   // WindowUtils
@@ -458,33 +456,33 @@ enum nsDOMClassInfoID {
   eDOMClassInfo_SimpleGestureEvent_id,
 
 #ifdef MOZ_MATHML
   eDOMClassInfo_MathMLElement_id,
 #endif
 
   eDOMClassInfo_Worker_id,
 
-#ifdef MOZ_ENABLE_CANVAS3D
+  // WebGL
   eDOMClassInfo_CanvasRenderingContextWebGL_id,
   eDOMClassInfo_WebGLBuffer_id,
   eDOMClassInfo_WebGLTexture_id,
   eDOMClassInfo_WebGLProgram_id,
   eDOMClassInfo_WebGLShader_id,
   eDOMClassInfo_WebGLFramebuffer_id,
   eDOMClassInfo_WebGLRenderbuffer_id,
 
+  // WebGL Buffers
   eDOMClassInfo_WebGLFloatArray_id,
   eDOMClassInfo_WebGLByteArray_id,
   eDOMClassInfo_WebGLUnsignedByteArray_id,
   eDOMClassInfo_WebGLShortArray_id,
   eDOMClassInfo_WebGLUnsignedShortArray_id,
   eDOMClassInfo_WebGLIntArray_id,
   eDOMClassInfo_WebGLUnsignedIntArray_id,
-#endif
 
   // This one better be the last one in this list
   eDOMClassInfoIDCount
 };
 
 /**
  * nsIClassInfo helper macros
  */
--- a/dom/interfaces/canvas/Makefile.in
+++ b/dom/interfaces/canvas/Makefile.in
@@ -41,15 +41,14 @@ srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= dom
 XPIDL_MODULE	= dom_canvas
 GRE_MODULE	= 1
 
-XPIDLSRCS = nsIDOMCanvasRenderingContext2D.idl
-
-ifdef MOZ_ENABLE_CANVAS3D
-XPIDLSRCS += nsICanvasRenderingContextWebGL.idl
-endif
+XPIDLSRCS = \
+	nsIDOMCanvasRenderingContext2D.idl \
+	nsICanvasRenderingContextWebGL.idl \
+	$(NULL)
 
 include $(topsrcdir)/config/rules.mk
--- a/embedding/browser/build/Makefile.in
+++ b/embedding/browser/build/Makefile.in
@@ -66,17 +66,17 @@ SHARED_LIBRARY_LIBS= \
 
 EXTRA_DSO_LDOPTS= \
 		$(LIBS_DIR) \
 		$(EXTRA_DSO_LIBS) \
 		$(MOZ_UNICHARUTIL_LIBS) \
 		$(MOZ_COMPONENT_LIBS) \
 		$(NULL)
 
-ifeq (mac,$(MOZ_WIDGET_TOOLKIT))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 EXTRA_DSO_LDOPTS += $(TK_LIBS)
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 INCLUDES	+= \
 		-I$(srcdir)			\
 		-I$(srcdir)/../webBrowser		\
--- a/embedding/components/build/Makefile.in
+++ b/embedding/components/build/Makefile.in
@@ -90,29 +90,29 @@ endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
 LOCAL_INCLUDES += -I$(srcdir)/../printingui/src/win 
 ifneq ($(OS_ARCH), WINCE)
 OS_LIBS	+= $(call EXPAND_LIBNAME,winspool comdlg32)
 endif
 endif
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 LOCAL_INCLUDES += -I$(srcdir)/../printingui/src/mac
 endif
 
 EXTRA_DSO_LIBS = gkgfx
 
 EXTRA_DSO_LDOPTS = \
 	$(LIBS_DIR) \
 	$(EXTRA_DSO_LIBS) \
 	$(MOZ_UNICHARUTIL_LIBS) \
 	$(MOZ_COMPONENT_LIBS) \
 	$(MOZ_JS_LIBS) \
 	$(NULL)
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 EXTRA_DSO_LDOPTS += \
         $(TK_LIBS) \
         $(NULL)
 endif
 
 include $(topsrcdir)/config/rules.mk
--- a/embedding/components/printingui/src/Makefile.in
+++ b/embedding/components/printingui/src/Makefile.in
@@ -49,17 +49,17 @@ endif
 ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
 PLATFORM_DIR = os2
 endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
 PLATFORM_DIR = win
 endif
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 PLATFORM_DIR = mac
 endif
 
 DIRS = $(PLATFORM_DIR)
 
 include $(topsrcdir)/config/rules.mk
 
 libs::
--- a/embedding/config/Makefile.in
+++ b/embedding/config/Makefile.in
@@ -38,17 +38,17 @@
 DEPTH           = ../..
 topsrcdir       = @top_srcdir@
 srcdir          = @srcdir@
 VPATH           = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
   BASEBROWSER = basebrowser-mac-macho
   CLIENTMANIFEST = client-mac-macho
   _PLATFORM = unix
 else
 ifeq (windows,$(MOZ_WIDGET_TOOLKIT))
   BASEBROWSER = basebrowser-win
   BASEBROWSER_SUPP = basebrowser-win-supp
   CLIENTMANIFEST = client-win
--- a/extensions/java/xpcom/glue/Makefile.in
+++ b/extensions/java/xpcom/glue/Makefile.in
@@ -76,14 +76,14 @@ endif
 
 LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/build
 
 EXTRA_DSO_LDOPTS = \
 	$(XPCOM_STANDALONE_GLUE_LDOPTS) \
 	$(NULL)
 
 # Need to link with CoreFoundation on Mac
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 EXTRA_DSO_LDOPTS += $(TK_LIBS)
 endif
 
 include $(topsrcdir)/config/rules.mk
 
--- a/extensions/pref/autoconfig/src/Makefile.in
+++ b/extensions/pref/autoconfig/src/Makefile.in
@@ -73,17 +73,17 @@ EXTRA_DSO_LDOPTS = \
                    $(MOZ_JS_LIBS) \
                    $(MOZ_COMPONENT_LIBS) \
                    $(NULL)
 
 AUTOCFG_JS_EXPORTS = \
 		$(srcdir)/prefcalls.js \
 		$(NULL)
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 AUTOCFG_JS_EXPORTS += $(srcdir)/mac/platform.js
 else
 ifeq ($(MOZ_WIDGET_TOOLKIT), windows)
 AUTOCFG_JS_EXPORTS += $(srcdir)/win/platform.js
 else
 ifeq ($(MOZ_WIDGET_TOOLKIT), os2)
 AUTOCFG_JS_EXPORTS += $(srcdir)/os2/platform.js
 else
--- a/gfx/cairo/cairo/src/Makefile.in
+++ b/gfx/cairo/cairo/src/Makefile.in
@@ -177,17 +177,17 @@ ifdef MOZ_OS2_HIGH_MEMORY
 DEFINES += -DOS2_HIGH_MEMORY
 endif
 CSRCS   += cairo-os2-surface.c
 EXPORTS_cairo += cairo-os2.h cairo-os2-private.h
 CSRCS   += $(PSPDF_BASE_CSRCS) $(PDF_CSRCS)
 EXPORTS_cairo += $(PDF_EXPORTS)
 endif
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 CSRCS   += cairo-quartz-surface.c cairo-quartz-image-surface.c cairo-quartz-font.c
 EXPORTS_cairo += cairo-quartz.h cairo-quartz-image.h
 endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),beos)
 CPPSRCS += cairo-beos-surface.cpp
 EXPORTS_cairo += cairo-beos.h
 endif
--- a/gfx/thebes/public/Makefile.in
+++ b/gfx/thebes/public/Makefile.in
@@ -87,17 +87,17 @@ EXPORTS +=	gfxPDFSurface.h
 endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),beos)
 EXPORTS	+=	gfxBeOSSurface.h gfxBeOSPlatform.h
 EXPORTS +=	gfxPangoFonts.h
 EXPORTS +=	gfxPDFSurface.h
 endif
 
-ifneq (,$(filter $(MOZ_WIDGET_TOOLKIT),mac cocoa))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 EXPORTS +=	gfxPlatformMac.h \
 		gfxQuartzSurface.h \
 		gfxQuartzImageSurface.h \
 		gfxQuartzPDFSurface.h \
 		gfxAtsuiFonts.h \
 		gfxQuartzNativeDrawing.h \
 		$(NULL)
 
--- a/gfx/thebes/src/gfxOS2Fonts.cpp
+++ b/gfx/thebes/src/gfxOS2Fonts.cpp
@@ -336,19 +336,19 @@ cairo_font_face_t *gfxOS2Font::CairoFont
     if (!mFontFace) {
 #ifdef DEBUG_thebes
         printf("gfxOS2Font[%#x]::CairoFontFace(): create it for %s, %f\n",
                (unsigned)this, NS_LossyConvertUTF16toASCII(GetName()).get(), GetStyle()->size);
 #endif
         FcPattern *fcPattern = FcPatternCreate();
 
         // add (family) name to pattern
-        // (the conversion should work, font names don't contain high bit chars)
+        // convert name because FC stores it in UTF8 while we have it in UTF16
         FcPatternAddString(fcPattern, FC_FAMILY,
-                           (FcChar8 *)NS_LossyConvertUTF16toASCII(GetName()).get());
+                           (FcChar8 *)NS_ConvertUTF16toUTF8(GetName()).get());
 
         // adjust font weight using the offset
         // The requirements outlined in gfxFont.h are difficult to meet without
         // having a table of available font weights, so we map the gfxFont
         // weight to possible FontConfig weights.
         PRInt8 weight, offset;
         GetStyle()->ComputeWeightAndOffset(&weight, &offset);
         // gfxFont weight   FC weight
--- a/intl/build/Makefile.in
+++ b/intl/build/Makefile.in
@@ -50,17 +50,17 @@ GRE_MODULE	= 1
 LIBXUL_LIBRARY = 1
 
 
 CPPSRCS		= \
 			nsI18nModule.cpp \
 			$(NULL)
 
 # see also intl/locale/src/Makefile.in
-ifneq (,$(filter mac os2 windows, $(MOZ_WIDGET_TOOLKIT)))
+ifneq (,$(filter os2 windows, $(MOZ_WIDGET_TOOLKIT)))
 LOCALE_DIR		= $(MOZ_WIDGET_TOOLKIT)
 else
 ifeq ($(MOZ_WIDGET_TOOLKIT), cocoa)
 LOCALE_DIR		= mac
 else
 LOCALE_DIR		= unix
 endif
 endif
@@ -81,17 +81,17 @@ SHARED_LIBRARY_LIBS = \
 			../locale/src/$(LOCALE_DIR)/$(LIB_PREFIX)platlocale_s.$(LIB_SUFFIX) \
 			$(NULL)
 
 EXTRA_DSO_LDOPTS = \
 	$(MOZ_UNICHARUTIL_LIBS) \
 	$(MOZ_COMPONENT_LIBS) \
 	$(NULL)
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 EXTRA_DSO_LDOPTS += \
         $(TK_LIBS) \
         $(NULL)
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
--- a/intl/locale/Makefile.in
+++ b/intl/locale/Makefile.in
@@ -44,15 +44,15 @@ VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= locale
 DIRS		= public idl src
 
 ifdef ENABLE_TESTS
 DIRS		+= tests
-ifneq (,$(filter mac cocoa windows, $(MOZ_WIDGET_TOOLKIT)))
+ifneq (,$(filter cocoa windows, $(MOZ_WIDGET_TOOLKIT)))
 DIRS		+= tests_multilocale
 endif
 endif
 
 include $(topsrcdir)/config/rules.mk
 
--- a/intl/locale/src/Makefile.in
+++ b/intl/locale/src/Makefile.in
@@ -42,17 +42,17 @@ VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= locale
 LIBRARY_NAME	= nslocale_s
 LIBXUL_LIBRARY  = 1
 
 
-ifneq (,$(filter mac os2 windows, $(MOZ_WIDGET_TOOLKIT)))
+ifneq (,$(filter os2 windows, $(MOZ_WIDGET_TOOLKIT)))
 DIRS		= $(MOZ_WIDGET_TOOLKIT)
 else
 ifeq ($(MOZ_WIDGET_TOOLKIT), cocoa)
 DIRS		= mac
 else
 DIRS		= unix
 endif
 endif
--- a/intl/uconv/src/Makefile.in
+++ b/intl/uconv/src/Makefile.in
@@ -82,17 +82,17 @@ CPPSRCS         += \
 endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
 CPPSRCS			+= nsOS2Charset.cpp
 else
 ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
 CPPSRCS			+= nsWinCharset.cpp
 else
-ifneq (,$(filter cocoa mac, $(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 CPPSRCS			+= nsMacCharset.cpp
 else
 ifeq ($(OS_ARCH),BeOS)
 CPPSRCS			+= nsBeOSCharset.cpp
 else
 CPPSRCS			+= nsUNIXCharset.cpp
 endif
 endif
@@ -103,17 +103,17 @@ EXTRA_DSO_LDOPTS = \
 		../util/$(LIB_PREFIX)ucvutil_s.$(LIB_SUFFIX) \
 		$(MOZ_UNICHARUTIL_LIBS) \
 		$(MOZ_NECKO_UTIL_LIBS) \
 		$(MOZ_COMPONENT_LIBS) \
 		$(NULL)
 
 LOCAL_INCLUDES	= -I$(srcdir)/../util
 
-ifneq (,$(filter cocoa mac, $(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 EXTRA_DSO_LDOPTS += $(TK_LIBS)
 endif
 
 LOCAL_INCLUDES	= -I$(srcdir)/../util \
 		  -I$(srcdir)/../ucvlatin \
 		  -I$(srcdir)/../ucvibm \
 		  -I$(srcdir)/../ucvja \
 		  -I$(srcdir)/../ucvtw2 \
--- a/js/src/config/static-checking.js
+++ b/js/src/config/static-checking.js
@@ -52,16 +52,41 @@ function hasAttribute(c, attrname)
 
   for each (attr in c.attributes)
     if (attr.name == 'user' && attr.value[0] == attrname)
       return true;
 
   return false;
 }
 
+// This is useful for detecting method overrides
+function signaturesMatch(m1, m2)
+{
+  if (m1.shortName != m2.shortName)
+    return false;
+
+  if (m1.isVirtual != m2.isVirtual)
+    return false;
+  
+  if (m1.isStatic != m2.isStatic)
+    return false;
+  
+  let p1 = m1.type.parameters;
+  let p2 = m2.type.parameters;
+  
+  if (p1.length != p2.length)
+    return false;
+  
+  for (let i = 0; i < p1.length; ++i)
+    if (p1[i] !== p2[i])
+      return false;
+  
+  return true;
+}
+
 const forward_functions = [
   'process_type',
   'process_tree_type',
   'process_decl',
   'process_tree_decl',
   'process_function',
   'process_tree',
   'process_cp_pre_genericize',
--- a/js/src/xpconnect/shell/Makefile.in
+++ b/js/src/xpconnect/shell/Makefile.in
@@ -44,17 +44,17 @@ VPATH		= @srcdir@
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= xpcshell
 PROGRAM		= xpcshell$(BIN_SUFFIX)
 
 
 CPPSRCS		= xpcshell.cpp
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 CMMSRCS += xpcshellMacUtils.mm
 endif
 
 LIBS		= \
 		$(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \
 		$(LIBXUL_LIBS) \
 		$(MOZ_JS_LIBS) \
 		$(NSPR_LIBS) \
--- a/js/src/xpconnect/src/qsgen.py
+++ b/js/src/xpconnect/src/qsgen.py
@@ -692,18 +692,20 @@ def writeQuickStub(f, customMethodCalls,
             templateGenerated = templateName + '_generated'
             if templateGenerated in customMethodCall:
                 f.write(callTemplate)
                 return
             customMethodCall[templateGenerated] = True
 
             if isMethod:
                 code = customMethodCall['code']
+            elif isGetter:
+                code = customMethodCall['getter_code']
             else:
-                code = customMethodCall['getter_code' if isGetter else 'setter_code']
+                code = customMethodCall['setter_code']
             stubName = templateName
     else:
         callTemplate = ""
         code = customMethodCall['code']
 
     # Function prolog.
 
     # Only template functions can have additional arguments.
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -192,16 +192,17 @@
 #include "nsMenuPopupFrame.h"
 #include "nsITreeColumns.h"
 #include "nsIDOMXULMultSelectCntrlEl.h"
 #include "nsIDOMXULSelectCntrlItemEl.h"
 #include "nsIDOMXULMenuListElement.h"
 
 #endif
 #include "nsPlaceholderFrame.h"
+#include "nsHTMLFrame.h"
 
 // Content viewer interfaces
 #include "nsIContentViewer.h"
 #include "imgIEncoder.h"
 #include "gfxPlatform.h"
 
 #include "nsContentCID.h"
 static NS_DEFINE_CID(kCSSStyleSheetCID, NS_CSS_STYLESHEET_CID);
@@ -5242,32 +5243,43 @@ PresShell::RenderDocument(const nsRect& 
   aThebesContext->SetOperator(gfxContext::OPERATOR_OVER);
 
   nsIFrame* rootFrame = FrameManager()->GetRootFrame();
   if (rootFrame) {
     nsDisplayListBuilder builder(rootFrame, PR_FALSE,
         (aFlags & RENDER_CARET) != 0);
     nsDisplayList list;
 
+    nsRect canvasArea(
+      builder.ToReferenceFrame(rootFrame), rootFrame->GetSize());
+
     nsRect rect(aRect);
     nsIFrame* rootScrollFrame = GetRootScrollFrame();
     if ((aFlags & RENDER_IGNORE_VIEWPORT_SCROLLING) && rootScrollFrame) {
-      nsPoint pos = GetRootScrollFrameAsScrollable()->GetScrollPosition();
+      nsIScrollableFrame* rootScrollableFrame =
+        GetRootScrollFrameAsScrollable();
+      nsPoint pos = rootScrollableFrame->GetScrollPosition();
       rect.MoveBy(-pos);
       builder.SetIgnoreScrollFrame(rootScrollFrame);
+
+      CanvasFrame* canvasFrame =
+        do_QueryFrame(rootScrollableFrame->GetScrolledFrame());
+      if (canvasFrame) {
+        canvasArea = canvasFrame->CanvasArea();
+      }
     }
 
     builder.SetBackgroundOnly(PR_FALSE);
     builder.SetSyncDecodeImages(PR_TRUE);
     builder.EnterPresShell(rootFrame, rect);
 
     // Add the canvas background color.
     nsresult rv =
       rootFrame->PresContext()->PresShell()->AddCanvasBackgroundColorItem(
-        builder, list, rootFrame);
+        builder, list, rootFrame, &canvasArea);
 
     if (NS_SUCCEEDED(rv)) {
       rv = rootFrame->BuildDisplayListForStackingContext(&builder, rect, &list);
     }
 
     builder.LeavePresShell(rootFrame, rect);
 
     if (NS_SUCCEEDED(rv)) {
--- a/layout/base/tests/Makefile.in
+++ b/layout/base/tests/Makefile.in
@@ -73,16 +73,17 @@ DEFINES += -D_IMPL_NS_LAYOUT
 		test_bug469170.html \
 		test_bug471126.html \
 		test_bug435293-scale.html \
 		test_bug435293-interaction.html \
 		test_bug435293-skew.html \
 		decoration_line_rendering.js \
 		test_bug495648.xul \
 		bug495648.rdf \
+		test_bug514127.html \
 		$(NULL)
 # test_bug396024.html is currently disabled because it interacts badly with
 # the "You can't print-preview while the page is loading" dialog.
 # (See bug 407080)
 
 # Tests for bugs 441782 and 467672 don't pass reliably on Windows, because of bug 469208
 ifeq (,$(filter windows,$(MOZ_WIDGET_TOOLKIT)))
 _TEST_FILES += \
new file mode 100644
--- /dev/null
+++ b/layout/base/tests/test_bug514127.html
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=514127
+-->
+<head>
+  <title>Test for Bug 514127</title>
+  <script type="application/javascript" src="/MochiKit/packed.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<p><a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=514127">Mozilla Bug 514127</a></p>
+
+<!--
+iframe source is
+<html><body style='background: rgb(0,0,255); width: 100px; height: 50100px;'></body></html>
+-->
+<iframe id="source" width="50" height="50"
+       src="data:text/html,%3Chtml%3E%3Cbody%20style%3D%27background%3A%20rgb%280%2C0%2C255%29%3B%20width%3A%20100px%3B%20height%3A%2050100px%3B%27%3E%3C%2Fbody%3E%3C%2Fhtml%3E"></iframe>
+<canvas id="scratch" width="50" height="50"></canvas>
+
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 514127 **/
+
+netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+var canvas = document.getElementById('scratch');
+var source = document.getElementById('source').contentWindow;
+var context = canvas.getContext("2d");
+
+context.clearRect(0, 0, canvas.width, canvas.height);
+context.drawWindow(source, 25, 50000, canvas.width, canvas.height,
+                   "transparent");
+
+var data = context.getImageData(0, 0, canvas.width, canvas.height).data;
+var failed = false;
+for (var i = 0; i < data.length; i+=4) {
+  if (data[i] != 0 || data[i+1] != 0 || data[i+2] != 255 || data[i+3] != 255) {
+    failed = true;
+    break;
+  }
+}
+ok(!failed, "all pixels blue");
+</script>
+</pre>
+</body>
+</html>
--- a/layout/build/Makefile.in
+++ b/layout/build/Makefile.in
@@ -219,29 +219,20 @@ EXTRA_DSO_LDOPTS += $(MOZ_GTK2_LIBS) \
 		    $(NULL)
 endif
 
 ifdef MOZ_ENABLE_QT
 EXTRA_DSO_LDOPTS += $(MOZ_QT_LIBS) \
 		    $(NULL)
 endif
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 EXTRA_DSO_LDOPTS += $(TK_LIBS)
-
-ifdef MOZ_ENABLE_CANVAS3D
 OS_LIBS += -framework OpenGL
 endif
-endif
-
-ifneq (,$(filter windows,$(MOZ_WIDGET_TOOLKIT)))
-ifdef MOZ_ENABLE_CANVAS3D
-OS_LIBS += opengl32.lib
-endif
-endif
 
 # Add explicit X11 dependency when building against X11 toolkits
 ifneq (,$(filter gtk2,$(MOZ_WIDGET_TOOLKIT)))
 EXTRA_DSO_LDOPTS += $(XLDFLAGS) $(XLIBS)
 endif
 
 ifdef MOZ_SYDNEYAUDIO
 ifeq ($(OS_ARCH),Linux)
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -201,22 +201,18 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextSer
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLEditorLog)
 #else
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLEditor)
 #endif
 #endif
 
 #include "nsHTMLCanvasFrame.h"
 
-#ifdef MOZ_ENABLE_CANVAS
 #include "nsIDOMCanvasRenderingContext2D.h"
-#ifdef MOZ_ENABLE_CANVAS3D
 #include "nsICanvasRenderingContextWebGL.h"
-#endif
-#endif
 
 class nsIDocumentLoaderFactory;
 
 #define PRODUCT_NAME "Gecko"
 
 #define NS_HTMLIMGELEMENT_CONTRACTID \
   "@mozilla.org/content/element/html;1?name=img"
 
@@ -398,22 +394,18 @@ nsresult NS_NewBoxObject(nsIBoxObject** 
 nsresult NS_NewListBoxObject(nsIBoxObject** aResult);
 nsresult NS_NewScrollBoxObject(nsIBoxObject** aResult);
 nsresult NS_NewMenuBoxObject(nsIBoxObject** aResult);
 nsresult NS_NewPopupBoxObject(nsIBoxObject** aResult);
 nsresult NS_NewContainerBoxObject(nsIBoxObject** aResult);
 nsresult NS_NewTreeBoxObject(nsIBoxObject** aResult);
 #endif
 
-#ifdef MOZ_ENABLE_CANVAS
 nsresult NS_NewCanvasRenderingContext2D(nsIDOMCanvasRenderingContext2D** aResult);
-#ifdef MOZ_ENABLE_CANVAS3D
 nsresult NS_NewCanvasRenderingContextWebGL(nsICanvasRenderingContextWebGL** aResult);
-#endif
-#endif
 
 nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult);
 
 nsresult NS_NewSelection(nsFrameSelection** aResult);
 nsresult NS_NewDomSelection(nsISelection** aResult);
 nsresult NS_NewDocumentViewer(nsIDocumentViewer** aResult);
 nsresult NS_NewRange(nsIDOMRange** aResult);
 nsresult NS_NewRangeUtils(nsIRangeUtils** aResult);
@@ -535,22 +527,18 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsDataDoc
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsNoDataProtocolContentPolicy)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSyncLoadService)
 MAKE_CTOR(CreatePluginDocument,           nsIDocument,                 NS_NewPluginDocument)
 #ifdef MOZ_MEDIA
 MAKE_CTOR(CreateVideoDocument,            nsIDocument,                 NS_NewVideoDocument)
 #endif
 MAKE_CTOR(CreateFocusManager,             nsIFocusManager,      NS_NewFocusManager)
 
-#ifdef MOZ_ENABLE_CANVAS
 MAKE_CTOR(CreateCanvasRenderingContext2D, nsIDOMCanvasRenderingContext2D, NS_NewCanvasRenderingContext2D)
-#ifdef MOZ_ENABLE_CANVAS3D
 MAKE_CTOR(CreateCanvasRenderingContextWebGL, nsICanvasRenderingContextWebGL, NS_NewCanvasRenderingContextWebGL)
-#endif
-#endif
 
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsStyleSheetService, Init)
 
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsJSURI)
 
 // views are not refcounted, so this is the same as
 // NS_GENERIC_FACTORY_CONSTRUCTOR without the NS_ADDREF/NS_RELEASE
 #define NS_GENERIC_FACTORY_CONSTRUCTOR_NOREFS(_InstanceClass)                 \
@@ -1070,28 +1058,24 @@ static const nsModuleComponentInfo gComp
   { "HTML audio element",
     NS_HTMLAUDIOELEMENT_CID,
     NS_HTMLAUDIOELEMENT_CONTRACTID,
     CreateHTMLAudioElement,
     RegisterHTMLAudioElement,
     UnregisterHTMLAudioElement },
 #endif
 
-#ifdef MOZ_ENABLE_CANVAS
   { "Canvas 2D Rendering Context",
     NS_CANVASRENDERINGCONTEXT2D_CID,
     "@mozilla.org/content/canvas-rendering-context;1?id=2d",
     CreateCanvasRenderingContext2D },
-#ifdef MOZ_ENABLE_CANVAS3D
   { "Canvas WebGL Rendering Context",
     NS_CANVASRENDERINGCONTEXTWEBGL_CID,
     "@mozilla.org/content/canvas-rendering-context;1?id=moz-webgl",
     CreateCanvasRenderingContextWebGL },
-#endif
-#endif
 
   { "XML document encoder",
     NS_TEXT_ENCODER_CID,
     NS_DOC_ENCODER_CONTRACTID_BASE "text/xml",
     CreateTextEncoder },
 
   { "XML document encoder",
     NS_TEXT_ENCODER_CID,
--- a/layout/generic/nsHTMLFrame.cpp
+++ b/layout/generic/nsHTMLFrame.cpp
@@ -32,16 +32,17 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /* rendering object that goes directly inside the document's scrollbars */
 
+#include "nsHTMLFrame.h"
 #include "nsIServiceManager.h"
 #include "nsHTMLParts.h"
 #include "nsHTMLContainerFrame.h"
 #include "nsCSSRendering.h"
 #include "nsPresContext.h"
 #include "nsStyleContext.h"
 #include "nsIView.h"
 #include "nsIViewManager.h"
@@ -65,143 +66,29 @@
 #include "nsICanvasFrame.h"
 
 #ifdef DEBUG_rods
 //#define DEBUG_CANVAS_FOCUS
 #endif
 
 #define CANVAS_ABS_POS_CHILD_LIST NS_CONTAINER_LIST_COUNT_INCL_OC
 
-// Interface IDs
-
-/**
- * Root frame class.
- *
- * The root frame is the parent frame for the document element's frame.
- * It only supports having a single child frame which must be an area
- * frame
- */
-class CanvasFrame : public nsHTMLContainerFrame, 
-                    public nsIScrollPositionListener, 
-                    public nsICanvasFrame {
-public:
-  CanvasFrame(nsStyleContext* aContext)
-  : nsHTMLContainerFrame(aContext), mDoPaintFocus(PR_FALSE),
-    mAbsoluteContainer(nsGkAtoms::absoluteList) {}
-
-  NS_DECL_QUERYFRAME
-  NS_DECL_FRAMEARENA_HELPERS
-
-  // nsISupports (nsIScrollPositionListener)
-  NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
-
-  NS_IMETHOD Init(nsIContent*      aContent,
-                  nsIFrame*        aParent,
-                  nsIFrame*        aPrevInFlow);
-  virtual void Destroy();
-
-  NS_IMETHOD SetInitialChildList(nsIAtom*        aListName,
-                                 nsFrameList&    aChildList);
-  NS_IMETHOD AppendFrames(nsIAtom*        aListName,
-                          nsFrameList&    aFrameList);
-  NS_IMETHOD InsertFrames(nsIAtom*        aListName,
-                          nsIFrame*       aPrevFrame,
-                          nsFrameList&    aFrameList);
-  NS_IMETHOD RemoveFrame(nsIAtom*        aListName,
-                         nsIFrame*       aOldFrame);
-
-  virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
-  virtual nsFrameList GetChildList(nsIAtom* aListName) const;
-
-  virtual nscoord GetMinWidth(nsIRenderingContext *aRenderingContext);
-  virtual nscoord GetPrefWidth(nsIRenderingContext *aRenderingContext);
-  NS_IMETHOD Reflow(nsPresContext*          aPresContext,
-                    nsHTMLReflowMetrics&     aDesiredSize,
-                    const nsHTMLReflowState& aReflowState,
-                    nsReflowStatus&          aStatus);
-  virtual PRBool IsContainingBlock() const { return PR_TRUE; }
-  virtual PRBool IsFrameOfType(PRUint32 aFlags) const
-  {
-    return nsHTMLContainerFrame::IsFrameOfType(aFlags &
-             ~(nsIFrame::eCanContainOverflowContainers));
-  }
-
-  NS_IMETHOD BuildDisplayList(nsDisplayListBuilder*   aBuilder,
-                              const nsRect&           aDirtyRect,
-                              const nsDisplayListSet& aLists);
-
-  void PaintFocus(nsIRenderingContext& aRenderingContext, nsPoint aPt);
-
-  // nsIScrollPositionListener
-  NS_IMETHOD ScrollPositionWillChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY);
-  virtual void ViewPositionDidChange(nsIScrollableView* aScrollable,
-                                     nsTArray<nsIWidget::Configuration>* aConfigurations) {}
-  NS_IMETHOD ScrollPositionDidChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY);
-
-  // nsICanvasFrame
-  NS_IMETHOD SetHasFocus(PRBool aHasFocus);
-
-  /**
-   * Get the "type" of the frame
-   *
-   * @see nsGkAtoms::canvasFrame
-   */
-  virtual nsIAtom* GetType() const;
-
-  virtual nsresult StealFrame(nsPresContext* aPresContext,
-                              nsIFrame*      aChild,
-                              PRBool         aForceNormal)
-  {
-    NS_ASSERTION(!aForceNormal, "No-one should be passing this in here");
-
-    // CanvasFrame keeps overflow container continuations of its child
-    // frame in main child list
-    nsresult rv = nsContainerFrame::StealFrame(aPresContext, aChild, PR_TRUE);
-    if (NS_FAILED(rv)) {
-      rv = nsContainerFrame::StealFrame(aPresContext, aChild);
-    }
-    return rv;
-  }
-
-#ifdef DEBUG
-  NS_IMETHOD GetFrameName(nsAString& aResult) const;
-#endif
-  NS_IMETHOD GetContentForEvent(nsPresContext* aPresContext,
-                                nsEvent* aEvent,
-                                nsIContent** aContent);
-
-  nsRect CanvasArea() const;
-
-protected:
-  virtual PRIntn GetSkipSides() const;
-
-  // Data members
-  PRPackedBool              mDoPaintFocus;
-  nsCOMPtr<nsIViewManager>  mViewManager;
-  nsAbsoluteContainingBlock mAbsoluteContainer;
-
-private:
-  NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
-  NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }
-};
-
-
-//----------------------------------------------------------------------
 
 nsIFrame*
 NS_NewCanvasFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
 {
   return new (aPresShell) CanvasFrame(aContext);
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(CanvasFrame)
 
 NS_IMPL_QUERY_INTERFACE1(CanvasFrame, nsIScrollPositionListener)
 
 NS_QUERYFRAME_HEAD(CanvasFrame)
+  NS_QUERYFRAME_ENTRY(CanvasFrame)
   NS_QUERYFRAME_ENTRY(nsICanvasFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsHTMLContainerFrame)
 
 NS_IMETHODIMP
 CanvasFrame::Init(nsIContent*      aContent,
                   nsIFrame*        aParent,
                   nsIFrame*        aPrevInFlow)
 {
new file mode 100644
--- /dev/null
+++ b/layout/generic/nsHTMLFrame.h
@@ -0,0 +1,172 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/* rendering object that goes directly inside the document's scrollbars */
+
+#ifndef nsHTMLFrame_h___
+#define nsHTMLFrame_h___
+
+
+#include "nsHTMLContainerFrame.h"
+#include "nsPresContext.h"
+#include "nsStyleContext.h"
+#include "nsIView.h"
+#include "nsIViewManager.h"
+#include "nsIRenderingContext.h"
+#include "nsGUIEvent.h"
+#include "nsGkAtoms.h"
+#include "nsIScrollPositionListener.h"
+#include "nsDisplayList.h"
+#include "nsAbsoluteContainingBlock.h"
+
+// for focus
+#include "nsIScrollableView.h"
+#include "nsICanvasFrame.h"
+
+/**
+ * Root frame class.
+ *
+ * The root frame is the parent frame for the document element's frame.
+ * It only supports having a single child frame which must be an area
+ * frame
+ */
+class CanvasFrame : public nsHTMLContainerFrame, 
+                    public nsIScrollPositionListener, 
+                    public nsICanvasFrame {
+public:
+  CanvasFrame(nsStyleContext* aContext)
+  : nsHTMLContainerFrame(aContext), mDoPaintFocus(PR_FALSE),
+    mAbsoluteContainer(nsGkAtoms::absoluteList) {}
+
+  NS_DECL_QUERYFRAME_TARGET(CanvasFrame)
+  NS_DECL_QUERYFRAME
+  NS_DECL_FRAMEARENA_HELPERS
+
+  // nsISupports (nsIScrollPositionListener)
+  NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
+
+  NS_IMETHOD Init(nsIContent*      aContent,
+                  nsIFrame*        aParent,
+                  nsIFrame*        aPrevInFlow);
+  virtual void Destroy();
+
+  NS_IMETHOD SetInitialChildList(nsIAtom*        aListName,
+                                 nsFrameList&    aChildList);
+  NS_IMETHOD AppendFrames(nsIAtom*        aListName,
+                          nsFrameList&    aFrameList);
+  NS_IMETHOD InsertFrames(nsIAtom*        aListName,
+                          nsIFrame*       aPrevFrame,
+                          nsFrameList&    aFrameList);
+  NS_IMETHOD RemoveFrame(nsIAtom*        aListName,
+                         nsIFrame*       aOldFrame);
+
+  virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
+  virtual nsFrameList GetChildList(nsIAtom* aListName) const;
+
+  virtual nscoord GetMinWidth(nsIRenderingContext *aRenderingContext);
+  virtual nscoord GetPrefWidth(nsIRenderingContext *aRenderingContext);
+  NS_IMETHOD Reflow(nsPresContext*          aPresContext,
+                    nsHTMLReflowMetrics&     aDesiredSize,
+                    const nsHTMLReflowState& aReflowState,
+                    nsReflowStatus&          aStatus);
+  virtual PRBool IsContainingBlock() const { return PR_TRUE; }
+  virtual PRBool IsFrameOfType(PRUint32 aFlags) const
+  {
+    return nsHTMLContainerFrame::IsFrameOfType(aFlags &
+             ~(nsIFrame::eCanContainOverflowContainers));
+  }
+
+  NS_IMETHOD BuildDisplayList(nsDisplayListBuilder*   aBuilder,
+                              const nsRect&           aDirtyRect,
+                              const nsDisplayListSet& aLists);
+
+  void PaintFocus(nsIRenderingContext& aRenderingContext, nsPoint aPt);
+
+  // nsIScrollPositionListener
+  NS_IMETHOD ScrollPositionWillChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY);
+  virtual void ViewPositionDidChange(nsIScrollableView* aScrollable,
+                                     nsTArray<nsIWidget::Configuration>* aConfigurations) {}
+  NS_IMETHOD ScrollPositionDidChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY);
+
+  // nsICanvasFrame
+  NS_IMETHOD SetHasFocus(PRBool aHasFocus);
+
+  /**
+   * Get the "type" of the frame
+   *
+   * @see nsGkAtoms::canvasFrame
+   */
+  virtual nsIAtom* GetType() const;
+
+  virtual nsresult StealFrame(nsPresContext* aPresContext,
+                              nsIFrame*      aChild,
+                              PRBool         aForceNormal)
+  {
+    NS_ASSERTION(!aForceNormal, "No-one should be passing this in here");
+
+    // CanvasFrame keeps overflow container continuations of its child
+    // frame in main child list
+    nsresult rv = nsContainerFrame::StealFrame(aPresContext, aChild, PR_TRUE);
+    if (NS_FAILED(rv)) {
+      rv = nsContainerFrame::StealFrame(aPresContext, aChild);
+    }
+    return rv;
+  }
+
+#ifdef DEBUG
+  NS_IMETHOD GetFrameName(nsAString& aResult) const;
+#endif
+  NS_IMETHOD GetContentForEvent(nsPresContext* aPresContext,
+                                nsEvent* aEvent,
+                                nsIContent** aContent);
+
+  nsRect CanvasArea() const;
+
+protected:
+  virtual PRIntn GetSkipSides() const;
+
+  // Data members
+  PRPackedBool              mDoPaintFocus;
+  nsCOMPtr<nsIViewManager>  mViewManager;
+  nsAbsoluteContainingBlock mAbsoluteContainer;
+
+private:
+  NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
+  NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }
+};
+
+#endif /* nsHTMLFrame_h___ */
--- a/modules/libpr0n/decoders/Makefile.in
+++ b/modules/libpr0n/decoders/Makefile.in
@@ -53,17 +53,17 @@ ifeq (,$(filter-out WINNT WINCE, $(OS_AR
 DIRS = icon/win icon
 endif
 ifeq ($(OS_ARCH),OS2)
 DIRS = icon/os2 icon
 endif
 ifeq ($(OS_ARCH),BeOS)
 DIRS = icon/beos icon
 endif
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 DIRS = icon/mac icon
 endif
 endif # icon
 
 DIRS += $(filter-out icon,$(MOZ_IMG_DECODERS))
 
 include $(topsrcdir)/config/rules.mk
 
--- a/modules/libpr0n/src/imgContainer.cpp
+++ b/modules/libpr0n/src/imgContainer.cpp
@@ -2210,17 +2210,26 @@ imgContainer::RequestDecode()
   // If we're not storing source data, we have nothing to do
   if (!StoringSourceData())
     return NS_OK;
 
   // If we're fully decoded, we have nothing to do
   if (mDecoded)
     return NS_OK;
 
-  // If we're within the decoder, request asynchronously
+  // If we've already got a full decoder running, we have nothing to do
+  if (mDecoder && !(mDecoderFlags & imgIDecoder::DECODER_FLAG_HEADERONLY))
+    return NS_OK;
+
+  // If our callstack goes through a header-only decoder, we have a problem.
+  // We need to shutdown the header-only decoder and replace it with  a full
+  // decoder, but can't do that from within the decoder itself. Thus, we post
+  // an asynchronous event to the event loop to do it later. Since
+  // RequestDecode() is an asynchronous function this works fine (though it's
+  // a little slower).
   if (mInDecoder) {
     nsRefPtr<imgDecodeRequestor> requestor = new imgDecodeRequestor(this);
     if (!requestor)
       return NS_ERROR_OUT_OF_MEMORY;
     return NS_DispatchToCurrentThread(requestor);
   }
 
 
--- a/modules/plugin/base/src/Makefile.in
+++ b/modules/plugin/base/src/Makefile.in
@@ -67,17 +67,17 @@ ifneq (,$(filter WINNT WINCE,$(OS_ARCH))
 	CPPSRCS += nsPluginsDirWin.cpp
 	CPPSRCS += nsPluginNativeWindowWin.cpp
 	CPPSRCS += nsPluginDirServiceProvider.cpp
 else
 ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
 	CPPSRCS += nsPluginsDirOS2.cpp
 	CPPSRCS += nsPluginNativeWindowOS2.cpp
 else
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 	CPPSRCS += nsPluginsDirDarwin.cpp
 	CPPSRCS += nsPluginNativeWindow.cpp
 else
 ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
 	CPPSRCS += nsPluginsDirUnix.cpp
 	CPPSRCS += nsPluginNativeWindowGtk2.cpp
 else
 	CPPSRCS += nsPluginsDirUnix.cpp
@@ -96,17 +96,17 @@ EXTRA_DSO_LDOPTS = \
 		$(LIBS_DIR) \
 		$(EXTRA_DSO_LIBS) \
 		$(MOZ_NECKO_UTIL_LIBS) \
 		$(MOZ_UNICHARUTIL_LIBS) \
 		$(MOZ_COMPONENT_LIBS) \
 		$(MOZ_JS_LIBS) \
 		$(NULL)
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 EXTRA_DSO_LDOPTS += $(TK_LIBS)
 endif
 
 ifndef WINCE
 ENABLE_CXX_EXCEPTIONS = 1
 endif
 
 include $(topsrcdir)/config/config.mk
--- a/netwerk/base/src/Makefile.in
+++ b/netwerk/base/src/Makefile.in
@@ -96,17 +96,17 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
 	CPPSRCS += nsURLHelperWin.cpp
 	CPPSRCS += nsNativeConnectionHelper.cpp
 ifneq ($(OS_ARCH), WINCE)
 	CPPSRCS += nsAutodialWin.cpp
 else
 	CPPSRCS += nsAutodialWinCE.cpp
 endif
 else
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 	CPPSRCS += nsURLHelperOSX.cpp
 else
 	CPPSRCS += nsURLHelperUnix.cpp
 endif
 endif
 endif
 
 EXTRA_COMPONENTS = \
--- a/netwerk/build/Makefile.in
+++ b/netwerk/build/Makefile.in
@@ -130,17 +130,17 @@ endif
 EXTRA_DSO_LDOPTS = \
 		$(LIBS_DIR) \
 		$(EXTRA_DSO_LIBS) \
 		$(MOZ_UNICHARUTIL_LIBS) \
 		$(MOZ_COMPONENT_LIBS) \
 		$(ZLIB_LIBS) \
 		$(NULL)
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)))
 EXTRA_DSO_LDOPTS += \
 		-framework SystemConfiguration \
 		$(TK_LIBS) \
 	$(NULL)
 endif
 
 ifeq ($(OS_ARCH),AIX)
 EXTRA_DSO_LDOPTS += -lodm -lcfg
--- a/netwerk/streamconv/converters/Makefile.in
+++ b/netwerk/streamconv/converters/Makefile.in
@@ -70,17 +70,17 @@ endif
 # only include Gopher directory listing support if the Gopher
 # protocol is being built.
 ifneq (,$(filter gopher,$(NECKO_PROTOCOLS)))
 CPPSRCS += \
 		nsGopherDirListingConv.cpp \
         $(NULL)
 endif
 
-ifeq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 CPPSRCS += \
 		nsBinHexDecoder.cpp \
 		$(NULL)
 endif
 
 # we don't want the shared lib, but we want to force the creation of a
 # static lib.
 FORCE_STATIC_LIB = 1
--- a/toolkit/components/build/Makefile.in
+++ b/toolkit/components/build/Makefile.in
@@ -117,17 +117,17 @@ EXTRA_DSO_LIBS = gkgfx
 EXTRA_DSO_LDOPTS += \
 	$(LIBS_DIR) \
 	$(EXTRA_DSO_LIBS) \
 	$(MOZ_UNICHARUTIL_LIBS) \
 	$(MOZ_COMPONENT_LIBS) \
 	$(MOZ_JS_LIBS) \
 	$(NULL)
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 EXTRA_DSO_LDOPTS += $(TK_LIBS)
 endif
 
 ifeq ($(OS_ARCH),WINNT)
 OS_LIBS	+= $(call EXPAND_LIBNAME,shell32 ole32)
 endif
 
 include $(topsrcdir)/config/rules.mk
--- a/toolkit/components/commandlines/src/Makefile.in
+++ b/toolkit/components/commandlines/src/Makefile.in
@@ -58,13 +58,13 @@ CPPSRCS = \
 	nsCommandLine.cpp \
 	$(NULL)
 
 EXTRA_DSO_LDOPTS += \
 	$(MOZ_UNICHARUTIL_LIBS) \
 	$(MOZ_COMPONENT_LIBS) \
 	$(NULL)
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 EXTRA_DSO_LDOPTS += $(TK_LIBS)
 endif
 
 include $(topsrcdir)/config/rules.mk
--- a/toolkit/components/filepicker/Makefile.in
+++ b/toolkit/components/filepicker/Makefile.in
@@ -39,15 +39,15 @@
 DEPTH     = ../../..
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 ifdef MOZ_XUL
-ifeq (,$(filter qt beos os2 mac photon cocoa windows,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (,$(filter qt beos os2 photon cocoa windows,$(MOZ_WIDGET_TOOLKIT)))
 DIRS = public src
 endif
 endif
 
 include $(topsrcdir)/config/rules.mk
 
--- a/toolkit/components/places/tests/browser/browser_bug399606.js
+++ b/toolkit/components/places/tests/browser/browser_bug399606.js
@@ -85,27 +85,27 @@ function test() {
   }
 
   var loadCount = 0;
   function handleLoad(aEvent) {
     loadCount++;
     info("new load count is " + loadCount);
 
     if (loadCount == 3) {
-      window.getBrowser().removeEventListener("DOMContentLoaded", handleLoad, true);
-      window.content.document.location.href = "about:blank";
+      gBrowser.removeEventListener("DOMContentLoaded", handleLoad, true);
+      content.location.href = "about:blank";
       executeSoon(check_next_uri);
     }
   }
 
   function check_next_uri() {
     if (URIs.length) {
       let uri = URIs.shift();
       loadCount = 0;
-      window.getBrowser().addEventListener("DOMContentLoaded", handleLoad, true);
-      window.content.document.location.href = uri;
+      gBrowser.addEventListener("DOMContentLoaded", handleLoad, true);
+      content.location.href = uri;
     }
     else {
       setTimeout(confirm_results, LAZY_ADD_TIMER * 2);
     }
   }
   executeSoon(check_next_uri);
 }
--- a/toolkit/components/startup/src/Makefile.in
+++ b/toolkit/components/startup/src/Makefile.in
@@ -52,17 +52,17 @@ CPPSRCS = \
 	$(NULL)
 
 ifeq (os2,$(MOZ_WIDGET_TOOLKIT))
 CPPSRCS += nsUserInfoOS2.cpp
 else
 ifeq (,$(filter-out WINCE WINNT,$(OS_ARCH)))
 CPPSRCS += nsUserInfoWin.cpp
 else
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 CMMSRCS += nsUserInfoMac.mm
 else
 CPPSRCS += nsUserInfoUnix.cpp
 endif
 endif
 endif
 
 EXTRA_COMPONENTS = nsTryToClose.js
--- a/toolkit/content/tests/chrome/Makefile.in
+++ b/toolkit/content/tests/chrome/Makefile.in
@@ -90,17 +90,17 @@ include $(topsrcdir)/config/rules.mk
 		window_keys.xul \
 		test_showcaret.xul \
 		window_showcaret.xul \
 		test_righttoleft.xul \
 		$(NULL)
 
 # test_panel_focus.xul won't work if the Full Keyboard Access preference is set to
 # textboxes and lists only, so skip this test on Mac
-ifeq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 _TEST_FILES += test_panel_focus.xul \
                window_panel_focus.xul
 else
 _TEST_FILES += test_autocomplete.xul
 endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
 _TEST_FILES += 	$(warning test_cursorsnap.xul temporarily disabled) \
--- a/toolkit/content/tests/widgets/Makefile.in
+++ b/toolkit/content/tests/widgets/Makefile.in
@@ -130,15 +130,15 @@ include $(topsrcdir)/config/rules.mk
 		videocontrols_direction_test.js \
 		use_large_cache.js \
 		audio.oga \
 		black.ogv \
 		video.ogg \
 		videomask.css \
 		$(NULL)
 
-ifeq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 _TEST_FILES += test_menubar.xul \
                window_menubar.xul
 endif
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
--- a/toolkit/library/libxul-config.mk
+++ b/toolkit/library/libxul-config.mk
@@ -143,22 +143,16 @@ COMPONENT_LIBS += \
 	txmgr \
 	chrome \
 	commandlines \
 	toolkitcomps \
 	pipboot \
 	pipnss \
 	$(NULL)
 
-ifdef MOZ_XMLEXTRAS
-COMPONENT_LIBS += \
-	xmlextras \
-	$(NULL)
-endif
-  
 ifdef MOZ_PLUGINS
 DEFINES += -DMOZ_PLUGINS
 COMPONENT_LIBS += \
 	gkplugin \
 	$(NULL)
 endif
 
 ifdef MOZ_XPFE_COMPONENTS
@@ -213,23 +207,16 @@ endif
 
 ifdef MOZ_PREF_EXTENSIONS
 DEFINES += -DMOZ_PREF_EXTENSIONS
 COMPONENT_LIBS += \
 	autoconfig \
 	$(NULL)
 endif
 
-ifdef MOZ_WEBSERVICES
-DEFINES += -DMOZ_WEBSERVICES
-COMPONENT_LIBS += \
-	websrvcs \
-	$(NULL)
-endif
-
 ifdef MOZ_AUTH_EXTENSION
 COMPONENT_LIBS += auth
 DEFINES += -DMOZ_AUTH_EXTENSION
 endif
 
 ifdef MOZ_PERMISSIONS
 COMPONENT_LIBS += cookie permissions
 DEFINES += -DMOZ_PERMISSIONS
@@ -253,17 +240,17 @@ COMPONENT_LIBS += \
 ifdef MOZ_XPFE_COMPONENTS
 COMPONENT_LIBS += \
 	windowds \
 	intlapp \
 	$(NULL)
 endif
 endif
 
-ifeq (,$(filter qt beos os2 mac photon cocoa windows,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (,$(filter qt beos os2 photon cocoa windows,$(MOZ_WIDGET_TOOLKIT)))
 ifdef MOZ_XUL
 ifdef MOZ_XPFE_COMPONENTS
 COMPONENT_LIBS += fileview
 DEFINES += -DMOZ_FILEVIEW
 endif
 endif
 endif
 
@@ -332,17 +319,17 @@ ifeq (windows,$(MOZ_WIDGET_TOOLKIT))
 COMPONENT_LIBS += gkwidget
 endif
 ifeq (beos,$(MOZ_WIDGET_TOOLKIT))
 COMPONENT_LIBS += widget_beos
 endif
 ifeq (os2,$(MOZ_WIDGET_TOOLKIT))
 COMPONENT_LIBS += wdgtos2
 endif
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 COMPONENT_LIBS += widget_mac
 endif
 ifeq (qt,$(MOZ_WIDGET_TOOLKIT))
 COMPONENT_LIBS += widget_qt
 endif
 
 ifdef MOZ_ENABLE_PHOTON
 COMPONENT_LIBS += widget_photon
@@ -365,14 +352,11 @@ ifdef MOZ_ZIPWRITER
 DEFINES += -DMOZ_ZIPWRITER
 COMPONENT_LIBS += zipwriter
 endif
 
 ifneq (,$(filter layout-debug,$(MOZ_EXTENSIONS)))
 COMPONENT_LIBS += gkdebug
 endif
 
-ifdef MOZ_ENABLE_CANVAS3D
 ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 EXTRA_DSO_LDOPTS += -framework OpenGL
 endif
-endif
-
--- a/toolkit/library/libxul-rules.mk
+++ b/toolkit/library/libxul-rules.mk
@@ -72,22 +72,19 @@ DEFINES += \
 	-DEXPORT_XPTC_API \
 	-D_IMPL_NS_GFX \
 	-D_IMPL_NS_WIDGET \
 	$(NULL)
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
 ifneq ($(OS_ARCH),WINCE)
 OS_LIBS += $(call EXPAND_LIBNAME,usp10 oleaut32)
-ifdef MOZ_ENABLE_CANVAS3D
-OS_LIBS += $(call EXPAND_LIBNAME,opengl32)
 endif
 endif
-endif
-ifneq (,$(filter $(MOZ_WIDGET_TOOLKIT),mac cocoa))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 EXTRA_DSO_LDOPTS += -lcups
 endif
 
 ifdef MOZ_SYDNEYAUDIO
 ifeq ($(OS_ARCH),Linux)
 EXTRA_DSO_LDOPTS += $(MOZ_ALSA_LIBS)
 endif
 endif
--- a/toolkit/library/nsStaticXULComponents.cpp
+++ b/toolkit/library/nsStaticXULComponents.cpp
@@ -143,23 +143,16 @@
 
 #ifdef MOZ_PLUGINS
 #define PLUGINS_MODULES \
     MODULE(nsPluginModule)
 #else
 #define PLUGINS_MODULES
 #endif
 
-#ifdef MOZ_WEBSERVICES
-#define WEBSERVICES_MODULES \
-    MODULE(nsWebServicesModule)
-#else
-#define WEBSERVICES_MODULES
-#endif
-
 #ifdef MOZ_XPFE_COMPONENTS
 #ifdef MOZ_RDF
 #define RDFAPP_MODULES \
     MODULE(nsXPIntlModule) \
     MODULE(nsWindowDataSourceModule)
 #else
 #define RDFAPP_MODULES
 #endif
@@ -225,22 +218,16 @@
 #endif
 
 #ifdef MOZ_SPELLCHECK
 #define SPELLCHECK_MODULE MODULE(mozSpellCheckerModule)
 #else
 #define SPELLCHECK_MODULE
 #endif
 
-#ifdef MOZ_XMLEXTRAS
-#define XMLEXTRAS_MODULE MODULE(nsXMLExtrasModule)
-#else
-#define XMLEXTRAS_MODULE
-#endif
-
 #ifdef MOZ_XUL
 #ifdef MOZ_ENABLE_GTK2
 #define UNIXPROXY_MODULE MODULE(nsUnixProxyModule)
 #endif
 #if defined(MOZ_WIDGET_QT)
 #define UNIXPROXY_MODULE MODULE(nsUnixProxyModule)
 #endif
 #endif
@@ -278,17 +265,16 @@
     RDFAPP_MODULES                           \
     MODULE(nsParserModule)                   \
     GFX_MODULES                              \
     WIDGET_MODULES                           \
     MODULE(nsImageLib2Module)                \
     ICON_MODULE                              \
     PLUGINS_MODULES                          \
     MODULE(nsLayoutModule)                   \
-    WEBSERVICES_MODULES                      \
     MODULE(docshell_provider)                \
     MODULE(embedcomponents)                  \
     MODULE(Browser_Embedding_Module)         \
     ACCESS_MODULES                           \
     MODULE(appshell)                         \
     MODULE(nsTransactionManagerModule)       \
     COMPOSER_MODULE                          \
     MODULE(nsChromeModule)                   \
@@ -302,17 +288,16 @@
     MODULE(nsToolkitCompsModule)             \
     XREMOTE_MODULES                          \
     XPINSTALL_MODULES                        \
     JSDEBUGGER_MODULES                       \
     MODULE(BOOT)                             \
     MODULE(NSS)                              \
     SYSTEMPREF_MODULES                       \
     SPELLCHECK_MODULE                        \
-    XMLEXTRAS_MODULE                         \
     LAYOUT_DEBUG_MODULE                      \
     UNIXPROXY_MODULE                         \
     OSXPROXY_MODULE                          \
     WINDOWSPROXY_MODULE                      \
     /* end of list */
 
 #define MODULE(_name) \
 NSGETMODULE_ENTRY_POINT(_name) (nsIComponentManager*, nsIFile*, nsIModule**);
--- a/toolkit/locales/Makefile.in
+++ b/toolkit/locales/Makefile.in
@@ -71,14 +71,14 @@ endif
 
 ifdef MOZ_UPDATER
 libs:: update.locale
 	cat $< | sed -e "s/%AB_CD%/$(AB_CD)/" > $(FINAL_TARGET)/update.locale
 endif
 
 ifdef MOZ_CRASHREPORTER
 libs:: crashreporter.ini
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 	$(SYSINSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)/crashreporter.app/Contents/MacOS
 else
 	$(SYSINSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)
 endif
 endif
--- a/toolkit/locales/l10n.mk
+++ b/toolkit/locales/l10n.mk
@@ -93,27 +93,27 @@ DEFINES += \
 clobber-%:
 	$(RM) -rf $(DIST)/xpi-stage/locale-$*
 
 
 PACKAGER_NO_LIBS = 1
 include $(topsrcdir)/toolkit/mozapps/installer/packager.mk
 
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 STAGEDIST = $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_APPNAME)/$(_APPNAME)/Contents/MacOS
 else
 STAGEDIST = $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_DIR)
 endif
 
 $(STAGEDIST): AB_CD:=en-US
 $(STAGEDIST): UNPACKAGE=$(ZIP_IN)
 $(STAGEDIST): $(ZIP_IN)
 # only mac needs to remove the parent of STAGEDIST...
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 	$(RM) -r -v $(DIST)/l10n-stage
 else
 # ... and windows doesn't like removing STAGEDIST itself, remove all children
 	find $(STAGEDIST) -maxdepth 1 -print0 | xargs -0 $(RM) -r
 endif
 	$(NSINSTALL) -D $(DIST)/l10n-stage
 	cd $(DIST)/l10n-stage && \
 	  $(UNMAKE_PACKAGE)
@@ -128,32 +128,32 @@ repackage-zip: UNPACKAGE="$(ZIP_IN)"
 repackage-zip:
 # call a hook for apps to put their uninstall helper.exe into the package
 	$(UNINSTALLER_PACKAGE_HOOK)
 # copy xpi-stage over, but not install.rdf and chrome.manifest,
 # those are just for language packs
 	cd $(DIST)/xpi-stage/locale-$(AB_CD) && \
 	  tar --exclude=install.rdf --exclude=chrome.manifest $(TAR_CREATE_FLAGS) - * | ( cd $(STAGEDIST) && tar -xf - )
 ifneq (en,$(AB))
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 	mv $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_APPNAME)/$(_APPNAME)/Contents/Resources/en.lproj $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_APPNAME)/$(_APPNAME)/Contents/Resources/$(AB).lproj
 endif
 endif
 	$(NSINSTALL) -D $(DIST)/l10n-stage/$(PKG_PATH)
 	cd $(DIST)/l10n-stage; \
 	  $(MAKE_PACKAGE)
 ifdef MOZ_MAKE_COMPLETE_MAR
 	$(MAKE) -C $(DEPTH)/tools/update-packaging full-update AB_CD=$(AB_CD) \
 	  MOZ_PKG_PRETTYNAMES=$(MOZ_PKG_PRETTYNAMES) \
 	  PACKAGE_BASE_DIR="$(_ABS_DIST)/l10n-stage" \
 	  DIST="$(_ABS_DIST)"
 endif
 # packaging done, undo l10n stuff
 ifneq (en,$(AB))
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 	mv $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_APPNAME)/$(_APPNAME)/Contents/Resources/$(AB).lproj $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_APPNAME)/$(_APPNAME)/Contents/Resources/en.lproj
 endif
 endif
 	$(MAKE) clobber-zip AB_CD=$(AB_CD)
 	$(NSINSTALL) -D $(DIST)/$(PKG_PATH)
 	mv -f "$(DIST)/l10n-stage/$(PACKAGE)" "$(DIST)/$(PACKAGE)"
 
 repackage-zip-%: $(ZIP_IN) $(STAGEDIST) libs-%
--- a/toolkit/mozapps/extensions/test/unit/test_bug430120.js
+++ b/toolkit/mozapps/extensions/test/unit/test_bug430120.js
@@ -56,17 +56,17 @@ var timerService = {
 
   hasTimer: function(id) {
     var catMan = Components.classes["@mozilla.org/categorymanager;1"]
                            .getService(Components.interfaces.nsICategoryManager);
     var entries = catMan.enumerateCategory(CATEGORY_UPDATE_TIMER);
     while (entries.hasMoreElements()) {
       var entry = entries.getNext().QueryInterface(Components.interfaces.nsISupportsCString).data;
       var value = catMan.getCategoryEntry(CATEGORY_UPDATE_TIMER, entry);
-      var timerID = value.split(",")[3];
+      var timerID = value.split(",")[2];
       if (id == timerID) {
         return true;
       }
     }
     return false;
   },
 
   fireTimer: function(id) {
--- a/toolkit/mozapps/installer/packager.mk
+++ b/toolkit/mozapps/installer/packager.mk
@@ -38,17 +38,17 @@
 #
 # ***** END LICENSE BLOCK *****
 
 include $(MOZILLA_DIR)/toolkit/mozapps/installer/package-name.mk
 
 # This is how we create the binary packages we release to the public.
 
 ifndef MOZ_PKG_FORMAT
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 MOZ_PKG_FORMAT  = DMG
 else
 ifeq (,$(filter-out OS2 WINNT WINCE BeOS, $(OS_ARCH)))
 MOZ_PKG_FORMAT  = ZIP
 else
 ifeq (,$(filter-out SunOS, $(OS_ARCH)))
    MOZ_PKG_FORMAT  = BZ2
 else
--- a/toolkit/mozapps/update/src/updater/Makefile.in
+++ b/toolkit/mozapps/update/src/updater/Makefile.in
@@ -101,17 +101,17 @@ ifneq ($(MOZ_ENABLE_GTK2),)
 HAVE_PROGRESSUI = 1
 CPPSRCS += \
 	progressui_gtk.cpp \
 	$(NULL)
 OS_CXXFLAGS += $(TK_CFLAGS)
 OS_LIBS += $(TK_LIBS)
 endif
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 HAVE_PROGRESSUI = 1
 CMMSRCS += progressui_osx.mm launchchild_osx.mm
 OS_LIBS += -framework Cocoa
 endif
 
 ifndef HAVE_PROGRESSUI
 CPPSRCS += progressui_null.cpp
 endif
@@ -137,17 +137,17 @@ endif
 endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
 libs:: updater.png
 	$(NSINSTALL) -D $(DIST)/bin/icons
 	$(INSTALL) $(IFLAGS1) $^ $(DIST)/bin/icons
 endif
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 libs::
 	$(NSINSTALL) -D $(DIST)/bin/updater.app
 	rsync -a -C --exclude "*.in" $(srcdir)/macbuild/Contents $(DIST)/bin/updater.app 
 	sed -e "s/%APP_NAME%/$(MOZ_APP_DISPLAYNAME)/" $(srcdir)/macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in | \
 	  iconv -f UTF-8 -t UTF-16 > $(DIST)/bin/updater.app/Contents/Resources/English.lproj/InfoPlist.strings
 	$(NSINSTALL) -D $(DIST)/bin/updater.app/Contents/MacOS
 	$(NSINSTALL) $(DIST)/bin/updater $(DIST)/bin/updater.app/Contents/MacOS
 	rm -f $(DIST)/bin/updater
--- a/toolkit/profile/Makefile.in
+++ b/toolkit/profile/Makefile.in
@@ -40,15 +40,15 @@ topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 DIRS = public src
 
 # Use Qute for non-Mac non-Phoenix apps
-ifeq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT)))
 ifndef MOZ_PHOENIX
 DIRS += skin
 endif
 endif
 
 include $(topsrcdir)/config/rules.mk
--- a/toolkit/themes/Makefile.in
+++ b/toolkit/themes/Makefile.in
@@ -47,17 +47,17 @@ include $(DEPTH)/config/autoconf.mk
 # MacOS X                 Pinstripe (toolkit/themes/pinstripe)
 # Windows (9x, 2000, XP)  Winstripe (toolkit/themes/winstripe)
 # GNOME/Linux             Winstripe (toolkit/themes/winstripe) + 
 #                         GNOMEStripe overrides (toolkit/themes/gnomestripe)
 # OS/2                    Winstripe (toolkit/themes/winstripe) + 
 #                         PMStripe overrides (toolkit/themes/pmstripe)
 # faststripe              Winstripe + faststripe (no native theme components)
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 DIRS	= pinstripe
 else
 
 DIRS	= winstripe
 
 ifneq (,$(filter gtk2 qt,$(MOZ_WIDGET_TOOLKIT)))
 DIRS    += gnomestripe
 endif
--- a/toolkit/toolkit-tiers.mk
+++ b/toolkit/toolkit-tiers.mk
@@ -148,24 +148,16 @@ tier_gecko_dirs	+= \
 		editor \
 		layout \
 		docshell \
 		webshell \
 		embedding \
 		xpfe/appshell \
 		$(NULL)
 
-ifdef MOZ_XMLEXTRAS
-tier_gecko_dirs += extensions/xmlextras
-endif
-
-ifdef MOZ_WEBSERVICES
-tier_gecko_dirs += extensions/webservices
-endif
-
 ifdef MOZ_UNIVERSALCHARDET
 tier_gecko_dirs += extensions/universalchardet
 endif
 
 ifdef ACCESSIBILITY
 tier_gecko_dirs    += accessible
 endif
 
--- a/tools/trace-malloc/Makefile.in
+++ b/tools/trace-malloc/Makefile.in
@@ -72,32 +72,32 @@ PROGRAM		= spacetrace$(BIN_SUFFIX)
 
 ifeq ($(OS_ARCH),WINNT)
 LOCAL_INCLUDES	+= -I$(topsrcdir)/config/os2
 endif
 
 include $(topsrcdir)/config/config.mk
 
 ifdef MOZ_ENABLE_LIBXUL
-ifeq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 EXTRA_DSO_LIBS	= xul
 endif
 endif
 
 LIBS		+= \
 		$(LIBS_DIR) \
 		tmreader.$(OBJ_SUFFIX) \
 		adreader.$(OBJ_SUFFIX) \
 		$(EXTRA_DSO_LIBS) \
 		$(XPCOM_GLUE_LDOPTS) \
 		$(NSPR_LIBS) \
 		$(NULL)
 
 ifdef MOZ_ENABLE_LIBXUL
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 LIBS += $(DIST)/bin/XUL
 endif
 endif
 
 ifdef HAVE_BOUTELL_GD
 ifeq ($(OS_ARCH),WINNT)
 LOCAL_INCLUDES	+= \
 		-I"$(HAVE_BOUTELL_GD)" \
--- a/tools/update-packaging/Makefile.in
+++ b/tools/update-packaging/Makefile.in
@@ -48,17 +48,17 @@ include $(topsrcdir)/toolkit/mozapps/ins
 
 # input location for the build, usually $(DIST)
 # set this to $(DIST)/l10n-stage per override for L10n builds
 PACKAGE_BASE_DIR	= $(DIST)
 
 # Default output location for update archive
 STAGE_DIR	= $(DIST)/$(PKG_UPDATE_PATH)
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 ifdef UNIVERSAL_BINARY
 ifneq (,$(filter %/l10n-stage,$(PACKAGE_BASE_DIR)))
 PACKAGE_DIR	= $(PACKAGE_BASE_DIR)/$(MOZ_PKG_APPNAME)/$(MOZ_APP_DISPLAYNAME).app
 else
 PACKAGE_DIR	= $(PACKAGE_BASE_DIR)/universal/$(MOZ_PKG_APPNAME)/$(MOZ_APP_DISPLAYNAME).app
 endif
 else
 PACKAGE_DIR	= $(PACKAGE_BASE_DIR)/$(MOZ_PKG_APPNAME)/$(MOZ_APP_DISPLAYNAME).app
--- a/xpcom/base/Makefile.in
+++ b/xpcom/base/Makefile.in
@@ -61,17 +61,17 @@ CPPSRCS		= \
 		nsInterfaceRequestorAgg.cpp \
 		nsUUIDGenerator.cpp \
 		nsSystemInfo.cpp \
 		nsCycleCollector.cpp \
 		nsStackWalk.cpp \
 		nsMemoryReporterManager.cpp \
 		$(NULL)
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 CPPSRCS		+= nsMacUtilsImpl.cpp
 endif
 
 EXPORTS		= \
 		nsAgg.h \
 		nsAutoRef.h \
 		nsCom.h \
 		nsDebugImpl.h \
@@ -118,17 +118,17 @@ XPIDLSRCS	= \
 		nsIException.idl \
 		nsIExceptionService.idl \
 		nsIVersionComparator.idl \
 		nsIUUIDGenerator.idl \
 		nsIMutable.idl \
 		nsIMemoryReporter.idl \
 		$(NULL)
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 XPIDLSRCS	+= nsIMacUtils.idl
 endif
 
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 
 # Force use of PIC
 FORCE_USE_PIC	= 1
--- a/xpcom/sample/Makefile.in
+++ b/xpcom/sample/Makefile.in
@@ -90,17 +90,17 @@ EXTRA_COMPONENTS = nsSample.js
 # frozen XPCOM shared library.
 EXTRA_DSO_LDOPTS = \
 		$(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \
 		$(XPCOM_FROZEN_LDOPTS) \
 		$(NSPR_LIBS) \
 		$(NULL)
 
 # Need to link with CoreFoundation on Mac
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 EXTRA_DSO_LDOPTS += \
 		$(TK_LIBS) \
 		$(NULL)
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 libs:: $(TARGETS)
--- a/xpcom/sample/program/Makefile.in
+++ b/xpcom/sample/program/Makefile.in
@@ -56,17 +56,17 @@ SIMPLE_PROGRAMS = nsTestSample$(BIN_SUFF
 # this Makefile. We link against the "standalone glue" which does not require
 # that the application be linked against the XPCOM dynamic library or the NSPR
 # dynamic libraries.
 LIBS            = \
 		$(XPCOM_STANDALONE_GLUE_LDOPTS) \
 		$(NULL)
 
 # Need to link with CoreFoundation on Mac
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 LIBS            += \
 		$(TK_LIBS) \
 		$(NULL)
 endif
 
 # Whatever code is going to be linked with the *standalone* glue must be
 # built with the XPCOM_GLUE define set.
 DEFINES += -DXPCOM_GLUE
--- a/xpcom/tools/registry/Makefile.in
+++ b/xpcom/tools/registry/Makefile.in
@@ -53,17 +53,17 @@ LOCAL_INCLUDES	= \
 
 SIMPLE_PROGRAMS	= $(CPPSRCS:.cpp=$(BIN_SUFFIX))
 
 LIBS            = \
 		$(XPCOM_STANDALONE_GLUE_LDOPTS) \
 		$(NULL)
 
 # Need to link with CoreFoundation on Mac
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 LIBS            += \
 		$(TK_LIBS) \
 		$(NULL)
 endif
 
 SDK_BINARY     =                    \
 		$(SIMPLE_PROGRAMS)  \
 		$(NULL)
--- a/xulrunner/app/Makefile.in
+++ b/xulrunner/app/Makefile.in
@@ -91,17 +91,17 @@ endif
 endif
 endif
 
 LOCAL_INCLUDES += \
         -I$(topsrcdir)/toolkit/xre \
         -I$(topsrcdir)/toolkit/profile/src \
         $(NULL)
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 TK_LIBS := -framework Cocoa $(TK_LIBS)
 endif
 
 ifndef MOZ_ENABLE_LIBXUL
 ifeq (bundle,$(MOZ_FS_LAYOUT))
 LIBS += $(DIST)/bin/XUL
 else
 EXTRA_DSO_LIBS += xul
@@ -263,17 +263,17 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
 endif
 ifeq ($(OS_ARCH),OS2)
 	cp $(srcdir)/xulrunner-os2.ico   $(DIST)/branding/xulrunner.ico
 endif
 
 libs::
 	touch $(DIST)/bin/.autoreg
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 
 FRAMEWORK_NAME = XUL
 FRAMEWORK_VERSION = $(MOZILLA_VERSION)
 
 libs:: $(PROGRAM)
 	mkdir -p $(DIST)/$(FRAMEWORK_NAME).framework/Versions/$(FRAMEWORK_VERSION)/Resources
 	$(NSINSTALL) $(srcdir)/macbuild/InfoPlist.strings $(DIST)/$(FRAMEWORK_NAME).framework/Versions/$(FRAMEWORK_VERSION)/Resources
 	sed -e "s/APP_VERSION/$(APP_VERSION)/" $(srcdir)/macbuild/Info.plist.in > $(DIST)/$(FRAMEWORK_NAME).framework/Versions/$(FRAMEWORK_VERSION)/Info.plist
--- a/xulrunner/installer/Makefile.in
+++ b/xulrunner/installer/Makefile.in
@@ -48,17 +48,17 @@ NO_PKG_FILES = \
 	xulrunner-config \
 	regchrome* \
 	regxpcom* \
 	$(NULL)
 
 # If we're on mac, we want to make the .pkg first, in the mac/
 # directory. Then packager.mk can put it into a DMG
 
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 DIRS += mac
 _APPNAME = $(PKG_BASENAME).pkg
 PKG_SKIP_STRIP = 1
 MOZ_PKG_SPECIAL = pkg
 PKG_DMG_SOURCE = $(STAGEPATH)xulrunner-pkg
 endif
 
 include $(topsrcdir)/config/rules.mk
--- a/xulrunner/stub/Makefile.in
+++ b/xulrunner/stub/Makefile.in
@@ -61,17 +61,17 @@ LOCAL_INCLUDES = -I$(topsrcdir)/xpcom/bu
 
 DEFINES  += -DXPCOM_GLUE
 
 LIBS = \
   $(XPCOM_STANDALONE_GLUE_LDOPTS) \
   $(NULL)
 
 # Need to link with CoreFoundation on Mac
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 LIBS            += \
 		$(TK_LIBS) \
 		$(NULL)
 endif
 
 ifneq (,$(filter WINNT WINCE,$(OS_ARCH)))
 RCINCLUDE = xulrunner-stub.rc
 ifndef GNU_CC