Title: [279780] trunk/Source/WebCore
- Revision
- 279780
- Author
- n...@apple.com
- Date
- 2021-07-09 05:05:23 -0700 (Fri, 09 Jul 2021)
Log Message
Add topLayerElements() and activeModalDialog() to Document
https://bugs.webkit.org/show_bug.cgi?id=227800
Reviewed by Antti Koivisto.
These DOM methods are a pre-requisite for a lot of dialog element accessibility work, aside from
the top layer rendering work.
* dom/Document.cpp:
(WebCore::Document::addToTopLayer):
(WebCore::Document::removeFromTopLayer):
(WebCore::Document::activeModalDialog const):
* dom/Document.h:
(WebCore::Document::topLayerElements const):
* dom/Element.cpp:
(WebCore::Element::removedFromAncestor):
* html/HTMLDialogElement.cpp:
(WebCore::HTMLDialogElement::showModal):
(WebCore::HTMLDialogElement::close):
(WebCore::HTMLDialogElement::parseAttribute):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (279779 => 279780)
--- trunk/Source/WebCore/ChangeLog 2021-07-09 11:47:35 UTC (rev 279779)
+++ trunk/Source/WebCore/ChangeLog 2021-07-09 12:05:23 UTC (rev 279780)
@@ -1,3 +1,26 @@
+2021-07-09 Tim Nguyen <n...@apple.com>
+
+ Add topLayerElements() and activeModalDialog() to Document
+ https://bugs.webkit.org/show_bug.cgi?id=227800
+
+ Reviewed by Antti Koivisto.
+
+ These DOM methods are a pre-requisite for a lot of dialog element accessibility work, aside from
+ the top layer rendering work.
+
+ * dom/Document.cpp:
+ (WebCore::Document::addToTopLayer):
+ (WebCore::Document::removeFromTopLayer):
+ (WebCore::Document::activeModalDialog const):
+ * dom/Document.h:
+ (WebCore::Document::topLayerElements const):
+ * dom/Element.cpp:
+ (WebCore::Element::removedFromAncestor):
+ * html/HTMLDialogElement.cpp:
+ (WebCore::HTMLDialogElement::showModal):
+ (WebCore::HTMLDialogElement::close):
+ (WebCore::HTMLDialogElement::parseAttribute):
+
2021-07-09 Carlos Alberto Lopez Perez <clo...@igalia.com>
[GTK][WPE][libsoup] Test imported/w3c/web-platform-tests/cookies/samesite/about-blank-toplevel.https.html crashes since it was imported
Modified: trunk/Source/WebCore/dom/Document.cpp (279779 => 279780)
--- trunk/Source/WebCore/dom/Document.cpp 2021-07-09 11:47:35 UTC (rev 279779)
+++ trunk/Source/WebCore/dom/Document.cpp 2021-07-09 12:05:23 UTC (rev 279780)
@@ -92,6 +92,7 @@
#include "HTMLBaseElement.h"
#include "HTMLBodyElement.h"
#include "HTMLCanvasElement.h"
+#include "HTMLDialogElement.h"
#include "HTMLDocument.h"
#include "HTMLElementFactory.h"
#include "HTMLFormControlElement.h"
@@ -8399,6 +8400,32 @@
return animations;
}
+void Document::addToTopLayer(Element& element)
+{
+ // To add an element to a top layer, remove it from top layer and then append it to top layer.
+ m_topLayerElements.appendOrMoveToLast(&element);
+
+ element.invalidateStyle();
+}
+
+void Document::removeFromTopLayer(Element& element)
+{
+ if (!m_topLayerElements.remove(&element))
+ return;
+
+ element.invalidateStyle();
+}
+
+HTMLDialogElement* Document::activeModalDialog() const
+{
+ for (auto& element : makeReversedRange(m_topLayerElements)) {
+ if (is<HTMLDialogElement>(element))
+ return downcast<HTMLDialogElement>(element.get());
+ }
+
+ return nullptr;
+}
+
#if ENABLE(ATTACHMENT_ELEMENT)
void Document::registerAttachmentIdentifier(const String& identifier)
Modified: trunk/Source/WebCore/dom/Document.h (279779 => 279780)
--- trunk/Source/WebCore/dom/Document.h 2021-07-09 11:47:35 UTC (rev 279779)
+++ trunk/Source/WebCore/dom/Document.h 2021-07-09 12:05:23 UTC (rev 279780)
@@ -149,6 +149,7 @@
class HTMLBodyElement;
class HTMLCanvasElement;
class HTMLCollection;
+class HTMLDialogElement;
class HTMLDocument;
class HTMLElement;
class HTMLFrameOwnerElement;
@@ -1501,6 +1502,12 @@
DocumentTimelinesController* timelinesController() const { return m_timelinesController.get(); }
WEBCORE_EXPORT DocumentTimelinesController& ensureTimelinesController();
+ void addToTopLayer(Element&);
+ void removeFromTopLayer(Element&);
+ const ListHashSet<RefPtr<Element>>& topLayerElements() const { return m_topLayerElements; }
+
+ HTMLDialogElement* activeModalDialog() const;
+
#if ENABLE(ATTACHMENT_ELEMENT)
void registerAttachmentIdentifier(const String&);
void didInsertAttachmentElement(HTMLAttachmentElement&);
@@ -2187,6 +2194,8 @@
UniqueRef<Editor> m_editor;
UniqueRef<FrameSelection> m_selection;
+
+ ListHashSet<RefPtr<Element>> m_topLayerElements;
};
Element* eventTargetElementForDocument(Document*);
Modified: trunk/Source/WebCore/dom/Element.cpp (279779 => 279780)
--- trunk/Source/WebCore/dom/Element.cpp 2021-07-09 11:47:35 UTC (rev 279779)
+++ trunk/Source/WebCore/dom/Element.cpp 2021-07-09 12:05:23 UTC (rev 279780)
@@ -2253,6 +2253,8 @@
void Element::removedFromAncestor(RemovalType removalType, ContainerNode& oldParentOfRemovedTree)
{
+ document().removeFromTopLayer(*this);
+
#if ENABLE(FULLSCREEN_API)
if (containsFullScreenElement())
setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false);
Modified: trunk/Source/WebCore/html/HTMLDialogElement.cpp (279779 => 279780)
--- trunk/Source/WebCore/html/HTMLDialogElement.cpp 2021-07-09 11:47:35 UTC (rev 279779)
+++ trunk/Source/WebCore/html/HTMLDialogElement.cpp 2021-07-09 12:05:23 UTC (rev 279780)
@@ -88,6 +88,8 @@
return Exception { InvalidStateError };
setBooleanAttribute(openAttr, true);
+
+ document().addToTopLayer(*this);
m_isModal = true;
return { };
@@ -99,6 +101,7 @@
return;
setBooleanAttribute(openAttr, false);
+
if (!returnValue.isNull())
m_returnValue = returnValue;
}
@@ -117,7 +120,11 @@
// Emit close event
if (oldValue != m_isOpen && !m_isOpen) {
- m_isModal = false;
+ if (m_isModal) {
+ document().removeFromTopLayer(*this);
+ m_isModal = false;
+ }
+
dialogCloseEventSender().cancelEvent(*this);
dialogCloseEventSender().dispatchEventSoon(*this);
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes