Disabled form control elements should not be active

Clicking on a disabled form control element like a button should not
make it active. This patch adds a check for the disabled element before
setting the activation. This is as per the spec 
http://www.whatwg.org/specs/web-apps/current-work/multipage/selectors.html#selector-active
This matches the behavior on IE. Firefox behavior is same as Chrome.

BUG=385601
TEST=fast/css/disabled-form-control-elements-should-not-be-active.html

Review URL: https://codereview.chromium.org/340143002

git-svn-id: svn://svn.chromium.org/blink/trunk@176501 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 58645a4a
Style :active should not be applied for disabled Form Control elements
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS background is "rgb(0, 255, 0)"
PASS successfullyParsed is true
TEST COMPLETE
Click Me!
<!DOCTYPE html>
<style>
#outbox {
background-color: #00ff00;
width: 100px;
height: 100px;
}
#outbox:active {
background-color: #ff0000;
}
</style>
<script src='../../resources/js-test.js'></script>
<div id='outbox'>
<button disabled>Click Me!</button>
</div>
<script>
function shouldHaveBackground(element, bg) {
background = getComputedStyle(element, null).getPropertyValue('background-color');
shouldBeEqualToString('background', bg);
}
description('Style :active should not be applied for disabled Form Control elements');
if (window.testRunner) {
var box = document.getElementById('outbox');
eventSender.dragMode = false;
var button = document.querySelector('button');
var buttonRect = button.getBoundingClientRect();
// Click the button.
eventSender.mouseMoveTo(buttonRect.left + 5, buttonRect.top + 5);
eventSender.mouseDown();
shouldHaveBackground(box, 'rgb(0, 255, 0)');
eventSender.mouseUp();
}
</script>
...@@ -5481,7 +5481,7 @@ void Document::updateHoverActiveState(const HitTestRequest& request, Element* in ...@@ -5481,7 +5481,7 @@ void Document::updateHoverActiveState(const HitTestRequest& request, Element* in
setActiveHoverElement(nullptr); setActiveHoverElement(nullptr);
} else { } else {
Element* newActiveElement = innerElementInDocument; Element* newActiveElement = innerElementInDocument;
if (!oldActiveElement && newActiveElement && request.active() && !request.touchMove()) { if (!oldActiveElement && newActiveElement && !newActiveElement->isDisabledFormControl() && request.active() && !request.touchMove()) {
// We are setting the :active chain and freezing it. If future moves happen, they // We are setting the :active chain and freezing it. If future moves happen, they
// will need to reference this chain. // will need to reference this chain.
for (RenderObject* curr = newActiveElement->renderer(); curr; curr = curr->parent()) { for (RenderObject* curr = newActiveElement->renderer(); curr; curr = curr->parent()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment