Merge last PGO-green changeset of mozilla-inbound to mozilla-central
authorEd Morley <bmo@edmorley.co.uk>
Tue, 07 Feb 2012 20:55:09 +0000
changeset 86341 02e4c23ae67d78700f7a625598f84f3d297a72ac
parent 86313 e0d9c8ddd5bd31cfc5481d47945ffe6e62009704 (current diff)
parent 86340 997e5fc795748cd7595263b9d1bd169c7821874b (diff)
child 86342 ede0d3cd7e3a45d7bdc24acd90d3a1a0ae08bdef
child 86373 9fd87a976096ec66734badd53d8ae7620e0406e2
push id22011
push userbmo@edmorley.co.uk
push dateTue, 07 Feb 2012 20:55:38 +0000
treeherdermozilla-central@02e4c23ae67d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge last PGO-green changeset of mozilla-inbound to mozilla-central
accessible/public/nsIAccessNode.idl
browser/themes/gnomestripe/jar.mn
browser/themes/pinstripe/jar.mn
browser/themes/winstripe/jar.mn
toolkit/themes/pinstripe/global/icons/commandline.png
toolkit/themes/winstripe/global/icons/commandline.png
--- a/accessible/public/Makefile.in
+++ b/accessible/public/Makefile.in
@@ -56,17 +56,16 @@ XPIDLSRCS = \
       nsIAccessible.idl \
       nsIAccessibleApplication.idl \
       nsIAccessibleRelation.idl \
       nsIAccessibleRole.idl \
       nsIAccessibleStates.idl \
       nsIAccessibleDocument.idl \
       nsIAccessibleProvider.idl \
       nsIAccessibleSelectable.idl \
-      nsIAccessNode.idl \
       nsIAccessibleCursorable.idl \
       nsIAccessibleEvent.idl \
       nsIAccessibleEditableText.idl \
       nsIAccessibleHyperLink.idl \
       nsIAccessibleHyperText.idl \
       nsIAccessiblePivot.idl \
       nsIAccessibleTable.idl \
       nsIAccessibleText.idl \
--- a/accessible/public/msaa/ISimpleDOMNode.idl
+++ b/accessible/public/msaa/ISimpleDOMNode.idl
@@ -112,17 +112,17 @@ cpp_quote("// DOM navigation - get a dif
 cpp_quote("//")
 cpp_quote("// get_innerHTML(/* [out] */ BSTR *htmlText);")
 cpp_quote("// ---------------------------------------------------------------------------------------------------=")
 cpp_quote("// Returns HTML of this DOM node's subtree. Does not include the start and end tag for this node/element.")
 cpp_quote("//")
 cpp_quote("//")
 cpp_quote("// get_localInterface(/* [out] */ void **localInterface);")
 cpp_quote("// ---------------------------------------------------------------------------------------------------=")
-cpp_quote("// Only available in Gecko's process - casts to an XPCOM nsIAccessNode interface pointer")
+cpp_quote("// Only available in Gecko's process - casts to an XPCOM nsAccessNode object pointer")
 cpp_quote("//")
 cpp_quote("//")
 cpp_quote("// get_language(/* [out] */ BSTR *htmlText);")
 cpp_quote("// ---------------------------------------------------------------------------------------------------=")
 cpp_quote("// Returns the computed language for this node, or empty string if unknown.")
 cpp_quote("//")
 cpp_quote("//")
 cpp_quote("///////////////////////////////////////////////////////////////////////////////////////////////////////")
deleted file mode 100644
--- a/accessible/public/nsIAccessNode.idl
+++ /dev/null
@@ -1,126 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2003
- * the Initial Developer. All Rights Reserved.
- *
- * Original Author: Aaron Leventhal (aaronl@netscape.com)
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsISupports.idl"
-
-interface nsIDOMNode;
-interface nsIAccessibleDocument;
-interface nsIDOMCSSPrimitiveValue;
-
-/**
- * An interface used by in-process accessibility clients
- * to get style, window, markup and other information about
- * a DOM node. When accessibility is active in Gecko,
- * every DOM node can have one nsIAccessNode for each
- * pres shell the DOM node is rendered in.
- * The nsIAccessNode implementations are instantiated lazily.
- * The nsIAccessNode tree for a given dom window
- * has a one to one relationship to the DOM tree.
- * If the DOM node for this access node is "accessible",
- * then a QueryInterface to nsIAccessible will succeed.
- */
-[scriptable, uuid(08bb2c50-1b30-11e1-bddb-0800200c9a66)]
-interface nsIAccessNode : nsISupports
-{
-  /**
-   * The DOM node this nsIAccessNode is associated with.
-   */
-  readonly attribute nsIDOMNode DOMNode;
-
-  /**
-   * The document accessible that this access node resides in.
-   */
-  readonly attribute nsIAccessibleDocument document;
-
-  /**
-   * The root document accessible that this access node resides in.
-   */
-  readonly attribute nsIAccessibleDocument rootDocument;
-
-  /**
-   * The innerHTML for the DOM node
-   * This is a text string of all the markup inside the DOM
-   * node, not including the start and end tag for the node.
-   */
-  readonly attribute DOMString innerHTML;
-
-  /**
-   * Makes an object visible on screen.
-   *
-   * @param scrollType - defines where the object should be placed on
-   *                     the screen (see nsIAccessibleScrollType for
-   *                     available constants).
-   */
-  void scrollTo(in unsigned long aScrollType);
-
-  /**
-   * Moves the top left of an object to a specified location.
-   *
-   * @param coordinateType - specifies whether the coordinates are relative to
-   *                         the screen or the parent object (for available
-   *                         constants refer to nsIAccessibleCoordinateType)
-   * @param aX - defines the x coordinate
-   * @param aY - defines the y coordinate
-  */
-  void scrollToPoint(in unsigned long aCoordinateType, in long aX, in long aY);
-
-  /**
-   * Retrieve the computed style value for this DOM node, if it is a DOM element.
-   * Note: the meanings of width, height and other size measurements depend
-   * on the version of CSS being used. Therefore, for bounds information, 
-   * it is better to use nsIAccessible::accGetBounds.
-   * @param pseudoElt The pseudo element to retrieve style for, or NULL
-   *                  for general computed style information for this node.
-   * @param propertyName Retrieve the computed style value for this property name,
-   *                     for example "border-bottom".
-   */
-  DOMString getComputedStyleValue(in DOMString pseudoElt, in DOMString propertyName);
-
-  /**
-   * The method is similar to getComputedStyleValue() excepting that this one
-   * returns nsIDOMCSSPrimitiveValue.
-   */
-  nsIDOMCSSPrimitiveValue getComputedStyleCSSValue(in DOMString pseudoElt,
-                                                   in DOMString propertyName);
-
-  /**
-   * The language for the current DOM node, e.g. en, de, etc.
-   */
-  readonly attribute DOMString language;
-};
-
--- a/accessible/public/nsIAccessible.idl
+++ b/accessible/public/nsIAccessible.idl
@@ -38,17 +38,20 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsISupports.idl"
 #include "nsIArray.idl"
 
 interface nsIPersistentProperties;
+interface nsIDOMCSSPrimitiveValue;
 interface nsIDOMDOMStringList;
+interface nsIDOMNode;
+interface nsIAccessibleDocument;
 interface nsIAccessibleRelation;
 
 /**
  * A cross-platform interface that supports platform-specific 
  * accessibility APIs like MSAA and ATK. Contains the sum of what's needed
  * to support IAccessible as well as ATK's generic accessibility objects.
  * Can also be used by in-process accessibility clients to get information
  * about objects in the accessible tree. The accessible tree is a subset of 
@@ -96,16 +99,63 @@ interface nsIAccessible : nsISupports
 
   /**
    * The 0-based index of this accessible in its parent's list of children,
    * or -1 if this accessible does not have a parent.
    */
   readonly attribute long indexInParent;
 
   /**
+   * The innerHTML for the HTML element associated with this accessible if applicable.
+   * This is a text string of all the markup inside the DOM
+   * node, not including the start and end tag for the node.
+   */
+  readonly attribute DOMString innerHTML;
+
+  /**
+   * Retrieve the computed style value for this DOM node, if it is a DOM element.
+   * Note: the meanings of width, height and other size measurements depend
+   * on the version of CSS being used. Therefore, for bounds information, 
+   * it is better to use nsIAccessible::accGetBounds.
+   *
+   * @param pseudoElt [in] The pseudo element to retrieve style for, or NULL
+   *                  for general computed style information for this node.
+   * @param propertyName [in] Retrieve the computed style value for this property name,
+   *                     for example "border-bottom".
+   */
+  DOMString getComputedStyleValue(in DOMString pseudoElt, in DOMString propertyName);
+
+  /**
+   * The method is similar to getComputedStyleValue() excepting that this one
+   * returns nsIDOMCSSPrimitiveValue.
+   */
+  nsIDOMCSSPrimitiveValue getComputedStyleCSSValue(in DOMString pseudoElt,
+                                                   in DOMString propertyName);
+
+  /**
+   * The DOM node this nsIAccessible is associated with.
+   */
+  readonly attribute nsIDOMNode DOMNode;
+
+  /**
+   * The document accessible that this access node resides in.
+   */
+  readonly attribute nsIAccessibleDocument document;
+
+  /**
+   * The root document accessible that this access node resides in.
+   */
+  readonly attribute nsIAccessibleDocument rootDocument;
+
+  /**
+   * The language for the current DOM node, e.g. en, de, etc.
+   */
+  readonly attribute DOMString language;
+
+  /**
    * Accessible name -- the main text equivalent for this node. The name is
    * specified by ARIA or by native markup. Example of ARIA markup is
    * aria-labelledby attribute placed on element of this accessible. Example
    * of native markup is HTML label linked with HTML element of this accessible.
    *
    * Value can be string or null. A null value indicates that AT may attempt to
    * compute the name. Any string value, including the empty string, should be
    * considered author-intentional, and respected.
@@ -281,14 +331,34 @@ interface nsIAccessible : nsISupports
 
   /**
    * Perform the accessible action at the given zero-based index
    * Action number 0 is the default action
    */
   void doAction(in PRUint8 index);   
 
   /**
+   * Makes an object visible on screen.
+   *
+   * @param scrollType - defines where the object should be placed on
+   *                     the screen (see nsIAccessibleScrollType for
+   *                     available constants).
+   */
+  void scrollTo(in unsigned long aScrollType);
+
+  /**
+   * Moves the top left of an object to a specified location.
+   *
+   * @param coordinateType [in] - specifies whether the coordinates are relative to
+   *                         the screen or the parent object (for available
+   *                         constants refer to nsIAccessibleCoordinateType)
+   * @param x [in] - defines the x coordinate
+   * @param y [in] - defines the y coordinate
+  */
+  void scrollToPoint(in unsigned long coordinateType, in long x, in long y);
+
+  /**
    * Get a pointer to accessibility interface for this node, which is specific 
    * to the OS/accessibility toolkit we're running on.
    */
   [noscript] void getNativeInterface(out voidPtr aOutAccessible);
 };
 
--- a/accessible/public/nsIAccessibleDocument.idl
+++ b/accessible/public/nsIAccessibleDocument.idl
@@ -34,31 +34,29 @@
  * 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 "nsISupports.idl"
 
 interface nsIAccessible;
