Bug 1427419 - Part 20: Move inIDOMUtils.getBindingURLs to InspectorUtils. r=bz

This is unused in mozilla-central but still used by comm-central.

The only consumer of this API really just wants the URL strings, so
we return a sequence<DOMString> instead of an array of nsIURI objects.

MozReview-Commit-ID: ITcEe42shHw
This commit is contained in:
Cameron McCormack 2018-01-11 12:38:01 +08:00
Родитель 45c9e50a65
Коммит 075f0e5256
8 изменённых файлов: 21 добавлений и 54 удалений

Просмотреть файл

@ -56,6 +56,7 @@ namespace InspectorUtils {
Node? getParentForNode(Node node, boolean showingAnonymousContent);
[NewObject] NodeList getChildrenForNode(Node node,
boolean showingAnonymousContent);
sequence<DOMString> getBindingURLs(Element element);
};
dictionary PropertyNamesOptions {

Просмотреть файл

@ -190,6 +190,10 @@ public:
nsINode& aNode,
bool aShowingAnonymousContent);
static void GetBindingURLs(GlobalObject& aGlobal,
Element& aElement,
nsTArray<nsString>& aResult);
private:
static already_AddRefed<nsStyleContext>
GetCleanStyleContextForElement(Element* aElement, nsAtom* aPseudo);

Просмотреть файл

@ -876,34 +876,26 @@ InspectorUtils::IsValidCSSColor(GlobalObject& aGlobalObject,
#endif
}
} // namespace dom
} // namespace mozilla
NS_IMETHODIMP
inDOMUtils::GetBindingURLs(nsIDOMElement *aElement, nsIArray **_retval)
void
InspectorUtils::GetBindingURLs(GlobalObject& aGlobalObject,
Element& aElement,
nsTArray<nsString>& aResult)
{
NS_ENSURE_ARG_POINTER(aElement);
*_retval = nullptr;
nsCOMPtr<nsIMutableArray> urls = do_CreateInstance(NS_ARRAY_CONTRACTID);
if (!urls)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
NS_ENSURE_ARG_POINTER(content);
nsXBLBinding *binding = content->GetXBLBinding();
nsXBLBinding* binding = aElement.GetXBLBinding();
while (binding) {
urls->AppendElement(binding->PrototypeBinding()->BindingURI());
nsCString spec;
nsCOMPtr<nsIURI> bindingURI = binding->PrototypeBinding()->BindingURI();
bindingURI->GetSpec(spec);
nsString* resultURI = aResult.AppendElement();
CopyASCIItoUTF16(spec, *resultURI);
binding = binding->GetBaseBinding();
}
urls.forget(_retval);
return NS_OK;
}
} // namespace dom
} // namespace mozilla
NS_IMETHODIMP
inDOMUtils::SetContentState(nsIDOMElement* aElement,
EventStates::InternalType aState,

Просмотреть файл

@ -20,9 +20,6 @@ interface nsIDOMCSSStyleSheet;
[scriptable, uuid(362e98c3-82c2-4ad8-8dcb-00e8e4eab497)]
interface inIDOMUtils : nsISupports
{
// XBL utilities
nsIArray getBindingURLs(in nsIDOMElement aElement);
// content state utilities
unsigned long long getContentState(in nsIDOMElement aElement);
/**

Просмотреть файл

@ -12,7 +12,6 @@ support-files =
[test_bug536379-2.html]
[test_bug557726.html]
[test_bug609549.xhtml]
[test_bug806192.html]
[test_bug856317.html]
[test_bug877690.html]
[test_bug1006595.html]

Просмотреть файл

@ -64,7 +64,7 @@ function do_test() {
}
catch(e) {
e = SpecialPowers.wrap(e);
is(e.result, INVALID_POINTER, "got the expected exception");
is(e.name, "TypeError", "got the expected exception");
}
try {

Просмотреть файл

@ -63,8 +63,8 @@ function do_test() {
catch(e) { ok(false, "got an unexpected exception:" + e); }
try {
var res = utils.getBindingURLs(docElement);
ok(SpecialPowers.call_Instanceof(res, SpecialPowers.Ci["nsIArray"]), "getBindingURLs result type");
var res = InspectorUtils.getBindingURLs(docElement);
ok(Array.isArray(SpecialPowers.unwrap(res)), "getBindingURLs result type");
is(res.length, 0, "getBindingURLs array length");
}
catch(e) { ok(false, "got an unexpected exception:" + e); }

Просмотреть файл

@ -1,26 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=806192
-->
<head>
<title>Test for Bug 806192</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<pre id="test">
<script type="application/javascript">
const utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
.getService(SpecialPowers.Ci.inIDOMUtils);
try {
var res = utils.getBindingURLs({});
ok(false, "didn't get error");
}
catch(e) { ok(true, "got expected exception"); }
</script>
</pre>
</body>
</html>