Backed out changeset 4309266ff43d (bug 1629291) for frequent assertion failures on ErrorResult.h. CLOSED TREE
authorCsoregi Natalia <ncsoregi@mozilla.com>
Wed, 13 May 2020 10:23:18 +0300
changeset 529558 4648ea360a394f64de8a67a086e879033865523b
parent 529557 16456971c2e6269f70496d8f6c71e90e02c522e8
child 529559 1e959f3236791770fed2405956c2bc6d6ee723d4
push id115772
push userncsoregi@mozilla.com
push dateWed, 13 May 2020 07:25:25 +0000
treeherderautoland@4648ea360a39 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1629291
milestone78.0a1
backs out4309266ff43d3a4f398200c7a5df768a021ed0be
first release with
nightly linux32
4648ea360a39 / 78.0a1 / 20200513094918 / files
nightly linux64
4648ea360a39 / 78.0a1 / 20200513094918 / files
nightly mac
4648ea360a39 / 78.0a1 / 20200513094918 / files
nightly win32
4648ea360a39 / 78.0a1 / 20200513094918 / files
nightly win64
4648ea360a39 / 78.0a1 / 20200513094918 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 4309266ff43d (bug 1629291) for frequent assertion failures on ErrorResult.h. CLOSED TREE
dom/base/Document.cpp
dom/base/Document.h
dom/l10n/DOMLocalization.cpp
dom/l10n/DocumentL10n.cpp
dom/l10n/DocumentL10n.h
dom/xul/nsXULPrototypeDocument.cpp
dom/xul/nsXULPrototypeDocument.h
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -3959,31 +3959,31 @@ void Document::OnParsingCompleted() {
   // now we're closing the document.
   OnL10nResourceContainerParsed();
 
   if (mDocumentL10n) {
     mDocumentL10n->TriggerInitialTranslation();
   }
 }
 
