HTMLInputElement::defaultEventHandler() shouldn't force style updates.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Mar 2014 23:13:27 +0000 (23:13 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Mar 2014 23:13:27 +0000 (23:13 +0000)
<https://webkit.org/b/130303>

Move the updateStyleIfNeeded() call down to TextFieldInputType instead
of doing it for every HTMLInputEvent.

There might be a better way to do this; we only want to know about this
specific element's renderer, and don't need the rest of the tree.
This is still an easy hack to avoid a lot of unnecessary work.

Reviewed by Anders Carlsson.

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::defaultEventHandler):
* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::forwardEvent):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@165773 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/TextFieldInputType.cpp

index b35220f370ce099884dfa5a2bb5890d30b6a54e5..9d874d1e554fd843f297668df01195332d2d040c 100644 (file)
@@ -1,3 +1,22 @@
+2014-03-16  Andreas Kling  <akling@apple.com>
+
+        HTMLInputElement::defaultEventHandler() shouldn't force style updates.
+        <https://webkit.org/b/130303>
+
+        Move the updateStyleIfNeeded() call down to TextFieldInputType instead
+        of doing it for every HTMLInputEvent.
+
+        There might be a better way to do this; we only want to know about this
+        specific element's renderer, and don't need the rest of the tree.
+        This is still an easy hack to avoid a lot of unnecessary work.
+
+        Reviewed by Anders Carlsson.
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::defaultEventHandler):
+        * html/TextFieldInputType.cpp:
+        (WebCore::TextFieldInputType::forwardEvent):
+
 2014-03-17  Brent Fulgham  <bfulgham@apple.com>
 
         [WebVTT] Extending WebVTT Rendering with Regions
index f8c9777199e7688d4813bc5ab5888f2fb6667d8e..58a940cd610e9025819302feb287e3d24e0db7a8 100644 (file)
@@ -1176,7 +1176,6 @@ void HTMLInputElement::defaultEventHandler(Event* evt)
             return;
     }
 
-    document().updateStyleIfNeededForNode(*this);
     m_inputType->forwardEvent(evt);
 
     if (!callBaseClassEarly && !evt->defaultHandled())
index 4398bc25a1f0073cc441fc66f0a6dfa75b8d69d5..c3f6ffa8d11766afc0bf27ad496caf84c4ad3c5d 100644 (file)
@@ -176,21 +176,30 @@ void TextFieldInputType::forwardEvent(Event* event)
             return;
     }
 
-    if (element().renderer() && (event->isMouseEvent() || event->isDragEvent() || event->eventInterface() == WheelEventInterfaceType || event->type() == eventNames().blurEvent || event->type() == eventNames().focusEvent)) {
-        RenderTextControlSingleLine* renderTextControl = toRenderTextControlSingleLine(element().renderer());
-        if (event->type() == eventNames().blurEvent) {
-            if (RenderTextControlInnerBlock* innerTextRenderer = innerTextElement()->renderer()) {
-                if (RenderLayer* innerLayer = innerTextRenderer->layer()) {
-                    IntSize scrollOffset(!renderTextControl->style().isLeftToRightDirection() ? innerLayer->scrollWidth() : 0, 0);
-                    innerLayer->scrollToOffset(scrollOffset, RenderLayer::ScrollOffsetClamped);
+    if (event->isMouseEvent()
+        || event->isDragEvent()
+        || event->eventInterface() == WheelEventInterfaceType
+        || event->type() == eventNames().blurEvent
+        || event->type() == eventNames().focusEvent)
+    {
+        element().document().updateStyleIfNeededForNode(element());
+
+        if (element().renderer()) {
+            RenderTextControlSingleLine* renderTextControl = toRenderTextControlSingleLine(element().renderer());
+            if (event->type() == eventNames().blurEvent) {
+                if (RenderTextControlInnerBlock* innerTextRenderer = innerTextElement()->renderer()) {
+                    if (RenderLayer* innerLayer = innerTextRenderer->layer()) {
+                        IntSize scrollOffset(!renderTextControl->style().isLeftToRightDirection() ? innerLayer->scrollWidth() : 0, 0);
+                        innerLayer->scrollToOffset(scrollOffset, RenderLayer::ScrollOffsetClamped);
+                    }
                 }
-            }
 
-            renderTextControl->capsLockStateMayHaveChanged();
-        } else if (event->type() == eventNames().focusEvent)
-            renderTextControl->capsLockStateMayHaveChanged();
+                renderTextControl->capsLockStateMayHaveChanged();
+            } else if (event->type() == eventNames().focusEvent)
+                renderTextControl->capsLockStateMayHaveChanged();
 
-        element().forwardEvent(event);
+            element().forwardEvent(event);
+        }
     }
 }