summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkochi <kochi@chromium.org>2016-03-25 03:20:42 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-25 10:21:41 +0000
commit671b78468b2d2a3457f11dbbc5b3af23c8ad7bff (patch)
treedba6c25125edf201b9c3b6e79d7e389a9ade09f2
parent9bfa2f564d21f22fa74fd0ffbefbf7c290166332 (diff)
downloadchromium_src-671b78468b2d2a3457f11dbbc5b3af23c8ad7bff.zip
chromium_src-671b78468b2d2a3457f11dbbc5b3af23c8ad7bff.tar.gz
chromium_src-671b78468b2d2a3457f11dbbc5b3af23c8ad7bff.tar.bz2
:active state should stick while mouse button is pressed regardless of focus state
For a css selector like 'input:active', it should match even after focus moves out of the element. WebKit used to clear :active flag at focus blur. The clearing code has been there since the KHTML era but looks irrelevant now. BUG=365308 TEST=layout test Review URL: https://codereview.chromium.org/1827363003 Cr-Commit-Position: refs/heads/master@{#383268}
-rw-r--r--third_party/WebKit/LayoutTests/fast/css/active-pseudo-and-focus-move.html44
-rw-r--r--third_party/WebKit/Source/core/dom/Document.cpp3
2 files changed, 44 insertions, 3 deletions
diff --git a/third_party/WebKit/LayoutTests/fast/css/active-pseudo-and-focus-move.html b/third_party/WebKit/LayoutTests/fast/css/active-pseudo-and-focus-move.html
new file mode 100644
index 0000000..8006b92
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/css/active-pseudo-and-focus-move.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<script src='../../resources/testharness.js'></script>
+<script src='../../resources/testharnessreport.js'></script>
+<style>
+input { background-color: black; }
+input:active { background-color: red; }
+</style>
+<div id="sandbox">
+ <input id="i1" type="button"><input id="i2" type="button">
+</div>
+<script>
+if (window.eventSender) {
+ test(() => {
+ var i1 = document.querySelector('#i1');
+ var x = i1.offsetLeft + i1.offsetWidth / 2;
+ var y = i1.offsetTop + i1.offsetHeight / 2;
+ eventSender.mouseMoveTo(x, y);
+
+ var i2 = document.querySelector('#i2');
+
+ assert_equals(getComputedStyle(i1).backgroundColor, 'rgb(0, 0, 0)');
+ assert_equals(getComputedStyle(i2).backgroundColor, 'rgb(0, 0, 0)');
+
+ // Press mouse button
+ eventSender.mouseDown();
+ assert_equals(document.activeElement.id, 'i1');
+ assert_equals(getComputedStyle(i1).backgroundColor, 'rgb(255, 0, 0)');
+ assert_equals(getComputedStyle(i2).backgroundColor, 'rgb(0, 0, 0)');
+
+ // Moving focus via TAB
+ eventSender.keyDown('\t');
+ assert_equals(document.activeElement.id, 'i2');
+ assert_equals(getComputedStyle(i1).backgroundColor, 'rgb(255, 0, 0)');
+ assert_equals(getComputedStyle(i2).backgroundColor, 'rgb(0, 0, 0)');
+
+ // Release mouse button
+ eventSender.mouseUp();
+ assert_equals(getComputedStyle(i1).backgroundColor, 'rgb(0, 0, 0)');
+ assert_equals(getComputedStyle(i2).backgroundColor, 'rgb(0, 0, 0)');
+
+ sandbox.remove();
+ }, ":active state should stick while mouse button is pressed regardless of focus state.");
+}
+</script>
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
index 80cda29..7b5651b 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -3603,9 +3603,6 @@ bool Document::setFocusedElement(PassRefPtrWillBeRawPtr<Element> prpNewFocusedEl
// Remove focus from the existing focus node (if any)
if (oldFocusedElement) {
- if (oldFocusedElement->active())
- oldFocusedElement->setActive(false);
-
oldFocusedElement->setFocus(false);
// Dispatch the blur event and let the node do any other blur related activities (important for text fields)