Title: [222167] trunk
Revision
222167
Author
[email protected]
Date
2017-09-18 11:23:22 -0700 (Mon, 18 Sep 2017)

Log Message

Avoid style resolution when clearing focused element.
https://bugs.webkit.org/show_bug.cgi?id=176224
<rdar://problem/34206409>

Reviewed by Zalan Bujtas.

Source/WebCore:

Test: fast/dom/focus-style-resolution.html

* dom/Document.cpp:
(WebCore::Document::setFocusedElement):

    Don't do synchronous style resolution with FocusRemovalEventsMode::DoNotDispatch.
    Style resolution may dispatch events.

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didBlur):

    Move resolveStyleIfNeeded call to setFocusedElement. It is the only client for didBlur.

LayoutTests:

* fast/dom/focus-style-resolution-expected.txt: Added.
* fast/dom/focus-style-resolution.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (222166 => 222167)


--- trunk/LayoutTests/ChangeLog	2017-09-18 18:21:17 UTC (rev 222166)
+++ trunk/LayoutTests/ChangeLog	2017-09-18 18:23:22 UTC (rev 222167)
@@ -1,5 +1,16 @@
 2017-09-18  Antti Koivisto  <[email protected]>
 
+        Avoid style resolution when clearing focused element.
+        https://bugs.webkit.org/show_bug.cgi?id=176224
+        <rdar://problem/34206409>
+
+        Reviewed by Zalan Bujtas.
+
+        * fast/dom/focus-style-resolution-expected.txt: Added.
+        * fast/dom/focus-style-resolution.html: Added.
+
+2017-09-18  Antti Koivisto  <[email protected]>
+
         Try to unflake a test.
 
         Unreviewed.

Added: trunk/LayoutTests/fast/dom/focus-style-resolution-expected.txt (0 => 222167)


--- trunk/LayoutTests/fast/dom/focus-style-resolution-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/focus-style-resolution-expected.txt	2017-09-18 18:23:22 UTC (rev 222167)
@@ -0,0 +1,2 @@
+This test passes if it doesn't assert or crash.
+  

Added: trunk/LayoutTests/fast/dom/focus-style-resolution.html (0 => 222167)


--- trunk/LayoutTests/fast/dom/focus-style-resolution.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/focus-style-resolution.html	2017-09-18 18:23:22 UTC (rev 222167)
@@ -0,0 +1,31 @@
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+function eventhandler1() {
+txt.appendChild(kg);
+}
+
+function eventhandler2() {
+anim.appendChild(kg);
+}
+
+function eventhandler3() {
+table.scrollIntoView(true);
+testRunner.notifyDone();
+}
+
+</script>
+This test passes if it doesn't assert or crash.
+<table id="table"></table>
+<form>
+<input id="kg" autofocus="autofocus">
+</form>
+<svg>
+<animate id="anim" attributeName="text-anchor" from="middle" to="inherit" _onbegin_="eventhandler1()" />
+<text id="txt" _onload_="eventhandler3()">
+<font color="white"></font>
+<select _onfocus_="eventhandler2()" autofocus="autofocus">
+<textarea>a</textarea>
+<iframe _onload_="eventhandler1()"></iframe>

Modified: trunk/Source/WebCore/ChangeLog (222166 => 222167)


--- trunk/Source/WebCore/ChangeLog	2017-09-18 18:21:17 UTC (rev 222166)
+++ trunk/Source/WebCore/ChangeLog	2017-09-18 18:23:22 UTC (rev 222167)
@@ -1,5 +1,26 @@
 2017-09-18  Antti Koivisto  <[email protected]>
 
+        Avoid style resolution when clearing focused element.
+        https://bugs.webkit.org/show_bug.cgi?id=176224
+        <rdar://problem/34206409>
+
+        Reviewed by Zalan Bujtas.
+
+        Test: fast/dom/focus-style-resolution.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::setFocusedElement):
+
+            Don't do synchronous style resolution with FocusRemovalEventsMode::DoNotDispatch.
+            Style resolution may dispatch events.
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::didBlur):
+
+            Move resolveStyleIfNeeded call to setFocusedElement. It is the only client for didBlur.
+
+2017-09-18  Antti Koivisto  <[email protected]>
+
         Rolling out the previous to land again with a test.
 
         * dom/Document.cpp:

Modified: trunk/Source/WebCore/dom/Document.cpp (222166 => 222167)


--- trunk/Source/WebCore/dom/Document.cpp	2017-09-18 18:21:17 UTC (rev 222166)
+++ trunk/Source/WebCore/dom/Document.cpp	2017-09-18 18:23:22 UTC (rev 222167)
@@ -3840,8 +3840,14 @@
                 view()->setFocus(false);
         }
 
-        if (is<HTMLInputElement>(oldFocusedElement.get()))
+        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();
             downcast<HTMLInputElement>(*oldFocusedElement).didBlur();
+        }
     }
 
     if (newFocusedElement && newFocusedElement->isFocusable()) {
@@ -3915,7 +3921,10 @@
         page()->chrome().focusedElementChanged(m_focusedElement.get());
 
 SetFocusedNodeDone:
-    updateStyleIfNeeded();
+    // Updating style may dispatch events due to PostResolutionCallback
+    // FIXME: Why is synchronous style update needed here at all?
+    if (eventsMode == FocusRemovalEventsMode::Dispatch)
+        updateStyleIfNeeded();
     return !focusChangeBlocked;
 }
 

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (222166 => 222167)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2017-09-18 18:21:17 UTC (rev 222166)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2017-09-18 18:23:22 UTC (rev 222167)
@@ -1122,9 +1122,6 @@
 
 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();
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to