Merge mozilla-central to tracemonkey.
authorRobert Sayre <sayrer@gmail.com>
Mon, 22 Feb 2010 12:29:54 -0800
changeset 38625 61a56eb14431d3a3bb2c4cac7f81613eb293ca01
parent 38624 3970759ca2c144ca91c2189dd71c9cf9666a11bc (current diff)
parent 38393 d8df8e07f0fb60758bf396a7fa0949317c75b75f (diff)
child 38626 76e22cb4cbb5a9316217eae78ad2c8372932e413
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.3a2pre
Merge mozilla-central to tracemonkey.
accessible/src/base/nsAccessibleTreeWalker.cpp
accessible/src/base/nsAccessibleTreeWalker.h
accessible/tests/mochitest/nsIAccessibleEditableText.js
accessible/tests/mochitest/test_nsIAccessibleEditableText.html
browser/themes/pinstripe/browser/bookmark-hover-dropmarker.png
browser/themes/pinstripe/browser/bookmark-open-left.png
browser/themes/pinstripe/browser/bookmark-open-mid.png
browser/themes/pinstripe/browser/bookmark-open-right.png
browser/themes/pinstripe/browser/bookmark_toolbar_background.png
browser/themes/pinstripe/browser/urlbar/endcap-focused-graphite-rtl.png
browser/themes/pinstripe/browser/urlbar/endcap-focused-graphite.png
browser/themes/pinstripe/browser/urlbar/endcap-focused-rtl.png
browser/themes/pinstripe/browser/urlbar/endcap-focused.png
browser/themes/pinstripe/browser/urlbar/endcap-rtl.png
browser/themes/pinstripe/browser/urlbar/endcap-secure.png
browser/themes/pinstripe/browser/urlbar/endcap.png
browser/themes/pinstripe/browser/urlbar/startcap-active-focused-graphite-rtl.png
browser/themes/pinstripe/browser/urlbar/startcap-active-focused-graphite.png
browser/themes/pinstripe/browser/urlbar/startcap-active-focused-rtl.png
browser/themes/pinstripe/browser/urlbar/startcap-active-focused.png
browser/themes/pinstripe/browser/urlbar/startcap-active-rtl.png
browser/themes/pinstripe/browser/urlbar/startcap-active.png
browser/themes/pinstripe/browser/urlbar/startcap-focused-graphite-rtl.png
browser/themes/pinstripe/browser/urlbar/startcap-focused-graphite.png
browser/themes/pinstripe/browser/urlbar/startcap-focused-rtl.png
browser/themes/pinstripe/browser/urlbar/startcap-focused.png
browser/themes/pinstripe/browser/urlbar/startcap-rtl.png
browser/themes/pinstripe/browser/urlbar/startcap-secure-active.png
browser/themes/pinstripe/browser/urlbar/startcap-secure-end-active.png
browser/themes/pinstripe/browser/urlbar/startcap-secure-end-focused-graphite.png
browser/themes/pinstripe/browser/urlbar/startcap-secure-end-focused.png
browser/themes/pinstripe/browser/urlbar/startcap-secure-end.png
browser/themes/pinstripe/browser/urlbar/startcap-secure-mid-active.png
browser/themes/pinstripe/browser/urlbar/startcap-secure-mid-focused-graphite.png
browser/themes/pinstripe/browser/urlbar/startcap-secure-mid-focused.png
browser/themes/pinstripe/browser/urlbar/startcap-secure-mid.png
browser/themes/pinstripe/browser/urlbar/startcap-secure-start-active.png
browser/themes/pinstripe/browser/urlbar/startcap-secure-start-focused-graphite.png
browser/themes/pinstripe/browser/urlbar/startcap-secure-start-focused.png
browser/themes/pinstripe/browser/urlbar/startcap-secure-start.png
browser/themes/pinstripe/browser/urlbar/startcap-secure.png
browser/themes/pinstripe/browser/urlbar/startcap-verified-end-active.png
browser/themes/pinstripe/browser/urlbar/startcap-verified-end-focused-graphite.png
browser/themes/pinstripe/browser/urlbar/startcap-verified-end-focused.png
browser/themes/pinstripe/browser/urlbar/startcap-verified-end-invalid.png
browser/themes/pinstripe/browser/urlbar/startcap-verified-end.png
browser/themes/pinstripe/browser/urlbar/startcap-verified-mid-active.png
browser/themes/pinstripe/browser/urlbar/startcap-verified-mid-focused-graphite.png
browser/themes/pinstripe/browser/urlbar/startcap-verified-mid-focused.png
browser/themes/pinstripe/browser/urlbar/startcap-verified-mid.png
browser/themes/pinstripe/browser/urlbar/startcap-verified-start-active.png
browser/themes/pinstripe/browser/urlbar/startcap-verified-start-focused-graphite.png
browser/themes/pinstripe/browser/urlbar/startcap-verified-start-focused.png
browser/themes/pinstripe/browser/urlbar/startcap-verified-start.png
browser/themes/pinstripe/browser/urlbar/startcap.png
browser/themes/pinstripe/browser/urlbar/textfield-mid-focused-graphite.png
browser/themes/pinstripe/browser/urlbar/textfield-mid-focused.png
browser/themes/pinstripe/browser/urlbar/textfield-mid-secure-focused.png
browser/themes/pinstripe/browser/urlbar/textfield-mid-secure.png
browser/themes/pinstripe/browser/urlbar/textfield-mid.png
browser/themes/pinstripe/browser/urlbar/urlbar-favicon-glow.png
browser/themes/winstripe/browser/Toolbar-aero.png
browser/themes/winstripe/browser/Toolbar-small-aero.png
browser/themes/winstripe/browser/Toolbar-small.png
chrome/test/unit/data/test_bug519468.manifest
dom/base/nsFocusController.cpp
dom/base/nsFocusController.h
dom/base/nsIFocusController.h
js/src/config/autoconf.mk.in
js/src/configure.in
layout/forms/nsICheckboxControlFrame.h
layout/forms/nsIRadioControlFrame.h
layout/reftests/svg-integration/clipPath-html-01-extref.xhtml
layout/reftests/svg-integration/clipPath-html-01-ref.svg
layout/reftests/svg-integration/clipPath-html-01.xhtml
layout/reftests/svg-integration/clipPath-html-02-extref.xhtml
layout/reftests/svg-integration/clipPath-html-02-ref.svg
layout/reftests/svg-integration/clipPath-html-02.xhtml
layout/reftests/svg-integration/clipPath-html-03-extref.xhtml
layout/reftests/svg-integration/clipPath-html-03-ref.svg
layout/reftests/svg-integration/clipPath-html-03.xhtml
layout/reftests/svg-integration/clipPath-html-04-extref.xhtml
layout/reftests/svg-integration/clipPath-html-04-ref.xhtml
layout/reftests/svg-integration/clipPath-html-04.xhtml
layout/reftests/svg-integration/clipPath-html-05-extref.xhtml
layout/reftests/svg-integration/clipPath-html-05-ref.xhtml
layout/reftests/svg-integration/clipPath-html-05.xhtml
layout/reftests/svg-integration/clipPath-html-06-extref.xhtml
layout/reftests/svg-integration/clipPath-html-06-ref.xhtml
layout/reftests/svg-integration/clipPath-html-06.xhtml
layout/reftests/svg-integration/clipPath-html-zoomed-01.xhtml
layout/reftests/svg-integration/filter-html-01-extref.xhtml
layout/reftests/svg-integration/filter-html-01-ref.svg
layout/reftests/svg-integration/filter-html-01.xhtml
layout/reftests/svg-integration/filter-html-zoomed-01.xhtml
layout/reftests/svg-integration/mask-html-01-extref-01.xhtml
layout/reftests/svg-integration/mask-html-01-extref-02.xhtml
layout/reftests/svg-integration/mask-html-01-ref.svg
layout/reftests/svg-integration/mask-html-01-resource.svg
layout/reftests/svg-integration/mask-html-01.xhtml
layout/reftests/svg-integration/mask-html-zoomed-01.xhtml
layout/reftests/svg-integration/reftest.list
nsprpub/pr/tests/nst_wince.h
nsprpub/pr/tests/wince_tester.cpp
security/nss/lib/util/secinit.c
testing/mochitest/tests/test_bug100533.html
testing/mochitest/tests/test_bug1297.html
testing/mochitest/tests/test_bug1366.html
testing/mochitest/tests/test_bug1400.html
testing/mochitest/tests/test_bug1682.html
testing/mochitest/tests/test_bug172261.html
testing/mochitest/tests/test_bug1823.html
testing/mochitest/tests/test_bug2082.html
testing/mochitest/tests/test_bug218236.html
testing/mochitest/tests/test_bug218277.html
testing/mochitest/tests/test_bug237071.html
testing/mochitest/tests/test_bug238409.html
testing/mochitest/tests/test_bug24958.html
testing/mochitest/tests/test_bug277724.html
testing/mochitest/tests/test_bug300691-1.html
testing/mochitest/tests/test_bug300691-2.html
testing/mochitest/tests/test_bug300691-3.xhtml
testing/mochitest/tests/test_bug302186.html
testing/mochitest/tests/test_bug308484.html
testing/mochitest/tests/test_bug308856.html
testing/mochitest/tests/test_bug311681.html
testing/mochitest/tests/test_bug311681.xhtml
testing/mochitest/tests/test_bug311681.xml
testing/mochitest/tests/test_bug311681.xul
testing/mochitest/tests/test_bug319381.html
testing/mochitest/tests/test_bug332848.xhtml
testing/mochitest/tests/test_bug333983.html
testing/mochitest/tests/test_bug3348.html
testing/mochitest/tests/test_bug337124.html
testing/mochitest/tests/test_bug337631.html
testing/mochitest/tests/test_bug338541.xhtml
testing/mochitest/tests/test_bug338679.html
testing/mochitest/tests/test_bug339350.xhtml
testing/mochitest/tests/test_bug339494.html
testing/mochitest/tests/test_bug339494.xhtml
testing/mochitest/tests/test_bug339494.xul
testing/mochitest/tests/test_bug340800.html
testing/mochitest/tests/test_bug342448.html
testing/mochitest/tests/test_bug343596.html
testing/mochitest/tests/test_bug344830.html
testing/mochitest/tests/test_bug344861.html
testing/mochitest/tests/test_bug345521.html
testing/mochitest/tests/test_bug348497.html
testing/mochitest/tests/test_bug351601.html
testing/mochitest/tests/test_bug352728.html
testing/mochitest/tests/test_bug352728.xhtml
testing/mochitest/tests/test_bug355026.html
testing/mochitest/tests/test_bug357509.html
testing/mochitest/tests/test_bug358660.html
testing/mochitest/tests/test_bug358797.html
testing/mochitest/tests/test_bug359657.html
testing/mochitest/tests/test_bug359754.xul
testing/mochitest/tests/test_bug360220.xul
testing/mochitest/tests/test_bug362391.xhtml
testing/mochitest/tests/test_bug364092.xhtml
testing/mochitest/tests/test_bug364413.xhtml
testing/mochitest/tests/test_bug365773.xul
testing/mochitest/tests/test_bug367164.html
testing/mochitest/tests/test_bug51034.html
testing/mochitest/tests/test_bug5141.html
testing/mochitest/tests/test_bug589.html
testing/mochitest/tests/test_bug6296.html
testing/mochitest/tests/test_bug691.html
testing/mochitest/tests/test_bug694.html
testing/mochitest/tests/test_bug696.html
toolkit/components/contentprefs/public/Makefile.in
toolkit/components/contentprefs/public/nsIContentURIGrouper.idl
toolkit/crashreporter/content/oopcrashdialog.js
toolkit/crashreporter/content/oopcrashdialog.xul
toolkit/mozapps/plugins/content/missingPlugin.xml
toolkit/mozapps/plugins/content/missingPluginBinding.css
toolkit/themes/pinstripe/global/toolbar/dropmark-nav.png
toolkit/themes/pinstripe/global/toolbar/toolbar-background-tall-inactive.png
toolkit/themes/pinstripe/global/toolbar/toolbar-background-tall.gif
toolkit/themes/pinstripe/global/toolbar/toolbar-background-tall.png
toolkit/themes/pinstripe/global/toolbar/toolbarbutton-customhover-left.png
toolkit/themes/pinstripe/global/toolbar/toolbarbutton-customhover-mid.png
toolkit/themes/pinstripe/global/toolbar/toolbarbutton-customhover-right.png
toolkit/themes/pinstripe/global/tree/item-grayscale.png
toolkit/themes/pinstripe/mozapps/plugins/missingPlugin.css
toolkit/themes/winstripe/mozapps/plugins/missingPlugin.css
tools/rb/fix-macosx-stack.py
--- a/Makefile.in
+++ b/Makefile.in
@@ -78,17 +78,17 @@ TIERS += testharness
 ifdef ENABLE_TESTS
 tier_testharness_dirs += testing/xpcshell
 endif
 
 include $(topsrcdir)/config/config.mk
 
 GARBAGE_DIRS += dist _javagen _profile _tests staticlib
 DIST_GARBAGE = config.cache config.log config.status config-defs.h \
-   dependencies.beos config/autoconf.mk config/myrules.mk config/myconfig.mk \
+   dependencies.beos config/autoconf.mk \
    unallmakefiles mozilla-config.h \
    netwerk/necko-config.h xpcom/xpcom-config.h xpcom/xpcom-private.h \
    $(topsrcdir)/.mozconfig.mk $(topsrcdir)/.mozconfig.out
 
 default alldep all:: $(topsrcdir)/configure config.status
 	$(RM) -rf $(DIST)/sdk
 	$(RM) -rf $(DIST)/include
 	$(RM) -rf $(DIST)/private
@@ -140,16 +140,26 @@ tier_necko::
 	$(foreach tier,$(TIERS),$(MAKE) tools_tier_$(tier); )
 endif
 
 distclean::
 	cat unallmakefiles | $(XARGS) rm -f
 	rm -f unallmakefiles $(DIST_GARBAGE)
 
 ifeq ($(OS_ARCH),WINNT)
+rebase:
+ifdef MOZILLA_OFFICIAL
+	echo rebasing $(DIST)
+	/bin/find $(DIST) -name "*.dll" -a -not -name "msvc*" > rebase.lst
+	rebase -b 60000000 -R . -G rebase.lst
+	rm rebase.lst
+endif
+endif # WINNT
+
+ifeq ($(OS_ARCH),WINNT)
 # we want to copy PDB files on Windows
 MAKE_SYM_STORE_ARGS := -c
 ifdef PDBSTR_PATH
 MAKE_SYM_STORE_ARGS += -i
 endif
 ifeq (,$(CYGWIN_WRAPPER))
 # this doesn't work with Cygwin Python
 MAKE_SYM_STORE_ARGS += --vcs-info
@@ -220,16 +230,29 @@ endif # SYMBOLSTORE_PATH
 endif # WINCE
 endif # MOZ_CRASHREPORTER
 
 uploadsymbols:
 ifdef MOZ_CRASHREPORTER
 	$(SHELL) $(topsrcdir)/toolkit/crashreporter/tools/upload_symbols.sh "$(DIST)/$(PKG_PATH)$(SYMBOL_ARCHIVE_BASENAME).zip"
 endif
 
+ifeq ($(OS_ARCH),WINNT)
+signnss:
+ifdef MOZILLA_OFFICIAL
+	echo signing NSS libs
+	cd $(DIST)/bin; ./shlibsign.exe -v -i softokn3.dll
+	cd $(DIST)/bin; ./shlibsign.exe -v -i freebl3.dll
+	cd $(DIST)/bin; ./shlibsign.exe -v -i nssdbm3.dll
+endif # MOZILLA_OFFICIAL
+
+deliver: rebase signnss
+
+endif # WINNT
+
 ifneq (,$(wildcard $(DIST)/bin/application.ini))
 BUILDID = $(shell $(PYTHON) $(srcdir)/config/printconfigsetting.py $(DIST)/bin/application.ini App BuildID)
 else
 BUILDID = $(shell $(PYTHON) $(srcdir)/config/printconfigsetting.py $(DIST)/bin/platform.ini Build BuildID)
 endif
 
 MOZ_SOURCE_STAMP = $(shell hg -R $(srcdir) parent --template="{node|short}\n" 2>/dev/null)
 export MOZ_SOURCE_STAMP
--- a/accessible/public/nsIAccessibilityService.idl
+++ b/accessible/public/nsIAccessibilityService.idl
@@ -39,27 +39,25 @@
 #include "nsISupports.idl"
 #include "nsIAccessibleRetrieval.idl"
 
 interface nsIDocument;
 interface nsIFrame;
 interface nsObjectFrame;
 interface nsIContent;
 
-[uuid(84a3ab70-8f7e-4610-9cd8-bd69308b76c5)]
+[uuid(4df7499d-d96e-48f8-a936-8a22ec0d4915)]
 interface nsIAccessibilityService : nsIAccessibleRetrieval
 {
   nsIAccessible createOuterDocAccessible(in nsIDOMNode aNode);
-  nsIAccessible createRootAccessible(in nsIPresShell aShell, in nsIDocument aDocument);
 
   nsIAccessible createHTML4ButtonAccessible(in nsIFrame aFrame);
   nsIAccessible createHyperTextAccessible(in nsIFrame aFrame);
   nsIAccessible createHTMLBRAccessible(in nsIFrame aFrame);
   nsIAccessible createHTMLButtonAccessible(in nsIFrame aFrame);
-  nsIAccessible createHTMLAccessibleByMarkup(in nsIFrame aFrame, in nsIWeakReference aWeakShell, in nsIDOMNode aDOMNode);
   nsIAccessible createHTMLLIAccessible(in nsIFrame aFrame, in nsIFrame aBulletFrame, in AString aBulletText);
   nsIAccessible createHTMLCheckboxAccessible(in nsIFrame aFrame);
   nsIAccessible createHTMLComboboxAccessible(in nsIDOMNode aNode, in nsIWeakReference aPresShell);
   nsIAccessible createHTMLGenericAccessible(in nsIFrame aFrame);
   nsIAccessible createHTMLGroupboxAccessible(in nsIFrame aFrame);
   nsIAccessible createHTMLHRAccessible(in nsIFrame aFrame);
   nsIAccessible createHTMLImageAccessible(in nsIFrame aFrame);
   nsIAccessible createHTMLLabelAccessible(in nsIFrame aFrame);
--- a/accessible/public/nsIAccessibleDocument.idl
+++ b/accessible/public/nsIAccessibleDocument.idl
@@ -53,17 +53,17 @@ interface nsIDOMWindow;
  * You can QueryInterface to nsIAccessibleDocument from
  * the nsIAccessible or nsIAccessNode for the root node
  * of a document. You can also get one from 
  * nsIAccessNode::GetAccessibleDocument() or 
  * nsIAccessibleEvent::GetAccessibleDocument()
  *
  * @status UNDER_REVIEW
  */
-[scriptable, uuid(b7ae45bd-21e9-4ed5-a67e-86448b25d56b)]
+[scriptable, uuid(427597a3-1737-4743-bf43-2311a1ed5fbd)]
 interface nsIAccessibleDocument : nsISupports
 {
   /**
    * The URL of the document
    */
   readonly attribute AString URL;
 
   /**
@@ -98,25 +98,16 @@ interface nsIAccessibleDocument : nsISup
 
   /**
    * The window handle for the OS window the document is being displayed in.
    * For example, in Windows you can static cast it to an HWND.
    */
   [noscript] readonly attribute voidPtr windowHandle;
 
   /**
-   * Returns the access node cached by this document
-   * @param aUniqueID The unique ID used to cache the node.
-   *                  This matches up with the uniqueID attribute on
-   *                  nsIAccessNode.
-   * @return The nsIAccessNode cached for this particular unique ID.
-   */
-  [noscript] nsIAccessNode getCachedAccessNode(in voidPtr aUniqueID);
-
-  /**
    * Returns the first accessible parent of a DOM node.
    * Guaranteed not to return nsnull if the DOM node is in a document.
    * @param aDOMNode The DOM node we need an accessible for.
    * @param aCanCreate Can accessibles be created or must it be the first 
    *                   cached accessible in the parent chain?
    * @return An first nsIAccessible found by crawling up the DOM node
    *         to the document root.
    */
--- a/accessible/public/nsIAccessibleRetrieval.idl
+++ b/accessible/public/nsIAccessibleRetrieval.idl
@@ -51,17 +51,17 @@ interface nsIDOMDOMStringList;
  * An interface for in-process accessibility clients
  * wishing to get an nsIAccessible or nsIAccessNode for
  * a given DOM node.
  * More documentation at:
  *   http://www.mozilla.org/projects/ui/accessibility
  *
  * @status UNDER_REVIEW
  */
-[scriptable, uuid(7eb49afb-6298-4ce6-816f-9615936540f4)]
+[scriptable, uuid(5f5a6f98-835d-4771-8bfe-a0c7cdc85fec)]
 interface nsIAccessibleRetrieval : nsISupports
 {
   /**
    * Return an nsIAccessible for a DOM node in pres shell 0.
    * Create a new accessible of the appropriate type if necessary,
    * or use one from the accessibility cache if it already exists.
    * @param aNode The DOM node to get an accessible for.
    * @return The nsIAccessible for the given DOM node.
@@ -96,36 +96,16 @@ interface nsIAccessibleRetrieval : nsISu
    * Return an nsIAccessible for a DOM node in the given pres shell.
    * Create a new accessible of the appropriate type if necessary,
    * or use one from the accessibility cache if it already exists.
    * @param aNode      The DOM node to get an accessible for.
    * @param aPresShell The presentation shell which contains layout info for the DOM node.
    * @return The nsIAccessible for the given DOM node.
    */
   nsIAccessible getAccessibleInShell(in nsIDOMNode aNode, in nsIPresShell aPresShell);
-  
-   /**
-    * Return an nsIAccessNode for an already created DOM node in the given weak shell.
-    * Does not create a new one -- only returns cached access nodes.
-    * @param aNode      The DOM node to get an access node for.
-    * @param aPresShell The presentation shell which contains layout info for the DOM node.
-    * @return The nsIAccessNode for the given DOM node or null if
-    *         an access node does not already exist for this DOM node.
-    */
-  nsIAccessNode getCachedAccessNode(in nsIDOMNode aNode, in nsIWeakReference aShell);
-
-   /**
-    * Return an nsIAccessible for an already created DOM node in the given weak shell.
-    * Does not create a new one -- only returns cached accessibles.
-    * @param aNode      The DOM node to get an accessible for.
-    * @param aPresShell The presentation shell which contains layout info for the DOM node.
-    * @return The nsIAccessible for the given DOM node or null if
-    *         an accessible does not already exist for this DOM node.
-    */
-  nsIAccessible getCachedAccessible(in nsIDOMNode aNode, in nsIWeakReference aShell);
 
    /**
     * Returns accessible role as a string.
     *
     * @param aRole - the accessible role constants.
     */
   AString getStringRole(in unsigned long aRole);
 
--- a/accessible/src/base/Makefile.in
+++ b/accessible/src/base/Makefile.in
@@ -56,17 +56,17 @@ CPPSRCS = \
   nsOuterDocAccessible.cpp \
   nsAccessibilityAtoms.cpp \
   nsCoreUtils.cpp \
   nsAccUtils.cpp \
   nsRelUtils.cpp \
   nsAccessibilityService.cpp \
   nsAccessible.cpp \
   nsAccessibleRelation.cpp \
-  nsAccessibleTreeWalker.cpp \
+  nsAccTreeWalker.cpp \
   nsBaseWidgetAccessible.cpp \
   nsEventShell.cpp \
   nsFormControlAccessible.cpp \
   nsRootAccessible.cpp \
   nsApplicationAccessible.cpp \
   nsCaretAccessible.cpp \
   nsTextAccessible.cpp \
   nsTextEquivUtils.cpp \
rename from accessible/src/base/nsAccessibleTreeWalker.cpp
rename to accessible/src/base/nsAccTreeWalker.cpp
--- a/accessible/src/base/nsAccessibleTreeWalker.cpp
+++ b/accessible/src/base/nsAccTreeWalker.cpp
@@ -15,292 +15,142 @@
  * 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) 2003
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
- *   Original Author: Aaron Leventhal (aaronl@netscape.com)
+ *  Aaron Leventhal <aaronleventhal@moonset.net> (original author)
+ *  Alexander Surkov <surkov.alexander@gmail.com>
  *
  * 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 ***** */
 
-#include "nsAccessibleTreeWalker.h"
+#include "nsAccTreeWalker.h"
 
-#include "nsAccessibilityAtoms.h"
-#include "nsAccessNode.h"
+#include "nsAccessible.h"
+#include "nsAccessibilityService.h"
 
-#include "nsIAnonymousContentCreator.h"
-#include "nsIServiceManager.h"
-#include "nsIContent.h"
-#include "nsIDOMXULElement.h"
-#include "nsIPresShell.h"
-#include "nsAccessibilityService.h"
-#include "nsWeakReference.h"
+////////////////////////////////////////////////////////////////////////////////
+// WalkState
+////////////////////////////////////////////////////////////////////////////////
+
+struct WalkState
+{
+  WalkState(nsIContent *aContent) :
+    content(aContent), childIdx(0), prevState(nsnull) {}
 
-nsAccessibleTreeWalker::nsAccessibleTreeWalker(nsIWeakReference* aPresShell, nsIDOMNode* aNode, PRBool aWalkAnonContent): 
-  mWeakShell(aPresShell),
-  mWalkAnonContent(aWalkAnonContent)
-{
-  mState.domNode = aNode;
-  mState.prevState = nsnull;
-  mState.siblingIndex = eSiblingsUninitialized;
-  mState.siblingList = nsnull;
-  mState.isHidden = false;
+  nsCOMPtr<nsIContent> content;
+  nsCOMPtr<nsINodeList> childList;
+  PRUint32 childIdx;
+  WalkState *prevState;
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// nsAccTreeWalker
+////////////////////////////////////////////////////////////////////////////////
 
-  MOZ_COUNT_CTOR(nsAccessibleTreeWalker);
-}
-
-nsAccessibleTreeWalker::~nsAccessibleTreeWalker()
+nsAccTreeWalker::
+  nsAccTreeWalker(nsIWeakReference* aShell, nsIContent* aContent,
+                  PRBool aWalkAnonContent) :
+  mWeakShell(aShell), mState(nsnull)
 {
-  // Clear state stack from memory
-  while (NS_SUCCEEDED(PopState()))
-    /* do nothing */ ;
-   MOZ_COUNT_DTOR(nsAccessibleTreeWalker);
+  NS_ASSERTION(aContent, "No node for the accessible tree walker!");
+
+  if (aContent)
+    mState = new WalkState(aContent);
+
+  mChildType = aWalkAnonContent ? nsIContent::eAllChildren :
+                                  nsIContent::eAllButXBL;
+
+  MOZ_COUNT_CTOR(nsAccTreeWalker);
 }
 
-void nsAccessibleTreeWalker::GetKids(nsIDOMNode *aParentNode)
+nsAccTreeWalker::~nsAccTreeWalker()
 {
-  nsCOMPtr<nsIContent> parentContent(do_QueryInterface(aParentNode));
-  if (!parentContent || !parentContent->IsHTML()) {
-    mState.frame = nsnull;  // Don't walk frames in non-HTML content, just walk the DOM.
-  }
+  // Clear state stack from memory
+  while (mState)
+    PopState();
+
+  MOZ_COUNT_DTOR(nsAccTreeWalker);
+}
 
-  WalkFrames();
+////////////////////////////////////////////////////////////////////////////////
+// nsAccTreeWalker: private
 
-  // Walk frames? UpdateFrame() sets this when it sees anonymous frames
-  if (mState.siblingIndex == eSiblingsWalkFrames) {
-    return;
-  }
+already_AddRefed<nsAccessible>
+nsAccTreeWalker::GetNextChildInternal(PRBool aNoWalkUp)
+{
+  if (!mState || !mState->content)
+    return nsnull;
+
+  if (!mState->childList)
+    mState->childList = mState->content->GetChildren(mChildType);
+
+  nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mWeakShell));
 
-  // Walk anonymous content? Not currently used for HTML -- anonymous content there uses frame walking
-  mState.siblingIndex = 0;   // Indicates our index into the sibling list
-  if (parentContent) {
-    if (mWalkAnonContent) {
-      // Walk anonymous content
-      nsIDocument* doc = parentContent->GetOwnerDoc();
-      if (doc) {
-        // returns null if no anon nodes
-        doc->GetXBLChildNodesFor(parentContent,
-                                 getter_AddRefs(mState.siblingList));
-      }
-    }
-    if (!mState.siblingList) {
-      // Walk normal DOM. Just use nsIContent -- it doesn't require 
-      // the mallocs that GetChildNodes() needs
-      //aParentNode->GetChildNodes(getter_AddRefs(mState.siblingList));
-      mState.parentContent = parentContent;
-      mState.domNode = do_QueryInterface(parentContent->GetChildAt(0 /* 0 == mState.siblingIndex */));
-      return;
-    }
-  }
-  else {
-    // We're on document node, that's why we could not QI to nsIContent.
-    // So, use nsIDOMNodeList method to walk content.
-    aParentNode->GetChildNodes(getter_AddRefs(mState.siblingList));
-    if (!mState.siblingList) {
-      return;
+  PRUint32 length = 0;
+  if (mState->childList)
+    mState->childList->GetLength(&length);
+
+  while (mState->childIdx < length) {
+    nsIContent* childNode = mState->childList->GetNodeAt(mState->childIdx);
+    mState->childIdx++;
+
+    PRBool isHidden = PR_FALSE;
+    nsCOMPtr<nsIDOMNode> childDOMNode(do_QueryInterface(childNode));
+    nsRefPtr<nsAccessible> accessible =
+      GetAccService()->GetAccessible(childDOMNode, presShell, mWeakShell,
+                                     &isHidden);
+
+    if (accessible)
+      return accessible.forget();
+
+    // Walk down into subtree to find accessibles.
+    if (!isHidden) {
+      if (!PushState(childNode))
+        break;
+
+      accessible = GetNextChildInternal(PR_TRUE);
+      if (accessible)
+        return accessible.forget();
     }
   }
 
-  mState.siblingList->Item(0 /* 0 == mState.siblingIndex */, getter_AddRefs(mState.domNode));
-}
-
-NS_IMETHODIMP nsAccessibleTreeWalker::PopState()
-{
-  nsIFrame *frameParent =
-    mState.frame.GetFrame() ? mState.frame.GetFrame()->GetParent() : nsnull;
-  if (mState.prevState) {
-    WalkState *toBeDeleted = mState.prevState;
-    mState = *mState.prevState; // deep copy
-    mState.isHidden = PR_FALSE; // If we were in a child, the parent wasn't hidden
-    if (!mState.frame.GetFrame()) {
-      mState.frame = frameParent;
-    }
-    delete toBeDeleted;
-    return NS_OK;
-  }
-  ClearState();
-  mState.frame = frameParent;
-  mState.isHidden = PR_FALSE;
-  return NS_ERROR_FAILURE;
-}
-
-void nsAccessibleTreeWalker::ClearState()
-{
-  mState.siblingList = nsnull;
-  mState.parentContent = nsnull;
-  mState.accessible = nsnull;
-  mState.domNode = nsnull;
-  mState.siblingIndex = eSiblingsUninitialized;
-}
+  // No more children, get back to the parent.
+  PopState();
 
-NS_IMETHODIMP nsAccessibleTreeWalker::PushState()
-{
-  // Duplicate mState and put right before end; reset mState; make mState the new end of the stack
-  WalkState* nextToLastState= new WalkState();
-  if (!nextToLastState)
-    return NS_ERROR_OUT_OF_MEMORY;
-  *nextToLastState = mState;  // Deep copy - copy contents of struct to new state that will be added to end of our stack
-  ClearState();
-  mState.prevState = nextToLastState;   // Link to previous state
-  return NS_OK;
-}
-
-void nsAccessibleTreeWalker::GetNextDOMNode()
-{
-  // Get next DOM node and its frame.
-  if (mState.parentContent) {
-    mState.domNode =
-      do_QueryInterface(mState.parentContent->GetChildAt(++mState.siblingIndex));
-
-  } else if (mState.siblingIndex == eSiblingsWalkFrames) {
-    if (mState.frame.IsAlive()) {
-      mState.frame = mState.frame.GetFrame()->GetNextSibling();
-
-      if (mState.frame.IsAlive()) {
-        mState.domNode = do_QueryInterface(mState.frame.GetFrame()->GetContent());
-        return;
-      }
-    }
-
-    mState.domNode = nsnull;
-    return;
-
-  } else {
-    mState.siblingList->Item(++mState.siblingIndex,
-                             getter_AddRefs(mState.domNode));
-  }
-
-  // Update the frame.
-  nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mWeakShell));
-  NS_ASSERTION(presShell, "Huh? No presshell?");
-  if (!presShell)
-    return;
-
-  nsCOMPtr<nsIContent> content = do_QueryInterface(mState.domNode);
-  if (content)
-    mState.frame = presShell->GetRealPrimaryFrameFor(content);
-  else
-    mState.frame = presShell->GetRootFrame();
+  return aNoWalkUp ? nsnull : GetNextChildInternal(PR_FALSE);
 }
 
-NS_IMETHODIMP nsAccessibleTreeWalker::GetNextSibling()
+void
+nsAccTreeWalker::PopState()
 {
-  // Make sure mState.prevState and mState.siblingIndex are initialized so we can walk forward
-  NS_ASSERTION(mState.prevState && mState.siblingIndex != eSiblingsUninitialized,
-               "Error - GetNextSibling() only works after a GetFirstChild(), so we must have a prevState.");
-  mState.accessible = nsnull;
-
-  while (PR_TRUE) {
-    // Get next frame
-    GetNextDOMNode();
-
-    if (!mState.domNode) {  // Done with current siblings
-      PopState();   // Use parent - go up in stack. Can always pop state because we have to start with a GetFirstChild().
-      if (!mState.prevState) {
-        mState.accessible = nsnull;
-        break; // Back to original accessible that we did GetFirstChild() from
-      }
-    }
-    else if ((mState.domNode != mState.prevState->domNode && GetAccessible()) || 
-             NS_SUCCEEDED(GetFirstChild())) {
-      return NS_OK; // if next is accessible, use it 
-    }
-  }
-  return NS_ERROR_FAILURE;
-}
-
-NS_IMETHODIMP nsAccessibleTreeWalker::GetFirstChild()
-{
-  mState.accessible = nsnull;
-  if (mState.isHidden || !mState.domNode) {
-    return NS_ERROR_FAILURE;
-  }
-
-  nsCOMPtr<nsIDOMNode> parent(mState.domNode);
-
-  PushState();
-  GetKids(parent); // Side effects change our state (mState)
-
-  // Recursive loop: depth first search for first accessible child
-  while (mState.domNode) {
-    if ((mState.domNode != parent && GetAccessible()) || NS_SUCCEEDED(GetFirstChild()))
-      return NS_OK;
-
-    GetNextDOMNode();
-  }
-
-  PopState();  // Return to previous state
-  return NS_ERROR_FAILURE;
+  WalkState* prevToLastState = mState->prevState;
+  delete mState;
+  mState = prevToLastState;
 }
 
-void 
-nsAccessibleTreeWalker::WalkFrames()
+PRBool
+nsAccTreeWalker::PushState(nsIContent* aContent)
 {
-  nsIFrame *curFrame = mState.frame.GetFrame();
-  if (!curFrame) {
-    return;
-  }
-
-  // If the frame implements nsIAnonymousContentCreator interface then go down
-  // through the frames and obtain anonymous nodes for them.
-  nsIAnonymousContentCreator* creator = do_QueryFrame(curFrame);
-  nsIFrame *child = curFrame->GetFirstChild(nsnull);
+  WalkState* nextToLastState = new WalkState(aContent);
+  if (!nextToLastState)
+    return PR_FALSE;
 
-  if (creator && child && mState.siblingIndex < 0) {
-    mState.frame = child;
-    mState.domNode = do_QueryInterface(child->GetContent());
-    mState.siblingIndex = eSiblingsWalkFrames;
-  }
-// temporary workaround for Bug 359210. We never want to walk frames.
-// Aaron Leventhal will refix :before and :after content later without walking frames.
-#if 0
-  if (mState.frame && mState.siblingIndex < 0) {
-    // Container frames can contain generated content frames from
-    // :before and :after style rules, so we walk their frame trees
-    // instead of content trees
-    // XXX Walking the frame tree doesn't get us Aural CSS nodes, e.g. 
-    // @media screen { display: none; }
-    // Asking the style system might be better (with ProbePseudoStyleFor(),
-    // except that we need to ask only for those display types that support 
-    // :before and :after (which roughly means non-replaced elements)
-    // Here's some code to see if there is an :after rule for an element
-    // nsRefPtr<nsStyleContext> pseudoContext;
-    // nsStyleContext *styleContext = primaryFrame->GetStyleContext();
-    // if (aContent) {
-    //   pseudoContext = presContext->StyleSet()->
-    //     ProbePseudoStyleFor(content, nsAccessibilityAtoms::after, aStyleContext);
-    mState.domNode = do_QueryInterface(mState.frame->GetContent());
-    mState.siblingIndex = eSiblingsWalkFrames;
-  }
-#endif
+  nextToLastState->prevState = mState;
+  mState = nextToLastState;
+
+  return PR_TRUE;
 }
-
-/**
- * If the DOM node's frame has an accessible or the DOMNode
- * itself implements nsIAccessible return it.
- */
-PRBool nsAccessibleTreeWalker::GetAccessible()
-{
-  mState.accessible = nsnull;
-  nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mWeakShell));
-
-  GetAccService()->GetAccessible(mState.domNode, presShell, mWeakShell,
-                                 mState.frame.GetFrame(), &mState.isHidden,
-                                 getter_AddRefs(mState.accessible));
-
-  return mState.accessible ? PR_TRUE : PR_FALSE;
-}
-
rename from accessible/src/base/nsAccessibleTreeWalker.h
rename to accessible/src/base/nsAccTreeWalker.h
--- a/accessible/src/base/nsAccessibleTreeWalker.h
+++ b/accessible/src/base/nsAccTreeWalker.h
@@ -15,123 +15,84 @@
  * 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) 2003
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
- *   Original Author: Aaron Leventhal (aaronl@netscape.com)
+ *  Aaron Leventhal <aaronleventhal@moonset.net> (original author)
+ *  Alexander Surkov <surkov.alexander@gmail.com>
  *
  * 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 ***** */
 
-#ifndef _nsAccessibleTreeWalker_H_
-#define _nsAccessibleTreeWalker_H_
-
-/* For documentation of the accessibility architecture, see
- * http://www.mozilla.org/access/architecture
- */
+#ifndef _nsAccTreeWalker_H_
+#define _nsAccTreeWalker_H_
 
-#include "nsCOMPtr.h"
-#include "nsIDocument.h"
-#include "nsIAccessible.h"
-#include "nsIDOMNode.h"
-#include "nsIDOMNodeList.h"
+#include "nsAutoPtr.h"
+#include "nsIContent.h"
 #include "nsIWeakReference.h"
-#include "nsIFrame.h"
 
-enum { eSiblingsUninitialized = -1, eSiblingsWalkFrames = -2 };
+class nsAccessible;
+struct WalkState;
 
-struct WalkState {
-  nsCOMPtr<nsIAccessible> accessible;
-  nsCOMPtr<nsIDOMNode> domNode;
-  nsCOMPtr<nsIDOMNodeList> siblingList;
-  nsIContent *parentContent; // For walking normal DOM
-  WalkState *prevState;
-  // XXXbz is |frame| still needed?
-  nsWeakFrame frame;       // Helps avoid GetPrimaryFrameFor() calls
-  PRInt32 siblingIndex;    // Holds a state flag or an index into the siblingList
-  PRBool isHidden;         // Don't enter subtree if hidden
-};
- 
-/** This class is used to walk the DOM tree. It skips
-  * everything but nodes that either implement nsIAccessibleProvider
-  * or have primary frames that implement "GetAccessible"
-  */
-
-class nsAccessibleTreeWalker {
+/**
+ * This class is used to walk the DOM tree to create accessible tree.
+ */
+class nsAccTreeWalker
+{
 public:
-  nsAccessibleTreeWalker(nsIWeakReference* aShell, nsIDOMNode* aContent, 
-    PRBool mWalkAnonymousContent);
-  virtual ~nsAccessibleTreeWalker();
-
-  /**
-   * Moves current state to point to the next child accessible.
-   */
-  NS_IMETHOD GetNextSibling();
+  nsAccTreeWalker(nsIWeakReference *aShell, nsIContent *aNode, 
+                  PRBool aWalkAnonymousContent);
+  virtual ~nsAccTreeWalker();
 
   /**
-   * Moves current state to point to the first child accessible.
+   * Return the next child accessible.
    */
-  NS_IMETHOD GetFirstChild();
-
-  /**
-   * Current state. Used to initialize a11y tree walker and to get an accessible
-   * current state points to.
-   */
-  WalkState mState;
+  already_AddRefed<nsAccessible> GetNextChild()
+  {
+    return GetNextChildInternal(PR_FALSE);
+  }
 
-protected:
-
-  /**
-   * Return true if currently navigated node/frame is accessible.
-   */
-  PRBool GetAccessible();
-
-  /**
-   * Prepares current state to navigate through children of node/frame.
-   */
-  void GetKids(nsIDOMNode *aParent);
+private:
 
   /**
-   * Clears the current state.
+   * Return the next child accessible.
+   *
+   * @param  aNoWalkUp  [in] specifies the walk direction, true means we
+   *                     shouldn't go up through the tree if we failed find
+   *                     accessible children.
    */
-  void ClearState();
-
-  /**
-   * Push current state on top of stack. State stack is used to navigate down to
-   * DOM/frame subtree during searching of accessible children.
-   */
-  NS_IMETHOD PushState();
+  already_AddRefed<nsAccessible>
+    GetNextChildInternal(PRBool aNoWalkUp = PR_FALSE);
 
   /**
-   * Pop state from stack and make it current.
+   * Create new state for the given node and push it on top of stack.
+   *
+   * @note State stack is used to navigate up/down the DOM subtree during
+   *        accessible children search.
    */
-  NS_IMETHOD PopState();
+  PRBool PushState(nsIContent *aNode);
 
   /**
-   * Make treewalker traverse by frame tree if necessary.
+   * Pop state from stack.
    */
-  void WalkFrames();
-
-  /**
-   * Change current state so that its node is changed to next node.
-   */
-  void GetNextDOMNode();
+  void PopState();
 
   nsCOMPtr<nsIWeakReference> mWeakShell;
-  PRBool mWalkAnonContent;
+  PRInt32 mChildType;
+  WalkState* mState;
 };
 
 #endif 
--- a/accessible/src/base/nsAccUtils.cpp
+++ b/accessible/src/base/nsAccUtils.cpp
@@ -42,17 +42,17 @@
 #include "nsIAccessibleStates.h"
 #include "nsIAccessibleTypes.h"
 
 #include "nsAccEvent.h"
 #include "nsHyperTextAccessible.h"
 #include "nsHTMLTableAccessible.h"
 #include "nsDocAccessible.h"
 #include "nsAccessibilityAtoms.h"
-#include "nsAccessibleTreeWalker.h"
+#include "nsAccTreeWalker.h"
 #include "nsAccessible.h"
 #include "nsARIAMap.h"
 #include "nsXULTreeGridAccessible.h"
 
 #include "nsIDOMXULContainerElement.h"
 #include "nsIDOMXULSelectCntrlEl.h"
 #include "nsIDOMXULSelectCntrlItemEl.h"
 #include "nsWhitespaceTokenizer.h"
@@ -357,24 +357,21 @@ nsAccUtils::HasAccessibleChildren(nsIDOM
 
   nsCOMPtr<nsIPresShell> presShell = nsCoreUtils::GetPresShellFor(aNode);
   if (!presShell)
     return PR_FALSE;
 
   nsIFrame *frame = content->GetPrimaryFrame();
   if (!frame)
     return PR_FALSE;
-  
+
   nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(presShell));
-  nsAccessibleTreeWalker walker(weakShell, aNode, PR_FALSE);
-
-  walker.mState.frame = frame;
-
-  walker.GetFirstChild();
-  return walker.mState.accessible ? PR_TRUE : PR_FALSE;
+  nsAccTreeWalker walker(weakShell, content, PR_FALSE);
+  nsRefPtr<nsAccessible> accessible = walker.GetNextChild();
+  return accessible ? PR_TRUE : PR_FALSE;
 }
 
 already_AddRefed<nsIAccessible>
 nsAccUtils::GetAncestorWithRole(nsIAccessible *aDescendant, PRUint32 aRole)
 {
   nsCOMPtr<nsIAccessible> parentAccessible = aDescendant, testRoleAccessible;
   while (NS_SUCCEEDED(parentAccessible->GetParent(getter_AddRefs(testRoleAccessible))) &&
          testRoleAccessible) {
--- a/accessible/src/base/nsAccessNode.cpp
+++ b/accessible/src/base/nsAccessNode.cpp
@@ -97,45 +97,45 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAccessNode)
 NS_INTERFACE_MAP_END
  
 NS_IMPL_CYCLE_COLLECTING_ADDREF_AMBIGUOUS(nsAccessNode, nsIAccessNode)
 NS_IMPL_CYCLE_COLLECTING_RELEASE_FULL(nsAccessNode, nsIAccessNode,
                                       LastRelease())
 
 ////////////////////////////////////////////////////////////////////////////////
-// nsAccessible. Constructor
+// nsAccessNode construction/desctruction
 
 nsAccessNode::nsAccessNode(nsIDOMNode *aNode, nsIWeakReference* aShell): 
   mDOMNode(aNode), mWeakShell(aShell)
 {
 #ifdef DEBUG_A11Y
   mIsInitialized = PR_FALSE;
 #endif
 }
 
-//-----------------------------------------------------
-// destruction
-//-----------------------------------------------------
 nsAccessNode::~nsAccessNode()
 {
   NS_ASSERTION(!mWeakShell, "LastRelease was never called!?!");
 }
 
 void nsAccessNode::LastRelease()
 {
   // First cleanup if needed...
   if (mWeakShell) {
     Shutdown();
     NS_ASSERTION(!mWeakShell, "A Shutdown() impl forgot to call its parent's Shutdown?");
   }
   // ... then die.
   NS_DELETEXPCOM(this);
 }
 
+////////////////////////////////////////////////////////////////////////////////
+// nsAccessNode public
+
 nsresult
 nsAccessNode::Init()
 {
   // We have to put this here, instead of constructor, otherwise
   // we don't have the virtual GetUniqueID() method for the hash key.
   // We need that for accessibles that don't have DOM nodes
 
 #ifdef DEBUG_A11Y
@@ -163,17 +163,19 @@ nsAccessNode::Init()
     }
   }
 
   void* uniqueID;
   GetUniqueID(&uniqueID);
   nsRefPtr<nsDocAccessible> docAcc =
     nsAccUtils::QueryAccessibleDocument(docAccessible);
   NS_ASSERTION(docAcc, "No nsDocAccessible for document accessible!");
-  docAcc->CacheAccessNode(uniqueID, this);
+
+  if (!docAcc->CacheAccessNode(uniqueID, this))
+    return NS_ERROR_OUT_OF_MEMORY;
 
   // Make sure an ancestor in real content is cached
   // so that nsDocAccessible::RefreshNodes() can find the anonymous subtree to release when
   // the root node goes away
   nsCOMPtr<nsIContent> content = do_QueryInterface(mDOMNode);
   if (content && content->IsInAnonymousSubtree()) {
     // Specific examples of where this is used: <input type="file"> and <xul:findbar>
     nsCOMPtr<nsIAccessible> parentAccessible;
@@ -196,22 +198,24 @@ nsresult
 nsAccessNode::Shutdown()
 {
   mDOMNode = nsnull;
   mWeakShell = nsnull;
 
   return NS_OK;
 }
 
+// nsIAccessNode
 NS_IMETHODIMP nsAccessNode::GetUniqueID(void **aUniqueID)
 {
   *aUniqueID = static_cast<void*>(mDOMNode);
   return NS_OK;
 }
 
+// nsIAccessNode
 NS_IMETHODIMP nsAccessNode::GetOwnerWindow(void **aWindow)
 {
   *aWindow = nsnull;
   nsCOMPtr<nsIAccessibleDocument> docAccessible(GetDocAccessible());
   if (!docAccessible)
     return NS_ERROR_FAILURE; // This node or doc accessible is shut down
   return docAccessible->GetWindowHandle(aWindow);
 }
@@ -264,16 +268,17 @@ void nsAccessNode::InitXPAccessibility()
   if (prefBranch) {
     prefBranch->GetBoolPref("accessibility.disablecache", &gIsCacheDisabled);
     prefBranch->GetBoolPref("browser.formfill.enable", &gIsFormFillEnabled);
   }
 
   NotifyA11yInitOrShutdown(PR_TRUE);
 }
 
+// nsAccessNode protected static
 void nsAccessNode::NotifyA11yInitOrShutdown(PRBool aIsInit)
 {
   nsCOMPtr<nsIObserverService> obsService =
     do_GetService("@mozilla.org/observer-service;1");
   NS_ASSERTION(obsService, "No observer service to notify of a11y init/shutdown");
   if (obsService) {
     static const PRUnichar kInitIndicator[] = { '1', 0 };
     static const PRUnichar kShutdownIndicator[] = { '0', 0 }; 
@@ -326,25 +331,27 @@ already_AddRefed<nsIPresShell> nsAccessN
       // and should be shut down
       Shutdown();
     }
     return nsnull;
   }
   return presShell;
 }
 
+// nsAccessNode protected
 nsPresContext* nsAccessNode::GetPresContext()
 {
   nsCOMPtr<nsIPresShell> presShell(GetPresShell());
   if (!presShell) {
     return nsnull;
   }
   return presShell->GetPresContext();
 }
 
+// nsAccessNode protected
 already_AddRefed<nsIAccessibleDocument> nsAccessNode::GetDocAccessible()
 {
   return GetDocAccessibleFor(mWeakShell); // Addref'd
 }
 
 already_AddRefed<nsRootAccessible> nsAccessNode::GetRootAccessible()
 {
   nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem =
@@ -374,16 +381,38 @@ already_AddRefed<nsRootAccessible> nsAcc
 
 nsIFrame*
 nsAccessNode::GetFrame()
 {
   nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
   return content ? content->GetPrimaryFrame() : nsnull;
 }
 
+#ifdef DEBUG
+PRBool
+nsAccessNode::IsInCache()
+{
+  nsCOMPtr<nsIAccessibleDocument> accessibleDoc =
+    nsAccessNode::GetDocAccessibleFor(mWeakShell);
+
+  if (!accessibleDoc)
+    return nsnull;
+
+  void* uniqueID = nsnull;
+  GetUniqueID(&uniqueID);
+
+  nsRefPtr<nsDocAccessible> docAccessible =
+    nsAccUtils::QueryObject<nsDocAccessible>(accessibleDoc);
+  return docAccessible->GetCachedAccessNode(uniqueID) ? PR_TRUE : PR_FALSE;
+}
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+// nsIAccessNode
+
 NS_IMETHODIMP
 nsAccessNode::GetDOMNode(nsIDOMNode **aNode)
 {
   NS_IF_ADDREF(*aNode = mDOMNode);
   return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -454,24 +483,24 @@ nsAccessNode::ScrollToPoint(PRUint32 aCo
 
   nsIFrame *parentFrame = frame;
   while ((parentFrame = parentFrame->GetParent()))
     nsCoreUtils::ScrollFrameToPoint(parentFrame, frame, coords);
 
   return NS_OK;
 }
 
+// nsAccessNode protected
 nsresult
 nsAccessNode::MakeAccessNode(nsIDOMNode *aNode, nsIAccessNode **aAccessNode)
 {
   *aAccessNode = nsnull;
   
-  nsCOMPtr<nsIAccessNode> accessNode;
-  GetAccService()->GetCachedAccessNode(aNode, mWeakShell,
-                                       getter_AddRefs(accessNode));
+  nsCOMPtr<nsIAccessNode> accessNode =
+    GetAccService()->GetCachedAccessNode(aNode, mWeakShell);
 
   if (!accessNode) {
     nsCOMPtr<nsIAccessible> accessible;
     GetAccService()->GetAccessibleInWeakShell(aNode, mWeakShell,
                                               getter_AddRefs(accessible));
 
     accessNode = do_QueryInterface(accessible);
   }
@@ -606,33 +635,29 @@ nsAccessNode::GetComputedStyleCSSValue(c
 
   nsCOMPtr<nsIDOMCSSValue> cssValue;
   styleDecl->GetPropertyCSSValue(aPropertyName, getter_AddRefs(cssValue));
   NS_ENSURE_TRUE(cssValue, NS_ERROR_FAILURE);
 
   return CallQueryInterface(cssValue, aCSSValue);
 }
 
-/***************** Hashtable of nsIAccessNode's *****************/
+////////////////////////////////////////////////////////////////////////////////
+// nsAccessNode public static
 
 already_AddRefed<nsIAccessibleDocument>
 nsAccessNode::GetDocAccessibleFor(nsIDocument *aDocument)
 {
   if (!aDocument) {
     return nsnull;
   }
 
-  nsIAccessibleDocument *docAccessible = nsnull;
-  nsCOMPtr<nsIAccessNode> accessNode;
-  gGlobalDocAccessibleCache.Get(static_cast<void*>(aDocument),
-                                getter_AddRefs(accessNode));
-  if (accessNode) {
-    CallQueryInterface(accessNode, &docAccessible);
-  }
-  return docAccessible;
+  nsCOMPtr<nsIAccessibleDocument> docAccessible(do_QueryInterface(
+    gGlobalDocAccessibleCache.GetWeak(static_cast<void*>(aDocument))));
+  return docAccessible.forget();
 }
  
 already_AddRefed<nsIAccessibleDocument>
 nsAccessNode::GetDocAccessibleFor(nsIWeakReference *aWeakShell)
 {
   nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(aWeakShell));
   if (!presShell) {
     return nsnull;
@@ -678,45 +703,24 @@ nsAccessNode::GetDocAccessibleFor(nsIDOM
   nsCOMPtr<nsIDocument> doc(do_QueryInterface(aNode));
   if (doc) {
     return GetDocAccessibleFor(doc);
   }
 
   return nsnull;
 }
 
-void
-nsAccessNode::PutCacheEntry(nsAccessNodeHashtable& aCache,
-                            void* aUniqueID,
-                            nsIAccessNode *aAccessNode)
-{
-#ifdef DEBUG_A11Y
-  nsCOMPtr<nsIAccessNode> oldAccessNode;
-  GetCacheEntry(aCache, aUniqueID, getter_AddRefs(oldAccessNode));
-  NS_ASSERTION(!oldAccessNode, "This cache entry shouldn't exist already");
-#endif
-  aCache.Put(aUniqueID, aAccessNode);
-}
-
-void
-nsAccessNode::GetCacheEntry(nsAccessNodeHashtable& aCache,
-                            void* aUniqueID,
-                            nsIAccessNode **aAccessNode)
-{
-  aCache.Get(aUniqueID, aAccessNode);  // AddRefs for us
-}
-
-PLDHashOperator nsAccessNode::ClearCacheEntry(const void* aKey, nsCOMPtr<nsIAccessNode>& aAccessNode, void* aUserArg)
+// Callback used when clearing the cache, see nsAccessNode::ClearCache() method.
+static PLDHashOperator
+ClearCacheEntry(const void* aKey, nsCOMPtr<nsAccessNode>& aAccessNode,
+                void* aUserArg)
 {
   NS_ASSERTION(aAccessNode, "Calling ClearCacheEntry with a NULL pointer!");
-  if (aAccessNode) {
-    nsRefPtr<nsAccessNode> accessNode =
-      nsAccUtils::QueryAccessNode(aAccessNode);
-    accessNode->Shutdown();
-  }
+  if (aAccessNode)
+    aAccessNode->Shutdown();
 
   return PL_DHASH_REMOVE;
 }
 
 void
 nsAccessNode::ClearCache(nsAccessNodeHashtable& aCache)
 {
   aCache.Enumerate(ClearCacheEntry, nsnull);
@@ -747,16 +751,17 @@ already_AddRefed<nsIDOMNode> nsAccessNod
     focusedWindow->GetDocument(getter_AddRefs(doc));
     if (doc)
       CallQueryInterface(doc, &focusedNode);
   }
 
   return focusedNode;
 }
 
+// nsIAccessNode
 NS_IMETHODIMP
 nsAccessNode::GetLanguage(nsAString& aLanguage)
 {
   aLanguage.Truncate();
   nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
   if (!content) {
     // For documents make sure we look for lang attribute on
     // document element
@@ -786,9 +791,8 @@ nsAccessNode::GetLanguage(nsAString& aLa
     nsIDocument *doc = content->GetOwnerDoc();
     if (doc) {
       doc->GetHeaderData(nsAccessibilityAtoms::headerContentLanguage, aLanguage);
     }
   }
  
   return NS_OK;
 }
-
--- a/accessible/src/base/nsAccessNode.h
+++ b/accessible/src/base/nsAccessNode.h
@@ -65,17 +65,17 @@ class nsIFrame;
 class nsIDOMNodeList;
 class nsRootAccessible;
 class nsApplicationAccessibleWrap;
 class nsIDocShellTreeItem;
 
 #define ACCESSIBLE_BUNDLE_URL "chrome://global-platform/locale/accessible.properties"
 #define PLATFORM_KEYS_BUNDLE_URL "chrome://global-platform/locale/platformKeys.properties"
 
-typedef nsInterfaceHashtable<nsVoidPtrHashKey, nsIAccessNode>
+typedef nsInterfaceHashtable<nsVoidPtrHashKey, nsAccessNode>
         nsAccessNodeHashtable;
 
 // What we want is: NS_INTERFACE_MAP_ENTRY(self) for static IID accessors,
 // but some of our classes have an ambiguous base class of nsISupports which
 // prevents this from working (the default macro converts it to nsISupports,
 // then addrefs it, then returns it). Therefore, we expand the macro here and
 // change it so that it works. Yuck.
 #define NS_INTERFACE_MAP_STATIC_AMBIGUOUS(_class) \
@@ -122,24 +122,20 @@ class nsAccessNode: public nsIAccessNode
     static void InitXPAccessibility();
     static void ShutdownXPAccessibility();
 
     /**
      * Return an application accessible.
      */
     static already_AddRefed<nsApplicationAccessibleWrap> GetApplicationAccessible();
 
-    // Static methods for handling per-document cache
-    static void PutCacheEntry(nsAccessNodeHashtable& aCache,
-                              void* aUniqueID, nsIAccessNode *aAccessNode);
-    static void GetCacheEntry(nsAccessNodeHashtable& aCache,
-                              void* aUniqueID, nsIAccessNode **aAccessNode);
-    static void ClearCache(nsAccessNodeHashtable& aCache);
-
-    static PLDHashOperator ClearCacheEntry(const void* aKey, nsCOMPtr<nsIAccessNode>& aAccessNode, void* aUserArg);
+  /**
+   * Clear the cache and shutdown the access nodes.
+   */
+  static void ClearCache(nsAccessNodeHashtable& aCache);
 
     // Static cache methods for global document cache
     static already_AddRefed<nsIAccessibleDocument> GetDocAccessibleFor(nsIDocument *aDocument);
     static already_AddRefed<nsIAccessibleDocument> GetDocAccessibleFor(nsIWeakReference *aWeakShell);
     static already_AddRefed<nsIAccessibleDocument> GetDocAccessibleFor(nsIDocShellTreeItem *aContainer, PRBool aCanCreate = PR_FALSE);
     static already_AddRefed<nsIAccessibleDocument> GetDocAccessibleFor(nsIDOMNode *aNode);
 
     already_AddRefed<nsRootAccessible> GetRootAccessible();
@@ -174,16 +170,23 @@ class nsAccessNode: public nsIAccessNode
   already_AddRefed<nsIPresShell> GetPresShell();
 
   /**
    * Return true if the accessible still has presentation shell. Light-weight
    * version of IsDefunct() method.
    */
   PRBool HasWeakShell() const { return !!mWeakShell; }
 
+#ifdef DEBUG
+  /**
+   * Return true if the access node is cached.
+   */
+  PRBool IsInCache();
+#endif
+
 protected:
     nsresult MakeAccessNode(nsIDOMNode *aNode, nsIAccessNode **aAccessNode);
 
     nsPresContext* GetPresContext();
     already_AddRefed<nsIAccessibleDocument> GetDocAccessible();
     void LastRelease();
 
     nsCOMPtr<nsIDOMNode> mDOMNode;
--- a/accessible/src/base/nsAccessibilityService.cpp
+++ b/accessible/src/base/nsAccessibilityService.cpp
@@ -103,23 +103,23 @@
 #include "nsHTMLWin32ObjectAccessible.h"
 #endif
 
 #ifndef DISABLE_XFORMS_HOOKS
 #include "nsXFormsFormControlsAccessible.h"
 #include "nsXFormsWidgetsAccessible.h"
 #endif
 
+////////////////////////////////////////////////////////////////////////////////
+// nsAccessibilityService
+////////////////////////////////////////////////////////////////////////////////
+
 nsAccessibilityService *nsAccessibilityService::gAccessibilityService = nsnull;
 PRBool nsAccessibilityService::gIsShutdown = PR_TRUE;
 
-/**
-  * nsAccessibilityService
-  */
-
 nsAccessibilityService::nsAccessibilityService()
 {
   // Add observers.
   nsCOMPtr<nsIObserverService> observerService = 
     do_GetService("@mozilla.org/observer-service;1");
   if (!observerService)
     return;
 
@@ -138,16 +138,18 @@ nsAccessibilityService::~nsAccessibility
 {
   NS_ASSERTION(gIsShutdown, "Accessibility wasn't shutdown!");
   gAccessibilityService = nsnull;
 }
 
 NS_IMPL_THREADSAFE_ISUPPORTS5(nsAccessibilityService, nsIAccessibilityService, nsIAccessibleRetrieval,
                               nsIObserver, nsIWebProgressListener, nsISupportsWeakReference)
 
+
+////////////////////////////////////////////////////////////////////////////////
 // nsIObserver
 
 NS_IMETHODIMP
 nsAccessibilityService::Observe(nsISupports *aSubject, const char *aTopic,
                          const PRUnichar *aData)
 {
   if (!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
 
@@ -170,17 +172,19 @@ nsAccessibilityService::Observe(nsISuppo
 
     gIsShutdown = PR_TRUE;
     nsAccessNodeWrap::ShutdownAccessibility();
   }
 
   return NS_OK;
 }
 
+////////////////////////////////////////////////////////////////////////////////
 // nsIWebProgressListener
+
 NS_IMETHODIMP nsAccessibilityService::OnStateChange(nsIWebProgress *aWebProgress,
   nsIRequest *aRequest, PRUint32 aStateFlags, nsresult aStatus)
 {
   NS_ASSERTION(aStateFlags & STATE_IS_DOCUMENT, "Other notifications excluded");
 
   if (gIsShutdown || !aWebProgress ||
       (aStateFlags & (STATE_START | STATE_STOP)) == 0) {
     return NS_OK;
@@ -203,16 +207,17 @@ NS_IMETHODIMP nsAccessibilityService::On
   } else { // Failed end load
     NS_DISPATCH_RUNNABLEMETHOD_ARG2(ProcessDocLoadEvent, this, aWebProgress,
                                     nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_STOPPED)
   }
 
   return NS_OK;
 }
 
+// nsAccessibilityService private
 void
 nsAccessibilityService::ProcessDocLoadEvent(nsIWebProgress *aWebProgress,
                                             PRUint32 aEventType)
 {
   if (gIsShutdown)
     return;
 
   nsCOMPtr<nsIDOMWindow> domWindow;
@@ -242,16 +247,17 @@ nsAccessibilityService::ProcessDocLoadEv
   GetAccessibleFor(docNode, getter_AddRefs(accessible));
   nsRefPtr<nsDocAccessible> docAcc =
     nsAccUtils::QueryAccessibleDocument(accessible);
   NS_ENSURE_TRUE(docAcc,);
 
   docAcc->FireDocLoadEvents(aEventType);
 }
 
+// nsIAccessibilityService
 NS_IMETHODIMP
 nsAccessibilityService::NotifyOfAnchorJumpTo(nsIContent *aTarget)
 {
   nsCOMPtr<nsIDOMNode> targetNode(do_QueryInterface(aTarget));
 
   nsCOMPtr<nsIAccessible> targetAcc;
   GetAccessibleFor(targetNode, getter_AddRefs(targetAcc));
 
@@ -271,16 +277,17 @@ nsAccessibilityService::NotifyOfAnchorJu
 
   if (targetAcc)
     nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_SCROLLING_START,
                             targetAcc);
 
   return NS_OK;
 }
 
+// nsIAccessibilityService
 NS_IMETHODIMP
 nsAccessibilityService::FireAccessibleEvent(PRUint32 aEvent,
                                             nsIAccessible *aTarget)
 {
   nsEventShell::FireEvent(aEvent, aTarget);
   return NS_OK;
 }
 
@@ -313,16 +320,17 @@ NS_IMETHODIMP nsAccessibilityService::On
 NS_IMETHODIMP nsAccessibilityService::OnSecurityChange(nsIWebProgress *aWebProgress,
   nsIRequest *aRequest, PRUint32 state)
 {
   NS_NOTREACHED("notification excluded in AddProgressListener(...)");
   return NS_OK;
 }
 
 
+// nsAccessibilityService private
 nsresult
 nsAccessibilityService::GetInfo(nsIFrame* aFrame, nsIWeakReference** aShell, nsIDOMNode** aNode)
 {
   NS_ASSERTION(aFrame,"Error -- 1st argument (aFrame) is null!!");
   if (!aFrame) {
     return NS_ERROR_FAILURE;
   }
   nsCOMPtr<nsIContent> content = aFrame->GetContent();
@@ -342,16 +350,17 @@ nsAccessibilityService::GetInfo(nsIFrame
   // do_GetWR only works into a |nsCOMPtr| :-(
   nsCOMPtr<nsIWeakReference> weakShell =
     do_GetWeakReference(document->GetPrimaryShell());
   NS_IF_ADDREF(*aShell = weakShell);
 
   return NS_OK;
 }
 
+// nsAccessibilityService public
 nsresult
 nsAccessibilityService::GetShellFromNode(nsIDOMNode *aNode, nsIWeakReference **aWeakShell)
 {
   nsCOMPtr<nsIDOMDocument> domDoc;
   aNode->GetOwnerDocument(getter_AddRefs(domDoc));
   nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
   if (!doc)
     return NS_ERROR_INVALID_ARG;
@@ -364,19 +373,18 @@ nsAccessibilityService::GetShellFromNode
   nsCOMPtr<nsIWeakReference> weakRef(do_GetWeakReference(shell));
   
   *aWeakShell = weakRef;
   NS_IF_ADDREF(*aWeakShell);
 
   return NS_OK;
 }
 
-/**
-  * nsIAccessibilityService methods:
-  */
+////////////////////////////////////////////////////////////////////////////////
+// nsIAccessibilityService
 
 NS_IMETHODIMP 
 nsAccessibilityService::CreateOuterDocAccessible(nsIDOMNode* aDOMNode, 
                                                  nsIAccessible **aOuterDocAccessible)
 {
   NS_ENSURE_ARG_POINTER(aDOMNode);
   
   *aOuterDocAccessible = nsnull;
@@ -389,79 +397,72 @@ nsAccessibilityService::CreateOuterDocAc
     new nsOuterDocAccessible(aDOMNode, outerWeakShell);
   NS_ENSURE_TRUE(outerDocAccessible, NS_ERROR_FAILURE);
 
   NS_ADDREF(*aOuterDocAccessible = outerDocAccessible);
 
   return NS_OK;
 }
 
-NS_IMETHODIMP 
-nsAccessibilityService::CreateRootAccessible(nsIPresShell *aShell, 
-                                             nsIDocument* aDocument, 
-                                             nsIAccessible **aRootAcc)
+// nsAccessibilityService private
+already_AddRefed<nsAccessible>
+nsAccessibilityService::CreateDocOrRootAccessible(nsIPresShell *aShell,
+                                                  nsIDocument* aDocument)
 {
-  *aRootAcc = nsnull;
-
   nsCOMPtr<nsIDOMNode> rootNode(do_QueryInterface(aDocument));
-  NS_ENSURE_TRUE(rootNode, NS_ERROR_FAILURE);
+  NS_ENSURE_TRUE(rootNode, nsnull);
 
   nsIPresShell *presShell = aShell;
   if (!presShell) {
     presShell = aDocument->GetPrimaryShell();
   }
   nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(presShell));
 
   nsCOMPtr<nsISupports> container = aDocument->GetContainer();
   nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(container);
-  NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
+  NS_ENSURE_TRUE(docShell, nsnull);
+
   nsCOMPtr<nsIContentViewer> contentViewer;
   docShell->GetContentViewer(getter_AddRefs(contentViewer));
-  NS_ENSURE_TRUE(contentViewer, NS_ERROR_FAILURE); // Doc was already shut down
+  NS_ENSURE_TRUE(contentViewer, nsnull); // Doc was already shut down
+
   PRUint32 busyFlags;
   docShell->GetBusyFlags(&busyFlags);
   if (busyFlags != nsIDocShell::BUSY_FLAGS_NONE) {
     nsCOMPtr<nsIWebNavigation> webNav(do_GetInterface(docShell));
     nsCOMPtr<nsIURI> uri;
     webNav->GetCurrentURI(getter_AddRefs(uri));
-    NS_ENSURE_STATE(uri);
+    NS_ENSURE_TRUE(uri, nsnull);
+
     nsCAutoString url;
     uri->GetSpec(url);
     if (url.EqualsLiteral("about:blank")) {
-      return NS_OK;  // No load events for a busy about:blank -- they are often temporary
+      // No load events for a busy about:blank -- they are often temporary.
+      return nsnull;
     }
   }
 
   nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem =
     do_QueryInterface(container);
-  NS_ENSURE_TRUE(docShellTreeItem, NS_ERROR_FAILURE);
+  NS_ENSURE_TRUE(docShellTreeItem, nsnull);
   
   nsCOMPtr<nsIDocShellTreeItem> parentTreeItem;
   docShellTreeItem->GetParent(getter_AddRefs(parentTreeItem));
 
+  nsRefPtr<nsAccessible> accessible;
   if (parentTreeItem) {
     // We only create root accessibles for the true root, othewise create a
     // doc accessible
-    *aRootAcc = new nsDocAccessibleWrap(rootNode, weakShell);
+    accessible = new nsDocAccessibleWrap(rootNode, weakShell);
   }
   else {
-    *aRootAcc = new nsRootAccessibleWrap(rootNode, weakShell);
+    accessible = new nsRootAccessibleWrap(rootNode, weakShell);
   }
-  if (!*aRootAcc)
-    return NS_ERROR_OUT_OF_MEMORY;
 
-  nsRefPtr<nsAccessible> rootAcc = nsAccUtils::QueryAccessible(*aRootAcc);
-  rootAcc->Init();
-
-  nsRoleMapEntry *roleMapEntry = nsAccUtils::GetRoleMapEntry(rootNode);
-  rootAcc->SetRoleMapEntry(roleMapEntry);
-
-  NS_ADDREF(*aRootAcc);
-
-  return NS_OK;
+  return accessible.forget();
 }
 
  /**
    * HTML widget creation
    */
 NS_IMETHODIMP
 nsAccessibilityService::CreateHTML4ButtonAccessible(nsIFrame *aFrame, nsIAccessible **_retval)
 {
@@ -491,83 +492,85 @@ nsAccessibilityService::CreateHTMLButton
   *_retval = new nsHTMLButtonAccessible(node, weakShell);
   if (! *_retval) 
     return NS_ERROR_OUT_OF_MEMORY;
 
   NS_ADDREF(*_retval);
   return NS_OK;
 }
 
-nsresult
+// nsAccessibilityService private
+already_AddRefed<nsAccessible>
 nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsIFrame *aFrame,
                                                      nsIWeakReference *aWeakShell,
-                                                     nsIDOMNode *aNode,
-                                                     nsIAccessible **aAccessible)
+                                                     nsIDOMNode *aNode)
 {
   // This method assumes we're in an HTML namespace.
-  *aAccessible = nsnull;
+  nsRefPtr<nsAccessible> accessible;
+
   nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
   nsIAtom *tag = content->Tag();
   if (tag == nsAccessibilityAtoms::legend) {
-    *aAccessible = new nsHTMLLegendAccessible(aNode, aWeakShell);
+    accessible = new nsHTMLLegendAccessible(aNode, aWeakShell);
   }
   else if (tag == nsAccessibilityAtoms::option) {
-    *aAccessible = new nsHTMLSelectOptionAccessible(aNode, aWeakShell);
+    accessible = new nsHTMLSelectOptionAccessible(aNode, aWeakShell);
   }
   else if (tag == nsAccessibilityAtoms::optgroup) {
-    *aAccessible = new nsHTMLSelectOptGroupAccessible(aNode, aWeakShell);
+    accessible = new nsHTMLSelectOptGroupAccessible(aNode, aWeakShell);
   }
   else if (tag == nsAccessibilityAtoms::ul || tag == nsAccessibilityAtoms::ol ||
            tag == nsAccessibilityAtoms::dl) {
-    *aAccessible = new nsHTMLListAccessible(aNode, aWeakShell);
+    accessible = new nsHTMLListAccessible(aNode, aWeakShell);
   }
   else if (tag == nsAccessibilityAtoms::a) {
 
     // Only some roles truly enjoy life as nsHTMLLinkAccessibles, for details
     // see closed bug 494807.
     nsRoleMapEntry *roleMapEntry = nsAccUtils::GetRoleMapEntry(aNode);
     if (roleMapEntry && roleMapEntry->role != nsIAccessibleRole::ROLE_NOTHING
         && roleMapEntry->role != nsIAccessibleRole::ROLE_LINK) {
-      return CreateHyperTextAccessible(aFrame, aAccessible);
+
+      accessible = new nsHyperTextAccessibleWrap(aNode, aWeakShell);
+    } else {
+      accessible = new nsHTMLLinkAccessible(aNode, aWeakShell);
     }
-
-    *aAccessible = new nsHTMLLinkAccessible(aNode, aWeakShell);
   }
   else if (tag == nsAccessibilityAtoms::dt ||
            (tag == nsAccessibilityAtoms::li && 
             aFrame->GetType() != nsAccessibilityAtoms::blockFrame)) {
     // Normally for li, it is created by the list item frame (in nsBlockFrame)
     // which knows about the bullet frame; however, in this case the list item
     // must have been styled using display: foo
-    *aAccessible = new nsHTMLLIAccessible(aNode, aWeakShell, EmptyString());
+    accessible = new nsHTMLLIAccessible(aNode, aWeakShell, EmptyString());
   }
   else if (tag == nsAccessibilityAtoms::abbr ||
            tag == nsAccessibilityAtoms::acronym ||
            tag == nsAccessibilityAtoms::blockquote ||
            tag == nsAccessibilityAtoms::dd ||
            tag == nsAccessibilityAtoms::form ||
            tag == nsAccessibilityAtoms::h1 ||
            tag == nsAccessibilityAtoms::h2 ||
            tag == nsAccessibilityAtoms::h3 ||
            tag == nsAccessibilityAtoms::h4 ||
            tag == nsAccessibilityAtoms::h5 ||
            tag == nsAccessibilityAtoms::h6 ||
            tag == nsAccessibilityAtoms::q) {
-    return CreateHyperTextAccessible(aFrame, aAccessible);
+
+    accessible = new nsHyperTextAccessibleWrap(aNode, aWeakShell);
   }
   else if (tag == nsAccessibilityAtoms::tr) {
-    *aAccessible = new nsEnumRoleAccessible(aNode, aWeakShell,
+    accessible = new nsEnumRoleAccessible(aNode, aWeakShell,
                                             nsIAccessibleRole::ROLE_ROW);
   }
   else if (nsCoreUtils::IsHTMLTableHeader(content)) {
-    *aAccessible = new nsHTMLTableHeaderCellAccessibleWrap(aNode, aWeakShell);
+    accessible = new nsHTMLTableHeaderCellAccessibleWrap(aNode, aWeakShell);
   }
 
-  NS_IF_ADDREF(*aAccessible);
-  return NS_OK;
+  return accessible.forget();
 }
 
 NS_IMETHODIMP
 nsAccessibilityService::CreateHTMLLIAccessible(nsIFrame *aFrame, 
                                                nsIFrame *aBulletFrame,
                                                const nsAString& aBulletText,
                                                nsIAccessible **_retval)
 {
@@ -933,42 +936,35 @@ nsAccessibilityService::CreateHTMLCaptio
   *_retval = new nsHTMLCaptionAccessible(node, weakShell);
   if (! *_retval) 
     return NS_ERROR_OUT_OF_MEMORY;
 
   NS_ADDREF(*_retval);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsAccessibilityService::GetCachedAccessible(nsIDOMNode *aNode, 
-                                                          nsIWeakReference *aWeakShell,
-                                                          nsIAccessible **aAccessible)
-{
-  nsCOMPtr<nsIAccessNode> accessNode;
-  nsresult rv = GetCachedAccessNode(aNode, aWeakShell, getter_AddRefs(accessNode));
-  nsCOMPtr<nsIAccessible> accessible(do_QueryInterface(accessNode));
-  NS_IF_ADDREF(*aAccessible = accessible);
-  return rv;
-}
-
-NS_IMETHODIMP nsAccessibilityService::GetCachedAccessNode(nsIDOMNode *aNode, 
-                                                          nsIWeakReference *aWeakShell,
-                                                          nsIAccessNode **aAccessNode)
+// nsAccessibilityService public
+nsAccessNode*
+nsAccessibilityService::GetCachedAccessNode(nsIDOMNode *aNode, 
+                                            nsIWeakReference *aWeakShell)
 {
   nsCOMPtr<nsIAccessibleDocument> accessibleDoc =
     nsAccessNode::GetDocAccessibleFor(aWeakShell);
 
-  if (!accessibleDoc) {
-    *aAccessNode = nsnull;
-    return NS_ERROR_FAILURE;
-  }
+  if (!accessibleDoc)
+    return nsnull;
 
-  return accessibleDoc->GetCachedAccessNode(static_cast<void*>(aNode), aAccessNode);
+  nsRefPtr<nsDocAccessible> docAccessible =
+    nsAccUtils::QueryObject<nsDocAccessible>(accessibleDoc);
+  return docAccessible->GetCachedAccessNode(static_cast<void*>(aNode));
 }
 
+////////////////////////////////////////////////////////////////////////////////
+// nsIAccessibleRetrieval
+
 NS_IMETHODIMP
 nsAccessibilityService::GetStringRole(PRUint32 aRole, nsAString& aString)
 {
   if ( aRole >= NS_ARRAY_LENGTH(kRoleNames)) {
     aString.AssignLiteral("unknown");
     return NS_OK;
   }
 
@@ -1132,31 +1128,39 @@ NS_IMETHODIMP
 nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
                                          nsIAccessible **aAccessible)
 {
   NS_ENSURE_ARG_POINTER(aAccessible);
   *aAccessible = nsnull;
 
   NS_ENSURE_ARG(aNode);
 
-  // We use presentation shell #0 because we assume that is presentation of
-  // given node window.
   nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
   nsCOMPtr<nsIDocument> doc;
   if (content) {
     doc = content->GetDocument();
   }
   else {// Could be document node
     doc = do_QueryInterface(aNode);
   }
   if (!doc)
     return NS_ERROR_FAILURE;
 
+  // We use presentation shell #0 because we assume that is presentation of
+  // given node window.
   nsIPresShell *presShell = doc->GetPrimaryShell();
-  return GetAccessibleInShell(aNode, presShell, aAccessible);
+
+  nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(presShell));
+  nsRefPtr<nsAccessible> accessible =
+    GetAccessible(aNode, presShell, weakShell);
+
+  if (accessible)
+    CallQueryInterface(accessible.get(), aAccessible);
+  
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsAccessibilityService::GetAttachedAccessibleFor(nsIDOMNode *aNode,
                                                  nsIAccessible **aAccessible)
 {
   NS_ENSURE_ARG(aNode);
   NS_ENSURE_ARG_POINTER(aAccessible);
@@ -1168,66 +1172,84 @@ nsAccessibilityService::GetAttachedAcces
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (relevantNode != aNode)
     return NS_OK;
 
   return GetAccessibleFor(aNode, aAccessible);
 }
 
-NS_IMETHODIMP nsAccessibilityService::GetAccessibleInShell(nsIDOMNode *aNode, 
-                                                           nsIPresShell *aPresShell,
-                                                           nsIAccessible **aAccessible) 
+NS_IMETHODIMP
+nsAccessibilityService::GetAccessibleInShell(nsIDOMNode *aNode, 
+                                             nsIPresShell *aPresShell,
+                                             nsIAccessible **aAccessible) 
 {
   NS_ENSURE_ARG_POINTER(aAccessible);
   *aAccessible = nsnull;
 
   NS_ENSURE_ARG(aNode);
   NS_ENSURE_ARG(aPresShell);
 
   nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(aPresShell));
-  PRBool isHiddenUnused = false;
-  return GetAccessible(aNode, aPresShell, weakShell, 
-                       nsnull, &isHiddenUnused, aAccessible);
+  nsRefPtr<nsAccessible> accessible =
+    GetAccessible(aNode, aPresShell, weakShell);
+
+  if (accessible)
+    CallQueryInterface(accessible.get(), aAccessible);
+  
+  return NS_OK;
 }
 
+////////////////////////////////////////////////////////////////////////////////
+// nsAccessibilityService public
+
 nsresult
 nsAccessibilityService::GetAccessibleInWeakShell(nsIDOMNode *aNode, 
                                                  nsIWeakReference *aWeakShell,
                                                  nsIAccessible **aAccessible) 
 {
   NS_ENSURE_ARG_POINTER(aAccessible);
   *aAccessible = nsnull;
 
   NS_ENSURE_ARG(aNode);
   NS_ENSURE_ARG(aWeakShell);
 
   nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(aWeakShell));
-  PRBool isHiddenUnused = false;
-  return GetAccessible(aNode, presShell, aWeakShell, 
-                       nsnull, &isHiddenUnused, aAccessible);
+  nsRefPtr<nsAccessible> accessible =
+    GetAccessible(aNode, presShell, aWeakShell);
+
+  if (accessible)
+    CallQueryInterface(accessible.get(), aAccessible);
+
+  return NS_OK;
 }
 
-nsresult nsAccessibilityService::InitAccessible(nsIAccessible *aAccessibleIn,
-                                                nsIAccessible **aAccessibleOut,
-                                                nsRoleMapEntry *aRoleMapEntry)
+////////////////////////////////////////////////////////////////////////////////
+// nsAccessibilityService private
+
+PRBool
+nsAccessibilityService::InitAccessible(nsAccessible *aAccessible,
+                                       nsRoleMapEntry *aRoleMapEntry)
 {
-  if (!aAccessibleIn) {
-    return NS_ERROR_FAILURE; // No accessible to init
-  }
-  NS_ASSERTION(aAccessibleOut && !*aAccessibleOut, "Out param should already be cleared out");
+  if (!aAccessible)
+    return PR_FALSE;
 
-  nsRefPtr<nsAccessible> acc = nsAccUtils::QueryAccessible(aAccessibleIn);
-  nsresult rv = acc->Init(); // Add to cache, etc.
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsresult rv = aAccessible->Init(); // Add to cache, etc.
+  if (NS_FAILED(rv)) {
+    NS_ERROR("Failed to initialize an accessible!");
 
-  acc->SetRoleMapEntry(aRoleMapEntry);
-  NS_ADDREF(*aAccessibleOut = aAccessibleIn);
+    aAccessible->Shutdown();
+    return PR_FALSE;
+  }
 
-  return NS_OK;
+  NS_ASSERTION(aAccessible->IsInCache(),
+               "Initialized accessible not in the cache!");
+
+  aAccessible->SetRoleMapEntry(aRoleMapEntry);
+  return PR_TRUE;
 }
 
 static PRBool HasRelatedContent(nsIContent *aContent)
 {
   nsAutoString id;
   if (!aContent || !nsCoreUtils::GetID(aContent, id) || id.IsEmpty()) {
     return PR_FALSE;
   }
@@ -1248,40 +1270,30 @@ static PRBool HasRelatedContent(nsIConte
         // ancestor has activedescendant property, this content could be active
       return PR_TRUE;
     }
   }
 
   return PR_FALSE;
 }
 
-nsresult
+// nsAccessibilityService public
+already_AddRefed<nsAccessible>
 nsAccessibilityService::GetAccessible(nsIDOMNode *aNode,
                                       nsIPresShell *aPresShell,
                                       nsIWeakReference *aWeakShell,
-                                      nsIFrame *aFrameHint,
-                                      PRBool *aIsHidden,
-                                      nsIAccessible **aAccessible)
+                                      PRBool *aIsHidden)
 {
-  NS_ENSURE_ARG_POINTER(aAccessible);
-  *aAccessible = nsnull;
-
-  if (!aPresShell || !aWeakShell || gIsShutdown) {
-    return NS_ERROR_FAILURE;
-  }
+  if (!aPresShell || !aWeakShell || gIsShutdown)
+    return nsnull;
 
   NS_ASSERTION(aNode, "GetAccessible() called with no node.");
 
-  *aIsHidden = PR_FALSE;
-
-  // Frames can be deallocated when we flush layout, or when we call into code
-  // that can flush layout, either directly, or via DOM manipulation, or some
-  // CSS styles like :hover. We use the weak frame checks to avoid calling
-  // methods on a dead frame pointer.
-  nsWeakFrame weakFrame(aFrameHint);
+  if (aIsHidden)
+    *aIsHidden = PR_FALSE;
 
 #ifdef DEBUG_A11Y
   // Please leave this in for now, it's a convenient debugging method
   nsAutoString name;
   aNode->GetLocalName(name);
   if (name.LowerCaseEqualsLiteral("h1")) 
     printf("## aaronl debugging tag name\n");
 
@@ -1289,176 +1301,171 @@ nsAccessibilityService::GetAccessible(ns
   nsCOMPtr<nsIDOMElement> element(do_QueryInterface(aNode));
   if (element) {
     element->GetAttribute(NS_LITERAL_STRING("type"), attrib);
     if (attrib.EqualsLiteral("statusbarpanel"))
       printf("## aaronl debugging attribute\n");
   }
 #endif
 
-  // Check to see if we already have an accessible for this
-  // node in the cache
-  nsCOMPtr<nsIAccessNode> accessNode;
-  GetCachedAccessNode(aNode, aWeakShell, getter_AddRefs(accessNode));
+  // Check to see if we already have an accessible for this node in the cache.
+  nsAccessNode* cachedAccessNode = GetCachedAccessNode(aNode, aWeakShell);
+  if (cachedAccessNode) {
+    // XXX: the cache might contain the access node for the DOM node that is not
+    // accessible because of wrong cache update. In this case try to create new
+    // accessible.
+    nsRefPtr<nsAccessible> cachedAccessible =
+      nsAccUtils::QueryObject<nsAccessible>(cachedAccessNode);
 
-  nsCOMPtr<nsIAccessible> newAcc;
-  if (accessNode) {
-    // Retrieved from cache. QI might not succeed if it's a node that's not
-    // accessible. In this case try to create new accessible because one and
-    // the same DOM node may be accessible or not in time (for example,
-    // when it is visible or hidden).
-    newAcc = do_QueryInterface(accessNode);
-    if (newAcc) {
-      NS_ADDREF(*aAccessible = newAcc);
-      return NS_OK;
-    }
+    if (cachedAccessible)
+      return cachedAccessible.forget();
   }
 
-  nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
+  // No cache entry, so we must create the accessible.
+  nsRefPtr<nsAccessible> newAcc;
 
-  // No cache entry, so we must create the accessible
-  // Check to see if hidden first
-  nsCOMPtr<nsIDocument> nodeIsDoc;
+  nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
   if (!content) {
     // This happens when we're on the document node, which will not QI to an
     // nsIContent.
-    nodeIsDoc = do_QueryInterface(aNode);
-    NS_ENSURE_TRUE(nodeIsDoc, NS_ERROR_FAILURE); // No content, and not doc node
-
-    nsCOMPtr<nsIAccessibleDocument> accessibleDoc =
-      nsAccessNode::GetDocAccessibleFor(aWeakShell);
-    if (accessibleDoc) {
-      newAcc = do_QueryInterface(accessibleDoc);
-      NS_ASSERTION(newAcc, "nsIAccessibleDocument is not an nsIAccessible");
-    }
-    else {
-      CreateRootAccessible(aPresShell, nodeIsDoc, getter_AddRefs(newAcc)); // Does Init() for us
-    }
+    nsCOMPtr<nsIDocument> nodeIsDoc = do_QueryInterface(aNode);
+    if (!nodeIsDoc) // No content, and not doc node.
+      return nsnull;
 
-    NS_IF_ADDREF(*aAccessible = newAcc);
-    return NS_OK;
-  }
-
-  NS_ASSERTION(content->GetDocument(), "Creating accessible for node with no document");
-  if (!content->GetDocument()) {
-    return NS_ERROR_FAILURE;
-  }
-  NS_ASSERTION(content->GetDocument() == aPresShell->GetDocument(), "Creating accessible for wrong pres shell");
-  if (content->GetDocument() != aPresShell->GetDocument()) {
-    return NS_ERROR_FAILURE;
-  }
-
-  // We have a content node
-#ifdef DEBUG_A11Y
-  static int frameHintFailed, frameHintTried, frameHintNonexistant, frameHintFailedForText;
-  ++frameHintTried;
+#ifdef DEBUG
+    // XXX: remove me if you don't see an assertion.
+    nsCOMPtr<nsIAccessibleDocument> accessibleDoc =
+      nsAccessNode::GetDocAccessibleFor(nodeIsDoc);
+    NS_ASSERTION(!accessibleDoc,
+                 "Trying to create already cached accessible document!");
 #endif
 
-  if (!weakFrame.GetFrame() || content != weakFrame.GetFrame()->GetContent()) {
-    // Frame hint not correct, get true frame, we try to optimize away from this
-    weakFrame = content->GetPrimaryFrame();
-    if (weakFrame.GetFrame()) {
-#ifdef DEBUG_A11Y_FRAME_OPTIMIZATION
-      // Frame hint debugging
-      ++frameHintFailed;
-      if (content->IsNodeOfType(nsINode::eTEXT)) {
-        ++frameHintFailedForText;
-      }
-      frameHintNonexistant += !aFrameHint;
-      printf("Frame hint failures: %d / %d . Text fails = %d. No hint fails = %d \n", frameHintFailed, frameHintTried, frameHintFailedForText, frameHintNonexistant);
-      if (frameHintTried >= 354) {
-        printf("* "); // Aaron's break point
-      }
-#endif
-      if (weakFrame.GetFrame()->GetContent() != content) {
-        // Not the main content for this frame!
-        // For example, this happens because <area> elements return the
-        // image frame as their primary frame. The main content for the 
-        // image frame is the image content.
+    newAcc = CreateDocOrRootAccessible(aPresShell, nodeIsDoc);
+    if (InitAccessible(newAcc, nsAccUtils::GetRoleMapEntry(aNode)))
+      return newAcc.forget();
+    return nsnull;
+  }
+
+  // We have a content node.
+  if (!content->IsInDoc()) {
+    NS_ERROR("Creating accessible for node with no document");
+    return nsnull;
+  }
+
+  if (content->GetOwnerDoc() != aPresShell->GetDocument()) {
+    NS_ERROR("Creating accessible for wrong pres shell");
+    return nsnull;
+  }
+
+  // Frames can be deallocated when we flush layout, or when we call into code
+  // that can flush layout, either directly, or via DOM manipulation, or some
+  // CSS styles like :hover. We use the weak frame checks to avoid calling
+  // methods on a dead frame pointer.
+  nsWeakFrame weakFrame = content->GetPrimaryFrame();
 
-        // Check if frame is an image frame, and content is <area>
-        nsIImageFrame *imageFrame = do_QueryFrame(weakFrame.GetFrame());
-        nsCOMPtr<nsIDOMHTMLAreaElement> areaElmt = do_QueryInterface(content);
-        if (imageFrame && areaElmt) {
-          nsCOMPtr<nsIAccessible> imageAcc;
-          CreateHTMLImageAccessible(weakFrame.GetFrame(), getter_AddRefs(imageAcc));
-          if (imageAcc) {
-            // cache children
-            PRInt32 childCount;
-            imageAcc->GetChildCount(&childCount);
-            // area accessible should be in cache now
-            return GetCachedAccessible(aNode, aWeakShell, aAccessible);
-          }
+  // Check frame to see if it is hidden.
+  if (!weakFrame.GetFrame() ||
+      !weakFrame.GetFrame()->GetStyleVisibility()->IsVisible()) {
+    if (aIsHidden)
+      *aIsHidden = PR_TRUE;
+
+    return nsnull;
+  }
+
+  if (weakFrame.GetFrame()->GetContent() != content) {
+    // Not the main content for this frame!
+    // For example, this happens because <area> elements return the
+    // image frame as their primary frame. The main content for the 
+    // image frame is the image content.
+
+    // Check if frame is an image frame, and content is <area>.
+    nsIImageFrame *imageFrame = do_QueryFrame(weakFrame.GetFrame());
+    nsCOMPtr<nsIDOMHTMLAreaElement> areaElmt = do_QueryInterface(content);
+    if (imageFrame && areaElmt) {
+      // XXX: it's a hack we should try the cache before or if failed cache
+      // the image accessible.
+      nsCOMPtr<nsIAccessible> imageAcc;
+      CreateHTMLImageAccessible(weakFrame.GetFrame(), getter_AddRefs(imageAcc));
+      if (imageAcc) {
+        // Cache children.
+        PRInt32 childCount;
+        imageAcc->GetChildCount(&childCount);
+        // <area> accessible should be in cache now.
+        nsAccessNode* cachedAreaAcc = GetCachedAccessNode(aNode, aWeakShell);
+        if (cachedAreaAcc) {
+          newAcc = nsAccUtils::QueryObject<nsAccessible>(cachedAreaAcc);
+          return newAcc.forget();
         }
-
-        return NS_OK;
       }
     }
+
+    return nsnull;
   }
 
-  // Check frame to see if it is hidden
-  if (!weakFrame.GetFrame() ||
-      !weakFrame.GetFrame()->GetStyleVisibility()->IsVisible()) {
-    *aIsHidden = PR_TRUE;
-  }
-
-  if (*aIsHidden)
-    return NS_OK;
-
-  /**
-   * Attempt to create an accessible based on what we know
-   */
+  // Attempt to create an accessible based on what we know.
   if (content->IsNodeOfType(nsINode::eTEXT)) {
     // --- Create HTML for visible text frames ---
     nsIFrame* f = weakFrame.GetFrame();
     if (f && f->IsEmpty()) {
       nsAutoString renderedWhitespace;
       f->GetRenderedText(&renderedWhitespace, nsnull, nsnull, 0, 1);
       if (renderedWhitespace.IsEmpty()) {
         // Really empty -- nothing is rendered
-        *aIsHidden = PR_TRUE;
-        return NS_OK;
+        if (aIsHidden)
+          *aIsHidden = PR_TRUE;
+
+        return nsnull;
       }
     }
     if (weakFrame.IsAlive()) {
-      weakFrame.GetFrame()->GetAccessible(getter_AddRefs(newAcc));
+      nsCOMPtr<nsIAccessible> newAccessible;
+      weakFrame.GetFrame()->GetAccessible(getter_AddRefs(newAccessible));
+      if (newAccessible) {
+        newAcc = nsAccUtils::QueryObject<nsAccessible>(newAccessible);
+        if (InitAccessible(newAcc, nsnull))
+          return newAcc.forget();
+        return nsnull;
+      }
     }
 
-    return InitAccessible(newAcc, aAccessible, nsnull);
+    return nsnull;
   }
 
   PRBool isHTML = content->IsHTML();
   if (isHTML && content->Tag() == nsAccessibilityAtoms::map) {
     // Create hyper text accessible for HTML map if it is used to group links
     // (see http://www.w3.org/TR/WCAG10-HTML-TECHS/#group-bypass). If the HTML
     // map doesn't have 'name' attribute (or has empty name attribute) then we
     // suppose it is used for links grouping. Otherwise we think it is used in
     // conjuction with HTML image element and in this case we don't create any
     // accessible for it and don't walk into it. The accessibles for HTML area
     // (nsHTMLAreaAccessible) the map contains are attached as children of the
     // appropriate accessible for HTML image (nsHTMLImageAccessible).
     nsAutoString name;
     content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::name, name);
     if (!name.IsEmpty()) {
-      *aIsHidden = PR_TRUE;
-      return NS_OK;
+      if (aIsHidden)
+        *aIsHidden = PR_TRUE;
+
+      return nsnull;
     }
-    
-    nsresult rv =
-      CreateHyperTextAccessible(weakFrame.GetFrame(), getter_AddRefs(newAcc));
-    NS_ENSURE_SUCCESS(rv, rv);
+
+    newAcc = new nsHyperTextAccessibleWrap(aNode, aWeakShell);
+    if (InitAccessible(newAcc, nsAccUtils::GetRoleMapEntry(aNode)))
+      return newAcc.forget();
+    return nsnull;
   }
 
   nsRoleMapEntry *roleMapEntry = nsAccUtils::GetRoleMapEntry(aNode);
   if (roleMapEntry && !nsCRT::strcmp(roleMapEntry->roleString, "presentation") &&
       !content->IsFocusable()) { // For presentation only
     // Only create accessible for role of "presentation" if it is focusable --
     // in that case we need an accessible in case it gets focused, we
     // don't want focus ever to be 'lost'
-    return NS_OK;
+    return nsnull;
   }
 
   if (weakFrame.IsAlive() && !newAcc && isHTML) {  // HTML accessibles
     PRBool tryTagNameOrFrame = PR_TRUE;
 
     nsIAtom *frameType = weakFrame.GetFrame()->GetType();
 
     PRBool partOfHTMLTable =
@@ -1475,18 +1482,18 @@ nsAccessibilityService::GetAccessible(ns
       while ((tableContent = tableContent->GetParent()) != nsnull) {
         nsIFrame *tableFrame = tableContent->GetPrimaryFrame();
         if (!tableFrame)
           continue;
 
         if (tableFrame->GetType() == nsAccessibilityAtoms::tableOuterFrame) {
           nsCOMPtr<nsIDOMNode> tableNode(do_QueryInterface(tableContent));
           nsCOMPtr<nsIAccessible> tableAccessible;
-          GetAccessibleInShell(tableNode, aPresShell,
-                               getter_AddRefs(tableAccessible));
+          GetAccessibleInWeakShell(tableNode, aWeakShell,
+                                   getter_AddRefs(tableAccessible));
 
           if (tableAccessible) {
             if (!roleMapEntry) {
               PRUint32 role = nsAccUtils::Role(tableAccessible);
               if (role != nsIAccessibleRole::ROLE_TABLE &&
                   role != nsIAccessibleRole::ROLE_TREE_TABLE) {
                 // No ARIA role and not in table: override role. For example,
                 // <table role="label"><td>content</td></table>
@@ -1505,17 +1512,17 @@ nsAccessibilityService::GetAccessible(ns
                        "No accessible for parent table and it didn't have role of presentation");
 #endif
 
           if (!roleMapEntry && !content->IsFocusable()) {
             // Table-related descendants of presentation table are also
             // presentation if they aren't focusable and have not explicit ARIA
             // role (don't create accessibles for them unless they need to fire
             // focus events).
-            return NS_OK;
+            return nsnull;
           }
 
           // otherwise create ARIA based accessible.
           tryTagNameOrFrame = PR_FALSE;
           break;
         }
 
         if (tableContent->Tag() == nsAccessibilityAtoms::table) {
@@ -1549,49 +1556,52 @@ nsAccessibilityService::GetAccessible(ns
     }
 
     if (!newAcc && tryTagNameOrFrame) {
       // Prefer to use markup (mostly tag name, perhaps attributes) to
       // decide if and what kind of accessible to create.
       // The method creates accessibles for table related content too therefore
       // we do not call it if accessibles for table related content are
       // prevented above.
-      nsresult rv =
-        CreateHTMLAccessibleByMarkup(weakFrame.GetFrame(), aWeakShell, aNode,
-                                     getter_AddRefs(newAcc));
-      NS_ENSURE_SUCCESS(rv, rv);
+      newAcc = CreateHTMLAccessibleByMarkup(weakFrame.GetFrame(), aWeakShell,
+                                            aNode);
 
       if (!newAcc) {
         // Do not create accessible object subtrees for non-rendered table
         // captions. This could not be done in
         // nsTableCaptionFrame::GetAccessible() because the descendants of
         // the table caption would still be created. By setting
         // *aIsHidden = PR_TRUE we ensure that no descendant accessibles are
         // created.
         nsIFrame* f = weakFrame.GetFrame();
         if (!f) {
           f = aPresShell->GetRealPrimaryFrameFor(content);
         }
         if (f->GetType() == nsAccessibilityAtoms::tableCaptionFrame &&
            f->GetRect().IsEmpty()) {
           // XXX This is not the ideal place for this code, but right now there
           // is no better place:
-          *aIsHidden = PR_TRUE;
-          return NS_OK;
+          if (aIsHidden)
+            *aIsHidden = PR_TRUE;
+
+          return nsnull;
         }
-        f->GetAccessible(getter_AddRefs(newAcc)); // Try using frame to do it
+
+        // Try using frame to do it.
+        nsCOMPtr<nsIAccessible> newAccessible;
+        f->GetAccessible(getter_AddRefs(newAccessible));
+        newAcc = nsAccUtils::QueryObject<nsAccessible>(newAccessible);
       }
     }
   }
 
   if (!newAcc) {
     // Elements may implement nsIAccessibleProvider via XBL. This allows them to
     // say what kind of accessible to create.
-    nsresult rv = GetAccessibleByType(aNode, getter_AddRefs(newAcc));
-    NS_ENSURE_SUCCESS(rv, rv);
+    newAcc = CreateAccessibleByType(aNode, aWeakShell);
   }
 
   if (!newAcc) {
     // Create generic accessibles for SVG and MathML nodes.
     if (content->GetNameSpaceID() == kNameSpaceID_SVG &&
         content->Tag() == nsAccessibilityAtoms::svg) {
       newAcc = new nsEnumRoleAccessible(aNode, aWeakShell,
                                         nsIAccessibleRole::ROLE_DIAGRAM);
@@ -1599,42 +1609,45 @@ nsAccessibilityService::GetAccessible(ns
     else if (content->GetNameSpaceID() == kNameSpaceID_MathML &&
              content->Tag() == nsAccessibilityAtoms::math) {
       newAcc = new nsEnumRoleAccessible(aNode, aWeakShell,
                                         nsIAccessibleRole::ROLE_EQUATION);
     }
   }
 
   if (!newAcc) {
-    GetAccessibleForDeckChildren(aNode, getter_AddRefs(newAcc));
+    newAcc = CreateAccessibleForDeckChild(weakFrame.GetFrame(), aNode,
+                                          aWeakShell);
   }
 
   // If no accessible, see if we need to create a generic accessible because
   // of some property that makes this object interesting
   // We don't do this for <body>, <html>, <window>, <dialog> etc. which 
   // correspond to the doc accessible and will be created in any case
   if (!newAcc && content->Tag() != nsAccessibilityAtoms::body && content->GetParent() && 
       ((weakFrame.GetFrame() && weakFrame.GetFrame()->IsFocusable()) ||
        (isHTML && nsCoreUtils::HasClickListener(content)) ||
        HasUniversalAriaProperty(content, aWeakShell) || roleMapEntry ||
        HasRelatedContent(content) || nsCoreUtils::IsXLink(content))) {
     // This content is focusable or has an interesting dynamic content accessibility property.
     // If it's interesting we need it in the accessibility hierarchy so that events or
     // other accessibles can point to it, or so that it can hold a state, etc.
     if (isHTML) {
       // Interesting HTML container which may have selectable text and/or embedded objects
-      CreateHyperTextAccessible(weakFrame.GetFrame(), getter_AddRefs(newAcc));
+      newAcc = new nsHyperTextAccessibleWrap(aNode, aWeakShell);
     }
     else {  // XUL, SVG, MathML etc.
       // Interesting generic non-HTML container
       newAcc = new nsAccessibleWrap(aNode, aWeakShell);
     }
   }
 
-  return InitAccessible(newAcc, aAccessible, roleMapEntry);
+  if (InitAccessible(newAcc, roleMapEntry))
+    return newAcc.forget();
+  return nsnull;
 }
 
 PRBool
 nsAccessibilityService::HasUniversalAriaProperty(nsIContent *aContent,
                                                  nsIWeakReference *aWeakShell)
 {
   // ARIA attributes that take token values (NMTOKEN, bool) are special cased.
   return nsAccUtils::HasDefinedARIAToken(aContent, nsAccessibilityAtoms::aria_atomic) ||
@@ -1650,16 +1663,17 @@ nsAccessibilityService::HasUniversalAria
          aContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::aria_labelledby) ||
          nsAccUtils::HasDefinedARIAToken(aContent, nsAccessibilityAtoms::aria_live) ||
          nsAccUtils::HasDefinedARIAToken(aContent, nsAccessibilityAtoms::aria_owns) ||
          nsAccUtils::HasDefinedARIAToken(aContent, nsAccessibilityAtoms::aria_relevant) ||
          nsAccUtils::HasDefinedARIAToken(aContent, nsAccessibilityAtoms::aria_required) ||
          nsAccUtils::HasDefinedARIAToken(aContent, nsAccessibilityAtoms::aria_sort);
 }
 
+// nsIAccessibleRetrieval
 NS_IMETHODIMP
 nsAccessibilityService::GetRelevantContentNodeFor(nsIDOMNode *aNode,
                                                   nsIDOMNode **aRelevantNode)
 {
   // The method returns node that is relevant for attached accessible check.
   // Sometimes element that is XBL widget hasn't accessible children in
   // anonymous content. This method check whether given node can be accessible
   // by looking through all nested bindings that given node is anonymous for. If
@@ -1676,17 +1690,16 @@ nsAccessibilityService::GetRelevantConte
   // 3. xforms:input that is hosted in xul document contains xul:textbox
   // element. When given node is html:input or xul:textbox then we return
   // xforms:input element since xforms:input hasn't accessible anonymous
   // children.
 
   NS_ENSURE_ARG(aNode);
   NS_ENSURE_ARG_POINTER(aRelevantNode);
 
-  nsresult rv;
   nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
   if (content) {
     // Build stack of binding parents so we can walk it in reverse.
     nsIContent *bindingParent;
     nsCOMArray<nsIContent> bindingsStack;
 
     for (bindingParent = content->GetBindingParent(); bindingParent != nsnull &&
          bindingParent != bindingParent->GetBindingParent();
@@ -1696,282 +1709,282 @@ nsAccessibilityService::GetRelevantConte
 
     PRInt32 bindingsCount = bindingsStack.Count();
     for (PRInt32 index = bindingsCount - 1; index >= 0 ; index--) {
       bindingParent = bindingsStack[index];
       nsCOMPtr<nsIDOMNode> bindingNode(do_QueryInterface(bindingParent));
       if (bindingNode) {
         // Try to get an accessible by type since XBL widget can be accessible
         // only if it implements nsIAccessibleProvider interface.
-        nsCOMPtr<nsIAccessible> accessible;
-        rv = GetAccessibleByType(bindingNode, getter_AddRefs(accessible));
+        nsCOMPtr<nsIWeakReference> weakShell;
+        GetShellFromNode(bindingNode, getter_AddRefs(weakShell));
 
-        if (NS_SUCCEEDED(rv)) {
-          nsRefPtr<nsAccessible> acc(nsAccUtils::QueryAccessible(accessible));
-          if (acc) {
-            PRBool allowsAnonChildren = acc->GetAllowsAnonChildAccessibles();
-            if (!allowsAnonChildren) {
-              NS_ADDREF(*aRelevantNode = bindingNode);
-              return NS_OK;
-            }
+        // XXX: it's a hack we should try the cache before, otherwise to cache
+        // the accessible.
+        nsRefPtr<nsAccessible> accessible =
+          CreateAccessibleByType(bindingNode, weakShell);
+
+        if (accessible) {
+          if (!accessible->GetAllowsAnonChildAccessibles()) {
+            NS_ADDREF(*aRelevantNode = bindingNode);
+            return NS_OK;
           }
         }
       }
     }
   }
 
   NS_ADDREF(*aRelevantNode = aNode);
   return NS_OK;
 }
 
-nsresult nsAccessibilityService::GetAccessibleByType(nsIDOMNode *aNode,
-                                                     nsIAccessible **aAccessible)
+already_AddRefed<nsAccessible>
+nsAccessibilityService::CreateAccessibleByType(nsIDOMNode *aNode,
+                                               nsIWeakReference *aWeakShell)
 {
-  NS_ENSURE_ARG(aNode);
-  NS_ENSURE_ARG_POINTER(aAccessible);
-
-  *aAccessible = nsnull;
-
   nsCOMPtr<nsIAccessibleProvider> accessibleProvider(do_QueryInterface(aNode));
   if (!accessibleProvider)
-    return NS_OK;
+    return nsnull;
 
   PRInt32 type;
   nsresult rv = accessibleProvider->GetAccessibleType(&type);
-  NS_ENSURE_SUCCESS(rv, rv);
+  if (NS_FAILED(rv))
+    return nsnull;
 
-  if (type == nsIAccessibleProvider::OuterDoc)
-    return CreateOuterDocAccessible(aNode, aAccessible);
-
-  nsCOMPtr<nsIWeakReference> weakShell;
-  GetShellFromNode(aNode, getter_AddRefs(weakShell));
+  nsRefPtr<nsAccessible> accessible;
+  if (type == nsIAccessibleProvider::OuterDoc) {
+    accessible = new nsOuterDocAccessible(aNode, aWeakShell);
+    return accessible.forget();
+  }
 
   switch (type)
   {
 #ifdef MOZ_XUL
     case nsIAccessibleProvider::NoAccessible:
-      return NS_OK;
+      return nsnull;
+
     // XUL controls
     case nsIAccessibleProvider::XULAlert:
-      *aAccessible = new nsXULAlertAccessible(aNode, weakShell);
+      accessible = new nsXULAlertAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULButton:
-      *aAccessible = new nsXULButtonAccessible(aNode, weakShell);
+      accessible = new nsXULButtonAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULCheckbox:
-      *aAccessible = new nsXULCheckboxAccessible(aNode, weakShell);
+      accessible = new nsXULCheckboxAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULColorPicker:
-      *aAccessible = new nsXULColorPickerAccessible(aNode, weakShell);
+      accessible = new nsXULColorPickerAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULColorPickerTile:
-      *aAccessible = new nsXULColorPickerTileAccessible(aNode, weakShell);
+      accessible = new nsXULColorPickerTileAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULCombobox:
-      *aAccessible = new nsXULComboboxAccessible(aNode, weakShell);
+      accessible = new nsXULComboboxAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULDropmarker:
-      *aAccessible = new nsXULDropmarkerAccessible(aNode, weakShell);
+      accessible = new nsXULDropmarkerAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULGroupbox:
-      *aAccessible = new nsXULGroupboxAccessible(aNode, weakShell);
+      accessible = new nsXULGroupboxAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULImage:
     {
       // Don't include nameless images in accessible tree
       nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(aNode));
       if (!elt)
-        return NS_ERROR_FAILURE;
+        return nsnull;
 
       PRBool hasTextEquivalent;
       // Prefer value over tooltiptext
       elt->HasAttribute(NS_LITERAL_STRING("tooltiptext"), &hasTextEquivalent);
       if (!hasTextEquivalent)
-        return NS_OK;
+        return nsnull;
 
-      *aAccessible = new nsHTMLImageAccessibleWrap(aNode, weakShell);
+      accessible = new nsHTMLImageAccessibleWrap(aNode, aWeakShell);
       break;
     }
     case nsIAccessibleProvider::XULLink:
-      *aAccessible = new nsXULLinkAccessible(aNode, weakShell);
+      accessible = new nsXULLinkAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULListbox:
-      *aAccessible = new nsXULListboxAccessibleWrap(aNode, weakShell);
+      accessible = new nsXULListboxAccessibleWrap(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULListCell:
-      *aAccessible = new nsXULListCellAccessibleWrap(aNode, weakShell);
+      accessible = new nsXULListCellAccessibleWrap(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULListHead:
-      *aAccessible = new nsXULColumnsAccessible(aNode, weakShell);
+      accessible = new nsXULColumnsAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULListHeader:
-      *aAccessible = new nsXULColumnItemAccessible(aNode, weakShell);
+      accessible = new nsXULColumnItemAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULListitem:
-      *aAccessible = new nsXULListitemAccessible(aNode, weakShell);
+      accessible = new nsXULListitemAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULMenubar:
-      *aAccessible = new nsXULMenubarAccessible(aNode, weakShell);
+      accessible = new nsXULMenubarAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULMenuitem:
-      *aAccessible = new nsXULMenuitemAccessibleWrap(aNode, weakShell);
+      accessible = new nsXULMenuitemAccessibleWrap(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULMenupopup:
     {
 #ifdef MOZ_ACCESSIBILITY_ATK
       // ATK considers this node to be redundant when within menubars, and it makes menu
       // navigation with assistive technologies more difficult
       // XXX In the future we will should this for consistency across the nsIAccessible
       // implementations on each platform for a consistent scripting environment, but
       // then strip out redundant accessibles in the nsAccessibleWrap class for each platform.
       nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
       if (content) {
         nsIContent *parent = content->GetParent();
         if (parent && parent->NodeInfo()->Equals(nsAccessibilityAtoms::menu, kNameSpaceID_XUL)) {
-          return NS_OK;
+          return nsnull;
         }
       }
 #endif
-      *aAccessible = new nsXULMenupopupAccessible(aNode, weakShell);
+      accessible = new nsXULMenupopupAccessible(aNode, aWeakShell);
       break;
     }
     case nsIAccessibleProvider::XULMenuSeparator:
-      *aAccessible = new nsXULMenuSeparatorAccessible(aNode, weakShell);
+      accessible = new nsXULMenuSeparatorAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULPane:
-      *aAccessible = new nsEnumRoleAccessible(aNode, weakShell, nsIAccessibleRole::ROLE_PANE);
+      accessible = new nsEnumRoleAccessible(aNode, aWeakShell,
+                                            nsIAccessibleRole::ROLE_PANE);
       break;
     case nsIAccessibleProvider::XULProgressMeter:
-      *aAccessible = new nsXULProgressMeterAccessible(aNode, weakShell);
+      accessible = new nsXULProgressMeterAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULStatusBar:
-      *aAccessible = new nsXULStatusBarAccessible(aNode, weakShell);
+      accessible = new nsXULStatusBarAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULScale:
-      *aAccessible = new nsXULSliderAccessible(aNode, weakShell);
+      accessible = new nsXULSliderAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULRadioButton:
-      *aAccessible = new nsXULRadioButtonAccessible(aNode, weakShell);
+      accessible = new nsXULRadioButtonAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULRadioGroup:
-      *aAccessible = new nsXULRadioGroupAccessible(aNode, weakShell);
+      accessible = new nsXULRadioGroupAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULTab:
-      *aAccessible = new nsXULTabAccessible(aNode, weakShell);
+      accessible = new nsXULTabAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULTabBox:
-      *aAccessible = new nsXULTabBoxAccessible(aNode, weakShell);
+      accessible = new nsXULTabBoxAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULTabs:
-      *aAccessible = new nsXULTabsAccessible(aNode, weakShell);
+      accessible = new nsXULTabsAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULText:
-      *aAccessible = new nsXULTextAccessible(aNode, weakShell);
+      accessible = new nsXULTextAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULTextBox:
-      *aAccessible = new nsXULTextFieldAccessible(aNode, weakShell);
+      accessible = new nsXULTextFieldAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULThumb:
-      *aAccessible = new nsXULThumbAccessible(aNode, weakShell);
+      accessible = new nsXULThumbAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULTree:
-      return GetAccessibleForXULTree(aNode, weakShell, aAccessible);
+      return CreateAccessibleForXULTree(aNode, aWeakShell);
+
     case nsIAccessibleProvider::XULTreeColumns:
-      *aAccessible = new nsXULTreeColumnsAccessible(aNode, weakShell);
+      accessible = new nsXULTreeColumnsAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULTreeColumnItem:
-      *aAccessible = new nsXULColumnItemAccessible(aNode, weakShell);
+      accessible = new nsXULColumnItemAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULToolbar:
-      *aAccessible = new nsXULToolbarAccessible(aNode, weakShell);
+      accessible = new nsXULToolbarAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULToolbarSeparator:
-      *aAccessible = new nsXULToolbarSeparatorAccessible(aNode, weakShell);
+      accessible = new nsXULToolbarSeparatorAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULTooltip:
-      *aAccessible = new nsXULTooltipAccessible(aNode, weakShell);
+      accessible = new nsXULTooltipAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XULToolbarButton:
-      *aAccessible = new nsXULToolbarButtonAccessible(aNode, weakShell);
+      accessible = new nsXULToolbarButtonAccessible(aNode, aWeakShell);
       break;
 #endif // MOZ_XUL
 
 #ifndef DISABLE_XFORMS_HOOKS
     // XForms elements
     case nsIAccessibleProvider::XFormsContainer:
-      *aAccessible = new nsXFormsContainerAccessible(aNode, weakShell);
+      accessible = new nsXFormsContainerAccessible(aNode, aWeakShell);
       break;
 
     case nsIAccessibleProvider::XFormsLabel:
-      *aAccessible = new nsXFormsLabelAccessible(aNode, weakShell);
+      accessible = new nsXFormsLabelAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XFormsOuput:
-      *aAccessible = new nsXFormsOutputAccessible(aNode, weakShell);
+      accessible = new nsXFormsOutputAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XFormsTrigger:
-      *aAccessible = new nsXFormsTriggerAccessible(aNode, weakShell);
+      accessible = new nsXFormsTriggerAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XFormsInput:
-      *aAccessible = new nsXFormsInputAccessible(aNode, weakShell);
+      accessible = new nsXFormsInputAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XFormsInputBoolean:
-      *aAccessible = new nsXFormsInputBooleanAccessible(aNode, weakShell);
+      accessible = new nsXFormsInputBooleanAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XFormsInputDate:
-      *aAccessible = new nsXFormsInputDateAccessible(aNode, weakShell);
+      accessible = new nsXFormsInputDateAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XFormsSecret:
-      *aAccessible = new nsXFormsSecretAccessible(aNode, weakShell);
+      accessible = new nsXFormsSecretAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XFormsSliderRange:
-      *aAccessible = new nsXFormsRangeAccessible(aNode, weakShell);
+      accessible = new nsXFormsRangeAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XFormsSelect:
-      *aAccessible = new nsXFormsSelectAccessible(aNode, weakShell);
+      accessible = new nsXFormsSelectAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XFormsChoices:
-      *aAccessible = new nsXFormsChoicesAccessible(aNode, weakShell);
+      accessible = new nsXFormsChoicesAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XFormsSelectFull:
-      *aAccessible = new nsXFormsSelectFullAccessible(aNode, weakShell);
+      accessible = new nsXFormsSelectFullAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XFormsItemCheckgroup:
-      *aAccessible = new nsXFormsItemCheckgroupAccessible(aNode, weakShell);
+      accessible = new nsXFormsItemCheckgroupAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XFormsItemRadiogroup:
-      *aAccessible = new nsXFormsItemRadiogroupAccessible(aNode, weakShell);
+      accessible = new nsXFormsItemRadiogroupAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XFormsSelectCombobox:
-      *aAccessible = new nsXFormsSelectComboboxAccessible(aNode, weakShell);
+      accessible = new nsXFormsSelectComboboxAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XFormsItemCombobox:
-      *aAccessible = new nsXFormsItemComboboxAccessible(aNode, weakShell);
+      accessible = new nsXFormsItemComboboxAccessible(aNode, aWeakShell);
       break;
 
     case nsIAccessibleProvider::XFormsDropmarkerWidget:
-      *aAccessible = new nsXFormsDropmarkerWidgetAccessible(aNode, weakShell);
+      accessible = new nsXFormsDropmarkerWidgetAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XFormsCalendarWidget:
-      *aAccessible = new nsXFormsCalendarWidgetAccessible(aNode, weakShell);
+      accessible = new nsXFormsCalendarWidgetAccessible(aNode, aWeakShell);
       break;
     case nsIAccessibleProvider::XFormsComboboxPopupWidget:
-      *aAccessible = new nsXFormsComboboxPopupWidgetAccessible(aNode, weakShell);
+      accessible = new nsXFormsComboboxPopupWidgetAccessible(aNode, aWeakShell);
       break;
 #endif
 
     default:
-      return NS_ERROR_FAILURE;
+      return nsnull;
   }
 
-  if (!*aAccessible)
-    return NS_ERROR_OUT_OF_MEMORY;
+  return accessible.forget();
+}
 
-  NS_ADDREF(*aAccessible);
-  return NS_OK;
-}
+////////////////////////////////////////////////////////////////////////////////
+// nsIAccessibilityService (DON'T put methods here)
 
 NS_IMETHODIMP nsAccessibilityService::AddNativeRootAccessible(void * aAtkAccessible,  nsIAccessible **aRootAccessible)
 {
 #ifdef MOZ_ACCESSIBILITY_ATK
   nsNativeRootAccessibleWrap* rootAccWrap =
     new nsNativeRootAccessibleWrap((AtkObject*)aAtkAccessible);
 
   *aRootAccessible = static_cast<nsIAccessible*>(rootAccWrap);
@@ -2028,18 +2041,19 @@ nsAccessibilityService::InvalidateSubtre
   nsRefPtr<nsDocAccessible> docAcc =
     nsAccUtils::QueryAccessibleDocument(accessibleDoc);
   if (docAcc)
     docAcc->InvalidateCacheSubtree(aChangeContent, aChangeType);
 
   return NS_OK;
 }
 
-//////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+// NS_GetAccessibilityService
+////////////////////////////////////////////////////////////////////////////////
 
 /**
  * Return accessibility service; creating one if necessary.
  */
 nsresult
 NS_GetAccessibilityService(nsIAccessibilityService** aResult)
 {
    NS_ENSURE_TRUE(aResult, NS_ERROR_NULL_POINTER);
@@ -2051,81 +2065,68 @@ NS_GetAccessibilityService(nsIAccessibil
  
     nsAccessibilityService::gIsShutdown = PR_FALSE;
    }
  
   NS_ADDREF(*aResult = nsAccessibilityService::gAccessibilityService);
   return NS_OK;
 }
 
-nsresult
-nsAccessibilityService::GetAccessibleForDeckChildren(nsIDOMNode *aNode, nsIAccessible** aAccessible)
+////////////////////////////////////////////////////////////////////////////////
+// nsAccessibilityService private (DON'T put methods here)
+
+already_AddRefed<nsAccessible>
+nsAccessibilityService::CreateAccessibleForDeckChild(nsIFrame* aFrame,
+                                                     nsIDOMNode *aNode,
+                                                     nsIWeakReference *aWeakShell)
 {
-  nsCOMPtr<nsIWeakReference> weakShell;
-  GetShellFromNode(aNode, getter_AddRefs(weakShell));
-  NS_ENSURE_TRUE(weakShell, NS_ERROR_FAILURE);
-  nsCOMPtr<nsIPresShell> shell(do_QueryReferent(weakShell));
-  NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE);
-  
-  nsIFrame* frame = nsnull;
-  nsIFrame* parentFrame = nsnull;
-  nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
+  nsRefPtr<nsAccessible> accessible;
 
-  if (content) {
-    frame = content->GetPrimaryFrame();
-  }
+  if (aFrame->GetType() == nsAccessibilityAtoms::boxFrame ||
+      aFrame->GetType() == nsAccessibilityAtoms::scrollFrame) {
 
-  if (frame && (frame->GetType() == nsAccessibilityAtoms::boxFrame ||
-                frame->GetType() == nsAccessibilityAtoms::scrollFrame)) { 
-    parentFrame = frame->GetParent();
+    nsIFrame* parentFrame = aFrame->GetParent();
     if (parentFrame && parentFrame->GetType() == nsAccessibilityAtoms::deckFrame) {
       // If deck frame is for xul:tabpanels element then the given node has
       // tabpanel accessible.
       nsCOMPtr<nsIContent> parentContent = parentFrame->GetContent();
 #ifdef MOZ_XUL
       if (parentContent->NodeInfo()->Equals(nsAccessibilityAtoms::tabpanels,
                                             kNameSpaceID_XUL)) {
-        *aAccessible = new nsXULTabpanelAccessible(aNode, weakShell);
+        accessible = new nsXULTabpanelAccessible(aNode, aWeakShell);
       } else
 #endif
-        *aAccessible =
-          new nsEnumRoleAccessible(aNode, weakShell,
+        accessible =
+          new nsEnumRoleAccessible(aNode, aWeakShell,
                                    nsIAccessibleRole::ROLE_PROPERTYPAGE);
-
-      NS_ENSURE_TRUE(*aAccessible, NS_ERROR_OUT_OF_MEMORY);
-
-      NS_ADDREF(*aAccessible);
     }
   }
 
-  return NS_OK;
+  return accessible.forget();
 }
 
 #ifdef MOZ_XUL
-nsresult
-nsAccessibilityService::GetAccessibleForXULTree(nsIDOMNode *aNode,
-                                                nsIWeakReference *aWeakShell,
-                                                nsIAccessible **aAccessible)
+already_AddRefed<nsAccessible>
+nsAccessibilityService::CreateAccessibleForXULTree(nsIDOMNode *aNode,
+                                                   nsIWeakReference *aWeakShell)
 {
   nsCOMPtr<nsITreeBoxObject> treeBoxObj;
   nsCoreUtils::GetTreeBoxObject(aNode, getter_AddRefs(treeBoxObj));
   if (!treeBoxObj)
-    return NS_ERROR_FAILURE;
+    return nsnull;
 
   nsCOMPtr<nsITreeColumns> treeColumns;
   treeBoxObj->GetColumns(getter_AddRefs(treeColumns));
   if (!treeColumns)
-    return NS_OK;
+    return nsnull;
+
+  nsRefPtr<nsAccessible> accessible;
 
   PRInt32 count = 0;
   treeColumns->GetCount(&count);
   if (count == 1) // outline of list accessible
-    *aAccessible = new nsXULTreeAccessible(aNode, aWeakShell);
+    accessible = new nsXULTreeAccessible(aNode, aWeakShell);
   else // table or tree table accessible
-    *aAccessible = new nsXULTreeGridAccessibleWrap(aNode, aWeakShell);
+    accessible = new nsXULTreeGridAccessibleWrap(aNode, aWeakShell);
 
-  if (!*aAccessible)
-    return NS_ERROR_OUT_OF_MEMORY;
-
-  NS_ADDREF(*aAccessible);
-  return NS_OK;
+  return accessible.forget();
 }
 #endif
--- a/accessible/src/base/nsAccessibilityService.h
+++ b/accessible/src/base/nsAccessibilityService.h
@@ -44,16 +44,18 @@
 #include "nsCoreUtils.h"
 
 #include "nsCOMArray.h"
 #include "nsIObserver.h"
 #include "nsIWebProgress.h"
 #include "nsIWebProgressListener.h"
 #include "nsWeakReference.h"
 
+class nsAccessNode;
+class nsAccessible;
 class nsIFrame;
 class nsIWeakReference;
 class nsIDOMNode;
 class nsObjectFrame;
 class nsIDocShell;
 class nsIPresShell;
 class nsIContent;
 struct nsRoleMapEntry;
@@ -87,34 +89,45 @@ public:
   static PRBool gIsShutdown;
 
   /**
    * Return an accessible for the given DOM node.
    *
    * @param  aNode       [in] the given node
    * @param  aPresShell  [in] the pres shell of the node
    * @param  aWeakShell  [in] the weak shell for the pres shell
-   * @param  aFrameHint  [in] the frame of the given node
-   * @param  aIsHidden   [out] indicates whether the node's frame is hidden
+   * @param  aIsHidden   [out, optional] indicates whether the node's frame is
+   *                       hidden
    */
-  nsresult GetAccessible(nsIDOMNode *aNode, nsIPresShell *aPresShell,
-                         nsIWeakReference *aWeakShell, nsIFrame *aFrameHint,
-                         PRBool *aIsHidden, nsIAccessible **aAccessible);
+  already_AddRefed<nsAccessible>
+    GetAccessible(nsIDOMNode *aNode, nsIPresShell *aPresShell,
+                  nsIWeakReference *aWeakShell, PRBool *aIsHidden = nsnull);
 
   /**
    * Return an accessible for a DOM node in the given pres shell.
    * 
    * @param aNode       [in] the given node.
    * @param aPresShell  [in] the presentation shell of the given node.
    * @param aAccessible [out] the nsIAccessible for the given node.
    */
   nsresult GetAccessibleInWeakShell(nsIDOMNode *aNode,
                                     nsIWeakReference *aPresShell,
                                     nsIAccessible **aAccessible);
 
+  /**
+   * Return an access node for the DOM node in the given presentation shell if
+   * the access node already exists, otherwise null.
+   *
+   * @param  aNode       [in] the DOM node to get an access node for
+   * @param  aPresShell  [in] the presentation shell which contains layout info
+   *                       for the DOM node
+   */
+  nsAccessNode* GetCachedAccessNode(nsIDOMNode *aNode,
+                                    nsIWeakReference *aShell);
+
 private:
   /**
    * Return presentation shell, DOM node for the given frame.
    *
    * @param aFrame - the given frame
    * @param aShell [out] - presentation shell for DOM node associated with the
    *                 given frame
    * @param aContent [out] - DOM node associated with the given frame
@@ -122,48 +135,58 @@ private:
   nsresult GetInfo(nsIFrame *aFrame,
                    nsIWeakReference **aShell,
                    nsIDOMNode **aContent);
 
   /**
    * Initialize an accessible and cache it. The method should be called for
    * every created accessible.
    *
-   * @param aAccessibleIn - accessible to initialize.
-   * @param aAcccessibleOut - set to the same thing as aAccessibleIn, unless there was
-   *                          an error initializing the accessible, in which case
-   *                          it is set to nsnull
-   * @param aRoleMapEntry - The role map entry role the ARIA role or nsnull if none
+   * @param  aAccessible    [in] accessible to initialize.
+   * @param  aRoleMapEntry  [in] the role map entry role the ARIA role or nsnull
+   *                          if none
+   *
+   * @return true if the accessible was initialized, otherwise false
    */
-  nsresult InitAccessible(nsIAccessible *aAccessibleIn, nsIAccessible **aAccessibleOut,
-                          nsRoleMapEntry *aRoleMapEntry = nsnull);
+  PRBool InitAccessible(nsAccessible *aAccessible,
+                        nsRoleMapEntry *aRoleMapEntry);
+
+  /**
+   * Create accessible for the element implementing nsIAccessibleProvider
+   * interface.
+   */
+  already_AddRefed<nsAccessible>
+    CreateAccessibleByType(nsIDOMNode *aNode, nsIWeakReference *aWeakShell);
 
   /**
-   * Return accessible object for elements implementing nsIAccessibleProvider
-   * interface.
-   *
-   * @param aNode - DOM node that accessible is returned for.
+   * Create document or root accessible.
    */
-  nsresult GetAccessibleByType(nsIDOMNode *aNode, nsIAccessible **aAccessible);
+  already_AddRefed<nsAccessible>
+    CreateDocOrRootAccessible(nsIPresShell *aShell, nsIDocument *aDocument);
 
   /**
-   * Return accessible object if parent is a deck frame.
-   *
-   * @param aNode - DOMNode that accessible is returned for.
+   * Create accessible for HTML node by tag name.
    */
-  nsresult GetAccessibleForDeckChildren(nsIDOMNode *aNode,
-                                        nsIAccessible **aAccessible);
+  already_AddRefed<nsAccessible>
+    CreateHTMLAccessibleByMarkup(nsIFrame *aFrame, nsIWeakReference *aWeakShell,
+                                 nsIDOMNode *aNode);
+
+  /**
+   * Create accessible if parent is a deck frame.
+   */
+  already_AddRefed<nsAccessible>
+    CreateAccessibleForDeckChild(nsIFrame *aFrame, nsIDOMNode *aNode,
+                                 nsIWeakReference *aWeakShell);
 
 #ifdef MOZ_XUL
   /**
    * Create accessible for XUL tree element.
    */
-  nsresult GetAccessibleForXULTree(nsIDOMNode *aNode,
-                                   nsIWeakReference *aWeakShell,
-                                   nsIAccessible **aAccessible);
+  already_AddRefed<nsAccessible>
+    CreateAccessibleForXULTree(nsIDOMNode *aNode, nsIWeakReference *aWeakShell);
 #endif
   
   static nsAccessibilityService *gAccessibilityService;
 
   /**
    * Does this content node have a universal ARIA property set on it?
    * A universal ARIA property is one that can be defined on any element even if there is no role.
    *
--- a/accessible/src/base/nsAccessible.cpp
+++ b/accessible/src/base/nsAccessible.cpp
@@ -39,17 +39,17 @@
 
 #include "nsAccessible.h"
 #include "nsAccessibleRelation.h"
 #include "nsHyperTextAccessibleWrap.h"
 
 #include "nsIAccessibleDocument.h"
 #include "nsIAccessibleHyperText.h"
 #include "nsIXBLAccessible.h"
-#include "nsAccessibleTreeWalker.h"
+#include "nsAccTreeWalker.h"
 
 #include "nsIDOMElement.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMDocumentXBL.h"
 #include "nsIDOMDocumentTraversal.h"
 #include "nsIDOMHTMLDocument.h"
 #include "nsIDOMHTMLFormElement.h"
 #include "nsIDOMNodeFilter.h"
@@ -2982,35 +2982,23 @@ nsAccessible::GetCachedFirstChild()
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsAccessible protected methods
 
 void
 nsAccessible::CacheChildren()
 {
-  PRBool allowsAnonChildren = GetAllowsAnonChildAccessibles();
-  nsAccessibleTreeWalker walker(mWeakShell, mDOMNode, allowsAnonChildren);
-
-  // Seed the frame hint early while we're still on a container node.
-  // This is better than doing the GetPrimaryFrameFor() later on
-  // a text node, because text nodes aren't in the frame map.
-  // XXXbz is this code still needed?
-  walker.mState.frame = GetFrame();
-
-  walker.GetFirstChild();
-  while (walker.mState.accessible) {
-    nsRefPtr<nsAccessible> acc =
-      nsAccUtils::QueryObject<nsAccessible>(walker.mState.accessible);
-
-    mChildren.AppendElement(acc);
-
-    acc->SetParent(this);
-
-    walker.GetNextSibling();
+  nsAccTreeWalker walker(mWeakShell, nsCoreUtils::GetRoleContent(mDOMNode),
+                         GetAllowsAnonChildAccessibles());
+
+  nsRefPtr<nsAccessible> child;
+  while ((child = walker.GetNextChild())) {
+    mChildren.AppendElement(child);
+    child->SetParent(this);
   }
 }
 
 void
 nsAccessible::TestChildCache(nsAccessible *aCachedChild)
 {
 #ifdef DEBUG
   // All cached accessible nodes should be in the parent
--- a/accessible/src/base/nsDocAccessible.cpp
+++ b/accessible/src/base/nsDocAccessible.cpp
@@ -130,19 +130,19 @@ nsDocAccessible::nsDocAccessible(nsIDOMN
 nsDocAccessible::~nsDocAccessible()
 {
 }
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsISupports
 
+// Callback used when traversing the cache by cycle collector.
 static PLDHashOperator
-ElementTraverser(const void *aKey, nsIAccessNode *aAccessNode,
-                 void *aUserArg)
+ElementTraverser(const void *aKey, nsAccessNode *aAccessNode, void *aUserArg)
 {
   nsCycleCollectionTraversalCallback *cb = 
     static_cast<nsCycleCollectionTraversalCallback*>(aUserArg);
 
   NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb, "mAccessNodeCache entry");
   cb->NoteXPCOMChild(aAccessNode);
   return PL_DHASH_NEXT;
 }
@@ -534,52 +534,59 @@ NS_IMETHODIMP nsDocAccessible::GetAssoci
   PRBool isEditable;
   editor->GetIsDocumentEditable(&isEditable);
   if (isEditable) {
     NS_ADDREF(*aEditor = editor);
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP nsDocAccessible::GetCachedAccessNode(void *aUniqueID, nsIAccessNode **aAccessNode)
+nsAccessNode*
+nsDocAccessible::GetCachedAccessNode(void *aUniqueID)
 {
-  GetCacheEntry(mAccessNodeCache, aUniqueID, aAccessNode); // Addrefs for us
+  nsAccessNode* accessNode = mAccessNodeCache.GetWeak(aUniqueID);
+
+  // No accessible in the cache, check if the given ID is unique ID of this
+  // document accesible.
+  if (!accessNode) {
+    void* thisUniqueID = nsnull;
+    GetUniqueID(&thisUniqueID);
+    if (thisUniqueID == aUniqueID)
+      accessNode = this;
+  }
+
 #ifdef DEBUG
   // All cached accessible nodes should be in the parent
   // It will assert if not all the children were created
   // when they were first cached, and no invalidation
   // ever corrected parent accessible's child cache.
   nsRefPtr<nsAccessible> acc =
-    nsAccUtils::QueryObject<nsAccessible>(*aAccessNode);
+    nsAccUtils::QueryObject<nsAccessible>(accessNode);
 
   if (acc) {
     nsAccessible* parent(acc->GetCachedParent());
     if (parent)
       parent->TestChildCache(acc);
   }
 #endif
-  return NS_OK;
+
+  return accessNode;
 }
 
 // nsDocAccessible public method
-void
-nsDocAccessible::CacheAccessNode(void *aUniqueID, nsIAccessNode *aAccessNode)
+PRBool
+nsDocAccessible::CacheAccessNode(void *aUniqueID, nsAccessNode *aAccessNode)
 {
-  // If there is an access node for the given unique ID then let's shutdown it.
-  // The unique ID may be presented in the cache if originally we created
-  // access node object and then we want to create accessible object when
-  // DOM node is changed.
-  nsCOMPtr<nsIAccessNode> accessNode;
-  GetCacheEntry(mAccessNodeCache, aUniqueID, getter_AddRefs(accessNode));
-  if (accessNode) {
-    nsRefPtr<nsAccessNode> accNode = nsAccUtils::QueryAccessNode(accessNode);
-    accNode->Shutdown();
-  }
+  // If there is already an access node with the given unique ID, shut it down
+  // because the DOM node has changed.
+  nsAccessNode* accessNode = mAccessNodeCache.GetWeak(aUniqueID);
+  if (accessNode)
+    accessNode->Shutdown();
 
-  PutCacheEntry(mAccessNodeCache, aUniqueID, aAccessNode);
+  return mAccessNodeCache.Put(aUniqueID, aAccessNode);
 }
 
 // nsDocAccessible public method
 void
 nsDocAccessible::RemoveAccessNodeFromCache(nsIAccessNode *aAccessNode)
 {
   if (!aAccessNode)
     return;
@@ -590,33 +597,36 @@ nsDocAccessible::RemoveAccessNodeFromCac
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsAccessNode
 
 nsresult
 nsDocAccessible::Init()
 {
-  PutCacheEntry(gGlobalDocAccessibleCache, mDocument, this);
+  // Put the document into the global cache.
+  if (!gGlobalDocAccessibleCache.Put(static_cast<void*>(mDocument), this))
+    return NS_ERROR_OUT_OF_MEMORY;
+
+  // Initialize event queue.
+  mEventQueue = new nsAccEventQueue(this);
+  if (!mEventQueue)
+    return NS_ERROR_OUT_OF_MEMORY;
 
   AddEventListeners();
 
-  GetParent(); // Ensure outer doc mParent accessible.
-
-  nsresult rv = nsHyperTextAccessibleWrap::Init();
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // Initialize event queue.
-  mEventQueue = new nsAccEventQueue(this);
+  // Ensure outer doc mParent accessible.
+  GetParent();
 
   // Fire reorder event to notify new accessible document has been created and
   // attached to the tree.
   nsRefPtr<nsAccEvent> reorderEvent =
     new nsAccReorderEvent(mParent, PR_FALSE, PR_TRUE, mDOMNode);
-  NS_ENSURE_TRUE(reorderEvent, NS_ERROR_OUT_OF_MEMORY);
+  if (!reorderEvent)
+    return NS_ERROR_OUT_OF_MEMORY;
 
   FireDelayedAccessibleEvent(reorderEvent);
   return NS_OK;
 }
 
 nsresult
 nsDocAccessible::Shutdown()
 {
@@ -1758,19 +1768,18 @@ nsDocAccessible::ProcessPendingEvent(nsA
         }
       }
     }
   }
 }
 
 void nsDocAccessible::InvalidateChildrenInSubtree(nsIDOMNode *aStartNode)
 {
-  nsCOMPtr<nsIAccessNode> accessNode;
-  GetCachedAccessNode(aStartNode, getter_AddRefs(accessNode));
-  nsRefPtr<nsAccessible> acc(nsAccUtils::QueryAccessible(accessNode));
+  nsRefPtr<nsAccessible> acc =
+    nsAccUtils::QueryObject<nsAccessible>(GetCachedAccessNode(aStartNode));
   if (acc)
     acc->InvalidateChildren();
 
   // Invalidate accessible children in the DOM subtree 
   nsCOMPtr<nsINode> node = do_QueryInterface(aStartNode);
   PRInt32 index, numChildren = node->GetChildCount();
   for (index = 0; index < numChildren; index ++) {
     nsCOMPtr<nsIDOMNode> childNode = do_QueryInterface(node->GetChildAt(index));
@@ -1780,41 +1789,40 @@ void nsDocAccessible::InvalidateChildren
 }
 
 void nsDocAccessible::RefreshNodes(nsIDOMNode *aStartNode)
 {
   if (mAccessNodeCache.Count() <= 1) {
     return; // All we have is a doc accessible. There is nothing to invalidate, quit early
   }
 
-  nsCOMPtr<nsIAccessNode> accessNode;
-  GetCachedAccessNode(aStartNode, getter_AddRefs(accessNode));
+  nsRefPtr<nsAccessNode> accessNode = GetCachedAccessNode(aStartNode);
 
   // Shut down accessible subtree, which may have been created for
   // anonymous content subtree
-  nsCOMPtr<nsIAccessible> accessible(do_QueryInterface(accessNode));
+  nsRefPtr<nsAccessible> accessible =
+    nsAccUtils::QueryObject<nsAccessible>(accessNode);
   if (accessible) {
     // Fire menupopup end if a menu goes away
     PRUint32 role = nsAccUtils::Role(accessible);
     if (role == nsIAccessibleRole::ROLE_MENUPOPUP) {
       nsCOMPtr<nsIDOMNode> domNode;
       accessNode->GetDOMNode(getter_AddRefs(domNode));
       nsCOMPtr<nsIDOMXULPopupElement> popup(do_QueryInterface(domNode));
       if (!popup) {
         // Popup elements already fire these via DOMMenuInactive
         // handling in nsRootAccessible::HandleEvent
         nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_END,
                                 accessible);
       }
     }
-    nsRefPtr<nsAccessible> acc = nsAccUtils::QueryAccessible(accessible);
 
     // We only need to shutdown the accessibles here if one of them has been
     // created.
-    if (acc->GetCachedFirstChild()) {
+    if (accessible->GetCachedFirstChild()) {
       nsCOMPtr<nsIArray> children;
       // use GetChildren() to fetch children at one time, instead of using
       // GetNextSibling(), because after we shutdown the first child,
       // mNextSibling will be set null.
       accessible->GetChildren(getter_AddRefs(children));
       PRUint32 childCount =0;
       if (children)
         children->GetLength(&childCount);
@@ -1855,18 +1863,17 @@ void nsDocAccessible::RefreshNodes(nsIDO
     // all pointers to them are correct
     InvalidateChildren();
     return;
   }
 
   // Shut down the actual accessible or access node
   void *uniqueID;
   accessNode->GetUniqueID(&uniqueID);
-  nsRefPtr<nsAccessNode> accNode = nsAccUtils::QueryAccessNode(accessNode);
-  accNode->Shutdown();
+  accessNode->Shutdown();
 
   // Remove from hash table as well
   mAccessNodeCache.Remove(uniqueID);
 }
 
 // nsDocAccessible public member
 void
 nsDocAccessible::InvalidateCacheSubtree(nsIContent *aChild,
@@ -1937,18 +1944,17 @@ nsDocAccessible::InvalidateCacheSubtree(
       return;
     }     
     // else: user input, so we must fall through and for full handling,
     // e.g. fire the mutation events. Note: user input could cause DOM_CREATE
     // during page load if user typed into an input field or contentEditable area
   }
 
   // Update last change state information
-  nsCOMPtr<nsIAccessNode> childAccessNode;
-  GetCachedAccessNode(childNode, getter_AddRefs(childAccessNode));
+  nsCOMPtr<nsIAccessNode> childAccessNode = GetCachedAccessNode(childNode);
   nsCOMPtr<nsIAccessible> childAccessible = do_QueryInterface(childAccessNode);
 
 #ifdef DEBUG_A11Y
   nsAutoString localName;
   childNode->GetLocalName(localName);
   const char *hasAccessible = childAccessible ? " (acc)" : "";
   if (aChangeType == nsIAccessibilityService::FRAME_HIDE)
     printf("[Hide %s %s]\n", NS_ConvertUTF16toUTF8(localName).get(), hasAccessible);
@@ -1991,17 +1997,18 @@ nsDocAccessible::InvalidateCacheSubtree(
     }
 
     // Fire an event if the accessible existed for node being hidden, otherwise
     // for the first line accessible descendants. Fire before the accessible(s)
     // away.
     nsresult rv = FireShowHideEvents(childNode, PR_FALSE,
                                      nsIAccessibleEvent::EVENT_HIDE,
                                      eDelayedEvent, isAsynch);
-    NS_ENSURE_SUCCESS(rv,);
+    if (NS_FAILED(rv))
+      return;
 
     if (childNode != mDOMNode) { // Fire text change unless the node being removed is for this doc
       // When a node is hidden or removed, the text in an ancestor hyper text will lose characters
       // At this point we still have the frame and accessible for this node if there was one
       // XXX Collate events when a range is deleted
       // XXX We need a way to ignore SplitNode and JoinNode() when they
       // do not affect the text within the hypertext
       nsRefPtr<nsAccEvent> textChangeEvent =
@@ -2119,21 +2126,19 @@ nsDocAccessible::GetAccessibleInParentCh
     if (NS_SUCCEEDED(GetAccService()->GetRelevantContentNodeFor(currentNode, getter_AddRefs(relevantNode))) && relevantNode) {
       currentNode = relevantNode;
     }
     if (aCanCreate) {
       GetAccService()->GetAccessibleInWeakShell(currentNode, mWeakShell, 
                                                 aAccessible);
     }
     else { // Only return cached accessibles, don't create anything
-      nsCOMPtr<nsIAccessNode> accessNode;
-      GetCachedAccessNode(currentNode, getter_AddRefs(accessNode)); // AddRefs
-      if (accessNode) {
-        CallQueryInterface(accessNode, aAccessible); // AddRefs
-      }
+      nsAccessNode* accessNode = GetCachedAccessNode(currentNode);
+      if (accessNode)
+        CallQueryInterface(accessNode, aAccessible);
     }
   } while (!*aAccessible);
 
   return NS_OK;
 }
 
 nsresult
 nsDocAccessible::FireShowHideEvents(nsIDOMNode *aDOMNode,
@@ -2144,19 +2149,17 @@ nsDocAccessible::FireShowHideEvents(nsID
                                     EIsFromUserInput aIsFromUserInput)
 {
   NS_ENSURE_ARG(aDOMNode);
 
   nsCOMPtr<nsIAccessible> accessible;
   if (!aAvoidOnThisNode) {
     if (aEventType == nsIAccessibleEvent::EVENT_HIDE) {
       // Don't allow creation for accessibles when nodes going away
-      nsCOMPtr<nsIAccessNode> accessNode;
-      GetCachedAccessNode(aDOMNode, getter_AddRefs(accessNode));
-      accessible = do_QueryInterface(accessNode);
+      accessible = do_QueryInterface(GetCachedAccessNode(aDOMNode));
     } else {
       // Allow creation of new accessibles for show events
       GetAccService()->GetAttachedAccessibleFor(aDOMNode,
                                                 getter_AddRefs(accessible));
     }
   }
 
   if (accessible) {
--- a/accessible/src/base/nsDocAccessible.h
+++ b/accessible/src/base/nsDocAccessible.h
@@ -146,22 +146,36 @@ public:
    *
    * @param aContent  [in] the child that is changing
    * @param aEvent    [in] the event from nsIAccessibleEvent that caused
    *                   the change.
    */
   void InvalidateCacheSubtree(nsIContent *aContent, PRUint32 aEvent);
 
   /**
-   * Cache access node.
+   * Return the cached access node by the given unique ID if it's in subtree of
+   * this document accessible or the document accessible itself, otherwise null.
+   *
+   * @note   the unique ID matches with the uniqueID attribute on nsIAccessNode
+   *
+   * @param  aUniqueID  [in] the unique ID used to cache the node.
+   *
+   * @return the access node object
+   */
+  nsAccessNode* GetCachedAccessNode(void *aUniqueID);
+
+  /**
+   * Cache the access node.
    *
    * @param  aUniquID     [in] the unique identifier of accessible
    * @param  aAccessNode  [in] accessible to cache
+   *
+   * @return true if node beign cached, otherwise false
    */
-  void CacheAccessNode(void *aUniqueID, nsIAccessNode *aAccessNode);
+  PRBool CacheAccessNode(void *aUniqueID, nsAccessNode *aAccessNode);
 
   /**
    * Remove the given access node from document cache.
    */
   void RemoveAccessNodeFromCache(nsIAccessNode *aAccessNode);
 
   /**
    * Fire document load events.
--- a/accessible/src/html/nsHTMLFormControlAccessible.cpp
+++ b/accessible/src/html/nsHTMLFormControlAccessible.cpp
@@ -32,17 +32,16 @@
  * 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 ***** */
 
 // NOTE: alphabetically ordered
-#include "nsAccessibleTreeWalker.h"
 #include "nsAccessibilityAtoms.h"
 #include "nsHTMLFormControlAccessible.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMNSHTMLInputElement.h"
 #include "nsIDOMHTMLInputElement.h"
 #include "nsIDOMNSHTMLElement.h"
 #include "nsIDOMNSEditableElement.h"
 #include "nsIDOMNSHTMLButtonElement.h"
--- a/accessible/src/html/nsHTMLImageAccessible.cpp
+++ b/accessible/src/html/nsHTMLImageAccessible.cpp
@@ -380,38 +380,34 @@ nsHTMLImageAccessible::GetAreaAccessible
 {
   if (!aAreaCollection)
     return nsnull;
 
   nsCOMPtr<nsIDOMNode> domNode;
   aAreaCollection->Item(aAreaNum,getter_AddRefs(domNode));
   if (!domNode)
     return nsnull;
-  
-  nsCOMPtr<nsIAccessNode> accessNode;
-  GetCacheEntry(*mAccessNodeCache, (void*)(aAreaNum),
-                getter_AddRefs(accessNode));
-  
+
+  void* key = reinterpret_cast<void*>(aAreaNum);
+  nsRefPtr<nsAccessNode> accessNode = mAccessNodeCache->GetWeak(key);
+
   if (!accessNode) {
     accessNode = new nsHTMLAreaAccessible(domNode, this, mWeakShell);
     if (!accessNode)
       return nsnull;
-    
-    nsRefPtr<nsAccessNode> accNode = nsAccUtils::QueryAccessNode(accessNode);
-    nsresult rv = accNode->Init();
+
+    nsresult rv = accessNode->Init();
     if (NS_FAILED(rv))
       return nsnull;
-    
-    PutCacheEntry(*mAccessNodeCache, (void*)(aAreaNum), accessNode);
+
+    mAccessNodeCache->Put(key, accessNode);
   }
 
-  nsIAccessible *accessible = nsnull;
-  CallQueryInterface(accessNode, &accessible);
-
-  return accessible;
+  nsCOMPtr<nsIAccessible> accessible = do_QueryInterface(accessNode);
+  return accessible.forget();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // Private methods
 
 PRBool
 nsHTMLImageAccessible::HasLongDesc()
 {
--- a/accessible/src/html/nsHTMLSelectAccessible.h
+++ b/accessible/src/html/nsHTMLSelectAccessible.h
@@ -40,17 +40,16 @@
 #define __nsHTMLSelectAccessible_h__
 
 #include "nsIAccessibleSelectable.h"
 #include "nsAccessibilityAtoms.h"
 #include "nsHTMLFormControlAccessible.h"
 #include "nsIDOMHTMLOptionsCollection.h"
 #include "nsIDOMHTMLOptionElement.h"
 #include "nsIDOMNode.h"
-#include "nsAccessibleTreeWalker.h"
 
 class nsIMutableArray;
 
 /**
   *  Selects, Listboxes and Comboboxes, are made up of a number of different
   *  widgets, some of which are shared between the two. This file contains
 	*  all of the widgets for both of the Selects, for HTML only.
   *
--- a/accessible/src/html/nsHTMLTableAccessible.cpp
+++ b/accessible/src/html/nsHTMLTableAccessible.cpp
@@ -34,17 +34,16 @@
  * 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 ***** */
 
 #include "nsHTMLTableAccessible.h"
 #include "nsAccessibilityAtoms.h"
-#include "nsAccessibleTreeWalker.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMDocumentRange.h"
 #include "nsIDOMRange.h"
 #include "nsISelection2.h"
 #include "nsISelectionPrivate.h"
 #include "nsINameSpaceManager.h"
 #include "nsIAccessibilityService.h"
--- a/accessible/src/html/nsHTMLTextAccessible.cpp
+++ b/accessible/src/html/nsHTMLTextAccessible.cpp
@@ -33,17 +33,16 @@
  * 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 ***** */
 
 #include "nsHTMLTextAccessible.h"
-#include "nsAccessibleTreeWalker.h"
 #include "nsIAccessibleDocument.h"
 #include "nsIAccessibleEvent.h"
 #include "nsIFrame.h"
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsISelection.h"
 #include "nsISelectionController.h"
 #include "nsComponentManagerUtils.h"
--- a/accessible/src/html/nsHyperTextAccessible.cpp
+++ b/accessible/src/html/nsHyperTextAccessible.cpp
@@ -35,17 +35,16 @@
  * 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 ***** */
 
 #include "nsHyperTextAccessible.h"
 #include "nsAccessibilityAtoms.h"
 #include "nsAccessibilityService.h"
-#include "nsAccessibleTreeWalker.h"
 #include "nsTextAttrs.h"
 
 #include "nsIClipboard.h"
 #include "nsContentCID.h"
 #include "nsIDOMAbstractView.h"
 #include "nsIDOMCharacterData.h"
 #include "nsIDOMDocument.h"
 #include "nsPIDOMWindow.h"        
@@ -1408,66 +1407,81 @@ NS_IMETHODIMP nsHyperTextAccessible::Set
   PRInt32 numChars;
   GetCharacterCount(&numChars);
   if (numChars == 0 || NS_SUCCEEDED(DeleteText(0, numChars))) {
     return InsertText(aText, 0);
   }
   return NS_ERROR_FAILURE;
 }
 
-NS_IMETHODIMP nsHyperTextAccessible::InsertText(const nsAString &aText, PRInt32 aPosition)
+NS_IMETHODIMP
+nsHyperTextAccessible::InsertText(const nsAString &aText, PRInt32 aPosition)
 {
-  if (NS_SUCCEEDED(SetCaretOffset(aPosition))) {
-    nsCOMPtr<nsIEditor> editor;
-    GetAssociatedEditor(getter_AddRefs(editor));
-    nsCOMPtr<nsIPlaintextEditor> peditor(do_QueryInterface(editor));
-    return peditor ? peditor->InsertText(aText) : NS_ERROR_FAILURE;
-  }
+  nsCOMPtr<nsIEditor> editor;
+  GetAssociatedEditor(getter_AddRefs(editor));
 
-  return NS_ERROR_FAILURE;
+  nsCOMPtr<nsIPlaintextEditor> peditor(do_QueryInterface(editor));
+  NS_ENSURE_STATE(peditor);
+
+  nsresult rv = SetSelectionRange(aPosition, aPosition);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  return peditor->InsertText(aText);
 }
 
-NS_IMETHODIMP nsHyperTextAccessible::CopyText(PRInt32 aStartPos, PRInt32 aEndPos)
+NS_IMETHODIMP
+nsHyperTextAccessible::CopyText(PRInt32 aStartPos, PRInt32 aEndPos)
+{
+  nsCOMPtr<nsIEditor> editor;
+  GetAssociatedEditor(getter_AddRefs(editor));
+  NS_ENSURE_STATE(editor);
+
+  nsresult rv = SetSelectionRange(aStartPos, aEndPos);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  return editor->Copy();
+}
+
+NS_IMETHODIMP
+nsHyperTextAccessible::CutText(PRInt32 aStartPos, PRInt32 aEndPos)
 {
   nsCOMPtr<nsIEditor> editor;
   GetAssociatedEditor(getter_AddRefs(editor));
-  if (editor && NS_SUCCEEDED(SetSelectionRange(aStartPos, aEndPos)))
-    return editor->Copy();
+  NS_ENSURE_STATE(editor);
 
-  return NS_ERROR_FAILURE;
+  nsresult rv = SetSelectionRange(aStartPos, aEndPos);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  return editor->Cut();
 }
 
-NS_IMETHODIMP nsHyperTextAccessible::CutText(PRInt32 aStartPos, PRInt32 aEndPos)
+NS_IMETHODIMP
+nsHyperTextAccessible::DeleteText(PRInt32 aStartPos, PRInt32 aEndPos)
 {
   nsCOMPtr<nsIEditor> editor;
   GetAssociatedEditor(getter_AddRefs(editor));
-  if (editor && NS_SUCCEEDED(SetSelectionRange(aStartPos, aEndPos)))
-    return editor->Cut();
+  NS_ENSURE_STATE(editor);
 
-  return NS_ERROR_FAILURE;
+  nsresult rv = SetSelectionRange(aStartPos, aEndPos);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  return editor->DeleteSelection(nsIEditor::eNone);
 }
 
-NS_IMETHODIMP nsHyperTextAccessible::DeleteText(PRInt32 aStartPos, PRInt32 aEndPos)
+NS_IMETHODIMP
+nsHyperTextAccessible::PasteText(PRInt32 aPosition)
 {
   nsCOMPtr<nsIEditor> editor;
   GetAssociatedEditor(getter_AddRefs(editor));
-  if (editor && NS_SUCCEEDED(SetSelectionRange(aStartPos, aEndPos)))
-    return editor->DeleteSelection(nsIEditor::eNone);
-
-  return NS_ERROR_FAILURE;
-}
+  NS_ENSURE_STATE(editor);
 
-NS_IMETHODIMP nsHyperTextAccessible::PasteText(PRInt32 aPosition)
-{
-  nsCOMPtr<nsIEditor> editor;
-  GetAssociatedEditor(getter_AddRefs(editor));
-  if (editor && NS_SUCCEEDED(SetCaretOffset(aPosition)))
-    return editor->Paste(nsIClipboard::kGlobalClipboard);
+  nsresult rv = SetSelectionRange(aPosition, aPosition);
+  NS_ENSURE_SUCCESS(rv, rv);
 
-  return NS_ERROR_FAILURE;
+  return editor->Paste(nsIClipboard::kGlobalClipboard);
 }
 
 NS_IMETHODIMP
 nsHyperTextAccessible::GetAssociatedEditor(nsIEditor **aEditor)
 {
   NS_ENSURE_ARG_POINTER(aEditor);
 
   *aEditor = nsnull;
@@ -1506,20 +1520,24 @@ nsHyperTextAccessible::GetAssociatedEdit
   nsCOMPtr<nsIEditor> editor;
   return editingSession->GetEditorForWindow(doc->GetWindow(), aEditor);
 }
 
 /**
   * =================== Caret & Selection ======================
   */
 
-nsresult nsHyperTextAccessible::SetSelectionRange(PRInt32 aStartPos, PRInt32 aEndPos)
+nsresult
+nsHyperTextAccessible::SetSelectionRange(PRInt32 aStartPos, PRInt32 aEndPos)
 {
+  nsresult rv = TakeFocus();
+  NS_ENSURE_SUCCESS(rv, rv);
+
   // Set the selection
-  nsresult rv = SetSelectionBounds(0, aStartPos, aEndPos);
+  SetSelectionBounds(0, aStartPos, aEndPos);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // If range 0 was successfully set, clear any additional selection 
   // ranges remaining from previous selection
   nsCOMPtr<nsISelection> domSel;
   nsCOMPtr<nsISelectionController> selCon;
   GetSelections(nsISelectionController::SELECTION_NORMAL,
                 getter_AddRefs(selCon), getter_AddRefs(domSel));
@@ -1539,17 +1557,18 @@ nsresult nsHyperTextAccessible::SetSelec
     // set to true, this calling might flush the pending reflow. See bug 418470.
     selCon->ScrollSelectionIntoView(nsISelectionController::SELECTION_NORMAL,
       nsISelectionController::SELECTION_FOCUS_REGION, PR_FALSE);
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP nsHyperTextAccessible::SetCaretOffset(PRInt32 aCaretOffset)
+NS_IMETHODIMP
+nsHyperTextAccessible::SetCaretOffset(PRInt32 aCaretOffset)
 {
   return SetSelectionRange(aCaretOffset, aCaretOffset);
 }
 
 /*
  * Gets the offset position of the caret (cursor).
  */
 NS_IMETHODIMP
--- a/accessible/src/msaa/nsAccessibleWrap.cpp
+++ b/accessible/src/msaa/nsAccessibleWrap.cpp
@@ -1600,17 +1600,17 @@ nsAccessibleWrap::GetTypeInfoCount(UINT 
 }
 
 STDMETHODIMP
 nsAccessibleWrap::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
 {
   *ppTInfo = NULL;
 
   if (iTInfo != 0)
-    return ResultFromScode(DISP_E_BADINDEX);
+    return DISP_E_BADINDEX;
 
   ITypeInfo * typeInfo = GetTI(lcid);
   if (!typeInfo)
     return E_FAIL;
 
   typeInfo->AddRef();
   *ppTInfo = typeInfo;
 
--- a/accessible/src/msaa/nsDocAccessibleWrap.cpp
+++ b/accessible/src/msaa/nsDocAccessibleWrap.cpp
@@ -273,34 +273,35 @@ STDMETHODIMP nsDocAccessibleWrap::get_ac
       role != nsIAccessibleRole::ROLE_ALERT)
     return hr;
 
   return get_URL(pszValue);
 }
 
 struct nsSearchAccessibleInCacheArg
 {
-  nsCOMPtr<nsIAccessNode> mAccessNode;
+  nsRefPtr<nsAccessNode> mAccessNode;
   void *mUniqueID;
 };
 
 static PLDHashOperator
-SearchAccessibleInCache(const void* aKey, nsIAccessNode* aAccessNode,
+SearchAccessibleInCache(const void* aKey, nsAccessNode* aAccessNode,
                         void* aUserArg)
 {
-  nsCOMPtr<nsIAccessibleDocument> docAccessible(do_QueryInterface(aAccessNode));
-  NS_ASSERTION(docAccessible,
+  nsCOMPtr<nsIAccessibleDocument> accessibleDoc(do_QueryInterface(aAccessNode));
+  NS_ASSERTION(accessibleDoc,
                "No doc accessible for the object in doc accessible cache!");
 
+  nsRefPtr<nsDocAccessible> docAccessible =
+    nsAccUtils::QueryObject<nsDocAccessible>(accessibleDoc);
   if (docAccessible) {
     nsSearchAccessibleInCacheArg* arg =
       static_cast<nsSearchAccessibleInCacheArg*>(aUserArg);
-    nsCOMPtr<nsIAccessNode> accessNode;
-    docAccessible->GetCachedAccessNode(arg->mUniqueID,
-                                       getter_AddRefs(accessNode));
+    nsAccessNode* accessNode =
+      docAccessible->GetCachedAccessNode(arg->mUniqueID);
     if (accessNode) {
       arg->mAccessNode = accessNode;
       return PL_DHASH_STOP;
     }
   }
 
   return PL_DHASH_NEXT;
 }
@@ -318,10 +319,10 @@ nsDocAccessibleWrap::GetXPAccessibleForC
   void *uniqueID = reinterpret_cast<void*>(-aVarChild.lVal);
 
   nsSearchAccessibleInCacheArg arg;
   arg.mUniqueID = uniqueID;
 
   gGlobalDocAccessibleCache.EnumerateRead(SearchAccessibleInCache,
                                           static_cast<void*>(&arg));
   if (arg.mAccessNode)
-    CallQueryInterface(arg.mAccessNode, aAccessible);
+    CallQueryInterface(arg.mAccessNode.get(), aAccessible);
 }
--- a/accessible/src/xul/nsXULColorPickerAccessible.cpp
+++ b/accessible/src/xul/nsXULColorPickerAccessible.cpp
@@ -33,17 +33,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 ***** */
 
 #include "nsXULColorPickerAccessible.h"
 
-#include "nsAccessibleTreeWalker.h"
+#include "nsAccTreeWalker.h"
 
 #include "nsIDOMElement.h"
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsXULColorPickerTileAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
@@ -161,29 +161,24 @@ nsXULColorPickerAccessible::GetRoleInter
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsXULColorPickerAccessible: protected nsAccessible
 
 void
 nsXULColorPickerAccessible::CacheChildren()
 {
-  nsCOMPtr<nsIAccessible> menupopupAccessible;
-  nsAccessibleTreeWalker walker(mWeakShell, mDOMNode, PR_TRUE);
-  walker.GetFirstChild();
+  nsCOMPtr<nsIContent> node(do_QueryInterface(mDOMNode));
+  nsAccTreeWalker walker(mWeakShell, node, PR_TRUE);
 
-  while (walker.mState.accessible) {
-    PRUint32 role = nsAccUtils::Role(walker.mState.accessible);
+  nsRefPtr<nsAccessible> child;
+  while ((child = walker.GetNextChild())) {
+    PRUint32 role = nsAccUtils::Role(child);
 
     // Get an accessbile for menupopup or panel elements.
     if (role == nsIAccessibleRole::ROLE_ALERT) {
-      nsRefPtr<nsAccessible> menupopupAcc =
-        nsAccUtils::QueryObject<nsAccessible>(walker.mState.accessible);
-
-      mChildren.AppendElement(menupopupAcc);
-      menupopupAcc->SetParent(this);
+      mChildren.AppendElement(child);
+      child->SetParent(this);
 
       return;
     }
-
-    walker.GetNextSibling();
   }
 }
--- a/accessible/src/xul/nsXULFormControlAccessible.cpp
+++ b/accessible/src/xul/nsXULFormControlAccessible.cpp
@@ -36,17 +36,17 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 // NOTE: alphabetically ordered
 #include "nsXULFormControlAccessible.h"
 #include "nsHTMLFormControlAccessible.h"
 #include "nsAccessibilityAtoms.h"
-#include "nsAccessibleTreeWalker.h"
+#include "nsAccTreeWalker.h"
 #include "nsXULMenuAccessible.h"
 #include "nsIDOMHTMLInputElement.h"
 #include "nsIDOMNSEditableElement.h"
 #include "nsIDOMXULButtonElement.h"
 #include "nsIDOMXULCheckboxElement.h"
 #include "nsIDOMXULMenuListElement.h"
 #include "nsIDOMXULSelectCntrlItemEl.h"
 #include "nsIDOMXULTextboxElement.h"
@@ -199,54 +199,46 @@ nsXULButtonAccessible::CacheChildren()
   PRBool isMenuButton = isMenu ?
     PR_FALSE :
     content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type,
                          nsAccessibilityAtoms::menuButton, eCaseMatters);
 
   if (!isMenu && !isMenuButton)
     return;
 
-  nsCOMPtr<nsIAccessible> buttonAccessible;
-  nsCOMPtr<nsIAccessible> menupopupAccessible;
+  nsRefPtr<nsAccessible> menupopupAccessible;
+  nsRefPtr<nsAccessible> buttonAccessible;
 
-  nsAccessibleTreeWalker walker(mWeakShell, mDOMNode, PR_TRUE);
-  walker.GetFirstChild();
+  nsAccTreeWalker walker(mWeakShell, content, PR_TRUE);
 
-  while (walker.mState.accessible) {
-    PRUint32 role = nsAccUtils::Role(walker.mState.accessible);
+  nsRefPtr<nsAccessible> child;
+  while ((child = walker.GetNextChild())) {
+    PRUint32 role = nsAccUtils::Role(child);
 
     if (role == nsIAccessibleRole::ROLE_MENUPOPUP) {
       // Get an accessbile for menupopup or panel elements.
-      menupopupAccessible = walker.mState.accessible;
+      menupopupAccessible.swap(child);
 
     } else if (isMenuButton && role == nsIAccessibleRole::ROLE_PUSHBUTTON) {
       // Button type="menu-button" contains a real button. Get an accessible
       // for it. Ignore dropmarker button what is placed as a last child.
-      buttonAccessible = walker.mState.accessible;
+      buttonAccessible.swap(child);
       break;
     }
-
-    walker.GetNextSibling();
   }
 
   if (!menupopupAccessible)
     return;
 
-  nsRefPtr<nsAccessible> menupopupAcc =
-    nsAccUtils::QueryObject<nsAccessible>(menupopupAccessible);
-
-  mChildren.AppendElement(menupopupAcc);
-  menupopupAcc->SetParent(this);
+  mChildren.AppendElement(menupopupAccessible);
+  menupopupAccessible->SetParent(this);
 
   if (buttonAccessible) {
-    nsRefPtr<nsAccessible> buttonAcc =
-      nsAccUtils::QueryObject<nsAccessible>(buttonAccessible);
-
-    mChildren.AppendElement(buttonAcc);
-    buttonAcc->SetParent(this);
+    mChildren.AppendElement(buttonAccessible);
+    buttonAccessible->SetParent(this);
   }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsXULButtonAccessible protected
 
 PRBool
 nsXULButtonAccessible::ContainsMenu()
@@ -1075,23 +1067,16 @@ nsXULTextFieldAccessible::CacheChildren(
 {
   // Create child accessibles for native anonymous content of underlying HTML
   // input element.
   nsCOMPtr<nsIDOMNode> inputNode(GetInputField());
   nsCOMPtr<nsIContent> inputContent(do_QueryInterface(inputNode));
   if (!inputContent)
     return;
 
-  nsAccessibleTreeWalker walker(mWeakShell, inputNode, PR_FALSE);
-  walker.mState.frame = inputContent->GetPrimaryFrame();
+  nsAccTreeWalker walker(mWeakShell, inputContent, PR_FALSE);
 
-  walker.GetFirstChild();
-  while (walker.mState.accessible) {
-    nsRefPtr<nsAccessible> acc =
-      nsAccUtils::QueryObject<nsAccessible>(walker.mState.accessible);
-
-    mChildren.AppendElement(acc);
-
-    acc->SetParent(this);
-
-    walker.GetNextSibling();
+  nsRefPtr<nsAccessible> child;
+  while ((child = walker.GetNextChild())) {
+    mChildren.AppendElement(child);
+    child->SetParent(this);
   }
 }
--- a/accessible/src/xul/nsXULMenuAccessible.h
+++ b/accessible/src/xul/nsXULMenuAccessible.h
@@ -35,17 +35,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef _nsXULMenuAccessible_H_
 #define _nsXULMenuAccessible_H_
 
 #include "nsAccessibleWrap.h"
-#include "nsAccessibleTreeWalker.h"
 #include "nsIAccessibleSelectable.h"
 #include "nsIDOMXULSelectCntrlEl.h"
 
 /*
  * The basic implementation of nsIAccessibleSelectable.
  */
 class nsXULSelectableAccessible : public nsAccessibleWrap
 {
--- a/accessible/src/xul/nsXULTreeAccessible.cpp
+++ b/accessible/src/xul/nsXULTreeAccessible.cpp
@@ -46,19 +46,19 @@
 #include "nsITreeSelection.h"
 #include "nsIMutableArray.h"
 #include "nsComponentManagerUtils.h"
 
 ////////////////////////////////////////////////////////////////////////////////
 // Internal static functions
 ////////////////////////////////////////////////////////////////////////////////
 
+// Callback used when traversing the cache by cycle collector.
 static PLDHashOperator
-ElementTraverser(const void *aKey, nsIAccessNode *aAccessNode,
-                 void *aUserArg)
+ElementTraverser(const void *aKey, nsAccessNode *aAccessNode, void *aUserArg)
 {
   nsCycleCollectionTraversalCallback *cb = 
     static_cast<nsCycleCollectionTraversalCallback*>(aUserArg);
 
   NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb, "mAccessNodeCache of XUL tree entry");
   cb->NoteXPCOMChild(aAccessNode);
   return PL_DHASH_NEXT;
 }
@@ -524,52 +524,48 @@ nsXULTreeAccessible::GetTreeItemAccessib
     return;
 
   PRInt32 rowCount = 0;
   nsresult rv = mTreeView->GetRowCount(&rowCount);
   if (NS_FAILED(rv) || aRow >= rowCount)
     return;
 
   void *key = reinterpret_cast<void*>(aRow);
-  nsCOMPtr<nsIAccessNode> accessNode;
-  GetCacheEntry(mAccessNodeCache, key, getter_AddRefs(accessNode));
+  nsRefPtr<nsAccessNode> accessNode = mAccessNodeCache.GetWeak(key);
 
   if (!accessNode) {
-    nsRefPtr<nsAccessNode> treeItemAcc;
-    CreateTreeItemAccessible(aRow, getter_AddRefs(treeItemAcc));
-    if (!treeItemAcc)
+    CreateTreeItemAccessible(aRow, getter_AddRefs(accessNode));
+    if (!accessNode)
       return;
 
-    nsresult rv = treeItemAcc->Init();
+    nsresult rv = accessNode->Init();
     if (NS_FAILED(rv))
       return;
 
-    accessNode = treeItemAcc;
-    PutCacheEntry(mAccessNodeCache, key, accessNode);
+    mAccessNodeCache.Put(key, accessNode);
   }
 
-  CallQueryInterface(accessNode, aAccessible);
+  CallQueryInterface(accessNode.get(), aAccessible);
 }
 
 void
 nsXULTreeAccessible::InvalidateCache(PRInt32 aRow, PRInt32 aCount)
 {
   if (IsDefunct())
     return;
 
   // Do not invalidate the cache if rows have been inserted.
   if (aCount > 0)
     return;
 
   // Fire destroy event for removed tree items and delete them from caches.
   for (PRInt32 rowIdx = aRow; rowIdx < aRow - aCount; rowIdx++) {
-    void *key = reinterpret_cast<void*>(rowIdx);
 
-    nsCOMPtr<nsIAccessNode> accessNode;
-    GetCacheEntry(mAccessNodeCache, key, getter_AddRefs(accessNode));
+    void* key = reinterpret_cast<void*>(rowIdx);
+    nsAccessNode* accessNode = mAccessNodeCache.GetWeak(key);
 
     if (accessNode) {
       nsRefPtr<nsAccessible> accessible =
         nsAccUtils::QueryAccessible(accessNode);
 
       nsRefPtr<nsAccEvent> event =
         new nsAccEvent(nsIAccessibleEvent::EVENT_HIDE, accessible, PR_FALSE);
       nsEventShell::FireEvent(event);
@@ -594,33 +590,29 @@ nsXULTreeAccessible::InvalidateCache(PRI
   PRInt32 newRowCount = 0;
   nsresult rv = mTreeView->GetRowCount(&newRowCount);
   if (NS_FAILED(rv))
     return;
 
   PRInt32 oldRowCount = newRowCount - aCount;
 
   for (PRInt32 rowIdx = newRowCount; rowIdx < oldRowCount; ++rowIdx) {
+
     void *key = reinterpret_cast<void*>(rowIdx);
-
-    nsCOMPtr<nsIAccessNode> accessNode;
-    GetCacheEntry(mAccessNodeCache, key, getter_AddRefs(accessNode));
+    nsAccessNode* accessNode = mAccessNodeCache.GetWeak(key);
 
     if (accessNode) {
-      nsRefPtr<nsAccessNode> accNode =
-        nsAccUtils::QueryAccessNode(accessNode);
-
-      accNode->Shutdown();
+      accessNode->Shutdown();
 
       // Remove accessible from document cache and tree cache.
       nsCOMPtr<nsIAccessibleDocument> docAccessible = GetDocAccessible();
       if (docAccessible) {
         nsRefPtr<nsDocAccessible> docAcc =
           nsAccUtils::QueryAccessibleDocument(docAccessible);
-        docAcc->RemoveAccessNodeFromCache(accNode);
+        docAcc->RemoveAccessNodeFromCache(accessNode);
       }
 
       mAccessNodeCache.Remove(key);
     }
   }
 }
 
 void
@@ -654,20 +646,19 @@ nsXULTreeAccessible::TreeViewInvalidated
     rv = treeColumns->GetCount(&colCount);
     if (NS_FAILED(rv))
       return;
 
     endCol = colCount - 1;
   }
 
   for (PRInt32 rowIdx = aStartRow; rowIdx <= endRow; ++rowIdx) {
+
     void *key = reinterpret_cast<void*>(rowIdx);
-
-    nsCOMPtr<nsIAccessNode> accessNode;
-    GetCacheEntry(mAccessNodeCache, key, getter_AddRefs(accessNode));
+    nsAccessNode* accessNode = mAccessNodeCache.GetWeak(key);
 
     if (accessNode) {
       nsRefPtr<nsXULTreeItemAccessibleBase> treeitemAcc =
         nsAccUtils::QueryObject<nsXULTreeItemAccessibleBase>(accessNode);
       NS_ASSERTION(treeitemAcc, "Wrong accessible at the given key!");
 
       treeitemAcc->RowInvalidated(aStartCol, endCol);
     }
--- a/accessible/src/xul/nsXULTreeGridAccessible.cpp
+++ b/accessible/src/xul/nsXULTreeGridAccessible.cpp
@@ -40,19 +40,19 @@
 
 #include "nsITreeSelection.h"
 #include "nsServiceManagerUtils.h"
 
 ////////////////////////////////////////////////////////////////////////////////
 // Internal static functions
 ////////////////////////////////////////////////////////////////////////////////
 
+// Callback used when traversing the cache by cycle collector.
 static PLDHashOperator
-ElementTraverser(const void *aKey, nsIAccessNode *aAccessNode,
-                 void *aUserArg)
+ElementTraverser(const void *aKey, nsAccessNode *aAccessNode, void *aUserArg)
 {
   nsCycleCollectionTraversalCallback *cb = 
     static_cast<nsCycleCollectionTraversalCallback*>(aUserArg);
 
   NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb,
                                      "mAccessNodeCache of XUL tree row entry");
   cb->NoteXPCOMChild(aAccessNode);
   return PL_DHASH_NEXT;
@@ -734,36 +734,33 @@ nsXULTreeGridRowAccessible::GetIndexOf(n
 void
 nsXULTreeGridRowAccessible::GetCellAccessible(nsITreeColumn* aColumn,
                                               nsIAccessible** aAccessible)
 {
   NS_PRECONDITION(aColumn, "No tree column!");
   *aAccessible = nsnull;
 
   void* key = static_cast<void*>(aColumn);
-
-  nsCOMPtr<nsIAccessNode> accessNode;
-  GetCacheEntry(mAccessNodeCache, key, getter_AddRefs(accessNode));
+  nsRefPtr<nsAccessNode> accessNode = mAccessNodeCache.GetWeak(key);
 
   if (!accessNode) {
-    nsRefPtr<nsAccessNode> cellAcc =
+    accessNode =
       new nsXULTreeGridCellAccessibleWrap(mDOMNode, mWeakShell, this, mTree,
                                           mTreeView, mRow, aColumn);
-    if (!cellAcc)
+    if (!accessNode)
       return;
 
-    nsresult rv = cellAcc->Init();
+    nsresult rv = accessNode->Init();
     if (NS_FAILED(rv))
       return;
 
-    accessNode = cellAcc;
-    PutCacheEntry(mAccessNodeCache, key, accessNode);
+    mAccessNodeCache.Put(key, accessNode);
   }
 
-  CallQueryInterface(accessNode, aAccessible);
+  CallQueryInterface(accessNode.get(), aAccessible);
 }
 
 void
 nsXULTreeGridRowAccessible::RowInvalidated(PRInt32 aStartColIdx,
                                            PRInt32 aEndColIdx)
 {
   nsCOMPtr<nsITreeColumns> treeColumns;
   mTree->GetColumns(getter_AddRefs(treeColumns));
--- a/accessible/tests/mochitest/Makefile.in
+++ b/accessible/tests/mochitest/Makefile.in
@@ -50,58 +50,59 @@ include $(topsrcdir)/config/rules.mk
 _TEST_FILES =\
 		letters.gif \
 		moz.png \
 		$(topsrcdir)/content/media/test/bug461281.ogg \
 		longdesc_src.html \
 		actions.js \
 		attributes.js \
 		common.js \
+		editabletext.js \
 		events.js \
 		events_scroll.html \
 		grid.js \
 		layout.js \
 		name.css \
 		name.js \
 		name.xbl \
 		name_nsRootAcc_wnd.xul \
 		namerules.xml \
  		nsIAccessible_selects.js \
-		nsIAccessibleEditableText.js \
 		relations.js \
 		role.js \
 		states.js \
 		table.js \
 		value.js \
 		test_aria_activedescendant.html \
 		test_aria_role_article.html \
 		test_aria_role_equation.html \
 		test_aria_roles.html \
 		test_aria_roles.xul \
 		test_aria_token_attrs.html \
 		test_bug420863.html \
 	$(warning   test_childAtPoint.html temporarily disabled) \
 	$(warning	test_childAtPoint.xul temporarily disabled) \
 		test_descr.html \
+		test_editabletext_1.html \
+		test_editabletext_2.html \
 		test_elm_listbox.xul \
 	$(warning   test_elm_media.html temporarily disabled) \
 		test_elm_plugin.html \
 		test_invalidate_accessnode.html \
 		test_name.html \
 		test_name.xul \
 		test_name_button.html \
 		test_name_link.html \
 		test_name_markup.html \
 		test_name_nsApplicationAcc.html \
 		test_name_nsRootAcc.xul \
 	$(warning test_nsIAccessible_comboboxes.xul temporarily disabled) \
  		test_nsIAccessible_selects.html \
 		test_nsIAccessible_focus.html \
 		test_nsIAccessibleDocument.html \
-		test_nsIAccessibleEditableText.html \
 		test_nsIAccessibleHyperLink.html \
 		test_nsIAccessibleHyperLink.xul \
 		test_nsIAccessibleHyperText.html \
 		test_nsIAccessibleImage.html \
 		test_nsIAccessNode_utils.html \
 		test_nsOuterDocAccessible.html \
 		test_relations.html \
 		test_relations.xul \
@@ -122,16 +123,17 @@ include $(topsrcdir)/config/rules.mk
 		test_table_sels_ariagrid.html \
 		test_table_sels_listbox.xul \
 		test_table_sels_tree.xul \
 		test_table_struct.html \
 		test_table_struct_ariagrid.html \
 		test_table_struct_ariatreegrid.html \
 		test_table_struct_listbox.xul \
 		test_table_struct_tree.xul \
+		test_text_caret.html \
 		test_textboxes.html \
 		test_textboxes.xul \
 		test_value.html \
 		test_value.xul \
 		testTextboxes.js \
 		treeview.css \
 		treeview.js \
 		$(NULL)
rename from accessible/tests/mochitest/nsIAccessibleEditableText.js
rename to accessible/tests/mochitest/editabletext.js
--- a/accessible/tests/mochitest/nsIAccessibleEditableText.js
+++ b/accessible/tests/mochitest/editabletext.js
@@ -26,17 +26,31 @@ function nsEditableText(aElmOrID)
          " to element with ID '" + this.mID + "'");
     } catch (e) {
       ok(false,
          "insertText: Can't insert " + aStr + " at " + aPos +
          " to element with ID '" + this.mID +
          "', value '" + this.getValue() + "', exception " + e);
     }
   }
-  
+
+  this.copyText = function copyText(aStartPos, aEndPos, aClipboardStr)
+  {
+    var msg = "copyText from " + aStartPos + " to " + aEndPos +
+      " for element " + prettyName(this.mID) + ": ";
+
+    try {
+      this.mAcc.copyText(aStartPos, aEndPos);
+      is(this.pasteFromClipboard(), aClipboardStr, msg);
+
+    } catch(e) {
+      ok(false, msg + e);
+    }
+  }
+
   this.copyNPasteText = function copyNPasteText(aStartPos, aEndPos,
                                                 aPos, aResStr)
   {
     try {
       this.mAcc.copyText(aStartPos, aEndPos);
       this.mAcc.pasteText(aPos);
       
       is(this.getValue(), aResStr,
@@ -46,17 +60,34 @@ function nsEditableText(aElmOrID)
     } catch (e) {
       ok(false,
          "copyText & pasteText: Can't copy text from " + aStartPos +
          " to " + aEndPos + " and paste to " + aPos +
          " for element with ID '" + this.mID +
          "', value '" + this.getValue() + "', exception " + e);
     }
   }
-  
+
+  this.cutText = function cutText(aStartPos, aEndPos, aClipboardStr, aResStr)
+  {
+    var msg = "cutText from " + aStartPos + " to " + aEndPos +
+      " for element " + prettyName(this.mID) + ": ";
+
+    try {
+      this.mAcc.cutText(aStartPos, aEndPos);
+
+      is(this.pasteFromClipboard(), aClipboardStr,
+         msg + "wrong clipboard value");
+      is(this.getValue(), aResStr, msg + "wrong control value");
+
+    } catch(e) {
+      ok(false, msg + e);
+    }
+  }
+
   this.cutNPasteText = function copyNPasteText(aStartPos, aEndPos,
                                                aPos, aResStr)
   {
     try {
       this.mAcc.cutText(aStartPos, aEndPos);
       this.mAcc.pasteText(aPos);
       
       is(this.getValue(), aResStr,
@@ -66,22 +97,37 @@ function nsEditableText(aElmOrID)
     } catch (e) {
       ok(false,
          "cutText & pasteText: Can't cut text from " + aStartPos +
          " to " + aEndPos + " and paste to " + aPos +
          " for element with ID '" + this.mID +
          "', value '" + this.getValue() + "', exception " + e);
     }
   }
-  
+
+  this.pasteText = function pasteText(aPos, aResStr)
+  {
+    var msg = "pasteText to " + aPos + " position for element " +
+      prettyName(this.mID) + ": ";
+
+    try {
+      this.mAcc.pasteText(aPos);
+
+      is(this.getValue(), aResStr, msg + "wrong control value");
+
+    } catch(e) {
+      ok(false, msg + e);
+    }
+  }
+
   this.deleteText = function deleteText(aStartPos, aEndPos, aResStr)
   {
     try {
       this.mAcc.deleteText(aStartPos, aEndPos);
-      
+
       is(this.getValue(), aResStr,
          "deleteText: Can't delete text from " + aStartPos +
          " to " + aEndPos + " for element with ID '" + this.mID + "'");
     } catch (e) {
       ok(false,
          "deleteText: Can't delete text from " + aStartPos +
          " to " + aEndPos + " for element with ID '" + this.mID +
          "', value " + this.getValue() + ", exception " + e);
@@ -92,14 +138,41 @@ function nsEditableText(aElmOrID)
   {
     if (this.mElm instanceof Components.interfaces.nsIDOMNSEditableElement)
       return this.mElm.value;
     if (this.mElm instanceof Components.interfaces.nsIDOMHTMLDocument)
       return this.mElm.body.textContent;
     return this.mElm.textContent;
   }
 
+  this.pasteFromClipboard = function pasteFromClipboard()
+  {
+    var clip = Components.classes["@mozilla.org/widget/clipboard;1"].
+      getService(Components.interfaces.nsIClipboard);
+    if (!clip)
+      return;
+
+    var trans = Components.classes["@mozilla.org/widget/transferable;1"].
+    createInstance(Components.interfaces.nsITransferable);
+    if (!trans)
+      return;
+
+    trans.addDataFlavor("text/unicode");
+    clip.getData(trans, clip.kGlobalClipboard);
+
+    var str = new Object();
+    var strLength = new Object();
+    trans.getTransferData("text/unicode", str, strLength);
+
+    if (str)
+      str = str.value.QueryInterface(Components.interfaces.nsISupportsString);
+    if (str)
+      return str.data.substring(0, strLength.value / 2);
+
+    return "";
+  }
+
   var elmObj = { value: null };
   this.mAcc = getAccessible(aElmOrID, nsIAccessibleEditableText, elmObj);
 
   this.mElm = elmObj.value;
   this.mID = aElmOrID;
 }
--- a/accessible/tests/mochitest/events/Makefile.in
+++ b/accessible/tests/mochitest/events/Makefile.in
@@ -44,17 +44,17 @@ relativesrcdir  = accessible/events
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES =\
 		test_attrs.html \
 		test_caretmove.html \
 	$(warning	test_coalescence.html temporarily disabled) \
-	$(warning	test_doc.html temporarily disabled) \
+		test_doc.html \
 		test_dragndrop.html \
 		test_flush.html \
 		test_focus.html \
 		test_focus.xul \
 		test_focusdoc.html \
 		test_mutation.html \
 		test_scroll.xul \
 		test_tree.xul \
--- a/accessible/tests/mochitest/name_nsRootAcc_wnd.xul
+++ b/accessible/tests/mochitest/name_nsRootAcc_wnd.xul
@@ -81,17 +81,17 @@
 
     var gQueue = null;
 
     const Ci = Components.interfaces;
 
     function doTest()
     {
       var tabBrowser = document.getElementById("content");
-      tabBrowser.loadURI("about:");
+      tabBrowser.loadURI("about:robots");
       tabBrowser.addTab("about:mozilla");
 
       gQueue = new gOpenerWnd.eventQueue();
       gQueue.push(new switchTabInvoker(tabBrowser));
       gQueue.onFinish = function() { window.close(); }
       gQueue.invoke();
     }
 
--- a/accessible/tests/mochitest/table.js
+++ b/accessible/tests/mochitest/table.js
@@ -8,17 +8,17 @@
  *   states.js
  */
 
 /**
  * Constants used to describe cells array.
  */
 const kDataCell = 1; // Indicates the cell is origin data cell
 const kRowHeaderCell = 2; // Indicates the cell is row header cell
-const kColHeaderCell = 4; // Indicated teh cell is column header cell
+const kColHeaderCell = 4; // Indicated the cell is column header cell
 const kOrigin = kDataCell | kRowHeaderCell | kColHeaderCell;
 
 const kRowSpanned = 8; // Indicates the cell is not origin and row spanned 
 const kColSpanned = 16; // Indicates the cell is not origin and column spanned
 const kSpanned = kRowSpanned | kColSpanned;
 
 /**
  * Constants to define column header type.
rename from accessible/tests/mochitest/test_nsIAccessibleEditableText.html
rename to accessible/tests/mochitest/test_editabletext_1.html
--- a/accessible/tests/mochitest/test_nsIAccessibleEditableText.html
+++ b/accessible/tests/mochitest/test_editabletext_1.html
@@ -9,17 +9,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   <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/nsIAccessibleEditableText.js"></script>
+          src="chrome://mochikit/content/a11y/accessible/editabletext.js"></script>
 
   <script type="application/javascript">
     var gParagraphAcc;
 
     function testEditable(aID)
     {
       var et = new nsEditableText(aID);
 
new file mode 100644
--- /dev/null
+++ b/accessible/tests/mochitest/test_editabletext_2.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>nsIAccessibleEditableText chrome tests</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/editabletext.js"></script>
+
+  <script type="application/javascript">
+    var gParagraphAcc;
+
+    function doTest()
+    {
+      var et = new nsEditableText("input");
+
+      et.insertText("ee", 1, "heeello");
+      et.copyText(1, 3, "ee");
+      et.cutText(1, 3, "ee", "hello");
+      et.deleteText(1, 3, "hlo");
+      et.pasteText(1, "heelo");
+
+      SimpleTest.finish();
+    }
+
+    SimpleTest.waitForExplicitFinish();
+    addA11yLoadEvent(doTest);
+  </script>
+</head>
+<body>
+
+  <a target="_blank"
+     title="HyperText accessible should get focus when the caret is positioned inside of it, text is changed or copied into clipboard by ATs"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=524115">
+    Mozilla Bug 524115
+  </a>
+  <p id="display"></p>
+  <div id="content" style="display: none"></div>
+  <pre id="test">
+  </pre>
+
+  <input id="input" value="hello"/>
+
+</body>
+</html>
--- a/accessible/tests/mochitest/test_name.html
+++ b/accessible/tests/mochitest/test_name.html
@@ -68,17 +68,17 @@
 
       // Gets the name from image accessible.
       testName("btn_labelledby_mixed_img", "text image");
 
       // Gets the name from input accessibles
       // Note: if input have label elements then the name isn't calculated
       // from them.
       testName("btn_labelledby_mixed_input",
-               "input button Submit Query Reset input image");
+               "input button Submit Query Reset Submit Query");
 
       // Gets the name from the title of object element.
       testName("btn_labelledby_mixed_object", "object");
 
       // Gets the name from text nodes. Element br adds space between them.
       testName("btn_labelledby_mixed_br", "text text");
 
       // Gets the name from label content which allows name from subtree,
@@ -142,16 +142,22 @@
       testName("textareawithchild", "Story Foo is ended.");
 
       // new textarea name should reflect the value change. 
       var elem = document.getElementById("textareawithchild");
       elem.value = "Bar";
 
       testName("textareawithchild", "Story Bar is ended.");
 
+      //////////////////////////////////////////////////////////////////////////
+      // button name (specific cases not covered by test_name_markup.html)
+
+      testName("submit", "Submit Query");
+      testName("image_submit", "Submit Query");
+
       /////////////////////////////////////////////////////////////////////////
       // label with nested combobox (test for 'f' item of name computation guide)
 
       testName("comboinstart", "One day(s).");
       testName("combo3", "day(s).");
 
       testName("textboxinstart", "Two days.");
       testName("textbox1", "days.");
@@ -179,16 +185,21 @@
 </head>
 
 <body>
 
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=444279"
      title="mochitest for accessible name calculating">
     Mozilla Bug 444279
+  </a><br>
+  <a target="_blank"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=530081"
+     title="Clean up our tree walker ">
+    Mozilla Bug 530081
   </a>
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
 
   <!-- aria-label, simple label -->
   <span id="btn_simple_aria_label" role="button" aria-label="I am a button"/>
@@ -352,16 +363,20 @@
   <!-- A textarea nested in a label with a text child (bug #453371). -->
   <form>
     <label>Story
       <textarea id="textareawithchild" name="name">Foo</textarea>
       is ended.
     </label>
   </form>
 
+  <!-- submit buttons -->
+  <input type="submit" id="submit">
+  <input type="image" id="image_submit">
+
   <!-- a label with a nested control in the start, middle and end -->
   <form>
     <!-- at the start (without and with whitespaces) -->
     <label id="comboinstart"><select id="combo3">
         <option>One</option>
         <option>Two</option>
       </select>
       day(s).
--- a/accessible/tests/mochitest/test_name_nsRootAcc.xul
+++ b/accessible/tests/mochitest/test_name_nsRootAcc.xul
@@ -19,24 +19,31 @@
           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">
   <![CDATA[
     // var gA11yEventDumpID = "eventdump"; // debug stuff
 
+    function doTest()
+    {
+      if (LINUX) {
+        todo(false, "Enable test on Linux - see bug 525175.");
+        SimpleTest.finish();
+        return;
+      }
+
+      var w = window.openDialog("chrome://mochikit/content/a11y/accessible/name_nsRootAcc_wnd.xul",
+                                "nsRootAcc_name_test", 
+                                "chrome,width=600,height=600");
+    }
+
     SimpleTest.waitForExplicitFinish();
-    var w = window.openDialog("chrome://mochikit/content/a11y/accessible/name_nsRootAcc_wnd.xul",
-                              "nsRootAcc_name_test", 
-                              "chrome,width=600,height=600");
-    if (LINUX) {
-      w.focus();
-    }
-    
+    addLoadEvent(doTest);
   ]]>
   </script>
 
   <vbox flex="1" style="overflow: auto;">
   <body xmlns="http://www.w3.org/1999/xhtml">
     <a target="_blank"
        href="https://bugzilla.mozilla.org/show_bug.cgi?id=507382"
        title="focus is fired earlier than root accessible name is changed when switching between tabs">
new file mode 100644
--- /dev/null
+++ b/accessible/tests/mochitest/test_text_caret.html
@@ -0,0 +1,99 @@
+<html>
+
+<head>
+  <title>Text accessible caret testing</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/events.js"></script>
+
+  <script type="application/javascript">
+
+    /**
+     * Checkers.
+     */
+    function caretMovedChecker(aID, aOffset)
+    {
+      this.__proto__ = new invokerChecker(EVENT_TEXT_CARET_MOVED, aID);
+
+      this.check = function caretMovedChecker_check(aEvent)
+      {
+        is(aEvent.QueryInterface(nsIAccessibleCaretMoveEvent).caretOffset,
+           aOffset,
+           "Wrong caret offset for " + prettyName(aEvent.target));
+      }
+    }
+
+    /**
+     * Invokers.
+     */
+    function setCaretOffsetInvoker(aID, aOffset)
+    {
+      this.target = getAccessible(aID, [nsIAccessibleText]);
+
+      this.invoke = function setCaretOffsetInvoker_invoke()
+      {
+        this.target.caretOffset = aOffset;
+      }
+
+      this.getID = function setCaretOffsetInvoker_getID()
+      {
+        "nsIAccessibleText::caretOffset test"
+      }
+
+      this.eventSeq = [
+        new invokerChecker(EVENT_FOCUS, this.target),
+        new caretMovedChecker(this.target, aOffset)
+      ];
+    }
+
+    /**
+     * Do tests.
+     */
+    var gQueue = null;
+
+    // gA11yEventDumpID = "eventdump"; // debug stuff
+
+    function doTests()
+    {
+      // test caret move events and caret offsets
+      gQueue = new eventQueue();
+
+      gQueue.push(new setCaretOffsetInvoker("textbox", 1));
+      gQueue.push(new setCaretOffsetInvoker("link", 1));
+
+      gQueue.invoke(); // Will call SimpleTest.finish();
+    }
+
+    SimpleTest.waitForExplicitFinish();
+    addA11yLoadEvent(doTests);
+  </script>
+</head>
+
+<body>
+
+  <a target="_blank"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=524115"
+     title="HyperText accessible should get focus when the caret is positioned inside of it, text is changed or copied into clipboard by ATs">
+    Mozilla Bug 524115
+  </a>
+  <p id="display"></p>
+  <div id="content" style="display: none"></div>
+  <pre id="test">
+  </pre>
+
+  <input id="textbox" value="hello"/>
+  <a id="link" href="about:">about mozilla</a>
+
+  <div id="eventdump"></div>
+</body>
+</html>
--- a/accessible/tests/mochitest/tree/Makefile.in
+++ b/accessible/tests/mochitest/tree/Makefile.in
@@ -47,16 +47,17 @@ include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES =\
 		test_button.xul \
 		test_colorpicker.xul \
 		test_combobox.xul \
 		test_filectrl.html \
 		test_formctrl.html \
 		test_formctrl.xul \
+		test_gencontent.html \
 		test_groupbox.xul \
 		test_iframe.html \
 		test_img.html \
 		test_list.html \
 		test_list_invalidate.html \
 		test_media.html \
 		test_menu.xul \
 		test_select.html \
--- a/accessible/tests/mochitest/tree/test_formctrl.html
+++ b/accessible/tests/mochitest/tree/test_formctrl.html
@@ -30,39 +30,48 @@
       // input@type="radio"
       accTree = {
         role: ROLE_RADIOBUTTON,
         children: [ ]
       };
 
       testAccessibleTree("radio", accTree);
 
-      // input@type="button" and button
+      // input@type="button" and input@type="submit"
       accTree = {
         role: ROLE_PUSHBUTTON,
         children: [ ]
       };
 
       testAccessibleTree("btn1", accTree);
-
       testAccessibleTree("submit", accTree);
-      testAccessibleTree("image_submit", accTree);
 
       // button
       accTree = {
         role: ROLE_PUSHBUTTON,
         children: [
           {
             role: ROLE_TEXT_LEAF
           }
         ]
       };
 
       testAccessibleTree("btn2", accTree);
 
+      // input@type="image"
+      accTree = {
+        role: ROLE_PUSHBUTTON,
+        children: [
+          {
+            role: ROLE_STATICTEXT
+          }
+        ]
+      };
+      testAccessibleTree("image_submit", accTree);
+
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
 </head>
 <body>
new file mode 100644
--- /dev/null
+++ b/accessible/tests/mochitest/tree/test_gencontent.html
@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+  <title>Generated content tests</title>
+  <link rel="stylesheet" type="text/css"
+        href="chrome://mochikit/content/tests/SimpleTest/test.css" />
+
+  <style>
+    .gentext:before {
+      content: "START"
+    }
+    .gentext:after {
+      content: "END"
+    }
+  </style>
+
+  <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">
+    function doTest()
+    {
+      // :before and :after pseudo styles
+      var accTree = {
+        role: ROLE_SECTION,
+        children: [
+          {
+            role: ROLE_STATICTEXT,
+            name: "START"
+          },
+          {
+            role: ROLE_TEXT_LEAF,
+            name: "MIDDLE"
+          },
+          {
+            role: ROLE_STATICTEXT,
+            name: "END"
+          }
+        ]
+      };
+
+      testAccessibleTree("gentext", accTree);
+
+      SimpleTest.finish();
+    }
+
+    SimpleTest.waitForExplicitFinish();
+    addA11yLoadEvent(doTest);
+  </script>
+</head>
+<body>
+
+  <a target="_blank"
+     title="Clean up our tree walker"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=530081">
+    Mozilla Bug 530081
+  </a>
+  <p id="display"></p>
+  <div id="content" style="display: none"></div>
+  <pre id="test">
+  </pre>
+
+  <div class="gentext" id="gentext">MIDDLE</div>
+</body>
+</html>
--- a/accessible/tests/mochitest/tree/test_txtcntr.html
+++ b/accessible/tests/mochitest/tree/test_txtcntr.html
@@ -88,16 +88,95 @@
             role: ROLE_TEXT_LEAF,
             name: "hello "
           }
         ]
       };
 
       testAccessibleTree("c4", accTree);
 
+      // blockquote
+      accTree = {
+        role: ROLE_SECTION,
+        children: [
+          { // block quote
+            role: ROLE_SECTION,
+            children: [
+              { // text child
+                role: ROLE_TEXT_LEAF,
+                name: "Hello",
+                children: []
+              }
+            ]
+          }
+        ]
+      };
+
+      testAccessibleTree("c5", accTree);
+
+      // abbreviation tag
+      accTree = {
+        role: ROLE_SECTION,
+        children: [
+          { // text leaf
+            role: ROLE_TEXT_LEAF,
+            name: "This ",
+            children: []
+          },
+          { // abbr tag
+            role: ROLE_TEXT_CONTAINER,
+            name: "accessibility",
+            children: [
+              { // text leaf with actual text
+                role: ROLE_TEXT_LEAF,
+                name: "a11y",
+                children: []
+              }
+            ]
+          },
+          { // text leaf
+            role: ROLE_TEXT_LEAF,
+            name: " test",
+            children: []
+          }
+        ]
+      };
+
+      testAccessibleTree("c6", accTree);
+
+      // acronym tag
+      accTree = {
+        role: ROLE_SECTION,
+        children: [
+          { // text leaf
+            role: ROLE_TEXT_LEAF,
+            name: "This ",
+            children: []
+          },
+          { // acronym tag
+            role: ROLE_TEXT_CONTAINER,
+            name: "personal computer",
+            children: [
+              { // text leaf with actual text
+                role: ROLE_TEXT_LEAF,
+                name: "PC",
+                children: []
+              }
+            ]
+          },
+          { // text leaf
+            role: ROLE_TEXT_LEAF,
+            name: " is broken",
+            children: []
+          }
+        ]
+      };
+
+      testAccessibleTree("c7", accTree);
+
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
 </head>
 <body>
@@ -129,10 +208,13 @@
     Hello3
     <p>
       Hello4
     </p>
   </div>
   <div id="c4" contentEditable="true">
     helllo <p>blabla</p> hello
   </div>
+  <div id="c5"><blockquote>Hello</blockquote></div>
+  <div id="c6">This <abbr title="accessibility">a11y</abbr> test</div>
+  <div id="c7">This <acronym title="personal computer">PC</acronym> is broken</div>
 </body>
 </html>
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -860,16 +860,17 @@ pref("browser.privatebrowsing.autostart"
 pref("browser.privatebrowsing.dont_prompt_on_enter", false);
 
 // Don't try to alter this pref, it'll be reset the next time you use the
 // bookmarking dialog
 pref("browser.bookmarks.editDialog.firstEditField", "namePicker");
 
 // base url for the wifi geolocation network provider
 pref("geo.wifi.uri", "https://www.google.com/loc/json");
+pref("geo.wifi.protocol", 0);
 
 #ifdef WINCE
 
 // tweak awesomebar -- increase the delay until a search happens.
 pref("browser.urlbar.delay", 250);
 
 // disable safe browsing, due to perf hit
 pref("browser.safebrowsing.enabled", false);
--- a/browser/base/content/browser-fullZoom.js
+++ b/browser/base/content/browser-fullZoom.js
@@ -328,23 +328,23 @@ var FullZoom = {
    * and perhaps the same is true for full zoom
    * (although DocumentViewerImpl::SetFullZoom doesn't mention it).
    *
    * So when we apply new zoom values to the browser, we simply set the zoom.
    * We don't check first to see if the new value is the same as the current
    * one.
    **/
   _applyPrefToSetting: function FullZoom__applyPrefToSetting(aValue, aBrowser) {
-    if (!this.siteSpecific && !this._inPrivateBrowsing)
+    if ((!this.siteSpecific && !this._inPrivateBrowsing) ||
+        gInPrintPreviewMode)
       return;
 
     var browser = aBrowser || gBrowser.selectedBrowser;
     try {
-      if (gInPrintPreviewMode ||
-          browser.contentDocument instanceof Ci.nsIImageDocument ||
+      if (browser.contentDocument instanceof Ci.nsIImageDocument ||
           this._inPrivateBrowsing)
         ZoomManager.setZoomForBrowser(browser, 1);
       else if (typeof aValue != "undefined")
         ZoomManager.setZoomForBrowser(browser, this._ensureValid(aValue));
       else if (typeof this.globalValue != "undefined")
         ZoomManager.setZoomForBrowser(browser, this.globalValue);
       else
         ZoomManager.setZoomForBrowser(browser, 1);
--- a/browser/base/content/browser.css
+++ b/browser/base/content/browser.css
@@ -71,19 +71,26 @@ toolbar[mode="icons"] > #reload-button[d
 }
 
 #urlbar[pageproxystate="invalid"] > #urlbar-icons > .urlbar-icon:not(#go-button),
 #urlbar[pageproxystate="valid"] > #urlbar-icons > #go-button ,
 #urlbar[isempty="true"] > #urlbar-icons > #go-button {
   visibility: collapse;
 }
 
-#identity-box-inner {
-  max-width: 22em;
-  min-width: 1px;
+#identity-icon-labels {
+  max-width: 18em;
+}
+
+#identity-icon-country-label {
+  direction: ltr;
+}
+
+#identity-box.verifiedIdentity > hbox > #identity-icon-labels > #identity-icon-label {
+  -moz-margin-end: 0.25em !important;
 }
 
 #wrapper-search-container > #search-container > #searchbar > .searchbar-textbox > .autocomplete-textbox-container > .textbox-input-box > html|*.textbox-input {
   visibility: hidden;
 }
 
 /* ::::: Unified Back-/Forward Button ::::: */
 #back-button > .toolbarbutton-menu-dropmarker,
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1096,24 +1096,28 @@ function HandleAppCommandEvent(evt) {
     BrowserHome();
     break;
   default:
     break;
   }
 }
 
 function prepareForStartup() {
+  var os = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
+
   gBrowser.addEventListener("DOMUpdatePageReport", gPopupBlockerObserver.onUpdatePageReport, false);
   // Note: we need to listen to untrusted events, because the pluginfinder XBL
   // binding can't fire trusted ones (runs with page privileges).
   gBrowser.addEventListener("PluginNotFound", gMissingPluginInstaller.newMissingPlugin, true, true);
+  gBrowser.addEventListener("PluginCrashed", gMissingPluginInstaller.pluginInstanceCrashed, true, true);
   gBrowser.addEventListener("PluginBlocklisted", gMissingPluginInstaller.newMissingPlugin, true, true);
   gBrowser.addEventListener("PluginOutdated", gMissingPluginInstaller.newMissingPlugin, true, true);
   gBrowser.addEventListener("PluginDisabled", gMissingPluginInstaller.newDisabledPlugin, true, true);
   gBrowser.addEventListener("NewPluginInstalled", gMissingPluginInstaller.refreshBrowser, false);
+  os.addObserver(gMissingPluginInstaller.pluginCrashed, "plugin-crashed", false);
   window.addEventListener("AppCommand", HandleAppCommandEvent, true);
 
   var webNavigation;
   try {
     webNavigation = getWebNavigation();
     if (!webNavigation)
       throw "no XBL binding for browser";
   } catch (e) {
@@ -1147,17 +1151,16 @@ function prepareForStartup() {
 
   // Manually hook up session and global history for the first browser
   // so that we don't have to load global history before bringing up a
   // window.
   // Wire up session and global history before any possible
   // progress notifications for back/forward button updating
   webNavigation.sessionHistory = Components.classes["@mozilla.org/browser/shistory;1"]
                                            .createInstance(Components.interfaces.nsISHistory);
-  var os = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
   os.addObserver(gBrowser.browsers[0], "browser:purge-session-history", false);
 
   // remove the disablehistory attribute so the browser cleans up, as
   // though it had done this work itself
   gBrowser.browsers[0].removeAttribute("disablehistory");
 
   // enable global history
   try {
@@ -1208,34 +1211,29 @@ function delayedStartup(isLoadingBlank, 
   // initiated by a web page script
   window.addEventListener("fullscreen", onFullScreen, true);
 
   if (isLoadingBlank && gURLBar && isElementVisible(gURLBar))
     gURLBar.focus();
   else
     gBrowser.selectedBrowser.focus();
 
-  if (gURLBar)
-    gURLBar.emptyText = gURLBarEmptyText.value;
-
   gNavToolbox.customizeDone = BrowserToolboxCustomizeDone;
   gNavToolbox.customizeChange = BrowserToolboxCustomizeChange;
 
   // Set up Sanitize Item
   initializeSanitizer();
 
   // Enable/Disable auto-hide tabbar
   gAutoHideTabbarPrefListener.toggleAutoHideTabbar();
   gPrefService.addObserver(gAutoHideTabbarPrefListener.domain,
                            gAutoHideTabbarPrefListener, false);
 
   gPrefService.addObserver(gHomeButton.prefDomain, gHomeButton, false);
 
-  gPrefService.addObserver(gURLBarEmptyText.domain, gURLBarEmptyText, false);
-
   var homeButton = document.getElementById("home-button");
   gHomeButton.updateTooltip(homeButton);
   gHomeButton.updatePersonalToolbarStyle(homeButton);
 
 #ifdef HAVE_SHELL_SERVICE
   // Perform default browser checking (after window opens).
   var shell = getShellService();
   if (shell) {
@@ -1402,30 +1400,30 @@ function BrowserShutdown()
   catch(ex) {
     Components.utils.reportError(ex);
   }
 
   var os = Components.classes["@mozilla.org/observer-service;1"]
     .getService(Components.interfaces.nsIObserverService);
   os.removeObserver(gSessionHistoryObserver, "browser:purge-session-history");
   os.removeObserver(gXPInstallObserver, "xpinstall-install-blocked");
+  os.removeObserver(gMissingPluginInstaller.pluginCrashed, "plugin-crashed");
 
   try {
     gBrowser.removeProgressListener(window.XULBrowserWindow);
     gBrowser.removeTabsProgressListener(window.TabsProgressListener);
   } catch (ex) {
   }
 
   PlacesStarButton.uninit();
 
   try {
     gPrefService.removeObserver(gAutoHideTabbarPrefListener.domain,
                                 gAutoHideTabbarPrefListener);
     gPrefService.removeObserver(gHomeButton.prefDomain, gHomeButton);
-    gPrefService.removeObserver(gURLBarEmptyText.domain, gURLBarEmptyText);
   } catch (ex) {
     Components.utils.reportError(ex);
   }
 
   BrowserOffline.uninit();
   OfflineApps.uninit();
   DownloadMonitorPanel.uninit();
   gPrivateBrowsingUI.uninit();
@@ -2531,21 +2529,44 @@ function BrowserReloadWithFlags(reloadFl
 
   try {
     webNav.reload(reloadFlags);
   } catch (e) {
   }
 }
 
 var PrintPreviewListener = {
+  _printPreviewTab: null,
+  _tabBeforePrintPreview: null,
+
+  getPrintPreviewBrowser: function () {
+    if (!this._printPreviewTab) {
+      this._tabBeforePrintPreview = gBrowser.selectedTab;
+      this._printPreviewTab = gBrowser.loadOneTab("about:blank",
+                                                  { inBackground: false });
+      gBrowser.selectedTab = this._printPreviewTab;
+    }
+    return gBrowser.getBrowserForTab(this._printPreviewTab);
+  },
+  getSourceBrowser: function () {
+    return this._tabBeforePrintPreview ?
+      this._tabBeforePrintPreview.linkedBrowser : gBrowser.selectedBrowser;
+  },
+  getNavToolbox: function () {
+    return gNavToolbox;
+  },
   onEnter: function () {
     gInPrintPreviewMode = true;
     this._toggleAffectedChrome();
   },
   onExit: function () {
+    gBrowser.selectedTab = this._tabBeforePrintPreview;
+    this._tabBeforePrintPreview = null;
+    gBrowser.removeTab(this._printPreviewTab);
+    this._printPreviewTab = null;
     gInPrintPreviewMode = false;
     this._toggleAffectedChrome();
   },
   _toggleAffectedChrome: function () {
     // chrome to toggle includes:
     //   (*) menubar
     //   (*) navigation bar
     //   (*) bookmarks toolbar
@@ -2567,51 +2588,44 @@ var PrintPreviewListener = {
   },
   _hideChrome: function () {
     this._chromeState = {};
 
     var sidebar = document.getElementById("sidebar-box");
     this._chromeState.sidebarOpen = !sidebar.hidden;
     this._sidebarCommand = sidebar.getAttribute("sidebarcommand");
 
-    this._chromeState.hadTabStrip = gBrowser.getStripVisibility();
-    gBrowser.setStripVisibilityTo(false);
+    gBrowser.mStrip.setAttribute("moz-collapsed", "true");
 
     var notificationBox = gBrowser.getNotificationBox();
     this._chromeState.notificationsOpen = !notificationBox.notificationsHidden;
     notificationBox.notificationsHidden = true;
 
     document.getElementById("sidebar").setAttribute("src", "about:blank");
     var statusbar = document.getElementById("status-bar");
     this._chromeState.statusbarOpen = !statusbar.hidden;
     statusbar.hidden = true;
 
     this._chromeState.findOpen = !gFindBar.hidden;
     gFindBar.close();
   },
   _showChrome: function () {
-    if (this._chromeState.hadTabStrip)
-      gBrowser.setStripVisibilityTo(true);
+    gBrowser.mStrip.removeAttribute("moz-collapsed");
 
     if (this._chromeState.notificationsOpen)
       gBrowser.getNotificationBox().notificationsHidden = false;
 
     if (this._chromeState.statusbarOpen)
       document.getElementById("status-bar").hidden = false;
 
     if (this._chromeState.findOpen)
       gFindBar.open();
   }
 }
 
-function getPPBrowser()
-{
-  return gBrowser;
-}
-
 function getMarkupDocumentViewer()
 {
   return gBrowser.markupDocumentViewer;
 }
 
 /**
  * Content area tooltip.
  * XXX - this must move into XBL binding/equiv! Do not want to pollute
@@ -3366,38 +3380,28 @@ function BrowserToolboxCustomizeDone(aTo
   if (gCustomizeSheet) {
     document.getElementById("customizeToolbarSheetIFrame").hidden = true;
     document.getElementById("customizeToolbarSheetPopup").hidePopup();
   }
 
   // Update global UI elements that may have been added or removed
   if (aToolboxChanged) {
     gURLBar = document.getElementById("urlbar");
-    if (gURLBar)
-      gURLBar.emptyText = gURLBarEmptyText.value;
 
     gProxyFavIcon = document.getElementById("page-proxy-favicon");
     gHomeButton.updateTooltip();
     gIdentityHandler._cacheElements();
     window.XULBrowserWindow.init();
 
     var backForwardDropmarker = document.getElementById("back-forward-dropmarker");
     if (backForwardDropmarker)
       backForwardDropmarker.disabled =
         document.getElementById('Browser:Back').hasAttribute('disabled') &&
         document.getElementById('Browser:Forward').hasAttribute('disabled');
 
-    // support downgrading to Firefox 2.0
-    var navBar = document.getElementById("nav-bar");
-    navBar.setAttribute("currentset",
-                        navBar.getAttribute("currentset")
-                              .replace("unified-back-forward-button",
-                                "unified-back-forward-button,back-button,forward-button"));
-    document.persist(navBar.id, "currentset");
-
 #ifndef XP_MACOSX
     updateEditUIVisibility();
 #endif
   }
 
   UpdateUrlbarSearchSplitterState();
 
   CombinedStopReload.init();
@@ -5972,32 +5976,50 @@ function getPluginInfo(pluginElement)
     }
   }
 
   return {mimetype: tagMimetype, pluginsPage: pluginsPage};
 }
 
 var gMissingPluginInstaller = {
 
+  get CrashSubmit() {
+    delete this.CrashSubmit;
+    Cu.import("resource://gre/modules/CrashSubmit.jsm", this);
+    return this.CrashSubmit;
+  },
+
+  get crashReportHelpURL() {
+    delete this.crashReportHelpURL;
+    let url = formatURL("app.support.baseURL", true);
+    url += "plugin-crashed";
+    this.crashReportHelpURL = url;
+    return this.crashReportHelpURL;
+  },
+
   installSinglePlugin: function (aEvent) {
+    if (!aEvent.isTrusted)
+        return;
     var missingPluginsArray = {};
 
     var pluginInfo = getPluginInfo(aEvent.target);
     missingPluginsArray[pluginInfo.mimetype] = pluginInfo;
 
     if (missingPluginsArray) {
       openDialog("chrome://mozapps/content/plugins/pluginInstallerWizard.xul",
                  "PFSWindow", "chrome,centerscreen,resizable=yes",
                  {plugins: missingPluginsArray, browser: gBrowser.selectedBrowser});
     }
 
     aEvent.stopPropagation();
   },
 
   managePlugins: function (aEvent) {
+    if (!aEvent.isTrusted)
+        return;
     BrowserOpenAddonsMgr("plugins");
     aEvent.stopPropagation();
   },
 
   newMissingPlugin: function (aEvent) {
     // Since we are expecting also untrusted events, make sure
     // that the target is a plugin
     if (!(aEvent.target instanceof Ci.nsIObjectLoadingContent))
@@ -6009,16 +6031,21 @@ var gMissingPluginInstaller = {
     // so don't stomp on the page developers toes.
 
     if (aEvent.type != "PluginBlocklisted" &&
         aEvent.type != "PluginOutdated" &&
         !(aEvent.target instanceof HTMLObjectElement)) {
       aEvent.target.addEventListener("click",
                                      gMissingPluginInstaller.installSinglePlugin,
                                      true);
+      aEvent.target.addEventListener("keydown",
+                                     function(evt) { if (evt.keyCode == evt.DOM_VK_RETURN)
+                                                       gMissingPluginInstaller.installSinglePlugin(evt) },
+                                     true);
+                                                    
     }
 
     let hideBarPrefName = aEvent.type == "PluginOutdated" ?
                     "plugins.hide_infobar_for_outdated_plugin" :
                     "plugins.hide_infobar_for_missing_plugin";
     if (gPrefService.getBoolPref(hideBarPrefName))
       return;
 
@@ -6132,16 +6159,143 @@ var gMissingPluginInstaller = {
     // Since we are expecting also untrusted events, make sure
     // that the target is a plugin
     if (!(aEvent.target instanceof Ci.nsIObjectLoadingContent))
       return;
 
     aEvent.target.addEventListener("click",
                                    gMissingPluginInstaller.managePlugins,
                                    true);
+    aEvent.target.addEventListener("keydown",
+                                   function(evt) { if (evt.keyCode == evt.DOM_VK_RETURN)
+                                                     gMissingPluginInstaller.managePlugins(evt) },
+                                   true);
+  },
+
+  // Crashed-plugin observer. Notified once per plugin crash, before events
+  // are dispatched to individual plugin instances.
+  pluginCrashed : function(subject, topic, data) {
+    let propertyBag = subject;
+    if (!(propertyBag instanceof Ci.nsIPropertyBag2) ||
+        !(propertyBag instanceof Ci.nsIWritablePropertyBag2))
+     return;
+
+#ifdef MOZ_CRASHREPORTER
+    let minidumpID = subject.getPropertyAsAString("minidumpID");
+    let submitReports = gCrashReporter.submitReports;
+    // The crash reporter wants a DOM element it can append an IFRAME to,
+    // which it uses to submit a form. Let's just give it gBrowser.
+    if (submitReports)
+      gMissingPluginInstaller.CrashSubmit.submit(minidumpID, gBrowser, null, null);
+    propertyBag.setPropertyAsBool("submittedCrashReport", submitReports);
+#endif
+  },
+
+  pluginInstanceCrashed: function (aEvent) {
+    // Evil content could fire a fake event at us, ignore them.
+    if (!aEvent.isTrusted)
+      return;
+
+    if (!(aEvent instanceof Ci.nsIDOMDataContainerEvent))
+      return;
+
+    let submittedReport = aEvent.getData("submittedCrashReport");
+    let pluginName      = aEvent.getData("pluginName");
+
+    // We're expecting this to be a plugin.
+    let plugin = aEvent.target;
+    if (!(plugin instanceof Ci.nsIObjectLoadingContent))
+      return;
+
+    // Force a style flush, so that we ensure our binding is attached.
+    plugin.clientTop;
+
+    let messageString = gNavigatorBundle.getFormattedString("crashedpluginsMessage.title", [pluginName]);
+
+    //
+    // Configure the crashed-plugin placeholder.
+    //
+    let doc = plugin.ownerDocument;
+    let overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
+
+    // The binding has role="link" here, since missing/disabled/blocked
+    // plugin UI has a onclick handler on the whole thing. This isn't needed
+    // for the plugin-crashed UI, because we use actual HTML links in the text.
+    overlay.removeAttribute("role");
+
+#ifdef MOZ_CRASHREPORTER
+    let helpClass = submittedReport ? "submitLink" : "notSubmitLink";
+    let helpLink = doc.getAnonymousElementByAttribute(plugin, "class", helpClass);
+    helpLink.href = gMissingPluginInstaller.crashReportHelpURL;
+    let showClass = submittedReport ? "msg msgSubmitted" : "msg msgNotSubmitted";
+    let textToShow = doc.getAnonymousElementByAttribute(plugin, "class", showClass);
+    textToShow.style.display = "block";
+#endif
+
+    let crashText = doc.getAnonymousElementByAttribute(plugin, "class", "msg msgCrashed");
+    crashText.textContent = messageString;
+
+    let link = doc.getAnonymousElementByAttribute(plugin, "class", "reloadLink");
+    link.addEventListener("click", function(e) { if (e.isTrusted) browser.reload(); }, true);
+
+    let browser = gBrowser.getBrowserForDocument(plugin.ownerDocument
+                                                       .defaultView.top.document);
+    let notificationBox = gBrowser.getNotificationBox(browser);
+
+    // Is the <object>'s size too small to hold what we want to show?
+    let pluginRect = plugin.getBoundingClientRect();
+    // XXX bug 446693. The text-shadow on the submitted-report text at
+    //     the bottom causes scrollHeight to be larger than it should be.
+    let isObjectTooSmall = (overlay.scrollWidth > pluginRect.width) ||
+                           (overlay.scrollHeight - 5 > pluginRect.height);
+    if (isObjectTooSmall) {
+        // Hide the overlay's contents. Use visibility style, so that it
+        // doesn't collapse down to 0x0.
+        overlay.style.visibility = "hidden";
+        // If another plugin on the page was large enough to show our UI, we
+        // don't want to show a notification bar.
+        if (!doc.mozNoPluginCrashedNotification)
+          showNotificationBar();
+    } else {
+        // If a previous plugin on the page was too small and resulted in
+        // adding a notification bar, then remove it because this plugin
+        // instance it big enough to serve as in-content notification.
+        hideNotificationBar();
+        doc.mozNoPluginCrashedNotification = true;
+    }
+
+    function hideNotificationBar() {
+      let notification = notificationBox.getNotificationWithValue("plugin-crashed");
+      if (notification)
+        notificationBox.removeNotification(notification, true);
+    }
+
+    function showNotificationBar() {
+      // If there's already an existing notification bar, don't do anything.
+      let notification = notificationBox.getNotificationWithValue("plugin-crashed");
+      if (notification)
+        return;
+
+      // Configure the notification bar
+      let priority = notificationBox.PRIORITY_WARNING_MEDIUM;
+      let iconURL = "chrome://mozapps/skin/plugins/pluginGeneric-16.png";
+      let label = gNavigatorBundle.getString("crashedpluginsMessage.reloadButton.label");
+      let accessKey = gNavigatorBundle.getString("crashedpluginsMessage.reloadButton.accesskey");
+
+      let buttons = [{
+        label: label,
+        accessKey: accessKey,
+        popup: null,
+        callback: function() { browser.reload(); },
+      }];
+
+      let notification = notificationBox.appendNotification(messageString, "plugin-crashed",
+                                                            iconURL, priority, buttons);
+    }
+
   },
 
   refreshBrowser: function (aEvent) {
     // browser elements are anonymous so we can't just use target.
     var browser = aEvent.originalTarget;
     var notificationBox = gBrowser.getNotificationBox(browser);
     var notification = notificationBox.getNotificationWithValue("missing-plugins");
 
@@ -6506,26 +6660,32 @@ var gIdentityHandler = {
     delete this._identityIconLabel;
     return this._identityIconLabel = document.getElementById("identity-icon-label");
   },
   get _overrideService () {
     delete this._overrideService;
     return this._overrideService = Cc["@mozilla.org/security/certoverride;1"]
                                      .getService(Ci.nsICertOverrideService);
   },
+  get _identityIconCountryLabel () {
+    delete this._identityIconCountryLabel;
+    return this._identityIconCountryLabel = document.getElementById("identity-icon-country-label");
+  },
 
   /**
    * Rebuild cache of the elements that may or may not exist depending
    * on whether there's a location bar.
    */
   _cacheElements : function() {
     delete this._identityBox;
     delete this._identityIconLabel;
+    delete this._identityIconCountryLabel;
     this._identityBox = document.getElementById("identity-box");
     this._identityIconLabel = document.getElementById("identity-icon-label");
+    this._identityIconCountryLabel = document.getElementById("identity-icon-country-label");
   },
 
   /**
    * Handler for mouseclicks on the "More Information" button in the
    * "identity-popup" panel.
    */
   handleMoreInfoClick : function(event) {
     displaySecurityInfo();
@@ -6640,16 +6800,18 @@ var gIdentityHandler = {
       
       // It would be sort of nice to use the CN= field in the cert, since that's
       // typically what we want here, but thanks to x509 certs being extensible,
       // it's not the only place you have to check, there can be more than one domain,
       // et cetera, ad nauseum.  We know the cert is valid for location.host, so
       // let's just use that. Check the pref to determine how much of the verified
       // hostname to show
       var icon_label = "";
+      var icon_country_label = "";
+      var icon_labels_dir = "ltr";
       switch (gPrefService.getIntPref("browser.identity.ssl_domain_display")) {
         case 2 : // Show full domain
           icon_label = this._lastLocation.hostname;
           break;
         case 1 : // Show eTLD.
           icon_label = this.getEffectiveHost();
       }
       
@@ -6670,33 +6832,47 @@ var gIdentityHandler = {
       // something in the default case (bug 432241).
       if (this._overrideService.hasMatchingOverride(this._lastLocation.hostname, 
                                                     (this._lastLocation.port || 443),
                                                     iData.cert, {}, {}))
         tooltip = gNavigatorBundle.getString("identity.identified.verified_by_you");
     }
     else if (newMode == this.IDENTITY_MODE_IDENTIFIED) {
       // If it's identified, then we can populate the dialog with credentials
-      iData = this.getIdentityData();  
+      iData = this.getIdentityData();
       tooltip = gNavigatorBundle.getFormattedString("identity.identified.verifier",
                                                     [iData.caOrg]);
+      icon_label = iData.subjectOrg;
       if (iData.country)
-        icon_label = gNavigatorBundle.getFormattedString("identity.identified.title_with_country",
-                                                         [iData.subjectOrg, iData.country]);
-      else
-        icon_label = iData.subjectOrg;
+        icon_country_label = "(" + iData.country + ")";
+      // If the organization name starts with an RTL character, then
+      // swap the positions of the organization and country code labels.
+      // The Unicode ranges reflect the definition of the UCS2_CHAR_IS_BIDI
+      // macro in intl/unicharutil/util/nsBidiUtils.h. When bug 218823 gets
+      // fixed, this test should be replaced by one adhering to the
+      // Unicode Bidirectional Algorithm proper (at the paragraph level).
+      icon_labels_dir = /^[\u0590-\u08ff\ufb1d-\ufdff\ufe70-\ufefc]/.test(icon_label) ?
+                        "rtl" : "ltr";
     }
     else {
       tooltip = gNavigatorBundle.getString("identity.unknown.tooltip");
       icon_label = "";
+      icon_country_label = "";
+      icon_labels_dir = "ltr";
     }
     
     // Push the appropriate strings out to the UI
     this._identityBox.tooltipText = tooltip;
     this._identityIconLabel.value = icon_label;
+    this._identityIconCountryLabel.value = icon_country_label;
+    // Set cropping and direction
+    this._identityIconLabel.crop = icon_country_label ? "end" : "center";
+    this._identityIconLabel.parentNode.style.direction = icon_labels_dir;
+    // Hide completely if the organization label is empty
+    this._identityIconLabel.parentNode.hidden = icon_label ? false : true;
   },
   
   /**
    * Set up the title and content messages for the identity message popup,
    * based on the specified mode, and the details of the SSL cert, where
    * applicable
    *
    * @param newMode The newly set identity mode.  Should be one of the IDENTITY_MODE_* constants.
@@ -7166,50 +7342,16 @@ let gPrivateBrowsingUI = {
       !this.privateBrowsingEnabled;
   },
 
   get privateBrowsingEnabled PBUI_get_privateBrowsingEnabled() {
     return this._privateBrowsingService.privateBrowsingEnabled;
   }
 };
 
-let gURLBarEmptyText = {
-  domain: "browser.urlbar.",
-
-  observe: function UBET_observe(aSubject, aTopic, aPrefName) {
-    if (aTopic == "nsPref:changed") {
-      switch (aPrefName) {
-      case "browser.urlbar.autocomplete.enabled":
-      case "browser.urlbar.default.behavior":
-        gURLBar.emptyText = this.value;
-        break;
-      }
-    }
-  },
-
-  get value UBET_get_value() {
-    let type = "none";
-    if (gPrefService.getBoolPref("browser.urlbar.autocomplete.enabled")) {
-      // Bottom 2 bits of default.behavior specify history/bookmark
-      switch (gPrefService.getIntPref("browser.urlbar.default.behavior") & 3) {
-      case 0:
-        type = "bookmarkhistory";
-        break;
-      case 1:
-        type = "history";
-        break;
-      case 2:
-        type = "bookmark";
-        break;
-      }
-    }
-    return gURLBar.getAttribute(type + "emptytext");
-  }
-};
-
 var LightWeightThemeWebInstaller = {
   handleEvent: function (event) {
     switch (event.type) {
       case "InstallBrowserTheme":
       case "PreviewBrowserTheme":
       case "ResetBrowserThemePreview":
         // ignore requests from background tabs
         if (event.target.ownerDocument.defaultView.top != content)
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -418,17 +418,20 @@
               <stack id="page-proxy-stack"
                      onclick="PageProxyClickHandler(event);">
                 <image id="urlbar-throbber" busy="false"/>
                 <image id="page-proxy-favicon" validate="never"
                        pageproxystate="invalid"
                        ondragstart="proxyIconDNDObserver.onDragStart(event);"
                        onerror="this.removeAttribute('src');"/>
               </stack>
-              <label id="identity-icon-label" crop="center" flex="1"/>
+              <hbox id="identity-icon-labels">
+                <label id="identity-icon-label" class="plain" flex="1"/>
+                <label id="identity-icon-country-label" class="plain"/>
+              </hbox>
             </hbox>
           </box>
           <hbox id="urlbar-icons">
             <button type="menu"
                     style="-moz-user-focus: none"
                     class="plain urlbar-icon"
                     id="feed-button"
                     collapsed="true"
@@ -549,25 +552,25 @@
 #ifdef WINCE
              defaultset="unified-back-forward-button,reload-button,stop-button,home-button,urlbar-container,search-container,navigator-throbber,fullscreenflex,window-controls"
 #else
              defaultset="unified-back-forward-button,reload-button,stop-button,home-button,urlbar-container,search-container,fullscreenflex,window-controls"
 #endif
              context="toolbar-context-menu">
       <hbox id="fullscreenflex" flex="1" hidden="true" fullscreencontrol="true"/>
       <hbox id="window-controls" hidden="true" fullscreencontrol="true">
-        <toolbarbutton id="minimize-button" class="toolbarbutton-1"
+        <toolbarbutton id="minimize-button"
                        tooltiptext="&fullScreenMinimize.tooltip;"
                        oncommand="window.minimize();"/>
 
-        <toolbarbutton id="restore-button" class="toolbarbutton-1"
+        <toolbarbutton id="restore-button"
                        tooltiptext="&fullScreenRestore.tooltip;"
                        oncommand="BrowserFullScreen();"/>
 
-        <toolbarbutton id="close-button" class="toolbarbutton-1"
+        <toolbarbutton id="close-button"
                        tooltiptext="&fullScreenClose.tooltip;"
                        oncommand="BrowserTryToCloseWindow();"/>
       </hbox>
     </toolbar>
 
     <toolbarset id="customToolbars" context="toolbar-context-menu"/>
 
     <toolbar id="PersonalToolbar"
@@ -631,9 +634,17 @@
           <menuitem observes="blockedPopupAllowSite"/>
           <menuitem observes="blockedPopupEditSettings"/>
           <menuitem observes="blockedPopupDontShowMessage"/>
           <menuseparator observes="blockedPopupsSeparator"/>
         </menupopup>
       </statusbarpanel>
     </statusbar>
   </vbox>
+#ifndef XP_UNIX
+  <svg:svg height="0">
+    <svg:mask id="winstripe-keyhole-forward-mask" maskContentUnits="objectBoundingBox">
+      <svg:rect x="0" y="0" width="1" height="1" fill="white"/>
+      <svg:circle cx="-0.42" cy="0.5" r="0.63" id="circle"/>
+    </svg:mask>
+  </svg:svg>
+#endif
 </window>
--- a/browser/base/content/test/browser_allTabsPanel.js
+++ b/browser/base/content/test/browser_allTabsPanel.js
@@ -64,16 +64,17 @@ function next() {
     if (steps-- <= 0) {
       nextSequence();
       return;
     }
     var step;
     var rv;
     do {
       step = pickOne(allTabs.isOpen ? whenOpen : whenClosed);
+      info(step.name);
       rv = step();
     } while (rv === false);
     history.push(step.name + (rv !== true && rv !== undefined ? " " + rv : ""));
   });
 }
 
 function openPanel() {
   if (allTabs.isOpen)
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -48,16 +48,20 @@
                                 .getBranch("browser.urlbar.")
                                 .QueryInterface(Components.interfaces.nsIPrefBranch2);
 
         this._prefs.addObserver("", this, false);
         this.clickSelectsAll = this._prefs.getBoolPref("clickSelectsAll");
         this.doubleClickSelectsAll = this._prefs.getBoolPref("doubleClickSelectsAll");
         this.completeDefaultIndex = this._prefs.getBoolPref("autoFill");
         this.timeout = this._prefs.getIntPref("delay");
+        setTimeout(function (self) {
+          if (self._setEmptyText)
+            self._setEmptyText();
+        }, 0, this);
 
         this._urlTooltip = document.getElementById("urlTooltip");
 
         this.inputField.controllers.insertControllerAt(0, this._copyCutController);
         this.inputField.addEventListener("mousedown", this, false);
         this.inputField.addEventListener("mousemove", this, false);
         this.inputField.addEventListener("mouseout", this, false);
         this.inputField.addEventListener("overflow", this, false);
@@ -357,16 +361,20 @@
                 this[aData] = this._prefs.getBoolPref(aData);
                 break;
               case "autoFill":
                 this.completeDefaultIndex = this._prefs.getBoolPref(aData);
                 break;
               case "delay":
                 this.timeout = this._prefs.getIntPref(aData);
                 break;
+              case "autocomplete.enabled":
+              case "default.behavior":
+                this._setEmptyText();
+                break;
             }
           }
         ]]></body>
       </method>
 
       <method name="handleEvent">
         <parameter name="aEvent"/>
         <body><![CDATA[
@@ -411,16 +419,37 @@
           this.mIgnoreInput = true;
           this.dispatchEvent(evt);
           this.mIgnoreInput = false;
 
           return this.value;
           ]]>
         </setter>
       </property>
+
+      <method name="_setEmptyText">
+        <body><![CDATA[
+          var type = "none";
+          if (this._prefs.getBoolPref("autocomplete.enabled")) {
+            // Bottom 2 bits of default.behavior specify history/bookmark
+            switch (this._prefs.getIntPref("default.behavior") & 3) {
+              case 0:
+                type = "bookmarkhistory";
+                break;
+              case 1:
+                type = "history";
+                break;
+              case 2:
+                type = "bookmark";
+                break;
+            }
+          }
+          this.emptyText = this.getAttribute(type + "emptytext");
+        ]]></body>
+      </method>
     </implementation>
 
     <handlers>
       <handler event="draggesture" phase="capturing"><![CDATA[
         // TODO: This should use dragstart but editor code is still using
         //       the old drag & drop APIs, so we have to handle draggesture.
         //       This can be changed once editor code is updated to the new API.
         //       See bug 499008 for details.
--- a/browser/components/preferences/advanced.js
+++ b/browser/components/preferences/advanced.js
@@ -61,16 +61,19 @@ var gAdvancedPane = {
     }
 
 #ifdef MOZ_UPDATER
     this.updateAppUpdateItems();
     this.updateAutoItems();
     this.updateModeItems();
 #endif
     this.updateOfflineApps();
+#ifdef MOZ_CRASHREPORTER
+    this.initSubmitCrashes();
+#endif
   },
 
   /**
    * Stores the identity of the current tab in preferences so that the selected
    * tab can be persisted between openings of the preferences window.
    */
   tabSelectionChanged: function ()
   {
@@ -134,16 +137,45 @@ var gAdvancedPane = {
    * unchanged and represents a value not strictly allowed in UI.
    */
   writeCheckSpelling: function ()
   {
     var checkbox = document.getElementById("checkSpelling");
     return checkbox.checked ? (this._storedSpellCheck == 2 ? 2 : 1) : 0;
   },
 
+  /**
+   *
+   */
+  initSubmitCrashes: function ()
+  {
+    var checkbox = document.getElementById("submitCrashesBox");
+    try {
+      var cr = Components.classes["@mozilla.org/toolkit/crash-reporter;1"].
+               getService(Components.interfaces.nsICrashReporter);
+      checkbox.checked = cr.submitReports;
+    } catch (e) {
+      checkbox.style.display = "none";
+    }
+  },
+
+  /**
+   *
+   */
+  updateSubmitCrashes: function ()
+  {
+    var checkbox = document.getElementById("submitCrashesBox");
+    try {
+      var cr = Components.classes["@mozilla.org/toolkit/crash-reporter;1"].
+               getService(Components.interfaces.nsICrashReporter);
+      cr.submitReports = checkbox.checked;
+    } catch (e) { }
+  },
+
+
   // NETWORK TAB
 
   /*
    * Preferences:
    *
    * browser.cache.disk.capacity
    * - the size of the browser cache in KB
    */
--- a/browser/components/preferences/advanced.xul
+++ b/browser/components/preferences/advanced.xul
@@ -179,28 +179,33 @@
                       accesskey="&checkSpelling.accesskey;"
                       onsyncfrompreference="return gAdvancedPane.readCheckSpelling();"
                       onsynctopreference="return gAdvancedPane.writeCheckSpelling();"
                       preference="layout.spellcheckDefault"/>
           </groupbox>
 
 #ifdef HAVE_SHELL_SERVICE
           <!-- System Defaults -->
-          <groupbox id="systemDefaultsGroup" orient="horizontal">
+          <groupbox id="systemDefaultsGroup" orient="vertical">
             <caption label="&systemDefaults.label;"/>
 
             <hbox id="checkDefaultBox" align="center" flex="1">      
               <checkbox id="alwaysCheckDefault" preference="browser.shell.checkDefaultBrowser"
                         label="&alwaysCheckDefault.label;" accesskey="&alwaysCheckDefault.accesskey;"
                         flex="1"/>
               <button id="checkDefaultButton"
                       label="&checkNow.label;" accesskey="&checkNow.accesskey;"
                       oncommand="gAdvancedPane.checkNow()"
                       preference="pref.general.disable_button.default_browser"/>
             </hbox>
+#ifdef MOZ_CRASHREPORTER
+            <checkbox id="submitCrashesBox" flex="1"
+                      oncommand="gAdvancedPane.updateSubmitCrashes();"
+                      label="&submitCrashes.label;" accesskey="&submitCrashes.accesskey;"/>
+#endif
           </groupbox>
 #endif
         </tabpanel>
 
         <!-- Network -->
         <tabpanel id="networkPanel" orient="vertical">
 
            <!-- Connection -->
--- a/browser/components/search/content/engineManager.xul
+++ b/browser/components/search/content/engineManager.xul
@@ -48,17 +48,17 @@
         buttonlabelextra2="&restoreDefaults.label;"
         buttonaccesskeyextra2="&restoreDefaults.accesskey;"
         onload="gEngineManagerDialog.init();"
         ondialogaccept="gEngineManagerDialog.onOK();"
         ondialogcancel="gEngineManagerDialog.onCancel();"
         ondialogextra2="gEngineManagerDialog.onRestoreDefaults();"
         title="&engineManager.title;"
         style="&engineManager.style;"
-        persist="screenX screenY"
+        persist="screenX screenY width height"
         windowtype="Browser:SearchManager">
 
   <script type="application/javascript"
           src="chrome://browser/content/search/engineManager.js"/>
 
   <commandset id="engineManagerCommandSet">
     <command id="cmd_remove"
              oncommand="gEngineManagerDialog.remove();"
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -71,30 +71,32 @@
                    autocompletesearch="search-autocomplete"
                    autocompletesearchparam="searchbar-history"
                    timeout="250"
                    maxrows="10"
                    completeselectedindex="true"
                    showcommentcolumn="true"
                    tabscrolling="true"
                    xbl:inherits="disabled,disableautocomplete,searchengine,src,newlines">
-        <xul:button class="searchbar-engine-button"
-                    type="menu"
-                    anonid="searchbar-engine-button">
-          <xul:image class="searchbar-engine-image" xbl:inherits="src"/>
-          <xul:image class="searchbar-dropmarker-image"/>
-          <xul:menupopup class="searchbar-popup"
-                         anonid="searchbar-popup">
-            <xul:menuseparator/>
-            <xul:menuitem class="open-engine-manager"
-                          anonid="open-engine-manager"
-                          label="&cmd_engineManager.label;"
-                          oncommand="openManager(event);"/>
-          </xul:menupopup>
-        </xul:button>
+        <xul:box>
+          <xul:button class="searchbar-engine-button"
+                      type="menu"
+                      anonid="searchbar-engine-button">
+            <xul:image class="searchbar-engine-image" xbl:inherits="src"/>
+            <xul:image class="searchbar-dropmarker-image"/>
+            <xul:menupopup class="searchbar-popup"
+                           anonid="searchbar-popup">
+              <xul:menuseparator/>
+              <xul:menuitem class="open-engine-manager"
+                            anonid="open-engine-manager"
+                            label="&cmd_engineManager.label;"
+                            oncommand="openManager(event);"/>
+            </xul:menupopup>
+          </xul:button>
+        </xul:box>
         <xul:hbox class="search-go-container">
           <xul:image class="search-go-button"
                      anonid="search-go-button"
                      onclick="handleSearchCommand(event);"
                      tooltiptext="&searchEndCap.label;" />
         </xul:hbox>
       </xul:textbox>
     </content>
@@ -427,17 +429,17 @@
                           .getService(Components.interfaces.nsIWindowMediator);
 
           var window = wm.getMostRecentWindow("Browser:SearchManager");
           if (window)
             window.focus()
           else {
             setTimeout(function () {
               openDialog("chrome://browser/content/search/engineManager.xul",
-                         "_blank", "chrome,dialog,modal,centerscreen");
+                         "_blank", "chrome,dialog,modal,centerscreen,resizable");
             }, 0);
           }
         ]]></body>
       </method>
 
       <method name="selectEngine">
         <parameter name="aEvent"/>
         <parameter name="isNextEngine"/>
--- a/browser/installer/Makefile.in
+++ b/browser/installer/Makefile.in
@@ -38,28 +38,16 @@
 
 DEPTH		= ../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-NO_PKG_FILES = \
-	$(MOZ_APP_NAME)-config \
-	$(MOZ_APP_NAME)-bin.elf \
-	nspr-config \
-	regchrome* \
-	regxpcom* \
-	xpcshell* \
-	xpidl* \
-	xpt_dump* \
-	xpt_link* \
-	$(NULL)
-
 include $(topsrcdir)/config/rules.mk
 
 MOZ_PKG_REMOVALS = $(srcdir)/removed-files.in
 
 ifdef MOZ_ENABLE_LIBXUL
 MOZ_PKG_MANIFEST_P = $(srcdir)/package-manifest.in
 else
 define message
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -334,16 +334,17 @@
 @BINPATH@/components/nsFormAutoComplete.js
 @BINPATH@/components/contentSecurityPolicy.js
 #ifdef XP_MACOSX
 @BINPATH@/components/libalerts_s.dylib
 #endif
 #ifdef MOZ_ENABLE_DBUS
 @BINPATH@/components/@DLL_PREFIX@dbusservice@DLL_SUFFIX@
 #endif
+@BINPATH@/components/nsINIProcessor.js
 
 ; Modules
 @BINPATH@/modules/*
 
 ; Safe Browsing
 @BINPATH@/components/nsSafebrowsingApplication.js
 @BINPATH@/components/nsUrlClassifierListManager.js
 @BINPATH@/components/nsUrlClassifierLib.js
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -69,16 +69,19 @@ missingpluginsMessage.button.accesskey=I
 outdatedpluginsMessage.title=Some plugins used by this page are out of date.
 outdatedpluginsMessage.updateButton.label=Update Plugins…
 outdatedpluginsMessage.updateButton.accesskey=U
 blockedpluginsMessage.title=Some plugins required by this page have been blocked for your protection.
 blockedpluginsMessage.infoButton.label=Details…
 blockedpluginsMessage.infoButton.accesskey=D
 blockedpluginsMessage.searchButton.label=Update Plugins…
 blockedpluginsMessage.searchButton.accesskey=U
+crashedpluginsMessage.title=The %S plugin has crashed.
+crashedpluginsMessage.reloadButton.label=Reload page
+crashedpluginsMessage.reloadButton.accesskey=R
 
 # Sanitize
 # LOCALIZATION NOTE (sanitizeDialog2.everything.title): When "Time range to
 # clear" is set to "Everything", the Clear Recent History dialog's title is
 # changed to this.  See UI mockup and comment 11 at bug 480169 -->
 sanitizeDialog2.everything.title=Clear All History
 sanitizeButtonOK=Clear Now
 # LOCALIZATION NOTE (sanitizeEverythingWarning2): Warning that appears when
@@ -150,17 +153,16 @@ offlineApps.notNowAccessKey=N
 
 offlineApps.usage=This website (%S) is now storing more than %SMB of data on your computer for offline use.
 offlineApps.manageUsage=Show settings
 offlineApps.manageUsageAccessKey=S
 
 identity.identified.verifier=Verified by: %S
 identity.identified.verified_by_you=You have added a security exception for this site.
 identity.identified.state_and_country=%S, %S
-identity.identified.title_with_country=%S (%S)
 
 identity.encrypted=Your connection to this web site is encrypted to prevent eavesdropping.
 identity.unencrypted=Your connection to this web site is not encrypted.
 identity.mixed_content=Your connection to this site is only partially encrypted, and does not prevent eavesdropping.
 
 identity.unknown.tooltip=This web site does not supply identity information.
 
 identity.ownerUnknown2=(unknown)
--- a/browser/locales/en-US/chrome/browser/preferences/advanced.dtd
+++ b/browser/locales/en-US/chrome/browser/preferences/advanced.dtd
@@ -20,16 +20,18 @@
 <!ENTITY checkSpelling.label             "Check my spelling as I type">
 <!ENTITY checkSpelling.accesskey         "t">
 
 <!ENTITY systemDefaults.label            "System Defaults">
 <!ENTITY alwaysCheckDefault.label        "Always check to see if &brandShortName; is the default browser on startup"><!--XXX-->
 <!ENTITY alwaysCheckDefault.accesskey    "w">
 <!ENTITY checkNow.label                  "Check Now">
 <!ENTITY checkNow.accesskey              "N">
+<!ENTITY submitCrashes.label             "Submit crash reports">
+<!ENTITY submitCrashes.accesskey         "S">
 
 <!ENTITY networkTab.label                "Network">
 
 <!ENTITY connection.label                "Connection">
 
 <!ENTITY connectionDesc.label            "Configure how &brandShortName; connects to the Internet">
 <!ENTITY connectionSettings.label        "Settings…">
 <!ENTITY connectionSettings.accesskey    "e">
--- a/browser/themes/gnomestripe/browser/browser.css
+++ b/browser/themes/gnomestripe/browser/browser.css
@@ -861,23 +861,18 @@ toolbar[iconsize="small"] #fullscreen-bu
   background-color: rgba(255, 255, 255, .2);
 }
 
 #identity-box:hover:active > #identity-box-inner,
 #identity-box[open="true"] > #identity-box-inner {
   background-color: rgba(0, 0, 0, .1);
 }
 
-#identity-icon-label {
+#identity-icon-labels {
   padding: 0 2px;
-  margin: 0;
-}
-
-#identity-icon-label[value=""] {
-  display: none;
 }
 
 #identity-box.verifiedDomain {
   background-color: rgba(30, 80, 170, 0.7);
   color: white;
 }
 
 #identity-box.verifiedIdentity {
@@ -1191,25 +1186,16 @@ statusbarpanel#statusbar-display {
 #context_undoCloseTab {
   list-style-image: url("moz-icon://stock/gtk-undelete?size=menu");
 }
 
 #context_closeTab {
   list-style-image: url("moz-icon://stock/gtk-close?size=menu");
 }
 
-/* tabbrowser-tab focus ring */
-.tabbrowser-tab > .tab-text {
-  border: 1px dotted transparent;
-}
-
-.tabbrowser-tab:focus > .tab-text {
-  border: 1px dotted -moz-DialogText;
-}
-
 /* Tab drag and drop */
 .tab-drop-indicator-bar {
   height: 11px;
   margin-top: -11px;
   position: relative;
   /* set -moz-margin-start to -1/2 indicator width: */
   -moz-margin-start: -5px;
 }
--- a/browser/themes/gnomestripe/browser/searchbar.css
+++ b/browser/themes/gnomestripe/browser/searchbar.css
@@ -1,15 +1,19 @@
 .searchbar-textbox {
   min-height: 22px;
   width: 6em;
   min-width: 6em;
   background-color: -moz-field;
 }
 
+.autocomplete-textbox-container {
+  -moz-box-align: stretch;
+}
+
 .textbox-input-box {
   margin: 0;
 }
 
 .searchbar-engine-menuitem[selected="true"] > .menu-iconic-text {
   font-weight: bold;
 }
 
deleted file mode 100644
index 49352717ba8ecb9740e96399e1111761bdac5154..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 3a71df7f9068e1620132296c42762debf32c1fc0..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 48e0dda4726add57e3b3ff6972a6869acc246062..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index f620f8dbff306155140a18668e7123eb4c2e92a9..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 2616e00107084a97bf66d9c07b14c8281f07b485..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
--- a/browser/themes/pinstripe/browser/browser.css
+++ b/browser/themes/pinstripe/browser/browser.css
@@ -38,26 +38,28 @@
  * 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 ***** */
 
 @import url("chrome://global/skin/");
 
+%include shared.inc
+
 @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
 @namespace html url("http://www.w3.org/1999/xhtml");
 
 #urlbar:-moz-lwtheme:not([focused="true"]),
 .searchbar-textbox:-moz-lwtheme:not([focused="true"]) {
   opacity: .9;
 }
 
 #navigator-toolbox toolbarbutton:-moz-lwtheme {
-  color: inherit !important;
+  color: inherit;
   text-shadow: inherit;
 }
 
 #PersonalToolbar:-moz-lwtheme,
 #nav-bar:-moz-lwtheme {
   -moz-appearance: none !important;
   background: none !important;
   /* Switching to a lightweight theme shouldn't move the content area,
@@ -126,17 +128,16 @@
 
 /* ----- INACTIVE WINDOW ----- */
 
 #main-window:not([active="true"]) > #navigator-toolbox > #nav-bar {
   background-image: url("chrome://global/skin/toolbar/toolbar-background-inactive.png");
 }
 
 #main-window:not([active="true"]) > #navigator-toolbox > #PersonalToolbar {
-  border-top-color: rgba(255, 255, 255, 0.48);
   background-color: -moz-mac-chrome-inactive;
   border-bottom-color: rgba(0, 0, 0, 0.32);
 }
 
 #main-window:not([active="true"]) > #navigator-toolbox > toolbar > toolbaritem,
 #main-window:not([active="true"]) > #navigator-toolbox > toolbar > toolbarbutton,
 #main-window:not([active="true"]) .tabs-newtab-button > .toolbarbutton-icon {
   opacity: 0.75;
@@ -158,148 +159,111 @@
 #main-window:not([active="true"]) .tabbrowser-tab[selected="true"] {
   background-color: -moz-mac-chrome-inactive;
 }
 
 /* ----- BOOKMARK TOOLBAR ----- */
 
 #PersonalToolbar {
   -moz-appearance: none;
-  background: url("chrome://browser/skin/bookmark_toolbar_background.png") repeat-x center center -moz-mac-chrome-active;
-  border-top: 1px solid rgba(255, 255, 255, 0.4);
+  margin-top: -1px; /* overlay the bottom border of the toolbar above us */
+  background-color: -moz-mac-chrome-active;
   border-bottom: 1px solid rgba(0, 0, 0, 0.57);
+  min-height: 22px;
+  padding: 0 4px 3px;
+  -moz-box-align: center;
 }
 
 #personal-bookmarks {
-  min-height: 21px;
-  -moz-margin-start: 1px;
+  -moz-box-align: center;
+}
+
+toolbarbutton.chevron {
+  list-style-image: url("chrome://global/skin/icons/chevron.png");
+  margin: 1px 0 0;
+  padding: 0;
+}
+
+toolbarbutton.chevron > .toolbarbutton-text {
+  display: none;
+}
+
+toolbarbutton.chevron:-moz-locale-dir(rtl) > .toolbarbutton-icon {
+  -moz-transform: scaleX(-1);
 }
 
 /* ----- BOOKMARK BUTTONS ----- */	
 
 toolbarbutton.bookmark-item {
   font-weight: bold;
-  margin: 0 0 1px;
-  padding: 0;
-  -moz-padding-start: 7px;
-  min-width: 0;
-  max-width: 13em;
   color: #222;
-  border: none !important;
+  border: 0;
+  -moz-border-radius: 100%;
+  padding: 0 8px;
+  margin: 0;
+  height: 16px;
+}
+
+.bookmark-item > .toolbarbutton-menu-dropmarker {
+  list-style-image: url("chrome://browser/skin/places/folderDropArrow.png");
+  -moz-image-region: rect(0, 7px, 5px, 0);
+  margin-top: 1px;
+  -moz-margin-start: 3px;
+  -moz-margin-end: -2px;
+}
+
+.bookmark-item > .toolbarbutton-text {
+  display: -moz-box !important; /* prevent [mode="icons"] from hiding the label */
+  margin: 0 !important;
+}
+
+toolbarbutton.bookmark-item:hover,
+toolbarbutton.bookmark-item[open="true"] {
+  background-color: rgba(0, 0, 0, .205);
 }
 
-toolbarbutton.bookmark-item[type=menu] > .toolbarbutton-menu-dropmarker {
-  -moz-padding-end: 7px;
+toolbarbutton.bookmark-item:hover,
+toolbarbutton.bookmark-item[open="true"] {
+  color: #FFF !important;
+  text-shadow: 0 1px rgba(0, 0, 0, .4) !important;
+}
+
+.bookmark-item:hover > .toolbarbutton-menu-dropmarker,
+.bookmark-item[open="true"] > .toolbarbutton-menu-dropmarker {
+  -moz-image-region: rect(5px, 7px, 10px, 0);
 }
 
-toolbarbutton.bookmark-item[type=menu]:-moz-locale-dir(rtl) > .toolbarbutton-menu-dropmarker {
-  -moz-padding-start: 4px;
-  -moz-padding-end: 2px;
+toolbarbutton.bookmark-item:active:hover,
+toolbarbutton.bookmark-item[open="true"] {
+  -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.4), 0 1px rgba(255, 255, 255, 0.4);
+  background-color: rgba(0, 0, 0, .5);
 }
 
-toolbarbutton.bookmark-item:-moz-locale-dir(rtl) {
-  -moz-padding-start: 0px;
-  -moz-padding-end: 7px;
+.bookmark-item[livemark] > .toolbarbutton-menu-dropmarker {
+  list-style-image: url("chrome://browser/skin/places/livemarkFolder.png");
+  -moz-image-region: rect(0, 9px, 10px, 0);
+}
+
+.bookmark-item[livemark]:hover > .toolbarbutton-menu-dropmarker,
+.bookmark-item[livemark][open="true"] > .toolbarbutton-menu-dropmarker {
+  -moz-image-region: rect(0, 18px, 10px, 9px);
+}
+
+.bookmark-item > .toolbarbutton-icon {
+  display: none !important;
 }
 
 .bookmark-item[container] {
   list-style-image: url("chrome://global/skin/tree/folder.png");
 }
 
 .query-item[container] {
   list-style-image: url("chrome://browser/skin/places/history.png");
 }
 
-toolbarbutton.bookmark-item > .toolbarbutton-text {
-  margin: 0;
-}
-
-toolbarbutton.bookmark-item:not([container]) > .toolbarbutton-text {
-  -moz-padding-end: 7px;
-}
-
-toolbarbutton.bookmark-item:-moz-locale-dir(rtl) > .toolbarbutton-text {
-  -moz-padding-end: 0;
-  -moz-padding-start: 7px;
-}
-
-toolbarbutton.bookmark-item:hover {
-  background: url("chrome://global/skin/toolbar/toolbarbutton-customhover-left.png") no-repeat left center;
-}
-
-toolbarbutton.bookmark-item:hover:active,
-toolbarbutton.bookmark-item[open="true"] {
-  background:url("chrome://browser/skin/bookmark-open-left.png") no-repeat left center;
-}
-
-toolbarbutton.bookmark-item:not([container]):hover > .toolbarbutton-text,
-toolbarbutton.bookmark-item[container]:not([open]):hover > .toolbarbutton-menu-dropmarker {
-  background: url("chrome://global/skin/toolbar/toolbarbutton-customhover-right.png") no-repeat right top;
-}
-
-toolbarbutton.bookmark-item[container]:hover > .toolbarbutton-text,
-toolbarbutton.bookmark-item[container]:-moz-locale-dir(rtl):not([open]):hover > .toolbarbutton-menu-dropmarker,
-#home-button.bookmark-item:hover > .toolbarbutton-icon,
-#home-button.bookmark-item:-moz-locale-dir(rtl):hover > .toolbarbutton-text {
-  background: url("chrome://global/skin/toolbar/toolbarbutton-customhover-mid.png") repeat-x;
-}
-
-#home-button.bookmark-item:hover:-moz-locale-dir(rtl) > .toolbarbutton-icon,
-toolbarbutton.bookmark-item:-moz-locale-dir(rtl):hover > .toolbarbutton-text {
-  background: url("chrome://global/skin/toolbar/toolbarbutton-customhover-right.png") no-repeat right top;
-}
-
-toolbarbutton.bookmark-item:not([container]):hover:active > .toolbarbutton-text,
-toolbarbutton.bookmark-item[open] > .toolbarbutton-menu-dropmarker,
-toolbarbutton.bookmark-item[container]:hover:active > .toolbarbutton-menu-dropmarker {
-  background: url("chrome://browser/skin/bookmark-open-right.png") no-repeat right top;
-}
-
-toolbarbutton.bookmark-item[container]:hover:active > .toolbarbutton-text,
-toolbarbutton.bookmark-item[container][open="true"] > .toolbarbutton-text,
-#home-button.bookmark-item:hover:active > .toolbarbutton-icon,
-toolbarbutton.bookmark-item[container]:-moz-locale-dir(rtl):hover:active > .toolbarbutton-menu-dropmarker,
-toolbarbutton.bookmark-item[container]:-moz-locale-dir(rtl)[open="true"] > .toolbarbutton-menu-dropmarker,
-#home-button.bookmark-item:hover:active:-moz-locale-dir(rtl) > .toolbarbutton-text {
-  background: url("chrome://browser/skin/bookmark-open-mid.png") repeat-x !important;
-}
-
-toolbarbutton.bookmark-item:-moz-locale-dir(rtl)[container]:hover:active > .toolbarbutton-text,
-toolbarbutton.bookmark-item:-moz-locale-dir(rtl)[container][open] > .toolbarbutton-text,
-#home-button.bookmark-item:-moz-locale-dir(rtl):hover:active > .toolbarbutton-icon {
-  background: url("chrome://browser/skin/bookmark-open-right.png") no-repeat right top !important;
-}
-
-toolbarbutton.bookmark-item-microsummarized {
-  max-width: 20em;
-}
-
-.bookmark-item > .toolbarbutton-icon {
-  margin: 0px;
-  display: none !important;
-}
-
-/* Prevent [mode="icons"] from hiding the label */
-.bookmark-item .toolbarbutton-text {
-  display: -moz-box !important;
-  height: 16px !important;
-  padding-top: 1px;
-}
-
-.bookmark-item > .toolbarbutton-menu-dropmarker {
-  list-style-image: url("chrome://browser/skin/places/folderDropArrow.png");
-  height: 16px !important;
-  padding: 5px 5px 4px 3px;
-}
-
-.bookmark-item[livemark] > .toolbarbutton-menu-dropmarker {
-  list-style-image: url("chrome://browser/skin/places/livemarkFolder.png");
-  padding: 3px 4px 3px 4px;
-}
-
 .bookmark-item[livemark] {
   list-style-image: url("chrome://browser/skin/page-livemarks.png");
 }
 
 .bookmark-item[query] {
   list-style-image: url("chrome://browser/skin/places/query.png");
 }
 
@@ -323,20 +287,16 @@ toolbarbutton.bookmark-item-microsummari
   list-style-image: url("chrome://browser/skin/places/livemarkItem.png");
 }
 
 .bookmark-item menuitem[openInTabs],
 .bookmark-item menuitem[siteURI] {
   list-style-image: none;
 }
 
-.toolbarpaletteitem-box[type="bookmarks-toolbar"][place="palette"] {
-  background: url("chrome://browser/skin/bookmarks/Toolbar-bookmarks.png") no-repeat;
-}
-
 #wrapper-personal-bookmarks[place="palette"] > .toolbarpaletteitem-box {
   width: 16px;
   height: 16px;
   background: url("chrome://browser/skin/places/bookmarksToolbar.png") no-repeat;
 }
 
 .bookmarks-toolbar-customize {
   max-width: 15em !important;
@@ -352,43 +312,38 @@ toolbarbutton.bookmark-item-microsummari
 
 #bookmarksToolbarFolderMenu {
   list-style-image: url("chrome://browser/skin/places/bookmarksToolbar.png");  
 }
 
 /* ----- PRIMARY TOOLBAR BUTTONS ----- */	
 
 .toolbarbutton-1,
+#restore-button,
 #back-forward-dropmarker {
   min-width: 0px;
   list-style-image: url("chrome://browser/skin/Toolbar.png");
   -moz-box-orient: vertical;
 }
 
 toolbar[mode="text"] .toolbarbutton-1,
 toolbar[mode="text"] .toolbarbutton-menubutton-button {
   -moz-box-orient: horizontal;
 }
 
 toolbar[mode="text"] .toolbarbutton-1 > .toolbarbutton-text {
   margin: 4px;
 }
 
-#nav-bar .toolbarbutton-1 {
+#nav-bar .toolbarbutton-1,
+#restore-button {
   padding-top: 0;
   padding-bottom: 0;
 }
 
-toolbarbutton:not([disabled="true"]):hover,
-menubutton:not([disabled="true"]):hover,
-toolbarbutton:not([disabled="true"]):hover:active,
-menubutton:not([disabled="true"]):hover:active {
-  color: ButtonText !important;
-}
-
 #back-button:-moz-locale-dir(rtl) > .toolbarbutton-icon,
 #forward-button:-moz-locale-dir(rtl) > .toolbarbutton-icon,
 #back-forward-dropmarker:-moz-locale-dir(rtl) > .toolbarbutton-icon {
   -moz-transform: scaleX(-1);
 }
 
 /* ----- DEFAULT BACK BUTTON, STAND-ALONE ----- */	
 
@@ -584,22 +539,27 @@ toolbar[iconsize="small"] #unified-back-
   -moz-image-region: rect(23px, 180px, 46px, 144px) !important;
 }
 #home-button:hover:active {
   -moz-image-region: rect(46px, 180px, 69px, 144px);
 }
 
 #home-button.bookmark-item {
   list-style-image: url("chrome://browser/skin/home.png");
-  -moz-image-region: rect(0px, 16px, 16px, 0px) !important;
+  -moz-image-region: rect(0, 12px, 12px, 0);
+}
+
+#home-button.bookmark-item:hover {
+  -moz-image-region: rect(0, 24px, 12px, 12px);
 }
 
 #home-button.bookmark-item > .toolbarbutton-icon {
   display: -moz-box !important;
-  padding: 0 !important;
+  -moz-margin-start: -2px;
+  -moz-margin-end: 3px;
 }
 /* ----- DEFAULT DOWNLOADS BUTTON ----- */	
 
 #downloads-button {
   -moz-image-region: rect(0px, 216px, 23px, 180px);
 }
 #downloads-button:hover:active {
   -moz-image-region: rect(46px, 216px, 69px, 180px);
@@ -744,129 +704,203 @@ toolbar[iconsize="small"] #unified-back-
 #close-button,
 #fullscreen-button ~ #window-controls > #restore-button {
   display: none;
 }
 
 /* ::::: nav-bar-inner ::::: */
 
 #urlbar {
-  -moz-appearance: none;
-  direction: ltr !important;
-  border: none;
-  background: url("chrome://browser/skin/urlbar/endcap.png") transparent right center no-repeat;
-  margin: 0 3px 1px;
-  -moz-padding-end: 11px;
-  font: icon !important;
+  direction: ltr;
+}
+
+.searchbar-textbox,
+#urlbar {
+  font: icon;
   width: 7em;
   min-width: 7em;
-  height: 28px;
+  -moz-appearance: none;
+  -moz-border-radius: 100%;
+  border: 0;
+  padding: 1px;
+  background: -moz-linear-gradient(top, rgba(0,0,0,.55), rgba(0,0,0,.27));
+  -moz-box-shadow: @loweredShadow@;
+  margin-top: 0;
+  margin-bottom: 1px;
+}
+
+.searchbar-textbox[focused="true"],
+#urlbar[focused="true"] {
+  -moz-box-shadow: 0 0 3px 2px -moz-mac-focusring;
+  background: -moz-mac-focusring -moz-linear-gradient(top, rgba(0,0,0,.1), rgba(0,0,0,.1));
+}
+
+.search-go-container,
+#urlbar > .autocomplete-history-dropmarker {
+  -moz-padding-end: 6px;
+  -moz-border-radius: 100%;
+}
+
+#urlbar > .autocomplete-history-dropmarker {
+  width: 22px;
 }
 
-#urlbar[focused="true"] {
-  background: url("chrome://browser/skin/urlbar/endcap-focused.png") transparent right center no-repeat;
+.search-go-container:-moz-locale-dir(ltr),
+#urlbar > .autocomplete-history-dropmarker {
+  -moz-border-radius-topleft: 0;
+  -moz-border-radius-bottomleft: 0;
+}
+
+.search-go-container:-moz-locale-dir(rtl) {
+  -moz-border-radius-topright: 0;
+  -moz-border-radius-bottomright: 0;
 }
 
-#urlbar[focused="true"]:-moz-system-metric(mac-graphite-theme) {
-  background-image: url("chrome://browser/skin/urlbar/endcap-focused-graphite.png");
+.searchbar-engine-button,
+#identity-box {
+  background: @toolbarbuttonBackground@;
+  color: black;
+  -moz-padding-start: 6px;
+  -moz-padding-end: 16px;
+  -moz-border-radius: 100%;
+  margin: 0;
+  -moz-box-shadow: 0 1px rgba(0,0,0,.3);
+}
+
+.searchbar-textbox[focused="true"] .searchbar-engine-button,
+#urlbar[focused="true"] > #identity-box {
+  -moz-box-shadow: none;
 }
 
-#urlbar .textbox-input-box,
-#urlbar-icons {
-  margin: 0;
-  background: url("chrome://browser/skin/urlbar/textfield-mid.png") transparent left center  repeat-x;
+#identity-box:focus:not(:active):not([open="true"]) #page-proxy-stack {
+  -moz-border-radius: 4px;
+  -moz-box-shadow: 0 0 3px 1px -moz-mac-focusring inset,
+                   0 0 3px 2px -moz-mac-focusring;
 }
 
-#urlbar[focused="true"] .textbox-input-box,
-#urlbar[focused="true"] #urlbar-icons {
-  background-image: url("chrome://browser/skin/urlbar/textfield-mid-focused.png");
+.searchbar-engine-button[open="true"],
+.searchbar-engine-button:hover:active,
+#identity-box[open="true"],
+#identity-box:hover:active {
+  margin-top: -1px;
+  margin-bottom: -1px;
+  -moz-margin-start: -1px;
+  padding-top: 1px;
+  padding-bottom: 1px;
+  -moz-padding-start: 7px;
+  -moz-box-shadow: @toolbarbuttonPressedInnerShadow@,
+                   0 0 0 20px rgba(0,0,0,.2) inset !important;
+}
+
+#identity-box.verifiedDomain {
+  background-image: -moz-linear-gradient(top, #E8F2F9, #AED4EA 1px, #87ACCF 50%, #749CC5 50%, #4B6CA4);
+}
+
+#identity-box.verifiedIdentity {
+  background-image: -moz-linear-gradient(top, #EBF8D2, #D3EEA1 1px, #AAD77B 50%, #96CB60 50%, #6EB142);
 }
 
-#urlbar[focused="true"] .textbox-input-box:-moz-system-metric(mac-graphite-theme),
-#urlbar[focused="true"] #urlbar-icons:-moz-system-metric(mac-graphite-theme) {
-  background-image: url("chrome://browser/skin/urlbar/textfield-mid-focused-graphite.png");
+#identity-icon-labels {
+  margin: 0 4px;
+}
+
+.searchbar-textbox > .autocomplete-textbox-container > .textbox-input-box,
+#urlbar > .autocomplete-textbox-container > .textbox-input-box {
+  -moz-margin-end: 0;
+  -moz-margin-start: -16px;
+  -moz-padding-start: 10px;
+  height: 20px;
+  -moz-border-radius: 100%;
 }
 
-#urlbar .textbox-input-box {
-  padding-top: 1px;
+.searchbar-textbox > .autocomplete-textbox-container > .textbox-input-box,
+#urlbar > .autocomplete-textbox-container > .textbox-input-box,
+.search-go-container,
+#urlbar-icons,
+#urlbar > .autocomplete-history-dropmarker {
+  background: -moz-linear-gradient(#D6D6D6, #D6D6D6 1px, #F7F7F7 1px, #F7F7F7 2px, #FFF 2px, #FFF);
 }
 
-.autocomplete-textbox {
-  background-image: inherit !important;
+.searchbar-textbox:-moz-locale-dir(ltr) > .autocomplete-textbox-container > .textbox-input-box,
+#urlbar > .autocomplete-textbox-container > .textbox-input-box {
+  -moz-border-radius-topright: 0;
+  -moz-border-radius-bottomright: 0;
+  -moz-box-shadow: 1px 0 rgba(0,0,0,.4) inset;
+}
+
+.searchbar-textbox:-moz-locale-dir(rtl) > .autocomplete-textbox-container > .textbox-input-box {
+  -moz-border-radius-topleft: 0;
+  -moz-border-radius-bottomleft: 0;
+  -moz-box-shadow: -1px 0 rgba(0,0,0,.4) inset;
 }
 
 #urlbar-icons {
   -moz-box-align: center;
 }
 
 #urlbar-search-splitter {
-  /* This is a bit of a mess, because the location bar and the search bar are bigger
-     than they look. For example, -moz-margin-start: -6px should really be -4px.
-     Bug 482086 and bug 482105 will solve this. */
   min-width: 8px;
   width: 8px;
   background-image: none;
-  -moz-margin-start: -6px;
+  -moz-margin-start: -4px;
 }
 
 #urlbar-search-splitter + #urlbar-container > #urlbar,
 #urlbar-search-splitter + #search-container > #searchbar > .searchbar-textbox {
   -moz-margin-start: 0;
 }
 
-#wrapper-urlbar-container > #urlbar-container > #urlbar,
-#urlbar[readonly="true"] {
-  -moz-padding-end: 12px;
-}
-
-#wrapper-urlbar-container[place="palette"] {
-  max-width: 20em;
-}
-
-#wrapper-urlbar-container > #urlbar-container > #urlbar > .autocomplete-history-dropmarker {
-  display: none;
-}
-
-/* Keep the URL bar LTR */
-
-#PopupAutoCompleteRichResult {
-  direction: ltr !important;
-  margin-top: -2px;
-}
-
-/* ----- PAGE PROXY ICON ----- */
-
 #page-proxy-favicon,
 #urlbar-throbber {
   width: 16px;
   height: 16px;
   margin: 0px;
   padding: 0px;
 }
 
 #page-proxy-stack {
-  -moz-margin-start: 10px;
   width: 24px;
   height: 20px;
   padding: 2px 4px;
-  opacity: 1.0;
+}
+
+#identity-box.verifiedIdentity > hbox > #page-proxy-stack,
+#identity-box.verifiedDomain > hbox > #page-proxy-stack {
+  background: url(urlbar-favicon-glow.png) center center no-repeat;
 }
 
 #page-proxy-favicon:not([src]) {
   list-style-image: url("chrome://mozapps/skin/places/defaultFavicon.png");
 }
 
 #page-proxy-favicon[pageproxystate="invalid"] {
   opacity: 0.5;
 }
 
 #urlbar-throbber {
   list-style-image: url("chrome://browser/skin/places/searching_16.png");
 }
 
+#wrapper-urlbar-container[place="palette"] {
+  max-width: 20em;
+}
+
+#wrapper-urlbar-container #identity-icon-labels,
+#wrapper-urlbar-container .autocomplete-history-dropmarker > .dropmarker-icon {
+  display: none;
+}
+
+#wrapper-urlbar-container .autocomplete-history-dropmarker {
+  width: 10px;
+}
+
+#PopupAutoCompleteRichResult {
+  direction: ltr !important;
+  margin-top: 2px;
+}
 
 statusbarpanel#statusbar-display {
   -moz-padding-start: 0;
 }
 
 .statusbarpanel-text {
   margin-top: 2px;
   margin-bottom: 0;
@@ -1412,24 +1446,16 @@ sidebarheader > .tabs-closebutton > .too
 #navigator-throbber[busy="true"] {
   list-style-image: url("chrome://global/skin/icons/loading_16.png");
 }
 
 #wrapper-navigator-throbber > #navigator-throbber {
   list-style-image: url("chrome://global/skin/icons/notloading_16.png");
 }
 
-toolbarbutton.chevron {
-  list-style-image: url("chrome://global/skin/icons/chevron.png") !important;
-}
-
-toolbarbutton.chevron:-moz-locale-dir(rtl) > .toolbarbutton-icon {
-  -moz-transform: scaleX(-1);
-}
-
 
 toolbarbutton.chevron > .toolbarbutton-menu-dropmarker {
   display: none;
 }
 
 #nav-bar {
   background-color: #9e9e9e;
   background-image: url("chrome://global/skin/toolbar/toolbar-background.gif");
@@ -1455,24 +1481,20 @@ toolbarbutton.chevron > .toolbarbutton-m
 
 tabbrowser > tabbox {
   margin: 0;
 }
 
 .tab-icon-image {
   width: 16px;
   height: 16px;
-  list-style-image: url("chrome://global/skin/tree/item-grayscale.png");
+  list-style-image: url("chrome://global/skin/tree/item.png");
   margin-top: 2px;
 }
 
-.tabbrowser-tab[selected="true"] > .tab-icon-image {
-  list-style-image: url("chrome://global/skin/tree/item.png");
-}
-
 .tabbrowser-tab[busy] > .tab-icon-image {
   list-style-image: url("chrome://browser/skin/tabbrowser/progress.png") !important;
   -moz-image-region: rect(0, 16px, 16px, 0);
 }
 .tabbrowser-tab[busy][stalled] > .tab-icon-image {
   list-style-image: url("chrome://browser/skin/tabbrowser/progress-pulsing.png") !important;
 }
 .tabbrowser-tab[busy][progress="1"] > .tab-icon-image {
@@ -1542,21 +1564,17 @@ tabbrowser > tabbox {
   -moz-border-left-colors: rgba(0, 0, 0, .1) rgba(0, 0, 0, .2);
   -moz-border-bottom-colors: rgba(0, 0, 0, .1) rgba(0, 0, 0, .2);
   -moz-border-right-colors: rgba(0, 0, 0, .1) rgba(0, 0, 0, .2);
   background-image: none;
   background-color: -moz-mac-chrome-active;
 }
 
 .tabbrowser-tab:focus > .tab-text {
-  -moz-box-shadow: 0 0 4px -moz-mac-focusring,
-                   0 0 4px -moz-mac-focusring,
-                   0 0 3px -moz-mac-focusring,
-                   0 0 2px -moz-mac-focusring inset,
-                   0 0 3px -moz-mac-focusring inset;
+  -moz-box-shadow: @focusRingShadow@;
 }
 
 .tabbrowser-tab[selected="true"],
 .tabbrowser-tab:hover {
   color: #000000;
 }
 
 .tabbrowser-tab:-moz-lwtheme,
@@ -1798,189 +1816,16 @@ tabbrowser > tabbox {
   -moz-margin-end: -4em;
   background-color: Highlight;
 }
 
 #customizeToolbarSheetPopup {
   -moz-window-shadow: sheet;
 }
 
-/* ::::: Identity Indicator Styling ::::: */
-/* Location bar visuals*/
-
-#identity-box {
-  background: url("chrome://browser/skin/urlbar/startcap.png") left center no-repeat;
-  min-width: 45px;
-}
-
-#urlbar[focused="true"] > #identity-box {
-  background-image: url("chrome://browser/skin/urlbar/startcap-focused.png");
-}
-
-#urlbar[focused="true"] > #identity-box:-moz-system-metric(mac-graphite-theme) {
-  background-image: url("chrome://browser/skin/urlbar/startcap-focused-graphite.png");
-}
-
-#identity-box:focus > #identity-box-inner > #page-proxy-deck {
-  outline: 2px solid #4F8EC9;
-  -moz-outline-radius: 2px;
-}
-
-#identity-box:hover:active,
-#identity-box[open="true"] {
-  background-image: url("chrome://browser/skin/urlbar/startcap-active.png");
-}
-
-#identity-icon-label {
-  margin: 0;
-  color: black;
-  padding: 4px 6px 3px;
-  -moz-padding-end: 14px;
-}
-
-#identity-box.unknownIdentity > #identity-box-inner > #identity-icon-label {
-  display: none;
-}
-
-
-/* Verified domain */
-/* - Normal state */
-#identity-box.verifiedDomain {
-  background-image: url("chrome://browser/skin/urlbar/startcap-secure-start.png");
-  -moz-padding-start: 13px;
-}
-
-#identity-box.verifiedDomain > #identity-box-inner {
-  padding: 0;
-  background: url("chrome://browser/skin/urlbar/startcap-secure-mid.png") repeat-x center center;
-  -moz-box-pack: center;
-}
-
-#identity-box.verifiedDomain > #identity-box-inner > #identity-icon-label {
-  background: url("chrome://browser/skin/urlbar/startcap-secure-end.png") no-repeat center right;
-}
-
-/* - Active state */
-#identity-box.verifiedDomain[open="true"],
-#identity-box.verifiedDomain:hover:active {
-  background-image: url("chrome://browser/skin/urlbar/startcap-secure-start-active.png");
-}
-
-#identity-box.verifiedDomain[open="true"] > #identity-box-inner,
-#identity-box.verifiedDomain:hover:active > #identity-box-inner {
-  padding: 0;
-  background: url("chrome://browser/skin/urlbar/startcap-secure-mid-active.png") repeat-x center center;
-  -moz-box-pack: center;
-}
-
-#identity-box.verifiedDomain[open="true"] > #identity-box-inner > #identity-icon-label,
-#identity-box.verifiedDomain:hover:active > #identity-box-inner > #identity-icon-label {
-  background: url("chrome://browser/skin/urlbar/startcap-secure-end-active.png") no-repeat center right;
-}
-
-/* - Focus state */
-#urlbar[focused="true"] > #identity-box.verifiedDomain {
-  background-image: url("chrome://browser/skin/urlbar/startcap-secure-start-focused.png");
-}
-
-#urlbar[focused="true"] > #identity-box.verifiedDomain > #identity-box-inner {
-  background-image: url("chrome://browser/skin/urlbar/startcap-secure-mid-focused.png");
-}
-
-#urlbar[focused="true"] > #identity-box.verifiedDomain > #identity-box-inner > #identity-icon-label {
-  background-image: url("chrome://browser/skin/urlbar/startcap-secure-end-focused.png");
-}
-
-#urlbar[focused="true"] > #identity-box.verifiedDomain:-moz-system-metric(mac-graphite-theme) {
-  background-image: url("chrome://browser/skin/urlbar/startcap-secure-start-focused-graphite.png");
-}
-
-#urlbar[focused="true"] > #identity-box.verifiedDomain > #identity-box-inner:-moz-system-metric(mac-graphite-theme) {
-  background-image: url("chrome://browser/skin/urlbar/startcap-secure-mid-focused-graphite.png");
-}
-
-#urlbar[focused="true"] > #identity-box.verifiedDomain > #identity-box-inner > #identity-icon-label:-moz-system-metric(mac-graphite-theme) {
-  background-image: url("chrome://browser/skin/urlbar/startcap-secure-end-focused-graphite.png");
-}
-
-#identity-box.verifiedDomain > #identity-box-inner > #identity-icon-label[value=""] {
-  -moz-padding-start: 3px !important;
-  -moz-padding-end: 8px !important;
-}
-
-
-/* Verified Identity */
-/* - Normal state */
-#identity-box.verifiedIdentity {
-  background-image: url("chrome://browser/skin/urlbar/startcap-verified-start.png");
-  -moz-padding-start: 13px;
-}
-
-#identity-box.verifiedIdentity > #identity-box-inner {
-  padding: 0;
-  background: url("chrome://browser/skin/urlbar/startcap-verified-mid.png") repeat-x center center;
-  -moz-box-pack: center;
-}
-
-#identity-box.verifiedIdentity > #identity-box-inner > #identity-icon-label {
-  background: url("chrome://browser/skin/urlbar/startcap-verified-end.png") no-repeat center right;
-}
-
-/* - Active state */
-#identity-box.verifiedIdentity[open="true"],
-#identity-box.verifiedIdentity:hover:active {
-  background-image: url("chrome://browser/skin/urlbar/startcap-verified-start-active.png");
-}
-
-#identity-box.verifiedIdentity[open="true"] > #identity-box-inner,
-#identity-box.verifiedIdentity:hover:active > #identity-box-inner {
-  background: url("chrome://browser/skin/urlbar/startcap-verified-mid-active.png") repeat-x center center;
-}
-
-#identity-box.verifiedIdentity[open="true"] > #identity-box-inner > #identity-icon-label,
-#identity-box.verifiedIdentity:hover:active > #identity-box-inner > #identity-icon-label {
-  background: url("chrome://browser/skin/urlbar/startcap-verified-end-active.png") no-repeat center right;
-}
-
-/* - Focus state */
-#urlbar[focused="true"] > #identity-box.verifiedIdentity {
-  background-image: url("chrome://browser/skin/urlbar/startcap-verified-start-focused.png");
-}
-
-#urlbar[focused="true"] > #identity-box.verifiedIdentity > #identity-box-inner {
-  background-image: url("chrome://browser/skin/urlbar/startcap-verified-mid-focused.png");
-}
-
-#urlbar[focused="true"] > #identity-box.verifiedIdentity > #identity-box-inner > #identity-icon-label {
-  background-image: url("chrome://browser/skin/urlbar/startcap-verified-end-focused.png");
-}
-
-#urlbar[focused="true"] > #identity-box.verifiedIdentity:-moz-system-metric(mac-graphite-theme) {
-  background-image: url("chrome://browser/skin/urlbar/startcap-verified-start-focused-graphite.png");
-}
-
-#urlbar[focused="true"] > #identity-box.verifiedIdentity > #identity-box-inner:-moz-system-metric(mac-graphite-theme) {
-  background-image: url("chrome://browser/skin/urlbar/startcap-verified-mid-focused-graphite.png");
-}
-
-#urlbar[focused="true"] > #identity-box.verifiedIdentity > #identity-box-inner > #identity-icon-label:-moz-system-metric(mac-graphite-theme) {
-  background-image: url("chrome://browser/skin/urlbar/startcap-verified-end-focused-graphite.png");
-}
-
-/* Favicon Glow */
-#identity-box.verifiedIdentity > #identity-box-inner > #page-proxy-stack,
-#identity-box.verifiedDomain > #identity-box-inner > #page-proxy-stack {
-  -moz-margin-start: -3px;
-  width: 24px;
-  height: 20px;
-  padding: 2px 4px;
-  background: url("chrome://browser/skin/urlbar/urlbar-favicon-glow.png") center center no-repeat;
-}
-
-
 /* Popup Icons */
 #identity-popup-icon {
   height: 64px;
   width: 64px;
   padding: 0;
   list-style-image: url("chrome://browser/skin/identity.png");
   -moz-image-region: rect(0px, 64px, 64px, 0px);
 }
@@ -2039,17 +1884,17 @@ tabbrowser > tabbox {
 }
 
 /* Popup Bounding Box */
 #identity-popup {
   -moz-appearance: none;
   -moz-window-shadow: none;
   background-color: transparent;
   margin-top: -4px;
-  margin-left: -13px;
+  margin-left: -15px;
   min-width: 280px;
   -moz-border-image: url(chrome://browser/skin/hud-panel.png) 26 18 22 50 / 26px 18px 22px 50px repeat; 
 }
 
 #identity-popup-container {
   margin: 4px 3px 2px -30px;
   color: #fff;
 }
index bc88d69eda693788274a394f6bfeb02609347ace..04ae4ae965dbb61f89491ba7dedd787b8241188e
GIT binary patch
literal 470
zc$@*&0V)28P)<h;3K|Lk000e1NJLTq000;O000aK1^@s6crbl+0004<Nkl<ZIE}@T
zF>B*M6ohBA>#YKkP!Tn;QHpDA>^46mb;_$v+SI8GA-^HDenwgc{0AcBG)Z9_Ln?Wt
zxyCk%v3<?K4Lo=}hHu`!1^$Cf6h)ILiY5Te-^`MXq{+6<`@=AdlO)O0G+m@=x=4~F
z55q7%1CJ%;k`~*_CH?TT1;2LA<<{CO=Ufc{RaF`9{YO<*x9j!#{Q!O~DF<*xvfjN0
zzz4}&lJEO~IF4_eb1&A~3u|p11c3mcX&QR(jrab$s;axyYW2DW-2ixzbOE3Spw_~M
z<TrpjlCO;8__uTJvD4|uT3eIU!KU=yo6Tm!s;VBA%OxZ|ZlP^>`zi(iNj^~0F95?V
z%brO#CvF`SMKK2OHW&;bX*iqBo+TailMMR({+Q(3{ttS+-e(X5jU*ODaSs4lmOYVF
z(=<U@mgzz0=Qe<&(dZrkrqk&Y0Fewxru#ntfNr<@WsIrYuw7_f*JeJSUmgT}Nvhkh
zT_{OI@)7`oBj@0;{)~8{$I*a)ExT*VvK;T%AWzPA8V-kJ9O&5W4@64h*<rRjLI3~&
M07*qoM6N<$f*`il!2kdN
--- a/browser/themes/pinstripe/browser/jar.mn
+++ b/browser/themes/pinstripe/browser/jar.mn
@@ -1,19 +1,15 @@
 browser.jar:
 % skin browser classic/1.0 %skin/classic/browser/
   skin/classic/browser/sanitizeDialog.css                   (sanitizeDialog.css)
 * skin/classic/browser/aboutPrivateBrowsing.css             (aboutPrivateBrowsing.css)
 * skin/classic/browser/aboutSessionRestore.css              (aboutSessionRestore.css)
   skin/classic/browser/aboutSessionRestore-window-icon.png
   skin/classic/browser/aboutCertError.css                   (aboutCertError.css)
-  skin/classic/browser/bookmark_toolbar_background.png
-  skin/classic/browser/bookmark-open-left.png
-  skin/classic/browser/bookmark-open-mid.png
-  skin/classic/browser/bookmark-open-right.png
 * skin/classic/browser/browser.css                          (browser.css)
 * skin/classic/browser/engineManager.css                    (engineManager.css)
   skin/classic/browser/feed-icons.png
   skin/classic/browser/fullscreen-video.css
   skin/classic/browser/Geo.png
   skin/classic/browser/Go-arrow.png
   skin/classic/browser/home.png
   skin/classic/browser/hud-panel.png
@@ -45,16 +41,17 @@ browser.jar:
   skin/classic/browser/Search-addengines.png
   skin/classic/browser/section_collapsed.png
   skin/classic/browser/section_expanded.png
   skin/classic/browser/Secure-Glyph-White.png
   skin/classic/browser/Secure-statusbar.png
   skin/classic/browser/Secure-statusbar-broken.png
   skin/classic/browser/Secure-background.gif
   skin/classic/browser/Toolbar.png
+  skin/classic/browser/urlbar-favicon-glow.png
   skin/classic/browser/feeds/subscribe.css                  (feeds/subscribe.css)
   skin/classic/browser/feeds/feedIcon.png                   (feeds/feedIcon.png)
   skin/classic/browser/feeds/feedIcon16.png                 (feeds/feedIcon16.png)
   skin/classic/browser/feeds/videoFeedIcon.png              (feeds/videoFeedIcon.png)
   skin/classic/browser/feeds/videoFeedIcon16.png            (feeds/videoFeedIcon16.png)
   skin/classic/browser/feeds/audioFeedIcon.png              (feeds/audioFeedIcon.png)
   skin/classic/browser/feeds/audioFeedIcon16.png            (feeds/audioFeedIcon16.png)
   skin/classic/browser/setDesktopBackground.css
@@ -101,56 +98,8 @@ browser.jar:
   skin/classic/browser/tabbrowser/newtab.png                             (tabbrowser/newtab.png)
   skin/classic/browser/tabbrowser/progress.png                           (tabbrowser/progress.png)
   skin/classic/browser/tabbrowser/progress-pulsing.png                   (tabbrowser/progress-pulsing.png)
   skin/classic/browser/tabbrowser/tab-arrow-left.png                     (tabbrowser/tab-arrow-left.png)
   skin/classic/browser/tabbrowser/tab-arrow-right.png                    (tabbrowser/tab-arrow-right.png)
   skin/classic/browser/tabbrowser/tabbrowser-tabs-bkgnd.png              (tabbrowser/tabbrowser-tabs-bkgnd.png)
   skin/classic/browser/tabbrowser/tabDragIndicator.png                   (tabbrowser/tabDragIndicator.png)
   skin/classic/browser/tabbrowser/tab-bkgnd.png                          (tabbrowser/tab-bkgnd.png)
-  skin/classic/browser/urlbar/endcap.png                                 (urlbar/endcap.png)
-  skin/classic/browser/urlbar/endcap-rtl.png                             (urlbar/endcap-rtl.png)
-  skin/classic/browser/urlbar/endcap-focused.png                         (urlbar/endcap-focused.png)
-  skin/classic/browser/urlbar/endcap-focused-graphite.png                (urlbar/endcap-focused-graphite.png)
-  skin/classic/browser/urlbar/endcap-focused-graphite-rtl.png            (urlbar/endcap-focused-graphite-rtl.png)
-  skin/classic/browser/urlbar/endcap-focused-rtl.png                     (urlbar/endcap-focused-rtl.png)
-  skin/classic/browser/urlbar/startcap.png                               (urlbar/startcap.png)
-  skin/classic/browser/urlbar/startcap-rtl.png                           (urlbar/startcap-rtl.png)
-  skin/classic/browser/urlbar/startcap-focused.png                       (urlbar/startcap-focused.png)
-  skin/classic/browser/urlbar/startcap-focused-graphite.png              (urlbar/startcap-focused-graphite.png)
-  skin/classic/browser/urlbar/startcap-focused-graphite-rtl.png          (urlbar/startcap-focused-graphite-rtl.png)
-  skin/classic/browser/urlbar/startcap-focused-rtl.png                   (urlbar/startcap-focused-rtl.png)
-  skin/classic/browser/urlbar/startcap-secure-start.png                  (urlbar/startcap-secure-start.png)
-  skin/classic/browser/urlbar/startcap-secure-mid.png                    (urlbar/startcap-secure-mid.png)
-  skin/classic/browser/urlbar/startcap-secure-end.png                    (urlbar/startcap-secure-end.png)
-  skin/classic/browser/urlbar/startcap-secure-start-active.png           (urlbar/startcap-secure-start-active.png)
-  skin/classic/browser/urlbar/startcap-secure-mid-active.png             (urlbar/startcap-secure-mid-active.png)
-  skin/classic/browser/urlbar/startcap-secure-end-active.png             (urlbar/startcap-secure-end-active.png)
-  skin/classic/browser/urlbar/startcap-secure-start-focused.png          (urlbar/startcap-secure-start-focused.png)
-  skin/classic/browser/urlbar/startcap-secure-start-focused-graphite.png (urlbar/startcap-secure-start-focused-graphite.png)
-  skin/classic/browser/urlbar/startcap-secure-mid-focused.png            (urlbar/startcap-secure-mid-focused.png)
-  skin/classic/browser/urlbar/startcap-secure-mid-focused-graphite.png   (urlbar/startcap-secure-mid-focused-graphite.png)
-  skin/classic/browser/urlbar/startcap-secure-end-focused.png            (urlbar/startcap-secure-end-focused.png)
-  skin/classic/browser/urlbar/startcap-secure-end-focused-graphite.png   (urlbar/startcap-secure-end-focused-graphite.png)
-  skin/classic/browser/urlbar/startcap-verified-start.png                (urlbar/startcap-verified-start.png)
-  skin/classic/browser/urlbar/startcap-verified-mid.png                  (urlbar/startcap-verified-mid.png)
-  skin/classic/browser/urlbar/startcap-verified-end.png                  (urlbar/startcap-verified-end.png)
-  skin/classic/browser/urlbar/startcap-verified-start-active.png         (urlbar/startcap-verified-start-active.png)
-  skin/classic/browser/urlbar/startcap-verified-mid-active.png           (urlbar/startcap-verified-mid-active.png)
-  skin/classic/browser/urlbar/startcap-verified-end-active.png           (urlbar/startcap-verified-end-active.png)
-  skin/classic/browser/urlbar/startcap-verified-start-focused.png        (urlbar/startcap-verified-start-focused.png)
-  skin/classic/browser/urlbar/startcap-verified-start-focused-graphite.png (urlbar/startcap-verified-start-focused-graphite.png)
-  skin/classic/browser/urlbar/startcap-verified-mid-focused.png          (urlbar/startcap-verified-mid-focused.png)
-  skin/classic/browser/urlbar/startcap-verified-mid-focused-graphite.png (urlbar/startcap-verified-mid-focused-graphite.png)
-  skin/classic/browser/urlbar/startcap-verified-end-focused.png          (urlbar/startcap-verified-end-focused.png)
-  skin/classic/browser/urlbar/startcap-verified-end-focused-graphite.png (urlbar/startcap-verified-end-focused-graphite.png)
-  skin/classic/browser/urlbar/startcap-secure.png                        (urlbar/startcap-secure.png)
-  skin/classic/browser/urlbar/startcap-active.png                        (urlbar/startcap-active.png)
-  skin/classic/browser/urlbar/startcap-active-rtl.png                    (urlbar/startcap-active-rtl.png)
-  skin/classic/browser/urlbar/startcap-active-focused.png                (urlbar/startcap-active-focused.png)
-  skin/classic/browser/urlbar/startcap-active-focused-graphite.png       (urlbar/startcap-active-focused-graphite.png)
-  skin/classic/browser/urlbar/startcap-active-focused-graphite-rtl.png   (urlbar/startcap-active-focused-graphite-rtl.png)
-  skin/classic/browser/urlbar/startcap-active-focused-rtl.png            (urlbar/startcap-active-focused-rtl.png)
-  skin/classic/browser/urlbar/startcap-secure-active.png                 (urlbar/startcap-secure-active.png)
-  skin/classic/browser/urlbar/urlbar-favicon-glow.png                    (urlbar/urlbar-favicon-glow.png)
-  skin/classic/browser/urlbar/textfield-mid.png                          (urlbar/textfield-mid.png)
-  skin/classic/browser/urlbar/textfield-mid-focused.png                  (urlbar/textfield-mid-focused.png)
-  skin/classic/browser/urlbar/textfield-mid-focused-graphite.png         (urlbar/textfield-mid-focused-graphite.png)
index 9ae0f23b7cda89741dc8c2affa3baccdb1d49422..61a85c5d6b90d29a7b2a515bb8ce38b840618ac1
GIT binary patch
literal 161
zc%17D@N?(olHy`uVBq!ia0vp^>_E)L!3HEN&baUbsSHmS#}J9BrM(+P8w@yH{MkK^
z3q&?(`5mg*mck<CJ?-GJ9~WMf-ueGNqGJW)4a4;4yMGg&&5KTZ_pXkCL1|G}hfrWg
zhnq`n4o@OeWQDlyzRL^?X3Ttc?Tm<nBy%Z;_>6zo><hSmS}>~riEDcmbvzbmCxfS}
KpUXO@geCwQY&tOj
index 9cb5402775bc3997fdaa1722e12ee60de4dadc65..5e73536673c8cc561e0e580e2efe957a5ac94130
GIT binary patch
literal 645
zc$@)+0($+4P)<h;3K|Lk000e1NJLTq000sI000UI1^@s6xl0bA0006^Nkl<ZD3N85
zPe>|Z6vgi+A#Pj@jxx@u2nkL$PeM0=E+kj}!G#Zuz*PhWwJvDwzE-s<s7;%8?h0B6
z1qBggAX17YA(4$Ck%fcbd5bqa9`7AEa4wvC`Ei*b2yu(W5+@?!oS(hDy`9lN0uU#n
zxH+CN#{TP&rfFqamUTr@bhq2xcez|OK@j49cgEv!8GvrO&pEG|$Nz`{h!Rn>)9KiD
zcXy|bj*jLAgMrg9jMdlI*Fz#ARaK)FizVvw`D{x|OH=uLevUEbB%)Qu*dY-S34)+W
zl2q|}z1yWyX};BJEk+`d8(Eh1Z!!QH=ez=7yIQTzXEK?^;c$3k68<L3<#Mr^nVECH
z-~Xs6iXI3Aiud>T#p&tkJCDb6OGMOcHe+93U*`ZG&E;Y)mn)9P<2wMi-;Z<v$hO<<
z<!m;4tSE}EX<A}!ZEe%z@$_6SS4>q^hpMXCR4TRHY&MSp=!Rh=DwWD6=e!3XMxrQY
zoKENZ!oq@BtJTtzlarlbFt~SmdK&Thd@tc}xC|fzVEyXqN-Pu#Y0h~Ez~0KrN`!O%
zVi-o5BuVPK-R{1kC>sE*v$L}o;c&PL!0PpSd&y*S3qarWMko}r4hDk@!!W9$P{_(T
z?{&M~tqEC{pLAW9lF8&dV{Ej)zkkqZG(^VOD4kAU+wJz}&(F^%o6RO&US7V}>-Evj
z&dxzF7!>RE`l#J*Uw?djJTm}4iO4}jCycQN01hIun>j&5T}{(|0B~^5Pa2KJgQ}_y
fBC?w~K}6kOb8$$PDDHol00000NkvXXu0mjf7=SET
--- a/browser/themes/pinstripe/browser/places/organizer.css
+++ b/browser/themes/pinstripe/browser/places/organizer.css
@@ -119,16 +119,17 @@ window:not([active="true"]) #placesList 
 }
 
 #placesToolbar > toolbarbutton > .toolbarbutton-text {
   display: none;
 }
 
 #placesToolbar > toolbarbutton[type="menu"] > .toolbarbutton-menu-dropmarker {
   list-style-image: url("chrome://browser/skin/places/folderDropArrow.png");
+  -moz-image-region: rect(0, 7px, 5px, 0);
   padding: 0;
   margin-top: 1px;
   -moz-margin-end: 3px;
 }
 
 /* back and forward button */
 #placesToolbar > #back-button {
   -moz-margin-start: 3px;
--- a/browser/themes/pinstripe/browser/searchbar.css
+++ b/browser/themes/pinstripe/browser/searchbar.css
@@ -1,147 +1,40 @@
-/* *** pinstripe *** */
-
-.searchbar-textbox {
-  -moz-appearance: none;
-  font: icon;
-  height: 28px;
-  width: 5em;
-  margin: 0 3px 1px;
-  min-width: 5em;
-  border: none;
-  background-color: transparent;
-}
-
-.searchbar-textbox > .autocomplete-textbox-container > .textbox-input-box {
-  background: url("chrome://browser/skin/urlbar/textfield-mid.png") repeat-x;
-  padding: 0;
-  margin: 0;
-  -moz-margin-start: 45px;
-}
-
-.searchbar-textbox[focused="true"] > .autocomplete-textbox-container > .textbox-input-box {
-  background-image: url("chrome://browser/skin/urlbar/textfield-mid-focused.png");
-}
-
-.searchbar-textbox[focused="true"] > .autocomplete-textbox-container > .textbox-input-box:-moz-system-metric(mac-graphite-theme) {
-  background-image: url("chrome://browser/skin/urlbar/textfield-mid-focused-graphite.png");
-}
-
 .searchbar-engine-image {
   width: 16px;
   height: 16px;
   list-style-image: url("chrome://mozapps/skin/places/defaultFavicon.png");
   -moz-margin-start: 3px;
 }
 
 .searchbar-engine-button {
-  background: url("chrome://browser/skin/urlbar/startcap.png") center center no-repeat;
   -moz-appearance: none;
-  height: 28px;
-  min-width: 45px;
-  border: 0;
-  -moz-box-align: center;
-  margin: 0;
-  -moz-margin-start: -45px;
-  padding: 0;
-}
-
-.searchbar-engine-button:-moz-locale-dir(rtl) {
-  background-image: url("chrome://browser/skin/urlbar/startcap-rtl.png");
-}
-
-.searchbar-textbox[focused="true"] > .searchbar-engine-button {
-  background-image: url("chrome://browser/skin/urlbar/startcap-focused.png");
-}
-
-.searchbar-textbox[focused="true"] > .searchbar-engine-button:-moz-locale-dir(rtl) {
-  background-image: url("chrome://browser/skin/urlbar/startcap-focused-rtl.png");
-}
-
-.searchbar-textbox[focused="true"] > .searchbar-engine-button:-moz-system-metric(mac-graphite-theme) {
-  background-image: url("chrome://browser/skin/urlbar/startcap-focused-graphite.png");
-}
-
-.searchbar-textbox[focused="true"] > .searchbar-engine-button:-moz-locale-dir(rtl):-moz-system-metric(mac-graphite-theme) {
-  background-image: url("chrome://browser/skin/urlbar/startcap-focused-graphite-rtl.png");
-}
-
-.searchbar-engine-button:hover:active,
-.searchbar-engine-button[open="true"] {
-  background-image: url("chrome://browser/skin/urlbar/startcap-active.png") !important;
-}
-
-.searchbar-engine-button:hover:active:-moz-locale-dir(rtl),
-.searchbar-engine-button[open="true"]:-moz-locale-dir(rtl) {
-  background-image: url("chrome://browser/skin/urlbar/startcap-active-rtl.png") !important;
-}
-
-.searchbar-textbox[focused="true"] > .searchbar-engine-button:active,
-.searchbar-textbox[focused="true"] > .searchbar-engine-button[open="true"] {
-  background-image: url("chrome://browser/skin/urlbar/startcap-active-focused.png") !important;
-}
-
-.searchbar-textbox[focused="true"] > .searchbar-engine-button:-moz-locale-dir(rtl):active,
-.searchbar-textbox[focused="true"] > .searchbar-engine-button[open="true"]:-moz-locale-dir(rtl) {
-  background-image: url("chrome://browser/skin/urlbar/startcap-active-focused-rtl.png") !important;
-}
-
-.searchbar-textbox[focused="true"] > .searchbar-engine-button:active:-moz-system-metric(mac-graphite-theme),
-.searchbar-textbox[focused="true"] > .searchbar-engine-button[open="true"]:-moz-system-metric(mac-graphite-theme) {
-  background-image: url("chrome://browser/skin/urlbar/startcap-active-focused-graphite.png") !important;
-}
-
-.searchbar-textbox[focused="true"] > .searchbar-engine-button:-moz-locale-dir(rtl):active:-moz-system-metric(mac-graphite-theme),
-.searchbar-textbox[focused="true"] > .searchbar-engine-button[open="true"]:-moz-locale-dir(rtl):-moz-system-metric(mac-graphite-theme) {
-  background-image: url("chrome://browser/skin/urlbar/startcap-active-focused-graphite-rtl.png") !important;
+  min-width: 0;
 }
 
 .searchbar-engine-button > .button-box {
   -moz-appearance: none;
   padding: 0;
   -moz-padding-end: 3px;
   border: 0;
 }
 
 .searchbar-engine-button[addengines="true"] > .button-box {
-  background: transparent url(chrome://browser/skin/Search-addengines.png) no-repeat 25px 50%;
+  background: transparent url(chrome://browser/skin/Search-addengines.png) no-repeat right center;
+}
+
+.searchbar-textbox:-moz-locale-dir(rtl) .searchbar-engine-button[addengines="true"] > .button-box {
+  background-position: left center;
 }
 
 .searchbar-dropmarker-image {
   list-style-image: url("chrome://global/skin/arrow/arrow-dn.png");
   -moz-margin-start: 2px;
   margin-top: 1px;
 }
 
 .search-go-container {
   -moz-box-align: center;
-  background: url("chrome://browser/skin/urlbar/endcap.png") no-repeat right top;
-  -moz-padding-end: 5px;
-}
-
-.search-go-container:-moz-locale-dir(rtl) {
-  background-image: url("chrome://browser/skin/urlbar/endcap-rtl.png");
-}
-
-.searchbar-textbox[focused="true"] > .search-go-container {
-  background-image: url("chrome://browser/skin/urlbar/endcap-focused.png");
-}
-
-.searchbar-textbox[focused="true"] > .search-go-container:-moz-locale-dir(rtl) {
-  background: url("chrome://browser/skin/urlbar/endcap-focused-rtl.png") no-repeat left top;
-}
-
-.searchbar-textbox[focused="true"] > .search-go-container:-moz-system-metric(mac-graphite-theme) {
-  background-image: url("chrome://browser/skin/urlbar/endcap-focused-graphite.png");
-}
-
-.searchbar-textbox[focused="true"] > .search-go-container:-moz-locale-dir(rtl):-moz-system-metric(mac-graphite-theme) {
-  background-image: url("chrome://browser/skin/urlbar/endcap-focused-graphite-rtl.png");
 }
 
 .search-go-button {
-  padding: 1px;
   list-style-image: url("chrome://browser/skin/Search.png");
-  margin: 0;
-  padding: 0;
-  -moz-padding-end: 6px;
 }
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..68803e5d07861fc2fe1bec2fc0ef3ba2e05fed24
GIT binary patch
literal 504
zc$@+F0SEqxP)<h;3K|Lk000e1NJLTq000;O000yS1^@s6m$m(a00004XF*Lt007q5
z)K6G40000PbVXQnQ*UN;cVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBUzib+I4RCwC7
zRcmX*FbuREw^^1!1ABeh|Nn7gg%%ppM-orYPT?lHkqv4%oY>Z#CCjo;DS7wRa$f*z
zLKFnd>)Hg2f?jYY3_zZrjG25TxD(WZ2cW`SFajfpI>7;G1xKuzL?Vm=NHY0G@FaK?
zG!R>14Yw?C0qIV#6@1X#v<dYfARINw-vqA^t0+uXpoa$y);Wyzm>=1LHA0ei{vvqB
ze+loL36X}Of^DL3bvO?nDgG+Z0Qvi#!sCqxdJZa{3HJ!q9^*ZG5V4yYeF^e{NNgL>
zm&SI^JQfI)Nd;w&4G()zP|vo31soBCA4vTb0Tt2lZ^VwWhY7q9T-vPN%oW^?TQFBY
z8TXeqYnN=P;ItblJJK&=>B^lL=@!o(SmFy6EGuR`<uz<O3q?~EJJgnrik!_B>v1MM
z8Qb0p47iC06s`?!wp&mtPGq;k_nE7y?nDK)*uBTtl46%j!#iwMVD`X~KuaaJ`)9ds
uNx(((cpRzZvNwNyaP**)zx9*(DZl_xp1-<|EHsn=0000<MNUMnLSTZADbOAO
deleted file mode 100644
index 10c9e89529d309878a6b0d98c3a17da31100b377..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 4e27f08439cb41a44abab2e7e5469454ab943994..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index b7cb9c63c0f5f992c83bdad6a15dbf05d93b1862..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 786fd2979e57ba0a459e74149ef3df436714518a..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index e26eaebf8a15a5e0169a1bb5d63d5e27b30e3cf7..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 7e50ee4f6e11baba666927370ee2766a1dcf5cf0..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 60069850d3078219d59131026754ee1a1a7f84c0..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 0cca6565c49ee844a68c468017f019acdb9e0125..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 311cef8aefaddb7eabe11dd206c1a21b93694f8a..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index ed2bb440306806fb37484ffe465c3abf1ed71747..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 7076d1df6cd2d7cfb86b44afa6fd33c45699d76a..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 2047ada0fc5ca4c45372f2ae4e00e6f73aca1bc6..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 33603dea24992b55e03bea05d1a9cea076ee43d9..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 289c0fbd5d1541ebdedf60e899965cfcb641a3fe..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 5e5194d0204b7f8f8c75c785a71dfb48f460f152..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 26909af696fc85f5eb7d25b6e566b37acb97e28d..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 499d1c4df50b3a80d0a0e10e599b07e3d34fb61c..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index a73a41e50a63be452802e58eb5d8c32837f9bfc6..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index df39fe20da4339fceac3b203d8ba9ab99c06b186..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index aa4183cac7cc85acbaddcb4175e947a43c0f4f23..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index b85590b32d0f2c08d6b92f8550e339e7473cb9ec..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 9dc0637949bedea9eb5d244678bd9cc889a995d0..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 8fc0939b8b6f6177ff3dc995200797fd6531516b..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 6bfe1260248fcf85134a5f5e8aa62da75c66fbf1..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index e26ee4decdc5dff931d4be1debf81cb076019c5a..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index ebe4f69e5bcc4d8e60e30eda8d7bf4b3653e49c3..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index e9fc57660b22ff7cc68dc5e4a882eb8c11f6ed6b..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 8c8fd080b236490428a87f5395ec677cb1170b47..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 284f3b0a5b5bc908613d762962777d9584fd19cd..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index bc0e4064da205a171fd2d160dc9fdabe70d21e7f..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 46a282fee1e5ada5088a4d03b24e69c807221621..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index e7f85b9b1a29e243b2b78307a26d50e1062ebe05..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index ca0bad20bd3ff145c08326d49fdffb1991c3267a..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index be03cdbc2d0e8bfa32b4cfa2562bb31cb5d9a983..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 65e097bb2701745346d6c4b159ba2e9656776919..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index bb84890a47296323e47744aba9aa547519b2ba32..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index bcee816e211d8f7a62d8c085793644fd718e73ab..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 853aa7d8407e26fec9dab97ea2d6b1178d628817..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 1250613dd15a0cfa420bd07d1b26824309441e4e..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index b7c85e8f5ad5a686c4756fd6ece36cae7ddffc0c..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index e135410df0214282baa30dddd000c936e88f45b0..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 73e26174bc0956bd3e0556bf2d0c3008a519b1ee..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 83a3d55929f8d7ba6c4aeaef37097ded687d1ea0..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 3e1a2f6c129e1f8ec7994f13c3f5c82811c3481b..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index e5d3752a2016b5cbac94ca83ee0776c51b9938f8..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 5d822e9c074502fba302b1c108268243ad38f0fe..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 16be713c7446a0b339627ce88247a60b142c1f0a..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 0d8706580557cbbc85c10e0b4c1f5340d94b1f07..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 13a4a669f176dfd14caaa5a6888abe8005ad9c69..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 3f1cdcc3f2bd5c020544651a1defaeee12065a8f..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index b1ba5e9343a5ea5db09aae2156946f2cc29ffec2..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 68803e5d07861fc2fe1bec2fc0ef3ba2e05fed24..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100755
index 8094d8a1facd9540ad4f14b9ea1fcb794f63361c..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100755
index 9da3ea5abbdf8e354e652b8d4da8b89c06041b69..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100755
index c9b39175e8a0aaa57aa00751e82e2356582b756d..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
old mode 100755
new mode 100644
index 418d2e977f46ab1e8fda991b2b900baf0cdf6f07..ddad064d9fbe8bed571ce803a9e7af30319c862e
GIT binary patch
literal 8007
zc$_s@byQT{+XaU1?v#}79J)gqWI#ft29S;+q!pw=QW^;fK>;O&L7JgQKw@B|o1q&%
zc)#_#f82G~J?A{@tf%(g&j&+&O(J}Hd^9vPB5f@-V>C2$;)ic8T<nLpgp8jK8X60+
zwwkgjWNyzo&^KNE=W|JQY8(wLQ(7E*n9k&EYlCl)LBOQ8(;k0*el)4p-v9s^8IFTz
zx|9KS^5;?M1SIMtyjh8|pG@;m<`~<kpUe|oLn(!cN?-ri^|kSoxvXsfdER+HL#OOU
z!JV<+!L7^f)K{xhv)UFeHEC4umg@&>QlclV1z*M_ei5eptB-1~bq(g3$=bv&=~A1i
z9K>2BX}=AsQjDz)1=b<9Qy1m4O$O=@gOr%V^u*JgO-aBUSuOuuwmWegHpfn5$hKma
zFFbfK4umK4(>gYp2k_&F(<&m=x`Qn=*<}u(_pl)1DXG>SDWGE4ka(ms&uWJz!`aGh
zm~@5m^Unsn{X|Qy{9fujs6Dk*wU3a#tJ8YJ?iM$W8HsN=QRLoIhs1HC(z1q08zhN-
zd^1d446l?(Q^?TH*h{P+?2EtenFsK^Rv;nw?n+93o{4iC{Zvr4f3F>N?81|<v&mp+
zFmP|6I&hnQeDYBlbSWRYe+B3tTl7Ny1)0FMe>9BfkC_|}a%H-}cJ<6@#Il(P!Lm_a
zVJms+eqVfQUB8t+my(f9Qt#z%KxM0$snA2945bBqHtL9k46fWTb$Jq!0h6#rZZ1@Z
zbnJPj>*cX?!F1UYN@2n}M<aUML!Op9HLX^QIQ%w9W*P?-6754jk^4cx)38LvcW~?M
zE0)8Q0PuBpu;}q&7nTi^eQ^{ldA+rc=q0#F)Hf%v*Y$Mk=bIPq31}ow!<yIxrnVRC
zVZ#Vk2^GZ*eC9re=U@ME#f$rBoM~JoveA>5yvXM4i&7j}pTk@Z>N{>!;Pp<W^~9^p
zy#1iT0MBKVe}YocAT$>-3{((y-P*ssyaImgzBNsoI72^dB2ZzRge+=&2>Fl{hJq2W
zlN3l7PP98;{`?)+I&*&=1t7UU{cI3QmJoVwJ9huGx%D4AMvBQRB>Z4R)RUuJ?r-I>
z?M%!QR5Ti~bxl{Z6x+z$8$>uxyRi-Sd1(O!e2-sY>i4qoFh8-K7UjqEzGV}=l7i0|
zN70gr>PrwexVaoo<c@TrI^%)VcO+2?Q>{7I>KmO`ygos3%=ptD!FCRICGmp;f{^T!
zFwEtvR}jml=@?9U<jhM(?bl%Y<SteE^lW86jhNu-UTf$i<Lq9U1U%Do=cOIViCv08
zB%ysVpcV4oodlbCK@Z=DCcXAqKv1?oKP=&lpAP7bY^56iCM};^Gy86Mb?9|cUL?^`
zQC1BX7Mj(*^^QdL?wb$b=@n<`n`Mt4cEsxNVvSg-?dn0R4DJ{7@FxMCw^FK~rluUv
zA#}K7u`5w+A01e+G5xYlu*~2fGx!s8IVVsuZhJ~Z%>WG!kuQEe-%Q)6oqy=-bIOL{
z5}izI%N_0>HX`5)f6}bpgg+a|!FZ!yvs03f>WAmhh>R3RlTdYTgYT`xHSPDsnl?8p
zRyzrFGJ5nipG!w;;<;t+YH>5xl+@4+6eW<tPHX31lAr(^x}G58v9-kG*<~|VTY+53
zoz*J8`<C7r;hp1meEY$8ewpd+iVV0ew0}H0&%MY`6Fn-0I{4AQV=Tm~&UHj-u5>Z5
z${Byv>ov)py~#A2|ENcYmVEkRW4!visPUUx65T3>MZwB~J4sM13$_J|)H@84T9Tr&
z?h6rzbum&FU3q}G!gwu3)MR?<tzLOk+SIU(PJUCwEaI}x%amy$3IpTzH5&l587{cF
zO4s^qB%o`p#JZ(d?wGHlVH>0i%4~|GdlQPH<<|3Q5OexiU6f}gCG_&0gxENm2da-@
z)DK-C>}WdpUaKVJMs)U5;B1a<-vXz^5cIdu9hY63+sM#TF319%w3%bv97|j{xW{er
ztp4fj?n0KTZ29OLqlZYT(&N<qLx<rrElRxJa*;f)y|zHyQ0dGnNi={-4e5p$Xuj3I
zZwXa-u`(G<MK^F1f*4W`&@*m*liX_^d(|>29DG=veCrOI>+bJ#!Tfr?_F0!KMjQpb
zLPCS(4+!6q6tq)jy&3`L+RjcW6b+U4>Qof8IQP!?`i(GoiP4Cl!UJ|-bplQHRA10>
z938BG2NVhGlo=%8Bk8KJ8TXgzC0%;~ZvH!SDVWTtp};O54Vy}1k1pTgqDD&>u|M)d
z>+GzD&k8l))aN;@UT4#Lwg+q$elQQ{l5zDXtA3Lwrc0;~WG4n6FabXmVKC|x)W=nW
zj*qT0fDt;|jt#FXgqm}y`RAFd4V)%LpOzj(B`5P((20Dgyf)z<%|9JEZW;znUTx-;
zeNDb9m+T0aE{(uxcUdtz0^6m<d)w2vLDeEe(0_|9mwqrrY>?s7+XubzHs&nxuKpsH
zp`YJ!Fg~%unbs=|98cwtDSuB8k0qM&j(9Utf0G!S`Q~7vf9%C@ol9O@#j8FQ^-(j6
zB#?DDj?x<w4VxU%=J5+EqJ|~;kmbg6q=>_;7eHvtQ-R$Ld)X<ddX8a30C9TKAh$1n
zHr0ZCGYb0Yot1^HMdz32LJtKk4hcfpird{sR2hKSK7Icdj)KgkJX$a?@JYwTmQ%2q
zYrB)rmi!7NbPB>wR}W_D!cMdmzXoomYEBJb)o=Mc#9GIE#^OjDk~q3>#_w^89**gF
z+|4~!#%=ZD0QvkTQ5+RcBf2o$kqC$xEwCCIa^g3XmB0mzTFD*n-bHDKJfvx7PK%p_
zs|%=`o_eVp+ICuofPKx6Sdp|@TJarp%*_0^MJ@eMrV4ntnt7hAyr<CtXVIlWbfetq
z5S-I^?`^5YR#26x>3k2qi(`G{HeG@&-GuMEq4F^&V&ZZ1OJ?ts<;<@)vn#Zw8k%RR
zSvFyERB9hb$$A99*0-x&Ng;$rd}3T9bg=zniYWmY-`CK_`r^y2KAHH!gUSO{3p0D|
zf-iZ~H@rVQcHZvXy&kOkK_b*1JQ5ZEyw0j~nTCPcRiF~QK)@`qBLl5Kx0^uk!MJ8#
z=75z|kE!-fLhv00u{j*!SF^h3VcsWdvt6&9mI3&ZB2XF0?EcF@*8i{UX!mwiB4FuS
zZ#FS1y8)-cqj&fnq1cDnwOL1>4Ub4-Ux;lt(A;L}W<OPkYCPP;2^U9rlhGj7#<i4_
z#P8dgX4vrwpkLp1xES4`NF(X`2If=QakZYshx<oZxLm*z&!>~Z6Q%!Ee0rhmE0y+E
z61-&%KCsXpFTvj$^UStghwU-{k?3`ejfTSz8UarF!62T>!fs3R`;e{3Of!4|j!!aS
zTfbcLx$8=lQzQ73O+rMHc5ejq>r=`lN5b|RgvR>tiu?_kw2`%{4+MaKuE5`^-*}B2
zq`X#>?bx{uf~AM7rB8itEx#0Emi2pDFuc@c$lSxu)E)-;H?_v)B)CX6w&RrMsUeGN
z;U>e05Hy1V7Q;dQ?L0pETc*>^t2T;LBUW8H6(eT2W8U<TvMZe@qO|-uh$~PenY~#!
zV0!&aSg2oD>Ot<62p7Lo?fHj=w5lJ|ZbGVzWezCs6EgrYH>eLzjacDE>pyAH4b3+*
zJtRY$wHq-F5&Zt%m%12kVzpLzrO-3kuZ1KC7jFR`Scv+}JHKcIiOJWc$RYFXU8#>R
zww>vok7M-!-qJfd{jBF;3xfr2iaV@7jdnV^4q-d?Jq+}$JJeE;Q*_{h|4es8TDp{0
zt(Rp-5LdJvDR9KVal8f{-#vLnp;&b4&MTDdX_2JFIEl$(&q}~Fj+H;27=W}ket%WH
zyUBwz68RcvKsG|jiOD+q$0!`d311iXxOKBo`8|n>!k+Q^Z0!7eU+}pymTO)c1gG#r
zKdz9}SE8m8<(KGx9(vX@&guyM5?$khEAO!IQ7cfB@Zjo2pQ^b!=b=Ga*?am2C`G;_
zoH<<~rkJZ}@0WUu-W~ieYpW>4p<G{lj!HA1wTH^2<pF%aO52n9GMYtERtz5@QE6EJ
zSegMB2ON*ZohD}SU7COY3Dz!kU3*yna~h$UsHDPs$(YIC26>$?SeKn;=kXSuY#<IY
zBlQqX-a4n_#`Q}-6LRD84LD)axo?vXIx|WIyPh%&<L$)Z`(Hd_HIcHs4MjKGIial3
zhCFPW0i{e|=~z9Jv;=SK#7yo6XK$@Y46e?J5}S8!q=kspio&;{=*9h1+nswpS%_P-
zU)Q3`kbGi7M~7J;XCu&ZpPOV#<{5MKH*sDzB}_;#_(Qh3ZrwVT!2E0H%U7_Wo#kt!
zoRsXRJi&?8#<lSYiVg}VA!_`qqusLQ&M@!hr){NY7@3B=(0}LPzoN&I(f!+01(d;(
zK5%aa3c>+vW0<j<JLiKh_b}`iz|`Qz7G?vVRpIP?S~OvV2m_5#gg0*20_RldWNyBj
z)qJ5|h$98mOKv%Z>sW<awunHsnBf50hSGP(Co&ePproKh8i~E$FGzbYQ<KL}V)(R%
z)FJRFBdaFnX+#@cN#tNx5dJ{B!+gBSrC$8k!NH)<dotOu>|%6{Y_JgsJANn4{wa?F
zc}0civu6Dz_u^SBCaOykbtJmbe<=p$)T}cOt-|3?jKjOYuVScdFn!v9Bb(I#?FUkw
z4kciYe_<sc5=~jVG}eQOS8T*dRAld6Ux@J?Tny|y<ND-q_wBZfTKf3H7%cu+=U}Bo
zG|y7_ZkoDMp7H@_3L-(e<hz>UlTSB`PPTm%NMIH^l5J5y&IVNQ3Z`OH(_X+NPHHea
zfYB3;Hm-K9$zA$|eDa~eKStTE;&+vlj9kX7CN*a!>2G{PJ>MV=#>w<M?FUlGk3$@+
zmKUK-JY0NqN&fkxqsfy?Al`-%c5@0*eXhS4$n&Y+$gwTvg#-1~Vi@wDCbLGKrzH-6
zSTB9^KGJ!1nEJ<E4OOPSOy(SrIf_O%n(jE$Jqyh}x|HPh`T3dcQtoZ<bD9@1N%<`w
z4fMLD6C*M@i`EL3bWSCC?T*<Nwufd@T*eNg0RF9u_ZM&wMo~cL<>+$HNdmDU+d~S!
z_n2B7$CIunfE6^P&SGMoOwf~=>g;s95;co=E_#h3(18s&%-aTbGvYGFs(u<Kc<lVe
zG>@SlC54I@N~`F)lq(k6N^}d^Dv22wIUx3<m~b+=;spAXJ_=6#E1oTmy<O{81y7oz
z-e773Di2RtDtvp78y`hKpnT}36+ms4x+W&X5fQUf6;<<1S}zCd?uOtuAw@P$57v?L
zPYO@_RU2*Yl)u+^=m4STELhU9b<pR()Q-L<V3R=D*wOo+q2V=}ab4mG1GrLpO)NzG
z@Om}L6WQYYRw-+rl_+l&b5cN>cAc$irTCbJ*uvQ(WGy5kl$D=Rz}R)4<SI$WD_JCZ
zhxBMFU<;k%pty2gyn@ONh!R;!y(+?~W*@+pf9Y$ZhC%G$&m<)i$2m!ieT4l;ia@4x
zNELI3%H^d&t7i)D5^m~OR;5Z>YcDezSD9(uDpiU`;$DJ0>nEar*j-kc-wYkPf9gSV
z%Z8-MLWMn%e3`!b#U6>P^DUVhUf*bignpfsOHFKEaM5~Frkmd~Q)Hk`3|vrZu%@$a
zU&1MzPK_{6Fx<Kba+HuzV+YFV`&G}`H4bt9FTLS~U&U*i9M{PVX8#xrsvcB`w_U^Y
z!{%HGUsSOYgGGfN)lm^e>mhMF!NF?Aysd+-1(+vl@cYx=f5oE+sP|wFma(j;UuKWE
zZk7*oeXp`^1RVSaO5zRy##k}V9L`>96a>5+((w9tFR1`H&CqKre#Mj=vP$M0QU4a6
zoj-lc3XF%Kw06#mfA>c~(rvlGXYr)#qRSYU9QkBStm(nPj0;C0kWu$>vNwWwJhl{j
z1Bq@}i2IO!8kSXrSe_hkw^w6)6<2wq122BHyN<~P#x9-Det_I4{MuW?kMlS;l@vv}
zhjzRPjGUOplU`1wb6a1YMwmS#SQ7e@?<JdsX7fiqptQ;H5+}s&HoM`Ma+bW7NhOQ=
zSkIScK`6TJZ#4?sIlO46LD54%OiBjYYvDT0vPD;?VK8p|vv$-nU)>mA^_vh0S&=>b
z<<g%m`LL4=?r&-hx?4>p3y}NvHuIm$&ufzzU1Dm;Et4pkw*){g(Bg}EE{(o|)!NAK
zA!({~CHMYFt@hrG20_88Ae*dLc&(-pW+qZT`)3wW%caxmn}oZwS@+JAr`L?~?6oU|
zaXArLa=LN?W;dfog!WY_l6+q)8^A@5<QVIjQ@5w^u!1kLf%|C&<*NN-(O9yYWHbXf
z|D#<|QSU$b{2`&&24_Ay)WGpcDZ~K$v68>FwtWj{X4o3wsVU9r9$Y5ea*64owD+gE
zyvtM3eKMDIm+?m%8$}m{hLfF5V{`3O^=B3vQ%q*i-3jDyici;oe=GK+KphA%rPs@{
zAGN0qpA~O&N-=v?zNTvW>eE7ChJMn2GT}k&?lKDSRL^GUt(6FDIhB@835dHc{Iu`=
z)tQt4XZhmpT(vSkJ@x>#lSQ;>c1kwz%Hz4pP=cYIv-U$pma>W2%)|h_xOS}yb*YY)
z1D36pGKpX&(-|b9{q2VLBHJxgxdNG;IK53=ll)79zdAkht+;fs3f_`{2qP^I8k4fW
z%Zi1i{+)eDGm8=`LArFXJtXC6P@iUxKd36!U(|_4EX97%*Ro2h{w;(hPHpL%)7oMM
zoS|uwKZI@2S)P#KY-OyIr&M5@{Xr-~Ac}FT^=~hZl$}P05rullOzbdfBfa_z34!Kn
ziFY?*h(FKl6pfE$z&cO-=?als(oc%{3T1yi1xg+oGX99ks0p+%W6S&e84YvIFL9nq
z@x6W+_?0Q}dNA7a-NWtFg$_N(X{o%O-VH+xjMNdXTkf(8rWU<vd(5(CPP4bu9bp`&
z{&Lj+6Ht9}k#7CONGB>^yr=8WL<Xtp)j0X{>F4(Zo`=w*0u7xO0oIP9#RD)r5|reY
zeU<c-RKX}e;vIJOE8(}g#FH*yR3ceaioZDTm-^8iLU3-NCOspebP9_c(UTOxk^O^l
z2=yV-2#_TGDMt)!I13IRu^6uxfD*Fsj;h2$9vM<f2Gnbzk2_2;cW6p~t+oDQf6Au7
zU%rA3jVK)F|B=tUQ7WAM6LxXI9M_aO@nNOdPqiLymP9@AdTGm0WR~9F&t-mMP34Z%
zqNv)i-O3;K82%VZ*_3?fnpk3M>AXQ{OfCF5nG%(PmdvSnMU+koy&DrgWDTq2<CJC%
ze<^drpz&8^n56Y-2i%z_@j-oJkKE(v%IG8^pHTo1^Np4Y2dt(-5716BdP&B+$2VBQ
z%niIdX)w2(WE|qF{HrBL<Dte)SLYVuZ9;H^%L-&4P0Ki!eT4tTCbi%N^a=-L+R0|+
zvAKoo7aWOYzt8xL6G0U5`Z}E|+)?t?)3xVn+b3ahMQiWTJ8&_~oV*04KB)S+zF15u
z`<~u){o+lELtD}@redUEAwB2%LVJDHOa`%1B6CLi=#!N+|FbhR+W+xmrrnb-sHSl#
zvfL-&^>;6-8p0i@(+88rKcFS&Ef2|WCV)ZeI(H>2r}I67MqWu#{>BLf%W*TW!FDmd
z+w&C0BL<_OdKH=ENZT8E8Lsd0PuMbk#v+7p_zIoBX$2(@npBY%sK*eKFX2g-k3%T{
zgi5MyIt(1F6f88)kZo2Bj{(!$l0Ii84kwCI73{3JGLxNy{r1)79!OsxcOC@*AA~c?
zn|o0>l^abH62cqLt{7D?hi!*0I?kW162;u<W$(bMZ!m`B9ABz47=v!<FbHM&srX{(
zmeMVmZC-o6gvlEe!S`-f3OIc`>~43}1q=}9toLP|sTxUb+z&n<I70X6=1&;pO!+p9
zpR8++JLUpRp@Mq#_h|hP`1e7SM;AH)uC_=s<Hx${SU<&rS+cxm7p*Sx4faz#Hg{X`
z(LJRGvL`7d|9zz18k1}tsr1ySRI7eLVgUfZ`1lmhoE<SSV|u1N%(0Qc7h<e8>0n)D
zjqVa(kr4hl50s(s8qcr19F8s=HQPZ}q}@vS0OJ?rp%zUnzXq2o?ZP)8u%+0FB&ss0
zA5tS$H+CM$d8*j;<LK6m;u<m1-o(gQ&kY(6jjoS1?(4(H{^1(^nLCD~pWUV$X)e!-
z0DWmwF9SB@g{%k}*$%?BL6-1ufJ<C%(*h;Ozs)GxHJUK?f~39!G?t4felyuTH~XQ!
zaXmEp^L!8kzs=eEomYhA@XE$gZEgY`1IHbEOV!CHX$FpsPxV06yflqR&0`Pn55|Vq
z+dn~z;*WxT1jBYm2Q0WcOuGIXd!XX#AP&gbI0Jc>tb#%EuQL2y%Z_-CQhr*=h2#RW
zIzR|?XW*%<=6qXn3bVXWmJMOwm*_vo2Oam{t)yp?@_-(Fm)MsyU}W*yUl5qoDt1!X
zDBB0tN?J2Qi9twOFa>!cml=}1wfC`PMgQ8RLhAGkAob7%y!m(bvq|s#U{%+-1Tfc)
z{_Vtr(4$^$sivzdFZw9yPn&lb%(A$W45BKUv4_Pc6{u!PM-CX>9{<PGp$~(4Yr-YV
zD@AL|PmhxG*jVM?3=hkx>duS(T&NdojD8-Q$?F8A*geLRDAe?FK%DW&YGVBMp()f5
z>PYBC4zrJ4F@F+a=7tYV&nGYZH<zeY;&%KJnQm?{uODM&KTaCcCYyikxlX+|C{XFV
z0xPuYMUq;zt_HLKu0oGbrZdiVZvw!HA(DCYSe+LPhgvv=(tcHGb^5Mrc8hn=9}OHV
zKeq2|YvQ%P=V3ML71NQ6UC>%Kd}MI~1eCu2N9UylFu<V&jjEV4vaGKeD|mPF$L!7A
z)K^)5;OgIaDb5%52u~53A*)<jL{1VRKN3aAyq-F7Z>7z0SjWlsa*3fx?SQAfIdxeq
zGJaixN~vQSLoM0gUy8V$G!MG<Y!>p0dk<Tbcr8tAey3E-MCb#NRJK2l6jGHm%g*~J
zhXW-rL3vnRIVr)@HCCEY=jjlq<XFgq{<Rs4OHTL+4@mCtIa<@Qp0ueip@%3kav1o=
z&fl&t2B8w@Sp4Zk+ufwz)3U_fwWkf`e>3bYW#`fHpmvxXG%u0%wz0InkNIm4%V`$B
z&XIooT!kJI$s|Lvehke9V4Z?bFn}8HEB+YDvKM<!rw`!uV{AqB?XvCzM=hpy$v!;#
zR|~x%GY~v<)L!y>QSH5fnJHjWbnvI8t~vu<|Iyp+Zntgdjm2p=Hjv$3d0ciCL_@d$
z2xG$ZzO9XUPkqtDOz!Hjb-Y0c7EZCq1PT%+IeM#Q5zswOej*B|bfF@<e_K4BaSOdT
z%Ww4z%#_|O)2I-%sg?J>a+Q1gEO;a0wUayHK+Mq=#KQpWJx)tIL^5s?$*=f3)b(4?
zex~e9!?J7CyM#A>o7{Z7FV@;qj((hQ_m90lyqWQ;zA~49Ngz$$I&e4SioO(WQ$QW#
zq`?e_Xd|I;gr+<1>rvv?s<CY|#_}jtgv0~@_S)_XL7+-aC$<-~Sz+KGeQGBg!nzzj
z@|N+rpSF?Ej<VYxf^k(e>n;zY3rv|s#|Y6tUSner=P@&>iRW!nml)-_XBA)}^u%dJ
z+2)#?Xf_B}>+4zU{+LY)*M1I53EIcI+yT++NgZ9hWV<TPyU%SI4rkU&xh;E*?sEG1
zN?$<|+sBZWEZTh;cpD@#-FdIBfKDYE&9@VrNPV}2Qwb;j$K=LQkqdcoU%fAGdC?V6
ztI$q?7@Pt9lNSkYEW#3SE+YGRfJ}wV)w{ulglu5wtJFlm$AxIjL~$#}+^CLbarjrI
z=8X8L{$z0za{|k871D9f9}^obLnB&LClV!HyDpt!w;Ck2B<B+@dJpSLpDCQjv7m3<
zuND}jtRyBmrFu=Ae%$YN*}4}AJO!L%x>CnbHx@-;;}Bi73ij^0b>HST9~6Zu^VM3q
zR#fjvBHiQ_4MnePPs7+AZ*s#Bj{WxcqJ|XX)2#UM9|q07<+oi#ozz9eSIK@s-f|5O
z#@>YqA)%KE+Gs?r5^Y5HNoY;3Q{%Te&3JQ~SqDgeo>qK=77`H+j}tg%hKJ~XR)xb~
zODnOD+PQTL=rp5Sb_@+`K0jOG1ukIcYu?u?mD^jHkJlaiw>22hpV%BaW@7rYTca>~
zMY3$awvQrx+H3v?HlyYEZxT}Jo_-+nm6PC`W-x&i?;89zwdh6b+adLHIm<1$0|7#Z
z6P|u>mzwa?bRv>E)DG(P)i<K9qNe=&h)O0-tzh?UjG%{v)!(3{by8btmr)}DXJtTg
zJhO+{TPu1*=3bGU(AUOpm8EmBVE-;lFpc_r(o`gM<2V&?^V5wa0HO5mTH)i?dYSM7
zdH%oYq&!z;0!v&X<`YHsIr3o;;j|_OqF&zL*z{VS1X#)>GxKnklpc7bQ#Du4^E@YK
zZc9OZZ=mJTjRg@n2=WfsEkt$i)<mvE;rqv*hR6ulOO1(Nd33gU9Vvh2<urdhdd0Kr
mv!Y^V=&$ve@dtz9s7~IzE^?9AcQR-XkG8tLTCIv*<o^LWDRedf
--- a/browser/themes/winstripe/browser/browser.css
+++ b/browser/themes/winstripe/browser/browser.css
@@ -75,20 +75,16 @@
 
 toolbarbutton.bookmark-item {
   margin: 0;
   min-width: 0;
   max-width: 13em;
   padding: 2px 3px;
 }
 
-toolbarbutton.bookmark-item-microsummarized {
-  max-width: 20em;
-}
-
 toolbarbutton.bookmark-item:hover:active:not([disabled="true"]),
 toolbarbutton.bookmark-item[open="true"] {
   padding-top: 3px;
   padding-bottom: 1px;
   -moz-padding-start: 4px;
   -moz-padding-end: 2px;
 }
 
@@ -181,543 +177,301 @@ menuitem.bookmark-item {
 
 .bookmark-item[query][hostContainer][open] {
   list-style-image: url("chrome://global/skin/icons/folder-item.png");
   -moz-image-region: rect(16px, 32px, 32px, 16px);
 }
 
 /* ::::: primary toolbar buttons ::::: */
 
+.toolbarbutton-menubutton-button,
+.toolbarbutton-menubutton-dropmarker,
+.toolbarbutton-1 {
+  -moz-appearance: none;
+  padding: 1px 2px;
+  background: rgba(85%,85%,85%,.1)
+              -moz-linear-gradient(top, rgba(255,255,255,.7), rgba(255,255,255,.39) 48%,
+                                        rgba(95%,95%,95%,.33) 52%, rgba(95%,95%,95%,.15));
+  -moz-background-clip: padding;
+  -moz-border-radius: 5px;
+  border: 1px solid;
+  border-color: rgba(0,0,0,.1) rgba(0,0,0,.15) rgba(0,0,0,.25);
+  -moz-box-shadow: 0 0 0 1px rgba(255,255,255,.3) inset,
+                   0 1px 0 rgba(0,0,0,.08);
+  color: black;
+  text-shadow: 0 0 3px white;
+}
+
 .toolbarbutton-1 {
   -moz-box-orient: vertical;
-  min-width: 0;
   list-style-image: url("chrome://browser/skin/Toolbar.png");
 }
 
+.toolbarbutton-1[disabled="true"] > .toolbarbutton-icon {
+  opacity: .5;
+}
+
+toolbarbutton[type="menu-button"] {
+  -moz-appearance: none;
+  padding: 0;
+  background: none !important;
+  border: none !important;
+  -moz-box-shadow: none !important;
+}
+
+.toolbarbutton-1,
+toolbarbutton[type="menu-button"] {
+  margin: 1px 3px;
+}
+
+.toolbarbutton-menubutton-dropmarker {
+  -moz-border-start-style: none;
+}
+
+.toolbarbutton-menubutton-button:-moz-locale-dir(ltr),
+.toolbarbutton-menubutton-dropmarker:-moz-locale-dir(rtl) {
+  -moz-border-radius-topright: 0;
+  -moz-border-radius-bottomright: 0;
+}
+
+.toolbarbutton-menubutton-button:-moz-locale-dir(rtl),
+.toolbarbutton-menubutton-dropmarker:-moz-locale-dir(ltr) {
+  -moz-border-radius-topleft: 0;
+  -moz-border-radius-bottomleft: 0;
+}
+
+.toolbarbutton-menubutton-button[disabled="true"],
+.toolbarbutton-menubutton-dropmarker[disabled="true"],
+.toolbarbutton-1[disabled="true"] {
+  background-color: rgba(0,0,0,.15);
+  -moz-box-shadow: 0 1px 0 rgba(0,0,0,.08);
+}
+
+.toolbarbutton-menubutton-button:not([disabled="true"]):not(:active):hover,
+:not([open="true"]):not(:active):hover > .toolbarbutton-menubutton-dropmarker:not([disabled="true"]),
+.toolbarbutton-1:not([disabled="true"]):not([checked="true"]):not(:active):hover {
+  background-color: rgba(255,255,255,.6);
+  border-color: rgba(60%,60%,60%,.3) rgba(60%,60%,60%,.45) rgba(60%,60%,60%,.75);
+  -moz-box-shadow: 0 1px 0 rgba(0,0,0,.04),
+                   0 0 6px -1px white,
+                   0 0 6px -2px highlight,
+                   0 0 5px -2px highlight,
+                   0 4px 4px -3px white inset,
+                   0 -4px 4px -3px white inset,
+                   0 -3px 12px -5px highlight inset;
+  -moz-transition: background-color .6s;
+}
+
+.toolbarbutton-menubutton-button:not([disabled="true"]):hover:active,
+:hover:active > .toolbarbutton-menubutton-dropmarker:not([disabled="true"]),
+[open="true"] > .toolbarbutton-menubutton-dropmarker,
+.toolbarbutton-1:not([disabled="true"]):hover:active,
+.toolbarbutton-1[checked="true"],
+.toolbarbutton-1[open="true"] {
+  background-color: transparent;
+  border-color: rgba(0,0,0,.5) rgba(0,0,0,.4) rgba(0,0,0,.4);
+  -moz-box-shadow: 0 0 9px rgba(0,0,0,.4) inset,
+                   0 0 3px rgba(0,0,0,.4) inset,
+                   0 1px 0 rgba(255,255,255,.4);
+  text-shadow: none;
+}
+
+.toolbarbutton-1[checked="true"]:not(:active):hover {
+  background-color: rgba(90%,90%,90%,.4);
+  -moz-transition: background-color .4s;
+}
+
+.toolbarbutton-menubutton-button > .toolbarbutton-icon,
 .toolbarbutton-1 > .toolbarbutton-icon {
-  -moz-margin-end: 0px;
+  -moz-margin-end: 0;
+  width: 18px;
+  height: 18px;
 }
 
 toolbar[mode="full"] .toolbarbutton-1,
 toolbar[mode="full"] .toolbarbutton-menubutton-button {
   min-width: 57px;
 }
 
-.toolbarbutton-1,
-.toolbarbutton-menubutton-button {
-  padding: 5px;
+/* unified back/forward button */
+
+#back-button {
+  -moz-image-region: rect(0, 18px, 18px, 0);
+  -moz-margin-end: 0;
 }
 
-.toolbarbutton-1[checked="true"] {
-  padding: 5px !important;
+#forward-button {
+  -moz-image-region: rect(0, 36px, 18px, 18px);
+  border-left: none;
+  -moz-margin-start: 0;
 }
 
 #back-button:-moz-locale-dir(rtl) > .toolbarbutton-icon,
-#forward-button:-moz-locale-dir(rtl) > .toolbarbutton-icon,
-#back-forward-dropmarker:-moz-locale-dir(rtl) > .toolbarbutton-icon {
+#forward-button:-moz-locale-dir(rtl) {
   -moz-transform: scaleX(-1);
 }
 
-/* ::::: unified back and forward buttons ::::: */
-
-/* unified back button with keyhole icons */
-
-toolbar[mode="icons"] #back-button {
-  -moz-appearance: none;
-  padding: 0;
-  -moz-padding-start: 2px;
-  border: none;
+#back-button:-moz-locale-dir(ltr) {
+  -moz-border-radius-topright: 0;
+  -moz-border-radius-bottomright: 0;
 }
 
-toolbar[iconsize="large"][mode="icons"] #back-button {
-  -moz-image-region: rect(0px 396px 34px 360px);
-}
-toolbar[iconsize="large"][mode="icons"] #back-button:hover {
-  -moz-image-region: rect(34px 396px 68px 360px);
-}
-toolbar[iconsize="large"][mode="icons"] #back-button[disabled="true"] {
-  -moz-image-region: rect(68px 396px 102px 360px);
-}
-toolbar[iconsize="large"][mode="icons"] #back-button:not([disabled="true"]):hover:active {
-  -moz-image-region: rect(102px 396px 136px 360px);
+#back-button:-moz-locale-dir(rtl),
+#forward-button {
+  -moz-border-radius-topleft: 0;
+  -moz-border-radius-bottomleft: 0;
 }
 
-/* unified forward button with keyhole icons */
-
-toolbar[mode="icons"] #forward-button {
-  -moz-appearance: none;
+toolbar:not([iconsize="small"])[mode="icons"] #back-button {
+  -moz-border-radius: 100%;
   padding: 0;
-  border: none;
+  width: 32px;
+  height: 32px;
+  position: relative;
+  z-index: 1;
+  margin-top: -3px;
+  margin-bottom: -3px;
+  -moz-image-region: rect(18px, 18px, 38px, 0);
 }
 
-toolbar[iconsize="large"][mode="icons"] #forward-button {
-  -moz-image-region: rect(3px 422px 31px 396px);
-}
-toolbar[iconsize="large"][mode="icons"] #forward-button:hover {
-  -moz-image-region: rect(37px 422px 65px 396px);
-}
-toolbar[iconsize="large"][mode="icons"] #forward-button[disabled="true"] {
-  -moz-image-region: rect(71px 422px 99px 396px);
-}
-toolbar[iconsize="large"][mode="icons"] #forward-button:not([disabled="true"]):hover:active {
-  -moz-image-region: rect(105px 422px 133px 396px);
+toolbar:not([iconsize="small"])[mode="icons"] #back-button > .toolbarbutton-icon {
+  width: auto;
+  height: auto;
 }
 
-/* dropmarker for unified back and forward buttons with keyhole icons */
+toolbar:not([iconsize="small"])[mode="icons"][currentset*="unified-back-forward-button"],
+#nav-bar:not([iconsize="small"])[mode="icons"]:not([currentset]) {
+  padding-top: 3px;
+  padding-bottom: 3px;
+}
 
-toolbar[mode="icons"] #back-forward-dropmarker {
+toolbar:not([iconsize="small"])[mode="icons"] #forward-button {
+  /*mask: url(keyhole-forward-mask.svg#mask); XXX: this regresses twinopen */
+  mask: url(chrome://browser/content/browser.xul#winstripe-keyhole-forward-mask);
+  -moz-margin-start: -6px;
+  padding-left: 6px;
+}
+
+#back-forward-dropmarker {
   -moz-appearance: none;
   padding: 0;
   -moz-padding-end: 2px;
+  -moz-margin-start: -3px;
   border: none;
+  list-style-image: url(mainwindow-dropdown-arrow.png);
+  -moz-image-region: rect(0, 13px, 11px, 0);
 }
 
-toolbar[mode="icons"] #back-forward-dropmarker > image {
+#back-forward-dropmarker:not([disabled="true"]):hover:active,
+#back-forward-dropmarker[open="true"] {
+  -moz-image-region: rect(0, 26px, 11px, 13px);
+}
+
+#back-forward-dropmarker[disabled="true"] {
+  opacity: .6;
+}
+
+#back-forward-dropmarker > .toolbarbutton-icon {
   display: -moz-box;
   margin: 0;
 }
 
-toolbar[mode="icons"] #back-forward-dropmarker > dropmarker {
+#back-forward-dropmarker > .toolbarbutton-menu-dropmarker {
   display: none;
 }
 
-toolbar[iconsize="large"][mode="icons"] #back-forward-dropmarker {
-  list-style-image: url("chrome://browser/skin/Toolbar.png");
-  -moz-image-region: rect(3px 438px 31px 422px);
-}
-toolbar[iconsize="large"][mode="icons"] #back-forward-dropmarker:hover {
-  -moz-image-region: rect(37px 438px 65px 422px);
-}
-toolbar[iconsize="large"][mode="icons"] #back-forward-dropmarker[disabled="true"] {
-  -moz-image-region: rect(71px 438px 99px 422px);
-}
-toolbar[iconsize="large"][mode="icons"] #back-forward-dropmarker:not([disabled="true"]):hover:active {
-  -moz-image-region: rect(105px 438px 133px 422px);
-}
-
-/* ::::: unified back and forward buttons, small icons mode ::::: */
-
-toolbar[iconsize="small"][mode="icons"] #back-button > .toolbarbutton-icon,
-toolbar[iconsize="small"][mode="icons"] #forward-button > .toolbarbutton-icon {
-  -moz-padding-end: 0;
-}
-
-/* unified back button with keyhole icons, small icons mode */
-
-toolbar[iconsize="small"][mode="icons"] #back-button {
-  -moz-image-region: rect(0px 264px 24px 240px);
-}
-toolbar[iconsize="small"][mode="icons"] #back-button:hover {
-  -moz-image-region: rect(24px 264px 48px 240px);
-}
-toolbar[iconsize="small"][mode="icons"] #back-button[disabled="true"] {
-  -moz-image-region: rect(48px 264px 72px 240px);
-}
-toolbar[iconsize="small"][mode="icons"] #back-button:not([disabled="true"]):hover:active {
-  -moz-image-region: rect(72px 264px 96px 240px);
-}
-
-/* unified forward button with keyhole icons, small icons mode */
-
-toolbar[iconsize="small"][mode="icons"] #forward-button {
-  -moz-image-region: rect(0px 288px 24px 264px);
-}
-toolbar[iconsize="small"][mode="icons"] #forward-button:hover {
-  -moz-image-region: rect(24px 288px 48px 264px);
-}
-toolbar[iconsize="small"][mode="icons"] #forward-button[disabled="true"] {
-  -moz-image-region: rect(48px 288px 72px 264px);
-}
-toolbar[iconsize="small"][mode="icons"] #forward-button:not([disabled="true"]):hover:active {
-  -moz-image-region: rect(72px 288px 96px 264px);
-}
-
-/* dropmarker for unified back and forward buttons with keyhole icons, small icons mode */
-
-toolbar[iconsize="small"][mode="icons"] #back-forward-dropmarker {
-  list-style-image: url("chrome://browser/skin/Toolbar-small.png");
-  -moz-image-region: rect(0px 301px 24px 288px);
-}
-toolbar[iconsize="small"][mode="icons"] #back-forward-dropmarker:hover {
-  -moz-image-region: rect(24px 301px 48px 288px);
-}
-toolbar[iconsize="small"][mode="icons"] #back-forward-dropmarker[disabled="true"] {
-  -moz-image-region: rect(48px 301px 72px 288px);
-}
-toolbar[iconsize="small"][mode="icons"] #back-forward-dropmarker:not([disabled="true"]):hover:active {
-  -moz-image-region: rect(72px 301px 96px 288px);
-}
-
-/* ::::: 24px primary toolbar buttons ::::: */
-
-/* back button */
-
-#back-button {
-  -moz-image-region: rect(0px 24px 24px 0px); 
-}
-#back-button:hover {
-  -moz-image-region: rect(24px 24px 48px 0px);
-}
-#back-button[disabled="true"] {
-  -moz-image-region: rect(48px 24px 72px 0px);
-}
-
-/* forward button */
-
-#forward-button {
-  -moz-image-region: rect(0px 48px 24px 24px);
-}
-#forward-button:hover {
-  -moz-image-region: rect(24px 48px 48px 24px);
-}
-#forward-button[disabled="true"] {
-  -moz-image-region: rect(48px 48px 72px 24px);
-}
-
-/* stop button */
-
-#stop-button {
-  -moz-image-region: rect(0px 72px 24px 48px);
-}
-#stop-button:hover {
-  -moz-image-region: rect(24px 72px 48px 48px);
-}
-#stop-button[disabled="true"] {
-  -moz-image-region: rect(48px 72px 72px 48px);
-}
-
-/* reload button */
-
-#reload-button {
-  -moz-image-region: rect(0px 96px 24px 72px);
-}
-#reload-button:hover {
-  -moz-image-region: rect(24px 96px 48px 72px);
-}
-#reload-button[disabled="true"] {
-  -moz-image-region: rect(48px 96px 72px 72px);
-}
-
-/* home button */
-
-#home-button {
-  -moz-image-region: rect(0px 120px 24px 96px);
-}
-#home-button:hover {
-  -moz-image-region: rect(24px 120px 48px 96px);
-}
-#home-button[disabled="true"] {
-  -moz-image-region: rect(48px 120px 72px 96px);
-}
-
-/* download manager button */
-
-#downloads-button {
-  -moz-image-region: rect(0px 144px 24px 120px);
-}
-#downloads-button:hover {
-  -moz-image-region: rect(24px 144px 48px 120px);
-}
-
-/* history sidebar button */
-
-#history-button {
-  -moz-image-region: rect(0px 168px 24px 144px);
-}
-#history-button:hover,
-#history-button[checked="true"] {
-  -moz-image-region: rect(24px 168px 48px 144px);
-}
-
-/* bookmark sidebar button */
-
-#bookmarks-button {
-  -moz-image-region: rect(0px 192px 24px 168px);
-}
-#bookmarks-button:hover,
-#bookmarks-button[checked="true"] {
-  -moz-image-region: rect(24px 192px 48px 168px);
-}
-
-/* print button */
-
-#print-button {
-  -moz-image-region: rect(0px 216px 24px 192px);
-}
-#print-button:hover {
-  -moz-image-region: rect(24px 216px 48px 192px);
-}
-#print-button[disabled="true"] {
-  -moz-image-region: rect(48px 216px 72px 192px);
-}
-
-/* toolbar new tab button */
-
-#new-tab-button {
-  -moz-image-region: rect(0px 240px 24px 216px);
-}
-#new-tab-button:hover {
-  -moz-image-region: rect(24px 240px 48px 216px);
-}
-
-/* new window button */
-
-#new-window-button {
-  -moz-image-region: rect(0px 264px 24px 240px);
-}
-#new-window-button:hover {
-  -moz-image-region: rect(24px 264px 48px 240px);
-}
-
-/* cut button */
-
-#cut-button {
-  -moz-image-region: rect(0px 288px 24px 264px);
-}
-#cut-button:hover {
-  -moz-image-region: rect(24px 288px 48px 264px);
-}
-#cut-button[disabled="true"] {
-  -moz-image-region: rect(48px 288px 72px 264px);
-}
-
-/* copy button */
-
-#copy-button {
-  -moz-image-region: rect(0px 312px 24px 288px);
-}
-#copy-button:hover {
-  -moz-image-region: rect(24px 312px 48px 288px);
-}
-#copy-button[disabled="true"] {
-  -moz-image-region: rect(48px 312px 72px 288px);
-}
-
-/* paste button */
-
-#paste-button {
-  -moz-image-region: rect(0px 336px 24px 312px);
-}
-#paste-button:hover {
-  -moz-image-region: rect(24px 336px 48px 312px);
-}
-#paste-button[disabled="true"] {
-  -moz-image-region: rect(48px 336px 72px 312px);
-}
-
-/* fullscreen button */
-
-#fullscreen-button {
-  -moz-image-region: rect(0px 360px 24px 336px);
-}
-#fullscreen-button:hover,
-#fullscreen-button[checked="true"] {
-  -moz-image-region: rect(24px 360px 48px 336px);
-}
-
-/* ::::: 16px primary toolbar buttons ::::: */
-
-toolbar[iconsize="small"] .toolbarbutton-1 {
-  -moz-box-orient: vertical;
-  min-width: 0;
-  list-style-image: url("chrome://browser/skin/Toolbar-small.png");
-}
-
-toolbar[iconsize="small"] .toolbarbutton-1[type="menu-button"] {
-  border: 0 !important;
-}
-
-/* back button */
-
-toolbar[iconsize="small"] #back-button > .toolbarbutton-icon {
-  -moz-padding-end: 1px;
-}
-toolbar[iconsize="small"] #back-button {
-  -moz-image-region: rect(0px 16px 16px 0px);
-}
-toolbar[iconsize="small"] #back-button:hover {
-  -moz-image-region: rect(16px 16px 32px 0px);
-}
-toolbar[iconsize="small"] #back-button[disabled="true"] {
-  -moz-image-region: rect(32px 16px 48px 0px);
-}
-
 .unified-nav-back[_moz-menuactive]:-moz-locale-dir(ltr),
 .unified-nav-forward[_moz-menuactive]:-moz-locale-dir(rtl) {
   list-style-image: url("chrome://browser/skin/menu-back.png") !important;
 }
 
-/* forward button */
-
-toolbar[iconsize="small"] #forward-button > .toolbarbutton-icon {
-  -moz-padding-end: 1px;
-}
-toolbar[iconsize="small"] #forward-button {
-  -moz-image-region: rect(0px 32px 16px 16px);
-}
-toolbar[iconsize="small"] #forward-button:hover {
-  -moz-image-region: rect(16px 32px 32px 16px);
-}
-toolbar[iconsize="small"] #forward-button[disabled="true"] {
-  -moz-image-region: rect(32px 32px 48px 16px);
-}
-
 .unified-nav-forward[_moz-menuactive]:-moz-locale-dir(ltr),
 .unified-nav-back[_moz-menuactive]:-moz-locale-dir(rtl) {
   list-style-image: url("chrome://browser/skin/menu-forward.png") !important;
 }
 
 /* stop button */
 
-toolbar[iconsize="small"] #stop-button {
-  -moz-image-region: rect(0px 48px 16px 32px);
-}
-toolbar[iconsize="small"] #stop-button:hover {
-  -moz-image-region: rect(16px 48px 32px 32px);
-}
-toolbar[iconsize="small"] #stop-button[disabled="true"] {
-  -moz-image-region: rect(32px 48px 48px 32px);
+#stop-button {
+  -moz-image-region: rect(0, 54px, 18px, 36px);
 }
 
 /* reload button */
 
-toolbar[iconsize="small"] #reload-button {
-  -moz-image-region: rect(0px 64px 16px 48px);
-}
-toolbar[iconsize="small"] #reload-button:hover {
-  -moz-image-region: rect(16px 64px 32px 48px);
-}
-toolbar[iconsize="small"] #reload-button[disabled="true"] {
-  -moz-image-region: rect(32px 64px 48px 48px);
+#reload-button {
+  -moz-image-region: rect(0, 72px, 18px, 54px);
 }
 
 /* home button */
 
 #home-button.bookmark-item {
-  list-style-image: url("chrome://browser/skin/Toolbar-small.png");
-}
-toolbar[iconsize="small"] #home-button,
-#home-button.bookmark-item {
-  -moz-image-region: rect(0px 80px 16px 64px);
+  list-style-image: url("chrome://browser/skin/Toolbar.png");
 }
-toolbar[iconsize="small"] #home-button:hover,
-#home-button.bookmark-item:hover {
-  -moz-image-region: rect(16px 80px 32px 64px);
-}
-toolbar[iconsize="small"] #home-button[disabled="true"],
-#home-button.bookmark-item[disabled="true"] {
-  -moz-image-region: rect(32px 80px 48px 64px);
+#home-button {
+  -moz-image-region: rect(0, 90px, 18px, 72px);
 }
 
 /* download manager button */
 
-toolbar[iconsize="small"] #downloads-button {
-  -moz-image-region: rect(0px 96px 16px 80px);
-}
-toolbar[iconsize="small"] #downloads-button:hover {
-  -moz-image-region: rect(16px 96px 32px 80px);
+#downloads-button {
+  -moz-image-region: rect(0, 108px, 18px, 90px);
 }
 
 /* history sidebar button */
 
-toolbar[iconsize="small"] #history-button {
-  -moz-image-region: rect(0px 112px 16px 96px);
-}
-toolbar[iconsize="small"] #history-button:hover,
-toolbar[iconsize="small"] #history-button[checked="true"] {
-  -moz-image-region: rect(16px 112px 32px 96px);
+#history-button {
+  -moz-image-region: rect(0, 126px, 18px, 108px);
 }
 
 /* bookmark sidebar button */
 
-toolbar[iconsize="small"] #bookmarks-button {
-  -moz-image-region: rect(0px 128px 16px 112px);
-}
-toolbar[iconsize="small"] #bookmarks-button:hover,
-toolbar[iconsize="small"] #bookmarks-button[checked="true"] {
-  -moz-image-region: rect(16px 128px 32px 112px);
+#bookmarks-button {
+  -moz-image-region: rect(0, 144px, 18px, 126px);
 }
 
 /* print button */
 
-toolbar[iconsize="small"] #print-button {
-  -moz-image-region: rect(0px 144px 16px 128px);
-}
-toolbar[iconsize="small"] #print-button:hover {
-  -moz-image-region: rect(16px 144px 32px 128px);
-}
-toolbar[iconsize="small"] #print-button[disabled="true"] {
-  -moz-image-region: rect(32px 144px 48px 128px);
+#print-button {
+  -moz-image-region: rect(0, 162px, 18px, 144px);
 }
 
 /* toolbar new tab button */
 
-toolbar[iconsize="small"] #new-tab-button {
-  -moz-image-region: rect(0px 160px 16px 144px);
-}
-toolbar[iconsize="small"] #new-tab-button:hover {
-  -moz-image-region: rect(16px 160px 32px 144px);
+#new-tab-button {
+  -moz-image-region: rect(0, 180px, 18px, 162px);
 }
 
 /* new window button */
 
-toolbar[iconsize="small"] #new-window-button {
-  -moz-image-region: rect(0px 176px 16px 160px);
-}
-toolbar[iconsize="small"] #new-window-button:hover {
-  -moz-image-region: rect(16px 176px 32px 160px);
+#new-window-button {
+  -moz-image-region: rect(0, 198px, 18px, 180px);
 }
 
 /* cut button */
 
-toolbar[iconsize="small"] #cut-button > .toolbarbutton-icon {
-  padding-right: 1px;
-}
-toolbar[iconsize="small"] #cut-button {
-  -moz-image-region: rect(0px 192px 16px 176px);
-}
-toolbar[iconsize="small"] #cut-button:hover {
-  -moz-image-region: rect(16px 192px 32px 176px);
-}
-toolbar[iconsize="small"] #cut-button[disabled="true"] {
-  -moz-image-region: rect(32px 192px 48px 176px);
+#cut-button {
+  -moz-image-region: rect(0, 216px, 18px, 198px);
 }
 
 /* copy button */
 
-toolbar[iconsize="small"] #copy-button {
-  -moz-image-region: rect(0px 208px 16px 192px);
-}
-toolbar[iconsize="small"] #copy-button:hover {
-  -moz-image-region: rect(16px 208px 32px 192px);
-}
-toolbar[iconsize="small"] #copy-button[disabled="true"] {
-  -moz-image-region: rect(32px 208px 48px 192px);
+#copy-button {
+  -moz-image-region: rect(0, 234px, 18px, 216px);
 }
 
 /* paste button */
 
-toolbar[iconsize="small"] #paste-button {
-  -moz-image-region: rect(0px 224px 16px 208px);
-}
-toolbar[iconsize="small"] #paste-button:hover {
-  -moz-image-region: rect(16px 224px 32px 208px);
-}
-toolbar[iconsize="small"] #paste-button[disabled="true"] {
-  -moz-image-region: rect(32px 224px 48px 208px);
+#paste-button {
+  -moz-image-region: rect(0, 252px, 18px, 234px);
 }
 
 /* fullscreen button */
 
-toolbar[iconsize="small"] #fullscreen-button {
-  -moz-image-region: rect(0px 240px 16px 224px);
-}
-toolbar[iconsize="small"] #fullscreen-button:hover,
-toolbar[iconsize="small"] #fullscreen-button[checked="true"] {
-  -moz-image-region: rect(16px 240px 32px 224px);
+#fullscreen-button {
+  -moz-image-region: rect(0, 270px, 18px, 252px);
 }
 
 /* ::::: fullscreen window controls ::::: */
 
 #minimize-button,
 #restore-button,
 #close-button {
   list-style-image: url("chrome://global/skin/icons/windowControls.png");
@@ -1647,23 +1401,18 @@ toolbarbutton.bookmark-item[dragover="tr
   outline-offset: -3px;
 }
 
 #identity-box.verifiedDomain:focus ,
 #identity-box.verifiedIdentity:focus {
   outline: 1px dotted white;
 }
 
-#identity-icon-label {
+#identity-icon-labels {
   padding: 0 2px;
-  margin: 0;
-}
-
-#identity-icon-label[value=""] {
-  display: none;
 }
 
 /* Popup Icons */
 #identity-popup-icon {
   height: 64px;
   width: 64px;
   padding: 0;
   list-style-image: url("chrome://browser/skin/identity.png");
@@ -1747,18 +1496,18 @@ toolbarbutton.bookmark-item[dragover="tr
 }
 
 #identity-popup-container {
   min-width: 280px;
   padding: 9px;
 }
 
 #download-monitor {
-  list-style-image: url("chrome://browser/skin/Toolbar-small.png");
-  -moz-image-region: rect(0px 96px 16px 80px);
+  list-style-image: url("chrome://browser/skin/Toolbar.png");
+  -moz-image-region: rect(0, 108px, 18px, 90px);
 }
 
 /* Bookmarks Toolbar menu-item */
 #bookmarksToolbarFolderMenu {
   list-style-image: url("chrome://browser/skin/places/bookmarksToolbar.png");
   -moz-image-region: auto;
 }
 
--- a/browser/themes/winstripe/browser/jar.mn
+++ b/browser/themes/winstripe/browser/jar.mn
@@ -9,31 +9,31 @@ browser.jar:
         skin/classic/browser/aboutSessionRestore-window-icon.png     (aboutSessionRestore-window-icon.png)
         skin/classic/browser/aboutCertError.css                      (aboutCertError.css)
 *       skin/classic/browser/browser.css                             (browser.css)
 *       skin/classic/browser/engineManager.css                       (engineManager.css)
         skin/classic/browser/fullscreen-video.css
         skin/classic/browser/Geo.png                                 (Geo.png)
         skin/classic/browser/Info.png                                (Info.png)
         skin/classic/browser/identity.png                            (identity.png)
+        skin/classic/browser/keyhole-forward-mask.svg
         skin/classic/browser/KUI-background.png
         skin/classic/browser/KUI-close.png
         skin/classic/browser/mainwindow-dropdown-arrow.png
         skin/classic/browser/pageInfo.css
         skin/classic/browser/pageInfo.png                            (pageInfo.png)
         skin/classic/browser/page-livemarks.png                      (feeds/feedIcon16.png)
         skin/classic/browser/livemark-item.png                       (livemark-item.png)
         skin/classic/browser/livemark-folder.png                     (livemark-folder.png)
         skin/classic/browser/Privacy-16.png
         skin/classic/browser/Privacy-48.png
         skin/classic/browser/Secure.png                              (Secure.png)
         skin/classic/browser/Secure24.png                            (Secure24.png)
         skin/classic/browser/Security-broken.png                     (Security-broken.png)
         skin/classic/browser/Toolbar.png                             (Toolbar.png)
-        skin/classic/browser/Toolbar-small.png                       (Toolbar-small.png)
         skin/classic/browser/Go-arrow.png                            (Go-arrow.png)
 *       skin/classic/browser/searchbar.css                           (searchbar.css)
         skin/classic/browser/Search-addengines.png
         skin/classic/browser/section_collapsed.png
         skin/classic/browser/section_expanded.png
         skin/classic/browser/setDesktopBackground.css
         skin/classic/browser/menu-back.png                           (menu-back.png)
         skin/classic/browser/menu-forward.png                        (menu-forward.png)
@@ -97,31 +97,31 @@ browser.jar:
         skin/classic/aero/browser/aboutSessionRestore-window-icon.png (aboutSessionRestore-window-icon-aero.png)
         skin/classic/aero/browser/aboutCertError.css                 (aboutCertError.css)
 *       skin/classic/aero/browser/browser.css                        (browser-aero.css)
 *       skin/classic/aero/browser/engineManager.css                  (engineManager.css)
         skin/classic/aero/browser/fullscreen-video.css
         skin/classic/aero/browser/Geo.png                            (Geo-aero.png)
         skin/classic/aero/browser/Info.png                           (Info-aero.png)
         skin/classic/aero/browser/identity.png                       (identity-aero.png)
+        skin/classic/aero/browser/keyhole-forward-mask.svg
         skin/classic/aero/browser/KUI-background.png
         skin/classic/aero/browser/KUI-close.png
         skin/classic/aero/browser/mainwindow-dropdown-arrow.png      (mainwindow-dropdown-arrow-aero.png)
         skin/classic/aero/browser/pageInfo.css
         skin/classic/aero/browser/pageInfo.png                       (pageInfo-aero.png)
         skin/classic/aero/browser/page-livemarks.png                 (feeds/feedIcon16-aero.png)
         skin/classic/aero/browser/livemark-item.png                  (livemark-item-aero.png)
         skin/classic/aero/browser/livemark-folder.png                (livemark-folder-aero.png)
         skin/classic/aero/browser/Privacy-16.png                     (Privacy-16-aero.png)
         skin/classic/aero/browser/Privacy-48.png                     (Privacy-48-aero.png)
         skin/classic/aero/browser/Secure.png                         (Secure-aero.png)
         skin/classic/aero/browser/Secure24.png                       (Secure24-aero.png)
         skin/classic/aero/browser/Security-broken.png                (Security-broken-aero.png)
-        skin/classic/aero/browser/Toolbar.png                        (Toolbar-aero.png)
-        skin/classic/aero/browser/Toolbar-small.png                  (Toolbar-small-aero.png)
+        skin/classic/aero/browser/Toolbar.png
         skin/classic/aero/browser/Go-arrow.png                       (Go-arrow-aero.png)
 *       skin/classic/aero/browser/searchbar.css                      (searchbar.css)
         skin/classic/aero/browser/Search-addengines.png
         skin/classic/aero/browser/section_collapsed.png
         skin/classic/aero/browser/section_expanded.png
         skin/classic/aero/browser/setDesktopBackground.css
         skin/classic/aero/browser/menu-back.png                      (menu-back-aero.png)
         skin/classic/aero/browser/menu-forward.png                   (menu-forward-aero.png)
new file mode 100644
--- /dev/null
+++ b/browser/themes/winstripe/browser/keyhole-forward-mask.svg
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<svg xmlns="http://www.w3.org/2000/svg">
+  <mask id="mask" maskContentUnits="objectBoundingBox">
+    <rect x="0" y="0" width="1" height="1" fill="white"/>
+    <circle cx="-0.42" cy="0.5" r="0.63" id="circle"/>
+  </mask>
+</svg>
--- a/browser/themes/winstripe/browser/searchbar.css
+++ b/browser/themes/winstripe/browser/searchbar.css
@@ -1,14 +1,18 @@
 .searchbar-textbox {
   min-height: 22px;
   width: 6em;
   min-width: 6em;
 }
 
+.autocomplete-textbox-container {
+  -moz-box-align: stretch;
+}
+
 .searchbar-textbox:-moz-system-metric(windows-default-theme) {
   -moz-appearance: none;
   border-width: 1px;
   -moz-border-top-colors: ThreeDShadow;
   -moz-border-bottom-colors: ThreeDShadow;
   -moz-border-right-colors: ThreeDShadow;
   -moz-border-left-colors: ThreeDShadow;
 }
@@ -28,18 +32,16 @@
 }
 
 .searchbar-engine-button {
   -moz-appearance: none;
   min-width: 0;
   margin: 0;
   -moz-margin-end: 3px;
   padding: 0;
-  height: 1.23em;
-  min-height: 20px;
   -moz-box-align: center;
   background: -moz-dialog url(navbar-textbox-buttons.png) repeat-x;
   border: 0 solid;
   -moz-border-end-width: 1px;
   -moz-border-right-colors: ThreeDShadow;
   -moz-border-left-colors: ThreeDShadow;
   -moz-box-shadow: 1px 1px 0 rgba(255,255,255,.4) inset,
                    0 -1px 0 rgba(255,255,255,.4) inset;
--- a/build/Makefile.in
+++ b/build/Makefile.in
@@ -96,16 +96,18 @@ libs:: bloaturls.txt
 # of bloaturls.txt.  This is for browsers that can't do -f
 # autocycling of URLs.
 libs:: bloatcycle.html
 	$(INSTALL) $< $(DIST)/bin/res
 
 ifeq ($(OS_ARCH),Darwin)
 libs:: $(topsrcdir)/tools/rb/fix-macosx-stack.pl
 	$(INSTALL) $< $(DIST)/bin
+libs:: $(topsrcdir)/tools/rb/fix_macosx_stack.py
+	$(INSTALL) $< $(DIST)/bin
 
 # Basic unit tests for some stuff in the unify script
 check::
 # build ppc/i386 binaries, and unify them
 	rm -f unify-test-ppc unify-test-i386 unify-test-universal
 	$(HOST_CC) -arch ppc $(srcdir)/unify-test.c -o unify-test-ppc
 	$(HOST_CC) -arch i386 $(srcdir)/unify-test.c -o unify-test-i386
 	@if ! $(srcdir)/macosx/universal/unify ./unify-test-ppc ./unify-test-i386 \
--- a/build/automation.py.in
+++ b/build/automation.py.in
@@ -575,36 +575,40 @@ user_pref("camino.use_system_proxy_setti
           return
     #TODO: kill the process such that it triggers Breakpad on OS X (bug 525296)
     self.log.info("Can't trigger Breakpad, just killing process")
     proc.kill()
 
   def waitForFinish(self, proc, utilityPath, timeout, maxTime, startTime):
     """ Look for timeout or crashes and return the status after the process terminates """
     stackFixerProcess = None
+    stackFixerModule = None
     didTimeout = False
     if proc.stdout is None:
       self.log.info("TEST-INFO: Not logging stdout or stderr due to debugger connection")
     else:
       logsource = proc.stdout
-      if self.IS_DEBUG_BUILD:
-        stackFixerCommand = None
-        if self.IS_MAC:
-          stackFixerCommand = "fix-macosx-stack.pl"
-        elif self.IS_LINUX:
-          stackFixerCommand = "fix-linux-stack.pl"
-        if stackFixerCommand is not None:
-          stackFixerProcess = self.Process([self.PERL, os.path.join(utilityPath, stackFixerCommand)], 
-                                           stdin=logsource, 
-                                           stdout=subprocess.PIPE)
-          logsource = stackFixerProcess.stdout
+      if self.IS_DEBUG_BUILD and self.IS_LINUX:
+        # Run logsource through fix-linux-stack.pl
+        stackFixerProcess = self.Process([self.PERL, os.path.join(utilityPath, "fix-linux-stack.pl")],
+                                         stdin=logsource,
+                                         stdout=subprocess.PIPE)
+        logsource = stackFixerProcess.stdout
+
+      if self.IS_DEBUG_BUILD and self.IS_MAC:
+        # Import fix_macosx_stack.py from utilityPath
+        sys.path.insert(0, utilityPath)
+        import fix_macosx_stack as stackFixerModule
+        del sys.path[0]
 
       (line, didTimeout) = self.readWithTimeout(logsource, timeout)
       hitMaxTime = False
       while line != "" and not didTimeout:
+        if stackFixerModule:
+          line = stackFixerModule.fixSymbols(line)
         self.log.info(line.rstrip())
         (line, didTimeout) = self.readWithTimeout(logsource, timeout)
         if not hitMaxTime and maxTime and datetime.now() - startTime > timedelta(seconds = maxTime):
           # Kill the application, but continue reading from stack fixer so as not to deadlock on stackFixerProcess.wait().
           hitMaxTime = True
           self.log.info("TEST-UNEXPECTED-FAIL | automation.py | application ran for longer than allowed maximum time of %d seconds", int(maxTime))
           self.triggerBreakpad(proc, utilityPath)
       if didTimeout:
--- a/chrome/src/nsChromeRegistry.cpp
+++ b/chrome/src/nsChromeRegistry.cpp
@@ -1280,20 +1280,21 @@ nsChromeRegistry::WrappersEnabled(nsIURI
   return PL_DHASH_ENTRY_IS_LIVE(entry) &&
          entry->flags & PackageEntry::XPCNATIVEWRAPPERS;
 }
 
 nsresult
 nsChromeRegistry::SelectLocaleFromPref(nsIPrefBranch* prefs)
 {
   nsresult rv;
-  PRBool matchOSLocale = PR_FALSE;
+  PRBool matchOSLocale = PR_FALSE, userLocaleOverride = PR_FALSE;
+  prefs->PrefHasUserValue(SELECTED_LOCALE_PREF, &userLocaleOverride);
   rv = prefs->GetBoolPref(MATCH_OS_LOCALE_PREF, &matchOSLocale);
 
-  if (NS_SUCCEEDED(rv) && matchOSLocale) {
+  if (NS_SUCCEEDED(rv) && matchOSLocale && !userLocaleOverride) {
     // compute lang and region code only when needed!
     nsCAutoString uiLocale;
     rv = getUILangCountry(uiLocale);
     if (NS_SUCCEEDED(rv))
       mSelectedLocale = uiLocale;
   }
   else {
     nsXPIDLCString provider;
deleted file mode 100644
--- a/chrome/test/unit/data/test_bug519468.manifest
+++ /dev/null
@@ -1,2 +0,0 @@
-locale testmatchos en-US jar:en-US.jar!/locale/en-US/global/
-locale testmatchos fr-FR jar:en-US.jar!/locale/en-US/global/
--- a/chrome/test/unit/test_bug519468.js
+++ b/chrome/test/unit/test_bug519468.js
@@ -31,50 +31,90 @@
  * 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 write_locale(stream, locale, package) {
+  var s = "locale " + package + " " + locale + " jar:" + locale + ".jar!";
+  s += "/locale/" + locale + "/" + package +"/\n";
+  stream.write(s, s.length);
+}
+
+var localeService = Cc["@mozilla.org/intl/nslocaleservice;1"]
+                    .getService(Ci.nsILocaleService);
+
+var systemLocale = localeService.getLocaleComponentForUserAgent();
+
+var locales;
+
+if (systemLocale == "en-US")
+  locales = [ "en-US", "fr-FR", "de-DE" ];
+else if (systemLocale == "fr-FR")
+  locales = [ "en-US", systemLocale, "de-DE" ];
+else
+  locales = [ "en-US", systemLocale, "fr-FR" ];
+
+var workingDir = Cc["@mozilla.org/file/directory_service;1"].
+                 getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
+var manifest = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
+manifest.initWithFile(workingDir);
+manifest.append("test_bug519468.manifest");
+manifest.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0600);
+var stream = Cc["@mozilla.org/network/file-output-stream;1"].
+             createInstance(Ci.nsIFileOutputStream);
+stream.init(manifest, 0x04 | 0x08 | 0x20, 0600, 0); // write, create, truncate
+locales.slice(0,2).forEach(function(l) write_locale(stream, l, "testmatchos"));
+write_locale(stream, locales[2], "testnomatchos");
+stream.close();
+
 var MANIFESTS = [
-  do_get_file("data/test_bug519468.manifest")
+  manifest
 ];
 
 registerManifests(MANIFESTS);
 
 var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"]
                 .getService(Ci.nsIXULChromeRegistry)
                 .QueryInterface(Ci.nsIToolkitChromeRegistry);
 
-var localeService = Cc["@mozilla.org/intl/nslocaleservice;1"]
-                    .getService(Ci.nsILocaleService);
-
 var prefService = Cc["@mozilla.org/preferences-service;1"]
                   .getService(Ci.nsIPrefService)
                   .QueryInterface(Ci.nsIPrefBranch);
 
 function test_locale(aTest) {
   prefService.setBoolPref("intl.locale.matchOS", aTest.matchOS);
-  prefService.setCharPref("general.useragent.locale", aTest.selected || "en-US");
+  if (aTest.selected)
+    prefService.setCharPref("general.useragent.locale", aTest.selected);
+  else
+    try {
+      prefService.clearUserPref("general.useragent.locale");
+    } catch(e) {}
 
-  var selectedLocale = chromeReg.getSelectedLocale("testmatchos");
+  var selectedLocale = chromeReg.getSelectedLocale(aTest.package);
   do_check_eq(selectedLocale, aTest.locale);
 }
 
 function run_test()
 {
-  var systemLocale = localeService.getLocaleComponentForUserAgent();
-
   var tests = [
-    {matchOS: false, selected: null, locale: "en-US"},
     {matchOS: true, selected: null, locale: systemLocale},
-    {matchOS: true, selected: "fr-FR", locale: systemLocale},
-    {matchOS: false, selected: "fr-FR", locale: "fr-FR"},
-    {matchOS: true, selected: null, locale: systemLocale}
+    {matchOS: true, selected: locales[0], locale: locales[0]},
+    {matchOS: true, selected: locales[1], locale: locales[1]},
+    {matchOS: true, selected: locales[2], locale: locales[0]},
+    {matchOS: true, selected: null, locale: locales[2], package: "testnomatchos"},
+    {matchOS: false, selected: null, locale: locales[0]},
+    {matchOS: false, selected: locales[0], locale: locales[0]},
+    {matchOS: false, selected: locales[1], locale: locales[1]},
+    {matchOS: false, selected: locales[2], locale: locales[0]},
   ];
 
   for (var i = 0; i < tests.length; ++ i) {
     var test = tests[i];
+    if (!test.package)
+      test.package = "testmatchos";
     test_locale(test);
   }
+  manifest.remove(false);
 }
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -618,25 +618,19 @@ WINCE_SDK_DIR   = @WINCE_SDK_DIR@
 OGLES_SDK_DIR   = @OGLES_SDK_DIR@
 
 WINCE_WINDOWS_MOBILE = @WINCE_WINDOWS_MOBILE@
 
 HAS_OGLES = @HAS_OGLES@
 
 MOZ_DISTRIBUTION_ID = @MOZ_DISTRIBUTION_ID@
 
-NS_OSSO 	= @NS_OSSO@
-MOZ_PLATFORM_HILDON = @MOZ_PLATFORM_HILDON@
-
-LIBHILDONMIME_CFLAGS	= @LIBHILDONMIME_CFLAGS@
-LIBHILDONMIME_LIBS	= @LIBHILDONMIME_LIBS@
-LIBOSSO_CFLAGS 	= @LIBOSSO_CFLAGS@
-LIBOSSO_LIBS 	= @LIBOSSO_LIBS@
-LIBHILDONFM_CFLAGS	= @LIBHILDONFM_CFLAGS@
-LIBHILDONFM_LIBS	= @LIBHILDONFM_LIBS@
+MOZ_PLATFORM_MAEMO = @MOZ_PLATFORM_MAEMO@
+MOZ_PLATFORM_MAEMO_CFLAGS	= @MOZ_PLATFORM_MAEMO_CFLAGS@
+MOZ_PLATFORM_MAEMO_LIBS 	= @MOZ_PLATFORM_MAEMO_LIBS@
 
 MOZ_ENABLE_LIBCONIC = @MOZ_ENABLE_LIBCONIC@
 LIBCONIC_CFLAGS     = @LIBCONIC_CFLAGS@
 LIBCONIC_LIBS       = @LIBCONIC_LIBS@
 
 MACOS_SDK_DIR	= @MACOS_SDK_DIR@
 NEXT_ROOT	= @NEXT_ROOT@
 GCC_VERSION	= @GCC_VERSION@
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -375,16 +375,17 @@ ifndef TARGETS
 TARGETS			= $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(JAVA_LIBRARY)
 endif
 
 ifndef OBJS
 _OBJS			= \
 	$(JRI_STUB_CFILES) \
 	$(addsuffix .$(OBJ_SUFFIX), $(JMC_GEN)) \
 	$(CSRCS:.c=.$(OBJ_SUFFIX)) \
+	$(SSRCS:.S=.$(OBJ_SUFFIX)) \
 	$(patsubst %.cc,%.$(OBJ_SUFFIX),$(CPPSRCS:.cpp=.$(OBJ_SUFFIX))) \
 	$(CMSRCS:.m=.$(OBJ_SUFFIX)) \
 	$(CMMSRCS:.mm=.$(OBJ_SUFFIX)) \
 	$(ASFILES:.$(ASM_SUFFIX)=.$(OBJ_SUFFIX))
 OBJS	= $(strip $(_OBJS))
 endif
 
 ifndef HOST_OBJS
@@ -992,29 +993,34 @@ alltags:
 	rm -f TAGS
 	find $(topsrcdir) -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' -o -name '*.idl' \) -print | $(TAG_PROGRAM)
 
 #
 # PROGRAM = Foo
 # creates OBJS, links with LIBS to create Foo
 #
 $(PROGRAM): $(PROGOBJS) $(LIBS_DEPS) $(EXTRA_DEPS) $(EXE_DEF_FILE) $(RESFILE) $(GLOBAL_DEPS)
+	@rm -f $@.manifest
 ifeq (WINCE,$(OS_ARCH))
 	$(LD) -NOLOGO -OUT:$@ $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(PROGOBJS) $(RESFILE) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
 else
 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
 	$(LD) -NOLOGO -OUT:$@ -PDB:$(LINK_PDBFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(PROGOBJS) $(RESFILE) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
 ifdef MSMANIFEST_TOOL
 	@if test -f $@.manifest; then \
 		if test -f "$(srcdir)/$@.manifest"; then \
+			echo "Embedding manifest from $(srcdir)/$@.manifest and $@.manifest"; \
 			mt.exe -NOLOGO -MANIFEST "$(win_srcdir)/$@.manifest" $@.manifest -OUTPUTRESOURCE:$@\;1; \
 		else \
+			echo "Embedding manifest from $@.manifest"; \
 			mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
 		fi; \
-		rm -f $@.manifest; \
+	elif test -f "$(srcdir)/$@.manifest"; then \
+		echo "Embedding manifest from $(srcdir)/$@.manifest"; \
+		mt.exe -NOLOGO -MANIFEST "$(win_srcdir)/$@.manifest" -OUTPUTRESOURCE:$@\;1; \
 	fi
 endif	# MSVC with manifest tool
 ifdef MOZ_PROFILE_GENERATE
 # touch it a few seconds into the future to work around FAT's
 # 2-second granularity
 	touch -t `date +%Y%m%d%H%M.%S -d "now+5seconds"` pgo.relink
 endif
 else # !WINNT || GNU_CC
@@ -1397,16 +1403,20 @@ host_%.$(OBJ_SUFFIX): %.mm $(GLOBAL_DEPS
 %.$(OBJ_SUFFIX): %.c $(GLOBAL_DEPS)
 	$(REPORT_BUILD)
 	@$(MAKE_DEPS_AUTO_CC)
 	$(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $(_VPATH_SRCS)
 
 moc_%.cpp: %.h $(GLOBAL_DEPS)
 	$(MOC) $< $(OUTOPTION)$@ 
 
+moc_%.cc: %.cc $(GLOBAL_DEPS)
+	$(REPORT_BUILD)
+	$(ELOG) $(MOC) $(_VPATH_SRCS:.cc=.h) $(OUTOPTION)$@
+
 ifdef ASFILES
 # The AS_DASH_C_FLAG is needed cause not all assemblers (Solaris) accept
 # a '-c' flag.
 %.$(OBJ_SUFFIX): %.$(ASM_SUFFIX) $(GLOBAL_DEPS)
 	$(AS) -o $@ $(ASFLAGS) $(AS_DASH_C_FLAG) $(_VPATH_SRCS)
 endif
 
 %.$(OBJ_SUFFIX): %.S $(GLOBAL_DEPS)
@@ -2088,22 +2098,16 @@ endif
 endif
 endif
 #############################################################################
 
 -include $(topsrcdir)/$(MOZ_BUILD_APP)/app-rules.mk
 -include $(MY_RULES)
 
 #
-# This speeds up gmake's processing if these files don't exist.
-#
-$(MY_CONFIG) $(MY_RULES):
-	@touch $@
-
-#
 # Generate Emacs tags in a file named TAGS if ETAGS was set in $(MY_CONFIG)
 # or in $(MY_RULES)
 #
 ifdef ETAGS
 ifneq ($(CSRCS)$(CPPSRCS)$(HEADERS),)
 all:: TAGS
 TAGS:: $(CSRCS) $(CPPSRCS) $(HEADERS)
 	$(ETAGS) $(CSRCS) $(CPPSRCS) $(HEADERS)
--- a/config/system-headers
+++ b/config/system-headers
@@ -1004,22 +1004,20 @@ libsn/sn-monitor.h
 libsn/sn-util.h
 #endif
 #if MOZ_NATIVE_HUNSPELL==1
 hunspell.hxx
 #endif
 #if MOZ_NATIVE_BZ2==1
 bzlib.h
 #endif
-#ifdef MOZ_PLATFORM_HILDON
+#if MOZ_PLATFORM_MAEMO==5
 hildon-uri.h
 hildon-mime.h
 hildon-file-chooser-dialog.h
-#endif
-#ifdef NS_OSSO
 libosso.h
 osso-mem.h
 #endif
 #ifdef MOZ_ENABLE_GIO
 gio/gio.h
 #endif
 #ifdef MOZ_ENABLE_LIBCONIC
 conic/conicconnection.h
--- a/configure.in
+++ b/configure.in
@@ -398,38 +398,38 @@ else
     AC_PROG_CXX
     AC_PROG_RANLIB
     MOZ_PATH_PROGS(AS, $AS as, $CC)
     AC_CHECK_PROGS(AR, ar, :)
     AC_CHECK_PROGS(LD, ld, :)
     AC_CHECK_PROGS(STRIP, strip, :)
     AC_CHECK_PROGS(WINDRES, windres, :)
     if test -z "$HOST_CC"; then
-        HOST_CC="$CC"
+        HOST_CC='$(CC)'
     fi
     if test -z "$HOST_CFLAGS"; then
-        HOST_CFLAGS="$CFLAGS"
+        HOST_CFLAGS='$(CFLAGS)'
     fi
     if test -z "$HOST_CXX"; then
-        HOST_CXX="$CXX"
+        HOST_CXX='$(CXX)'
     fi
     if test -z "$HOST_CXXFLAGS"; then
-        HOST_CXXFLAGS="$CXXFLAGS"
+        HOST_CXXFLAGS='$(CXXFLAGS)'
     fi
     if test -z "$HOST_LDFLAGS"; then
-        HOST_LDFLAGS="$LDFLAGS"
+        HOST_LDFLAGS='$(LDFLAGS)'
     fi
     if test -z "$HOST_RANLIB"; then
-        HOST_RANLIB="$RANLIB"
+        HOST_RANLIB='$(RANLIB)'
     fi
     if test -z "$HOST_AR"; then
-        HOST_AR="$AR"
+        HOST_AR='$(AR)'
     fi
     if test -z "$HOST_AR_FLAGS"; then
-        HOST_AR_FLAGS="$AR_FLAGS"
+        HOST_AR_FLAGS='$(AR_FLAGS)'
     fi
 fi
 
 GNU_AS=
 GNU_LD=
 GNU_CC=
 GNU_CXX=
 CC_VERSION='N/A'
@@ -1725,17 +1725,16 @@ case "$host" in
         ;;
     esac
     ;;
 
 *-darwin*)
     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX -DNO_X11"
     HOST_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
-    MOZ_FIX_LINK_PATHS='-Wl,-executable_path,$(LIBXUL_DIST)/bin'
     ;;
 
 *-linux*|*-kfreebsd*-gnu)
     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
     HOST_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
     ;;
 
@@ -1911,16 +1910,17 @@ case "$target" in
             AC_MSG_RESULT([yes])
             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
         else
             AC_MSG_RESULT([no])
         fi