Bug 500467. When removing table rows/rowgroups/cells, don't try to create frames for their adjacent whitespace. We don't need it. r+sr=roc
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 25 Jun 2009 18:12:51 -0400
changeset 29580 ac15a5ef239ec3428e4c87a78e12855a047f5109
parent 29579 c40e6510409e62cafa72f8d9a46abea9019094d2
child 29581 dc227440ba7754d3fb47ef0c2e6257b928ddafa7
push id7722
push userbzbarsky@mozilla.com
push dateThu, 25 Jun 2009 22:13:45 +0000
treeherdermozilla-central@ac15a5ef239e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs500467
milestone1.9.2a1pre
Bug 500467. When removing table rows/rowgroups/cells, don't try to create frames for their adjacent whitespace. We don't need it. r+sr=roc
layout/base/nsCSSFrameConstructor.cpp
layout/base/nsCSSFrameConstructor.h
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -1972,29 +1972,28 @@ IsTablePseudo(nsIFrame* aFrame)
       (aFrame->GetFirstChild(nsnull)->GetStyleContext()->GetPseudoType() ==
          nsCSSAnonBoxes::table ||
        aFrame->GetFirstChild(nsnull)->GetStyleContext()->GetPseudoType() ==
          nsCSSAnonBoxes::inlineTable)));
 }
 
 /* static */
 nsCSSFrameConstructor::ParentType
-nsCSSFrameConstructor::GetParentType(nsIFrame* aParentFrame)
-{
-  nsIAtom* type = aParentFrame->GetType();
-  if (type == nsGkAtoms::tableFrame) {
+nsCSSFrameConstructor::GetParentType(nsIAtom* aFrameType)
+{
+  if (aFrameType == nsGkAtoms::tableFrame) {
     return eTypeTable;
   }
-  if (type == nsGkAtoms::tableRowGroupFrame) {
+  if (aFrameType == nsGkAtoms::tableRowGroupFrame) {
     return eTypeRowGroup;
   }
-  if (type == nsGkAtoms::tableRowFrame) {
+  if (aFrameType == nsGkAtoms::tableRowFrame) {
     return eTypeRow;
   }
-  if (type == nsGkAtoms::tableColGroupFrame) {
+  if (aFrameType == nsGkAtoms::tableColGroupFrame) {
     return eTypeColGroup;
   }
 
   return eTypeBlock;
 }
            
 static nsIFrame*
 AdjustCaptionParentFrame(nsIFrame* aParentFrame) 
@@ -7265,16 +7264,17 @@ nsCSSFrameConstructor::ContentRemoved(ns
       childFrame = mPresShell->GetPrimaryFrameFor(aChild);
       if (!childFrame || childFrame->GetContent() != aChild) {
         // XXXbz the GetContent() != aChild check is needed due to bug 135040.
         // Remove it once that's fixed.
         frameManager->ClearUndisplayedContentIn(aChild, aContainer);
         return NS_OK;
       }
       parentFrame = childFrame->GetParent();
+      parentType = parentFrame->GetType();
 
 #ifdef NOISY_FIRST_LETTER
       printf("  ==> revised parentFrame=");
       nsFrame::ListTag(stdout, parentFrame);
       printf(" childFrame=");
       nsFrame::ListTag(stdout, childFrame);
       printf("\n");
 #endif
@@ -7348,19 +7348,23 @@ nsCSSFrameConstructor::ContentRemoved(ns
       nsFrameConstructorState state(mPresShell, mFixedContainingBlock,
                                     GetAbsoluteContainingBlock(parentFrame),
                                     containingBlock);
       RecoverLetterFrames(containingBlock);
     }
 
     // If we're just reconstructing frames for the element, then the
     // following ContentInserted notification on the element will
-    // take care of fixing up any adjacent text nodes.
+    // take care of fixing up any adjacent text nodes.  We don't need
+    // to do this if the table parent type of our parent type is not
+    // eTypeBlock, though, because in that case the whitespace isn't
+    // being suppressed due to us anyway.
     if (aContainer && aIndexInContainer >= 0 &&
-        aFlags != REMOVE_FOR_RECONSTRUCTION) {
+        aFlags != REMOVE_FOR_RECONSTRUCTION &&
+        GetParentType(parentType) == eTypeBlock) {
       // Adjacent whitespace-only text nodes might have been suppressed if
       // this node does not have inline ends. Create frames for them now
       // if necessary.
       PRInt32 childCount = aContainer->GetChildCount();
       // Reframe any text node just before the node being removed, if there is
       // one, and if it's not the last child or the first child. If a whitespace
       // textframe was being suppressed and it's now the last child or first
       // child then it can stay suppressed since the parent must be a block
--- a/layout/base/nsCSSFrameConstructor.h
+++ b/layout/base/nsCSSFrameConstructor.h
@@ -465,17 +465,22 @@ private:
      FrameConstructionData */
 #define FCDATA_DESIRED_PARENT_TYPE(_bits)           \
   ParentType((_bits) >> FCDATA_PARENT_TYPE_OFFSET)
   /* Macro to create FrameConstructionData bits out of a desired parent type */
 #define FCDATA_DESIRED_PARENT_TYPE_TO_BITS(_type)     \
   (((PRUint32)(_type)) << FCDATA_PARENT_TYPE_OFFSET)
 
   /* Get the parent type that aParentFrame has. */
-  static ParentType GetParentType(nsIFrame* aParentFrame);
+  static ParentType GetParentType(nsIFrame* aParentFrame) {
+    return GetParentType(aParentFrame->GetType());
+  }
+
+  /* Get the parent type for the given nsIFrame type atom */
+  static ParentType GetParentType(nsIAtom* aFrameType);
 
   /* A constructor function that just creates an nsIFrame object.  The caller
      is responsible for initializing the object, adding it to frame lists,
      constructing frames for the children, etc.
 
      @param nsIPresShell the presshell whose arena should be used to allocate
                          the frame.
      @param nsStyleContext the style context to use for the frame. */