bug 258377 remove inline on PeekStyleData so that it can be called from the layout library r/sr=bzbarsky
authorBernd <bmlk@gmx.de>
Sat, 01 Nov 2008 09:52:29 +0100
changeset 21170 4f1383af8f100bbd44ae15d2b946be72f25ce5ad
parent 21169 7684dee590b95fca04e360d5245ae34b77dac22c
child 21171 f7b380c79f8d0734dc1862c31fa414c2953a7217
push id3375
push userbmlk@gmx.de
push dateSat, 01 Nov 2008 08:56:13 +0000
treeherdermozilla-central@4f1383af8f10 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs258377
milestone1.9.1b2pre
bug 258377 remove inline on PeekStyleData so that it can be called from the layout library r/sr=bzbarsky
layout/style/nsStyleContext.cpp
layout/tables/nsTableFrame.cpp
--- a/layout/style/nsStyleContext.cpp
+++ b/layout/style/nsStyleContext.cpp
@@ -230,17 +230,17 @@ const void* nsStyleContext::GetStyleData
       return cachedData; /* We have computed data stored on this node */    \
                          /* in the context tree. */                         \
     /* Else our rule node will take care of it for us. */                   \
     return mRuleNode->GetStyle##name_(this, PR_TRUE);                       \
   }
 #include "nsStyleStructList.h"
 #undef STYLE_STRUCT
 
-inline const void* nsStyleContext::PeekStyleData(nsStyleStructID aSID)
+const void* nsStyleContext::PeekStyleData(nsStyleStructID aSID)
 {
   const void* cachedData = mCachedStyleData.GetStyleData(aSID); 
   if (cachedData)
     return cachedData; // We have computed data stored on this node in the context tree.
   return mRuleNode->GetStyleData(aSID, this, PR_FALSE); // Our rule node will take care of it for us.
 }
 
 // This is an evil evil function, since it forces you to alloc your own separate copy of
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -270,17 +270,16 @@ nsTableFrame::~nsTableFrame()
 
 void
 nsTableFrame::Destroy()
 {
   mColGroups.DestroyFrames();
   nsHTMLContainerFrame::Destroy();
 }
 
-
 // Make sure any views are positioned properly
 void
 nsTableFrame::RePositionViews(nsIFrame* aFrame)
 {
   nsContainerFrame::PositionFrameView(aFrame);
   nsContainerFrame::PositionChildViews(aFrame);
 }
 
@@ -2222,18 +2221,17 @@ nsTableFrame::GetCollapsedWidth(nsMargin
             width += cellSpacingX;
         }
       }
     }
   }
   return width;
 }
 
-
-   /* virtual */ void
+/* virtual */ void
 nsTableFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
 {
    if (!aOldStyleContext) //avoid this on init
      return;
    
    if (IsBorderCollapse() &&
        BCRecalcNeeded(aOldStyleContext, GetStyleContext())) {
      nsRect damageArea(0, 0, GetColCount(), GetRowCount());
@@ -4693,33 +4691,57 @@ GetColorAndStyle(const nsIFrame*  aFrame
 class nsDelayedCalcBCBorders : public nsRunnable {
 public:
   nsDelayedCalcBCBorders(nsIFrame* aFrame) :
     mFrame(aFrame) {}
 
   NS_IMETHOD Run() {
     if (mFrame) {
       nsTableFrame* tableFrame = static_cast <nsTableFrame*>(mFrame.GetFrame());
-      if (tableFrame) {
-        if (tableFrame->NeedToCalcBCBorders()) {
-          tableFrame->CalcBCBorders();
-        }
+      if (tableFrame->NeedToCalcBCBorders()) {
+        tableFrame->CalcBCBorders();
       }
     }
     return NS_OK;
   }
 private:
   nsWeakFrame mFrame;
 };
   
 PRBool
 nsTableFrame::BCRecalcNeeded(nsStyleContext* aOldStyleContext,
                              nsStyleContext* aNewStyleContext)
 {
-  // XXX bernd temp disabled till I figure out the mac failure
+  // Attention: the old style context is the one we're forgetting,
+  // and hence possibly completely bogus for GetStyle* purposes.
+  // We use PeekStyleData instead.
+
+  const nsStyleBorder* oldStyleData = static_cast<const nsStyleBorder*>
+                        (aOldStyleContext->PeekStyleData(eStyleStruct_Border));
+  if (!oldStyleData)
+    return PR_FALSE;
+
+  const nsStyleBorder* newStyleData = aNewStyleContext->GetStyleBorder();
+  nsChangeHint change = newStyleData->CalcDifference(*oldStyleData);
+  if (change == NS_STYLE_HINT_NONE)
+    return PR_FALSE;
+  if ((change & NS_STYLE_HINT_REFLOW) == NS_STYLE_HINT_REFLOW)
+    return PR_TRUE; // the caller only needs to mark the bc damage area
+  if ((change & NS_STYLE_HINT_VISUAL) == NS_STYLE_HINT_VISUAL) {
+    NS_FOR_CSS_SIDES(side) {
+      if (newStyleData->GetBorderStyle(side) !=
+          oldStyleData->GetBorderStyle(side)) {
+        // we need to recompute the borders and the caller needs to mark
+        // the bc damage area
+        nsCOMPtr<nsIRunnable> evt = new nsDelayedCalcBCBorders(this);
+        NS_DispatchToCurrentThread(evt);
+        return PR_TRUE;
+      }
+    }
+  }
   return PR_FALSE;
 }
 
 /* BCCellBorder represents a border segment which can be either a horizontal
  * or a vertical segment. For each segment we need to know the color, width,
  * style, who owns it and how long it is in cellmap coordinates.
  * Ownership of these segments is  important to calculate which corners should
  * be bevelled. This structure has dual use, its used first to compute the