Back out bug 562169 because of Dromaeo DOM regressions
authorMatt Brubeck <mbrubeck@mozilla.com>
Wed, 08 Aug 2012 08:14:48 -0700
changeset 101815 5faf4c39e64cd7ff7e5f8ac81f991c57d2ce8a86
parent 101814 d21893bdae919da43e3d8145a3896e42e141a8a6
child 101816 add211f29374e0c68b3ecabbc1ffcd94ab2502df
push id13186
push usermbrubeck@mozilla.com
push dateWed, 08 Aug 2012 15:15:40 +0000
treeherdermozilla-inbound@5faf4c39e64c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs562169
milestone17.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
Back out bug 562169 because of Dromaeo DOM regressions Backed out changeset 841cd6e1e585 (bug 562169) Backed out changeset e226e413dd27 (bug 562169) Backed out changeset 9c24b7287c5b (bug 562169)
content/base/public/DirectionalityUtils.h
content/base/public/Element.h
content/base/public/Makefile.in
content/base/public/nsIDocument.h
content/base/public/nsINode.h
content/base/src/DirectionalityUtils.cpp
content/base/src/Makefile.in
content/base/src/nsDocument.cpp
content/base/src/nsDocument.h
content/base/src/nsGenericElement.cpp
content/base/src/nsGkAtomList.h
content/base/test/Makefile.in
content/base/test/test_bug562169-1.html
content/base/test/test_bug562169-2.html
content/events/public/nsEventStates.h
content/html/content/src/nsGenericHTMLElement.cpp
content/html/content/src/nsGenericHTMLElement.h
dom/locales/en-US/chrome/layout/css.properties
layout/reftests/bidi/562169-1-ref.html
layout/reftests/bidi/562169-1.html
layout/reftests/bidi/562169-1a.html
layout/reftests/bidi/562169-2-ref.html
layout/reftests/bidi/562169-2.html
layout/reftests/bidi/562169-2a.html
layout/reftests/bidi/562169-3-ref.html
layout/reftests/bidi/562169-3.html
layout/reftests/bidi/562169-3a.html
layout/reftests/bidi/562169-4-ref.html
layout/reftests/bidi/562169-4.html
layout/reftests/bidi/reftest.list
layout/style/nsCSSParser.cpp
layout/style/nsCSSPseudoClassList.h
layout/style/nsCSSPseudoClasses.cpp
layout/style/nsCSSRuleProcessor.cpp
deleted file mode 100644
--- a/content/base/public/DirectionalityUtils.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- *
- * 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/. */
-
-#ifndef DirectionalityUtils_h___
-#define DirectionalityUtils_h___
-
-class nsIContent;
-class nsIDocument;
-class nsINode;
-
-namespace mozilla {
-namespace dom {
-class Element;
-} // namespace dom
-} // namespace mozilla
-
-namespace mozilla {
-
-namespace directionality {
-
-enum Directionality {
-  eDir_NotSet = 0,
-  eDir_RTL    = 1,
-  eDir_LTR    = 2
-};
-
-void SetDirectionality(mozilla::dom::Element* aElement, Directionality aDir,
-                       bool aNotify = true);
-
-/**
- * Set the directionality of an element according to the algorithm defined at
- * http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#the-directionality,
- * not including elements with auto direction.
- *
- * @return the directionality that the element was set to
- */
-Directionality RecomputeDirectionality(mozilla::dom::Element* aElement,
-                                       bool aNotify = true);
-
-/**
- * Set the directionality of any descendants of a node that do not themselves
- * have a dir attribute.
- * For performance reasons we walk down the descendant tree in the rare case
- * of setting the dir attribute, rather than walking up the ancestor tree in
- * the much more common case of getting the element's directionality.
- */
-void SetDirectionalityOnDescendants(mozilla::dom::Element* aElement, 
-                                    Directionality aDir,
-                                    bool aNotify = true);
-
-} // end namespace directionality
-
-} // end namespace mozilla
-
-#endif /* DirectionalityUtils_h___ */
--- a/content/base/public/Element.h
+++ b/content/base/public/Element.h
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_Element_h__
 #define mozilla_dom_Element_h__
 
 #include "mozilla/dom/FragmentOrElement.h" // for base class
 #include "nsChangeHint.h"                  // for enum
 #include "nsEventStates.h"                 // for member
-#include "mozilla/dom/DirectionalityUtils.h"
 
 class nsEventStateManager;
 class nsFocusManager;
 class nsGlobalWindow;
 class nsICSSDeclaration;
 class nsISMILAttr;
 
 // Element-specific flags
@@ -212,28 +211,16 @@ public:
 
   /**
    * Returns an atom holding the name of the "class" attribute on this
    * content node (if applicable).  Returns null if there is no
    * "class" attribute for this type of content node.
    */
   virtual nsIAtom *GetClassAttributeName() const = 0;
 
-  inline mozilla::directionality::Directionality GetDirectionality() const {
-    if (HasFlag(NODE_HAS_DIRECTION_RTL)) {
-      return mozilla::directionality::eDir_RTL;
-    }
-
-    if (HasFlag(NODE_HAS_DIRECTION_LTR)) {
-      return mozilla::directionality::eDir_LTR;
-    }
-
-    return mozilla::directionality::eDir_NotSet;
-  }
-
 protected:
   /**
    * Method to get the _intrinsic_ content state of this element.  This is the
    * state that is independent of the element's presentation.  To get the full
    * content state, use State().  See nsEventStates.h for
    * the possible bits that could be set here.
    */
   virtual nsEventStates IntrinsicState() const;
--- a/content/base/public/Makefile.in
+++ b/content/base/public/Makefile.in
@@ -43,17 +43,16 @@ nsReferencedElement.h \
 nsTreeSanitizer.h \
 nsXMLNameSpaceMap.h \
 nsIXFormsUtilityService.h \
 $(NULL)
 
 EXPORTS_NAMESPACES = mozilla/dom mozilla
 
 EXPORTS_mozilla/dom = \
-		DirectionalityUtils.h \
 		Element.h \
 		FragmentOrElement.h \
 		FromParser.h \
 		$(NULL)
 
 EXPORTS_mozilla = \
 		CORSMode.h \
 		$(NULL)
--- a/content/base/public/nsIDocument.h
+++ b/content/base/public/nsIDocument.h
@@ -18,17 +18,16 @@
 #include "nsILoadContext.h"              // for member (in nsCOMPtr)
 #include "nsILoadGroup.h"                // for member (in nsCOMPtr)
 #include "nsINode.h"                     // for base class
 #include "nsIScriptGlobalObject.h"       // for member (in nsCOMPtr)
 #include "nsIStructuredCloneContainer.h" // for member (in nsCOMPtr)
 #include "nsPIDOMWindow.h"               // for use in inline functions
 #include "nsPropertyTable.h"             // for member
 #include "nsTHashtable.h"                // for member
-#include "mozilla/dom/DirectionalityUtils.h"
 
 class imgIRequest;
 class nsAString;
 class nsBindingManager;
 class nsCSSStyleSheet;
 class nsDOMNavigationTiming;
 class nsEventStates;
 class nsFrameLoader;
@@ -393,20 +392,16 @@ public:
    * callers are expected to take action as needed if they want this
    * change to actually change anything immediately.
    * @see nsBidiUtils.h
    */
   void SetBidiOptions(PRUint32 aBidiOptions)
   {
     mBidiOptions = aBidiOptions;
   }
-
-  inline mozilla::directionality::Directionality GetDocumentDirectionality() {
-    return mDirectionality;
-  }
   
   /**
    * Access HTTP header data (this may also get set from other
    * sources, like HTML META tags).
    */
   virtual void GetHeaderData(nsIAtom* aHeaderField, nsAString& aData) const = 0;
   virtual void SetHeaderData(nsIAtom* aheaderField, const nsAString& aData) = 0;
 
