Title: [176294] trunk
Revision
176294
Author
[email protected]
Date
2014-11-18 16:20:07 -0800 (Tue, 18 Nov 2014)

Log Message

Avoid synchronous style recalc in Document.activeElement
<https://webkit.org/b/138850>

Reviewed by Ryosuke Niwa.

Source/WebCore:

This subtly changes the behavior of <input autofocus>, which was caught by
a layout test. Auto-focus doesn't happen until the render tree is attached,
although it was possible to force it by accessing document.activeElement.

Now auto-focus is always lazy. This is consistent with other browser engines.

~1% progression on Speedometer locally.

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

LayoutTests:

Tweak a test to run once the DOM is loaded instead of during parsing.

* fast/forms/autofocus-in-sandbox-with-allow-scripts.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (176293 => 176294)


--- trunk/LayoutTests/ChangeLog	2014-11-19 00:17:27 UTC (rev 176293)
+++ trunk/LayoutTests/ChangeLog	2014-11-19 00:20:07 UTC (rev 176294)
@@ -1,3 +1,14 @@
+2014-11-18  Andreas Kling  <[email protected]>
+
+        Avoid synchronous style recalc in Document.activeElement
+        <https://webkit.org/b/138850>
+
+        Reviewed by Ryosuke Niwa.
+
+        Tweak a test to run once the DOM is loaded instead of during parsing.
+
+        * fast/forms/autofocus-in-sandbox-with-allow-scripts.html:
+
 2014-11-18  David Hyatt  <[email protected]>
 
         REGRESSION(r152313): Inline-block element doesn't wrap properly

Modified: trunk/LayoutTests/fast/forms/autofocus-in-sandbox-with-allow-scripts.html (176293 => 176294)


--- trunk/LayoutTests/fast/forms/autofocus-in-sandbox-with-allow-scripts.html	2014-11-19 00:17:27 UTC (rev 176293)
+++ trunk/LayoutTests/fast/forms/autofocus-in-sandbox-with-allow-scripts.html	2014-11-19 00:20:07 UTC (rev 176294)
@@ -5,4 +5,4 @@
 This test passes if the activeElement is the input element rather than the body
 (which it would be if the sandbox didn't allow autofocus although allow-scripts flag is set).
 <iframe sandbox="allow-scripts"
-    src="" autofocus onfocus><script>alert(document.activeElement.tagName)</script>"></iframe>
+    src="" autofocus onfocus><script>window._onload_ = function() { alert(document.activeElement.tagName) }</script>"></iframe>

Modified: trunk/Source/WebCore/ChangeLog (176293 => 176294)


--- trunk/Source/WebCore/ChangeLog	2014-11-19 00:17:27 UTC (rev 176293)
+++ trunk/Source/WebCore/ChangeLog	2014-11-19 00:20:07 UTC (rev 176294)
@@ -1,3 +1,21 @@
+2014-11-18  Andreas Kling  <[email protected]>
+
+        Avoid synchronous style recalc in Document.activeElement
+        <https://webkit.org/b/138850>
+
+        Reviewed by Ryosuke Niwa.
+
+        This subtly changes the behavior of <input autofocus>, which was caught by
+        a layout test. Auto-focus doesn't happen until the render tree is attached,
+        although it was possible to force it by accessing document.activeElement.
+
+        Now auto-focus is always lazy. This is consistent with other browser engines.
+
+        ~1% progression on Speedometer locally.
+
+        * dom/Document.cpp:
+        (WebCore::Document::activeElement):
+
 2014-11-18  Chris Dumez  <[email protected]>
 
         Have Vector::capacity() return an unsigned instead of a size_t

Modified: trunk/Source/WebCore/dom/Document.cpp (176293 => 176294)


--- trunk/Source/WebCore/dom/Document.cpp	2014-11-19 00:17:27 UTC (rev 176293)
+++ trunk/Source/WebCore/dom/Document.cpp	2014-11-19 00:20:07 UTC (rev 176294)
@@ -6315,7 +6315,6 @@
 
 Element* Document::activeElement()
 {
-    updateStyleIfNeeded();
     if (Element* element = treeScope().focusedElement())
         return element;
     return body();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to