Bug 1270349 part 5. Use LegacyUnenumerableNamedProperties instead of passing flags to GetSupportedNames to determine whether named props on DOM proxies should be reflected in ownPropertyKeys. r=peterv

This commit is contained in:
Boris Zbarsky 2016-05-09 22:25:40 -04:00
parent 76180fb5a7
commit 59de5a530f
33 changed files with 55 additions and 88 deletions

View File

@ -212,7 +212,9 @@ WindowNamedPropertiesHandler::ownPropNames(JSContext* aCx,
return true;
}
nsHTMLDocument* document = static_cast<nsHTMLDocument*>(htmlDoc.get());
document->GetSupportedNames(flags, names);
// Document names are enumerable, so we want to get them no matter what flags
// is.
document->GetSupportedNames(names);
JS::AutoIdVector docProps(aCx);
if (!AppendNamedPropertyIds(aCx, aProxy, names, false, docProps)) {

View File

@ -537,12 +537,8 @@ nsContentList::NamedItem(const nsAString& aName, bool aDoFlush)
}
void
nsContentList::GetSupportedNames(unsigned aFlags, nsTArray<nsString>& aNames)
nsContentList::GetSupportedNames(nsTArray<nsString>& aNames)
{
if (!(aFlags & JSITER_HIDDEN)) {
return;
}
BringSelfUpToDate(true);
AutoTArray<nsIAtom*, 8> atoms;

View File

@ -291,8 +291,7 @@ public:
aFound = !!item;
return item;
}
virtual void GetSupportedNames(unsigned aFlags,
nsTArray<nsString>& aNames) override;
virtual void GetSupportedNames(nsTArray<nsString>& aNames) override;
// nsContentList public methods
uint32_t Length(bool aDoFlush);

View File

@ -164,13 +164,8 @@ nsDOMAttributeMap::NamedGetter(const nsAString& aAttrName, bool& aFound)
}
void
nsDOMAttributeMap::GetSupportedNames(unsigned aFlags,
nsTArray<nsString>& aNames)
nsDOMAttributeMap::GetSupportedNames(nsTArray<nsString>& aNames)
{
if (!(aFlags & JSITER_HIDDEN)) {
return;
}
// For HTML elements in HTML documents, only include names that are still the
// same after ASCII-lowercasing, since our named getter will end up
// ASCII-lowercasing the given string.

View File

@ -158,7 +158,7 @@ public:
ErrorResult& aError);
void
GetSupportedNames(unsigned aFlags, nsTArray<nsString>& aNames);
GetSupportedNames(nsTArray<nsString>& aNames);
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;

View File