@@ -1853,19 +1848,16 @@ protected:
   // If mIsStaticDocument is true, mOriginalDocument points to the original
   // document.
   nsCOMPtr<nsIDocument> mOriginalDocument;
 
   // The bidi options for this document.  What this bitfield means is
   // defined in nsBidiUtils.h
   PRUint32 mBidiOptions;
 
-  // The root directionality of this document.
-  mozilla::directionality::Directionality mDirectionality;
-
   nsCString mContentLanguage;
 private:
   nsCString mContentType;
 protected:
 
   // The document's security info
   nsCOMPtr<nsISupports> mSecurityInfo;
 
--- a/content/base/public/nsINode.h
+++ b/content/base/public/nsINode.h
@@ -140,26 +140,18 @@ enum {
   NODE_HAS_ACCESSKEY           = 0x00020000U,
 
   // Set if the node is handling a click.
   NODE_HANDLING_CLICK          = 0x00040000U,
 
   // Set if the node has had :hover selectors matched against it
   NODE_HAS_RELEVANT_HOVER_RULES = 0x00080000U,
 
-  // Set if the node has right-to-left directionality
-  NODE_HAS_DIRECTION_RTL        = 0x00100000U,
-
-  // Set if the node has left-to-right directionality
-  NODE_HAS_DIRECTION_LTR        = 0x00200000U,
-
-  NODE_ALL_DIRECTION_FLAGS      = NODE_HAS_DIRECTION_LTR | NODE_HAS_DIRECTION_RTL,
-
   // Remaining bits are node type specific.
-  NODE_TYPE_SPECIFIC_BITS_OFFSET =        22
+  NODE_TYPE_SPECIFIC_BITS_OFFSET =        20
 };
 
 /**
  * Class used to detect unexpected mutations. To use the class create an
  * nsMutationGuard on the stack before unexpected mutations could occur.
  * You can then at any time call Mutated to check if any unexpected mutations
  * have occurred.
  *
@@ -1282,18 +1274,16 @@ private:
     // Set if element has pointer locked
     ElementHasPointerLock,
     // Set if the node may have DOMMutationObserver attached to it.
     NodeMayHaveDOMMutationObserver,
     // Set if node is Content
     NodeIsContent,
     // Set if the node has animations or transitions
     ElementHasAnimations,
-    // Set if node has a dir attribute with a valid value (ltr or rtl)
-    NodeHasValidDirAttribute,
     // Guard value
     BooleanFlagCount
   };
 
   void SetBoolFlag(BooleanFlag name, bool value) {
     PR_STATIC_ASSERT(BooleanFlagCount <= 8*sizeof(mBoolFlags));
     mBoolFlags = (mBoolFlags & ~(1 << name)) | (value << name);
   }
@@ -1351,19 +1341,16 @@ public:
   void SetMayHaveDOMMutationObserver()
     { SetBoolFlag(NodeMayHaveDOMMutationObserver, true); }
   bool HasListenerManager() { return HasFlag(NODE_HAS_LISTENERMANAGER); }
   bool HasPointerLock() const { return GetBoolFlag(ElementHasPointerLock); }
   void SetPointerLock() { SetBoolFlag(ElementHasPointerLock); }
   void ClearPointerLock() { ClearBoolFlag(ElementHasPointerLock); }
   bool MayHaveAnimations() { return GetBoolFlag(ElementHasAnimations); }
   void SetMayHaveAnimations() { SetBoolFlag(ElementHasAnimations); }
-  void SetHasValidDir() { SetBoolFlag(NodeHasValidDirAttribute); }
-  void ClearHasValidDir() { ClearBoolFlag(NodeHasValidDirAttribute); }
-  bool HasValidDir() const { return GetBoolFlag(NodeHasValidDirAttribute); }
 protected:
   void SetParentIsContent(bool aValue) { SetBoolFlag(ParentIsContent, aValue); }
   void SetInDocument() { SetBoolFlag(IsInDocument); }
   void SetNodeIsContent() { SetBoolFlag(NodeIsContent); }
   void ClearInDocument() { ClearBoolFlag(IsInDocument); }
   void SetIsElement() { SetBoolFlag(NodeIsElement); }
   void SetHasID() { SetBoolFlag(ElementHasID); }
   void ClearHasID() { ClearBoolFlag(ElementHasID); }
deleted file mode 100644
--- a/content/base/src/DirectionalityUtils.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 sw=2 et tw=78: */
-/* 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 "mozilla/dom/DirectionalityUtils.h"
-#include "nsINode.h"
-#include "nsIContent.h"
-#include "nsIDocument.h"
-#include "mozilla/dom/Element.h"
-#include "nsIDOMNodeFilter.h"
-#include "nsTreeWalker.h"
-#include "nsIDOMHTMLDocument.h"
-
-
-namespace mozilla {
-
-namespace directionality {
-
-typedef mozilla::dom::Element Element;
-
-void
-SetDirectionality(Element* aElement, Directionality aDir, bool aNotify)
-{
-  aElement->UnsetFlags(NODE_ALL_DIRECTION_FLAGS);
-  switch (aDir) {
-    case eDir_RTL:
-      aElement->SetFlags(NODE_HAS_DIRECTION_RTL);
-      break;
-    case eDir_LTR:
-      aElement->SetFlags(NODE_HAS_DIRECTION_LTR);
-      break;
-    default:
-      break;
-  }
-
-  aElement->UpdateState(aNotify);
-}
-
-Directionality
-RecomputeDirectionality(Element* aElement, bool aNotify)
-{
-  Directionality dir = eDir_LTR;
-
-  if (aElement->HasValidDir()) {
-    dir = aElement->GetDirectionality();
-  } else {
-    Element* parent = aElement->GetElementParent();
-    if (parent) {
-      // If the element doesn't have an explicit dir attribute with a valid
-      // value, the directionality is the same as the parent element (but
-      // don't propagate the parent directionality if it isn't set yet).
-      Directionality parentDir = parent->GetDirectionality();
-      if (parentDir != eDir_NotSet) {
-        dir = parentDir;
-      }
-    } else {
-      // If there is no parent element, the directionality is the same as the
-      // document direction.
-      Directionality documentDir =
-        aElement->OwnerDoc()->GetDocumentDirectionality();
-      if (documentDir != eDir_NotSet) {
-        dir = documentDir;
-      }
-    }
-    
-    SetDirectionality(aElement, dir, aNotify);
-  }
-  return dir;
-}
-
-void
-SetDirectionalityOnDescendants(Element* aElement, Directionality aDir,
-                               bool aNotify)
-{
-  for (nsIContent* child = aElement->GetFirstChild(); child; ) {
-    if (!child->IsElement()) {
-      child = child->GetNextNode(aElement);
-      continue;
-    }
-
-    Element* element = child->AsElement();
-    if (element->HasValidDir()) {
-      child = child->GetNextNonChildNode(aElement);
-      continue;
-    }
-    SetDirectionality(element, aDir, aNotify);
-    child = child->GetNextNode(aElement);
-  }
-}
-
-} // end namespace directionality
-
-} // end namespace mozilla
-
--- a/content/base/src/Makefile.in
+++ b/content/base/src/Makefile.in
@@ -48,17 +48,16 @@ EXPORTS_NAMESPACES = mozilla/dom
 EXPORTS_mozilla/dom = \
   Link.h \
   $(NULL)
 
 LOCAL_INCLUDES = \
 		$(NULL)
 
 CPPSRCS		= \
-		DirectionalityUtils.cpp \
 		nsAtomListUtils.cpp \
 		nsAttrAndChildArray.cpp \
 		nsAttrValue.cpp \
 		nsAttrValueOrString.cpp \
 		nsCCUncollectableMarker.cpp \
 		nsChannelPolicy.cpp \
 		nsCommentNode.cpp \
 		nsContentAreaDragDrop.cpp \
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -86,17 +86,16 @@
 // for radio group stuff
 #include "nsIDOMHTMLInputElement.h"
 #include "nsIRadioVisitor.h"
 #include "nsIFormControl.h"
 
 #include "nsXMLEventsManager.h"
 
 #include "nsBidiUtils.h"
-#include "mozilla/dom/DirectionalityUtils.h"
 
 #include "nsIDOMUserDataHandler.h"
 #include "nsIDOMXPathEvaluator.h"
 #include "nsIXPathEvaluatorInternal.h"
 #include "nsIParserService.h"
 #include "nsContentCreatorFunctions.h"
 
 #include "nsIScriptContext.h"
@@ -166,17 +165,16 @@
 
 #include "mozilla/Preferences.h"
 
 #include "imgILoader.h"
 #include "nsWrapperCacheInlines.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
-using namespace mozilla::directionality;
 
 typedef nsTArray<Link*> LinkArray;
 
 // Reference to the document which requested DOM full-screen mode.
 nsWeakPtr nsDocument::sFullScreenDoc = nullptr;
 
 // Reference to the root document of the branch containing the document
 // which requested DOM full-screen mode.
@@ -1507,18 +1505,17 @@ nsIDocument::nsIDocument()
     mRemovedFromDocShell(false),
     // mAllowDNSPrefetch starts true, so that we can always reliably && it
     // with various values that might disable it.  Since we never prefetch
     // unless we get a window, and in that case the docshell value will get
     // &&-ed in, this is safe.
     mAllowDNSPrefetch(true),
     mIsBeingUsedAsImage(false),
     mHasLinksToUpdate(false),
-    mPartID(0),
-    mDirectionality(eDir_LTR)
+    mPartID(0)
 {
   SetInDocument();
 }
 
 // NOTE! nsDocument::operator new() zeroes out all members, so don't
 // bother initializing members to 0.
 
 nsDocument::nsDocument(const char* aContentType)
@@ -5581,25 +5578,16 @@ nsDocument::SetDir(const nsAString& aDir
         if (shell) {
           nsPresContext *context = shell->GetPresContext();
           NS_ENSURE_TRUE(context, NS_ERROR_UNEXPECTED);
           context->SetBidi(options, true);
         } else {
           // No presentation; just set it on ourselves
           SetBidiOptions(options);
         }
-        Directionality dir = elt->mValue == IBMBIDI_TEXTDIRECTION_RTL ?
-                               eDir_RTL : eDir_LTR;
-        SetDocumentDirectionality(dir);
-        // Set the directionality of the root element and its descendants, if any
-        Element* rootElement = GetRootElement();
-        if (rootElement) {
-          SetDirectionality(rootElement, dir, true);
-          SetDirectionalityOnDescendants(rootElement, dir);
-        }
       }
 
       break;
     }
   }
 
   return NS_OK;
 }
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -1043,22 +1043,16 @@ protected:
   void DestroyElementMaps();
 
   // Refreshes the hrefs of all the links in the document.
   void RefreshLinkHrefs();
 
   nsIContent* GetFirstBaseNodeWithHref();
   nsresult SetFirstBaseNodeWithHref(nsIContent *node);
 
-  inline void
-  SetDocumentDirectionality(mozilla::directionality::Directionality aDir)
-  {
-    mDirectionality = aDir;
-  }
-
   // Get the first <title> element with the given IsNodeOfType type, or
   // return null if there isn't one
   nsIContent* GetTitleContent(PRUint32 aNodeType);
   // Find the first "title" element in the given IsNodeOfType type and
   // append the concatenation of its text node children to aTitle. Do
   // nothing if there is no such element.
   void GetTitleFromElement(PRUint32 aNodeType, nsAString& aTitle);
 
--- a/content/base/src/nsGenericElement.cpp
+++ b/content/base/src/nsGenericElement.cpp
@@ -46,17 +46,16 @@
 #include "nsDOMTokenList.h"
 #include "nsXBLPrototypeBinding.h"
 #include "nsDOMError.h"
 #include "nsDOMString.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIDOMMutationEvent.h"
 #include "nsMutationEvent.h"
 #include "nsNodeUtils.h"
-#include "mozilla/dom/DirectionalityUtils.h"
 #include "nsDocument.h"
 #include "nsAttrValueOrString.h"
 #ifdef MOZ_XUL
 #include "nsXULElement.h"
 #endif /* MOZ_XUL */
 #include "nsFrameManager.h"
 #include "nsFrameSelection.h"
 #ifdef DEBUG
