Bug 843003 - Send events and allow :hover to apply on <button>'s children. r=bz
This commit is contained in:
@@ -325,23 +325,6 @@ HTMLButtonElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_MOUSE_ENTER_SYNTH:
|
||||
{
|
||||
aVisitor.mPresContext->EventStateManager()->
|
||||
SetContentState(this, NS_EVENT_STATE_HOVER);
|
||||
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
break;
|
||||
|
||||
// XXX this doesn't seem to do anything yet
|
||||
case NS_MOUSE_EXIT_SYNTH:
|
||||
{
|
||||
aVisitor.mPresContext->EventStateManager()->
|
||||
SetContentState(nullptr, NS_EVENT_STATE_HOVER);
|
||||
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -119,8 +119,6 @@ nsHTMLButtonControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
|
||||
nsDisplayListCollection set;
|
||||
|
||||
// Do not allow the child subtree to receive events.
|
||||
if (!aBuilder->IsForEventDelivery()) {
|
||||
DisplayListClipState::AutoSaveRestore clipState(aBuilder);
|
||||
|
||||
if (IsInput() || StyleDisplay()->mOverflowX != NS_STYLE_OVERFLOW_VISIBLE) {
|
||||
@@ -132,10 +130,9 @@ nsHTMLButtonControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
clipState.ClipContainingBlockDescendants(rect, hasRadii ? radii : nullptr);
|
||||
}
|
||||
|
||||
// That should put the display items in set.Content()
|
||||
BuildDisplayListForChild(aBuilder, mFrames.FirstChild(), aDirtyRect, set,
|
||||
DISPLAY_CHILD_FORCE_PSEUDO_STACKING_CONTEXT);
|
||||
// That should put the display items in set.Content()
|
||||
}
|
||||
|
||||
// Put the foreground outline and focus rects on top of the children
|
||||
set.Content()->AppendToTop(&onTop);
|
||||
|
||||
@@ -45,6 +45,7 @@ MOCHITEST_FILES = test_bug231389.html \
|
||||
test_bug704049.html \
|
||||
test_bug869314.html \
|
||||
test_listcontrol_search.html \
|
||||
test_button_inner_events.html \
|
||||
$(NULL)
|
||||
|
||||
MOCHITEST_CHROME_FILES = \
|
||||
|
||||
141
layout/forms/test/test_button_inner_events.html
Normal file
141
layout/forms/test/test_button_inner_events.html
Normal file
@@ -0,0 +1,141 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=843003
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 843003</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"/>
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 843003 **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var currentEvent = "";
|
||||
var buttonEvents = 0;
|
||||
var spanEvents = 0;
|
||||
var b = null;
|
||||
var s = null;
|
||||
|
||||
function buttonEventHandler(e) {
|
||||
is(e.type, currentEvent, "should get the expected event");
|
||||
buttonEvents++;
|
||||
}
|
||||
|
||||
function spanEventHandler(e) {
|
||||
is(e.type, currentEvent, "should get the expected event");
|
||||
spanEvents++;
|
||||
}
|
||||
|
||||
function setup(name) {
|
||||
currentEvent = name;
|
||||
b.addEventListener(currentEvent, buttonEventHandler);
|
||||
s.addEventListener(currentEvent, spanEventHandler);
|
||||
}
|
||||
|
||||
function test(expectedButtonEvents, expectedSpanEvents) {
|
||||
is(buttonEvents, expectedButtonEvents,
|
||||
"button should have received " + expectedButtonEvents + " " +
|
||||
currentEvent + " events");
|
||||
is(spanEvents, expectedSpanEvents,
|
||||
"span should have received " + expectedSpanEvents + " " +
|
||||
currentEvent + " events");
|
||||
}
|
||||
|
||||
function clear() {
|
||||
b.removeEventListener(currentEvent, buttonEventHandler);
|
||||
s.removeEventListener(currentEvent, spanEventHandler);
|
||||
currentEvent = "";
|
||||
buttonEvents = 0;
|
||||
spanEvents = 0;
|
||||
}
|
||||
|
||||
SimpleTest.waitForFocus(function() {
|
||||
b = document.getElementsByTagName('button')[0];
|
||||
s = document.getElementsByTagName('span')[0];
|
||||
|
||||
setup('focus');
|
||||
b.focus();
|
||||
test(1, 0);
|
||||
clear();
|
||||
|
||||
setup('blur');
|
||||
b.blur();
|
||||
test(1, 0);
|
||||
clear();
|
||||
|
||||
setup('focus');
|
||||
s.focus();
|
||||
test(0, 0);
|
||||
clear();
|
||||
is(document.activeElement, document.body, "focus is back to body");
|
||||
|
||||
if (!navigator.platform.startsWith("Mac")) {
|
||||
setup('focus');
|
||||
synthesizeMouseAtCenter(b, {});
|
||||
test(1, 0);
|
||||
clear();
|
||||
}
|
||||
|
||||
setup('mousedown');
|
||||
synthesizeMouseAtCenter(b, {});
|
||||
test(1, 1);
|
||||
clear();
|
||||
|
||||
setup('mouseup');
|
||||
synthesizeMouseAtCenter(b, {});
|
||||
test(1, 1);
|
||||
clear();
|
||||
|
||||
setup('click');
|
||||
synthesizeMouseAtCenter(b, {});
|
||||
test(1, 1);
|
||||
clear();
|
||||
|
||||
b.focus();
|
||||
|
||||
setup('keydown');
|
||||
synthesizeKey("VK_A", {});
|
||||
test(1, 0);
|
||||
clear();
|
||||
|
||||
setup('keyup');
|
||||
synthesizeKey("VK_A", {});
|
||||
test(1, 0);
|
||||
clear();
|
||||
|
||||
setup('keypress');
|
||||
synthesizeKey("VK_A", {});
|
||||
test(1, 0);
|
||||
clear();
|
||||
|
||||
setup('DOMActivate');
|
||||
synthesizeMouseAtCenter(b, {});
|
||||
test(1, 0);
|
||||
clear();
|
||||
|
||||
synthesizeMouseAtCenter(b, { type: 'mouseover' });
|
||||
is(b.mozMatchesSelector(":hover"), true, ":hover should match");
|
||||
is(s.mozMatchesSelector(":hover"), true, ":hover should match");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=843003">Mozilla Bug 843003</a>
|
||||
<p id="display"></p>
|
||||
<div id="content">
|
||||
<button>
|
||||
<span>foo</button>
|
||||
</button>
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user