@ -131,7 +131,7 @@ nsMimeTypeArray::Length()
}
void
nsMimeTypeArray::GetSupportedNames(unsigned, nsTArray< nsString >& aRetval)
nsMimeTypeArray::GetSupportedNames(nsTArray< nsString >& aRetval)
{
EnsurePluginMimeTypes();

View File

@ -36,7 +36,7 @@ public:
nsMimeType* IndexedGetter(uint32_t index, bool &found);
nsMimeType* NamedGetter(const nsAString& name, bool &found);
uint32_t Length();
void GetSupportedNames(unsigned, nsTArray< nsString >& retval);
void GetSupportedNames(nsTArray<nsString>& retval);
protected:
virtual ~nsMimeTypeArray();

View File

@ -237,7 +237,7 @@ nsPluginArray::Length()
}
void
nsPluginArray::GetSupportedNames(unsigned, nsTArray<nsString>& aRetval)
nsPluginArray::GetSupportedNames(nsTArray<nsString>& aRetval)
{
aRetval.Clear();
@ -422,7 +422,7 @@ nsPluginElement::Length()
}
void
nsPluginElement::GetSupportedNames(unsigned, nsTArray<nsString>& retval)
nsPluginElement::GetSupportedNames(nsTArray<nsString>& retval)
{
EnsurePluginMimeTypes();

View File

@ -50,7 +50,7 @@ public:
nsPluginElement* IndexedGetter(uint32_t aIndex, bool &aFound);
nsPluginElement* NamedGetter(const nsAString& aName, bool &aFound);
uint32_t Length();
void GetSupportedNames(unsigned, nsTArray<nsString>& aRetval);
void GetSupportedNames(nsTArray<nsString>& aRetval);
private:
virtual ~nsPluginArray();
@ -91,7 +91,7 @@ public:
nsMimeType* IndexedGetter(uint32_t index, bool &found);
nsMimeType* NamedGetter(const nsAString& name, bool &found);
uint32_t Length();
void GetSupportedNames(unsigned, nsTArray<nsString>& retval);
void GetSupportedNames(nsTArray<nsString>& retval);
nsTArray<RefPtr<nsMimeType> >& MimeTypes();

View File

@ -11295,14 +11295,17 @@ class CGDOMJSProxyHandler_ownPropNames(ClassMethod):
shadow = "false"
addNames = fill(
"""
nsTArray<nsString> names;
UnwrapProxy(proxy)->GetSupportedNames(flags, names);
UnwrapProxy(proxy)->GetSupportedNames(names);
if (!AppendNamedPropertyIds(cx, proxy, names, ${shadow}, props)) {
return false;
}
""",
shadow=shadow)
if not self.descriptor.namedPropertiesEnumerable:
addNames = CGIfWrapper(CGGeneric(addNames),
"flags & JSITER_HIDDEN").define()
addNames = "\n" + addNames
else:
addNames = ""
@ -14123,7 +14126,7 @@ class CGBindingImplClass(CGClass):
[]),
{"infallible": True}))
# And if we support named properties we need to be able to
# enumerate the supported names and test whether they're enumerable.
# enumerate the supported names.
if descriptor.supportsNamedProperties():
self.methodDecls.append(
CGNativeMember(
@ -14131,11 +14134,7 @@ class CGBindingImplClass(CGClass):
"GetSupportedNames",
(IDLSequenceType(None,
BuiltinTypes[IDLBuiltinType.Types.domstring]),
# Let's use unsigned long for the type here, though really
# it's just a C++ "unsigned"...
[FakeArgument(BuiltinTypes[IDLBuiltinType.Types.unsigned_long],
FakeMember(),
name="aFlags")]),
[]),
{"infallible": True}))
wrapArgs = [Argument('JSContext*', 'aCx'),

View File

@ -1137,7 +1137,7 @@ public:
virtual nsISupports* GetParentObject();
void NamedGetter(const nsAString&, bool&, nsAString&);
void GetSupportedNames(unsigned, nsTArray<nsString>&);
void GetSupportedNames(nsTArray<nsString>&);
};
class TestIndexedGetterAndSetterAndNamedGetterInterface : public nsISupports,
@ -1150,7 +1150,7 @@ public:
virtual nsISupports* GetParentObject();
void NamedGetter(const nsAString&, bool&, nsAString&);
void GetSupportedNames(unsigned, nsTArray<nsString>&);
void GetSupportedNames(nsTArray<nsString>&);
int32_t IndexedGetter(uint32_t, bool&);
void IndexedSetter(uint32_t, int32_t);
uint32_t Length();
@ -1169,7 +1169,7 @@ public:
void NamedGetter(const nsAString&, bool&, nsAString&);
void NamedItem(const nsAString&, nsAString&);
uint32_t Length();
void GetSupportedNames(unsigned, nsTArray<nsString>&);
void GetSupportedNames(nsTArray<nsString>&);
};
class TestIndexedSetterInterface : public nsISupports,
@ -1198,7 +1198,7 @@ public:
void NamedSetter(const nsAString&, TestIndexedSetterInterface&);
TestIndexedSetterInterface* NamedGetter(const nsAString&, bool&);
void GetSupportedNames(unsigned, nsTArray<nsString>&);
void GetSupportedNames(nsTArray<nsString>&);
};
class TestIndexedAndNamedSetterInterface : public nsISupports,
@ -1216,7 +1216,7 @@ public:
void NamedSetter(const nsAString&, TestIndexedSetterInterface&);
TestIndexedSetterInterface* NamedGetter(const nsAString&, bool&);
void SetNamedItem(const nsAString&, TestIndexedSetterInterface&);
void GetSupportedNames(unsigned, nsTArray<nsString>&);
void GetSupportedNames(nsTArray<nsString>&);
};
class TestIndexedAndNamedGetterAndSetterInterface : public TestIndexedSetterInterface
@ -1231,7 +1231,7 @@ public:
void NamedSetter(const nsAString&, const nsAString&);
void Stringify(nsAString&);
uint32_t Length();
void GetSupportedNames(unsigned, nsTArray<nsString>&);
void GetSupportedNames(nsTArray<nsString>&);
};
class TestCppKeywordNamedMethodsInterface : public nsISupports,
@ -1293,7 +1293,7 @@ public:
void NamedDeleter(const nsAString&, bool&);
long NamedGetter(const nsAString&, bool&);
void GetSupportedNames(unsigned, nsTArray<nsString>&);
void GetSupportedNames(nsTArray<nsString>&);
};
class TestNamedDeleterWithRetvalInterface : public nsISupports,
@ -1310,7 +1310,7 @@ public:
long NamedGetter(const nsAString&, bool&);
bool DelNamedItem(const nsAString&);
bool DelNamedItem(const nsAString&, bool&) = delete;
void GetSupportedNames(unsigned, nsTArray<nsString>&);
void GetSupportedNames(nsTArray<nsString>&);
};
class TestIndexedAndNamedDeleterInterface : public nsISupports,
@ -1331,7 +1331,7 @@ public:
long NamedGetter(const nsAString&, bool&);
void DelNamedItem(const nsAString&);
void DelNamedItem(const nsAString&, bool&) = delete;
void GetSupportedNames(unsigned, nsTArray<nsString>&);
void GetSupportedNames(nsTArray<nsString>&);
};
class TestParentInterface : public nsISupports,

