Bug 1150308 - Use flattened tree parent when settings event state on ancestors. r=smaug

This commit is contained in:
William Chen 2015-04-08 18:13:48 -07:00
Родитель 14910f6300
Коммит a1dae92265
3 изменённых файлов: 50 добавлений и 8 удалений

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

@ -4608,7 +4608,7 @@ static nsIContent* FindCommonAncestor(nsIContent *aNode1, nsIContent *aNode2)
nsIContent *anc1 = aNode1;
for (;;) {
++offset;
nsIContent* parent = anc1->GetParent();
nsIContent* parent = anc1->GetFlattenedTreeParent();
if (!parent)
break;
anc1 = parent;
@ -4616,7 +4616,7 @@ static nsIContent* FindCommonAncestor(nsIContent *aNode1, nsIContent *aNode2)
nsIContent *anc2 = aNode2;
for (;;) {
--offset;
nsIContent* parent = anc2->GetParent();
nsIContent* parent = anc2->GetFlattenedTreeParent();
if (!parent)
break;
anc2 = parent;
@ -4625,16 +4625,16 @@ static nsIContent* FindCommonAncestor(nsIContent *aNode1, nsIContent *aNode2)
anc1 = aNode1;
anc2 = aNode2;
while (offset > 0) {
anc1 = anc1->GetParent();
anc1 = anc1->GetFlattenedTreeParent();
--offset;
}
while (offset < 0) {
anc2 = anc2->GetParent();
anc2 = anc2->GetFlattenedTreeParent();
++offset;
}
while (anc1 != anc2) {
anc1 = anc1->GetParent();
anc2 = anc2->GetParent();
anc1 = anc1->GetFlattenedTreeParent();
anc2 = anc2->GetFlattenedTreeParent();
}
return anc1;
}
@ -4690,7 +4690,7 @@ EventStateManager::UpdateAncestorState(nsIContent* aStartNode,
bool aAddState)
{
for (; aStartNode && aStartNode != aStopBefore;
aStartNode = aStartNode->GetParentElementCrossingShadowRoot()) {
aStartNode = aStartNode->GetFlattenedTreeParent()) {
// We might be starting with a non-element (e.g. a text node) and
// if someone is doing something weird might be ending with a
// non-element too (e.g. a document fragment)
@ -4718,7 +4718,7 @@ EventStateManager::UpdateAncestorState(nsIContent* aStartNode,
// still be in hover state. To handle this situation we need to
// keep walking up the tree and any time we find a label mark its
// corresponding node as still in our state.
for ( ; aStartNode; aStartNode = aStartNode->GetParentElementCrossingShadowRoot()) {
for ( ; aStartNode; aStartNode = aStartNode->GetFlattenedTreeParent()) {
if (!aStartNode->IsElement()) {
continue;
}

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

@ -142,6 +142,7 @@ support-files = bug1017086_inner.html
support-files = bug1017086_inner.html
[test_bug1079236.html]
[test_bug1145910.html]
[test_bug1150308.html]
[test_clickevent_on_input.html]
skip-if = toolkit == 'android' #CRASH_DUMP, RANDOM
[test_continuous_wheel_events.html]

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

@ -0,0 +1,41 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1150308
-->
<head>
<title>Test for Bug 1150308</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<div id="host"><span id="distributeme">Foo</span></div>
<script type="application/javascript">
/** Test for Bug 1150308 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var host = document.getElementById("host");
var shadow = host.createShadowRoot();
shadow.innerHTML = '<style>.bar:active { color: rgb(0, 255, 0); }</style><div class="bar" id="inner"><content></content></div>';
var inner = shadow.getElementById("inner");
var distributed = document.getElementById("distributeme");
is(window.getComputedStyle(inner).color, "rgb(0, 0, 0)", "The div inside the shadow root should not be active.");
synthesizeMouseAtCenter(distributed, { type: "mousedown" });
is(window.getComputedStyle(inner).color, "rgb(0, 255, 0)", "Div inside shadow root should be active.");
synthesizeMouseAtCenter(distributed, { type: "mouseup" });
is(window.getComputedStyle(inner).color, "rgb(0, 0, 0)", "Div inside shadow root should no longer be active.");
SimpleTest.finish();
});
</script>
</body>
</html>