Bug 130303

Summary: HTMLInputElement::defaultEventHandler() shouldn't force style updates.
Product: WebKit Reporter: Andreas Kling <kling>
Component: FormsAssignee: Andreas Kling <kling>
Severity: Normal CC: kling, koivisto
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Description Flags
Patch andersca: review+

Description Andreas Kling 2014-03-16 03:24:43 PDT
HTMLInputElement::defaultEventHandler() shouldn't force style updates.
Comment 1 Andreas Kling 2014-03-16 03:25:59 PDT
Created attachment 226839 [details]
Comment 2 Darin Adler 2014-03-16 08:42:28 PDT
Comment on attachment 226839 [details]

View in context: https://bugs.webkit.org/attachment.cgi?id=226839&action=review

> Source/WebCore/ChangeLog:10
> +        There might be a better way to do this; we only want to know if the
> +        element has/gets a renderer at all, but this is an easy hack to avoid
> +        a lot of unnecessary work.

This comment made me see a little bit of opportunity for additional optimization. We don’t in fact just want to know if the element has a renderer in all cases. We use the renderer for blur and focus. And in the other cases we want to know if there’s a renderer. But in still-other cases we don’t need to check the renderer for null at all!

> Source/WebCore/html/TextFieldInputType.cpp:180
> +    element().document().updateStyleIfNeededForNode(element());
>      if (element().renderer() && (event->isMouseEvent() || event->isDragEvent() || event->eventInterface() == WheelEventInterfaceType || event->type() == eventNames().blurEvent || event->type() == eventNames().focusEvent)) {

Should rearrange this to only do the updateStyleIfNeededForNode after the second half of the if statement returns true. No reason to do this style update for other types of events.
Comment 3 Andreas Kling 2014-03-17 16:14:00 PDT
Committed r165773: <http://trac.webkit.org/changeset/165773>