AlternativePresentationButtonSubstitution::unapply() may not undo substitution
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 2 Dec 2017 00:28:46 +0000 (00:28 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 2 Dec 2017 00:28:46 +0000 (00:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=180279
<rdar://problem/35800599>

Reviewed by Simon Fraser.

Source/WebCore:

Fixes an issue where removing an alternative presentation button substituted for a non-HTML input
element did not restore the original appearance of the element before the substitution.

To substitute the alternative presentation button for a non-HTML input element we attach a
user-agent shadow root to it. Adding a shadow root, including a user-agent shadow root,
tears down the existing renderers for the element. Currently when we unapply such a substitution
we ultimately just remove the shadow root and do not create new renderers for the subtree
that the shadow root was removed from. We need to create new renderers for this subtree
to restore the original appearance of the element before the substitution.

* editing/cocoa/AlternativePresentationButtonSubstitution.cpp:
(WebCore::AlternativePresentationButtonSubstitution::unapply):

LayoutTests:

Update test to ensure that we undo the alternative presentation button substitution
made to an HTML label element.

* fast/forms/alternative-presentation-button/replace-and-remove-expected.html:
* fast/forms/alternative-presentation-button/replace-and-remove.html:

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

LayoutTests/ChangeLog
LayoutTests/fast/forms/alternative-presentation-button/replace-and-remove-expected.html
LayoutTests/fast/forms/alternative-presentation-button/replace-and-remove.html
Source/WebCore/ChangeLog
Source/WebCore/editing/cocoa/AlternativePresentationButtonSubstitution.cpp

index 295568a..2cbee29 100644 (file)
@@ -1,5 +1,19 @@
 2017-12-01  Daniel Bates  <dabates@apple.com>
 
+        AlternativePresentationButtonSubstitution::unapply() may not undo substitution
+        https://bugs.webkit.org/show_bug.cgi?id=180279
+        <rdar://problem/35800599>
+
+        Reviewed by Simon Fraser.
+
+        Update test to ensure that we undo the alternative presentation button substitution
+        made to an HTML label element.
+
+        * fast/forms/alternative-presentation-button/replace-and-remove-expected.html:
+        * fast/forms/alternative-presentation-button/replace-and-remove.html:
+
+2017-12-01  Daniel Bates  <dabates@apple.com>
+
         Alternative Presentation Button: Provide a way to query for the replaced elements
         https://bugs.webkit.org/show_bug.cgi?id=180114
         <rdar://problem/35710539>
index 84dc48e..3ba7f13 100644 (file)
@@ -39,6 +39,9 @@
                 </tr>
         </table>
     </div>
+    <div>
+        <label>First name <input type="text"></label>
+    </div>
     <p>Name</p>
 </div>
 </body>
index 3d41b42..6bdb2d2 100644 (file)
@@ -39,6 +39,9 @@
                 </tr>
         </table>
     </div>
+    <div class="test">
+        <label>First name <input type="text"></label>
+    </div>
 </div>
 <script>
 var id = 0;
index 94dc120..1e90422 100644 (file)
@@ -1,3 +1,24 @@
+2017-12-01  Daniel Bates  <dabates@apple.com>
+
+        AlternativePresentationButtonSubstitution::unapply() may not undo substitution
+        https://bugs.webkit.org/show_bug.cgi?id=180279
+        <rdar://problem/35800599>
+
+        Reviewed by Simon Fraser.
+
+        Fixes an issue where removing an alternative presentation button substituted for a non-HTML input
+        element did not restore the original appearance of the element before the substitution.
+
+        To substitute the alternative presentation button for a non-HTML input element we attach a
+        user-agent shadow root to it. Adding a shadow root, including a user-agent shadow root,
+        tears down the existing renderers for the element. Currently when we unapply such a substitution
+        we ultimately just remove the shadow root and do not create new renderers for the subtree
+        that the shadow root was removed from. We need to create new renderers for this subtree
+        to restore the original appearance of the element before the substitution.
+
+        * editing/cocoa/AlternativePresentationButtonSubstitution.cpp:
+        (WebCore::AlternativePresentationButtonSubstitution::unapply):
+
 2017-12-01  Christopher Reid  <chris.reid@sony.com>
 
         Move DateComponents into WTF
index 02b6852..1f2a924 100644 (file)
@@ -110,6 +110,7 @@ void AlternativePresentationButtonSubstitution::unapply()
         m_shadowHost->userAgentShadowRoot()->removeChild(*m_alternativePresentationButtonElement);
         ASSERT(!m_shadowHost->userAgentShadowRoot()->countChildNodes());
         m_shadowHost->removeShadowRoot();
+        m_shadowHost->invalidateStyleAndRenderersForSubtree();
     };
     auto restoreStyles = [&] {
         for (auto& savedDisplayStyle : m_savedDisplayStyles) {