Commit 2a9602f6 authored by Emilio Cobos Álvarez's avatar Emilio Cobos Álvarez
Browse files

Bug 1596391 - Remove lazy computation of FlattenedChildIterator::mXBLInvolved. r=smaug

XBL is gone, and thus we don't need to check for the children element anymore,
and computing it upfront becomes cheap.

Depends on D52990

Differential Revision: https://phabricator.services.mozilla.com/D52991

--HG--
extra : moz-landing-system : lando
parent e6d93238
Loading
Loading
Loading
Loading
+4 −26
Original line number Diff line number Diff line
@@ -94,7 +94,6 @@ nsIContent* ExplicitChildIterator::GetNextChild() {

void FlattenedChildIterator::Init(bool aIgnoreXBL) {
  if (aIgnoreXBL) {
    mXBLInvolved = Some(false);
    return;
  }

@@ -103,35 +102,14 @@ void FlattenedChildIterator::Init(bool aIgnoreXBL) {
  if (mParent->IsElement()) {
    if (ShadowRoot* shadow = mParent->AsElement()->GetShadowRoot()) {
      mParent = shadow;
      mXBLInvolved = Some(true);
      mXBLInvolved = true;
      return;
    }
  }
}

bool FlattenedChildIterator::ComputeWhetherXBLIsInvolved() const {
  MOZ_ASSERT(mXBLInvolved.isNothing());
  // We set mXBLInvolved to true if either the node we're iterating has a
  // binding with content attached to it (in which case it is handled in Init),
  // the node is generated XBL content and has an <xbl:children> child, or the
  // node is a <slot> element.
  if (!mParent->GetBindingParent()) {
    return false;
  }

    if (mParentAsSlot) {
    return true;
  }

  for (nsIContent* child = mParent->GetFirstChild(); child;
       child = child->GetNextSibling()) {
    if (child->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) {
      MOZ_ASSERT(child->GetBindingParent());
      return true;
      mXBLInvolved = true;
      return;
    }
  }

  return false;
}

bool ExplicitChildIterator::Seek(const nsIContent* aChildToFind) {
+3 −8
Original line number Diff line number Diff line
@@ -144,17 +144,14 @@ class FlattenedChildIterator : public ExplicitChildIterator {
        mOriginalContent(aOther.mOriginalContent),
        mXBLInvolved(aOther.mXBLInvolved) {}

  // TODO(emilio): Rename to use shadow dom terminology.
  bool XBLInvolved() {
    if (mXBLInvolved.isNothing()) {
      mXBLInvolved = Some(ComputeWhetherXBLIsInvolved());
    }
    return *mXBLInvolved;
    return mXBLInvolved;
  }

  const nsIContent* Parent() const { return mOriginalContent; }

 private:
  bool ComputeWhetherXBLIsInvolved() const;

  void Init(bool aIgnoreXBL);

@@ -176,9 +173,7 @@ class FlattenedChildIterator : public ExplicitChildIterator {
 private:
  // For certain optimizations, nsCSSFrameConstructor needs to know if the child
  // list of the element that we're iterating matches its .childNodes.
  //
  // This is lazily computed when asked for it.
  Maybe<bool> mXBLInvolved;
  bool mXBLInvolved = false;
};

/**