Bug 130303 - HTMLInputElement::defaultEventHandler() shouldn't force style updates.
Summary: HTMLInputElement::defaultEventHandler() shouldn't force style updates.
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Andreas Kling
Depends on:
Reported: 2014-03-16 03:24 PDT by Andreas Kling
Modified: 2014-03-17 16:14 PDT (History)
2 users (show)

See Also:

Patch (2.22 KB, patch)
2014-03-16 03:25 PDT, Andreas Kling
andersca: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>