Backed out changeset 6c4807171f00 (bug 1323618) on jaws' request. r=backout

This commit is contained in:
Sebastian Hengst 2017-01-12 18:45:39 +01:00
Родитель a5d7653858
Коммит 7e8e7b64ec
8 изменённых файлов: 36 добавлений и 84 удалений

Просмотреть файл

@ -1755,8 +1755,6 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, {
* Options object:
* `parents`: True if the pseudo-class should be added
* to parent nodes.
* `enabled`: False if the pseudo-class should be locked
* to 'off'. Defaults to true.
*
* @returns An empty packet. A "pseudoClassLock" mutation will
* be queued for any changed nodes.
@ -1774,9 +1772,7 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, {
}
}
let enabled = options.enabled === undefined ||
options.enabled;
this._addPseudoClassLock(node, pseudo, enabled);
this._addPseudoClassLock(node, pseudo);
if (!options.parents) {
return;
@ -1786,7 +1782,7 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, {
let cur;
while ((cur = walker.parentNode())) {
let curNode = this._ref(cur);
this._addPseudoClassLock(curNode, pseudo, enabled);
this._addPseudoClassLock(curNode, pseudo);
}
},
@ -1798,11 +1794,11 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, {
});
},
_addPseudoClassLock: function (node, pseudo, enabled) {
_addPseudoClassLock: function (node, pseudo) {
if (node.rawNode.nodeType !== Ci.nsIDOMNode.ELEMENT_NODE) {
return false;
}
DOMUtils.addPseudoClassLock(node.rawNode, pseudo, enabled);
DOMUtils.addPseudoClassLock(node.rawNode, pseudo);
this._activePseudoClassLocks.add(node);
this._queuePseudoClassMutation(node);
return true;

Просмотреть файл

@ -1,4 +1,3 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

Просмотреть файл

@ -60,21 +60,16 @@ function checkChange(change, expectation) {
is(target.pseudoClassLocks.length, expectation.pseudos.length,
"Expect " + expectation.pseudos.length + " pseudoclass locks.");
for (let i = 0; i < expectation.pseudos.length; i++) {
let pseudo = expectation.pseudos[i];
let enabled = expectation.enabled === undefined ? true : expectation.enabled[i];
for (let pseudo of expectation.pseudos) {
ok(target.hasPseudoClassLock(pseudo), "Expect lock: " + pseudo);
let rawNode = target.rawNode();
ok(DOMUtils.hasPseudoClassLock(rawNode, pseudo), "Expect lock in dom: " + pseudo);
is(rawNode.matches(pseudo), enabled,
`Target should match pseudoclass, '${pseudo}', if enabled (with .matches())`);
ok(DOMUtils.hasPseudoClassLock(target.rawNode(), pseudo), "Expect lock in dom: " + pseudo);
}
for (let pseudo of KNOWN_PSEUDOCLASSES) {
if (!expectation.pseudos.some(expected => pseudo === expected)) {
ok(!target.hasPseudoClassLock(pseudo), "Don't expect lock: " + pseudo);
ok(!DOMUtils.hasPseudoClassLock(target.rawNode(), pseudo), "Don't expect lock in dom: " + pseudo);
}
}
}
@ -98,7 +93,7 @@ addTest(function testPseudoClassLock() {
// Expect a single pseudoClassLock mutation.
return promiseOnce(gWalker, "mutations");
}).then(mutations => {
is(mutations.length, 1, "Should get one mutation");
is(mutations.length, 1, "Should get one mutations");
is(mutations[0].target, nodeFront, "Should be the node we tried to apply to");
checkChange(mutations[0], {
id: "b",
@ -154,18 +149,6 @@ addTest(function testPseudoClassLock() {
pseudos: []
}];
checkMutations(mutations, expectedMutations);
}).then(() => {
gWalker.addPseudoClassLock(nodeFront, ":hover", {enabled: false});
return promiseOnce(gWalker, "mutations");
}).then(mutations => {
is(mutations.length, 1, "Should get one mutation");
is(mutations[0].target, nodeFront, "Should be the node we tried to apply to");
checkChange(mutations[0], {
id: "b",
nodeName: "DIV",
pseudos: [":hover", ":active"],
enabled: [false, true]
});
}).then(() => {
// Now shut down the walker and make sure that clears up the remaining lock.
return gWalker.release();

Просмотреть файл

@ -234,8 +234,7 @@ const walkerSpec = generateActorSpec({
request: {
node: Arg(0, "domnode"),
pseudoClass: Arg(1),
parents: Option(2),
enabled: Option(2, "boolean"),
parents: Option(2)
},
response: {}
},

Просмотреть файл

@ -346,30 +346,27 @@ Element::Blur(mozilla::ErrorResult& aError)
EventStates
Element::StyleStateFromLocks() const
{
StyleStateLocks locksAndValues = LockedStyleStates();
EventStates locks = locksAndValues.mLocks;
EventStates values = locksAndValues.mValues;
EventStates state = (mState & ~locks) | (locks & values);
EventStates locks = LockedStyleStates();
EventStates state = mState | locks;
if (state.HasState(NS_EVENT_STATE_VISITED)) {
if (locks.HasState(NS_EVENT_STATE_VISITED)) {
return state & ~NS_EVENT_STATE_UNVISITED;
}
if (state.HasState(NS_EVENT_STATE_UNVISITED)) {
if (locks.HasState(NS_EVENT_STATE_UNVISITED)) {
return state & ~NS_EVENT_STATE_VISITED;
}
return state;
}
Element::StyleStateLocks
EventStates
Element::LockedStyleStates() const
{
StyleStateLocks* locks =
static_cast<StyleStateLocks*>(GetProperty(nsGkAtoms::lockedStyleStates));
EventStates* locks =
static_cast<EventStates*>(GetProperty(nsGkAtoms::lockedStyleStates));
if (locks) {
return *locks;
}
return StyleStateLocks();
return EventStates();
}
void
@ -386,26 +383,21 @@ Element::NotifyStyleStateChange(EventStates aStates)
}
void
Element::LockStyleStates(EventStates aStates, bool aEnabled)
Element::LockStyleStates(EventStates aStates)
{
StyleStateLocks* locks = new StyleStateLocks(LockedStyleStates());
EventStates* locks = new EventStates(LockedStyleStates());
locks->mLocks |= aStates;
if (aEnabled) {
locks->mValues |= aStates;
} else {
locks->mValues &= ~aStates;
}
*locks |= aStates;
if (aStates.HasState(NS_EVENT_STATE_VISITED)) {
locks->mLocks &= ~NS_EVENT_STATE_UNVISITED;
*locks &= ~NS_EVENT_STATE_UNVISITED;
}
if (aStates.HasState(NS_EVENT_STATE_UNVISITED)) {
locks->mLocks &= ~NS_EVENT_STATE_VISITED;
*locks &= ~NS_EVENT_STATE_VISITED;
}
SetProperty(nsGkAtoms::lockedStyleStates, locks,
nsINode::DeleteProperty<StyleStateLocks>);
nsINode::DeleteProperty<EventStates>);
SetHasLockedStyleStates();
NotifyStyleStateChange(aStates);
@ -414,18 +406,18 @@ Element::LockStyleStates(EventStates aStates, bool aEnabled)
void
Element::UnlockStyleStates(EventStates aStates)
{
StyleStateLocks* locks = new StyleStateLocks(LockedStyleStates());
EventStates* locks = new EventStates(LockedStyleStates());
locks->mLocks &= ~aStates;
*locks &= ~aStates;
if (locks->mLocks.IsEmpty()) {
if (locks->IsEmpty()) {
DeleteProperty(nsGkAtoms::lockedStyleStates);
ClearHasLockedStyleStates();
delete locks;
}
else {
SetProperty(nsGkAtoms::lockedStyleStates, locks,
nsINode::DeleteProperty<StyleStateLocks>);
nsINode::DeleteProperty<EventStates>);
}
NotifyStyleStateChange(aStates);
@ -434,12 +426,12 @@ Element::UnlockStyleStates(EventStates aStates)
void
Element::ClearStyleStateLocks()
{
StyleStateLocks locks = LockedStyleStates();
EventStates locks = LockedStyleStates();
DeleteProperty(nsGkAtoms::lockedStyleStates);
ClearHasLockedStyleStates();
NotifyStyleStateChange(locks.mLocks);
NotifyStyleStateChange(locks);
}
bool

Просмотреть файл

@ -244,27 +244,15 @@ public:
return StyleStateFromLocks();
}
/**
* StyleStateLocks is used to specify which event states should be locked,
* and whether they should be locked to on or off.
*/
struct StyleStateLocks {
// mLocks tracks which event states should be locked.
EventStates mLocks;
// mValues tracks if the locked state should be on or off.
EventStates mValues;
};
/**
* The style state locks applied to this element.
*/
StyleStateLocks LockedStyleStates() const;
EventStates LockedStyleStates() const;
/**
* Add a style state lock on this element.
* aEnabled is the value to lock the given state bits to.
*/
void LockStyleStates(EventStates aStates, bool aEnabled);
void LockStyleStates(EventStates aStates);
/**
* Remove a style state lock on this element.

Просмотреть файл

@ -1254,9 +1254,7 @@ inDOMUtils::GetCSSPseudoElementNames(uint32_t* aLength, char16_t*** aNames)
NS_IMETHODIMP
inDOMUtils::AddPseudoClassLock(nsIDOMElement *aElement,
const nsAString &aPseudoClass,
bool aEnabled,
uint8_t aArgc)
const nsAString &aPseudoClass)
{
EventStates state = GetStatesForPseudoClass(aPseudoClass);
if (state.IsEmpty()) {
@ -1266,7 +1264,7 @@ inDOMUtils::AddPseudoClassLock(nsIDOMElement *aElement,
nsCOMPtr<mozilla::dom::Element> element = do_QueryInterface(aElement);
NS_ENSURE_ARG_POINTER(element);
element->LockStyleStates(state, aArgc > 0 ? aEnabled : true);
element->LockStyleStates(state);
return NS_OK;
}
@ -1302,7 +1300,7 @@ inDOMUtils::HasPseudoClassLock(nsIDOMElement *aElement,
nsCOMPtr<mozilla::dom::Element> element = do_QueryInterface(aElement);
NS_ENSURE_ARG_POINTER(element);
EventStates locks = element->LockedStyleStates().mLocks;
EventStates locks = element->LockedStyleStates();
*_retval = locks.HasAllStates(state);
return NS_OK;

Просмотреть файл

@ -185,11 +185,8 @@ interface inIDOMUtils : nsISupports
// pseudo-class style locking methods. aPseudoClass must be a valid pseudo-class
// selector string, e.g. ":hover". ":any-link" and non-event-state
// pseudo-classes are ignored. aEnabled sets whether the psuedo-class
// should be locked to on or off.
[optional_argc] void addPseudoClassLock(in nsIDOMElement aElement,
in DOMString aPseudoClass,
[optional] in boolean aEnabled);
// pseudo-classes are ignored.
void addPseudoClassLock(in nsIDOMElement aElement, in DOMString aPseudoClass);
void removePseudoClassLock(in nsIDOMElement aElement, in DOMString aPseudoClass);
bool hasPseudoClassLock(in nsIDOMElement aElement, in DOMString aPseudoClass);
void clearPseudoClassLocks(in nsIDOMElement aElement);