Verified Commit cca5581d authored by David Shin's avatar David Shin Committed by ma1
Browse files

Bug 2045611: a=pascalc DONTBUILD

parent 8a2d0e82
Loading
Loading
Loading
Loading
+21 −4
Original line number Diff line number Diff line
@@ -8258,6 +8258,25 @@ static nsIFrame* FindPreviousNonWhitespaceSibling(nsIFrame* aFrame) {
  return f;
}

static nsIFrame* CheckRubyContainers(nsIFrame* aFrame, nsIFrame* aParent) {
  auto* ancestor = aParent;
  auto* ancestorChild = aFrame;
  while (ancestor && IsWrapperPseudo(ancestor) &&
         CanRemoveWrapperPseudoForChildRemoval(ancestorChild, ancestor)) {
    ancestorChild = ancestor;
    ancestor = ancestorChild->GetParent();
  }
  if (!ancestor) {
    return nullptr;
  }
  const auto ancestorType = ancestor->Type();
  if (ancestorType != LayoutFrameType::Ruby &&
      !RubyUtils::IsRubyContainerBox(ancestorType)) {
    return nullptr;
  }
  return ancestor;
}

bool nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(
    nsIFrame* aFrame) {
#define TRACE(reason)                                                       \
@@ -8368,9 +8387,7 @@ bool nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(
  }

  // Check ruby containers
  LayoutFrameType parentType = parent->Type();
  if (parentType == LayoutFrameType::Ruby ||
      RubyUtils::IsRubyContainerBox(parentType)) {
  if (const auto* ancestor = CheckRubyContainers(inFlowFrame, parent)) {
    // In ruby containers, pseudo frames may be created from
    // whitespaces or even nothing. There are two cases we actually
    // need to handle here, but hard to check exactly:
@@ -8379,7 +8396,7 @@ bool nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(
    // 2. The type of the first child of a ruby frame determines
    //    whether a pseudo ruby base container should exist.
    TRACE("Ruby container");
    RecreateFramesForContent(parent->GetContent(), InsertionKind::Async);
    RecreateFramesForContent(ancestor->GetContent(), InsertionKind::Async);
    return true;
  }