Title: [287219] trunk/Source/WebCore
Revision
287219
Author
wenson_hs...@apple.com
Date
2021-12-17 21:45:31 -0800 (Fri, 17 Dec 2021)

Log Message

Hide viewport-constrained elements that are detected by ModalContainerObserver
https://bugs.webkit.org/show_bug.cgi?id=234216

Reviewed by Tim Horton.

Make a small Style::Adjuster tweak to hide (i.e. set `display: none;`) on an element that is tagged as the
current "modal container" on ModalContainerObserver. See #234214 for more details.

* page/ModalContainerObserver.cpp:
(WebCore::ModalContainerObserver::updateModalContainerIfNeeded):

Additionally invalidate style when setting `m_container` here, so that the style adjuster can kick in and set
`display: none;` on a modal container after it is detected.

(WebCore::ModalContainerObserver::shouldHide):
* page/ModalContainerObserver.h:
* style/StyleAdjuster.cpp:
(WebCore::Style::Adjuster::adjust const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (287218 => 287219)


--- trunk/Source/WebCore/ChangeLog	2021-12-18 03:35:22 UTC (rev 287218)
+++ trunk/Source/WebCore/ChangeLog	2021-12-18 05:45:31 UTC (rev 287219)
@@ -1,5 +1,26 @@
 2021-12-17  Wenson Hsieh  <wenson_hs...@apple.com>
 
+        Hide viewport-constrained elements that are detected by ModalContainerObserver
+        https://bugs.webkit.org/show_bug.cgi?id=234216
+
+        Reviewed by Tim Horton.
+
+        Make a small Style::Adjuster tweak to hide (i.e. set `display: none;`) on an element that is tagged as the
+        current "modal container" on ModalContainerObserver. See #234214 for more details.
+
+        * page/ModalContainerObserver.cpp:
+        (WebCore::ModalContainerObserver::updateModalContainerIfNeeded):
+
+        Additionally invalidate style when setting `m_container` here, so that the style adjuster can kick in and set
+        `display: none;` on a modal container after it is detected.
+
+        (WebCore::ModalContainerObserver::shouldHide):
+        * page/ModalContainerObserver.h:
+        * style/StyleAdjuster.cpp:
+        (WebCore::Style::Adjuster::adjust const):
+
+2021-12-17  Wenson Hsieh  <wenson_hs...@apple.com>
+
         Add support for detecting modal containers that contain a given search term
         https://bugs.webkit.org/show_bug.cgi?id=234214
 

Modified: trunk/Source/WebCore/page/ModalContainerObserver.cpp (287218 => 287219)


--- trunk/Source/WebCore/page/ModalContainerObserver.cpp	2021-12-18 03:35:22 UTC (rev 287218)
+++ trunk/Source/WebCore/page/ModalContainerObserver.cpp	2021-12-18 05:45:31 UTC (rev 287219)
@@ -121,6 +121,7 @@
         for (auto& textRenderer : descendantsOfType<RenderText>(renderer)) {
             if (RefPtr textNode = textRenderer.textNode(); textNode && matchesSearchTerm(*textNode, searchTerm)) {
                 m_container = element.get();
+                element->invalidateStyle();
                 return;
             }
         }
@@ -127,4 +128,9 @@
     }
 }
 
+bool ModalContainerObserver::shouldHide(const Element& element)
+{
+    return &element == m_container;
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/ModalContainerObserver.h (287218 => 287219)


--- trunk/Source/WebCore/page/ModalContainerObserver.h	2021-12-18 03:35:22 UTC (rev 287218)
+++ trunk/Source/WebCore/page/ModalContainerObserver.h	2021-12-18 05:45:31 UTC (rev 287219)
@@ -43,6 +43,7 @@
     ModalContainerObserver();
     ~ModalContainerObserver();
 
+    bool shouldHide(const Element&);
     void updateModalContainerIfNeeded(const FrameView&);
 
 private:

Modified: trunk/Source/WebCore/style/StyleAdjuster.cpp (287218 => 287219)


--- trunk/Source/WebCore/style/StyleAdjuster.cpp	2021-12-18 03:35:22 UTC (rev 287218)
+++ trunk/Source/WebCore/style/StyleAdjuster.cpp	2021-12-18 05:45:31 UTC (rev 287219)
@@ -46,6 +46,7 @@
 #include "HTMLTextAreaElement.h"
 #include "HTMLVideoElement.h"
 #include "MathMLElement.h"
+#include "ModalContainerObserver.h"
 #include "Page.h"
 #include "Quirks.h"
 #include "RenderBox.h"
@@ -549,6 +550,11 @@
         adjustForTextAutosizing(style, *m_element);
 #endif
 
+    if (m_element) {
+        if (auto observer = m_element->document().modalContainerObserver(); observer && observer->shouldHide(*m_element))
+            style.setDisplay(DisplayType::None);
+    }
+
     adjustForSiteSpecificQuirks(style);
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to