View File

@ -239,10 +239,10 @@ CameraRecorderProfiles::~CameraRecorderProfiles()
}
void
CameraRecorderProfiles::GetSupportedNames(unsigned aFlags, nsTArray<nsString>& aNames)
CameraRecorderProfiles::GetSupportedNames(nsTArray<nsString>& aNames)
{
DOM_CAMERA_LOGT("%s:%d : this=%p, flags=0x%x\n",
__func__, __LINE__, this, aFlags);
DOM_CAMERA_LOGT("%s:%d : this=%p\n",
__func__, __LINE__, this);
if (!mCameraControl) {
aNames.Clear();
return;

View File

@ -161,7 +161,7 @@ public:
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
CameraRecorderProfile* NamedGetter(const nsAString& aName, bool& aFound);
void GetSupportedNames(unsigned aFlags, nsTArray<nsString>& aNames);
void GetSupportedNames(nsTArray<nsString>& aNames);
virtual void OnHardwareClosed();

View File

@ -160,12 +160,8 @@ HTMLAllCollection::NamedGetter(const nsAString& aID,
}
void
HTMLAllCollection::GetSupportedNames(unsigned aFlags, nsTArray<nsString>& aNames)
HTMLAllCollection::GetSupportedNames(nsTArray<nsString>& aNames)
{
if (!(aFlags & JSITER_HIDDEN)) {
return;
}
// XXXbz this is very similar to nsContentList::GetSupportedNames,
// but has to check IsAllNamedElement for the name case.
AutoTArray<nsIAtom*, 8> atoms;

View File

@ -62,7 +62,7 @@ public:
void NamedGetter(const nsAString& aName,
bool& aFound,
Nullable<OwningNodeOrHTMLCollection>& aResult);
void GetSupportedNames(unsigned aFlags, nsTArray<nsString>& aNames);
void GetSupportedNames(nsTArray<nsString>& aNames);
void LegacyCall(JS::Handle<JS::Value>, const nsAString& aName,
Nullable<OwningNodeOrHTMLCollection>& aResult)
{

View File

@ -390,13 +390,8 @@ HTMLFormControlsCollection::NamedGetter(const nsAString& aName,
}
void
HTMLFormControlsCollection::GetSupportedNames(unsigned aFlags,
nsTArray<nsString>& aNames)
HTMLFormControlsCollection::GetSupportedNames(nsTArray<nsString>& aNames)
{
if (!(aFlags & JSITER_HIDDEN)) {
return;
}
FlushPendingNotifications();
// Just enumerate mNameLookupTable. This won't guarantee order, but
// that's OK, because the HTML5 spec doesn't define an order for

View File

@ -53,8 +53,7 @@ public:
bool dummy;
NamedGetter(aName, dummy, aResult);
}
virtual void GetSupportedNames(unsigned aFlags,
nsTArray<nsString>& aNames) override;
virtual void GetSupportedNames(nsTArray<nsString>& aNames) override;
nsresult AddElementToTable(nsGenericHTMLFormElement* aChild,
const nsAString& aName);

View File

@ -1539,7 +1539,7 @@ HTMLFormElement::NamedGetter(const nsAString& aName, bool &aFound)
}
void
HTMLFormElement::GetSupportedNames(unsigned, nsTArray<nsString >& aRetval)
HTMLFormElement::GetSupportedNames(nsTArray<nsString >& aRetval)
{
// TODO https://www.w3.org/Bugs/Public/show_bug.cgi?id=22320
}

View File

@ -393,7 +393,7 @@ public:
already_AddRefed<nsISupports>
NamedGetter(const nsAString& aName, bool &aFound);
void GetSupportedNames(unsigned, nsTArray<nsString >& aRetval);
void GetSupportedNames(nsTArray<nsString>& aRetval);
static int32_t
CompareFormControlPosition(Element* aElement1, Element* aElement2,

View File

@ -280,13 +280,8 @@ HTMLOptionsCollection::NamedItem(const nsAString& aName,
}
void
HTMLOptionsCollection::GetSupportedNames(unsigned aFlags,
nsTArray<nsString>& aNames)
HTMLOptionsCollection::GetSupportedNames(nsTArray<nsString>& aNames)
{
if (!(aFlags & JSITER_HIDDEN)) {
return;
}
AutoTArray<nsIAtom*, 8> atoms;
for (uint32_t i = 0; i < mElements.Length(); ++i) {
HTMLOptionElement* content = mElements.ElementAt(i);

View File

@ -154,8 +154,7 @@ public:
{
aError = SetOption(aIndex, aOption);
}
virtual void GetSupportedNames(unsigned aFlags,
nsTArray<nsString>& aNames) override;
virtual void GetSupportedNames(nsTArray<nsString>& aNames) override;
private:
/** The list of options (holds strong references). This is infallible, so

View File

@ -288,7 +288,7 @@ HTMLPropertiesCollection::CrawlSubtree(Element* aElement)
}
void
HTMLPropertiesCollection::GetSupportedNames(unsigned, nsTArray<nsString>& aNames)
HTMLPropertiesCollection::GetSupportedNames(nsTArray<nsString>& aNames)
{
EnsureFresh();
mNames->CopyList(aNames);

View File

@ -95,8 +95,7 @@ public:
EnsureFresh();
return mNames;
}
virtual void GetSupportedNames(unsigned,
nsTArray<nsString>& aNames) override;
virtual void GetSupportedNames(nsTArray<nsString>& aNames) override;
NS_DECL_NSIDOMHTMLCOLLECTION

View File

@ -41,8 +41,7 @@ public:
virtual Element*
GetFirstNamedElement(const nsAString& aName, bool& aFound) override;
virtual void GetSupportedNames(unsigned aFlags,
nsTArray<nsString>& aNames) override;
virtual void GetSupportedNames(nsTArray<nsString>& aNames) override;
NS_IMETHOD ParentDestroyed();
@ -236,18 +235,13 @@ TableRowsCollection::GetFirstNamedElement(const nsAString& aName, bool& aFound)
}
void
TableRowsCollection::GetSupportedNames(unsigned aFlags,
nsTArray<nsString>& aNames)
TableRowsCollection::GetSupportedNames(nsTArray<nsString>& aNames)
{
if (!(aFlags & JSITER_HIDDEN)) {
return;
}
DO_FOR_EACH_ROWGROUP(
nsTArray<nsString> names;
nsCOMPtr<nsIHTMLCollection> coll = do_QueryInterface(rows);
if (coll) {
coll->GetSupportedNames(aFlags, names);
coll->GetSupportedNames(names);
for (uint32_t i = 0; i < names.Length(); ++i) {
if (!aNames.Contains(names[i])) {
aNames.AppendElement(names[i]);

View File

@ -143,7 +143,7 @@ nsDOMStringMap::NamedDeleter(const nsAString& aProp, bool& found)
}
void
nsDOMStringMap::GetSupportedNames(unsigned, nsTArray<nsString>& aNames)
nsDOMStringMap::GetSupportedNames(nsTArray<nsString>& aNames)
{
uint32_t attrCount = mElement->GetAttrCount();

View File

@ -42,7 +42,7 @@ public:
void NamedSetter(const nsAString& aProp, const nsAString& aValue,
mozilla::ErrorResult& rv);
void NamedDeleter(const nsAString& aProp, bool &found);
void GetSupportedNames(unsigned, nsTArray<nsString>& aNames);
void GetSupportedNames(nsTArray<nsString>& aNames);
js::ExpandoAndGeneration mExpandoAndGeneration;

View File

@ -2326,7 +2326,7 @@ nsHTMLDocument::NamedGetter(JSContext* cx, const nsAString& aName, bool& aFound,
}
void
nsHTMLDocument::GetSupportedNames(unsigned, nsTArray<nsString>& aNames)
nsHTMLDocument::GetSupportedNames(nsTArray<nsString>& aNames)
{
for (auto iter = mIdentifierMap.Iter(); !iter.Done(); iter.Next()) {
nsIdentifierMapEntry* entry = iter.Get();

View File

@ -174,7 +174,7 @@ public:
void NamedGetter(JSContext* cx, const nsAString& aName, bool& aFound,
JS::MutableHandle<JSObject*> aRetval,
mozilla::ErrorResult& rv);
void GetSupportedNames(unsigned, nsTArray<nsString>& aNames);
void GetSupportedNames(nsTArray<nsString>& aNames);
nsGenericHTMLElement *GetBody();
void SetBody(nsGenericHTMLElement* aBody, mozilla::ErrorResult& rv);
mozilla::dom::HTMLSharedElement *GetHead() {

View File

@ -72,8 +72,7 @@ public:
virtual mozilla::dom::Element*
GetFirstNamedElement(const nsAString& aName, bool& aFound) = 0;
virtual void GetSupportedNames(unsigned aFlags,
nsTArray<nsString>& aNames) = 0;
virtual void GetSupportedNames(nsTArray<nsString>& aNames) = 0;
JSObject* GetWrapperPreserveColor()
{

View File

@ -296,7 +296,7 @@ DOMStorage::CanAccess(nsIPrincipal* aPrincipal)
}
void
DOMStorage::GetSupportedNames(unsigned, nsTArray<nsString>& aKeys)
DOMStorage::GetSupportedNames(nsTArray<nsString>& aKeys)
{
if (!CanUseStorage(nullptr, this)) {
// return just an empty array

View File

@ -81,7 +81,7 @@ public:
void GetItem(const nsAString& aKey, nsAString& aResult, ErrorResult& aRv);
void GetSupportedNames(unsigned, nsTArray<nsString>& aKeys);
void GetSupportedNames(nsTArray<nsString>& aKeys);
void NamedGetter(const nsAString& aKey, bool& aFound, nsAString& aResult,
ErrorResult& aRv)

View File

@ -621,7 +621,7 @@ nsTreeColumns::GetNamedColumn(const nsAString& aId, nsITreeColumn** _retval)
}
void
nsTreeColumns::GetSupportedNames(unsigned, nsTArray<nsString>& aNames)
nsTreeColumns::GetSupportedNames(nsTArray<nsString>& aNames)
{
for (nsTreeColumn* currCol = mFirstColumn; currCol; currCol = currCol->GetNext()) {
aNames.AppendElement(currCol->GetId());

View File

@ -187,7 +187,7 @@ public:
nsTreeColumn* GetColumnAt(uint32_t aIndex);
nsTreeColumn* NamedGetter(const nsAString& aId, bool& aFound);
nsTreeColumn* GetNamedColumn(const nsAString& aId);
void GetSupportedNames(unsigned, nsTArray<nsString>& aNames);
void GetSupportedNames(nsTArray<nsString>& aNames);
// Uses XPCOM InvalidateColumns().
// Uses XPCOM RestoreNaturalOrder().