-void Document::InitialTranslationCompleted(bool aL10nCached) {
+void Document::InitialTranslationCompleted() {
   if (mDocumentL10n && mDocumentL10n->mBlockingLayout) {
     // This means we blocked the load event in LocalizationLinkAdded.  It's
     // important that the load blocker removal here be async, because our caller
     // will notify the content sink after us, and we want the content sync's
     // work to happen before the load event fires.
     mDocumentL10n->mBlockingLayout = false;
     UnblockOnload(/* aFireSync = */ false);
   }
 
   mL10nProtoElements.Clear();
 
   nsXULPrototypeDocument* proto = GetPrototype();
   if (proto) {
-    proto->SetIsL10nCached(aL10nCached);
+    proto->SetIsL10nCached();
   }
 }
 
 bool Document::AllowsL10n() const {
   bool allowed = false;
   NodePrincipal()->IsL10nAllowed(GetDocumentURI(), &allowed);
   return allowed;
 }
--- a/dom/base/Document.h
+++ b/dom/base/Document.h
@@ -3738,21 +3738,18 @@ class Document : public nsINode,
    */
   void OnParsingCompleted();
 
   /**
    * This method is called when the initial translation
    * of the document is completed.
    *
    * It unblocks the load event if translation was blocking it.
-   *
-   * If the `aL10nCached` is set to `true`, and the document has
-   * a prototype, it will set the `isL10nCached` flag on it.
-   */
-  void InitialTranslationCompleted(bool aL10nCached);
+   */
+  void InitialTranslationCompleted();
 
   /**
    * Returns whether the document allows localization.
    */
   bool AllowsL10n() const;
 
  protected:
   RefPtr<DocumentL10n> mDocumentL10n;
--- a/dom/l10n/DOMLocalization.cpp
+++ b/dom/l10n/DOMLocalization.cpp
@@ -453,51 +453,43 @@ void DOMLocalization::ApplyTranslations(
   }
 
   PauseObserving(aRv);
   if (NS_WARN_IF(aRv.Failed())) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
-  bool hasMissingTranslation = false;
-
   nsTArray<L10nOverlaysError> errors;
   for (size_t i = 0; i < aTranslations.Length(); ++i) {
     Element* elem = aElements[i];
     if (aTranslations[i].IsNull()) {
-      hasMissingTranslation = true;
       continue;
     }
     L10nOverlays::TranslateElement(*elem, aTranslations[i].Value(), errors,
                                    aRv);
     if (NS_WARN_IF(aRv.Failed())) {
-      hasMissingTranslation = true;
-      continue;
+      aRv.Throw(NS_ERROR_FAILURE);
+      return;
     }
     if (aProto) {
       // We only need to rebuild deep if the translation has a value.
       // Otherwise we'll only rebuild the attributes.
       aProto->RebuildL10nPrototype(elem,
                                    !aTranslations[i].Value().mValue.IsVoid());
     }
   }
 
-  ReportL10nOverlaysErrors(errors);
-
   ResumeObserving(aRv);
   if (NS_WARN_IF(aRv.Failed())) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
-  if (hasMissingTranslation) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return;
-  }
+  ReportL10nOverlaysErrors(errors);
 }
 
 /* Protected */
 
 void DOMLocalization::OnChange() {
   Localization::OnChange();
   if (mLocalization) {
     ErrorResult rv;
--- a/dom/l10n/DocumentL10n.cpp
+++ b/dom/l10n/DocumentL10n.cpp
@@ -88,22 +88,22 @@ class L10nReadyHandler final : public Pr
  public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS(L10nReadyHandler)
 
   explicit L10nReadyHandler(Promise* aPromise, DocumentL10n* aDocumentL10n)
       : mPromise(aPromise), mDocumentL10n(aDocumentL10n) {}
 
   void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override {
-    mDocumentL10n->InitialTranslationCompleted(true);
+    mDocumentL10n->InitialTranslationCompleted();
     mPromise->MaybeResolveWithUndefined();
   }
 
   void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override {
-    mDocumentL10n->InitialTranslationCompleted(false);
+    mDocumentL10n->InitialTranslationCompleted();
     mPromise->MaybeRejectWithUndefined();
   }
 
  private:
   ~L10nReadyHandler() = default;
 
   RefPtr<Promise> mPromise;
   RefPtr<DocumentL10n> mDocumentL10n;
@@ -123,42 +123,42 @@ void DocumentL10n::TriggerInitialTransla
     return;
   }
 
   nsTArray<RefPtr<Promise>> promises;
 
   ErrorResult rv;
   promises.AppendElement(TranslateDocument(rv));
   if (NS_WARN_IF(rv.Failed())) {
-    InitialTranslationCompleted(false);
+    InitialTranslationCompleted();
     mReady->MaybeRejectWithUndefined();
     return;
   }
   promises.AppendElement(TranslateRoots(rv));
   Element* documentElement = mDocument->GetDocumentElement();
   if (!documentElement) {
-    InitialTranslationCompleted(false);
+    InitialTranslationCompleted();
     mReady->MaybeRejectWithUndefined();
     return;
   }
 
   DOMLocalization::ConnectRoot(*documentElement, rv);
   if (NS_WARN_IF(rv.Failed())) {
-    InitialTranslationCompleted(false);
+    InitialTranslationCompleted();
     mReady->MaybeRejectWithUndefined();
     return;
   }
 
   AutoEntryScript aes(mGlobal, "DocumentL10n InitialTranslation");
   RefPtr<Promise> promise = Promise::All(aes.cx(), promises, rv);
 
   if (promise->State() == Promise::PromiseState::Resolved) {
     // If the promise is already resolved, we can fast-track
     // to initial translation completed.
-    InitialTranslationCompleted(true);
+    InitialTranslationCompleted();
     mReady->MaybeResolveWithUndefined();
   } else {
     RefPtr<PromiseNativeHandler> l10nReadyHandler =
         new L10nReadyHandler(mReady, this);
     promise->AppendNativeHandler(l10nReadyHandler);
 
     mState = DocumentL10nState::InitialTranslationTriggered;
   }
@@ -185,17 +185,17 @@ already_AddRefed<Promise> DocumentL10n::
 
   RefPtr<nsXULPrototypeDocument> proto = mDocument->GetPrototype();
 
   // 2. Check if the document has a prototype that may cache
   //    translated elements.
   if (proto) {
     // 2.1. Handle the case when we have proto.
 
-    // 2.1.1. Move eslements that are not in the proto to a separate
+    // 2.1.1. Move elements that are not in the proto to a separate
     //        array.
     Sequence<OwningNonNull<Element>> nonProtoElements;
 
     uint32_t i = elements.Length();
     while (i > 0) {
       Element* elem = elements.ElementAt(i - 1);
       MOZ_RELEASE_ASSERT(elem->HasAttr(nsGkAtoms::datal10nid));
       if (!elem->HasElementCreatedFromPrototypeAndHasUnmodifiedL10n()) {
@@ -253,29 +253,29 @@ already_AddRefed<Promise> DocumentL10n::
   if (NS_WARN_IF(!promise || aRv.Failed())) {
     promise->MaybeRejectWithUndefined();
     return promise.forget();
   }
 
   return promise.forget();
 }
 
-void DocumentL10n::InitialTranslationCompleted(bool aL10nCached) {
+void DocumentL10n::InitialTranslationCompleted() {
   if (mState >= DocumentL10nState::Ready) {
     return;
   }
 
   Element* documentElement = mDocument->GetDocumentElement();
   if (documentElement) {
     SetRootInfo(documentElement);
   }
 
   mState = DocumentL10nState::Ready;
 
-  mDocument->InitialTranslationCompleted(aL10nCached);
+  mDocument->InitialTranslationCompleted();
 
   // In XUL scenario contentSink is nullptr.
   if (mContentSink) {
     mContentSink->InitialTranslationCompleted();
   }
 
   // If sync was true, we want to change the state of
   // mozILocalization to async now.
--- a/dom/l10n/DocumentL10n.h
+++ b/dom/l10n/DocumentL10n.h
@@ -66,17 +66,17 @@ class DocumentL10n final : public DOMLoc
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aGivenProto) override;
 
   Promise* Ready();
 
   void TriggerInitialTranslation();
   already_AddRefed<Promise> TranslateDocument(ErrorResult& aRv);
 
-  void InitialTranslationCompleted(bool aL10nCached);
+  void InitialTranslationCompleted();
 
   Document* GetDocument() { return mDocument; };
   void OnCreatePresShell();
 
   void ConnectRoot(nsINode& aNode, bool aTranslate, ErrorResult& aRv);
 
   DocumentL10nState GetState() { return mState; };
 
--- a/dom/xul/nsXULPrototypeDocument.cpp
+++ b/dom/xul/nsXULPrototypeDocument.cpp
@@ -435,19 +435,17 @@ void nsXULPrototypeDocument::TraceProtos
     mGCNumber = currentGCNumber;
   }
 
   if (mRoot) {
     mRoot->TraceAllScripts(aTrc);
   }
 }
 
-void nsXULPrototypeDocument::SetIsL10nCached(bool aIsCached) {
-  mWasL10nCached = aIsCached;
-}
+void nsXULPrototypeDocument::SetIsL10nCached() { mWasL10nCached = true; }
 
 void nsXULPrototypeDocument::RebuildPrototypeFromElement(
     nsXULPrototypeElement* aPrototype, Element* aElement, bool aDeep) {
   aPrototype->mHasIdAttribute = aElement->HasID();
   aPrototype->mHasClassAttribute = aElement->MayHaveClass();
   aPrototype->mHasStyleAttribute = aElement->MayHaveStyle();
   NodeInfo* oldNodeInfo = aElement->NodeInfo();
   RefPtr<NodeInfo> newNodeInfo = mNodeInfoManager->GetNodeInfo(
--- a/dom/xul/nsXULPrototypeDocument.h
+++ b/dom/xul/nsXULPrototypeDocument.h
@@ -92,17 +92,17 @@ class nsXULPrototypeDocument final : pub
   void MarkInCCGeneration(uint32_t aCCGeneration);
 
   NS_DECL_CYCLE_COLLECTION_CLASS(nsXULPrototypeDocument)
 
   void TraceProtos(JSTracer* aTrc);
 
   bool WasL10nCached() { return mWasL10nCached; };
 
-  void SetIsL10nCached(bool aIsCached);
+  void SetIsL10nCached();
   void RebuildPrototypeFromElement(nsXULPrototypeElement* aPrototype,
                                    mozilla::dom::Element* aElement, bool aDeep);
   void RebuildL10nPrototype(mozilla::dom::Element* aElement, bool aDeep);
 
  protected:
   nsCOMPtr<nsIURI> mURI;
   RefPtr<nsXULPrototypeElement> mRoot;
   nsTArray<RefPtr<nsXULPrototypePI> > mProcessingInstructions;