Backed out changeset 25462849adcc (bug 502288) to get some talos cycles for the tracemonkey merge without this patch in.
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 03 Aug 2009 15:10:09 -0400
changeset 31082 7fb86c108ae7981111030e5520593c10859d3562
parent 31081 28f03254f3fba3d344afdf9553afc87f0129fb75
child 31083 69f5bc3db4f4d4a1625b0be4eff67d6ccdd81e64
push id8358
push userbzbarsky@mozilla.com
push dateMon, 03 Aug 2009 19:12:58 +0000
treeherdermozilla-central@7fb86c108ae7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs502288
milestone1.9.2a1pre
backs out25462849adcc87648a7fa7fc362b34dd3931a82b
Backed out changeset 25462849adcc (bug 502288) to get some talos cycles for the tracemonkey merge without this patch in.
layout/base/nsCSSFrameConstructor.cpp
layout/base/nsCSSFrameConstructor.h
layout/base/nsChangeHint.h
layout/base/nsFrameManager.cpp
layout/style/nsStyleStruct.cpp
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -7566,53 +7566,42 @@ InvalidateCanvasIfNeeded(nsIPresShell* p
   nsIViewManager::UpdateViewBatch batch(presShell->GetViewManager());
   ApplyRenderingChangeToTree(presShell->GetPresContext(),
                              presShell->GetRootFrame(),
                              nsChangeHint_RepaintFrame);
   batch.EndUpdateViewBatch(NS_VMREFRESH_DEFERRED);
 }
 
 nsresult
-nsCSSFrameConstructor::StyleChangeReflow(nsIFrame* aFrame,
-                                         nsChangeHint aHint)
+nsCSSFrameConstructor::StyleChangeReflow(nsIFrame* aFrame)
 {
   // If the frame hasn't even received an initial reflow, then don't
   // send it a style-change reflow!
   if (aFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW)
     return NS_OK;
 
 #ifdef DEBUG
   if (gNoisyContentUpdates) {
     printf("nsCSSFrameConstructor::StyleChangeReflow: aFrame=");
     nsFrame::ListTag(stdout, aFrame);
     printf("\n");
   }
 #endif
 
-  nsIPresShell::IntrinsicDirty dirtyType;
-  if (aHint & nsChangeHint_ClearDescendantIntrinsics) {
-    NS_ASSERTION(aHint & nsChangeHint_ClearAncestorIntrinsics,
-                 "Please read the comments in nsChangeHint.h");
-    dirtyType = nsIPresShell::eStyleChange;
-  } else if (aHint & nsChangeHint_ClearAncestorIntrinsics) {
-    dirtyType = nsIPresShell::eTreeChange;
-  } else {
-    dirtyType = nsIPresShell::eResize;
-  }
-
-  nsFrameState dirtyBits;
-  if (aHint & nsChangeHint_NeedDirtyReflow) {
-    dirtyBits = NS_FRAME_IS_DIRTY;
-  } else {
-    dirtyBits = NS_FRAME_HAS_DIRTY_CHILDREN;
-  }
+  // If the frame is part of a split block-in-inline hierarchy, then
+  // target the style-change reflow at the first ``normal'' ancestor
+  // so we're sure that the style change will propagate to any
+  // anonymously created siblings.
+  if (IsFrameSpecial(aFrame))
+    aFrame = GetIBContainingBlockFor(aFrame);
 
   do {
-    mPresShell->FrameNeedsReflow(aFrame, dirtyType, dirtyBits);
-    aFrame = nsLayoutUtils::GetNextContinuationOrSpecialSibling(aFrame);
+    mPresShell->FrameNeedsReflow(aFrame, nsIPresShell::eStyleChange,
+                                 NS_FRAME_IS_DIRTY);
+    aFrame = aFrame->GetNextContinuation();
   } while (aFrame);
 
   return NS_OK;
 }
 
 nsresult
 nsCSSFrameConstructor::CharacterDataChanged(nsIContent* aContent,
                                             PRBool aAppend)