-interface nsIAccessNode;
 interface nsIDOMDocument;
 interface nsIDOMNode;
 interface nsIDOMWindow;
 
 /**
  * An interface for in-process accessibility clients
  * that wish to retrieve information about a document.
  * When accessibility is turned on in Gecko,
  * there is an nsIAccessibleDocument for each document
  * whether it is XUL, HTML or whatever.
- * 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 
+ * You can QueryInterface to nsIAccessibleDocument from the nsIAccessible for
+ * the root node of a document. You can also get one from 
+ * nsIAccessible::GetAccessibleDocument() or 
  * nsIAccessibleEvent::GetAccessibleDocument()
  */
 [scriptable, uuid(451242bd-8a0c-4198-ae88-c053609a4e5d)]
 interface nsIAccessibleDocument : nsISupports
 {
   /**
    * The URL of the document
    */
--- a/accessible/public/nsIAccessibleRetrieval.idl
+++ b/accessible/public/nsIAccessibleRetrieval.idl
@@ -38,25 +38,22 @@
 
 #include "nsISupports.idl"
 
 interface nsIDOMNode;
 interface nsIAccessible;
 interface nsIWeakReference;
 interface nsIPresShell;
 interface nsIDOMWindow;
-interface nsIAccessNode;
 interface nsIDOMDOMStringList;
 interface nsIAccessiblePivot;
 
 /**
- * An interface for in-process accessibility clients
- * wishing to get an nsIAccessible or nsIAccessNode for
- * a given DOM node.
- * More documentation at:
+ * An interface for in-process accessibility clients wishing to get an
+ * nsIAccessible for a given DOM node.  More documentation at:
  *   http://www.mozilla.org/projects/ui/accessibility
  */
 [scriptable, uuid(310ce77d-c92b-4761-82e8-77e1a728e8d4)]
 interface nsIAccessibleRetrieval : nsISupports
 {
   /**
    * Return application accessible.
    */
--- a/accessible/src/atk/nsMaiInterfaceDocument.cpp
+++ b/accessible/src/atk/nsMaiInterfaceDocument.cpp
@@ -74,17 +74,17 @@ documentInterfaceInitCB(AtkDocumentIface
 const gchar *
 getDocumentLocaleCB(AtkDocument *aDocument)
 {
   nsAccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
   if (!accWrap)
     return nsnull;
 
   nsAutoString locale;
-  accWrap->GetLanguage(locale);
+  accWrap->Language(locale);
   return locale.IsEmpty() ? nsnull : nsAccessibleWrap::ReturnString(locale);
 }
 
 static inline GSList *
 prependToList(GSList *aList, const char *const aName, const nsAutoString &aValue)
 {
   if (aValue.IsEmpty())
     return aList;
--- a/accessible/src/base/nsAccUtils.h
+++ b/accessible/src/base/nsAccUtils.h
@@ -35,17 +35,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsAccUtils_h_
 #define nsAccUtils_h_
 
 #include "nsIAccessible.h"
-#include "nsIAccessNode.h"
 #include "nsIAccessibleRole.h"
 #include "nsIAccessibleText.h"
 #include "nsIAccessibleTable.h"
 
 #include "nsARIAMap.h"
 #include "nsAccessibilityService.h"
 #include "nsCoreUtils.h"
 
--- a/accessible/src/base/nsAccessNode.cpp
+++ b/accessible/src/base/nsAccessNode.cpp
@@ -31,47 +31,37 @@
  * 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 "nsDocAccessible.h"
+#include "nsAccessNode.h"
 
-#include "nsIAccessible.h"
-
-#include "nsAccCache.h"
+#include "nsAccessibilityService.h"
 #include "nsAccUtils.h"
+#include "nsApplicationAccessibleWrap.h"
 #include "nsCoreUtils.h"
+#include "nsRootAccessible.h"
 
-#include "nsHashtable.h"
-#include "nsAccessibilityService.h"
-#include "nsApplicationAccessibleWrap.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
-#include "nsIDocument.h"
-#include "nsIDOMCSSPrimitiveValue.h"
-#include "nsIDOMDocument.h"
-#include "nsIDOMElement.h"
-#include "nsIDOMHTMLElement.h"
 #include "nsIDOMWindow.h"
-#include "nsPIDOMWindow.h"
+#include "nsIFrame.h"
 #include "nsIInterfaceRequestorUtils.h"
-#include "nsIFrame.h"
+#include "nsIObserverService.h"
+#include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
-#include "nsIPrefBranch.h"
-#include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsIServiceManager.h"
 #include "nsIStringBundle.h"
-#include "nsRootAccessible.h"
 #include "nsFocusManager.h"
-#include "nsIObserverService.h"
+#include "nsPresContext.h"
 #include "mozilla/Services.h"
 
 /* For documentation of the accessibility architecture, 
  * see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
  */
 
 nsIStringBundle *nsAccessNode::gStringBundle = 0;
 
@@ -84,19 +74,17 @@ nsApplicationAccessible *nsAccessNode::g
  */
  
 ////////////////////////////////////////////////////////////////////////////////
 // nsAccessible. nsISupports
 
 NS_IMPL_CYCLE_COLLECTION_1(nsAccessNode, mContent)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsAccessNode)
-  NS_INTERFACE_MAP_ENTRY(nsIAccessNode)
   NS_INTERFACE_MAP_ENTRY(nsAccessNode)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAccessNode)
 NS_INTERFACE_MAP_END
  
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsAccessNode)
 NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_DESTROY(nsAccessNode, LastRelease())
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsAccessNode construction/desctruction
 
@@ -282,136 +270,38 @@ nsAccessNode::GetFrame() const
 
 bool
 nsAccessNode::IsPrimaryForNode() const
 {
   return true;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-// nsIAccessNode
-
-NS_IMETHODIMP
-nsAccessNode::GetDOMNode(nsIDOMNode **aDOMNode)
-{
-  NS_ENSURE_ARG_POINTER(aDOMNode);
-  *aDOMNode = nsnull;
-
-  nsINode *node = GetNode();
-  if (node)
-    CallQueryInterface(node, aDOMNode);
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsAccessNode::GetDocument(nsIAccessibleDocument **aDocument)
-{
-  NS_ENSURE_ARG_POINTER(aDocument);
-
-  NS_IF_ADDREF(*aDocument = GetDocAccessible());
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsAccessNode::GetRootDocument(nsIAccessibleDocument **aRootDocument)
-{
-  NS_ENSURE_ARG_POINTER(aRootDocument);
-
-  nsRootAccessible* rootDocument = RootAccessible();
-  NS_IF_ADDREF(*aRootDocument = rootDocument);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsAccessNode::GetInnerHTML(nsAString& aInnerHTML)
-{
-  aInnerHTML.Truncate();
-
-  nsCOMPtr<nsIDOMHTMLElement> htmlElement = do_QueryInterface(mContent);
-  NS_ENSURE_TRUE(htmlElement, NS_ERROR_NULL_POINTER);
-
-  return htmlElement->GetInnerHTML(aInnerHTML);
-}
-
-NS_IMETHODIMP
+void
 nsAccessNode::ScrollTo(PRUint32 aScrollType)
 {
   if (IsDefunct())
-    return NS_ERROR_FAILURE;
+    return;
 
   nsCOMPtr<nsIPresShell> shell(GetPresShell());
-  NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE);
+  if (!shell)
+    return;
 
   nsIFrame *frame = GetFrame();
-  NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
+  if (!frame)
+    return;
 
-  nsCOMPtr<nsIContent> content = frame->GetContent();
-  NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
+  nsIContent* content = frame->GetContent();
+  if (!content)
+    return;
 
   PRInt16 vPercent, hPercent;
   nsCoreUtils::ConvertScrollTypeToPercents(aScrollType, &vPercent, &hPercent);
-  return shell->ScrollContentIntoView(content, vPercent, hPercent,
-                                      nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
-}
-
-NS_IMETHODIMP
-nsAccessNode::ScrollToPoint(PRUint32 aCoordinateType, PRInt32 aX, PRInt32 aY)
-{
-  nsIFrame *frame = GetFrame();
-  if (!frame)
-    return NS_ERROR_FAILURE;
-
-  nsIntPoint coords;
-  nsresult rv = nsAccUtils::ConvertToScreenCoords(aX, aY, aCoordinateType,
-                                                  this, &coords);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsIFrame *parentFrame = frame;
-  while ((parentFrame = parentFrame->GetParent()))
-    nsCoreUtils::ScrollFrameToPoint(parentFrame, frame, coords);
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsAccessNode::GetComputedStyleValue(const nsAString& aPseudoElt,
-                                    const nsAString& aPropertyName,
-                                    nsAString& aValue)
-{
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl =
-    nsCoreUtils::GetComputedStyleDeclaration(aPseudoElt, mContent);
-  NS_ENSURE_TRUE(styleDecl, NS_ERROR_FAILURE);
-
-  return styleDecl->GetPropertyValue(aPropertyName, aValue);
-}
-
-NS_IMETHODIMP
-nsAccessNode::GetComputedStyleCSSValue(const nsAString& aPseudoElt,
-                                       const nsAString& aPropertyName,
-                                       nsIDOMCSSPrimitiveValue **aCSSValue)
-{
-  NS_ENSURE_ARG_POINTER(aCSSValue);
-  *aCSSValue = nsnull;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl =
-    nsCoreUtils::GetComputedStyleDeclaration(aPseudoElt, mContent);
-  NS_ENSURE_STATE(styleDecl);
-
-  nsCOMPtr<nsIDOMCSSValue> cssValue;
-  styleDecl->GetPropertyCSSValue(aPropertyName, getter_AddRefs(cssValue));
-  NS_ENSURE_TRUE(cssValue, NS_ERROR_FAILURE);
-
-  return CallQueryInterface(cssValue, aCSSValue);
+  shell->ScrollContentIntoView(content, vPercent, hPercent,
+                               nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
 }
 
 // nsAccessNode public
 already_AddRefed<nsINode>
 nsAccessNode::GetCurrentFocus()
 {
   // XXX: consider to use nsFocusManager directly, it allows us to avoid
   // unnecessary query interface calls.
@@ -438,25 +328,23 @@ nsAccessNode::GetCurrentFocus()
     focusedWindow->GetDocument(getter_AddRefs(doc));
     if (doc)
       CallQueryInterface(doc, &focusedNode);
   }
 
   return focusedNode;
 }
 
-NS_IMETHODIMP
-nsAccessNode::GetLanguage(nsAString& aLanguage)
+void
+nsAccessNode::Language(nsAString& aLanguage)
 {
   aLanguage.Truncate();
 
   if (IsDefunct())
-    return NS_ERROR_FAILURE;
+    return;
 
   nsCoreUtils::GetLanguageFor(mContent, nsnull, aLanguage);
-
   if (aLanguage.IsEmpty()) { // Nothing found, so use document's language
     mContent->OwnerDoc()->GetHeaderData(nsGkAtoms::headerContentLanguage,
                                         aLanguage);
   }
- 
-  return NS_OK;
 }
+
--- a/accessible/src/base/nsAccessNode.h
+++ b/accessible/src/base/nsAccessNode.h
@@ -38,17 +38,16 @@
 
 /* For documentation of the accessibility architecture, 
  * see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
  */
 
 #ifndef _nsAccessNode_H_
 #define _nsAccessNode_H_
 
-#include "nsIAccessNode.h"
 #include "nsIAccessibleTypes.h"
 
 #include "a11yGeneric.h"
 
 #include "nsIContent.h"
 #include "nsIDOMNode.h"
 #include "nsINameSpaceManager.h"
 #include "nsIStringBundle.h"
@@ -63,36 +62,25 @@ class nsRootAccessible;
 class nsIPresShell;
 class nsPresContext;
 class nsIFrame;
 class nsIDocShellTreeItem;
 
 #define ACCESSIBLE_BUNDLE_URL "chrome://global-platform/locale/accessible.properties"
 #define PLATFORM_KEYS_BUNDLE_URL "chrome://global-platform/locale/platformKeys.properties"
 
-#define NS_ACCESSNODE_IMPL_CID                          \
-{  /* 2b07e3d7-00b3-4379-aa0b-ea22e2c8ffda */           \
-  0x2b07e3d7,                                           \
-  0x00b3,                                               \
-  0x4379,                                               \
-  { 0xaa, 0x0b, 0xea, 0x22, 0xe2, 0xc8, 0xff, 0xda }    \
-}
-
-class nsAccessNode: public nsIAccessNode
+class nsAccessNode: public nsISupports
 {
 public:
 
   nsAccessNode(nsIContent *aContent, nsIWeakReference *aShell);
   virtual ~nsAccessNode();
 
     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-    NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsAccessNode, nsIAccessNode)
-
-    NS_DECL_NSIACCESSNODE
-    NS_DECLARE_STATIC_IID_ACCESSOR(NS_ACCESSNODE_IMPL_CID)
+    NS_DECL_CYCLE_COLLECTION_CLASS(nsAccessNode)
 
     static void InitXPAccessibility();
     static void ShutdownXPAccessibility();
 
   /**
    * Return an application accessible.
    */
   static nsApplicationAccessible* GetApplicationAccessible();
@@ -129,28 +117,16 @@ public:
    * Returns true when the accessible is defunct.
    */
   virtual bool IsDefunct() const;
 
   /**
    * Return frame for the given access node object.
    */
   virtual nsIFrame* GetFrame() const;
-
-  /**
-   * Return DOM node associated with this accessible.
-   */
-  already_AddRefed<nsIDOMNode> GetDOMNode() const
-  {
-    nsIDOMNode *DOMNode = nsnull;
-    if (GetNode())
-      CallQueryInterface(GetNode(), &DOMNode);
-    return DOMNode;
-  }
-
   /**
    * Return DOM node associated with the accessible.
    */
   virtual nsINode* GetNode() const { return mContent; }
   nsIContent* GetContent() const { return mContent; }
   virtual nsIDocument* GetDocumentNode() const
     { return mContent ? mContent->OwnerDoc() : nsnull; }
 
@@ -190,16 +166,28 @@ public:
    * Return true if the accessible is primary accessible for the given DOM node.
    *
    * Accessible hierarchy may be complex for single DOM node, in this case
    * these accessibles share the same DOM node. The primary accessible "owns"
    * that DOM node in terms it gets stored in the accessible to node map.
    */
   virtual bool IsPrimaryForNode() const;
 
+  /**
+   * Return the string bundle
+   */
+  static nsIStringBundle* GetStringBundle()
+    { return gStringBundle; }
+
+  /**
+   * Interface methods on nsIAccessible shared with ISimpleDOM.
+   */
+  void Language(nsAString& aLocale);
+  void ScrollTo(PRUint32 aType);
+
 protected:
     nsPresContext* GetPresContext();
 
     void LastRelease();
 
   nsCOMPtr<nsIContent> mContent;
   nsCOMPtr<nsIWeakReference> mWeakShell;
 
@@ -216,13 +204,10 @@ protected:
 private:
   nsAccessNode();
   nsAccessNode(const nsAccessNode&);
   nsAccessNode& operator =(const nsAccessNode&);
   
   static nsApplicationAccessible *gApplicationAccessible;
 };
 
-NS_DEFINE_STATIC_IID_ACCESSOR(nsAccessNode,
-                              NS_ACCESSNODE_IMPL_CID)
-
 #endif
 
--- a/accessible/src/base/nsAccessible.cpp
+++ b/accessible/src/base/nsAccessible.cpp
@@ -47,21 +47,24 @@
 #include "nsDocAccessible.h"
 #include "nsEventShell.h"
 
 #include "nsAccEvent.h"
 #include "nsAccessibleRelation.h"
 #include "nsAccessibilityService.h"
 #include "nsAccTreeWalker.h"
 #include "nsIAccessibleRelation.h"
+#include "nsRootAccessible.h"
 #include "nsTextEquivUtils.h"
 #include "Relation.h"
 #include "Role.h"
 #include "States.h"
 
+#include "nsIDOMCSSValue.h"
+#include "nsIDOMCSSPrimitiveValue.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMDocumentXBL.h"
 #include "nsIDOMHTMLDocument.h"
 #include "nsIDOMHTMLFormElement.h"
 #include "nsIDOMNodeFilter.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsIDOMTreeWalker.h"
@@ -225,16 +228,102 @@ nsAccessible::~nsAccessible()
 
 void
 nsAccessible::SetRoleMapEntry(nsRoleMapEntry* aRoleMapEntry)
 {
   mRoleMapEntry = aRoleMapEntry;
 }
 
 NS_IMETHODIMP
+nsAccessible::GetComputedStyleValue(const nsAString& aPseudoElt,
+                                    const nsAString& aPropertyName,
+                                    nsAString& aValue)
+{
+  if (IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl =
+    nsCoreUtils::GetComputedStyleDeclaration(aPseudoElt, mContent);
+  NS_ENSURE_TRUE(styleDecl, NS_ERROR_FAILURE);
+
+  return styleDecl->GetPropertyValue(aPropertyName, aValue);
+}
+
+NS_IMETHODIMP
+nsAccessible::GetComputedStyleCSSValue(const nsAString& aPseudoElt,
+                                       const nsAString& aPropertyName,
+                                       nsIDOMCSSPrimitiveValue **aCSSValue) {
+  NS_ENSURE_ARG_POINTER(aCSSValue);
+  *aCSSValue = nsnull;
+
+  if (IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl =
+    nsCoreUtils::GetComputedStyleDeclaration(aPseudoElt, mContent);
+  NS_ENSURE_STATE(styleDecl);
+
+  nsCOMPtr<nsIDOMCSSValue> cssValue;
+  styleDecl->GetPropertyCSSValue(aPropertyName, getter_AddRefs(cssValue));
+  NS_ENSURE_TRUE(cssValue, NS_ERROR_FAILURE);
+
+  return CallQueryInterface(cssValue, aCSSValue);
+}
+
+NS_IMETHODIMP
+nsAccessible::GetDocument(nsIAccessibleDocument **aDocument)
+{
+  NS_ENSURE_ARG_POINTER(aDocument);
+
+  NS_IF_ADDREF(*aDocument = GetDocAccessible());
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsAccessible::GetDOMNode(nsIDOMNode **aDOMNode)
+{
+  NS_ENSURE_ARG_POINTER(aDOMNode);
+  *aDOMNode = nsnull;
+
+  nsINode *node = GetNode();
+  if (node)
+    CallQueryInterface(node, aDOMNode);
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsAccessible::GetRootDocument(nsIAccessibleDocument **aRootDocument)
+{
+  NS_ENSURE_ARG_POINTER(aRootDocument);
+
+  nsRootAccessible* rootDocument = RootAccessible();
+  NS_IF_ADDREF(*aRootDocument = rootDocument);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsAccessible::GetInnerHTML(nsAString& aInnerHTML)
+{
+  aInnerHTML.Truncate();
+
+  nsCOMPtr<nsIDOMHTMLElement> htmlElement = do_QueryInterface(mContent);
+  NS_ENSURE_TRUE(htmlElement, NS_ERROR_NULL_POINTER);
+
+  return htmlElement->GetInnerHTML(aInnerHTML);
+}
+
+NS_IMETHODIMP
+nsAccessible::GetLanguage(nsAString& aLanguage)
+{
+  Language(aLanguage);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 nsAccessible::GetName(nsAString& aName)
 {
   aName.Truncate();
 
   if (IsDefunct())
     return NS_ERROR_FAILURE;
 
   GetARIAName(aName);
@@ -2195,16 +2284,42 @@ nsAccessible::DispatchClickEvent(nsICont
   bool res = nsCoreUtils::DispatchMouseEvent(NS_MOUSE_BUTTON_DOWN, presShell,
                                                aContent);
   if (!res)
     return;
 
   nsCoreUtils::DispatchMouseEvent(NS_MOUSE_BUTTON_UP, presShell, aContent);
 }
 
+NS_IMETHODIMP
+nsAccessible::ScrollTo(PRUint32 aHow)
+{
+  nsAccessNode::ScrollTo(aHow);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsAccessible::ScrollToPoint(PRUint32 aCoordinateType, PRInt32 aX, PRInt32 aY)
+{
+  nsIFrame *frame = GetFrame();
+  if (!frame)
+    return NS_ERROR_FAILURE;
+
+  nsIntPoint coords;
+  nsresult rv = nsAccUtils::ConvertToScreenCoords(aX, aY, aCoordinateType,
+                                                  this, &coords);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  nsIFrame *parentFrame = frame;
+  while ((parentFrame = parentFrame->GetParent()))
+    nsCoreUtils::ScrollFrameToPoint(parentFrame, frame, coords);
+
+  return NS_OK;
+}
+
 // nsIAccessibleSelectable
 NS_IMETHODIMP nsAccessible::GetSelectedChildren(nsIArray **aSelectedAccessibles)
 {
   NS_ENSURE_ARG_POINTER(aSelectedAccessibles);
   *aSelectedAccessibles = nsnull;
 
   if (IsDefunct() || !IsSelect())
     return NS_ERROR_FAILURE;
--- a/accessible/src/base/nsAccessible.h
+++ b/accessible/src/base/nsAccessible.h
@@ -125,16 +125,27 @@ public:
   // Public methods
 
   /**
    * get the description of this accessible
    */
   virtual void Description(nsString& aDescription);
 
   /**
+   * Return DOM node associated with this accessible.
+   */
+  inline already_AddRefed<nsIDOMNode> DOMNode() const
+  {
+    nsIDOMNode *DOMNode = nsnull;
+    if (GetNode())
+      CallQueryInterface(GetNode(), &DOMNode);
+    return DOMNode;
+  }
+
+  /**
    * Returns the accessible name specified by ARIA.
    */
   nsresult GetARIAName(nsAString& aName);
 
   /**
    * Maps ARIA state attributes to state of accessible. Note the given state
    * argument should hold states for accessible before you pass it into this
    * method.
--- a/accessible/src/base/nsApplicationAccessible.cpp
+++ b/accessible/src/base/nsApplicationAccessible.cpp
@@ -416,17 +416,17 @@ nsApplicationAccessible::GetSiblingAtOff
 {
   if (aError)
     *aError = NS_OK; // fail peacefully
 
   return nsnull;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-// nsIAccessNode and nsAccessNode
+// nsIAccessible
 
 NS_IMETHODIMP
 nsApplicationAccessible::GetDOMNode(nsIDOMNode **aDOMNode)
 {
   NS_ENSURE_ARG_POINTER(aDOMNode);
   *aDOMNode = nsnull;
   return NS_OK;
 }
--- a/accessible/src/base/nsApplicationAccessible.h
+++ b/accessible/src/base/nsApplicationAccessible.h
@@ -64,32 +64,30 @@ class nsApplicationAccessible: public ns
 {
 public:
 
   nsApplicationAccessible();
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
-  // nsIAccessNode
+  // nsIAccessible
   NS_SCRIPTABLE NS_IMETHOD GetDOMNode(nsIDOMNode** aDOMNode);
   NS_SCRIPTABLE NS_IMETHOD GetDocument(nsIAccessibleDocument** aDocument);
   NS_SCRIPTABLE NS_IMETHOD GetRootDocument(nsIAccessibleDocument** aRootDocument);
   NS_SCRIPTABLE NS_IMETHOD GetInnerHTML(nsAString& aInnerHTML);
   NS_SCRIPTABLE NS_IMETHOD ScrollTo(PRUint32 aScrollType);
   NS_SCRIPTABLE NS_IMETHOD ScrollToPoint(PRUint32 aCoordinateType, PRInt32 aX, PRInt32 aY);
   NS_SCRIPTABLE NS_IMETHOD GetComputedStyleValue(const nsAString& aPseudoElt,
                                                  const nsAString& aPropertyName,
                                                  nsAString& aValue NS_OUTPARAM);
   NS_SCRIPTABLE NS_IMETHOD GetComputedStyleCSSValue(const nsAString& aPseudoElt,
                                                     const nsAString& aPropertyName,
                                                     nsIDOMCSSPrimitiveValue** aValue NS_OUTPARAM);
   NS_SCRIPTABLE NS_IMETHOD GetLanguage(nsAString& aLanguage);
-
-  // nsIAccessible
   NS_IMETHOD GetParent(nsIAccessible **aParent);
   NS_IMETHOD GetNextSibling(nsIAccessible **aNextSibling);
   NS_IMETHOD GetPreviousSibling(nsIAccessible **aPreviousSibling);
   NS_IMETHOD GetName(nsAString &aName);
   NS_IMETHOD GetValue(nsAString &aValue);
   NS_IMETHOD GetAttributes(nsIPersistentProperties **aAttributes);
   NS_IMETHOD GroupPosition(PRInt32 *aGroupLevel, PRInt32 *aSimilarItemsInGroup,
                            PRInt32 *aPositionInGroup);
--- a/accessible/src/base/nsCoreUtils.h
+++ b/accessible/src/base/nsCoreUtils.h
@@ -186,17 +186,17 @@ public:
    */
   static nsresult ScrollSubstringTo(nsIFrame *aFrame,
                                     nsIDOMNode *aStartNode, PRInt32 aStartIndex,
                                     nsIDOMNode *aEndNode, PRInt32 aEndIndex,
                                     PRInt16 aVPercent, PRInt16 aHPercent);
 
   /**
    * Scrolls the given frame to the point, used for implememntation of
-   * nsIAccessNode::scrollToPoint and nsIAccessibleText::scrollSubstringToPoint.
+   * nsIAccessible::scrollToPoint and nsIAccessibleText::scrollSubstringToPoint.
    *
    * @param aScrollableFrame  the scrollable frame
    * @param aFrame            the frame to scroll
    * @param aPoint            the point scroll to
    */
   static void ScrollFrameToPoint(nsIFrame *aScrollableFrame,
                                  nsIFrame *aFrame, const nsIntPoint& aPoint);
 
--- a/accessible/src/base/nsTextAttrs.cpp
+++ b/accessible/src/base/nsTextAttrs.cpp
@@ -278,18 +278,18 @@ nsTextAttrsMgr::GetRange(const nsTArray<
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsLangTextAttr
 
 nsLangTextAttr::nsLangTextAttr(nsHyperTextAccessible *aRootAcc, 
                                nsIContent *aRootContent, nsIContent *aContent) :
   nsTextAttr<nsAutoString>(aContent == nsnull), mRootContent(aRootContent)
 {
-  nsresult rv = aRootAcc->GetLanguage(mRootNativeValue);
-  mIsRootDefined = NS_SUCCEEDED(rv) && !mRootNativeValue.IsEmpty();
+  aRootAcc->Language(mRootNativeValue);
+  mIsRootDefined =  !mRootNativeValue.IsEmpty();
 
   if (aContent)
     mIsDefined = GetLang(aContent, mNativeValue);
 }
 
 bool
 nsLangTextAttr::GetValueFor(nsIContent *aElm, nsAutoString *aValue)
 {
--- a/accessible/src/html/nsHyperTextAccessible.cpp
+++ b/accessible/src/html/nsHyperTextAccessible.cpp
@@ -1143,17 +1143,17 @@ nsHyperTextAccessible::GetTextAttributes
                               accAtOffsetIdx);
   nsresult rv = textAttrsMgr.GetAttributes(*aAttributes, &startOffset,
                                            &endOffset);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Compute spelling attributes on text accessible only.
   nsIFrame *offsetFrame = accAtOffset->GetFrame();
   if (offsetFrame && offsetFrame->GetType() == nsGkAtoms::textFrame) {
-    nsCOMPtr<nsIDOMNode> node = accAtOffset->GetDOMNode();
+    nsCOMPtr<nsIDOMNode> node = accAtOffset->DOMNode();
 
     PRInt32 nodeOffset = 0;
     nsresult rv = RenderedToContentOffset(offsetFrame, offsetInAcc,
                                           &nodeOffset);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Set 'misspelled' text attribute.
     rv = GetSpellTextAttribute(node, nodeOffset, &startOffset, &endOffset,
@@ -2250,20 +2250,18 @@ nsHyperTextAccessible::GetDOMPointByFram
 {
   NS_ENSURE_ARG(aAccessible);
 
   nsCOMPtr<nsIDOMNode> node;
 
   if (!aFrame) {
     // If the given frame is null then set offset after the DOM node of the
     // given accessible.
-    nsCOMPtr<nsIAccessNode> accessNode(do_QueryInterface(aAccessible));
-
     nsCOMPtr<nsIDOMNode> DOMNode;
-    accessNode->GetDOMNode(getter_AddRefs(DOMNode));
+    aAccessible->GetDOMNode(getter_AddRefs(DOMNode));
     nsCOMPtr<nsIContent> content(do_QueryInterface(DOMNode));
     NS_ENSURE_STATE(content);
 
     nsCOMPtr<nsIContent> parent(content->GetParent());
     NS_ENSURE_STATE(parent);
 
     *aNodeOffset = parent->IndexOf(content) + 1;
     node = do_QueryInterface(parent);
--- a/accessible/src/msaa/CAccessibleComponent.cpp
+++ b/accessible/src/msaa/CAccessibleComponent.cpp
@@ -150,17 +150,17 @@ CAccessibleComponent::get_background(IA2
 
 HRESULT
 CAccessibleComponent::GetARGBValueFromCSSProperty(const nsAString& aPropName,
                                                   IA2Color *aColorValue)
 {
 __try {
   *aColorValue = 0;
 
-  nsCOMPtr<nsIAccessNode> acc(do_QueryObject(this));
+  nsRefPtr<nsAccessible> acc(do_QueryObject(this));
   if (!acc)
     return E_FAIL;
 
   nsCOMPtr<nsIDOMCSSPrimitiveValue> cssValue;
   nsresult rv = acc->GetComputedStyleCSSValue(EmptyString(), aPropName,
                                               getter_AddRefs(cssValue));
   if (NS_FAILED(rv) || !cssValue)
     return GetHRESULT(rv);
--- a/accessible/src/msaa/nsAccessNodeWrap.cpp
+++ b/accessible/src/msaa/nsAccessNodeWrap.cpp
@@ -391,19 +391,18 @@ STDMETHODIMP nsAccessNodeWrap::get_compu
 
 STDMETHODIMP nsAccessNodeWrap::scrollTo(/* [in] */ boolean aScrollTopLeft)
 {
 __try {
   PRUint32 scrollType =
     aScrollTopLeft ? nsIAccessibleScrollType::SCROLL_TYPE_TOP_LEFT :
                      nsIAccessibleScrollType::SCROLL_TYPE_BOTTOM_RIGHT;
 
-  nsresult rv = ScrollTo(scrollType);
-  if (NS_SUCCEEDED(rv))
-    return S_OK;
+  ScrollTo(scrollType);
+  return S_OK;
 } __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
 
   return E_FAIL;
 }
 
 ISimpleDOMNode*
 nsAccessNodeWrap::MakeAccessNode(nsINode *aNode)
 {
@@ -549,20 +548,17 @@ nsAccessNodeWrap::get_innerHTML(BSTR __R
 
 STDMETHODIMP 
 nsAccessNodeWrap::get_language(BSTR __RPC_FAR *aLanguage)
 {
 __try {
   *aLanguage = NULL;
 
   nsAutoString language;
-  if (NS_FAILED(GetLanguage(language))) {
-    return E_FAIL;
-  }
-
+  Language(language);
   if (language.IsEmpty())
     return S_FALSE;
 
   *aLanguage = ::SysAllocStringLen(language.get(), language.Length());
   if (!*aLanguage)
     return E_OUTOFMEMORY;
 
 } __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
@@ -570,17 +566,17 @@ nsAccessNodeWrap::get_language(BSTR __RP
   return S_OK;
 }
 
 STDMETHODIMP 
 nsAccessNodeWrap::get_localInterface( 
     /* [out] */ void __RPC_FAR *__RPC_FAR *localInterface)
 {
 __try {
-  *localInterface = static_cast<nsIAccessNode*>(this);
+  *localInterface = static_cast<nsAccessNode*>(this);
   NS_ADDREF_THIS();
 } __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
   return S_OK;
 }
  
 void nsAccessNodeWrap::InitAccessibility()
 {
   Compatibility::Init();
--- a/accessible/src/msaa/nsAccessibleWrap.cpp
+++ b/accessible/src/msaa/nsAccessibleWrap.cpp
@@ -1140,18 +1140,18 @@ nsAccessibleWrap::role(long *aRole)
 } __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
   return E_FAIL;
 }
 
 STDMETHODIMP
 nsAccessibleWrap::scrollTo(enum IA2ScrollType aScrollType)
 {
 __try {
-  nsresult rv = ScrollTo(aScrollType);
-  return GetHRESULT(rv);
+  nsAccessNode::ScrollTo(aScrollType);
+  return S_OK;
 
 } __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
   return E_FAIL;
 }
 
 STDMETHODIMP
 nsAccessibleWrap::scrollToPoint(enum IA2CoordinateType aCoordType,
                                 long aX, long aY)
@@ -1361,19 +1361,17 @@ nsAccessibleWrap::get_locale(IA2Locale *
 {
 __try {
   // Language codes consist of a primary code and a possibly empty series of
   // subcodes: language-code = primary-code ( "-" subcode )*
   // Two-letter primary codes are reserved for [ISO639] language abbreviations.
   // Any two-letter subcode is understood to be a [ISO3166] country code.
 
   nsAutoString lang;
-  nsresult rv = GetLanguage(lang);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
+  Language(lang);
 
   // If primary code consists from two letters then expose it as language.
   PRInt32 offset = lang.FindChar('-', 0);
   if (offset == -1) {
     if (lang.Length() == 2) {
       aLocale->language = ::SysAllocString(lang.get());
       return S_OK;
     }
--- a/accessible/src/xul/nsXULFormControlAccessible.cpp
+++ b/accessible/src/xul/nsXULFormControlAccessible.cpp
@@ -657,27 +657,20 @@ nsXULToolbarButtonAccessible::GetPositio
 
   *aPosInSet = posInSet;
   *aSetSize = setSize;
 }
 
 bool
 nsXULToolbarButtonAccessible::IsSeparator(nsAccessible *aAccessible)
 {
-  nsCOMPtr<nsIDOMNode> domNode;
-  aAccessible->GetDOMNode(getter_AddRefs(domNode));
-  nsCOMPtr<nsIContent> contentDomNode(do_QueryInterface(domNode));
-
-  if (!contentDomNode)
-    return false;
-
-  return (contentDomNode->Tag() == nsGkAtoms::toolbarseparator) ||
-         (contentDomNode->Tag() == nsGkAtoms::toolbarspacer) ||
-         (contentDomNode->Tag() == nsGkAtoms::toolbarspring);
-}
+  nsIContent* content = aAccessible->GetContent();
+  return content && ((content->Tag() == nsGkAtoms::toolbarseparator) ||
+                     (content->Tag() == nsGkAtoms::toolbarspacer) ||
+                     (content->Tag() == nsGkAtoms::toolbarspring)); }
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsXULToolbarAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 nsXULToolbarAccessible::
   nsXULToolbarAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
--- a/accessible/src/xul/nsXULTabAccessible.cpp
+++ b/accessible/src/xul/nsXULTabAccessible.cpp
@@ -148,19 +148,19 @@ nsXULTabAccessible::RelationByType(PRUin
     return rel;
 
   // Expose 'LABEL_FOR' relation on tab accessible for tabpanel accessible.
   nsCOMPtr<nsIDOMXULRelatedElement> tabsElm =
     do_QueryInterface(mContent->GetParent());
   if (!tabsElm)
     return rel;
 
-  nsCOMPtr<nsIDOMNode> DOMNode(GetDOMNode());
+  nsCOMPtr<nsIDOMNode> domNode(DOMNode());
   nsCOMPtr<nsIDOMNode> tabpanelNode;
-  tabsElm->GetRelatedElement(DOMNode, getter_AddRefs(tabpanelNode));
+  tabsElm->GetRelatedElement(domNode, getter_AddRefs(tabpanelNode));
   if (!tabpanelNode)
     return rel;
 
   nsCOMPtr<nsIContent> tabpanelContent(do_QueryInterface(tabpanelNode));
   rel.AppendTarget(tabpanelContent);
   return rel;
 }
 
@@ -250,18 +250,18 @@ nsXULTabpanelAccessible::RelationByType(
     return rel;
 
   // Expose 'LABELLED_BY' relation on tabpanel accessible for tab accessible.
   nsCOMPtr<nsIDOMXULRelatedElement> tabpanelsElm =
     do_QueryInterface(mContent->GetParent());
   if (!tabpanelsElm)
     return rel;
 
-  nsCOMPtr<nsIDOMNode> DOMNode(GetDOMNode());
+  nsCOMPtr<nsIDOMNode> domNode(DOMNode());
   nsCOMPtr<nsIDOMNode> tabNode;
-  tabpanelsElm->GetRelatedElement(DOMNode, getter_AddRefs(tabNode));
+  tabpanelsElm->GetRelatedElement(domNode, getter_AddRefs(tabNode));
   if (!tabNode)
     return rel;
 
   nsCOMPtr<nsIContent> tabContent(do_QueryInterface(tabNode));
   rel.AppendTarget(tabContent);
   return rel;
 }
--- a/accessible/tests/mochitest/common.js
+++ b/accessible/tests/mochitest/common.js
@@ -13,17 +13,16 @@ const nsIAccessibleTextChangeEvent =
 
 const nsIAccessibleStates = Components.interfaces.nsIAccessibleStates;
 const nsIAccessibleRole = Components.interfaces.nsIAccessibleRole;
 const nsIAccessibleScrollType = Components.interfaces.nsIAccessibleScrollType;
 const nsIAccessibleCoordinateType = Components.interfaces.nsIAccessibleCoordinateType;
 
 const nsIAccessibleRelation = Components.interfaces.nsIAccessibleRelation;
 
-const nsIAccessNode = Components.interfaces.nsIAccessNode;
 const nsIAccessible = Components.interfaces.nsIAccessible;
 
 const nsIAccessibleDocument = Components.interfaces.nsIAccessibleDocument;
 const nsIAccessibleApplication = Components.interfaces.nsIAccessibleApplication;
 
 const nsIAccessibleText = Components.interfaces.nsIAccessibleText;
 const nsIAccessibleEditableText = Components.interfaces.nsIAccessibleEditableText;
 
@@ -116,20 +115,18 @@ function addA11yLoadEvent(aFunc, aWindow
 function getNode(aAccOrNodeOrID)
 {
   if (!aAccOrNodeOrID)
     return null;
 
   if (aAccOrNodeOrID instanceof nsIDOMNode)
     return aAccOrNodeOrID;
 
-  if (aAccOrNodeOrID instanceof nsIAccessible) {
-    aAccOrNodeOrID.QueryInterface(nsIAccessNode);
+  if (aAccOrNodeOrID instanceof nsIAccessible)
     return aAccOrNodeOrID.DOMNode;
-  }
 
   node = document.getElementById(aAccOrNodeOrID);
   if (!node) {
     ok(false, "Can't get DOM element for " + aAccOrNodeOrID);
     return null;
   }
 
   return node;
@@ -162,17 +159,16 @@ const DONOTFAIL_IF_NO_INTERFACE = 2;
 function getAccessible(aAccOrElmOrID, aInterfaces, aElmObj, aDoNotFailIf)
 {
   if (!aAccOrElmOrID)
     return null;
 
   var elm = null;
 
   if (aAccOrElmOrID instanceof nsIAccessible) {
-    aAccOrElmOrID.QueryInterface(nsIAccessNode);
     elm = aAccOrElmOrID.DOMNode;
 
   } else if (aAccOrElmOrID instanceof nsIDOMNode) {
     elm = aAccOrElmOrID;
 
   } else {
     elm = document.getElementById(aAccOrElmOrID);
     if (!elm) {
@@ -194,18 +190,16 @@ function getAccessible(aAccOrElmOrID, aI
     if (!acc) {
       if (!(aDoNotFailIf & DONOTFAIL_IF_NO_ACC))
         ok(false, "Can't get accessible for " + aAccOrElmOrID);
 
       return null;
     }
   }
 
-  acc.QueryInterface(nsIAccessNode);
-
   if (!aInterfaces)
     return acc;
 
   if (aInterfaces instanceof Array) {
     for (var index = 0; index < aInterfaces.length; index++) {
       try {
         acc.QueryInterface(aInterfaces[index]);
       } catch (e) {
@@ -252,31 +246,29 @@ function getContainerAccessible(aAccOrEl
   return node ? getAccessible(node) : null;
 }
 
 /**
  * Return root accessible for the given identifier.
  */
 function getRootAccessible(aAccOrElmOrID)
 {
-  var acc = getAccessible(aAccOrElmOrID ? aAccOrElmOrID : document,
-                          [nsIAccessNode]);
+  var acc = getAccessible(aAccOrElmOrID ? aAccOrElmOrID : document);
   return acc ? acc.rootDocument.QueryInterface(nsIAccessible) : null;
 }
 
 /**
  * Return tab document accessible the given accessible is contained by.
  */
 function getTabDocAccessible(aAccOrElmOrID)
 {
-  var acc = getAccessible(aAccOrElmOrID ? aAccOrElmOrID : document,
-                          [nsIAccessNode]);
+  var acc = getAccessible(aAccOrElmOrID ? aAccOrElmOrID : document);
 
   var docAcc = acc.document.QueryInterface(nsIAccessible);
-  var containerDocAcc = docAcc.parent.QueryInterface(nsIAccessNode).document;
+  var containerDocAcc = docAcc.parent.document;
 
   // Test is running is stand-alone mode.
   if (acc.rootDocument == containerDocAcc)
     return docAcc;
 
   // In the case of running all tests together.
   return containerDocAcc.QueryInterface(nsIAccessible);
 }
@@ -579,17 +571,17 @@ function getTextFromClipboard()
 }
 
 /**
  * Return pretty name for identifier, it may be ID, DOM node or accessible.
  */
 function prettyName(aIdentifier)
 {
   if (aIdentifier instanceof nsIAccessible) {
-    var acc = getAccessible(aIdentifier, [nsIAccessNode]);
+    var acc = getAccessible(aIdentifier);
     var msg = "[" + getNodePrettyName(acc.DOMNode);
     try {
       msg += ", role: " + roleToString(acc.role);
       if (acc.name)
         msg += ", name: '" + acc.name + "'";
     } catch (e) {
       msg += "defunct";
     }
--- a/accessible/tests/mochitest/events/test_contextmenu.html
+++ b/accessible/tests/mochitest/events/test_contextmenu.html
@@ -86,17 +86,17 @@
 
     function getFocusedMenuItem()
     {
       var menu = getAccessible(getAccessible(getContextMenuNode()));
       for (var idx = 0; idx < menu.childCount; idx++) {
         var item = menu.getChildAt(idx);
 
         if (hasState(item, STATE_FOCUSED))
-          return getAccessible(item, [nsIAccessNode]);
+          return getAccessible(item);
       }
       return null;
     }
 
     ////////////////////////////////////////////////////////////////////////////
     // Do tests
 
     var gQueue = null;
--- a/accessible/tests/mochitest/hypertext/test_update.html
+++ b/accessible/tests/mochitest/hypertext/test_update.html
@@ -55,17 +55,17 @@
         return "Add links for '" + aContainerID + "'";
       }
     }
 
     function updateText(aContainerID)
     {
       this.containerNode = getNode(aContainerID);
       this.container = getAccessible(this.containerNode, nsIAccessibleHyperText);
-      this.text = this.container.firstChild.QueryInterface(nsIAccessNode);
+      this.text = this.container.firstChild;
       this.textNode = this.text.DOMNode;
       this.textLen = this.textNode.data.length;
 
       this.eventSeq = [
         new invokerChecker(EVENT_TEXT_INSERTED, this.containerNode)
       ];
 
       this.invoke = function updateText_invoke()
--- a/accessible/tests/mochitest/pivot.js
+++ b/accessible/tests/mochitest/pivot.js
@@ -70,17 +70,16 @@ var ObjectTraversalRule =
  */
 function virtualCursorChangedChecker(aDocAcc, aIdOrNameOrAcc, aTextOffsets)
 {
   this.__proto__ = new invokerChecker(EVENT_VIRTUALCURSOR_CHANGED, aDocAcc);
 
   this.check = function virtualCursorChangedChecker_check(aEvent)
   {
     var position = aDocAcc.virtualCursor.position;
-    position.QueryInterface(nsIAccessNode);
 
     var idMatches = position.DOMNode.id == aIdOrNameOrAcc;
     var nameMatches = position.name == aIdOrNameOrAcc;
     var accMatches = position == aIdOrNameOrAcc;
 
     SimpleTest.ok(idMatches || nameMatches || accMatches, "id or name matches",
                   "expecting " + aIdOrNameOrAcc + ", got '" +
                   prettyName(position));
@@ -209,9 +208,9 @@ function dumpTraversalSequence(aPivot, a
 {
   var sequence = []
   if (aPivot.moveFirst(aRule)) {
     do {
       sequence.push("'" + prettyName(aPivot.position) + "'");
     } while (aPivot.moveNext(aRule))
   }
   SimpleTest.info("\n[" + sequence.join(", ") + "]\n");
-}
\ No newline at end of file
+}
--- a/accessible/tests/mochitest/test_nsIAccessNode_utils.html
+++ b/accessible/tests/mochitest/test_nsIAccessNode_utils.html
@@ -10,25 +10,25 @@
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="common.js"></script>
 
   <script type="application/javascript">
     function doTest()
     {
       var elmObj = {};
-      var acc = getAccessible("span", [nsIAccessNode], elmObj);
+      var acc = getAccessible("span", null, elmObj);
       computedStyle = document.defaultView.getComputedStyle(elmObj.value, "");
 
       // html:span element
       is(acc.getComputedStyleValue("", "color"), computedStyle.color,
          "Wrong color for element with ID 'span'");
 
       // text child of html:span element
-      acc = getAccessible(acc.firstChild, [nsIAccessNode]);
+      acc = getAccessible(acc.firstChild);
       is(acc.getComputedStyleValue("", "color"), computedStyle.color,
          "Wrong color for text child of element with ID 'span'");
 
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
--- a/accessible/tests/mochitest/treeupdate/test_doc.html
+++ b/accessible/tests/mochitest/treeupdate/test_doc.html
@@ -59,18 +59,18 @@
       this.eventSeq = [
         new invokerChecker(EVENT_HIDE, null),
         new invokerChecker(EVENT_REORDER, getDocNode, aID)
       ];
 
       this.preinvoke = function rootContentRemoved_preinvoke()
       {
         // Set up target for hide event before we invoke.
-        var text = getAccessible(getAccessible(getDocNode(aID)).firstChild,
-                                               [nsIAccessNode]).DOMNode;
+        var text =
+          getAccessible(getAccessible(getDocNode(aID)).firstChild).DOMNode;
         this.eventSeq[0].target = text;
       }
 
       this.finalCheck = function rootContentRemoved_finalCheck()
       {
         var tree = {
           role: ROLE_DOCUMENT,
           states: {
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -408,16 +408,20 @@ pref("dom.mozBrowserFramesWhitelist", "h
 
 // Temporary permission hack for WebSMS
 pref("dom.sms.enabled", true);
 pref("dom.sms.whitelist", "file://,http://localhost:6666");
 
 // Ignore X-Frame-Options headers.
 pref("b2g.ignoreXFrameOptions", true);
 
+// controls if we want camera support
+pref("device.camera.enabled", true);
+pref("media.realtime_decoder.enabled", true);
+
 // "Preview" landing of bug 710563, which is bogged down in analysis
 // of talos regression.  This is a needed change for higher-framerate
 // CSS animations, and incidentally works around an apparent bug in
 // our handling of requestAnimationFrame() listeners, which are
 // supposed to enable this REPEATING_PRECISE_CAN_SKIP behavior.  The
 // secondary bug isn't really worth investigating since it's obseleted
 // by bug 710563.
 pref("layout.frame_rate.precise", true);
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -74,19 +74,20 @@ function startupHttpd(baseDir, port) {
   server.registerDirectory('/', new LocalFile(baseDir));
   server.registerContentType('appcache', 'text/cache-manifest');
   server.start(port);
 }
 
 // FIXME Bug 707625
 // until we have a proper security model, add some rights to
 // the pre-installed web applications
+// XXX never grant 'content-camera' to non-gaia apps
 function addPermissions(urls) {
   let permissions = [
-    'indexedDB', 'indexedDB-unlimited', 'webapps-manage', 'offline-app'
+    'indexedDB', 'indexedDB-unlimited', 'webapps-manage', 'offline-app', 'content-camera'
   ];
   urls.forEach(function(url) {
     let uri = Services.io.newURI(url, null, null);
     let allow = Ci.nsIPermissionManager.ALLOW_ACTION;
 
     permissions.forEach(function(permission) {
       Services.perms.add(uri, permission, allow);
     });
--- a/b2g/components/B2GComponents.manifest
+++ b/b2g/components/B2GComponents.manifest
@@ -1,2 +1,7 @@
 # Scrollbars
 category agent-style-sheets browser-content-stylesheet chrome://browser/content/content.css
+
+# CameraContent.js
+component {eff4231b-abce-4f7f-a40a-d646e8fde3ce} CameraContent.js
+contract @mozilla.org/b2g-camera-content;1 {eff4231b-abce-4f7f-a40a-d646e8fde3ce}
+category JavaScript-navigator-property mozCamera @mozilla.org/b2g-camera-content;1
new file mode 100644
--- /dev/null
+++ b/b2g/components/CameraContent.js
@@ -0,0 +1,83 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+
+const kProtocolName = "b2g-camera:";
+
+let CameraContent = function() {
+  this.hasPrivileges = false;
+  this.mapping = [];
+}
+ 
+CameraContent.prototype = {
+  getCameraURI: function(aOptions) {
+    if (!this.hasPrivileges)
+      return null;
+
+    let options = aOptions || { };
+    if (!options.camera)
+      options.camera = 0;
+    if (!options.width)
+      options.width = 320;
+    if (!options.height)
+      options.height = 240;
+
+    let uuid = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator).generateUUID().toString();
+    uuid = uuid.substring(1, uuid.length - 2); // remove the brackets
+    this.mapping.push(uuid);
+    let uri = kProtocolName + "?camera=" + options.camera + 
+                              "&width=" + options.width +
+                              "&height=" + options.height +
+                              "&type=video/x-raw-yuv";
+    // XXX that's no e10s ready, but the camera inputstream itself is not...
+    Services.prefs.setCharPref("b2g.camera." + kProtocolName + "?" + uuid, uri);
+    return kProtocolName + "?" + uuid;
+  },
+  
+  observe: function(aSubject, aTopic, aData) {
+    if (aTopic == "inner-window-destroyed") {
+      let wId = aSubject.QueryInterface(Ci.nsISupportsPRUint64).data;
+      if (wId == this.innerWindowID) {
+        Services.obs.removeObserver(this, "inner-window-destroyed");
+        for (let aId in this.mapping)
+          Services.prefs.clearUserPref("b2g.camera." + kProtocolName + "?" + aId);
+        this.mapping = null;
+      }
+    }
+  },
+
+  init: function(aWindow) {
+    let principal = aWindow.document.nodePrincipal;
+    let secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
+
+    let perm = principal == secMan.getSystemPrincipal() ? Ci.nsIPermissionManager.ALLOW_ACTION : Services.perms.testExactPermission(principal.URI, "content-camera");
+
+    //only pages with perm set and chrome pages can use the camera in content
+    this.hasPrivileges = perm == Ci.nsIPermissionManager.ALLOW_ACTION || from.schemeIs("chrome");
+
+    Services.obs.addObserver(this, "inner-window-destroyed", false);
+    let util = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+    this.innerWindowID = util.currentInnerWindowID;
+  },
+ 
+  classID: Components.ID("{eff4231b-abce-4f7f-a40a-d646e8fde3ce}"),
+
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIB2GCameraContent, Ci.nsIDOMGlobalPropertyInitializer, Ci.nsIObserver]),
+  
+  classInfo: XPCOMUtils.generateCI({classID: Components.ID("{eff4231b-abce-4f7f-a40a-d646e8fde3ce}"),
+                                    contractID: "@mozilla.org/b2g-camera-content;1",
+                                    interfaces: [Ci.nsIB2GCameraContent],
+                                    flags: Ci.nsIClassInfo.DOM_OBJECT,
+                                    classDescription: "B2G Camera Content Helper"})
+}
+ 
+const NSGetFactory = XPCOMUtils.generateNSGetFactory([CameraContent]);
--- a/b2g/components/Makefile.in
+++ b/b2g/components/Makefile.in
@@ -39,13 +39,18 @@ topsrcdir  = @top_srcdir@
 srcdir     = @srcdir@
 VPATH      = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = B2GComponents
 XPIDL_MODULE = B2GComponents
 
+XPIDLSRCS = \
+        b2g.idl \
+        $(NULL)
+
 EXTRA_PP_COMPONENTS = \
         B2GComponents.manifest \
+        CameraContent.js \
         $(NULL)
 
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/b2g/components/b2g.idl
@@ -0,0 +1,12 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "domstubs.idl"
+
+[scriptable, uuid(3615a616-571d-4194-bf54-ccf546067b14)]
+interface nsIB2GCameraContent : nsISupports
+{
+    /* temporary solution, waiting for getUserMedia */
+	DOMString getCameraURI([optional] in jsval options);
+};
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -598,8 +598,9 @@ bin/components/@DLL_PREFIX@nkgnomevfs@DL
 #endif
 
 [b2g]
 @BINPATH@/chrome/icons/
 @BINPATH@/chrome/chrome@JAREXT@
 @BINPATH@/chrome/chrome.manifest
 @BINPATH@/components/B2GComponents.manifest
 @BINPATH@/components/B2GComponents.xpt
+@BINPATH@/components/CameraContent.js
rename from toolkit/themes/pinstripe/global/icons/commandline.png
rename to browser/themes/gnomestripe/devtools/commandline.png
--- a/browser/themes/gnomestripe/devtools/gcli.css
+++ b/browser/themes/gnomestripe/devtools/gcli.css
@@ -59,17 +59,17 @@
   color: #FFF;
   padding-top: 4px;
   padding-bottom: 2px;
   -moz-padding-start: 21px;
   -moz-padding-end: 4px;
 }
 
 .gcliterm-stack-node {
-  background: url("chrome://global/skin/icons/commandline.png") 4px center no-repeat;
+  background: url("chrome://browser/skin/devtools/commandline.png") 4px center no-repeat;
   width: 100%;
 }
 
 .gcliterm-argfetcher {
   display: -moz-box;
   -moz-box-flex: 1;
 }
 
--- a/browser/themes/gnomestripe/devtools/webconsole.css
+++ b/browser/themes/gnomestripe/devtools/webconsole.css
@@ -288,17 +288,17 @@
 .jsterm-complete-node {
   border: none;
   padding: 0 0 0 16px;
   -moz-appearance: none;
 }
 
 .jsterm-input-node {
   width: 98%;
-  background: url("chrome://global/skin/icons/commandline.png") 4px 3px no-repeat;
+  background: url("chrome://browser/skin/devtools/commandline.png") 4px 3px no-repeat;
 }
 
 :-moz-any(.jsterm-input-node,
           .jsterm-complete-node) > .textbox-input-box > .textbox-textarea {
   overflow-x: hidden;
 }
 
 .jsterm-complete-node > .textbox-input-box > .textbox-textarea {
--- a/browser/themes/gnomestripe/jar.mn
+++ b/browser/themes/gnomestripe/jar.mn
@@ -82,16 +82,17 @@ browser.jar:
   skin/classic/browser/tabbrowser/tabDragIndicator.png (tabbrowser/tabDragIndicator.png)
   skin/classic/browser/tabview/edit-light.png         (tabview/edit-light.png)
   skin/classic/browser/tabview/search.png             (tabview/search.png)
   skin/classic/browser/tabview/stack-expander.png     (tabview/stack-expander.png)
   skin/classic/browser/tabview/tabview.png            (tabview/tabview.png)
   skin/classic/browser/tabview/tabview.css            (tabview/tabview.css)
   skin/classic/browser/devtools/common.css            (devtools/common.css)
   skin/classic/browser/devtools/arrows.png            (devtools/arrows.png)
+  skin/classic/browser/devtools/commandline.png       (devtools/commandline.png)
   skin/classic/browser/devtools/goto-mdn.png          (devtools/goto-mdn.png)
   skin/classic/browser/devtools/csshtmltree.css       (devtools/csshtmltree.css)
   skin/classic/browser/devtools/webconsole.css                  (devtools/webconsole.css)
   skin/classic/browser/devtools/webconsole_networkpanel.css     (devtools/webconsole_networkpanel.css)
   skin/classic/browser/devtools/webconsole.png                  (devtools/webconsole.png)
   skin/classic/browser/devtools/gcli.css              (devtools/gcli.css)
   skin/classic/browser/devtools/orion.css             (devtools/orion.css)
   skin/classic/browser/devtools/breadcrumbs/ltr-end-pressed.png              (devtools/breadcrumbs/ltr-end-pressed.png)
copy from toolkit/themes/pinstripe/global/icons/commandline.png
copy to browser/themes/pinstripe/devtools/commandline.png
--- a/browser/themes/pinstripe/devtools/gcli.css
+++ b/browser/themes/pinstripe/devtools/gcli.css
@@ -59,17 +59,17 @@
   color: #FFF;
   padding-top: 4px;
   padding-bottom: 2px;
   -moz-padding-start: 21px;
   -moz-padding-end: 4px;
 }
 
 .gcliterm-stack-node {
-  background: url("chrome://global/skin/icons/commandline.png") 4px center no-repeat;
+  background: url("chrome://browser/skin/devtools/commandline.png") 4px center no-repeat;
   width: 100%;
 }
 
 .gcliterm-argfetcher {
   display: -moz-box;
   -moz-box-flex: 1;
 }
 
--- a/browser/themes/pinstripe/devtools/webconsole.css
+++ b/browser/themes/pinstripe/devtools/webconsole.css
@@ -356,17 +356,17 @@
 .jsterm-input-node,
 .jsterm-complete-node {
   border: none;
   padding: 0 0 0 16px;
   -moz-appearance: none;
 }
 
 .jsterm-input-node {
-  background: url("chrome://global/skin/icons/commandline.png") 4px 2px no-repeat;
+  background: url("chrome://browser/skin/devtools/commandline.png") 4px 2px no-repeat;
 }
 
 :-moz-any(.jsterm-input-node,
           .jsterm-complete-node) > .textbox-input-box > .textbox-textarea {
   overflow-x: hidden;
 }
 
 .jsterm-complete-node > .textbox-input-box > .textbox-textarea {
--- a/browser/themes/pinstripe/jar.mn
+++ b/browser/themes/pinstripe/jar.mn
@@ -121,16 +121,17 @@ browser.jar:
   skin/classic/browser/tabview/close.png                    (tabview/close.png)
   skin/classic/browser/tabview/edit-light.png               (tabview/edit-light.png)
   skin/classic/browser/tabview/search.png                   (tabview/search.png)
   skin/classic/browser/tabview/stack-expander.png           (tabview/stack-expander.png)
   skin/classic/browser/tabview/tabview.png                  (tabview/tabview.png)
   skin/classic/browser/tabview/tabview.css                  (tabview/tabview.css)
 * skin/classic/browser/devtools/common.css                  (devtools/common.css)
   skin/classic/browser/devtools/arrows.png                  (devtools/arrows.png)
+  skin/classic/browser/devtools/commandline.png             (devtools/commandline.png)
   skin/classic/browser/devtools/goto-mdn.png                (devtools/goto-mdn.png)
   skin/classic/browser/devtools/csshtmltree.css             (devtools/csshtmltree.css)
   skin/classic/browser/devtools/gcli.css                    (devtools/gcli.css)
   skin/classic/browser/devtools/orion.css                   (devtools/orion.css)
   skin/classic/browser/devtools/toolbarbutton-close.png     (devtools/toolbarbutton-close.png)
 * skin/classic/browser/devtools/webconsole.css                  (devtools/webconsole.css)
   skin/classic/browser/devtools/webconsole_networkpanel.css     (devtools/webconsole_networkpanel.css)
   skin/classic/browser/devtools/webconsole.png                  (devtools/webconsole.png)
rename from toolkit/themes/winstripe/global/icons/commandline.png
rename to browser/themes/winstripe/devtools/commandline.png
--- a/browser/themes/winstripe/devtools/gcli.css
+++ b/browser/themes/winstripe/devtools/gcli.css
@@ -59,17 +59,17 @@
   color: #FFF;
   padding-top: 4px;
   padding-bottom: 2px;
   -moz-padding-start: 21px;
   -moz-padding-end: 4px;
 }
 
 .gcliterm-stack-node {
-  background: url("chrome://global/skin/icons/commandline.png") 4px center no-repeat;
+  background: url("chrome://browser/skin/devtools/commandline.png") 4px center no-repeat;
   width: 100%;
 }
 
 .gcliterm-argfetcher {
   display: -moz-box;
   -moz-box-flex: 1;
 }
 
--- a/browser/themes/winstripe/devtools/webconsole.css
+++ b/browser/themes/winstripe/devtools/webconsole.css
@@ -304,17 +304,17 @@
 .jsterm-input-node,
 .jsterm-complete-node {
   border: none;
   padding: 0 0 0 16px;
   -moz-appearance: none;
 }
 
 .jsterm-input-node {
-  background: url("chrome://global/skin/icons/commandline.png") 4px 3px no-repeat;
+  background: url("chrome://browser/skin/devtools/commandline.png") 4px 3px no-repeat;
 }
 
 :-moz-any(.jsterm-input-node,
           .jsterm-complete-node) > .textbox-input-box > .textbox-textarea {
   overflow-x: hidden;
 }
 
 .jsterm-complete-node > .textbox-input-box > .textbox-textarea {
--- a/browser/themes/winstripe/jar.mn
+++ b/browser/themes/winstripe/jar.mn
@@ -105,16 +105,17 @@ browser.jar:
         skin/classic/browser/tabview/grain.png                      (tabview/grain.png)
         skin/classic/browser/tabview/search.png                     (tabview/search.png)
         skin/classic/browser/tabview/stack-expander.png             (tabview/stack-expander.png)
         skin/classic/browser/tabview/tabview.png                    (tabview/tabview.png)
         skin/classic/browser/tabview/tabview-inverted.png           (tabview/tabview-inverted.png)
         skin/classic/browser/tabview/tabview.css                    (tabview/tabview.css)
         skin/classic/browser/devtools/common.css                    (devtools/common.css)
         skin/classic/browser/devtools/arrows.png                    (devtools/arrows.png)
+        skin/classic/browser/devtools/commandline.png               (devtools/commandline.png)
         skin/classic/browser/devtools/goto-mdn.png                  (devtools/goto-mdn.png)
         skin/classic/browser/devtools/csshtmltree.css               (devtools/csshtmltree.css)
         skin/classic/browser/devtools/gcli.css                      (devtools/gcli.css)
         skin/classic/browser/devtools/orion.css                     (devtools/orion.css)
         skin/classic/browser/devtools/toolbarbutton-close.png       (devtools/toolbarbutton-close.png)
         skin/classic/browser/devtools/webconsole.css                  (devtools/webconsole.css)
         skin/classic/browser/devtools/webconsole_networkpanel.css     (devtools/webconsole_networkpanel.css)
         skin/classic/browser/devtools/webconsole.png                  (devtools/webconsole.png)
@@ -269,16 +270,17 @@ browser.jar:
         skin/classic/aero/browser/tabview/grain.png                  (tabview/grain.png)
         skin/classic/aero/browser/tabview/search.png                 (tabview/search.png)
         skin/classic/aero/browser/tabview/stack-expander.png         (tabview/stack-expander.png)
         skin/classic/aero/browser/tabview/tabview.png                (tabview/tabview.png)
         skin/classic/aero/browser/tabview/tabview-inverted.png       (tabview/tabview-inverted.png)
         skin/classic/aero/browser/tabview/tabview.css                (tabview/tabview.css)
         skin/classic/aero/browser/devtools/common.css                (devtools/common.css)
         skin/classic/aero/browser/devtools/arrows.png                (devtools/arrows.png)
+        skin/classic/aero/browser/devtools/commandline.png           (devtools/commandline.png)
         skin/classic/aero/browser/devtools/goto-mdn.png              (devtools/goto-mdn.png)
         skin/classic/aero/browser/devtools/csshtmltree.css           (devtools/csshtmltree.css)
         skin/classic/aero/browser/devtools/gcli.css                  (devtools/gcli.css)
         skin/classic/aero/browser/devtools/orion.css                 (devtools/orion.css)
         skin/classic/aero/browser/devtools/toolbarbutton-close.png   (devtools/toolbarbutton-close.png)
         skin/classic/aero/browser/devtools/webconsole.css                  (devtools/webconsole.css)
         skin/classic/aero/browser/devtools/webconsole_networkpanel.css     (devtools/webconsole_networkpanel.css)
         skin/classic/aero/browser/devtools/webconsole.png                  (devtools/webconsole.png)
--- a/config/config.mk
+++ b/config/config.mk
@@ -158,34 +158,47 @@ TOUCH ?= touch
 ifndef .PYMAKE
 PYTHON_PATH = $(PYTHON) $(topsrcdir)/config/pythonpath.py
 else
 PYCOMMANDPATH += $(topsrcdir)/config
 PYTHON_PATH = %pythonpath main
 endif
 
 # determine debug-related options
+_DEBUG_ASFLAGS :=
 _DEBUG_CFLAGS :=
 _DEBUG_LDFLAGS :=
 
 ifdef MOZ_DEBUG
-  _DEBUG_CFLAGS += $(MOZ_DEBUG_ENABLE_DEFS) $(MOZ_DEBUG_FLAGS)
-  _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)
+  _DEBUG_CFLAGS += $(MOZ_DEBUG_ENABLE_DEFS)
   XULPPFLAGS += $(MOZ_DEBUG_ENABLE_DEFS)
 else
   _DEBUG_CFLAGS += $(MOZ_DEBUG_DISABLE_DEFS)
   XULPPFLAGS += $(MOZ_DEBUG_DISABLE_DEFS)
-  ifdef MOZ_DEBUG_SYMBOLS
-    _DEBUG_CFLAGS += $(MOZ_DEBUG_FLAGS)
-    _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)
+endif
+
+ifneq (,$(MOZ_DEBUG)$(MOZ_DEBUG_SYMBOLS))
+  ifeq ($(AS),yasm)
+    ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
+      _DEBUG_ASFLAGS += -g cv8
+    else
+      ifneq ($(OS_ARCH),Darwin)
+        _DEBUG_ASFLAGS += -g dwarf2
+      endif
+    endif
+  else
+    _DEBUG_ASFLAGS += $(MOZ_DEBUG_FLAGS)
   endif
+  _DEBUG_CFLAGS += $(MOZ_DEBUG_FLAGS)
+  _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)
 endif
 
 MOZALLOC_LIB = $(call EXPAND_LIBNAME_PATH,mozalloc,$(DIST)/lib)
 
+ASFLAGS += $(_DEBUG_ASFLAGS)
 OS_CFLAGS += $(_DEBUG_CFLAGS)
 OS_CXXFLAGS += $(_DEBUG_CFLAGS)
 OS_LDFLAGS += $(_DEBUG_LDFLAGS)
 
 # XXX: What does this? Bug 482434 filed for better explanation.
 ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
 ifdef MOZ_DEBUG
 ifneq (,$(MOZ_BROWSE_INFO)$(MOZ_BSCFILE))
@@ -193,23 +206,18 @@ OS_CFLAGS += -FR
 OS_CXXFLAGS += -FR
 endif
 else # ! MOZ_DEBUG
 
 # MOZ_DEBUG_SYMBOLS generates debug symbols in separate PDB files.
 # Used for generating an optimized build with debugging symbols.
 # Used in the Windows nightlies to generate symbols for crash reporting.
 ifdef MOZ_DEBUG_SYMBOLS
-ifeq ($(AS),yasm)
-ASFLAGS += -g cv8
-else
-ASFLAGS += -Zi
-endif
-OS_CXXFLAGS += -Zi -UDEBUG -DNDEBUG
-OS_CFLAGS += -Zi -UDEBUG -DNDEBUG
+OS_CXXFLAGS += -UDEBUG -DNDEBUG
+OS_CFLAGS += -UDEBUG -DNDEBUG
 ifdef HAVE_64BIT_OS
 OS_LDFLAGS += -DEBUG -OPT:REF,ICF
 else
 OS_LDFLAGS += -DEBUG -OPT:REF
 endif
 endif
 
 ifdef MOZ_QUANTIFY
--- a/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp
+++ b/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp
@@ -3021,16 +3021,21 @@ struct NS_STACK_CLASS nsCanvasBidiProces
         endRun = mTextRun->GetLength();
       }
 
       const gfxTextRun::CompressedGlyph *glyphs = mTextRun->GetCharacterGlyphs();
 
       RefPtr<ScaledFont> scaledFont =
         gfxPlatform::GetPlatform()->GetScaledFontForFont(font);
 
+      if (!scaledFont) {
+        // This can occur when something switched DirectWrite off.
+        return;
+      }
+
       GlyphBuffer buffer;
 
       std::vector<Glyph> glyphBuf;
 
       for (PRUint32 i = runs[c].mCharacterOffset; i < endRun; i++) {
         Glyph newGlyph;
         if (glyphs[i].IsSimpleGlyph()) {
           newGlyph.mIndex = glyphs[i].GetSimpleGlyph();
--- a/content/html/content/src/nsHTMLFormElement.cpp
+++ b/content/html/content/src/nsHTMLFormElement.cpp
@@ -33,16 +33,17 @@
  * 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 "nsHTMLFormElement.h"
 #include "nsIHTMLDocument.h"
 #include "nsIDOMEventTarget.h"
 #include "nsEventStateManager.h"
+#include "nsEventStates.h"
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsPresContext.h"
 #include "nsIDocument.h"
 #include "nsIFrame.h"
 #include "nsIFormControlFrame.h"
 #include "nsDOMError.h"
 #include "nsContentUtils.h"
@@ -1805,16 +1806,18 @@ nsHTMLFormElement::UpdateValidity(bool a
   // Because of backward compatibility, <input type='image'> is not in elements
   // so we have to check for controls not in elements too.
   PRUint32 length = mControls->mNotInElements.Length();
   for (PRUint32 i = 0; i < length; ++i) {
     if (mControls->mNotInElements[i]->IsSubmitControl()) {
       mControls->mNotInElements[i]->UpdateState(true);
     }
   }
+
+  UpdateState(true);
 }
 
 // nsIWebProgressListener
 NS_IMETHODIMP
 nsHTMLFormElement::OnStateChange(nsIWebProgress* aWebProgress,
                                  nsIRequest* aRequest,
                                  PRUint32 aStateFlags,
                                  PRUint32 aStatus)
@@ -2128,16 +2131,29 @@ nsHTMLFormElement::GetValueMissingState(
 }
 
 void
 nsHTMLFormElement::SetValueMissingState(const nsAString& aName, bool aValue)
 {
   mValueMissingRadioGroups.Put(aName, aValue);
 }
 
+nsEventStates
+nsHTMLFormElement::IntrinsicState() const
+{
+  nsEventStates state = nsGenericHTMLElement::IntrinsicState();
+
+  if (mInvalidElementsCount) {
+    state |= NS_EVENT_STATE_INVALID;
+  } else {
+      state |= NS_EVENT_STATE_VALID;
+  }
+
+  return state;
+}
 
 //----------------------------------------------------------------------
 // nsFormControlList implementation, this could go away if there were
 // a lightweight collection implementation somewhere
 
 nsFormControlList::nsFormControlList(nsHTMLFormElement* aForm) :
   mForm(aForm),
   // Initialize the elements list to have an initial capacity
--- a/content/html/content/src/nsHTMLFormElement.h
+++ b/content/html/content/src/nsHTMLFormElement.h
@@ -146,16 +146,18 @@ public:
   NS_IMETHOD RemoveFromRadioGroup(const nsAString& aName,
                                   nsIFormControl* aRadio);
   virtual PRUint32 GetRequiredRadioCount(const nsAString& aName) const;
   virtual void RadioRequiredChanged(const nsAString& aName,
                                     nsIFormControl* aRadio);
   virtual bool GetValueMissingState(const nsAString& aName) const;
   virtual void SetValueMissingState(const nsAString& aName, bool aValue);
 
+  virtual nsEventStates IntrinsicState() const;
+
   // nsIContent
   virtual bool ParseAttribute(PRInt32 aNamespaceID,
                                 nsIAtom* aAttribute,
                                 const nsAString& aValue,
                                 nsAttrValue& aResult);
   virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
   virtual nsresult WillHandleEvent(nsEventChainPostVisitor& aVisitor);
   virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
--- a/content/html/content/src/nsHTMLObjectElement.cpp
+++ b/content/html/content/src/nsHTMLObjectElement.cpp
@@ -323,45 +323,45 @@ nsHTMLObjectElement::UnsetAttr(PRInt32 a
 bool
 nsHTMLObjectElement::IsFocusableForTabIndex()
 {
   nsIDocument* doc = GetCurrentDoc();
   if (!doc || doc->HasFlag(NODE_IS_EDITABLE)) {
     return false;
   }
 
-  return Type() == eType_Plugin || IsEditableRoot() ||
-         (Type() == eType_Document && nsContentUtils::IsSubDocumentTabbable(this));
+  return IsEditableRoot() || (Type() == eType_Document &&
+                              nsContentUtils::IsSubDocumentTabbable(this));
 }
 
 bool
 nsHTMLObjectElement::IsHTMLFocusable(bool aWithMouse,
                                      bool *aIsFocusable, PRInt32 *aTabIndex)
 {
   // TODO: this should probably be managed directly by IsHTMLFocusable.
   // See bug 597242.
   nsIDocument *doc = GetCurrentDoc();
   if (!doc || doc->HasFlag(NODE_IS_EDITABLE)) {
     if (aTabIndex) {
-      GetIntAttr(nsGkAtoms::tabindex, -1, aTabIndex);
+      GetTabIndex(aTabIndex);
     }
 
     *aIsFocusable = false;
 
     return false;
   }
 
   // This method doesn't call nsGenericHTMLFormElement intentionally.
   // TODO: It should probably be changed when bug 597242 will be fixed.
   if (Type() == eType_Plugin || IsEditableRoot() ||
       (Type() == eType_Document && nsContentUtils::IsSubDocumentTabbable(this))) {
     // Has plugin content: let the plugin decide what to do in terms of
     // internal focus from mouse clicks
     if (aTabIndex) {
-      GetIntAttr(nsGkAtoms::tabindex, 0, aTabIndex);
+      GetTabIndex(aTabIndex);
     }
 
     *aIsFocusable = true;
 
     return false;
   }
 
   // TODO: this should probably be managed directly by IsHTMLFocusable.
--- a/content/html/content/test/Makefile.in
+++ b/content/html/content/test/Makefile.in
@@ -291,16 +291,17 @@ include $(topsrcdir)/config/rules.mk
 		file_fullscreen-navigation.html \
 		file_fullscreen-esc-exit.html \
 		file_fullscreen-esc-exit-inner.html \
 		file_fullscreen-rollback.html \
 		test_li_attributes_reflection.html \
 		test_ol_attributes_reflection.html \
 		test_bug651956.html \
 		test_bug694503.html \
+		test_object_plugin_nav.html \
 		$(NULL)
 
 _BROWSER_TEST_FILES = \
 		browser_bug649778.js \
 		file_bug649778.html \
 		file_bug649778.html^headers^ \
 		$(NULL)
 
new file mode 100644
--- /dev/null
+++ b/content/html/content/test/test_object_plugin_nav.html
@@ -0,0 +1,90 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=720130
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 720130</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=720130">Mozilla Bug 720130</a>
+<p id="display"></p>
+<div id="content">
+  <input>
+  <object type="application/x-test"></object>
+  <button>foo</button>
+  <object tabindex='0' type="application/x-test"></object>
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 720130 **/
+
+var gFocusCount = 0;
+var gFocusNb    = 4;
+
+/**
+ * Check the focus navigation.
+ */
+function checkFocus() {
+  switch (gFocusCount) {
+    case 0:
+      is(document.activeElement, document.getElementsByTagName('a')[0],
+         "first focused element should be the link");
+      break;
+    case 1:
+      is(document.activeElement, document.getElementsByTagName('input')[0],
+         "second focused element should be the text field");
+      break;
+    case 2:
+      is(document.activeElement, document.getElementsByTagName('button')[0],
+         "third focused element should be the button");
+      break;
+    case 3:
+      is(document.activeElement, document.getElementsByTagName('object')[1],
+         "fourth focused element should be the object");
+      break;
+  }
+
+  gFocusCount++;
+}
+
+SimpleTest.waitForExplicitFinish();
+
+SimpleTest.waitForFocus(function() {
+  is(document.activeElement, document.body);
+
+  // Preliminary check: tabindex should be -1 on the object.
+  is(document.getElementsByTagName('object')[0].tabIndex, -1,
+     "the plugin shouldn't get focus while navigating in the document");
+
+  document.addEventListener("focus", function() {
+    checkFocus();
+
+    if (gFocusCount != gFocusNb) {
+      synthesizeKey("VK_TAB", {});
+      return;
+    }
+
+    document.removeEventListener("focus", arguments.callee, true);
+
+    // Just make sure that .focus() still works.
+    var o = document.getElementsByTagName('object')[0];
+    o.onfocus = function() {
+      SimpleTest.finish();
+      o.onfocus = null;
+    };
+    o.focus();
+  }, true);
+
+  synthesizeKey("VK_TAB", {});
+});
+
+</script>
+</pre>
+</body>
+</html>
--- a/gfx/layers/basic/BasicLayers.cpp
+++ b/gfx/layers/basic/BasicLayers.cpp
@@ -1197,16 +1197,21 @@ BasicCanvasLayer::Paint(gfxContext* aCon
 
 void
 BasicCanvasLayer::PaintWithOpacity(gfxContext* aContext,
                                    float aOpacity)
 {
   NS_ASSERTION(BasicManager()->InDrawing(),
                "Can only draw in drawing phase");
 
+  if (!mSurface) {
+    NS_WARNING("No valid surface to draw!");
+    return;
+  }
+
   nsRefPtr<gfxPattern> pat = new gfxPattern(mSurface);
 
   pat->SetFilter(mFilter);
   pat->SetExtend(gfxPattern::EXTEND_PAD);
 
   gfxMatrix m;
   if (mNeedsYFlip) {
     m = aContext->CurrentMatrix();
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -513,16 +513,21 @@ gfxWindowsPlatform::GetThebesSurfaceForD
 {
 #ifdef XP_WIN
   if (aTarget->GetType() == BACKEND_DIRECT2D) {
     void *surface = aTarget->GetUserData(&kThebesSurfaceKey);
     if (surface) {
       nsRefPtr<gfxASurface> surf = static_cast<gfxASurface*>(surface);
       return surf.forget();
     } else {
+      if (!GetD2DDevice()) {
+        // We no longer have a D2D device, can't do this.
+        return NULL;
+      }
+
       RefPtr<ID3D10Texture2D> texture =
         static_cast<ID3D10Texture2D*>(aTarget->GetNativeSurface(NATIVE_SURFACE_D3D10_TEXTURE));
 
       if (!texture) {
         return gfxPlatform::GetThebesSurfaceForDrawTarget(aTarget);
       }
 
       aTarget->Flush();
--- a/js/src/config/config.mk
+++ b/js/src/config/config.mk
@@ -158,34 +158,47 @@ TOUCH ?= touch
 ifndef .PYMAKE
 PYTHON_PATH = $(PYTHON) $(topsrcdir)/config/pythonpath.py
 else
 PYCOMMANDPATH += $(topsrcdir)/config
 PYTHON_PATH = %pythonpath main
 endif
 
 # determine debug-related options
+_DEBUG_ASFLAGS :=
 _DEBUG_CFLAGS :=
 _DEBUG_LDFLAGS :=
 
 ifdef MOZ_DEBUG
-  _DEBUG_CFLAGS += $(MOZ_DEBUG_ENABLE_DEFS) $(MOZ_DEBUG_FLAGS)
-  _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)
+  _DEBUG_CFLAGS += $(MOZ_DEBUG_ENABLE_DEFS)
   XULPPFLAGS += $(MOZ_DEBUG_ENABLE_DEFS)
 else
   _DEBUG_CFLAGS += $(MOZ_DEBUG_DISABLE_DEFS)
   XULPPFLAGS += $(MOZ_DEBUG_DISABLE_DEFS)
-  ifdef MOZ_DEBUG_SYMBOLS
-    _DEBUG_CFLAGS += $(MOZ_DEBUG_FLAGS)
-    _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)
+endif
+
+ifneq (,$(MOZ_DEBUG)$(MOZ_DEBUG_SYMBOLS))
+  ifeq ($(AS),yasm)
+    ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
+      _DEBUG_ASFLAGS += -g cv8
+    else
+      ifneq ($(OS_ARCH),Darwin)
+        _DEBUG_ASFLAGS += -g dwarf2
+      endif
+    endif
+  else
+    _DEBUG_ASFLAGS += $(MOZ_DEBUG_FLAGS)
   endif
+  _DEBUG_CFLAGS += $(MOZ_DEBUG_FLAGS)
+  _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)
 endif
 
 MOZALLOC_LIB = $(call EXPAND_LIBNAME_PATH,mozalloc,$(DIST)/lib)
 
+ASFLAGS += $(_DEBUG_ASFLAGS)
 OS_CFLAGS += $(_DEBUG_CFLAGS)
 OS_CXXFLAGS += $(_DEBUG_CFLAGS)
 OS_LDFLAGS += $(_DEBUG_LDFLAGS)
 
 # XXX: What does this? Bug 482434 filed for better explanation.
 ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
 ifdef MOZ_DEBUG
 ifneq (,$(MOZ_BROWSE_INFO)$(MOZ_BSCFILE))
@@ -193,23 +206,18 @@ OS_CFLAGS += -FR
 OS_CXXFLAGS += -FR
 endif
 else # ! MOZ_DEBUG
 
 # MOZ_DEBUG_SYMBOLS generates debug symbols in separate PDB files.
 # Used for generating an optimized build with debugging symbols.
 # Used in the Windows nightlies to generate symbols for crash reporting.
 ifdef MOZ_DEBUG_SYMBOLS
-ifeq ($(AS),yasm)
-ASFLAGS += -g cv8
-else
-ASFLAGS += -Zi
-endif
-OS_CXXFLAGS += -Zi -UDEBUG -DNDEBUG
-OS_CFLAGS += -Zi -UDEBUG -DNDEBUG
+OS_CXXFLAGS += -UDEBUG -DNDEBUG
+OS_CFLAGS += -UDEBUG -DNDEBUG
 ifdef HAVE_64BIT_OS
 OS_LDFLAGS += -DEBUG -OPT:REF,ICF
 else
 OS_LDFLAGS += -DEBUG -OPT:REF
 endif
 endif
 
 ifdef MOZ_QUANTIFY
--- a/js/xpconnect/loader/XPCOMUtils.jsm
+++ b/js/xpconnect/loader/XPCOMUtils.jsm
@@ -312,16 +312,42 @@ var XPCOMUtils = {
   importRelative: function XPCOMUtils__importRelative(that, path) {
     if (!("__URI__" in that))
       throw Error("importRelative may only be used from a JSM, and its first argument "+
                   "must be that JSM's global object (hint: use this)");
     let uri = that.__URI__;
     let i = uri.lastIndexOf("/");
     Components.utils.import(uri.substring(0, i+1) + path, that);
   },
+
+  /**
+   * generates a singleton nsIFactory implementation that can be used as
+   * the _xpcom_factory of the component.
+   * @param aServiceConstructor
+   *        Constructor function of the component.
+   */
+  generateSingletonFactory:
+  function XPCOMUtils_generateSingletonFactory(aServiceConstructor) {
+    return {
+      _instance: null,
+      createInstance: function XPCU_SF_createInstance(aOuter, aIID) {
+        if (aOuter !== null) {
+          throw Cr.NS_ERROR_NO_AGGREGATION;
+        }
+        if (this._instance === null) {
+          this._instance = new aServiceConstructor();
+        }
+        return this._instance.QueryInterface(aIID);
+      },
+      lockFactory: function XPCU_SF_lockFactory(aDoLock) {
+        throw Cr.NS_ERROR_NOT_IMPLEMENTED;
+      },
+      QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory])
+    };
+  },
 };
 
 /**
  * Helper for XPCOMUtils.generateQI to avoid leaks - see bug 381651#c1
  */
 function makeQI(interfaceNames) {
   return function XPCOMUtils_QueryInterface(iid) {
     if (iid.equals(Ci.nsISupports))
@@ -331,9 +357,8 @@ function makeQI(interfaceNames) {
     for each(let interfaceName in interfaceNames) {
       if (Ci[interfaceName].equals(iid))
         return this;
     }
 
     throw Cr.NS_ERROR_NO_INTERFACE;
   };
 }
-
--- a/js/xpconnect/tests/unit/test_xpcomutils.js
+++ b/js/xpconnect/tests/unit/test_xpcomutils.js
@@ -45,17 +45,17 @@ Components.utils.import("resource://gre/
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Tests
 
-function test_generateQI_string_names()
+add_test(function test_generateQI_string_names()
 {
     var x = {
         QueryInterface: XPCOMUtils.generateQI([
             Components.interfaces.nsIClassInfo,
             "nsIDOMNode"
         ])
     };
 
@@ -68,20 +68,21 @@ function test_generateQI_string_names()
         x.QueryInterface(Components.interfaces.nsIDOMNode);
     } catch(e) {
         do_throw("Should QI to nsIDOMNode");
     }
     try {
         x.QueryInterface(Components.interfaces.nsIDOMDocument);
         do_throw("QI should not have succeeded!");
     } catch(e) {}
-}
+    run_next_test();
+});
 
 
-function test_generateCI()
+add_test(function test_generateCI()
 {
     const classID = Components.ID("562dae2e-7cff-432b-995b-3d4c03fa2b89");
     const classDescription = "generateCI test component";
     const flags = Components.interfaces.nsIClassInfo.DOM_OBJECT;
     var x = {
         QueryInterface: XPCOMUtils.generateQI([]),
         classInfo: XPCOMUtils.generateCI({classID: classID,
                                           interfaces: [],
@@ -94,19 +95,20 @@ function test_generateCI()
         ci = ci.QueryInterface(Components.interfaces.nsISupports);
         ci = ci.QueryInterface(Components.interfaces.nsIClassInfo);
         do_check_eq(ci.classID, classID);
         do_check_eq(ci.flags, flags);
         do_check_eq(ci.classDescription, classDescription);
     } catch(e) {
         do_throw("Classinfo for x should not be missing or broken");
     }
-}
+    run_next_test();
+});
 
-function test_defineLazyGetter()
+add_test(function test_defineLazyGetter()
 {
     let accessCount = 0;
     let obj = {
       inScope: false
     };
     const TEST_VALUE = "test value";
     XPCOMUtils.defineLazyGetter(obj, "foo", function() {
         accessCount++;
@@ -119,38 +121,40 @@ function test_defineLazyGetter()
     do_check_eq(obj.foo, TEST_VALUE);
     do_check_eq(accessCount, 1);
     do_check_true(obj.inScope);
 
     // Get the property once more, making sure the access count has not
     // increased.
     do_check_eq(obj.foo, TEST_VALUE);
     do_check_eq(accessCount, 1);
-}
+    run_next_test();
+});
 
 
-function test_defineLazyServiceGetter()
+add_test(function test_defineLazyServiceGetter()
 {
     let obj = { };
     XPCOMUtils.defineLazyServiceGetter(obj, "service",
                                        "@mozilla.org/consoleservice;1",
                                        "nsIConsoleService");
     let service = Cc["@mozilla.org/consoleservice;1"].
                   getService(Ci.nsIConsoleService);
 
     // Check that the lazy service getter and the actual service have the same
     // properties.
     for (let prop in obj.service)
         do_check_true(prop in service);
     for (let prop in service)
         do_check_true(prop in obj.service);
-}
+    run_next_test();
+});
 
 
-function test_categoryRegistration()
+add_test(function test_categoryRegistration()
 {
   const CATEGORY_NAME = "test-cat";
   const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1";
   const XULAPPINFO_CID = Components.ID("{fc937916-656b-4fb3-a395-8c63569e27a8}");
 
   // Create a fake app entry for our category registration apps filter.
   let XULAppInfo = {
     vendor: "Mozilla",
@@ -198,29 +202,50 @@ function test_categoryRegistration()
   while (entries.hasMoreElements()) {
     foundEntriesCount++;
     let entry = entries.getNext().QueryInterface(Ci.nsISupportsCString).data;
     print("Check the found category entry (" + entry + ") is expected.");  
     do_check_true(EXPECTED_ENTRIES.indexOf(entry) != -1);
   }
   print("Check there are no more or less than expected entries.");
   do_check_eq(foundEntriesCount, EXPECTED_ENTRIES.length);
-}
+  run_next_test();
+});
+
+add_test(function test_generateSingletonFactory()
+{
+  const XPCCOMPONENT_CONTRACTID = "@mozilla.org/singletonComponentTest;1";
+  const XPCCOMPONENT_CID = Components.ID("{31031c36-5e29-4dd9-9045-333a5d719a3e}");
 
+  function XPCComponent() {}
+  XPCComponent.prototype = {
+    classID: XPCCOMPONENT_CID,
+    _xpcom_factory: XPCOMUtils.generateSingletonFactory(XPCComponent),
+    QueryInterface: XPCOMUtils.generateQI([])
+  };
+  let NSGetFactory = XPCOMUtils.generateNSGetFactory([XPCComponent]);
+  let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
+  registrar.registerFactory(
+    XPCCOMPONENT_CID,
+    "XPCComponent",
+    XPCCOMPONENT_CONTRACTID,
+    NSGetFactory(XPCCOMPONENT_CID)
+  );
+
+  // First, try to instance the component.
+  let instance = Cc[XPCCOMPONENT_CONTRACTID].createInstance(Ci.nsISupports);
+  // Try again, check that it returns the same instance as before.
+  do_check_eq(instance,
+              Cc[XPCCOMPONENT_CONTRACTID].createInstance(Ci.nsISupports));
+  // Now, for sanity, check that getService is also returning the same instance.
+  do_check_eq(instance,
+              Cc[XPCCOMPONENT_CONTRACTID].getService(Ci.nsISupports));
+
+  run_next_test();
+});
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Test Runner
 
-let tests = [
-    test_generateQI_string_names,
-    test_generateCI,
-    test_defineLazyGetter,
-    test_defineLazyServiceGetter,
-    test_categoryRegistration,
-];
-
 function run_test()
 {
-    tests.forEach(function(test) {
-        print("Running next test: " + test.name);
-        test();
-    });
+  run_next_test();
 }
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-add-control.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<!--form with one invalid element and another valid one is added dynamically -->
+<html class='reftest-wait'>
+  <head>
+    <style>
+      form:invalid { display: none; }
+    </style>
+  </head>
+  <script>
+    function onloadHandler()
+    {
+      document.forms[0].appendChild(document.getElementById('i'));
+      document.documentElement.className = '';
+    }
+  </script>
+  <body onload='onloadHandler();'>
+    <input id='i'>
+    <form>
+      <input required>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-add-invalid-element-dynamic.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<!-- form with no elements and invalid element is added dynamically -->
+<html>
+  <head>
+    <style>
+      form:invalid { display:none }
+    </style>
+    <script>
+      function onLoadHandler()
+      {
+        document.forms[0].appendChild(document.getElementById('i'));
+        document.documentElement.className='';
+      }
+    </script>
+  </head>
+  <body onload='onLoadHandler();'>
+    <input id='i' required>
+    <form>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-add-invalid-element.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<!--form with one invalid element and another invalid one is added dynamically -->
+<html class='reftest-wait'>
+  <head>
+    <style>
+      form:invalid { display: none; }
+    </style>
+  </head>
+  <script>
+    function onloadHandler()
+    {
+      document.forms[0].appendChild(document.getElementById('i'));
+      document.documentElement.className = '';
+    }
+  </script>
+  <body onload='onloadHandler();'>
+    <input id='i' type='email' value='foo'>
+    <form>
+      <input id='j' type='email' value='foo'>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-add-invalid-with-valid-element.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<!--form with one valid element and invalid one is added dynamically -->
+<html class='reftest-wait'>
+  <head>
+    <style>
+      form:invalid { display: none; }
+    </style>
+  </head>
+  <script>
+    function onloadHandler()
+    {
+      document.forms[0].appendChild(document.getElementById('i'));
+      document.documentElement.className = '';
+    }
+  </script>
+  <body onload='onloadHandler();'>
+    <input id='i' type='email' value='bar'>
+    <form>
+      <input id='j' type='text' value='foo'>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-add-valid-element.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<!--form with one valid element and another valid one is added dynamically -->
+<html class='reftest-wait'>
+  <head>
+    <style>
+      form:invalid { display: none; }
+    </style>
+  </head>
+  <script>
+    function onloadHandler()
+    {
+      document.forms[0].appendChild(document.getElementById('i'));
+      document.documentElement.className = '';
+    }
+  </script>
+  <body onload='onloadHandler();'>
+    <input id='i' type='text' value='bar'>
+    <form>
+      <input id='j' type='text' value='foo'>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-add-valid-with-invalid-element.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<!--form with one invalid element and another valid one is added dynamically -->
+<html class='reftest-wait'>
+  <head>
+    <style>
+      form:invalid { display: none; }
+    </style>
+  </head>
+  <script>
+    function onloadHandler()
+    {
+      document.forms[0].appendChild(document.getElementById('i'));
+      document.documentElement.className = '';
+    }
+  </script>
+  <body onload='onloadHandler();'>
+    <input id='i' type='text' value='foo'>
+    <form>
+      <input id='j' type='email' value='emailfoo'>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-add-valid-with-no-element.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<!--form with no valid element and another valid one is added dynamically -->
+<html class='reftest-wait'>
+  <head>
+    <style>
+      form:invalid { display: none; }
+    </style>
+  </head>
+  <script>
+    function onloadHandler()
+    {
+      document.forms[0].appendChild(document.getElementById('i'));
+      document.documentElement.className = '';
+    }
+  </script>
+  <body onload='onloadHandler();'>
+    <input id='i' type='text' value='foo'>
+    <form>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-dynamic-invalid-barred.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<!-- form with one invalid element and dynamically made it element with
+barred constraints -->
+<html class='reftest-wait'>
+  <head>
+    <style>
+      form:invalid { display: none; }
+    </style>
+  </head>
+  <script>
+    function onloadHandler()
+    {
+      document.getElementById('i').readOnly = 'ro';
+      document.documentElement.className = '';
+    }
+  </script>
+  <body onload='onloadHandler();'>
+    <form>
+      <input id='i' required>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-dynamic-invalid-not-barred.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html class='reftest-wait'>
+  <head>
+    <style>
+      form:invalid { display: none; }
+    </style>
+  </head>
+  <script>
+    function onloadHandler()
+    {
+      document.getElementById('i').removeAttribute('readonly');
+      document.documentElement.className = '';
+    }
+  </script>
+  <body onload='onloadHandler();'>
+    <form>
+      <input id='i' required readonly>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-dynamic-invalid.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<!-- form with one invalid element which is made invalid dynamically -->
+<html class='reftest-wait'>
+  <head>
+    <style>
+      form:invalid { display: none; }
+      :-moz-ui-invalid { box-shadow: none; }
+    </style>
+  </head>
+  <script>
+    function onloadHandler()
+    {
+      document.getElementById('i').value = '';
+      document.documentElement.className = '';
+    }
+  </script>
+  <body onload='onloadHandler();'>
+    <form>
+      <input id='i' value='foo' required>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-dynamic-valid.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<!--  form with one valid element which is made valid dynamically -->
+<html>
+  <head>
+    <style>
+      form:invalid {display: none;}
+    </style>
+  </head>
+  <script>
+    function onloadHandler()
+    {
+      document.getElementById('i').value = 'foo';
+      document.documentElement.className = '';
+    }
+  </script>
+  <body onload="onloadHandler();">
+    <form>
+      <input id='i' required>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-invalid-and-barred-remove-barred.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<!-- form with one invalid element and a barred for constraint 
+validation element then you remove the second element -->
+<html class='reftest-wait'>
+  <head>
+    <style>
+      form:invalid { display: none; }
+    </style>
+  </head>
+  <script>
+    function onloadHandler()
+    {
+      document.forms[0].removeChild(document.getElementById('j'));
+      document.documentElement.className = '';
+    }
+  </script>
+  <body onload='onloadHandler();'>
+    <form>
+      <input required>
+      <input id='j' value='foo' readonly>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-invalid-and-barred.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<!-- Form with one invalid element and a barred for constraint validation element -->
+<html>
+  <head>
+    <style>
+      form:invalid { display: none; }
+    </style>
+  </head>
+ <body>
+   <form>
+    <input required>
+    <input id='i' value='foo' readonly required>
+   </form>
+ </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-invalid-barred-ref.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <form>
+      <input required readonly>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-invalid-barred.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<!-- form with invalid barred for constraint validation element -->
+<html>
+  <head>
+    <style>
+      form:invalid { display: none ;}
+    </style>
+  </head>
+  <body>
+    <form>
+      <input required readonly>
+    </form>
+  </body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-invalid-ref-2.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <form>
+      <input type='email' value='foo'>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-invalid-ref.html
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<html>
+  <body>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-remove-invalid-element.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<!-- form with one invalid element and the element is dynamically removed -->
+<html class='reftest-wait'>
+  <head>
+    <style>
+      form:invalid { display: none; }
+    </style>
+  </head>
+  <script>
+    function onloadHandler()
+    {
+      document.forms[0].removeChild(document.getElementById('i'));
+      document.documentElement.className = '';
+    }
+  </script>
+  <body onload='onloadHandler();'>
+    <form>
+      <input id='i' type='email' value='foo'>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-static-invalid-barred.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <style>
+      form:invalid { display: none; }
+    </style>
+  </head>
+  <body>
+    <form>
+      <input required readonly>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-static-invalid.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<!--form with only invalid elements -->
+<html>
+  <head>
+    <style>
+      form:invalid { display: none; }
+    </style>
+  </head>
+  <body>
+    <form>
+      <input required>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-static-valid.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<!-- form with only valid elements -->
+<html>
+ <head>
+   <style>
+     form:invalid { display: none; }
+   </style>
+ </head>
+ <body>
+   <form>
+    <input value='foo' required>
+   </form>
+ </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-valid-and-barred-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <form>
+      <input value='bar' required>
+      <input value='foo' readonly required>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-valid-and-barred-remove-barred.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<!-- form with one valid element and a barred for constraint
+validation element then you remove the second element -->
+<html class='reftest-wait'>
+  <head>
+    <style>
+      form:invalid { display: none; }
+    </style>
+  </head>
+  <script>
+    function onloadHandler()
+    {
+      document.forms[0].removeChild(document.getElementById('j'));
+      document.documentElement.className = '';
+    }
+  </script>
+  <body onload='onloadHandler();'>
+    <form>
+      <input id='i' value='foo'required>
+      <input id='j' value='bar' readonly>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-valid-and-barred.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<!-- Form with one invalid element and a barred for constraint validation element -->
+<html>
+  <head>
+    <style>
+      form:invalid { display: none; }
+    </style>
+  </head>
+ <body>
+   <form>
+    <input id='i' value='bar'required>
+    <input id='i' value='foo' readonly required>
+   </form>
+ </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-valid-ref-2.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <form>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-valid-ref-4.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <form>
+      <input type='text' value='foo'>
+      <input type='text' value='bar'>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-valid-ref.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <form>
+      <input type='text' value='foo' required>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-with-invalid-element-add-barred-dynamic.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<!-- form with one valid element and you dynamically add a barred constraint 
+validation element -->
+<html>
+  <head>
+    <style>
+      form:invalid { display:none }
+    </style>
+    <script>
+      function onLoadHandler()
+      {
+        document.forms[0].appendChild(document.getElementById('i'));
+        document.documentElement.className='';
+      }
+    </script>
+  </head>
+  <body onload='onLoadHandler();'>
+    <input id='i' value='foo' readonly>
+    <form>
+      <input required>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-with-valid-and-invalid.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<!-- form with invalid and valid elements -->
+<html>
+  <head>
+    <style>
+      form:invalid { display: none; }
+    </style>
+  </head>
+  <body>
+    <form>
+      <input id='i' value='foo'>
+      <input required>
+    <form>
+  <body>
+<html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/form-with-valid-element-add-barred-dynamic.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<!-- form with one valid element and you dynamically add a barred constraint 
+validation element -->
+<html>
+  <head>
+    <style>
+      form:invalid { display:none }
+    </style>
+    <script>
+      function onLoadHandler()
+      {
+        document.forms[0].appendChild(document.getElementById('i'));
+        document.documentElement.className='';
+      }
+    </script>
+  </head>
+  <body onload='onLoadHandler();'>
+    <input id='i' value='foo' readonly>
+    <form>
+      <input id='j' value='bar' required>
+    </form>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-invalid/form/reftest.list
@@ -0,0 +1,25 @@
+== form-static-valid.html form-valid-ref.html
+== form-dynamic-valid.html form-valid-ref.html
+== form-remove-invalid-element.html form-valid-ref-2.html
+== form-static-invalid.html form-invalid-ref.html
+== form-dynamic-invalid.html form-invalid-ref.html
+== form-add-control.html form-invalid-ref.html
+== form-dynamic-invalid-not-barred.html form-invalid-ref.html
+== form-remove-invalid-element.html form-invalid-ref.html
+== form-dynamic-invalid-barred.html form-invalid-barred-ref.html
+== form-dynamic-not-invalid-barred.html form-invalid-ref.html
+== form-static-invalid-barred.html form-invalid-barred-ref.html
+== form-add-invalid-element.html form-invalid-ref.html
+== form-add-valid-with-invalid-element.html form-invalid-ref.html
+== form-invalid-barred.html form-invalid-barred-ref.html
+== form-add-valid-element.html form-valid-ref-4.html
+== form-add-valid-with-no-element.html form-valid-ref.html
+== form-add-invalid-with-valid-element.html form-invalid-ref.html
+== form-with-valid-and-invalid.html form-invalid-ref.html
+== form-add-invalid-element-dynamic.html form-invalid-ref.html
+== form-invalid-and-barred.html form-invalid-ref.html
+== form-invalid-and-barred-remove-barred.html form-invalid-ref.html
+== form-valid-and-barred.html form-valid-and-barred-ref.html
+== form-valid-and-barred-remove-barred.html form-valid-ref.html
+== form-with-invalid-element-add-barred-dynamic.html form-invalid-ref.html
+== form-with-valid-element-add-barred-dynamic.html form-valid-and-barred-ref.html
--- a/layout/reftests/css-submit-invalid/default-style/button-submit.html
+++ b/layout/reftests/css-submit-invalid/default-style/button-submit.html
@@ -1,12 +1,12 @@
 <!DOCTYPE>
 <html class="reftest-wait">
   <style>
-    :invalid {
+    input:invalid {
       display: none;
     }
   </style>
   <script>
     function onloadHandler()
     {
       document.getElementById('e').setCustomValidity('foo');
       document.documentElement.className='';
--- a/layout/reftests/css-submit-invalid/default-style/input-image.html
+++ b/layout/reftests/css-submit-invalid/default-style/input-image.html
@@ -1,12 +1,12 @@
 <!DOCTYPE>
 <html class="reftest-wait">
   <style>
-    :invalid {
+    input:invalid {
       display: none;
     }
   </style>
   <script>
     function onloadHandler()
     {
       document.getElementById('e').setCustomValidity('foo');
       document.documentElement.className='';
--- a/layout/reftests/css-submit-invalid/default-style/input-submit.html
+++ b/layout/reftests/css-submit-invalid/default-style/input-submit.html
@@ -1,12 +1,12 @@
 <!DOCTYPE>
 <html class="reftest-wait">
   <style>
-    :invalid {
+    input:invalid {
       display: none;
     }
   </style>
   <script>
     function onloadHandler()
     {
       document.getElementById('e').setCustomValidity('foo');
       document.documentElement.className='';
--- a/mobile/android/base/AwesomeBar.java
+++ b/mobile/android/base/AwesomeBar.java
@@ -439,17 +439,17 @@ public class AwesomeBar extends Activity
         menu.setHeaderTitle(title);
     }
 
     @Override
     public boolean onContextItemSelected(MenuItem item) {
         if (mContextMenuSubject == null)
             return false;
 
-        String url = "";
+        final String url;
         byte[] b = null;
         String title = "";
         if (mContextMenuSubject instanceof Cursor) {
             Cursor cursor = (Cursor)mContextMenuSubject;
             url = cursor.getString(cursor.getColumnIndexOrThrow(URLColumns.URL));
             b = cursor.getBlob(cursor.getColumnIndexOrThrow(URLColumns.FAVICON));
             title = cursor.getString(cursor.getColumnIndexOrThrow(URLColumns.TITLE));
         } else if (mContextMenuSubject instanceof Map) {
@@ -465,19 +465,30 @@ public class AwesomeBar extends Activity
 
         switch (item.getItemId()) {
             case R.id.open_new_tab: {
                 GeckoApp.mAppContext.loadUrl(url, AwesomeBar.Type.ADD);
                 Toast.makeText(this, R.string.new_tab_opened, Toast.LENGTH_SHORT).show();
                 break;
             }
             case R.id.remove_bookmark: {
-                ContentResolver resolver = Tabs.getInstance().getContentResolver();
-                BrowserDB.removeBookmark(resolver, url);
-                Toast.makeText(this, R.string.bookmark_removed, Toast.LENGTH_SHORT).show();
+                GeckoAppShell.getHandler().post(new Runnable() {
+                    public void run() {
+                        ContentResolver resolver = Tabs.getInstance().getContentResolver();
+                        BrowserDB.removeBookmark(resolver, url);
+
+                        GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
+                            public void run() {
+                                mAwesomeTabs.refreshBookmarks();
+                                Toast.makeText(AwesomeBar.this, R.string.bookmark_removed,
+                                        Toast.LENGTH_SHORT).show();
+                            }
+                        });
+                    }
+                });
                 break;
             }
             case R.id.add_to_launcher: {
                 Bitmap bitmap = null;
                 if (b != null)
                     bitmap = BitmapFactory.decodeByteArray(b, 0, b.length);
     
                 GeckoAppShell.createShortcut(title, url, bitmap, "");
--- a/mobile/android/base/AwesomeBarTabs.java
+++ b/mobile/android/base/AwesomeBarTabs.java
@@ -742,9 +742,22 @@ public class AwesomeBarTabs extends TabH
     public void setSearchEngines(JSONArray engines) {
         mSearchEngines = engines;
         GeckoAppShell.getMainHandler().post(new Runnable() {
             public void run() {
                 mAllPagesCursorAdapter.notifyDataSetChanged();
             }
         });
     }
+
+    public void refreshBookmarks() {
+        new AsyncTask<Void, Void, Cursor>() {
+            protected Cursor doInBackground(Void... arg0) {
+                ContentResolver resolver = mContext.getContentResolver();
+                return BrowserDB.getAllBookmarks(resolver);
+            }
+
+            protected void onPostExecute(Cursor cursor) {
+                mBookmarksAdapter.changeCursor(cursor);
+            }
+        }.execute();
+    }
 }
--- a/netwerk/build/nsNetCID.h
+++ b/netwerk/build/nsNetCID.h
@@ -704,16 +704,27 @@
 #define NS_DEVICEPROTOCOLHANDLER_CID                 \
 { /* 6b0ffe9e-d114-486b-aeb7-da62e7273ed5 */         \
     0x60ffe9e,                                       \
     0xd114,                                          \
     0x486b,                                          \
     {0xae, 0xb7, 0xda, 0x62, 0xe7, 0x27, 0x3e, 0xd5} \
 }
 
+#ifdef MOZ_WIDGET_GONK
+#define NS_B2GPROTOCOLHANDLER_CLASSNAME \
+    "nsB2GProtocolHandler"
+#define NS_B2GPROTOCOLHANDLER_CID                    \
+{                                                    \
+/* {e50d101a-9db2-466f-977c-ae6af19e3b2f} */         \
+  0x50d101a, 0x9db2, 0x466f,                         \
+    {0x97, 0x7c, 0xae, 0x6a, 0xf1, 0x9e, 0x3b, 0x2f} \
+}
+#endif
+
 /******************************************************************************
  * netwerk/protocol/viewsource/ classes
  */
 
 // service implementing nsIProtocolHandler
 #define NS_VIEWSOURCEHANDLER_CID                     \
 { /* {0x9c7ec5d1-23f9-11d5-aea8-8fcc0793e97f} */     \
     0x9c7ec5d1,                                      \
--- a/netwerk/build/nsNetModule.cpp
+++ b/netwerk/build/nsNetModule.cpp
@@ -259,16 +259,20 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsHttpDig
 #include "nsResProtocolHandler.h"
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsResProtocolHandler, Init)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsResURL)
 #endif
 
 #ifdef NECKO_PROTOCOL_device
 #include "nsDeviceProtocolHandler.h"
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceProtocolHandler)
+#ifdef MOZ_WIDGET_GONK
+#include "nsB2GProtocolHandler.h"
+NS_GENERIC_FACTORY_CONSTRUCTOR(nsB2GProtocolHandler)
+#endif
 #endif
 
 #ifdef NECKO_PROTOCOL_viewsource
 #include "nsViewSourceHandler.h"
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsViewSourceHandler)
 #endif
 
 #ifdef NECKO_PROTOCOL_data
@@ -774,16 +778,19 @@ NS_DEFINE_NAMED_CID(NS_COOKIESERVICE_CID
 #ifdef NECKO_WIFI
 NS_DEFINE_NAMED_CID(NS_WIFI_MONITOR_COMPONENT_CID);
 #endif
 #ifdef NECKO_PROTOCOL_data
 NS_DEFINE_NAMED_CID(NS_DATAPROTOCOLHANDLER_CID);
 #endif
 #ifdef NECKO_PROTOCOL_device
 NS_DEFINE_NAMED_CID(NS_DEVICEPROTOCOLHANDLER_CID);
+#ifdef MOZ_WIDGET_GONK
+NS_DEFINE_NAMED_CID(NS_B2GPROTOCOLHANDLER_CID);
+#endif
 #endif
 #ifdef NECKO_PROTOCOL_viewsource
 NS_DEFINE_NAMED_CID(NS_VIEWSOURCEHANDLER_CID);
 #endif
 #ifdef NECKO_PROTOCOL_wyciwyg
 NS_DEFINE_NAMED_CID(NS_WYCIWYGPROTOCOLHANDLER_CID);
 #endif
 #ifdef NECKO_PROTOCOL_websocket
@@ -905,16 +912,19 @@ static const mozilla::Module::CIDEntry k
 #ifdef NECKO_WIFI
     { &kNS_WIFI_MONITOR_COMPONENT_CID, false, NULL, nsWifiMonitorConstructor },
 #endif
 #ifdef NECKO_PROTOCOL_data
     { &kNS_DATAPROTOCOLHANDLER_CID, false, NULL, nsDataHandler::Create },
 #endif
 #ifdef NECKO_PROTOCOL_device
     { &kNS_DEVICEPROTOCOLHANDLER_CID, false, NULL, nsDeviceProtocolHandlerConstructor},
+#ifdef MOZ_WIDGET_GONK
+    { &kNS_B2GPROTOCOLHANDLER_CID, false, NULL, nsB2GProtocolHandlerConstructor},
+#endif
 #endif
 #ifdef NECKO_PROTOCOL_viewsource
     { &kNS_VIEWSOURCEHANDLER_CID, false, NULL, nsViewSourceHandlerConstructor },
 #endif
 #ifdef NECKO_PROTOCOL_wyciwyg
     { &kNS_WYCIWYGPROTOCOLHANDLER_CID, false, NULL, nsWyciwygProtocolHandlerConstructor },
 #endif
 #ifdef NECKO_PROTOCOL_websocket
@@ -1045,16 +1055,19 @@ static const mozilla::Module::ContractID
 #ifdef NECKO_WIFI
     { NS_WIFI_MONITOR_CONTRACTID, &kNS_WIFI_MONITOR_COMPONENT_CID },
 #endif
 #ifdef NECKO_PROTOCOL_data
     { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "data", &kNS_DATAPROTOCOLHANDLER_CID },
 #endif
 #ifdef NECKO_PROTOCOL_device
     { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "moz-device", &kNS_DEVICEPROTOCOLHANDLER_CID },
+#ifdef MOZ_WIDGET_GONK
+    { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "b2g-camera", &kNS_B2GPROTOCOLHANDLER_CID },
+#endif
 #endif
 #ifdef NECKO_PROTOCOL_viewsource
     { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "view-source", &kNS_VIEWSOURCEHANDLER_CID },
 #endif
 #ifdef NECKO_PROTOCOL_wyciwyg
     { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "wyciwyg", &kNS_WYCIWYGPROTOCOLHANDLER_CID },
 #endif
 #ifdef NECKO_PROTOCOL_websocket
--- a/netwerk/protocol/device/Makefile.in
+++ b/netwerk/protocol/device/Makefile.in
@@ -61,16 +61,17 @@ EXPORTS_NAMESPACES = mozilla/net
 EXPORTS_mozilla/net += \
   CameraStreamImpl.h  \
   $(NULL)
 
 endif
 
 ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
 CPPSRCS += GonkCaptureProvider.cpp \
+           nsB2GProtocolHandler.cpp \
            $(NULL)
 endif
 
 LOCAL_INCLUDES = -I$(srcdir)/../../base/src/ \
                  $(NULL)
 
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
new file mode 100644
--- /dev/null
+++ b/netwerk/protocol/device/nsB2GProtocolHandler.cpp
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Camera.
+ *
+ * The Initial Developer of the Original Code is Mozilla Corporation
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *  Nino D'Aversa <ninodaversa@gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "nsB2GProtocolHandler.h"
+#include "nsDeviceChannel.h"
+#include "nsNetCID.h"
+#include "nsAutoPtr.h"
+#include "nsCOMPtr.h"
+#include "nsSimpleURI.h"
+#include "mozilla/Preferences.h"
+//-----------------------------------------------------------------------------
+
+NS_IMPL_THREADSAFE_ISUPPORTS1(nsB2GProtocolHandler,
+                              nsIProtocolHandler)
+
+nsresult
+nsB2GProtocolHandler::Init(){
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsB2GProtocolHandler::GetScheme(nsACString &aResult)
+{
+  aResult.AssignLiteral("b2g-camera");
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsB2GProtocolHandler::GetDefaultPort(PRInt32 *aResult)
+{
+  *aResult = -1;        // no port for b2g-camera: URLs
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsB2GProtocolHandler::GetProtocolFlags(PRUint32 *aResult)
+{
+  *aResult = URI_NORELATIVE | URI_NOAUTH | URI_LOADABLE_BY_ANYONE | URI_IS_LOCAL_RESOURCE;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsB2GProtocolHandler::NewURI(const nsACString &spec,
+                                const char *originCharset,
+                                nsIURI *baseURI,
+                                nsIURI **result)
+{
+  nsRefPtr<nsSimpleURI> uri = new nsSimpleURI();
+  nsresult rv;
+
+  // XXX get the "real" uri from the pref
+  // should use ipdl when we'll use e10s
+  nsCString key("b2g.camera.");
+  key.Append(spec);
+  nsCString pref;
+  rv = mozilla::Preferences::GetCString(key.get(), &pref);
+  NS_ENSURE_SUCCESS(rv, rv);
+  rv = uri->SetSpec(pref);
+  mozilla::Preferences::ClearUser(key.BeginReading());
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  return CallQueryInterface(uri, result);
+}
+
+NS_IMETHODIMP
+nsB2GProtocolHandler::NewChannel(nsIURI* aURI, nsIChannel **aResult)
+{
+  nsRefPtr<nsDeviceChannel> channel = new nsDeviceChannel();
+  nsresult rv = channel->Init(aURI);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  return CallQueryInterface(channel, aResult);
+}
+
+NS_IMETHODIMP 
+nsB2GProtocolHandler::AllowPort(PRInt32 port,
+                                   const char *scheme,
+                                   bool *aResult)
+{
+  // don't override anything.  
+  *aResult = false;
+  return NS_OK;
+}
new file mode 100644
--- /dev/null
+++ b/netwerk/protocol/device/nsB2GProtocolHandler.h
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Camera.
+ *
+ * The Initial Developer of the Original Code is Mozilla Corporation
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *  Nino D'Aversa <ninodaversa@gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsB2GProtocolHandler_h_
+#define nsB2GProtocolHandler_h_
+
+#include "nsIProtocolHandler.h"
+#include "nsString.h"
+
+// {e50d101a-9db2-466f-977c-ae6af19e3b2f}
+#define NS_B2GPROTOCOLHANDLER_CID                      \
+{ 0x50d101a, 0x9db2, 0x466f,                              \
+    {0x97, 0x7c, 0xae, 0x6a, 0xf1, 0x9e, 0x3b, 0x2f} }
+
+class nsB2GProtocolHandler : public nsIProtocolHandler {
+public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSIPROTOCOLHANDLER
+
+  nsB2GProtocolHandler() {}
+  ~nsB2GProtocolHandler() {}
+
+  nsresult Init();
+};
+
+#endif
--- a/toolkit/components/places/PlacesCategoriesStarter.js
+++ b/toolkit/components/places/PlacesCategoriesStarter.js
@@ -124,16 +124,18 @@ PlacesCategoriesStarter.prototype = {
     }
   },
 
   //////////////////////////////////////////////////////////////////////////////
   //// nsISupports
 
   classID: Components.ID("803938d5-e26d-4453-bf46-ad4b26e41114"),
 
+  _xpcom_factory: XPCOMUtils.generateSingletonFactory(PlacesCategoriesStarter),
+
   QueryInterface: XPCOMUtils.generateQI([
     Ci.nsIObserver
   , Ci.nsINavBookmarkObserver
   ])
 };
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Module Registration
--- a/toolkit/components/places/PlacesDBUtils.jsm
+++ b/toolkit/components/places/PlacesDBUtils.jsm
@@ -293,17 +293,17 @@ let PlacesDBUtils = {
    * @param [optional] aTasks
    *        Tasks object to execute.
    */
   checkCoherence: function PDBU_checkCoherence(aTasks)
   {
     let tasks = new Tasks(aTasks);
     tasks.log("> Coherence check");
 
-    let stmts = this._getBoundCoherenceStatements();
+    let stmts = PlacesDBUtils._getBoundCoherenceStatements();
     DBConn.executeAsync(stmts, stmts.length, {
       handleError: PlacesDBUtils._handleError,
       handleResult: function () {},
 
       handleCompletion: function (aReason)
       {
         if (aReason == Ci.mozIStorageStatementCallback.REASON_FINISHED) {
           tasks.log("+ The database is coherent");
@@ -955,17 +955,32 @@ let PlacesDBUtils = {
         query:     "PRAGMA page_count",
         callback: function (aDbPageCount) {
           // Note that the database file size would not be meaningful for this
           // calculation, because the file grows in fixed-size chunks.
           let dbPageSize = probeValues.PLACES_DATABASE_PAGESIZE_B;
           let placesPageCount = probeValues.PLACES_PAGES_COUNT;
           return Math.round((dbPageSize * aDbPageCount) / placesPageCount);
         }
-      }
+      },
+
+      { histogram: "PLACES_ANNOS_BOOKMARKS_COUNT",
+        query:     "SELECT count(*) FROM moz_items_annos" },
+
+      // LENGTH is not a perfect measure, since it returns the number of bytes
+      // only for BLOBs, the number of chars for anything else.  Though it's
+      // the best approximation we have.
+      { histogram: "PLACES_ANNOS_BOOKMARKS_SIZE_KB",
+        query:     "SELECT SUM(LENGTH(content))/1024 FROM moz_items_annos" },
+
+      { histogram: "PLACES_ANNOS_PAGES_COUNT",
+        query:     "SELECT count(*) FROM moz_annos" },
+
+      { histogram: "PLACES_ANNOS_PAGES_SIZE_KB",
+        query:     "SELECT SUM(LENGTH(content))/1024 FROM moz_annos" },
     ];
 
     let params = {
       tags_folder: PlacesUtils.tagsFolderId,
       type_folder: PlacesUtils.bookmarks.TYPE_FOLDER,
       type_bookmark: PlacesUtils.bookmarks.TYPE_BOOKMARK,
       places_root: PlacesUtils.placesRootId
     };
@@ -1011,31 +1026,50 @@ let PlacesDBUtils = {
       } finally{
         stmt.finalize();
       }
     }
 
     PlacesDBUtils._executeTasks(tasks);
   },
 
+  /**
+   * Runs a list of tasks, notifying log messages to the callback.
+   *
+   * @param aTasks
+   *        Array of tasks to be executed, in form of pointers to methods in
+   *        this module.
+   * @param [optional] aCallback
+   *        Callback to be invoked when done.  It will receive an array of
+   *        log messages.  If not specified the log will be printed to the
+   *        Error Console.
+   */
+  runTasks: function PDBU_runTasks(aTasks, aCallback) {
+    let tasks = new Tasks(aTasks);
+    tasks.callback = aCallback;
+    PlacesDBUtils._executeTasks(tasks);
+  }
 };
 
 /**
  * LIFO tasks stack.
  *
  * @param [optional] aTasks
  *        Array of tasks or another Tasks object to clone.
  */
 function Tasks(aTasks)
 {
   if (aTasks) {
     if (Array.isArray(aTasks)) {
       this._list = aTasks.slice(0, aTasks.length);
     }
-    else if (typeof(aTasks) == "object" && aTasks instanceof Tasks) {
+    // This supports passing in a Tasks-like object, with a "list" property,
+    // for compatibility reasons.
+    else if (typeof(aTasks) == "object" &&
+             (Tasks instanceof Tasks || "list" in aTasks)) {
       this._list = aTasks.list;
       this._log = aTasks.messages;
       this.callback = aTasks.callback;
       this.scope = aTasks.scope;
       this._telemetryStart = aTasks._telemetryStart;
     }
   }
 }
--- a/toolkit/components/places/PlacesUtils.jsm
+++ b/toolkit/components/places/PlacesUtils.jsm
@@ -1,9 +1,9 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* ***** BEGIN LICENSE BLOCK *****
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  *
  * The contents of this file are subject to the Mozilla Public License Version
  * 1.1 (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  * http://www.mozilla.org/MPL/
  *
--- a/toolkit/components/places/SQLFunctions.cpp
+++ b/toolkit/components/places/SQLFunctions.cpp
@@ -46,16 +46,18 @@
 #include "nsMathUtils.h"
 #include "nsUTF8Utils.h"
 #include "nsINavHistoryService.h"
 #include "nsPrintfCString.h"
 #include "nsNavHistory.h"
 #if defined(XP_OS2)
 #include "nsIRandomGenerator.h"
 #endif
+#include "mozilla/Telemetry.h"
+
 using namespace mozilla::storage;
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Anonymous Helpers
 
 namespace {
 
   typedef nsACString::const_char_iterator const_char_iterator;
@@ -462,16 +464,18 @@ namespace places {
                                             nsIVariant **_result)
   {
     // Fetch arguments.  Use default values if they were omitted.
     PRUint32 numEntries;
     nsresult rv = aArguments->GetNumEntries(&numEntries);
     NS_ENSURE_SUCCESS(rv, rv);
     NS_ASSERTION(numEntries > 0, "unexpected number of arguments");
 
+    Telemetry::AutoTimer<Telemetry::PLACES_FRECENCY_CALC_TIME_MS> timer;
+
     PRInt64 pageId = aArguments->AsInt64(0);
     PRInt32 typed = numEntries > 1 ? aArguments->AsInt32(1) : 0;
     PRInt32 fullVisitCount = numEntries > 2 ? aArguments->AsInt32(2) : 0;
     PRInt64 bookmarkId = numEntries > 3 ? aArguments->AsInt64(3) : 0;
     PRInt32 visitCount = 0;
     PRInt32 hidden = 0;
     PRInt32 isQuery = 0;
     float pointsForSampledVisits = 0.0;
--- a/toolkit/components/places/nsLivemarkService.js
+++ b/toolkit/components/places/nsLivemarkService.js
@@ -354,19 +354,23 @@ LivemarkService.prototype = {
     if (!this.isLivemark(aItemId)) {
       return;
     }
 
     this._livemarks[aItemId].terminate();
     delete this._livemarks[aItemId];
   },
 
-  // nsISupports
+  //////////////////////////////////////////////////////////////////////////////
+  //// nsISupports
+
   classID: Components.ID("{dca61eb5-c7cd-4df1-b0fb-d0722baba251}"),
 
+  _xpcom_factory: XPCOMUtils.generateSingletonFactory(LivemarkService),
+
   QueryInterface: XPCOMUtils.generateQI([
     Ci.nsILivemarkService
   , Ci.nsINavBookmarkObserver
   , Ci.nsIObserver
   ])
 };
 
 /**
--- a/toolkit/components/places/nsNavHistory.cpp
+++ b/toolkit/components/places/nsNavHistory.cpp
@@ -3928,16 +3928,18 @@ nsNavHistory::DecayFrecency()
 {
   nsresult rv = FixInvalidFrecencies();
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Globally decay places frecency rankings to estimate reduced frecency
   // values of pages that haven't been visited for a while, i.e., they do
   // not get an updated frecency.  A scaling factor of .975 results in .5 the
   // original value after 28 days.
+  // When changing the scaling factor, ensure that the barrier in
+  // moz_places_afterupdate_frecency_trigger still ignores these changes.
   nsCOMPtr<mozIStorageAsyncStatement> decayFrecency = mDB->GetAsyncStatement(
     "UPDATE moz_places SET frecency = ROUND(frecency * .975) "
     "WHERE frecency > 0"
   );
   NS_ENSURE_STATE(decayFrecency);
 
   // Decay potentially unused adaptive entries (e.g. those that are at 1)
   // to allow better chances for new entries that will start at 1.
--- a/toolkit/components/places/nsPlacesAutoComplete.js
+++ b/toolkit/components/places/nsPlacesAutoComplete.js
@@ -1257,16 +1257,18 @@ nsPlacesAutoComplete.prototype = {
     return this._pendingQuery == aHandle;
   },
 
   //////////////////////////////////////////////////////////////////////////////
   //// nsISupports
 
   classID: Components.ID("d0272978-beab-4adc-a3d4-04b76acfa4e7"),
 
+  _xpcom_factory: XPCOMUtils.generateSingletonFactory(nsPlacesAutoComplete),
+
   QueryInterface: XPCOMUtils.generateQI([
     Ci.nsIAutoCompleteSearch,
     Ci.nsIAutoCompleteSimpleResultListener,
     Ci.mozIPlacesAutoComplete,
     Ci.mozIStorageStatementCallback,
     Ci.nsIObserver,
     Ci.nsISupportsWeakReference,
   ])
@@ -1573,16 +1575,18 @@ urlInlineComplete.prototype = {
     return this._pendingQuery == aHandle;
   },
 
   //////////////////////////////////////////////////////////////////////////////
   //// nsISupports
 
   classID: Components.ID("c88fae2d-25cf-4338-a1f4-64a320ea7440"),
 
+  _xpcom_factory: XPCOMUtils.generateSingletonFactory(urlInlineComplete),
+
   QueryInterface: XPCOMUtils.generateQI([
     Ci.nsIAutoCompleteSearch,
     Ci.mozIStorageStatementCallback,
     Ci.nsIObserver,
     Ci.nsISupportsWeakReference,
   ])
 };
 
--- a/toolkit/components/places/nsPlacesExpiration.js
+++ b/toolkit/components/places/nsPlacesExpiration.js
@@ -56,33 +56,16 @@
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 
 ////////////////////////////////////////////////////////////////////////////////
-//// nsIFactory
-
-const nsPlacesExpirationFactory = {
-  _instance: null,
-  createInstance: function(aOuter, aIID) {
-    if (aOuter != null)
-      throw Components.results.NS_ERROR_NO_AGGREGATION;
-    return this._instance === null ? this._instance = new nsPlacesExpiration() :
-                                     this._instance;
-  },
-  lockFactory: function (aDoLock) {},
-  QueryInterface: XPCOMUtils.generateQI([
-    Ci.nsIFactory
-  ]),
-};
-
-////////////////////////////////////////////////////////////////////////////////
 //// Constants
 
 // Last expiration step should run before the final sync.
 const TOPIC_SHUTDOWN = "places-will-close-connection";
 const TOPIC_PREF_CHANGED = "nsPref:changed";
 const TOPIC_DEBUG_START_EXPIRATION = "places-debug-start-expiration";
 const TOPIC_EXPIRATION_FINISHED = "places-expiration-finished";
 const TOPIC_IDLE_BEGIN = "idle";
@@ -1026,23 +1009,23 @@ nsPlacesExpiration.prototype = {
     return this._timer = timer;
   },
 
   //////////////////////////////////////////////////////////////////////////////
   //// nsISupports
 
   classID: Components.ID("705a423f-2f69-42f3-b9fe-1517e0dee56f"),
 
-  _xpcom_factory: nsPlacesExpirationFactory,
+  _xpcom_factory: XPCOMUtils.generateSingletonFactory(nsPlacesExpiration),
 
   QueryInterface: XPCOMUtils.generateQI([
-    Ci.nsIObserver,
-    Ci.nsINavHistoryObserver,
-    Ci.nsITimerCallback,
-    Ci.mozIStorageStatementCallback,
+    Ci.nsIObserver
+  , Ci.nsINavHistoryObserver
+  , Ci.nsITimerCallback
+  , Ci.mozIStorageStatementCallback
   ])
 };
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Module Registration
 
 let components = [nsPlacesExpiration];
 var NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
--- a/toolkit/components/places/nsPlacesTriggers.h
+++ b/toolkit/components/places/nsPlacesTriggers.h
@@ -101,23 +101,33 @@
   "AFTER DELETE ON moz_places FOR EACH ROW " \
   "BEGIN " \
     "DELETE FROM moz_hosts " \
     "WHERE host = fixup_url(get_unreversed_host(OLD.rev_host)) " \
       "AND NOT EXISTS(SELECT 1 FROM moz_places WHERE rev_host = OLD.rev_host); " \
   "END" \
 )
 
+// For performance reasons the host frecency is updated only when the page
+// frecency changes by a meaningful percentage.  This is because the frecency
+// decay algorithm requires to update all the frecencies at once, causing a
+// too high overhead, while leaving the ordering unchanged.
 #define CREATE_PLACES_AFTERUPDATE_TRIGGER NS_LITERAL_CSTRING( \
   "CREATE TEMP TRIGGER moz_places_afterupdate_frecency_trigger " \
   "AFTER UPDATE OF frecency ON moz_places FOR EACH ROW " \
   "WHEN NEW.frecency >= 0 " \
+    "AND ABS(" \
+      "IFNULL((NEW.frecency - OLD.frecency) / CAST(NEW.frecency AS REAL), " \
+             "(NEW.frecency - OLD.frecency))" \
+    ") > .05 " \
   "BEGIN " \
     "UPDATE moz_hosts " \
-    "SET frecency = (SELECT MAX(frecency) FROM moz_places WHERE rev_host = NEW.rev_host OR rev_host = NEW.rev_host || 'www.') " \
+    "SET frecency = (SELECT MAX(frecency) FROM moz_places " \
+                    "WHERE rev_host = NEW.rev_host " \
+                       "OR rev_host = NEW.rev_host || 'www.') " \
     "WHERE host = fixup_url(get_unreversed_host(NEW.rev_host)); " \
   "END" \
 )
 
 /**
  * This trigger removes a row from moz_openpages_temp when open_count reaches 0.
  *
  * @note this should be kept up-to-date with the definition in
--- a/toolkit/components/places/nsTaggingService.js
+++ b/toolkit/components/places/nsTaggingService.js
@@ -467,19 +467,23 @@ TaggingService.prototype = {
       delete this._tagFolders[aItemId];
   },
 
   onItemVisited: function () {},
   onBeforeItemRemoved: function () {},
   onBeginUpdateBatch: function () {},
   onEndUpdateBatch: function () {},
 
-  // nsISupports
+  //////////////////////////////////////////////////////////////////////////////
+  //// nsISupports
+
   classID: Components.ID("{bbc23860-2553-479d-8b78-94d9038334f7}"),
-  
+
+  _xpcom_factory: XPCOMUtils.generateSingletonFactory(TaggingService),
+
   QueryInterface: XPCOMUtils.generateQI([
     Ci.nsITaggingService
   , Ci.nsINavBookmarkObserver
   , Ci.nsIObserver
   ])
 };
 
 
@@ -692,18 +696,22 @@ TagAutoCompleteSearch.prototype = {
 
   /**
    * Stop an asynchronous search that is in progress
    */
   stopSearch: function PTACS_stopSearch() {
     this._stopped = true;
   },
 
-  // nsISupports
+  //////////////////////////////////////////////////////////////////////////////
+  //// nsISupports
+
+  classID: Components.ID("{1dcc23b0-d4cb-11dc-9ad6-479d56d89593}"),
+
+  _xpcom_factory: XPCOMUtils.generateSingletonFactory(TagAutoCompleteSearch),
+
   QueryInterface: XPCOMUtils.generateQI([
     Ci.nsIAutoCompleteSearch
-  ]),
-
-  classID: Components.ID("{1dcc23b0-d4cb-11dc-9ad6-479d56d89593}")
+  ])
 };
 
 let component = [TaggingService, TagAutoCompleteSearch];
 var NSGetFactory = XPCOMUtils.generateNSGetFactory(component);
new file mode 100644
--- /dev/null
+++ b/toolkit/components/places/tests/unit/test_preventive_maintenance_runTasks.js
@@ -0,0 +1,46 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+ /**
+  * Test preventive maintenance runTasks.
+  */
+
+// Include PlacesDBUtils module.
+Components.utils.import("resource://gre/modules/PlacesDBUtils.jsm");
+
+function run_test() {
+  do_test_pending();
+  PlacesDBUtils.runTasks([PlacesDBUtils.reindex], function(aLog) {
+    let sections = [];
+    let positives = [];
+    let negatives = [];
+    let infos = [];
+
+    aLog.forEach(function (aMsg) {
+      print (aMsg);
+      switch (aMsg.substr(0, 1)) {
+        case "+":
+          positives.push(aMsg);
+          break;
+        case "-":
+          negatives.push(aMsg);
+          break;
+        case ">":
+          sections.push(aMsg);
+          break;
+        default:
+          infos.push(aMsg);
+      }
+    });
+
+    print("Check that we have run all sections.");
+    do_check_eq(sections.length, 1);
+    print("Check that we have no negatives.");
+    do_check_false(!!negatives.length);
+    print("Check that we have positives.");
+    do_check_true(!!positives.length);
+
+    do_test_finished();
+  });
+}
--- a/toolkit/components/places/tests/unit/test_telemetry.js
+++ b/toolkit/components/places/tests/unit/test_telemetry.js
@@ -17,16 +17,21 @@ let histograms = {
   // The journal may have been truncated.
   PLACES_DATABASE_JOURNALSIZE_MB: function (val) do_check_true(val >= 0),
   PLACES_DATABASE_PAGESIZE_B: function (val) do_check_eq(val, 32768),
   PLACES_DATABASE_SIZE_PER_PAGE_B: function (val) do_check_true(val > 0),
   PLACES_EXPIRATION_STEPS_TO_CLEAN: function (val) do_check_true(val > 1),
   //PLACES_AUTOCOMPLETE_1ST_RESULT_TIME_MS:  function (val) do_check_true(val > 1),
   PLACES_IDLE_FRECENCY_DECAY_TIME_MS: function (val) do_check_true(val > 0),
   PLACES_IDLE_MAINTENANCE_TIME_MS: function (val) do_check_true(val > 0),
+  PLACES_ANNOS_BOOKMARKS_COUNT: function (val) do_check_eq(val, 1),
+  PLACES_ANNOS_BOOKMARKS_SIZE_KB: function (val) do_check_eq(val, 1),
+  PLACES_ANNOS_PAGES_COUNT: function (val) do_check_eq(val, 1),
+  PLACES_ANNOS_PAGES_SIZE_KB: function (val) do_check_eq(val, 1),
+  PLACES_FRECENCY_CALC_TIME_MS: function (val) do_check_true(val >= 0),
 }
 
 function run_test() {
   do_test_pending();
 
   // Put some trash in the database.
   const URI = NetUtil.newURI("http://moz.org/");
 
@@ -35,16 +40,26 @@ function run_test() {
                                                     PlacesUtils.bookmarks.DEFAULT_INDEX);
   let itemId = PlacesUtils.bookmarks.insertBookmark(folderId,
                                                     uri,
                                                     PlacesUtils.bookmarks.DEFAULT_INDEX,
                                                     "moz test");
   PlacesUtils.tagging.tagURI(uri, ["tag"]);
   PlacesUtils.bookmarks.setKeywordForBookmark(itemId, "keyword");
 
+  // Set a large annotation.
+  let content = "";
+  while (content.length < 1024) {
+    content += "0";
+  }
+  PlacesUtils.annotations.setItemAnnotation(itemId, "test-anno", content, 0,
+                                            PlacesUtils.annotations.EXPIRE_NEVER);
+  PlacesUtils.annotations.setPageAnnotation(uri, "test-anno", content, 0,
+                                            PlacesUtils.annotations.EXPIRE_NEVER);
+
   // Request to gather telemetry data.
   Cc["@mozilla.org/places/categoriesStarter;1"]
     .getService(Ci.nsIObserver)
     .observe(null, "gather-telemetry", null);
 
   waitForAsyncUpdates(continue_test);
 }
 
@@ -107,12 +122,14 @@ function continue_test() {
     check_telemetry();
   }, "places-maintenance-finished", false);
 }
 
 function check_telemetry() {
   for (let histogramId in histograms) {
     do_log_info("checking histogram " + histogramId);
     let validate = histograms[histogramId];
-    validate(Services.telemetry.getHistogramById(histogramId).snapshot().sum);
+    let snapshot = Services.telemetry.getHistogramById(histogramId).snapshot();
+    validate(snapshot.sum);
+    do_check_true(snapshot.counts.reduce(function(a, b) a + b) > 0);
   }
   do_test_finished();
 }
--- a/toolkit/components/places/tests/unit/xpcshell.ini
+++ b/toolkit/components/places/tests/unit/xpcshell.ini
@@ -107,16 +107,17 @@ fail-if = os == "android"
 [test_placeURIs.js]
 [test_preventive_maintenance.js]
 # Bug 676989: test hangs consistently on Android
 skip-if = os == "android"
 [test_preventive_maintenance_checkAndFixDatabase.js]
 # Bug 676989: test hangs consistently on Android
 skip-if = os == "android"
 [test_preventive_maintenance_console.js]
+[test_preventive_maintenance_runTasks.js]
 [test_removeVisitsByTimeframe.js]
 # Bug 676989: test hangs consistently on Android
 skip-if = os == "android"
 [test_resolveNullBookmarkTitles.js]
 [test_result_sort.js]
 [test_sql_guid_functions.js]
 [test_tag_autocomplete_search.js]
 [test_tagging.js]
--- a/toolkit/components/telemetry/TelemetryHistograms.h
+++ b/toolkit/components/telemetry/TelemetryHistograms.h
@@ -284,16 +284,21 @@ HISTOGRAM(PLACES_TAGGED_BOOKMARKS_PERC, 
 HISTOGRAM(PLACES_DATABASE_FILESIZE_MB, 5, 200, 10, EXPONENTIAL, "PLACES: Database filesize (MB)")
 HISTOGRAM(PLACES_DATABASE_JOURNALSIZE_MB, 1, 50, 10, EXPONENTIAL, "PLACES: Database journal size (MB)")
 HISTOGRAM(PLACES_DATABASE_PAGESIZE_B, 1024, 32768, 10, EXPONENTIAL, "PLACES: Database page size (bytes)")
 HISTOGRAM(PLACES_DATABASE_SIZE_PER_PAGE_B, 500, 10240, 20, EXPONENTIAL, "PLACES: Average size of a place in the database (bytes)")
 HISTOGRAM(PLACES_EXPIRATION_STEPS_TO_CLEAN, 1, 10, 10, LINEAR, "PLACES: Expiration steps to cleanup the database")
 HISTOGRAM(PLACES_AUTOCOMPLETE_1ST_RESULT_TIME_MS, 50, 500, 10, EXPONENTIAL, "PLACES: Time for first autocomplete result if > 50ms (ms)")
 HISTOGRAM(PLACES_IDLE_FRECENCY_DECAY_TIME_MS, 50, 10000, 10, EXPONENTIAL, "PLACES: Time to decay all frecencies values on idle (ms)")
 HISTOGRAM(PLACES_IDLE_MAINTENANCE_TIME_MS, 1000, 30000, 10, EXPONENTIAL, "PLACES: Time to execute maintenance tasks on idle (ms)")
+HISTOGRAM(PLACES_ANNOS_BOOKMARKS_COUNT, 50, 5000, 10, EXPONENTIAL, "PLACES: Number of bookmarks annotations")
+HISTOGRAM(PLACES_ANNOS_BOOKMARKS_SIZE_KB, 10, 10000, 10, EXPONENTIAL, "PLACES: Size of bookmarks annotations (KB)")
+HISTOGRAM(PLACES_ANNOS_PAGES_COUNT, 50, 5000, 10, EXPONENTIAL, "PLACES: Number of pages annotations")
+HISTOGRAM(PLACES_ANNOS_PAGES_SIZE_KB, 10, 10000, 10, EXPONENTIAL, "PLACES: Size of pages annotations (KB)")
+HISTOGRAM(PLACES_FRECENCY_CALC_TIME_MS, 1, 100, 10, EXPONENTIAL, "PLACES: Time to calculate frecency of a page (ms)")
 
 /**
  * Updater telemetry.
  */
 HISTOGRAM(UPDATE_STATUS, 1, 16006, 27, LINEAR, "Updater: the status of the latest update performed")
 
 /**
  * Thunderbird-specific telemetry.
--- a/toolkit/themes/pinstripe/global/jar.mn
+++ b/toolkit/themes/pinstripe/global/jar.mn
@@ -88,17 +88,16 @@ toolkit.jar:
   skin/classic/global/icons/autocomplete-dropmarker.png              (icons/autocomplete-dropmarker.png)
   skin/classic/global/icons/autoscroll.png                           (icons/autoscroll.png)
   skin/classic/global/icons/blacklist_favicon.png                    (icons/blacklist_favicon.png)
   skin/classic/global/icons/blacklist_64.png                         (icons/blacklist_64.png)
   skin/classic/global/icons/chevron.png                              (icons/chevron.png)
   skin/classic/global/icons/checkbox.png                             (icons/checkbox.png)
   skin/classic/global/icons/close-sidebar.png                        (icons/close-sidebar.png)
   skin/classic/global/icons/close.png                                (icons/close.png)
-  skin/classic/global/icons/commandline.png                          (icons/commandline.png)
   skin/classic/global/icons/information-16.png                       (icons/information-16.png)
   skin/classic/global/icons/information-24.png                       (icons/information-24.png)
   skin/classic/global/icons/information-32.png                       (icons/information-32.png)
   skin/classic/global/icons/information-64.png                       (icons/information-64.png)
   skin/classic/global/icons/information-large.png                    (icons/information-large.png)
   skin/classic/global/icons/loading_16.png                           (icons/loading_16.png)
   skin/classic/global/icons/menulist-dropmarker.png                  (icons/menulist-dropmarker.png)
   skin/classic/global/icons/notloading_16.png                        (icons/notloading_16.png)
--- a/toolkit/themes/winstripe/global/jar.mn
+++ b/toolkit/themes/winstripe/global/jar.mn
@@ -95,17 +95,16 @@ toolkit.jar:
         skin/classic/global/dirListing/up.png                    (dirListing/up.png)
         skin/classic/global/Filepicker.png                       (filepicker/Filepicker.png)
         skin/classic/global/icons/autoscroll.png                 (icons/autoscroll.png)
         skin/classic/global/icons/blacklist_favicon.png          (icons/blacklist_favicon.png)
         skin/classic/global/icons/blacklist_large.png            (icons/blacklist_large.png)
         skin/classic/global/icons/Close.gif                      (icons/Close.gif)
         skin/classic/global/icons/close.png                      (icons/close.png)
         skin/classic/global/icons/collapse.png                   (icons/collapse.png)
-        skin/classic/global/icons/commandline.png                (icons/commandline.png)
         skin/classic/global/icons/Error.png                      (icons/Error.png)
         skin/classic/global/icons/error-16.png                   (icons/error-16.png)
         skin/classic/global/icons/error-24.png                   (icons/error-24.png)
         skin/classic/global/icons/error-48.png                   (icons/error-48.png)
         skin/classic/global/icons/error-64.png                   (icons/error-64.png)
         skin/classic/global/icons/expand.png                     (icons/expand.png)
         skin/classic/global/icons/find.png                       (icons/find.png)
         skin/classic/global/icons/folder-item.png                (icons/folder-item.png)
@@ -271,17 +270,16 @@ toolkit.jar:
         skin/classic/aero/global/dirListing/up.png                       (dirListing/up-aero.png)
         skin/classic/aero/global/Filepicker.png                          (filepicker/Filepicker.png)
         skin/classic/aero/global/icons/autoscroll.png                    (icons/autoscroll-aero.png)
         skin/classic/aero/global/icons/blacklist_favicon.png             (icons/blacklist_favicon-aero.png)
         skin/classic/aero/global/icons/blacklist_large.png               (icons/blacklist_large-aero.png)
         skin/classic/aero/global/icons/Close.gif                         (icons/Close.gif)
         skin/classic/aero/global/icons/close.png                         (icons/close.png)
         skin/classic/aero/global/icons/collapse.png                      (icons/collapse.png)
-        skin/classic/aero/global/icons/commandline.png                   (icons/commandline.png)
         skin/classic/aero/global/icons/Error.png                         (icons/Error-aero.png)
         skin/classic/aero/global/icons/error-16.png                      (icons/error-16-aero.png)
         skin/classic/aero/global/icons/error-24.png                      (icons/error-24-aero.png)
         skin/classic/aero/global/icons/error-48.png                      (icons/error-48-aero.png)
         skin/classic/aero/global/icons/error-64.png                      (icons/error-64-aero.png)
         skin/classic/aero/global/icons/expand.png                        (icons/expand.png)
         skin/classic/aero/global/icons/find.png                          (icons/find-aero.png)
         skin/classic/aero/global/icons/folder-item.png                   (icons/folder-item-aero.png)
--- a/widget/windows/nsIMM32Handler.cpp
+++ b/widget/windows/nsIMM32Handler.cpp
@@ -600,20 +600,42 @@ nsIMM32Handler::OnIMEEndComposition(nsWi
   PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
     ("IMM32: OnIMEEndComposition, hWnd=%08x, mIsComposing=%s\n",
      aWindow->GetWindowHandle(), mIsComposing ? "TRUE" : "FALSE"));
 
   if (!mIsComposing) {
     return ShouldDrawCompositionStringOurselves();
   }
 
-  // IME on Korean NT somehow send WM_IME_ENDCOMPOSITION
-  // first when we hit space in composition mode
-  // we need to clear out the current composition string
-  // in that case.
+  // Korean IME posts WM_IME_ENDCOMPOSITION first when we hit space during
+  // composition. Then, we should ignore the message and commit the composition
+  // string at following WM_IME_COMPOSITION.
+  MSG compositionMsg;
+  if (::PeekMessageW(&compositionMsg, aWindow->GetWindowHandle(),
+                     WM_IME_STARTCOMPOSITION, WM_IME_COMPOSITION,
+                     PM_NOREMOVE) &&
+      compositionMsg.message == WM_IME_COMPOSITION &&
+      IS_COMMITTING_LPARAM(compositionMsg.lParam)) {
+    PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
+      ("IMM32: OnIMEEndComposition, WM_IME_ENDCOMPOSITION is followed by "
+       "WM_IME_COMPOSITION, ignoring the message..."));
+    return ShouldDrawCompositionStringOurselves();
+  }
+
+  // Otherwise, e.g., ChangJie doesn't post WM_IME_COMPOSITION before
+  // WM_IME_ENDCOMPOSITION when composition string becomes empty.
+  // Then, we should dispatch a compositionupdate event, a text event and
+  // a compositionend event.
+  // XXX Shouldn't we dispatch the text event with actual or latest composition
+  //     string?
+  PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
+    ("IMM32: OnIMEEndComposition, mCompositionString=\"%s\"%s",
+     NS_ConvertUTF16toUTF8(mCompositionString).get(),
+     mCompositionString.IsEmpty() ? "" : ", but canceling it..."));
+
   mCompositionString.Truncate();
 
   nsIMEContext IMEContext(aWindow->GetWindowHandle());
   DispatchTextEvent(aWindow, IMEContext, false);
 
   HandleEndComposition(aWindow);
 
   return ShouldDrawCompositionStringOurselves();
--- a/xpcom/io/nsLocalFileWin.cpp
+++ b/xpcom/io/nsLocalFileWin.cpp
@@ -1475,18 +1475,17 @@ nsLocalFile::CopySingleFile(nsIFile *sou
             copyOK = CopyFileExW(filePath.get(), destPath.get(), NULL, NULL, NULL, dwCopyFlags);
 
             if (copyOK)
                 DeleteFileW(filePath.get());
         }
         else
         {
             copyOK = ::MoveFileExW(filePath.get(), destPath.get(),
-                                   MOVEFILE_REPLACE_EXISTING |
-                                   MOVEFILE_WRITE_THROUGH);
+                                   MOVEFILE_REPLACE_EXISTING);
             
             // Check if copying the source file to a different volume,
             // as this could be an SMBV2 mapped drive.
             if (!copyOK && GetLastError() == ERROR_NOT_SAME_DEVICE)
             {
                 copyOK = CopyFileExW(filePath.get(), destPath.get(), NULL, NULL, NULL, dwCopyFlags);
             
                 if (copyOK)