Bug 1443923 - part4: Expose isCustomElementName to DevTools via InspectorUtils;r=emilio
MozReview-Commit-ID: GaHP1gOCwoB
--- a/dom/chrome-webidl/InspectorUtils.webidl
+++ b/dom/chrome-webidl/InspectorUtils.webidl
@@ -72,16 +72,18 @@ namespace InspectorUtils {
void addPseudoClassLock(Element element,
DOMString pseudoClass,
optional boolean enabled = true);
void removePseudoClassLock(Element element, DOMString pseudoClass);
boolean hasPseudoClassLock(Element element, DOMString pseudoClass);
void clearPseudoClassLocks(Element element);
[Throws] void parseStyleSheet(CSSStyleSheet sheet, DOMString input);
void scrollElementIntoView(Element element);
+ boolean isCustomElementName([TreatNullAs=EmptyString] DOMString name,
+ DOMString? namespaceURI);
};
dictionary PropertyNamesOptions {
boolean includeAliases = false;
boolean includeShorthands = true;
boolean includeExperimentals = false;
};
--- a/layout/inspector/InspectorUtils.cpp
+++ b/layout/inspector/InspectorUtils.cpp
@@ -735,10 +735,31 @@ InspectorUtils::ScrollElementIntoView(Gl
}
presShell->ScrollContentIntoView(&aElement,
nsIPresShell::ScrollAxis(),
nsIPresShell::ScrollAxis(),
nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
}
+
+bool
+InspectorUtils::IsCustomElementName(GlobalObject&,
+ const nsAString& aName,
+ const nsAString& aNamespaceURI)
+{
+ if (aName.IsEmpty()) {
+ return false;
+ }
+
+ int32_t namespaceID;
+ nsContentUtils::NameSpaceManager()->RegisterNameSpace(
+ aNamespaceURI,
+ namespaceID);
+
+ RefPtr<nsAtom> nameElt = NS_Atomize(aName);
+ return nsContentUtils::IsCustomElementName(
+ nameElt,
+ namespaceID);
+}
+
} // namespace dom
} // namespace mozilla
--- a/layout/inspector/InspectorUtils.h
+++ b/layout/inspector/InspectorUtils.h
@@ -269,16 +269,23 @@ public:
ErrorResult& aRv);
/**
* Scroll an element completely into view, if possible.
* This is similar to ensureElementIsVisible but for all ancestors.
*/
static void ScrollElementIntoView(GlobalObject& aGlobal, Element& aElement);
+ /**
+ * Check if the provided name can be custom element name.
+ */
+ static bool IsCustomElementName(GlobalObject&,
+ const nsAString& aName,
+ const nsAString& aNamespaceURI);
+
private:
static already_AddRefed<ComputedStyle>
GetCleanComputedStyleForElement(Element* aElement, nsAtom* aPseudo);
};
} // namespace dom
} // namespace mozilla