Title: [219296] trunk
Revision
219296
Author
[email protected]
Date
2017-07-10 10:03:14 -0700 (Mon, 10 Jul 2017)

Log Message

REGRESSION(r210226): Keyboard-focused element not preserved when navigating back through page cache, causing multiple elements to have focus
https://bugs.webkit.org/show_bug.cgi?id=174302
<rdar://problem/33204273>

Reviewed by Antti Koivisto.

Source/WebCore:

Don't clear the active/hovered/focused elements when destroying the render tree,
since we might need to reconstruct it later, and would like to remember which
elements those were.

Only the focused state actually stuck when going in and out of the page cache,
but this patch removes all the element pointer clearing for consistency.

Test: fast/history/page-cache-element-state-focused.html

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

LayoutTests:

* fast/history/page-cache-element-state-focused-expected.html: Added.
* fast/history/page-cache-element-state-focused.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (219295 => 219296)


--- trunk/LayoutTests/ChangeLog	2017-07-10 16:23:19 UTC (rev 219295)
+++ trunk/LayoutTests/ChangeLog	2017-07-10 17:03:14 UTC (rev 219296)
@@ -1,3 +1,14 @@
+2017-07-10  Andreas Kling  <[email protected]>
+
+        REGRESSION(r210226): Keyboard-focused element not preserved when navigating back through page cache, causing multiple elements to have focus
+        https://bugs.webkit.org/show_bug.cgi?id=174302
+        <rdar://problem/33204273>
+
+        Reviewed by Antti Koivisto.
+
+        * fast/history/page-cache-element-state-focused-expected.html: Added.
+        * fast/history/page-cache-element-state-focused.html: Added.
+
 2017-07-10  Zalan Bujtas  <[email protected]>
 
         Block of text is missing in iBooks sample books.

Added: trunk/LayoutTests/fast/history/page-cache-element-state-focused-expected.html (0 => 219296)


--- trunk/LayoutTests/fast/history/page-cache-element-state-focused-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/history/page-cache-element-state-focused-expected.html	2017-07-10 17:03:14 UTC (rev 219296)
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+    a:focus {
+        background: yellow;
+    }
+</style>
+<script>
+    function runTest() {
+        document.getElementById("a3").focus();
+    }
+</script>
+</head>
+<body _onload_='runTest();'>
+<a id="a1" href=""
+<a id="a2" href=""
+<a id="a3" href=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/history/page-cache-element-state-focused.html (0 => 219296)


--- trunk/LayoutTests/fast/history/page-cache-element-state-focused.html	                        (rev 0)
+++ trunk/LayoutTests/fast/history/page-cache-element-state-focused.html	2017-07-10 17:03:14 UTC (rev 219296)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+    a:focus {
+        background: yellow;
+    }
+</style>
+<script>
+    function runTest() {
+        if (window.testRunner) {
+            testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+            testRunner.waitUntilDone();
+        }
+
+        window._onpageshow_ = function(e) {
+            if (e.persisted) {
+                document.getElementById("a3").focus();
+                if (window.testRunner)
+                    testRunner.notifyDone();
+            } else {
+                document.getElementById("a2").focus();
+            }
+        };
+
+        setTimeout(function() {
+            window.location.href = "" _onload_='history.back()'></body>";
+        }, 0);
+    }
+</script>
+</head>
+<body _onload_='runTest();'>
+<a id="a1" href=""
+<a id="a2" href=""
+<a id="a3" href=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (219295 => 219296)


--- trunk/Source/WebCore/ChangeLog	2017-07-10 16:23:19 UTC (rev 219295)
+++ trunk/Source/WebCore/ChangeLog	2017-07-10 17:03:14 UTC (rev 219296)
@@ -1,3 +1,23 @@
+2017-07-10  Andreas Kling  <[email protected]>
+
+        REGRESSION(r210226): Keyboard-focused element not preserved when navigating back through page cache, causing multiple elements to have focus
+        https://bugs.webkit.org/show_bug.cgi?id=174302
+        <rdar://problem/33204273>
+
+        Reviewed by Antti Koivisto.
+
+        Don't clear the active/hovered/focused elements when destroying the render tree,
+        since we might need to reconstruct it later, and would like to remember which
+        elements those were.
+
+        Only the focused state actually stuck when going in and out of the page cache,
+        but this patch removes all the element pointer clearing for consistency.
+
+        Test: fast/history/page-cache-element-state-focused.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::destroyRenderTree):
+
 2017-07-10  Daniel Bates  <[email protected]>
 
         REGRESSION (r218616): Cannot build WebCore for macOS 10.12 with macOS 10.13 SDK

Modified: trunk/Source/WebCore/dom/Document.cpp (219295 => 219296)


--- trunk/Source/WebCore/dom/Document.cpp	2017-07-10 16:23:19 UTC (rev 219295)
+++ trunk/Source/WebCore/dom/Document.cpp	2017-07-10 17:03:14 UTC (rev 219296)
@@ -2253,11 +2253,6 @@
         setFullScreenRenderer(nullptr);
 #endif
 
-    m_hoveredElement = nullptr;
-    m_focusedElement = nullptr;
-    m_activeElement = nullptr;
-    m_focusNavigationStartingNode = nullptr;
-
     if (m_documentElement)
         RenderTreeUpdater::tearDownRenderers(*m_documentElement);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to