Bug 1470545: Add chromeonly "shadowrootattached" event for devtools. r=smaug
Summary:
document.addEventListener("shadowrootattached", e => {
// Do stuff with composedTarget.
});
I didn't bother to add tests for the event itself since this is going to get
tested in bug 1449333, but I can look into writing a chrome mochitest if you
want.
Test Plan: See above.
Reviewers: smaug
Bug #: 1470545
Differential Revision: https://phabricator.services.mozilla.com/D1777
MozReview-Commit-ID: 55cVMSsznMS

/* -*- 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/. */#include"mozilla/dom/HTMLSharedListElement.h"#include"mozilla/dom/HTMLDListElementBinding.h"#include"mozilla/dom/HTMLOListElementBinding.h"#include"mozilla/dom/HTMLUListElementBinding.h"#include"mozilla/MappedDeclarations.h"#include"nsGenericHTMLElement.h"#include"nsAttrValueInlines.h"#include"nsGkAtoms.h"#include"nsStyleConsts.h"#include"nsMappedAttributes.h"NS_IMPL_NS_NEW_HTML_ELEMENT(SharedList)namespacemozilla{namespacedom{HTMLSharedListElement::~HTMLSharedListElement(){}NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(HTMLSharedListElement,nsGenericHTMLElement)NS_IMPL_ELEMENT_CLONE(HTMLSharedListElement)// Shared with nsHTMLSharedElement.cppnsAttrValue::EnumTablekListTypeTable[]={{"none",NS_STYLE_LIST_STYLE_NONE},{"disc",NS_STYLE_LIST_STYLE_DISC},{"circle",NS_STYLE_LIST_STYLE_CIRCLE},{"round",NS_STYLE_LIST_STYLE_CIRCLE},{"square",NS_STYLE_LIST_STYLE_SQUARE},{"decimal",NS_STYLE_LIST_STYLE_DECIMAL},{"lower-roman",NS_STYLE_LIST_STYLE_LOWER_ROMAN},{"upper-roman",NS_STYLE_LIST_STYLE_UPPER_ROMAN},{"lower-alpha",NS_STYLE_LIST_STYLE_LOWER_ALPHA},{"upper-alpha",NS_STYLE_LIST_STYLE_UPPER_ALPHA},{nullptr,0}};staticconstnsAttrValue::EnumTablekOldListTypeTable[]={{"1",NS_STYLE_LIST_STYLE_DECIMAL},{"A",NS_STYLE_LIST_STYLE_UPPER_ALPHA},{"a",NS_STYLE_LIST_STYLE_LOWER_ALPHA},{"I",NS_STYLE_LIST_STYLE_UPPER_ROMAN},{"i",NS_STYLE_LIST_STYLE_LOWER_ROMAN},{nullptr,0}};boolHTMLSharedListElement::ParseAttribute(int32_taNamespaceID,nsAtom*aAttribute,constnsAString&aValue,nsIPrincipal*aMaybeScriptedPrincipal,nsAttrValue&aResult){if(aNamespaceID==kNameSpaceID_None){if(mNodeInfo->Equals(nsGkAtoms::ol)||mNodeInfo->Equals(nsGkAtoms::ul)){if(aAttribute==nsGkAtoms::type){returnaResult.ParseEnumValue(aValue,kListTypeTable,false)||aResult.ParseEnumValue(aValue,kOldListTypeTable,true);}if(aAttribute==nsGkAtoms::start){returnaResult.ParseIntValue(aValue);}}}returnnsGenericHTMLElement::ParseAttribute(aNamespaceID,aAttribute,aValue,aMaybeScriptedPrincipal,aResult);}voidHTMLSharedListElement::MapAttributesIntoRule(constnsMappedAttributes*aAttributes,MappedDeclarations&aDecls){if(!aDecls.PropertyIsSet(eCSSProperty_list_style_type)){// type: enumconstnsAttrValue*value=aAttributes->GetAttr(nsGkAtoms::type);if(value&&value->Type()==nsAttrValue::eEnum){aDecls.SetKeywordValue(eCSSProperty_list_style_type,value->GetEnumValue());}}nsGenericHTMLElement::MapCommonAttributesInto(aAttributes,aDecls);}NS_IMETHODIMP_(bool)HTMLSharedListElement::IsAttributeMapped(constnsAtom*aAttribute)const{if(mNodeInfo->Equals(nsGkAtoms::ol)||mNodeInfo->Equals(nsGkAtoms::ul)){staticconstMappedAttributeEntryattributes[]={{&nsGkAtoms::type},{nullptr}};staticconstMappedAttributeEntry*constmap[]={attributes,sCommonAttributeMap,};returnFindAttributeDependence(aAttribute,map);}returnnsGenericHTMLElement::IsAttributeMapped(aAttribute);}nsMapRuleToAttributesFuncHTMLSharedListElement::GetAttributeMappingFunction()const{if(mNodeInfo->Equals(nsGkAtoms::ol)||mNodeInfo->Equals(nsGkAtoms::ul)){return&MapAttributesIntoRule;}returnnsGenericHTMLElement::GetAttributeMappingFunction();}JSObject*HTMLSharedListElement::WrapNode(JSContext*aCx,JS::Handle<JSObject*>aGivenProto){if(mNodeInfo->Equals(nsGkAtoms::ol)){returnHTMLOListElement_Binding::Wrap(aCx,this,aGivenProto);}if(mNodeInfo->Equals(nsGkAtoms::dl)){returnHTMLDListElement_Binding::Wrap(aCx,this,aGivenProto);}MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::ul));returnHTMLUListElement_Binding::Wrap(aCx,this,aGivenProto);}}// namespace dom}// namespace mozilla