Commit cc49a696 authored by kochi@chromium.org's avatar kochi@chromium.org

Set focused flag earlier than dispatching focus events.

Blink used to set focused flag on focused element after
dispatching focus events.

This caused mismatch with other
browsers, during event handler 
  document.querySelector(":focus")
doesn't match anything.

BUG=523126
TEST=fast/events/focus-querySelector-in-focus-event-handler.html

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

git-svn-id: svn://svn.chromium.org/blink/trunk@201118 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 0b7cac5b
PASS :focus matches event.target
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<input type="text">
<script>
var input = document.querySelector('input');
input.addEventListener('focus', function(e) {
var focused = document.querySelector(':focus');
if (e.target === focused) {
testPassed(":focus matches event.target");
} else {
testFailed(":focus doesn't match event.target");
}
}, false);
input.focus();
</script>
......@@ -3455,6 +3455,8 @@ bool Document::setFocusedElement(PassRefPtrWillBeRawPtr<Element> prpNewFocusedEl
// Set focus on the new node
m_focusedElement = newFocusedElement;
m_focusedElement->setFocus(true);
// Dispatch the focus event and let the node do any other focus related activities (important for text fields)
// If page lost focus, event will be dispatched on page focus, don't duplicate
if (page() && (page()->focusController().isFocused())) {
......@@ -3485,8 +3487,6 @@ bool Document::setFocusedElement(PassRefPtrWillBeRawPtr<Element> prpNewFocusedEl
}
}
m_focusedElement->setFocus(true);
if (m_focusedElement->isRootEditableElement())
frame()->spellChecker().didBeginEditing(m_focusedElement.get());
......
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