Skip to content

Commit

Permalink
Remove disabled condition from :active matching
Browse files Browse the repository at this point in the history
We are changing this behavior because other browsers don't have disabled
conditioning for :active and because it will become more consistent with
other pseudo classes:
whatwg/html#6635 (comment)

Fixed: 1287171
Change-Id: Idab2abbbc94cc73fac70e34ef391c5d63518d569
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3453424
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Reviewed-by: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#970008}
NOKEYCHECK=True
GitOrigin-RevId: ed8595a55c008ac96404f2d95408f59c9a3833b6
  • Loading branch information
josepharhar authored and copybara-github committed Feb 11, 2022
1 parent f157cce commit 59bf7f7
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 48 deletions.
3 changes: 1 addition & 2 deletions blink/renderer/core/dom/document.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7283,8 +7283,7 @@ void Document::UpdateActiveState(bool is_active,
SetActiveElement(nullptr);
} else {
Element* new_active_element = inner_element_in_document;
if (!old_active_element && new_active_element &&
!new_active_element->IsDisabledFormControl() && is_active) {
if (!old_active_element && new_active_element && is_active) {
// We are setting the :active chain and freezing it. If future moves
// happen, they will need to reference this chain.
for (Element* element = new_active_element; element;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=help href="https://github.com/whatwg/html/pull/7465">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>

<label id=buttonlabel for=disabledbutton>label for disabled button</label>
<button id=disabledbutton disabled>disabled</button>

<button id=buttonparent disabled>
<div id=buttonchild>child of disabled</div>
</button>

<input id=disabledinput disabled>

<textarea id=disabledtextarea disabled>disabled textarea</textarea>

<script>
promise_test(async () => {
await (new test_driver.Actions()
.pointerMove(2, 2, {origin: disabledbutton})
.pointerDown())
.send();

assert_true(disabledbutton.matches(':active'));

await (new test_driver.Actions()
.pointerUp())
.send();
}, 'Clicking on a disabled button should make it get the :active selector.');

promise_test(async () => {
await (new test_driver.Actions()
.pointerMove(2, 2, {origin: buttonlabel})
.pointerDown())
.send();

assert_true(disabledbutton.matches(':active'));

await (new test_driver.Actions()
.pointerUp())
.send();
}, 'Clicking the label for a disabled button should make the button get the :active selector.');

promise_test(async () => {
await (new test_driver.Actions()
.pointerMove(2, 2, {origin: buttonchild})
.pointerDown())
.send();

assert_true(buttonparent.matches(':active'));

await (new test_driver.Actions()
.pointerUp())
.send();
}, 'Clicking on a child of a disabled button should make the button get the :active selector.');

promise_test(async () => {
await (new test_driver.Actions()
.pointerMove(2, 2, {origin: disabledinput})
.pointerDown())
.send();

assert_true(disabledinput.matches(':active'));

await (new test_driver.Actions()
.pointerUp())
.send();
}, 'Clicking on a disabled input should make it get the :active selector.');

promise_test(async () => {
await (new test_driver.Actions()
.pointerMove(2, 2, {origin: disabledtextarea})
.pointerDown())
.send();

assert_true(disabledtextarea.matches(':active'));

await (new test_driver.Actions()
.pointerUp())
.send();
}, 'Clicking on a disabled textarea should make it get the :active selector.');
</script>

This file was deleted.

This file was deleted.

0 comments on commit 59bf7f7

Please sign in to comment.