Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  ConnectedAncestorTracker.h

  Sprache: C
 

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


#ifndef mozilla_ConnectedAncestorTracker_h
#define mozilla_ConnectedAncestorTracker_h

#include "mozilla/Attributes.h"
#include "mozilla/PresShell.h"
#include "mozilla/dom/Document.h"
#include "mozilla/dom/Element.h"
#include "nsIContent.h"

namespace mozilla {

/**
 * AutoConnectedAncestorTracker is a struct which keeps referring the connected
 * and closest ancestor of a content node.  E.g., say, there are nodes are:
 * Document -> <html> -> <body> -> <div> and starts tracking it with the <div>,
 * and the <body> is removed, this refers the <html> with mConnectedAncestor.
 * Note that even after reconnected the <body>, this won't refer the <div> as
 * connected one.
 */

struct MOZ_STACK_CLASS AutoConnectedAncestorTracker final {
  explicit AutoConnectedAncestorTracker(nsIContent& aContent)
      : mContent(aContent),
        mPresShell(aContent.IsInComposedDoc()
                       ? aContent.OwnerDoc()->GetPresShell()
                       : nullptr) {
    if (mPresShell) {
      mPresShell->AddConnectedAncestorTracker(*this);
    }
  }
  ~AutoConnectedAncestorTracker() {
    if (mPresShell) {
      mPresShell->RemoveConnectedAncestorTracker(*this);
    }
  }

  [[nodiscard]] bool ContentWasRemoved() const {
    return mPresShell && mConnectedAncestor;
  }
  [[nodiscard]] dom::Element* GetConnectedElement() const {
    return ContentWasRemoved()
               ? mConnectedAncestor->GetAsElementOrParentElement()
               : mContent->GetAsElementOrParentElement();
  }
  [[nodiscard]] nsIContent* GetConnectedContent() const {
    return ContentWasRemoved() ? nsIContent::FromNode(mConnectedAncestor)
                               : mContent.get();
  }
  [[nodiscard]] nsINode& ConnectedNode() const {
    return ContentWasRemoved() ? *mConnectedAncestor : mContent.ref();
  }

  // Store the original content node.
  const OwningNonNull<nsIContent> mContent;
  // Store the connected ancestor node if and only if mContent has been deleted
  // from the document.
  nsCOMPtr<nsINode> mConnectedAncestor;

  // The PresShell which manages this instance.
  const RefPtr<PresShell> mPresShell;

  AutoConnectedAncestorTracker* mPreviousTracker = nullptr;
};

}  // namespace mozilla

#endif  // #ifndef mozilla_ConnectedAncestorTracker_h

Messung V0.5 in Prozent
C=91 H=85 G=87

¤ Dauer der Verarbeitung: 0.4 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=141584
#Domains=738142