☠☠ backed out by 30ed797c2454 ☠ ☠ | |
author | Peter Van der Beken <peterv@propagandism.org> |
Fri, 09 Dec 2016 18:02:50 +0100 | |
changeset 414762 | 02178545f255e96f95540dba7668c6a7dda079fd |
parent 414761 | 719f7596c208eab1f2c8a1a250f1a6d2a7304d65 |
child 414763 | 80abe3305b24b7f2c251ac973a287275a488428f |
push id | 33876 |
push user | dluca@mozilla.com |
push date | Fri, 20 Apr 2018 23:00:46 +0000 |
treeherder | mozilla-central@39ccabfd7d07 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | bz |
bugs | 1452981 |
milestone | 61.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/base/WindowNamedPropertiesHandler.cpp +++ b/dom/base/WindowNamedPropertiesHandler.cpp @@ -108,52 +108,50 @@ WindowNamedPropertiesHandler::getOwnProp nsGlobalWindowInner* win = xpc::WindowOrNull(global); if (win->Length() > 0) { nsCOMPtr<nsPIDOMWindowOuter> childWin = win->GetChildWindow(str); if (childWin && ShouldExposeChildWindow(str, childWin)) { // We found a subframe of the right name. Shadowing via |var foo| in // global scope is still allowed, since |var| only looks up |own| // properties. But unqualified shadowing will fail, per-spec. JS::Rooted<JS::Value> v(aCx); - if (!WrapObject(aCx, childWin, &v)) { + if (!ToJSValue(aCx, nsGlobalWindowOuter::Cast(childWin), &v)) { return false; } FillPropertyDescriptor(aDesc, aProxy, 0, v); return true; } } // The rest of this function is for HTML documents only. nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(win->GetExtantDoc()); if (!htmlDoc) { return true; } nsHTMLDocument* document = static_cast<nsHTMLDocument*>(htmlDoc.get()); + JS::Rooted<JS::Value> v(aCx); Element* element = document->GetElementById(str); if (element) { - JS::Rooted<JS::Value> v(aCx); - if (!WrapObject(aCx, element, &v)) { + if (!ToJSValue(aCx, element, &v)) { return false; } FillPropertyDescriptor(aDesc, aProxy, 0, v); return true; } - nsWrapperCache* cache; - nsISupports* result = document->ResolveName(str, &cache); - if (!result) { - return true; + ErrorResult rv; + bool found = document->ResolveName(aCx, str, &v, rv); + if (rv.MaybeSetPendingException(aCx)) { + return false; } - JS::Rooted<JS::Value> v(aCx); - if (!WrapObject(aCx, result, cache, nullptr, &v)) { - return false; + if (found) { + FillPropertyDescriptor(aDesc, aProxy, 0, v); } - FillPropertyDescriptor(aDesc, aProxy, 0, v); return true; } bool WindowNamedPropertiesHandler::defineProperty(JSContext* aCx, JS::Handle<JSObject*> aProxy, JS::Handle<jsid> aId, JS::Handle<JS::PropertyDescriptor> aDesc,
--- a/dom/html/nsHTMLDocument.cpp +++ b/dom/html/nsHTMLDocument.cpp @@ -1886,74 +1886,59 @@ nsHTMLDocument::CaptureEvents() } void nsHTMLDocument::ReleaseEvents() { WarnOnceAbout(nsIDocument::eUseOfReleaseEvents); } -nsISupports* -nsHTMLDocument::ResolveName(const nsAString& aName, nsWrapperCache **aCache) +bool +nsHTMLDocument::ResolveName(JSContext* aCx, const nsAString& aName, + JS::MutableHandle<JS::Value> aRetval, ErrorResult& aError) { nsIdentifierMapEntry *entry = mIdentifierMap.GetEntry(aName); if (!entry) { - *aCache = nullptr; - return nullptr; + return false; } nsBaseContentList *list = entry->GetNameContentList(); uint32_t length = list ? list->Length() : 0; + nsIContent *node; if (length > 0) { - if (length == 1) { - // Only one element in the list, return the element instead of returning - // the list. - nsIContent *node = list->Item(0); - *aCache = node; - return node; + if (length > 1) { + // The list contains more than one element, return the whole list. + if (!ToJSValue(aCx, list, aRetval)) { + aError.NoteJSContextException(aCx); + return false; + } + return true; } - // The list contains more than one element, return the whole list. - *aCache = list; - return list; - } - - // No named items were found, see if there's one registerd by id for aName. - Element *e = entry->GetIdElement(); - - if (e && nsGenericHTMLElement::ShouldExposeIdAsHTMLDocumentProperty(e)) { - *aCache = e; - return e; + // Only one element in the list, return the element instead of returning + // the list. + node = list->Item(0); + } else { + // No named items were found, see if there's one registerd by id for aName. + Element *e = entry->GetIdElement(); + + if (!e || !nsGenericHTMLElement::ShouldExposeIdAsHTMLDocumentProperty(e)) { + return false; + } + + node = e; } - *aCache = nullptr; - return nullptr; -} - -void -nsHTMLDocument::NamedGetter(JSContext* cx, const nsAString& aName, bool& aFound, - JS::MutableHandle<JSObject*> aRetval, - ErrorResult& rv) -{ - nsWrapperCache* cache; - nsISupports* supp = ResolveName(aName, &cache); - if (!supp) { - aFound = false; - aRetval.set(nullptr); - return; + if (!ToJSValue(aCx, node, aRetval)) { + aError.NoteJSContextException(aCx); + return false; } - JS::Rooted<JS::Value> val(cx); - if (!dom::WrapObject(cx, supp, cache, nullptr, &val)) { - rv.Throw(NS_ERROR_OUT_OF_MEMORY); - return; - } - aFound = true; - aRetval.set(&val.toObject()); + return true; } void nsHTMLDocument::GetSupportedNames(nsTArray<nsString>& aNames) { for (auto iter = mIdentifierMap.Iter(); !iter.Done(); iter.Next()) { nsIdentifierMapEntry* entry = iter.Get(); if (entry->HasNameElement() ||
--- a/dom/html/nsHTMLDocument.h +++ b/dom/html/nsHTMLDocument.h @@ -87,17 +87,19 @@ public: using nsDocument::GetImplementation; using nsDocument::GetTitle; using nsDocument::SetTitle; using nsDocument::GetLastStyleSheetSet; using nsDocument::MozSetImageElement; mozilla::dom::HTMLAllCollection* All(); - nsISupports* ResolveName(const nsAString& aName, nsWrapperCache **aCache); + // Returns whether an object was found for aName. + bool ResolveName(JSContext* aCx, const nsAString& aName, + JS::MutableHandle<JS::Value> aRetval, mozilla::ErrorResult& aError); virtual void AddedForm() override; virtual void RemovedForm() override; virtual int32_t GetNumFormsSynchronous() override; virtual void TearingDownEditor() override; virtual void SetIsXHTML(bool aXHTML) override { mType = (aXHTML ? eXHTML : eHTML); @@ -159,17 +161,23 @@ public: void GetDomain(nsAString& aDomain); void SetDomain(const nsAString& aDomain, mozilla::ErrorResult& rv); bool IsRegistrableDomainSuffixOfOrEqualTo(const nsAString& aHostSuffixString, const nsACString& aOrigHost); void GetCookie(nsAString& aCookie, mozilla::ErrorResult& rv); void SetCookie(const nsAString& aCookie, mozilla::ErrorResult& rv); void NamedGetter(JSContext* cx, const nsAString& aName, bool& aFound, JS::MutableHandle<JSObject*> aRetval, - mozilla::ErrorResult& rv); + mozilla::ErrorResult& rv) + { + JS::Rooted<JS::Value> v(cx); + if ((aFound = ResolveName(cx, aName, &v, rv))) { + aRetval.set(v.toObjectOrNull()); + } + } void GetSupportedNames(nsTArray<nsString>& aNames); already_AddRefed<nsIDocument> Open(JSContext* cx, const mozilla::dom::Optional<nsAString>& /* unused */, const nsAString& aReplace, mozilla::ErrorResult& aError); already_AddRefed<nsPIDOMWindowOuter> Open(JSContext* cx, const nsAString& aURL,