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)
This commit is contained in:
Matt Brubeck
2012-08-08 08:14:48 -07:00
parent 24bbcfb311
commit 77d013d0d3
34 changed files with 24 additions and 757 deletions

View File

@@ -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___ */

View File

@@ -10,7 +10,6 @@
#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;
@@ -217,18 +216,6 @@ public:
*/
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

View File

@@ -48,7 +48,6 @@ $(NULL)
EXPORTS_NAMESPACES = mozilla/dom mozilla
EXPORTS_mozilla/dom = \
DirectionalityUtils.h \
Element.h \
FragmentOrElement.h \
FromParser.h \

View File

@@ -23,7 +23,6 @@
#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;
@@ -399,10 +398,6 @@ public:
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).
@@ -1858,9 +1853,6 @@ protected:
// defined in nsBidiUtils.h
PRUint32 mBidiOptions;
// The root directionality of this document.
mozilla::directionality::Directionality mDirectionality;
nsCString mContentLanguage;
private:
nsCString mContentType;

View File

@@ -145,16 +145,8 @@ enum {
// 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
};
/**
@@ -1287,8 +1279,6 @@ private:
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
};
@@ -1356,9 +1346,6 @@ public:
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); }

View File

@@ -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

View File

@@ -53,7 +53,6 @@ LOCAL_INCLUDES = \
$(NULL)
CPPSRCS = \
DirectionalityUtils.cpp \
nsAtomListUtils.cpp \
nsAttrAndChildArray.cpp \
nsAttrValue.cpp \

View File

@@ -91,7 +91,6 @@
#include "nsXMLEventsManager.h"
#include "nsBidiUtils.h"
#include "mozilla/dom/DirectionalityUtils.h"
#include "nsIDOMUserDataHandler.h"
#include "nsIDOMXPathEvaluator.h"
@@ -171,7 +170,6 @@
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::directionality;
typedef nsTArray<Link*> LinkArray;
@@ -1512,8 +1510,7 @@ nsIDocument::nsIDocument()
mAllowDNSPrefetch(true),
mIsBeingUsedAsImage(false),
mHasLinksToUpdate(false),
mPartID(0),
mDirectionality(eDir_LTR)
mPartID(0)
{
SetInDocument();
}
@@ -5586,15 +5583,6 @@ nsDocument::SetDir(const nsAString& aDirection)
// 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;

View File

@@ -1048,12 +1048,6 @@ protected:
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);

View File

@@ -51,7 +51,6 @@
#include "nsIDOMMutationEvent.h"
#include "nsMutationEvent.h"
#include "nsNodeUtils.h"
#include "mozilla/dom/DirectionalityUtils.h"
#include "nsDocument.h"
#include "nsAttrValueOrString.h"
#ifdef MOZ_XUL
@@ -129,7 +128,6 @@
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::directionality;
nsEventStates
Element::IntrinsicState() const
@@ -1360,13 +1358,6 @@ nsGenericElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
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;
@@ -1552,13 +1543,6 @@ nsGenericElement::UnbindFromTree(bool aDeep, bool aNullParent)
}
}
// 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

View File

@@ -270,7 +270,6 @@ 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")

View File

@@ -381,8 +381,6 @@ MOCHITEST_FILES_B = \
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 \

View File

@@ -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>

View File

@@ -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>

View File

@@ -248,10 +248,6 @@ private:
#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!

View File

@@ -53,7 +53,6 @@
#include "nsHTMLParts.h"
#include "nsContentUtils.h"
#include "mozilla/dom/DirectionalityUtils.h"
#include "nsString.h"
#include "nsUnicharUtils.h"
#include "nsGkAtoms.h"
@@ -97,7 +96,6 @@
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::directionality;
class nsINodeInfo;
class nsIDOMNodeList;
@@ -1689,24 +1687,6 @@ nsGenericHTMLElement::UpdateEditableState(bool aNotify)
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,
@@ -1909,20 +1889,6 @@ nsGenericHTMLElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
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,

View File

@@ -49,8 +49,6 @@ public:
{
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. **/
@@ -204,8 +202,6 @@ public:
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);

View File

@@ -114,7 +114,6 @@ 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'

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -86,13 +86,6 @@ random-if(winWidget) == 305643-1.html 305643-1-ref.html # depends on windows ver
== 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

View File

@@ -3595,12 +3595,10 @@ CSSParserImpl::ParsePseudoClassWithIdentArg(nsCSSSelector& aSelector,
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(')')
}
}

View File

@@ -9,45 +9,27 @@
* 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
@@ -108,11 +90,6 @@ CSS_PSEUDO_CLASS(mozTableBorderNonzero, ":-moz-table-border-nonzero")
// 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",
@@ -201,8 +178,3 @@ CSS_STATE_PSEUDO_CLASS(mozMeterSubSubOptimum, ":-moz-meter-sub-sub-optimum",
#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

View File

@@ -42,8 +42,7 @@ nsCSSPseudoClasses::HasStringArg(Type aType)
return aType == ePseudoClass_lang ||
aType == ePseudoClass_mozEmptyExceptChildrenWithLocalname ||
aType == ePseudoClass_mozSystemMetric ||
aType == ePseudoClass_mozLocaleDir ||
aType == ePseudoClass_dir;
aType == ePseudoClass_mozLocaleDir;
}
bool

View File

@@ -1308,7 +1308,7 @@ struct NodeMatchContext {
// 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
@@ -1533,21 +1533,7 @@ checkGenericEmptyMatches(Element* aElement,
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(),
@@ -1570,7 +1556,7 @@ MOZ_STATIC_ASSERT(NS_ARRAY_LENGTH(sPseudoClassStates) ==
// * 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,
@@ -2011,38 +1997,6 @@ static bool SelectorMatches(Element* aElement,
}
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?");
}
@@ -2174,10 +2128,10 @@ static bool SelectorMatches(Element* aElement,
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;
}
}
@@ -2711,7 +2665,7 @@ nsEventStates ComputeSelectorStateDependence(nsCSSSelector& aSelector)
if (pseudoClass->mType >= nsCSSPseudoClasses::ePseudoClass_Count) {
continue;
}
states |= sPseudoClassStateDependences[pseudoClass->mType];
states |= sPseudoClassStates[pseudoClass->mType];
}
return states;
}