2017-09-18 Antti Koivisto <antti@apple.com>
+ Rolling out the previous to land again with a test.
+
+ * dom/Document.cpp:
+ (WebCore::Document::setFocusedElement):
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::didBlur):
+
+2017-09-18 Antti Koivisto <antti@apple.com>
+
Avoid style resolution when clearing focused element.
https://bugs.webkit.org/show_bug.cgi?id=176224
<rdar://problem/34206409>
view()->setFocus(false);
}
- if (is<HTMLInputElement>(oldFocusedElement.get())) {
- // HTMLInputElement::didBlur just scrolls text fields back to the beginning.
- // FIXME: This could be done asynchronusly.
- // Updating style may dispatch events due to PostResolutionCallback
- if (eventsMode == FocusRemovalEventsMode::Dispatch)
- updateStyleIfNeeded();
+ if (is<HTMLInputElement>(oldFocusedElement.get()))
downcast<HTMLInputElement>(*oldFocusedElement).didBlur();
- }
}
if (newFocusedElement && newFocusedElement->isFocusable()) {
page()->chrome().focusedElementChanged(m_focusedElement.get());
SetFocusedNodeDone:
- // Updating style may dispatch events due to PostResolutionCallback
- // FIXME: Why is synchronous style update needed here at all?
- if (eventsMode == FocusRemovalEventsMode::Dispatch)
- updateStyleIfNeeded();
+ updateStyleIfNeeded();
return !focusChangeBlocked;
}
void HTMLInputElement::didBlur()
{
+ // We need to update style here, rather than in InputType itself, since style recomputation may fire events
+ // that could change the input's type.
+ document().updateStyleIfNeeded();
m_inputType->elementDidBlur();
}