@@ -124,17 +123,16 @@
 #include "mozilla/Telemetry.h"
 
 #include "mozilla/CORSMode.h"
 
 #include "nsStyledElement.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
-using namespace mozilla::directionality;
 
 nsEventStates
 Element::IntrinsicState() const
 {
   return IsEditable() ? NS_EVENT_STATE_MOZ_READWRITE :
                         NS_EVENT_STATE_MOZ_READONLY;
 }
 
@@ -1355,23 +1353,16 @@ nsGenericElement::BindToTree(nsIDocument
                NODE_NEEDS_FRAME | NODE_DESCENDANTS_NEED_FRAMES |
                // And the restyle bits
                ELEMENT_ALL_RESTYLE_FLAGS);
   } else {
     // If we're not in the doc, update our subtree pointer.
     SetSubtreeRootPointer(aParent->SubtreeRoot());
   }
 
-  // This has to be here, rather than in nsGenericHTMLElement::BindToTree, 
-  //  because it has to happen after updating the parent pointer, but before
-  //  recursively binding the kids.
-  if (IsHTML()) {
-    RecomputeDirectionality(this, false);
-  }
-
   // If NODE_FORCE_XBL_BINDINGS was set we might have anonymous children
   // that also need to be told that they are moving.
   nsresult rv;
   if (hadForceXBL) {
     nsBindingManager* bmgr = OwnerDoc()->BindingManager();
 
     // First check if we have a binding...
     nsXBLBinding* contBinding =
@@ -1547,23 +1538,16 @@ nsGenericElement::UnbindFromTree(bool aD
 #endif
   {
     nsDOMSlots *slots = GetExistingDOMSlots();
     if (slots) {
       slots->mBindingParent = nullptr;
     }
   }
 
-  // This has to be here, rather than in nsGenericHTMLElement::UnbindFromTree, 
-  //  because it has to happen after unsetting the parent pointer, but before
-  //  recursively unbinding the kids.
-  if (IsHTML()) {
-    RecomputeDirectionality(this, false);
-  }
-
   if (aDeep) {
     // Do the kids. Don't call GetChildCount() here since that'll force
     // XUL to generate template children, which there is no need for since
     // all we're going to do is unbind them anyway.
     PRUint32 i, n = mAttrsAndChildren.ChildCount();
 
     for (i = 0; i < n; ++i) {
       // Note that we pass false for aNullParent here, since we don't want
--- a/content/base/src/nsGkAtomList.h
+++ b/content/base/src/nsGkAtomList.h
@@ -265,17 +265,16 @@ GK_ATOM(details, "details")
 GK_ATOM(deviceAspectRatio, "device-aspect-ratio")
 GK_ATOM(deviceHeight, "device-height")
 GK_ATOM(deviceWidth, "device-width")
 GK_ATOM(dfn, "dfn")
 GK_ATOM(dialog, "dialog")
 GK_ATOM(difference, "difference")
 GK_ATOM(digit, "digit")
 GK_ATOM(dir, "dir")
-GK_ATOM(directionality, "directionality")
 GK_ATOM(disableOutputEscaping, "disable-output-escaping")
 GK_ATOM(disabled, "disabled")
 GK_ATOM(display, "display")
 GK_ATOM(distinct, "distinct")
 GK_ATOM(div, "div")
 GK_ATOM(dl, "dl")
 GK_ATOM(doctypePublic, "doctype-public")
 GK_ATOM(doctypeSystem, "doctype-system")
--- a/content/base/test/Makefile.in
+++ b/content/base/test/Makefile.in
@@ -376,18 +376,16 @@ MOCHITEST_FILES_B = \
 		file_csp_redirects_page.sjs \
 		file_csp_redirects_main.html \
 		file_csp_redirects_resource.sjs \
 		test_bug346485.html \
 		test_bug560780.html \
 		test_bug562652.html \
 		test_bug562137.html \
 		file_bug562137.txt \
-		test_bug562169-1.html \
-		test_bug562169-2.html \
 		test_bug548193.html \
 		file_bug548193.sjs \
 		test_html_colors_quirks.html \
 		test_html_colors_standards.html \
 		test_bug300992.html \
 		test_websocket_hello.html \
 		file_websocket_hello_wsh.py \
 		test_websocket_basic.html \
deleted file mode 100644
--- a/content/base/test/test_bug562169-1.html
+++ /dev/null
@@ -1,44 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=562169
--->
-<head>
-  <meta charset="utf-8">
-  <title>Test for Bug 562169</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.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=562169">Mozilla Bug 562169</a>
-<p id="display"></p>
-<div id="content" style="display: none">
- <div dir="rtl" id="z"></div>  
-</div>
-<pre id="test">
-<script type="application/javascript">
-
-/** Test for Bug 562169 **/
-/** Test that adding an child to an element with dir="rtl" makes the
-      child have rtl directionality, and removing the child makes it
-     go back to ltr directionality **/
-
-function checkSelector(element, expectedDir, expectedChild)
-{
-    ok(element.querySelector(":dir("+expectedDir+")") == expectedChild,
-       "direction should be " + expectedDir);
-}
-
-var x = document.createElement("div");
-var y = document.createElement("div");
-x.appendChild(y);
-checkSelector(x, "ltr", y);
-$(z).appendChild(x);
-checkSelector(x, "rtl", y);
-$(z).removeChild(x);
-checkSelector(x, "ltr", y);
-
-</script>
-</pre>
-</body>
-</html>
deleted file mode 100644
--- a/content/base/test/test_bug562169-2.html
+++ /dev/null
@@ -1,29 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=562169
--->
-<head>
-  <meta charset="utf-8">
-  <title>Test for Bug 562169</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.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=562169">Mozilla Bug 562169</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-</div>
-<pre id="test">
-<script type="application/javascript">
-
-/** Test for Bug 562169 **/
-/** Test that a newly created element has ltr directionality **/
-
-ok(document.createElement("div").mozMatchesSelector(":dir(ltr)"),
-   "Element should be ltr on creation");
-
-</script>
-</pre>
-</body>
-</html>
--- a/content/events/public/nsEventStates.h
+++ b/content/events/public/nsEventStates.h
@@ -243,20 +243,16 @@ private:
 // Content is in the sub-suboptimal region.
 #define NS_EVENT_STATE_SUB_SUB_OPTIMUM NS_DEFINE_EVENT_STATE_MACRO(39)
 // Handler for click to play plugin (vulnerable w/update)
 #define NS_EVENT_STATE_VULNERABLE_UPDATABLE NS_DEFINE_EVENT_STATE_MACRO(40)
 // Handler for click to play plugin (vulnerable w/no update)
 #define NS_EVENT_STATE_VULNERABLE_NO_UPDATE NS_DEFINE_EVENT_STATE_MACRO(41)
 // Platform does not support plugin content (some mobile platforms)
 #define NS_EVENT_STATE_TYPE_UNSUPPORTED_PLATFORM NS_DEFINE_EVENT_STATE_MACRO(42)
-// Element is ltr (for :dir pseudo-class)
-#define NS_EVENT_STATE_LTR NS_DEFINE_EVENT_STATE_MACRO(43)
-// Element is rtl (for :dir pseudo-class)
-#define NS_EVENT_STATE_RTL NS_DEFINE_EVENT_STATE_MACRO(44)
 
 /**
  * NOTE: do not go over 63 without updating nsEventStates::InternalType!
  */
 
 #define ESM_MANAGED_STATES (NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS |     \
                             NS_EVENT_STATE_HOVER | NS_EVENT_STATE_DRAGOVER |   \
                             NS_EVENT_STATE_URLTARGET | NS_EVENT_STATE_FOCUSRING | \
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -48,17 +48,16 @@
 #include "nsScriptLoader.h"
 #include "nsRuleData.h"
 
 #include "nsPresState.h"
 #include "nsILayoutHistoryState.h"
 
 #include "nsHTMLParts.h"
 #include "nsContentUtils.h"
-#include "mozilla/dom/DirectionalityUtils.h"
 #include "nsString.h"
 #include "nsUnicharUtils.h"
 #include "nsGkAtoms.h"
 #include "nsEventStateManager.h"
 #include "nsIDOMEvent.h"
 #include "nsDOMCSSDeclaration.h"
 #include "nsITextControlFrame.h"
 #include "nsIForm.h"
@@ -92,17 +91,16 @@
 #include "HTMLPropertiesCollection.h"
 #include "nsVariant.h"
 #include "nsDOMSettableTokenList.h"
 #include "nsThreadUtils.h"
 #include "nsTextFragment.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
-using namespace mozilla::directionality;
 
 class nsINodeInfo;
 class nsIDOMNodeList;
 class nsRuleWalker;
 
 // XXX todo: add in missing out-of-memory checks
 
 //----------------------------------------------------------------------
@@ -1684,34 +1682,16 @@ nsGenericHTMLElement::UpdateEditableStat
   if (value != eInherit) {
     DoSetEditableFlag(!!value, aNotify);
     return;
   }
 
   nsStyledElement::UpdateEditableState(aNotify);
 }
 
-nsEventStates
-nsGenericHTMLElement::IntrinsicState() const
-{
-  nsEventStates state = nsGenericHTMLElementBase::IntrinsicState();
-
-  if (GetDirectionality() == eDir_RTL) {
-    state |= NS_EVENT_STATE_RTL;
-    state &= ~NS_EVENT_STATE_LTR;
-  } else { // at least for HTML, directionality is exclusively LTR or RTL
-    NS_ASSERTION(GetDirectionality() == eDir_LTR,
-                 "HTML element's directionality must be either RTL or LTR");
-    state |= NS_EVENT_STATE_LTR;
-    state &= ~NS_EVENT_STATE_RTL;
-  }
-
-  return state;
-}
-
 nsresult
 nsGenericHTMLElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                                  nsIContent* aBindingParent,
                                  bool aCompileEventHandlers)
 {
   nsresult rv = nsGenericHTMLElementBase::BindToTree(aDocument, aParent,
                                                      aBindingParent,
                                                      aCompileEventHandlers);
@@ -1904,30 +1884,16 @@ nsGenericHTMLElement::AfterSetAttr(PRInt
       NS_ABORT_IF_FALSE(aValue->Type() == nsAttrValue::eString,
         "Expected string value for script body");
       nsresult rv = AddScriptEventListener(aName, aValue->GetStringValue());
       NS_ENSURE_SUCCESS(rv, rv);
     }
     else if (aNotify && aName == nsGkAtoms::spellcheck) {
       SyncEditorsOnSubtree(this);
     }
-    else if (aName == nsGkAtoms::dir) {
-      Directionality dir;
-      if (aValue &&
-          (aValue->Equals(nsGkAtoms::ltr, eIgnoreCase) ||
-           aValue->Equals(nsGkAtoms::rtl, eIgnoreCase))) {
-        SetHasValidDir();
-        dir = aValue->Equals(nsGkAtoms::rtl, eIgnoreCase) ? eDir_RTL : eDir_LTR;
-        SetDirectionality(this, dir, aNotify);
-      } else {
-        ClearHasValidDir();
-        dir = RecomputeDirectionality(this, aNotify);
-      }
-      SetDirectionalityOnDescendants(this, dir, aNotify);
-    }
   }
 
   return nsGenericHTMLElementBase::AfterSetAttr(aNamespaceID, aName,
                                                 aValue, aNotify);
 }
 
 nsEventListenerManager*
 nsGenericHTMLElement::GetEventListenerManagerForAttr(nsIAtom* aAttrName,
--- a/content/html/content/src/nsGenericHTMLElement.h
+++ b/content/html/content/src/nsGenericHTMLElement.h
@@ -44,18 +44,16 @@ typedef nsMappedAttributeElement nsGener
 class nsGenericHTMLElement : public nsGenericHTMLElementBase
 {
 public:
   nsGenericHTMLElement(already_AddRefed<nsINodeInfo> aNodeInfo)
     : nsGenericHTMLElementBase(aNodeInfo)
   {
     NS_ASSERTION(mNodeInfo->NamespaceID() == kNameSpaceID_XHTML,
                  "Unexpected namespace");
-    AddStatesSilently(NS_EVENT_STATE_LTR);
-    SetFlags(NODE_HAS_DIRECTION_LTR);
   }
 
   /** Typesafe, non-refcounting cast from nsIContent.  Cheaper than QI. **/
   static nsGenericHTMLElement* FromContent(nsIContent *aContent)
   {
     if (aContent->IsHTML())
       return static_cast<nsGenericHTMLElement*>(aContent);
     return nullptr;
@@ -199,18 +197,16 @@ public:
   nsresult PostHandleEventForAnchors(nsEventChainPostVisitor& aVisitor);
   bool IsHTMLLink(nsIURI** aURI) const;
 
   // HTML element methods
   void Compact() { mAttrsAndChildren.Compact(); }
 
   virtual void UpdateEditableState(bool aNotify);
 
-  virtual nsEventStates IntrinsicState() const;
-
   // Helper for setting our editable flag and notifying
   void DoSetEditableFlag(bool aEditable, bool aNotify) {
     SetEditableFlag(aEditable);
     UpdateState(aNotify);
   }
 
   virtual bool ParseAttribute(PRInt32 aNamespaceID,
                                 nsIAtom* aAttribute,
--- a/dom/locales/en-US/chrome/layout/css.properties
+++ b/dom/locales/en-US/chrome/layout/css.properties
@@ -109,17 +109,16 @@ PEMQExpectedExpressionStart=Expected '('
 PEMQExpressionEOF=contents of media query expression
 PEMQExpectedFeatureName=Expected media feature name but found '%1$S'.
 PEMQExpectedFeatureNameEnd=Expected ':' or ')' after media feature name but found '%1$S'.
 PEMQNoMinMaxWithoutValue=Media features with min- or max- must have a value.
 PEMQExpectedFeatureValue=Found invalid value for media feature.
 PEBadFontBlockStart=Expected '{' to begin @font-face rule but found '%1$S'.
 PEBadFontBlockEnd=Expected '}' to end @font-face rule but found '%1$S'.
 PEAnonBoxNotAlone=Did not expect anonymous box.
-PEBadDirValue=Expected 'ltr' or 'rtl' in direction selector but found '%1$S'.
 PESupportsConditionStartEOF='not' or '('
 PESupportsConditionInParensStartEOF='not', '(' or identifier
 PESupportsConditionNotEOF='not'
 PESupportsConditionExpectedOpenParen=Expected '(' while parsing supports condition but found '%1$S'.
 PESupportsConditionExpectedCloseParen=Expected ')' while parsing supports condition but found '%1$S'.
 PESupportsConditionExpectedStart=Expected 'not' or '(' while parsing supports condition but found '%1$S'.
 PESupportsConditionExpectedNot=Expected 'not' while parsing supports condition but found '%1$S'.
 PESupportsGroupRuleStart=Expected '{' to begin @supports rule but found '%1$S'.
deleted file mode 100644
--- a/layout/reftests/bidi/562169-1-ref.html
+++ /dev/null
@@ -1,31 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
-  <meta charset="UTF-8">
-  <title>dir() selector</title>
-  <style>
-   .blue { color: blue; direction: ltr; }
-   .lime { color: lime; direction: rtl; }
-   div { text-align: left; }
-  </style>
- </head>
- <body>
-  <div class="blue">This element has default direction.</div>
-  <div class="blue">This element is ltr.</div>
-  <div class="lime">This element is rtl.</div>
-  <div class="blue">
-    <div>This element should inherit ltr.</div>
-    <div class="blue">This element is ltr.</div>
-    <div class="lime">This element is rtl.</div>
-    <div class="blue">Every word in this element should inherit ltr.</div>
-  </div>
-  <div class="lime">
-    <div>This element should inherit rtl.</div>
-    <div class="blue">This element is ltr.</div>
-    <div class="lime">This element is rtl.</div>
-    <div class="lime">Every word in this element should inherit rtl.</div>
-  </div>
-  <div class="blue">This element has an invalid dir attribute and
-    should have default direction.</div>
- </body>
-</html>
deleted file mode 100644
--- a/layout/reftests/bidi/562169-1.html
+++ /dev/null
@@ -1,32 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
-  <meta charset="UTF-8">
-  <title>dir() selector</title>
-  <style>
-   :dir(ltr) { color: blue }
-   :dir(rtl) { color: lime }
-   :dir(foopy) { color: red }
-   div { text-align: left; }
-  </style>
- </head>
- <body>
-  <div>This element has default direction.</div>
-  <div dir="ltr">This element is ltr.</div>
-  <div dir="rtl">This element is rtl.</div>
-  <div dir="ltr">
-    <div>This element should inherit ltr.</div>
-    <div dir="ltr">This element is ltr.</div>
-    <div dir="rtl">This element is rtl.</div>
-    <div><span>Every <span>word <span>in <span>this <span>element <span>should <span>inherit <span>ltr</span></span></span></span></span></span></span></span>.</div>
-  </div>
-  <div dir="rtl">
-    <div>This element should inherit rtl.</div>
-    <div dir="ltr">This element is ltr.</div>
-    <div dir="rtl">This element is rtl.</div>
-    <div><span>Every <span>word <span>in <span>this <span>element <span>should <span>inherit <span>rtl</span></span></span></span></span></span></span></span>.</div>
-  </div>
-  <div dir="foopy">This element has an invalid dir attribute and
-    should have default direction.</div>
- </body>
-</html>
deleted file mode 100644
--- a/layout/reftests/bidi/562169-1a.html
+++ /dev/null
@@ -1,46 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
-  <meta charset="UTF-8">
-  <title>dir() selector</title>
-  <style>
-   :dir(ltr) { color: blue }
-   :dir(rtl) { color: lime }
-   :dir(foopy) { color: red }
-   div { text-align: left; }
-  </style>
-  <script type="text/javascript">
-function switchDir()
-{
-    divs = document.getElementsByTagName("div");
-    for (var i = 0; i < divs.length; ++i) {
-	theDiv = divs[i];
-	if (theDiv.dir == "ltr") {
-	    theDiv.dir = "rtl";
-	} else if (theDiv.dir == "rtl") {
-	    theDiv.dir = "ltr";
-	}
-    }
-}
-  </script>
- </head>
- <body onload="switchDir()">
-  <div>This element has default direction.</div>
-  <div dir="rtl">This element is ltr.</div>
-  <div dir="ltr">This element is rtl.</div>
-  <div dir="rtl">
-    <div>This element should inherit ltr.</div>
-    <div dir="rtl">This element is ltr.</div>
-    <div dir="ltr">This element is rtl.</div>
-    <div><span>Every <span>word <span>in <span>this <span>element <span>should <span>inherit <span>ltr</span></span></span></span></span></span></span></span>.</div>
-  </div>
-  <div dir="ltr">
-    <div>This element should inherit rtl.</div>
-    <div dir="rtl">This element is ltr.</div>
-    <div dir="ltr">This element is rtl.</div>
-    <div><span>Every <span>word <span>in <span>this <span>element <span>should <span>inherit <span>rtl</span></span></span></span></span></span></span></span>.</div>
-  </div>
-  <div dir="foopy">This element has an invalid dir attribute and
-    should have default direction.</div>
- </body>
-</html>
deleted file mode 100644
--- a/layout/reftests/bidi/562169-2-ref.html
+++ /dev/null
@@ -1,29 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
-  <meta charset="UTF-8">
-  <title>dir() selector</title>
-  <style>
-   .blue { color: blue; direction: ltr; }
-   .lime { color: lime; direction: rtl; }
-   div { text-align: left; }
-  </style>
- </head>
- <body>
-  <div class="lime">This element has default direction.</div>
-  <div class="blue">This element is ltr.</div>
-  <div class="lime">This element is rtl.</div>
-  <div class="blue">
-    <div>This element should inherit ltr.</div>
-    <div class="blue">This element is ltr.</div>
-    <div class="lime">This element is rtl.</div>
-  </div>
-  <div class="lime">
-    <div>This element should inherit rtl.</div>
-    <div class="blue">This element is ltr.</div>
-    <div class="lime">This element is rtl.</div>
-  </div>
-  <div class="lime">This element has an invalid dir attribute and
-    should have default direction.</div>
- </body>
-</html>
deleted file mode 100644
--- a/layout/reftests/bidi/562169-2.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE html>
-<html dir="rtl">
- <head>
-  <meta charset="UTF-8">
-  <title>dir() selector</title>
-  <style>
-   :dir(ltr) { color: blue }
-   :dir(rtl) { color: lime }
-   :dir(foopy) { color: red }
-   div { text-align: left; }
-  </style>
- </head>
- <body>
-  <div>This element has default direction.</div>
-  <div dir="ltr">This element is ltr.</div>
-  <div dir="rtl">This element is rtl.</div>
-  <div dir="ltr">
-    <div>This element should inherit ltr.</div>
-    <div dir="ltr">This element is ltr.</div>
-    <div dir="rtl">This element is rtl.</div>
-  </div>
-  <div dir="rtl">
-    <div>This element should inherit rtl.</div>
-    <div dir="ltr">This element is ltr.</div>
-    <div dir="rtl">This element is rtl.</div>
-  </div>
-  <div dir="foopy">This element has an invalid dir attribute and
-    should have default direction.</div>
- </body>
-</html>
deleted file mode 100644
--- a/layout/reftests/bidi/562169-2a.html
+++ /dev/null
@@ -1,36 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
-  <meta charset="UTF-8">
-  <title>dir() selector</title>
-  <style>
-   :dir(ltr) { color: blue }
-   :dir(rtl) { color: lime }
-   :dir(foopy) { color: red }
-   div { text-align: left; }
-  </style>
-  <script type="text/javascript">
-function switchDir()
-{
-    document.dir = "rtl";
-}
-  </script>
- </head>
- <body onload="switchDir()">
-  <div>This element has default direction.</div>
-  <div dir="ltr">This element is ltr.</div>
-  <div dir="rtl">This element is rtl.</div>
-  <div dir="ltr">
-    <div>This element should inherit ltr.</div>
-    <div dir="ltr">This element is ltr.</div>
-    <div dir="rtl">This element is rtl.</div>
-  </div>
-  <div dir="rtl">
-    <div>This element should inherit rtl.</div>
-    <div dir="ltr">This element is ltr.</div>
-    <div dir="rtl">This element is rtl.</div>
-  </div>
-  <div dir="foopy">This element has an invalid dir attribute and
-    should have default direction.</div>
- </body>
-</html>
deleted file mode 100644
--- a/layout/reftests/bidi/562169-3-ref.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
-  <meta charset="UTF-8">
-  <title>dir() selector</title>
-  <style>
-   .ltr { direction: ltr }
-   .rtl { direction: rtl }
-   div { color: lime; text-align: left; }
-  </style>
- </head>
- <body>
-  <div class="rtl">This element is rtl.</div>
-  <div>This element has default direction.</div>
- </body>
-</html>
deleted file mode 100644
--- a/layout/reftests/bidi/562169-3.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
-  <meta charset="UTF-8">
-  <title>dir() selector</title>
-  <style>
-   :not(:dir(rtl)) + div { color: blue }
-   div { color: lime; text-align: left; }
-  </style>
- </head>
- <body>
-  <div dir="rtl">This element is rtl.</div>
-  <div>This element has default direction.</div>
- </body>
-</html>
deleted file mode 100644
--- a/layout/reftests/bidi/562169-3a.html
+++ /dev/null
@@ -1,26 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
-  <meta charset="UTF-8">
-  <title>dir() selector</title>
-  <style>
-   :not(:dir(rtl)) + div { color: blue }
-   div { color: lime; text-align: left; }
-  </style>
-  <script type="text/javascript">
-function switchDir()
-{
-    theDiv = document.getElementById("d");
-    if (theDiv.dir == "ltr") {
-        theDiv.dir = "rtl";
-    } else if (theDiv.dir == "rtl") {
-        theDiv.dir = "ltr";
-    }
-}
-  </script>
- </head>
- <body onload="switchDir()">
-  <div id="d" dir="ltr">This element is rtl.</div>
-  <div>This element has default direction.</div>
- </body>
-</html>
deleted file mode 100644
--- a/layout/reftests/bidi/562169-4-ref.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
-  <meta charset="UTF-8">
-  <title>dir() selector</title>
-  <style>
-   .lime { direction: rtl; color: lime }
-   div { text-align: left; }
-  </style>
- </head>
- <body>
-  <div class="lime">This element is rtl. <span>This span should
-    inherit rtl from the parent. <span>This span should inherit rtl
-    from the grandparent.</span></span></div>
- </body>
-</html>
deleted file mode 100644
--- a/layout/reftests/bidi/562169-4.html
+++ /dev/null
@@ -1,29 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
-  <meta charset="UTF-8">
-  <title>dir() selector</title>
-  <style>
-   :dir(ltr) { color: blue }
-   :dir(rtl) { color: lime }
-   div { text-align: left; }
-  </style>
-  <script type="text/javascript">
-function AppendElementWithChild() {
-    var x = document.createElement("span");
-    x.innerHTML = "This span should inherit rtl from the parent. ";
-
-    var y = document.createElement("span");
-    y.innerHTML = "This span should inherit rtl from the grandparent.";
-
-    var z = document.getElementById("z");
-
-    x.appendChild(y);
-    z.appendChild(x);
-}
-  </script>
- </head>
- <body onload="AppendElementWithChild()">
-  <div id="z" dir="rtl">This element is rtl. </div>
- </body>
-</html>
--- a/layout/reftests/bidi/reftest.list
+++ b/layout/reftests/bidi/reftest.list
@@ -81,23 +81,16 @@ random-if(winWidget) == 305643-1.html 30
 == 489517-1.html 489517-1-ref.html
 == 489887-1.html 489887-1-ref.html
 == 492231-1.html 492231-1-ref.html
 == 496006-1.html 496006-1-ref.html
 == 503269-1.html 503269-1-ref.html
 == 503957-1.html 503957-1-ref.html
 == 525740-1.html 525740-1-ref.html
 == 536963-1.html 536963-1-ref.html
-== 562169-1.html 562169-1-ref.html
-== 562169-1a.html 562169-1-ref.html
-== 562169-2.html 562169-2-ref.html
-== 562169-2a.html 562169-2-ref.html
-== 562169-3.html 562169-3-ref.html
-== 562169-3a.html 562169-3-ref.html
-== 562169-4.html 562169-4-ref.html
 == 588739-1.html 588739-ref.html
 == 588739-2.html 588739-ref.html
 == 588739-3.html 588739-ref.html
 == 612843-1.html 612843-1-ref.html
 == 613149-1a.html 613149-1-ref.html
 == 613149-1b.html 613149-1-ref.html
 fails-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia) == 613149-2a.html 613149-2-ref.html # bug 696672
 fails-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated&&!azureSkia) == 613149-2b.html 613149-2-ref.html # bug 696672
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -3590,22 +3590,20 @@ CSSParserImpl::ParsePseudoClassWithIdent
   }
   // We expect an identifier with a language abbreviation
   if (eCSSToken_Ident != mToken.mType) {
     REPORT_UNEXPECTED_TOKEN(PEPseudoClassArgNotIdent);
     UngetToken();
     return eSelectorParsingStatus_Error; // our caller calls SkipUntil(')')
   }
 
-  // -moz-locale-dir and :dir can only have values of 'ltr' or 'rtl'.
-  if (aType == nsCSSPseudoClasses::ePseudoClass_mozLocaleDir ||
-      aType == nsCSSPseudoClasses::ePseudoClass_dir) {
+  // -moz-locale-dir can only have values of 'ltr' or 'rtl'.
+  if (aType == nsCSSPseudoClasses::ePseudoClass_mozLocaleDir) {
     if (!mToken.mIdent.EqualsLiteral("ltr") &&
         !mToken.mIdent.EqualsLiteral("rtl")) {
-      REPORT_UNEXPECTED_TOKEN(PEBadDirValue);
       return eSelectorParsingStatus_Error; // our caller calls SkipUntil(')')
     }
   }
 
   // Add the pseudo with the language parameter
   aSelector.AddPseudoClass(aType, mToken.mIdent.get());
 
   // close the parenthesis
--- a/layout/style/nsCSSPseudoClassList.h
+++ b/layout/style/nsCSSPseudoClassList.h
@@ -4,55 +4,37 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* atom list for CSS pseudo-classes */
 
 /*
  * This file contains the list of nsIAtoms and their values for CSS
  * pseudo-classes.  It is designed to be used as inline input to
  * nsCSSPseudoClasses.cpp *only* through the magic of C preprocessing.
- * All entries must be enclosed in the macros CSS_PSEUDO_CLASS,
- * CSS_STATE_DEPENDENT_PSEUDO_CLASS, or CSS_STATE_PSEUDO_CLASS which
- * will have cruel and unusual things done to them.  The entries should
- * be kept in some sort of logical order.  The first argument to
- * CSS_PSEUDO_CLASS is the C++ identifier of the atom.  The second
- * argument is the string value of the atom.
- * CSS_STATE_DEPENDENT_PSEUDO_CLASS and CSS_STATE_PSEUDO_CLASS also take
- * the name of the state bits that the class corresponds to.  Only one
- * of the bits needs to match for a CSS_STATE_PSEUDO_CLASS to match;
- * CSS_STATE_DEPENDENT_PSEUDO_CLASS matching depends on a customized per-class
- * algorithm which should be defined in SelectorMatches() in
- * nsCSSRuleProcessor.cpp.
- *
- * If CSS_STATE_PSEUDO_CLASS is not defined, it'll be automatically
- * defined to CSS_STATE_DEPENDENT_PSEUDO_CLASS;
- * if CSS_STATE_DEPENDENT_PSEUDO_CLASS is not defined, it'll be
- * automatically defined to CSS_PSEUDO_CLASS.
+ * All entries must be enclosed in the macros CSS_PSEUDO_CLASS or
+ * CSS_STATE_PSEUDO_CLASS which will have cruel and unusual things
+ * done to it.  The entries should be kept in some sort of logical
+ * order.  The first argument to CSS_PSEUDO_CLASS is the C++
+ * identifier of the atom.  The second argument is the string value of
+ * the atom.  CSS_STATE_PSEUDO_CLASS also takes the name of the state
+ * bits that the class corresponds to.  Only one of the bits needs to
+ * match for the pseudo-class to match.  If CSS_STATE_PSEUDO_CLASS is
+ * not defined, it'll be automatically defined to CSS_PSEUDO_CLASS.
  */
 
 // OUTPUT_CLASS=nsCSSPseudoClasses
 // MACRO_NAME=CSS_PSEUDO_CLASS
 
-#ifdef DEFINED_CSS_STATE_DEPENDENT_PSEUDO_CLASS
-#error "CSS_STATE_DEPENDENT_PSEUDO_CLASS shouldn't be defined"
-#endif
-
-#ifndef CSS_STATE_DEPENDENT_PSEUDO_CLASS
-#define CSS_STATE_DEPENDENT_PSEUDO_CLASS(_name, _value, _bit) \
-  CSS_PSEUDO_CLASS(_name, _value)
-#define DEFINED_CSS_STATE_DEPENDENT_PSEUDO_CLASS
-#endif
-
 #ifdef DEFINED_CSS_STATE_PSEUDO_CLASS
-#error "CSS_STATE_PSEUDO_CLASS shouldn't be defined"
+#error "This shouldn't be defined"
 #endif
 
 #ifndef CSS_STATE_PSEUDO_CLASS
 #define CSS_STATE_PSEUDO_CLASS(_name, _value, _bit) \
-  CSS_STATE_DEPENDENT_PSEUDO_CLASS(_name, _value, _bit)
+  CSS_PSEUDO_CLASS(_name, _value)
 #define DEFINED_CSS_STATE_PSEUDO_CLASS
 #endif
 
 // The CSS_PSEUDO_CLASS entries should all come before the
 // CSS_STATE_PSEUDO_CLASS entries.  The CSS_PSEUDO_CLASS entry order
 // must be the same as the order of cases in SelectorMatches.
 
 CSS_PSEUDO_CLASS(empty, ":empty")
@@ -103,21 +85,16 @@ CSS_PSEUDO_CLASS(mozWindowInactive, ":-m
 // Matches any table elements that have a nonzero border attribute,
 // according to HTML integer attribute parsing rules.
 CSS_PSEUDO_CLASS(mozTableBorderNonzero, ":-moz-table-border-nonzero")
 
 // :not needs to come at the end of the non-bit pseudo-class list, since
 // it doesn't actually get directly matched on in SelectorMatches.
 CSS_PSEUDO_CLASS(notPseudo, ":not")
 
-// :dir(ltr) and :dir(rtl) match elements whose resolved directionality
-// in the markup language is ltr or rtl respectively
-CSS_STATE_DEPENDENT_PSEUDO_CLASS(dir, ":dir",
-                                 NS_EVENT_STATE_LTR | NS_EVENT_STATE_RTL)
-
 CSS_STATE_PSEUDO_CLASS(link, ":link", NS_EVENT_STATE_UNVISITED)
 // what matches :link or :visited
 CSS_STATE_PSEUDO_CLASS(mozAnyLink, ":-moz-any-link",
                        NS_EVENT_STATE_VISITED | NS_EVENT_STATE_UNVISITED)
 CSS_STATE_PSEUDO_CLASS(visited, ":visited", NS_EVENT_STATE_VISITED)
 
 CSS_STATE_PSEUDO_CLASS(active, ":active", NS_EVENT_STATE_ACTIVE)
 CSS_STATE_PSEUDO_CLASS(checked, ":checked", NS_EVENT_STATE_CHECKED)
@@ -196,13 +173,8 @@ CSS_STATE_PSEUDO_CLASS(mozMeterSubOptimu
                        NS_EVENT_STATE_SUB_OPTIMUM)
 CSS_STATE_PSEUDO_CLASS(mozMeterSubSubOptimum, ":-moz-meter-sub-sub-optimum",
                        NS_EVENT_STATE_SUB_SUB_OPTIMUM)
 
 #ifdef DEFINED_CSS_STATE_PSEUDO_CLASS
 #undef DEFINED_CSS_STATE_PSEUDO_CLASS
 #undef CSS_STATE_PSEUDO_CLASS
 #endif
-
-#ifdef DEFINED_CSS_STATE_DEPENDENT_PSEUDO_CLASS
-#undef DEFINED_CSS_STATE_DEPENDENT_PSEUDO_CLASS
-#undef CSS_STATE_DEPENDENT_PSEUDO_CLASS
-#endif
--- a/layout/style/nsCSSPseudoClasses.cpp
+++ b/layout/style/nsCSSPseudoClasses.cpp
@@ -37,18 +37,17 @@ void nsCSSPseudoClasses::AddRefAtoms()
 }
 
 bool
 nsCSSPseudoClasses::HasStringArg(Type aType)
 {
   return aType == ePseudoClass_lang ||
          aType == ePseudoClass_mozEmptyExceptChildrenWithLocalname ||
          aType == ePseudoClass_mozSystemMetric ||
-         aType == ePseudoClass_mozLocaleDir ||
-         aType == ePseudoClass_dir;
+         aType == ePseudoClass_mozLocaleDir;
 }
 
 bool
 nsCSSPseudoClasses::HasNthPairArg(Type aType)
 {
   return aType == ePseudoClass_nthChild ||
          aType == ePseudoClass_nthLastChild ||
          aType == ePseudoClass_nthOfType ||
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -1303,17 +1303,17 @@ nsCSSRuleProcessor::GetContentStateForVi
  * node, but only one possible RuleProcessorData.
  */
 struct NodeMatchContext {
   // In order to implement nsCSSRuleProcessor::HasStateDependentStyle,
   // we need to be able to see if a node might match an
   // event-state-dependent selector for any value of that event state.
   // So mStateMask contains the states that should NOT be tested.
   //
-  // NOTE: For |mStateMask| to work correctly, it's important that any
+  // NOTE: For |aStateMask| to work correctly, it's important that any
   // change that changes multiple state bits include all those state
   // bits in the notification.  Otherwise, if multiple states change but
   // we do separate notifications then we might determine the style is
   // not state-dependent when it really is (e.g., determining that a
   // :hover:active rule no longer matches when both states are unset).
   const nsEventStates mStateMask;
 
   // Is this link the unique link whose visitedness can affect the style
@@ -1528,31 +1528,17 @@ checkGenericEmptyMatches(Element* aEleme
   do {
     child = aElement->GetChildAt(++index);
     // stop at first non-comment (and non-whitespace for
     // :-moz-only-whitespace) node        
   } while (child && !IsSignificantChild(child, true, isWhitespaceSignificant));
   return (child == nullptr);
 }
 
-// Arrays of the states that are relevant for various pseudoclasses.
-static const nsEventStates sPseudoClassStateDependences[] = {
-#define CSS_PSEUDO_CLASS(_name, _value) \
-  nsEventStates(),
-#define CSS_STATE_DEPENDENT_PSEUDO_CLASS(_name, _value, _states)  \
-  _states,
-#include "nsCSSPseudoClassList.h"
-#undef CSS_STATE_DEPENDENT_PSEUDO_CLASS
-#undef CSS_PSEUDO_CLASS
-  // Add more entries for our fake values to make sure we can't
-  // index out of bounds into this array no matter what.
-  nsEventStates(),
-  nsEventStates()
-};
-
+// An array of the states that are relevant for various pseudoclasses.
 static const nsEventStates sPseudoClassStates[] = {
 #define CSS_PSEUDO_CLASS(_name, _value)         \
   nsEventStates(),
 #define CSS_STATE_PSEUDO_CLASS(_name, _value, _states) \
   _states,
 #include "nsCSSPseudoClassList.h"
 #undef CSS_STATE_PSEUDO_CLASS
 #undef CSS_PSEUDO_CLASS
@@ -1565,17 +1551,17 @@ MOZ_STATIC_ASSERT(NS_ARRAY_LENGTH(sPseud
                   nsCSSPseudoClasses::ePseudoClass_NotPseudoClass + 1,
                   "ePseudoClass_NotPseudoClass is no longer at the end of"
                   "sPseudoClassStates");
 
 // |aDependence| has two functions:
 //  * when non-null, it indicates that we're processing a negation,
 //    which is done only when SelectorMatches calls itself recursively
 //  * what it points to should be set to true whenever a test is skipped
-//    because of aNodeMatchContent.mStateMask
+//    because of aStateMask
 static bool SelectorMatches(Element* aElement,
                               nsCSSSelector* aSelector,
                               NodeMatchContext& aNodeMatchContext,
                               TreeMatchContext& aTreeMatchContext,
                               bool* const aDependence = nullptr)
 
 {
   NS_PRECONDITION(!aSelector->IsPseudoElement(),
@@ -2006,48 +1992,16 @@ static bool SelectorMatches(Element* aEl
           if (!val ||
               (val->Type() == nsAttrValue::eInteger &&
                val->GetIntegerValue() == 0)) {
             return false;
           }
         }
         break;
 
-      case nsCSSPseudoClasses::ePseudoClass_dir:
-        {
-          if (aDependence) {
-            nsEventStates states
-              = sPseudoClassStateDependences[pseudoClass->mType];
-            if (aNodeMatchContext.mStateMask.HasAtLeastOneOfStates(states)) {
-              *aDependence = true;
-              return false;
-            }
-          }
-
-          // if we only had to consider HTML, directionality would be exclusively
-          // LTR or RTL, and this could be just
-          //
-          //  if (dirString.EqualsLiteral("rtl") !=
-          //    aElement->StyleState().HasState(NS_EVENT_STATE_RTL)
-          //
-          // However, in markup languages where there is no direction attribute
-          // we have to consider the possibility that neither dir(rtl) nor
-          // dir(ltr) matches.
-          nsEventStates state = aElement->StyleState();
-          bool elementIsRTL = state.HasState(NS_EVENT_STATE_RTL);
-          bool elementIsLTR = state.HasState(NS_EVENT_STATE_LTR);
-          nsDependentString dirString(pseudoClass->u.mString);
-
-          if ((dirString.EqualsLiteral("rtl") && !elementIsRTL) ||
-              (dirString.EqualsLiteral("ltr") && !elementIsLTR)) {
-            return false;
-          }
-        }
-        break;
-
       default:
         NS_ABORT_IF_FALSE(false, "How did that happen?");
       }
     } else {
       // Bit-based pseudo-classes
       if (statesToCheck.HasAtLeastOneOfStates(NS_EVENT_STATE_HOVER | NS_EVENT_STATE_ACTIVE) &&
           aTreeMatchContext.mCompatMode == eCompatibility_NavQuirks &&
           // global selector:
@@ -2169,20 +2123,20 @@ static bool SelectorMatches(Element* aEl
 
   // apply SelectorMatches to the negated selectors in the chain
   if (!isNegated) {
     for (nsCSSSelector *negation = aSelector->mNegations;
          result && negation; negation = negation->mNegations) {
       bool dependence = false;
       result = !SelectorMatches(aElement, negation, aNodeMatchContext,
                                 aTreeMatchContext, &dependence);
-      // If the selector does match due to the dependence on
-      // aNodeMatchContext.mStateMask, then we want to keep result true
-      // so that the final result of SelectorMatches is true.  Doing so
-      // tells StateEnumFunc that there is a dependence on the state.
+      // If the selector does match due to the dependence on aStateMask,
+      // then we want to keep result true so that the final result of
+      // SelectorMatches is true.  Doing so tells StateEnumFunc that
+      // there is a dependence on the state.
       result = result || dependence;
     }
   }
   return result;
 }
 
 #undef STATE_CHECK
 
@@ -2706,17 +2660,17 @@ nsEventStates ComputeSelectorStateDepend
   nsEventStates states;
   for (nsPseudoClassList* pseudoClass = aSelector.mPseudoClassList;
        pseudoClass; pseudoClass = pseudoClass->mNext) {
     // Tree pseudo-elements overload mPseudoClassList for things that
     // aren't pseudo-classes.
     if (pseudoClass->mType >= nsCSSPseudoClasses::ePseudoClass_Count) {
       continue;
     }
-    states |= sPseudoClassStateDependences[pseudoClass->mType];
+    states |= sPseudoClassStates[pseudoClass->mType];
   }
   return states;
 }
 
 static bool
 AddSelector(RuleCascadeData* aCascade,
             // The part between combinators at the top level of the selector
             nsCSSSelector* aSelectorInTopLevel,