From 48f602e65b0bcb10e3a8367dbbb70185e2e33125 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 17 Apr 2020 06:37:28 -0400 Subject: Bug 1402941 - Add HTMLSlotElement Tag #1375 --- dom/html/HTMLSlotElement.h | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 dom/html/HTMLSlotElement.h (limited to 'dom/html/HTMLSlotElement.h') diff --git a/dom/html/HTMLSlotElement.h b/dom/html/HTMLSlotElement.h new file mode 100644 index 000000000..187a295db --- /dev/null +++ b/dom/html/HTMLSlotElement.h @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_HTMLSlotElement_h +#define mozilla_dom_HTMLSlotElement_h + +#include "nsIDOMHTMLElement.h" +#include "nsGenericHTMLElement.h" +#include "nsTArray.h" + +namespace mozilla { +namespace dom { + +struct AssignedNodesOptions; + +class HTMLSlotElement final : public nsGenericHTMLElement +{ +public: + explicit HTMLSlotElement(already_AddRefed& aNodeInfo); + NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLSlotElement, slot) + + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLSlotElement, nsGenericHTMLElement) + virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult) const override; + + void SetName(const nsAString& aName, ErrorResult& aRv) + { + SetHTMLAttr(nsGkAtoms::name, aName, aRv); + } + + void GetName(nsAString& aName) + { + GetHTMLAttr(nsGkAtoms::name, aName); + } + + void AssignedNodes(const AssignedNodesOptions& aOptions, + nsTArray>& aNodes); + +protected: + virtual ~HTMLSlotElement(); + virtual JSObject* + WrapNode(JSContext* aCx, JS::Handle aGivenProto) override; + + nsTArray> mAssignedNodes; +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_HTMLSlotElement_h -- cgit v1.2.3 From e31ed5b07466d4a579fe4b025f97c971003fbc3f Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 17 Apr 2020 07:10:54 -0400 Subject: Bug 1409975 - Implement node distribution for shadow tree slots * Implementation for assignedNodes * Include slots in the flat tree * Fix event get-the-parent algorithm for a node * Update and add reftests for Shadow DOM v1 * Update web platform tests expectations Tag #1375 --- dom/html/HTMLSlotElement.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'dom/html/HTMLSlotElement.h') diff --git a/dom/html/HTMLSlotElement.h b/dom/html/HTMLSlotElement.h index 187a295db..4f8546200 100644 --- a/dom/html/HTMLSlotElement.h +++ b/dom/html/HTMLSlotElement.h @@ -26,6 +26,22 @@ public: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLSlotElement, nsGenericHTMLElement) virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult) const override; + // nsIContent + virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, + nsIContent* aBindingParent, + bool aCompileEventHandlers) override; + virtual void UnbindFromTree(bool aDeep = true, + bool aNullParent = true) override; + + virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName, + const nsAttrValueOrString* aValue, + bool aNotify) override; + virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, + const nsAttrValue* aValue, + const nsAttrValue* aOldValue, + bool aNotify) override; + + // WebIDL void SetName(const nsAString& aName, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::name, aName, aRv); @@ -39,6 +55,13 @@ public: void AssignedNodes(const AssignedNodesOptions& aOptions, nsTArray>& aNodes); + // Helper methods + const nsTArray>& AssignedNodes() const; + void InsertAssignedNode(uint32_t aIndex, nsINode* aNode); + void AppendAssignedNode(nsINode* aNode); + void RemoveAssignedNode(nsINode* aNode); + void ClearAssignedNodes(); + protected: virtual ~HTMLSlotElement(); virtual JSObject* -- cgit v1.2.3 From 3508e79b1fe7fc928eed2f3c7bf2d628c53fbf17 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 17 Apr 2020 07:35:48 -0400 Subject: Bug 1409976 - Add `slotchange` event * Add support for `slotchange` event * Signal `slotchange` when slot's assigned nodes changes Tag #1375 --- dom/html/HTMLSlotElement.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'dom/html/HTMLSlotElement.h') diff --git a/dom/html/HTMLSlotElement.h b/dom/html/HTMLSlotElement.h index 4f8546200..0494a654e 100644 --- a/dom/html/HTMLSlotElement.h +++ b/dom/html/HTMLSlotElement.h @@ -62,6 +62,9 @@ public: void RemoveAssignedNode(nsINode* aNode); void ClearAssignedNodes(); + void EnqueueSlotChangeEvent() const; + void FireSlotChangeEvent(); + protected: virtual ~HTMLSlotElement(); virtual JSObject* -- cgit v1.2.3