@@ -7724,21 +7713,16 @@ nsCSSFrameConstructor::ProcessRestyledFr
   PRBool didInvalidate = PR_FALSE;
   PRBool didReflow = PR_FALSE;
 
   while (0 <= --index) {
     nsIFrame* frame;
     nsIContent* content;
     nsChangeHint hint;
     aChangeList.ChangeAt(index, frame, content, hint);
-
-    NS_ASSERTION(!(hint & nsChangeHint_ReflowFrame) ||
-                 (hint & nsChangeHint_NeedReflow),
-                 "Reflow hint bits set without actually asking for a reflow");
-
     if (frame && frame->GetContent() != content) {
       // XXXbz this is due to image maps messing with the primary frame map.
       // See bug 135040.  Remove this block once that's fixed.
       frame = nsnull;
       if (!(hint & nsChangeHint_ReconstructFrame)) {
         continue;
       }
     }
@@ -7757,18 +7741,18 @@ nsCSSFrameConstructor::ProcessRestyledFr
       RecreateFramesForContent(content, PR_FALSE);
     } else {
       NS_ASSERTION(frame, "This shouldn't happen");
 #ifdef MOZ_SVG
       if (hint & nsChangeHint_UpdateEffects) {
         nsSVGEffects::UpdateEffects(frame);
       }
 #endif
-      if (hint & nsChangeHint_NeedReflow) {
-        StyleChangeReflow(frame, hint);
+      if (hint & nsChangeHint_ReflowFrame) {
+        StyleChangeReflow(frame);
         didReflow = PR_TRUE;
       }
       if (hint & (nsChangeHint_RepaintFrame | nsChangeHint_SyncFrameView)) {
         ApplyRenderingChangeToTree(presContext, frame, hint);
         didInvalidate = PR_TRUE;
       }
       if (hint & nsChangeHint_UpdateCursor) {
         nsIViewManager* viewMgr = mPresShell->GetViewManager();
--- a/layout/base/nsCSSFrameConstructor.h
+++ b/layout/base/nsCSSFrameConstructor.h
@@ -1536,17 +1536,17 @@ private:
                              nsIFrame*                aContainingBlock,
                              nsIFrame*                aFrame,
                              FrameConstructionItemList& aItems,
                              PRBool                   aIsAppend,
                              nsIFrame*                aPrevSibling);
 
   nsresult ReframeContainingBlock(nsIFrame* aFrame);
 
-  nsresult StyleChangeReflow(nsIFrame* aFrame, nsChangeHint aHint);
+  nsresult StyleChangeReflow(nsIFrame* aFrame);
 
   /** Helper function that searches the immediate child frames 
     * (and their children if the frames are "special")
     * for a frame that maps the specified content object
     *
     * @param aParentFrame   the primary frame for aParentContent
     * @param aContent       the content node for which we seek a frame
     * @param aParentContent the parent for aContent 
--- a/layout/base/nsChangeHint.h
+++ b/layout/base/nsChangeHint.h
@@ -40,67 +40,47 @@
 #ifndef nsChangeHint_h___
 #define nsChangeHint_h___
 
 #include "prtypes.h"
 
 // Defines for various style related constants
 
 enum nsChangeHint {
-  // change was visual only (e.g., COLOR=)
-  nsChangeHint_RepaintFrame = 0x01,
-
-  // For reflow, we want flags to give us arbitrary FrameNeedsReflow behavior.
-  // just do a FrameNeedsReflow
-  nsChangeHint_NeedReflow = 0x02,
-
-  // Invalidate intrinsic widths on the frame's ancestors.  Must not be set
-  // without setting nsChangeHint_NeedReflow.
-  nsChangeHint_ClearAncestorIntrinsics = 0x04,
-
-  // Invalidate intrinsic widths on the frame's descendants.  Must not be set
-  // without also setting nsChangeHint_ClearAncestorIntrinsics.
-  nsChangeHint_ClearDescendantIntrinsics = 0x08,
-
-  // Force unconditional reflow of all descendants.  Must not be set without
-  // setting nsChangeHint_NeedReflow, but is independent of both the
-  // Clear*Intrinsics flags.
-  nsChangeHint_NeedDirtyReflow = 0x10,
-
-  // change requires view to be updated, if there is one (e.g., clip:)
-  nsChangeHint_SyncFrameView = 0x20,
-
-  // The currently shown mouse cursor needs to be updated
-  nsChangeHint_UpdateCursor = 0x40,
-
+  nsChangeHint_RepaintFrame = 0x01,  // change was visual only (e.g., COLOR=)
+  nsChangeHint_ReflowFrame = 0x02,   // change requires reflow (e.g., WIDTH=)
+  nsChangeHint_SyncFrameView = 0x04, // change requires view to be updated, if there is one (e.g., clip:)
+  nsChangeHint_UpdateCursor = 0x08,  // The currently shown mouse cursor needs to be updated
   /**
    * SVG filter/mask/clip effects need to be recomputed because the URI
    * in the filter/mask/clip-path property has changed. This wipes
    * out cached nsSVGPropertyBase and subclasses which hold a reference to
    * the element referenced by the URI, and a mutation observer for
    * the DOM subtree rooted at that element. Also, for filters they store a
    * bounding-box for the filter result so that if the filter changes we can
    * invalidate the old covered area.
    */
-  nsChangeHint_UpdateEffects = 0x80,
-
-  // change requires frame change (e.g., display:).
-  // This subsumes all the above.
-  nsChangeHint_ReconstructFrame = 0x100
+  nsChangeHint_UpdateEffects = 0x10,
+  nsChangeHint_ReconstructFrame = 0x20   // change requires frame change (e.g., display:)
+                                         // This subsumes all the above
+  // TBD: add nsChangeHint_ForceFrameView to force frame reconstruction if the frame doesn't yet
+  // have a view
 };
 
+#ifdef DEBUG_roc
 // Redefine these operators to return nothing. This will catch any use
 // of these operators on hints. We should not be using these operators
 // on nsChangeHints
 inline void operator<(nsChangeHint s1, nsChangeHint s2) {}
 inline void operator>(nsChangeHint s1, nsChangeHint s2) {}
 inline void operator!=(nsChangeHint s1, nsChangeHint s2) {}
 inline void operator==(nsChangeHint s1, nsChangeHint s2) {}
 inline void operator<=(nsChangeHint s1, nsChangeHint s2) {}
 inline void operator>=(nsChangeHint s1, nsChangeHint s2) {}
+#endif
 
 // Operators on nsChangeHints
 
 // Merge two hints, taking the union
 inline nsChangeHint NS_CombineHint(nsChangeHint aH1, nsChangeHint aH2) {
   return (nsChangeHint)(aH1 | aH2);
 }
 
@@ -123,26 +103,22 @@ inline PRBool NS_IsHintSubset(nsChangeHi
   return (aSubset & aSuperSet) == aSubset;
 }
 
 // Redefine the old NS_STYLE_HINT constants in terms of the new hint structure
 #define NS_STYLE_HINT_NONE \
   nsChangeHint(0)
 #define NS_STYLE_HINT_VISUAL \
   nsChangeHint(nsChangeHint_RepaintFrame | nsChangeHint_SyncFrameView)
-#define nsChangeHint_ReflowFrame                        \
-  nsChangeHint(nsChangeHint_NeedReflow |                \
-               nsChangeHint_ClearAncestorIntrinsics |   \
-               nsChangeHint_ClearDescendantIntrinsics | \
-               nsChangeHint_NeedDirtyReflow)
 #define NS_STYLE_HINT_REFLOW \
   nsChangeHint(NS_STYLE_HINT_VISUAL | nsChangeHint_ReflowFrame)
 #define NS_STYLE_HINT_FRAMECHANGE \
   nsChangeHint(NS_STYLE_HINT_REFLOW | nsChangeHint_ReconstructFrame)
 
+
 /**
  * |nsReStyleHint| is a bitfield for the result of |HasStateDependentStyle|
  * and |HasAttributeDependentStyle|.  All values have an implied "and
  * descendants."  When no restyling is necessary, use |nsReStyleHint(0)|.
  */
 enum nsReStyleHint {
   eReStyle_Self = 0x1,
   eReStyle_LaterSiblings = 0x2
--- a/layout/base/nsFrameManager.cpp
+++ b/layout/base/nsFrameManager.cpp
@@ -1080,26 +1080,16 @@ CaptureChange(nsStyleContext* aOldContex
 nsChangeHint
 nsFrameManager::ReResolveStyleContext(nsPresContext     *aPresContext,
                                       nsIFrame          *aFrame,
                                       nsIContent        *aParentContent,
                                       nsStyleChangeList *aChangeList, 
                                       nsChangeHint       aMinChange,
                                       PRBool             aFireAccessibilityEvents)
 {
-  // If aMinChange doesn't include nsChangeHint_NeedDirtyReflow, clear out the
-  // nsChangeHint_NeedReflow bit from it, so that we'll make sure to append a
-  // change to the list for ourselves if we need a reflow.  Need this because
-  // the parent may or may not actually end up reflowing us otherwise.  This
-  // works because any reflow hint will include nsChangeHint_NeedReflow, which
-  // will be missing from aMinChange.
-  if (!NS_IsHintSubset(nsChangeHint_NeedDirtyReflow, aMinChange)) {
-    aMinChange = NS_SubtractHint(aMinChange, nsChangeHint_NeedReflow);
-  }
-  
   // It would be nice if we could make stronger assertions here; they
   // would let us simplify the ?: expressions below setting |content|
   // and |pseudoContent| in sensible ways as well as making what
   // |localContent|, |content|, and |pseudoContent| mean make more
   // sense.  However, we can't, because of frame trees like the one in
   // https://bugzilla.mozilla.org/show_bug.cgi?id=472353#c14 .  Once we
   // fix bug 242277 we should be able to make this make more sense.
   NS_ASSERTION(aFrame->GetContent() || !aParentContent ||
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -284,30 +284,24 @@ void nsStyleMargin::RecalcData()
     mHasCachedMargin = PR_FALSE;
 }
 
 nsChangeHint nsStyleMargin::CalcDifference(const nsStyleMargin& aOther) const
 {
   if (mMargin == aOther.mMargin) {
     return NS_STYLE_HINT_NONE;
   }
-  // Margin differences can't affect descendant intrinsic sizes and
-  // don't need to force children to reflow.
-  return NS_SubtractHint(NS_STYLE_HINT_REFLOW,
-                         NS_CombineHint(nsChangeHint_ClearDescendantIntrinsics,
-                                        nsChangeHint_NeedDirtyReflow));
+  return NS_STYLE_HINT_REFLOW;
 }
 
 #ifdef DEBUG
 /* static */
 nsChangeHint nsStyleMargin::MaxDifference()
 {
-  return NS_SubtractHint(NS_STYLE_HINT_REFLOW,
-                         NS_CombineHint(nsChangeHint_ClearDescendantIntrinsics,
-                                        nsChangeHint_NeedDirtyReflow));
+  return NS_STYLE_HINT_REFLOW;
 }
 #endif
 
 nsStylePadding::nsStylePadding() {
   nsStyleCoord zero(0);
   NS_FOR_CSS_SIDES(side) {
     mPadding.Set(side, zero);
   }
@@ -345,30 +339,24 @@ void nsStylePadding::RecalcData()
     mHasCachedPadding = PR_FALSE;
 }
 
 nsChangeHint nsStylePadding::CalcDifference(const nsStylePadding& aOther) const
 {
   if (mPadding == aOther.mPadding) {
     return NS_STYLE_HINT_NONE;
   }
-  // Padding differences can't affect descendant intrinsic sizes and
-  // don't need to force children to reflow.
-  return NS_SubtractHint(NS_STYLE_HINT_REFLOW,
-                         NS_CombineHint(nsChangeHint_ClearDescendantIntrinsics,
-                                        nsChangeHint_NeedDirtyReflow));
+  return NS_STYLE_HINT_REFLOW;
 }
 
 #ifdef DEBUG
 /* static */
 nsChangeHint nsStylePadding::MaxDifference()
 {
-  return NS_SubtractHint(NS_STYLE_HINT_REFLOW,
-                         NS_CombineHint(nsChangeHint_ClearDescendantIntrinsics,
-                                        nsChangeHint_NeedDirtyReflow));
+  return NS_STYLE_HINT_REFLOW;
 }
 #endif
 
 nsStyleBorder::nsStyleBorder(nsPresContext* aPresContext)
   : mHaveBorderImageWidth(PR_FALSE),
     mComputedBorder(0, 0, 0, 0),
     mBorderImage(nsnull)
 {
@@ -466,18 +454,16 @@ nsStyleBorder::Destroy(nsPresContext* aC
 
 nsChangeHint nsStyleBorder::CalcDifference(const nsStyleBorder& aOther) const
 {
   nsChangeHint shadowDifference =
     CalcShadowDifference(mBoxShadow, aOther.mBoxShadow);
 
   // Note that differences in mBorder don't affect rendering (which should only
   // use mComputedBorder), so don't need to be tested for here.
-  // XXXbz we should be able to return a more specific change hint for
-  // at least GetActualBorder() differences...
   if (mTwipsPerPixel != aOther.mTwipsPerPixel ||
       GetActualBorder() != aOther.GetActualBorder() || 
       mFloatEdge != aOther.mFloatEdge ||
       (shadowDifference & nsChangeHint_ReflowFrame))
     return NS_STYLE_HINT_REFLOW;
 
   // Note that mBorderStyle stores not only the border style but also
   // color-related flags.  Given that we've already done an mComputedBorder
@@ -1064,44 +1050,30 @@ nsStylePosition::~nsStylePosition(void)
 nsStylePosition::nsStylePosition(const nsStylePosition& aSource)
 {
   memcpy((nsStylePosition*)this, &aSource, sizeof(nsStylePosition));
 }
 
 nsChangeHint nsStylePosition::CalcDifference(const nsStylePosition& aOther) const
 {
   if (mZIndex != aOther.mZIndex) {
-    // FIXME: Bug 507764.  Why do we need reflow here?
     return NS_STYLE_HINT_REFLOW;
   }
   
-  if ((mWidth == aOther.mWidth) &&
+  if ((mOffset == aOther.mOffset) &&
+      (mWidth == aOther.mWidth) &&
       (mMinWidth == aOther.mMinWidth) &&
       (mMaxWidth == aOther.mMaxWidth) &&
       (mHeight == aOther.mHeight) &&
       (mMinHeight == aOther.mMinHeight) &&
       (mMaxHeight == aOther.mMaxHeight) &&
-      (mBoxSizing == aOther.mBoxSizing)) {
-    if (mOffset == aOther.mOffset) {
-      return NS_STYLE_HINT_NONE;
-    } else {
-      // Offset changes only affect positioned content, and can't affect any
-      // intrinsic widths (except, XXXbz, stacks!  So for now have to clear
-      // ancestor intrinsic widths).  They also don't need to force reflow of
-      // descendants.
-      return NS_CombineHint(nsChangeHint_NeedReflow,
-                            nsChangeHint_ClearAncestorIntrinsics);
-    }
-  }
-
-  // None of our differences can affect descendant intrinsic sizes and none of
-  // them need to force children to reflow.
-  return NS_SubtractHint(nsChangeHint_ReflowFrame,
-                         NS_CombineHint(nsChangeHint_ClearDescendantIntrinsics,
-                                        nsChangeHint_NeedDirtyReflow));
+      (mBoxSizing == aOther.mBoxSizing))
+    return NS_STYLE_HINT_NONE;
+  
+  return nsChangeHint_ReflowFrame;
 }
 
 #ifdef DEBUG
 /* static */
 nsChangeHint nsStylePosition::MaxDifference()
 {
   return NS_STYLE_HINT_REFLOW;
 }
@@ -1602,26 +1574,20 @@ nsChangeHint nsStyleDisplay::CalcDiffere
   if (!EqualURIs(mBinding, aOther.mBinding)
       || mPosition != aOther.mPosition
       || mDisplay != aOther.mDisplay
       || (mFloats == NS_STYLE_FLOAT_NONE) != (aOther.mFloats == NS_STYLE_FLOAT_NONE)
       || mOverflowX != aOther.mOverflowX
       || mOverflowY != aOther.mOverflowY)
     NS_UpdateHint(hint, nsChangeHint_ReconstructFrame);
 
-  if (mFloats != aOther.mFloats) {
-    // Changing which side we float on doesn't affect descendants directly
-    NS_UpdateHint(hint,
-       NS_SubtractHint(nsChangeHint_ReflowFrame,
-                       NS_CombineHint(nsChangeHint_ClearDescendantIntrinsics,
-                                      nsChangeHint_NeedDirtyReflow)));
-  }
+  if (mFloats != aOther.mFloats)
+    NS_UpdateHint(hint, nsChangeHint_ReflowFrame);    
 
   if (mClipFlags != aOther.mClipFlags || mClip != aOther.mClip) {
-    // FIXME: Bug 507764.  Could we use a more precise hint here?
     NS_UpdateHint(hint, nsChangeHint_ReflowFrame);
   }
   // XXX the following is conservative, for now: changing float breaking shouldn't
   // necessarily require a repaint, reflow should suffice.
   if (mBreakType != aOther.mBreakType
       || mBreakBefore != aOther.mBreakBefore
       || mBreakAfter != aOther.mBreakAfter
       || mAppearance != aOther.mAppearance)
@@ -2034,18 +2000,16 @@ nsCSSShadowArray::Release()
     delete this;
     return 0;
   }
   return mRefCnt;
 }
 
 // Allowed to return one of NS_STYLE_HINT_NONE, NS_STYLE_HINT_REFLOW
 // or NS_STYLE_HINT_VISUAL. Currently we just return NONE or REFLOW, though.
-// XXXbz can this not return a more specific hint?  If that's ever
-// changed, nsStyleBorder::CalcDifference will need changing too.
 static nsChangeHint
 CalcShadowDifference(nsCSSShadowArray* lhs,
                      nsCSSShadowArray* rhs)
 {
   if (lhs == rhs)
     return NS_STYLE_HINT_NONE;
 
   if (!lhs || !rhs || lhs->Length() != rhs->Length())