Bug 394120, 'ASSERTION: post-reflow queues not empty' with xul:listboxbody and xul:text, r+sr+a=roc
authorOlli.Pettay@helsinki.fi
Tue, 04 Sep 2007 01:46:50 -0700
changeset 5624 3e59d2a907436d1eae125fd39cd52238c44b2a6d
parent 5623 0314c7ab899b03f1f8286c3a549ffc7a582afbf3
child 5625 eabae7d25ace827f5055ec4d26788c6e4c78a412
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs394120
milestone1.9a8pre
Bug 394120, 'ASSERTION: post-reflow queues not empty' with xul:listboxbody and xul:text, r+sr+a=roc
layout/xul/base/src/nsTextBoxFrame.cpp
layout/xul/base/src/nsTextBoxFrame.h
--- a/layout/xul/base/src/nsTextBoxFrame.cpp
+++ b/layout/xul/base/src/nsTextBoxFrame.cpp
@@ -137,17 +137,18 @@ nsTextBoxFrame::AttributeChanged(PRInt32
     // The old value has been unregistered in nsXULElement::SetAttr
     if (aAttribute == nsGkAtoms::accesskey || aAttribute == nsGkAtoms::control)
         RegUnregAccessKey(PR_TRUE);
 
     return NS_OK;
 }
 
 nsTextBoxFrame::nsTextBoxFrame(nsIPresShell* aShell, nsStyleContext* aContext):
-  nsLeafBoxFrame(aShell, aContext), mCropType(CropRight),mAccessKeyInfo(nsnull)
+  nsLeafBoxFrame(aShell, aContext), mCropType(CropRight), mAccessKeyInfo(nsnull),
+  mNeedsReflowCallback(PR_FALSE)
 {
     mState |= NS_STATE_NEED_LAYOUT;
     MarkIntrinsicWidthsDirty();
 }
 
 nsTextBoxFrame::~nsTextBoxFrame()
 {
     delete mAccessKeyInfo;
@@ -244,17 +245,16 @@ nsTextBoxFrame::UpdateAccesskey(nsWeakFr
         nsCxPusher cx(mContent);
         labelElement->GetAccessKey(accesskey);
         NS_ENSURE_TRUE(aWeakThis.IsAlive(), PR_FALSE);
     }
     else {
         mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::accesskey, accesskey);
     }
 
-    mReflowCallbackPosted = PR_FALSE;
     if (!accesskey.Equals(mAccessKey)) {
         // Need to get clean mTitle.
         mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::value, mTitle);
         mAccessKey = accesskey;
         UpdateAccessTitle();
         PresContext()->PresShell()->
             FrameNeedsReflow(this, nsIPresShell::eStyleChange,
                              NS_FRAME_IS_DIRTY);
@@ -301,25 +301,20 @@ nsTextBoxFrame::UpdateAttributes(nsIAtom
         }
     }
 
     if (aAttribute == nsnull || aAttribute == nsGkAtoms::value) {
         mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::value, mTitle);
         doUpdateTitle = PR_TRUE;
     }
 
-    if (!mReflowCallbackPosted &&
-        (aAttribute == nsnull || aAttribute == nsGkAtoms::accesskey)) {
-        mReflowCallbackPosted = PR_TRUE;
+    if (aAttribute == nsnull || aAttribute == nsGkAtoms::accesskey) {
+        mNeedsReflowCallback = PR_TRUE;
         // Ensure that layout is refreshed and reflow callback called.
         aResize = PR_TRUE;
-        nsIReflowCallback* cb = new nsAsyncAccesskeyUpdate(this);
-        if (cb) {
-            PresContext()->PresShell()->PostReflowCallback(cb);
-        }
     }
 
     if (doUpdateTitle) {
         UpdateAccessTitle();
         aResize = PR_TRUE;
     }
 
 }
@@ -886,16 +881,24 @@ nsTextBoxFrame::UpdateAccessIndex()
                 mAccessKeyInfo->mAccesskeyIndex = kNotFound;
         }
     }
 }
 
 NS_IMETHODIMP
 nsTextBoxFrame::DoLayout(nsBoxLayoutState& aBoxLayoutState)
 {
+    if (mNeedsReflowCallback) {
+        nsIReflowCallback* cb = new nsAsyncAccesskeyUpdate(this);
+        if (cb) {
+            PresContext()->PresShell()->PostReflowCallback(cb);
+        }
+        mNeedsReflowCallback = PR_FALSE;
+    }
+
     mState |= NS_STATE_NEED_LAYOUT;
 
     return nsLeafBoxFrame::DoLayout(aBoxLayoutState);
 }
 
 /* virtual */ void
 nsTextBoxFrame::MarkIntrinsicWidthsDirty()
 {
--- a/layout/xul/base/src/nsTextBoxFrame.h
+++ b/layout/xul/base/src/nsTextBoxFrame.h
@@ -125,17 +125,17 @@ private:
 
   CroppingStyle mCropType;
   nsString mTitle;
   nsString mCroppedTitle;
   nsString mAccessKey;
   nscoord mTitleWidth;
   nsAccessKeyInfo* mAccessKeyInfo;
   PRPackedBool mNeedsRecalc;
-  PRPackedBool mReflowCallbackPosted;
+  PRPackedBool mNeedsReflowCallback;
   nsSize mTextSize;
   nscoord mAscent;
 
   static PRBool gAlwaysAppendAccessKey;
   static PRBool gAccessKeyPrefInitialized;
   static PRBool gInsertSeparatorBeforeAccessKey;
   static PRBool gInsertSeparatorPrefInitialized;