diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index c3eeb026050d..8db768db7feb 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -419,13 +419,19 @@ GetIBContainingBlockFor(nsIFrame* aFrame) nsIFrame* parentFrame; do { aFrame->GetParent(&parentFrame); - if (!parentFrame || !IsFrameSpecial(parentFrame)) + + if (! parentFrame) { + NS_ERROR("no unsplit block frame in IB hierarchy"); + return aFrame; + } + + if (!IsFrameSpecial(parentFrame)) break; aFrame = parentFrame; } while (1); - return aFrame; + return parentFrame; } //---------------------------------------------------------------------- @@ -8605,6 +8611,17 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, nsLayoutAtoms::fixedList, state.mFixedItems.childList); } + +#ifdef DEBUG + if (gReallyNoisyContentUpdates && docElementFrame) { + nsIFrameDebug* fdbg = nsnull; + CallQueryInterface(docElementFrame, &fdbg); + if (fdbg) { + printf("nsCSSFrameConstructor::ContentInserted: resulting frame model:\n"); + fdbg->List(aPresContext, stdout, 0); + } + } +#endif } nsCOMPtr bm; @@ -9904,9 +9921,9 @@ nsCSSFrameConstructor::StyleChangeReflow(nsIPresContext* aPresContext, nsCOMPtr shell; aPresContext->GetShell(getter_AddRefs(shell)); - nsCOMPtr reflowCmd; - rv = NS_NewHTMLReflowCommand(getter_AddRefs(reflowCmd), aFrame, - nsIReflowCommand::StyleChanged, + nsHTMLReflowCommand *reflowCmd; + rv = NS_NewHTMLReflowCommand(&reflowCmd, aFrame, + eReflowType_StyleChanged, nsnull, aAttribute); @@ -13461,6 +13478,12 @@ nsCSSFrameConstructor::WipeContainingBlock(nsIPresContext* aPresContext, aFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&) parentDisplay); if (NS_STYLE_DISPLAY_INLINE == parentDisplay->mDisplay) { if (!AreAllKidsInline(aFrameList)) { + // XXXwaterson temporary code until we figure out why bug 102931 + // is really happening. + NS_ASSERTION(aBlockContent != nsnull, "ack, inline without a containing block"); + if (! aBlockContent) + return PR_FALSE; + // Ok, reverse tracks: wipe out the frames we just created nsCOMPtr presShell; nsCOMPtr frameManager; diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index 886f25635f95..baf2f49d259a 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -39,9 +39,10 @@ #include "nsISupports.h" #include "nsCoord.h" -#include "nsIReflowCommand.h" #include "nsEvent.h" +#include "nsReflowType.h" +class nsIAtom; class nsIContent; class nsIContentIterator; class nsIDocument; @@ -64,6 +65,7 @@ class nsIArena; class nsIReflowCallback; class nsISupportsArray; class nsIDOMNode; +class nsHTMLReflowCommand; #define NS_IPRESSHELL_IID \ { 0x76e79c60, 0x944e, 0x11d1, \ @@ -287,8 +289,8 @@ public: /** * Reflow commands */ - NS_IMETHOD AppendReflowCommand(nsIReflowCommand* aReflowCommand) = 0; - NS_IMETHOD CancelReflowCommand(nsIFrame* aTargetFrame, nsIReflowCommand::ReflowType* aCmdType) = 0; + NS_IMETHOD AppendReflowCommand(nsHTMLReflowCommand* aReflowCommand) = 0; + NS_IMETHOD CancelReflowCommand(nsIFrame* aTargetFrame, nsReflowType* aCmdType) = 0; NS_IMETHOD CancelAllReflowCommands() = 0; diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 3d162197baae..0615af3a31b8 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -49,7 +49,7 @@ #include "nsINameSpaceManager.h" // for Pref-related rule management (bugs 22963,20760,31816) #include "nsIServiceManager.h" #include "nsFrame.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIViewManager.h" #include "nsCRT.h" #include "prlog.h" @@ -876,15 +876,15 @@ public: nsIContent** aContent) const; NS_IMETHOD GetPlaceholderFrameFor(nsIFrame* aFrame, nsIFrame** aPlaceholderFrame) const; - NS_IMETHOD AppendReflowCommand(nsIReflowCommand* aReflowCommand); - NS_IMETHOD AppendReflowCommandInternal(nsIReflowCommand* aReflowCommand, - nsVoidArray& aQueue); + NS_IMETHOD AppendReflowCommand(nsHTMLReflowCommand* aReflowCommand); + NS_IMETHOD AppendReflowCommandInternal(nsHTMLReflowCommand* aReflowCommand, + nsVoidArray& aQueue); NS_IMETHOD CancelReflowCommand(nsIFrame* aTargetFrame, - nsIReflowCommand::ReflowType* aCmdType); - NS_IMETHOD CancelReflowCommandInternal(nsIFrame* aTargetFrame, - nsIReflowCommand::ReflowType* aCmdType, - nsVoidArray& aQueue, - PRBool aProcessDummyLayoutRequest = PR_TRUE); + nsReflowType* aCmdType); + NS_IMETHOD CancelReflowCommandInternal(nsIFrame* aTargetFrame, + nsReflowType* aCmdType, + nsVoidArray& aQueue, + PRBool aProcessDummyLayoutRequest = PR_TRUE); NS_IMETHOD CancelAllReflowCommands(); NS_IMETHOD IsSafeToFlush(PRBool& aIsSafeToFlush); NS_IMETHOD FlushPendingNotifications(PRBool aUpdateViews); @@ -1092,8 +1092,8 @@ protected: */ nsresult NotifyReflowObservers(const char *aData); - nsresult ReflowCommandAdded(nsIReflowCommand* aRC); - nsresult ReflowCommandRemoved(nsIReflowCommand* aRC); + nsresult ReflowCommandAdded(nsHTMLReflowCommand* aRC); + nsresult ReflowCommandRemoved(nsHTMLReflowCommand* aRC); // This method should be called after a reflow commands have been // removed from the queue, but after the state in the presshell is @@ -1118,8 +1118,8 @@ protected: nsresult GetReflowEventStatus(PRBool* aPending); nsresult SetReflowEventStatus(PRBool aPending); void PostReflowEvent(); - PRBool AlreadyInQueue(nsIReflowCommand* aReflowCommand, - nsVoidArray& aQueue); + PRBool AlreadyInQueue(nsHTMLReflowCommand* aReflowCommand, + nsVoidArray& aQueue); friend struct ReflowEvent; // utility to determine if we're in the middle of a drag @@ -3526,8 +3526,8 @@ PresShell::EndReflow(nsIDocument *aDocument, nsIPresShell* aShell) // frame it targets is targeted by a pre-existing reflow command in // the queue. PRBool -PresShell::AlreadyInQueue(nsIReflowCommand* aReflowCommand, - nsVoidArray& aQueue) +PresShell::AlreadyInQueue(nsHTMLReflowCommand* aReflowCommand, + nsVoidArray& aQueue) { PRInt32 i, n = aQueue.Count(); nsIFrame* targetFrame; @@ -3536,12 +3536,12 @@ PresShell::AlreadyInQueue(nsIReflowCommand* aReflowCommand, if (NS_SUCCEEDED(aReflowCommand->GetTarget(targetFrame))) { // Iterate over the reflow commands and compare the targeted frames. for (i = 0; i < n; i++) { - nsIReflowCommand* rc = (nsIReflowCommand*) aQueue.ElementAt(i); + nsHTMLReflowCommand* rc = (nsHTMLReflowCommand*) aQueue.ElementAt(i); if (rc) { nsIFrame* targetOfQueuedRC; if (NS_SUCCEEDED(rc->GetTarget(targetOfQueuedRC))) { - nsIReflowCommand::ReflowType RCType; - nsIReflowCommand::ReflowType queuedRCType; + nsReflowType RCType; + nsReflowType queuedRCType; aReflowCommand->GetType(RCType); rc->GetType(queuedRCType); if (targetFrame == targetOfQueuedRC && @@ -3564,9 +3564,9 @@ PresShell::AlreadyInQueue(nsIReflowCommand* aReflowCommand, } void -NotifyAncestorFramesOfReflowCommand(nsIPresShell* aPresShell, - nsIReflowCommand* aRC, - PRBool aCommandAdded) +NotifyAncestorFramesOfReflowCommand(nsIPresShell* aPresShell, + nsHTMLReflowCommand* aRC, + PRBool aCommandAdded) { if (aRC) { nsIFrame* target; @@ -3583,8 +3583,8 @@ NotifyAncestorFramesOfReflowCommand(nsIPresShell* aPresShell, } NS_IMETHODIMP -PresShell::AppendReflowCommandInternal(nsIReflowCommand* aReflowCommand, - nsVoidArray& aQueue) +PresShell::AppendReflowCommandInternal(nsHTMLReflowCommand* aReflowCommand, + nsVoidArray& aQueue) { // If we've not yet done the initial reflow, then don't bother // enqueuing a reflow command yet. @@ -3616,11 +3616,14 @@ PresShell::AppendReflowCommandInternal(nsIReflowCommand* aReflowCommand, // who call SendInterruptNotificationTo to make sure there are no duplicates if ((&aQueue == &mTimeoutReflowCommands) || ((&aQueue == &mReflowCommands) && !AlreadyInQueue(aReflowCommand, aQueue))) { - NS_ADDREF(aReflowCommand); rv = (aQueue.AppendElement(aReflowCommand) ? NS_OK : NS_ERROR_OUT_OF_MEMORY); ReflowCommandAdded(aReflowCommand); NotifyAncestorFramesOfReflowCommand(this, aReflowCommand, PR_TRUE); } + else { + // We're not going to process this reflow command. + delete aReflowCommand; + } // For async reflow during doc load, post a reflow event if we are not batching reflow commands. // For sync reflow during doc load, post a reflow event if we are not batching reflow commands @@ -3637,7 +3640,7 @@ PresShell::AppendReflowCommandInternal(nsIReflowCommand* aReflowCommand, } NS_IMETHODIMP -PresShell::AppendReflowCommand(nsIReflowCommand* aReflowCommand) +PresShell::AppendReflowCommand(nsHTMLReflowCommand* aReflowCommand) { return AppendReflowCommandInternal(aReflowCommand, mReflowCommands); } @@ -3665,14 +3668,14 @@ PresShell :: IsDragInProgress ( ) const NS_IMETHODIMP -PresShell::CancelReflowCommandInternal(nsIFrame* aTargetFrame, - nsIReflowCommand::ReflowType* aCmdType, - nsVoidArray& aQueue, - PRBool aProcessDummyLayoutRequest) +PresShell::CancelReflowCommandInternal(nsIFrame* aTargetFrame, + nsReflowType* aCmdType, + nsVoidArray& aQueue, + PRBool aProcessDummyLayoutRequest) { PRInt32 i, n = aQueue.Count(); for (i = 0; i < n; i++) { - nsIReflowCommand* rc = (nsIReflowCommand*) aQueue.ElementAt(i); + nsHTMLReflowCommand* rc = (nsHTMLReflowCommand*) aQueue.ElementAt(i); if (rc) { nsIFrame* target; if (NS_SUCCEEDED(rc->GetTarget(target))) { @@ -3680,7 +3683,7 @@ PresShell::CancelReflowCommandInternal(nsIFrame* aTargetFram if (aCmdType != NULL) { // If aCmdType is specified, only remove reflow commands // of that type - nsIReflowCommand::ReflowType type; + nsReflowType type; if (NS_SUCCEEDED(rc->GetType(type))) { if (type != *aCmdType) continue; @@ -3696,7 +3699,7 @@ PresShell::CancelReflowCommandInternal(nsIFrame* aTargetFram aQueue.RemoveElementAt(i); ReflowCommandRemoved(rc); NotifyAncestorFramesOfReflowCommand(this, rc, PR_FALSE); - NS_RELEASE(rc); + delete rc; n--; i--; continue; @@ -3713,8 +3716,8 @@ PresShell::CancelReflowCommandInternal(nsIFrame* aTargetFram } NS_IMETHODIMP -PresShell::CancelReflowCommand(nsIFrame* aTargetFrame, - nsIReflowCommand::ReflowType* aCmdType) +PresShell::CancelReflowCommand(nsIFrame* aTargetFrame, + nsReflowType* aCmdType) { return CancelReflowCommandInternal(aTargetFrame, aCmdType, mReflowCommands); } @@ -3724,21 +3727,21 @@ NS_IMETHODIMP PresShell::CancelAllReflowCommands() { PRInt32 n = mReflowCommands.Count(); - nsIReflowCommand* rc; + nsHTMLReflowCommand* rc; PRInt32 i; for (i = 0; i < n; i++) { - rc = NS_STATIC_CAST(nsIReflowCommand*, mReflowCommands.ElementAt(0)); + rc = NS_STATIC_CAST(nsHTMLReflowCommand*, mReflowCommands.ElementAt(0)); mReflowCommands.RemoveElementAt(0); ReflowCommandRemoved(rc); - NS_RELEASE(rc); + delete rc; } n = mTimeoutReflowCommands.Count(); for (i = 0; i < n; i++) { - rc = NS_STATIC_CAST(nsIReflowCommand*, mTimeoutReflowCommands.ElementAt(0)); + rc = NS_STATIC_CAST(nsHTMLReflowCommand*, mTimeoutReflowCommands.ElementAt(0)); mTimeoutReflowCommands.RemoveElementAt(0); ReflowCommandRemoved(rc); - NS_RELEASE(rc); + delete rc; } DoneRemovingReflowCommands(); @@ -6043,7 +6046,7 @@ PresShell::ProcessReflowCommand(nsVoidArray& aQueue, { // Use RemoveElementAt in case the reflowcommand dispatches a // new one during its execution. - nsIReflowCommand* rc = (nsIReflowCommand*)aQueue.ElementAt(0); + nsHTMLReflowCommand* rc = (nsHTMLReflowCommand*)aQueue.ElementAt(0); aQueue.RemoveElementAt(0); // Dispatch the reflow command @@ -6055,7 +6058,7 @@ PresShell::ProcessReflowCommand(nsVoidArray& aQueue, afterReflow = PR_Now(); ReflowCommandRemoved(rc); - NS_RELEASE(rc); + delete rc; VERIFY_STYLE_TREE; if (aAccumulateTime) { @@ -6095,7 +6098,7 @@ PresShell::ProcessReflowCommands(PRBool aInterruptible) PRInt32 i, n = mReflowCommands.Count(); printf("\nPresShell::ProcessReflowCommands: this=%p, count=%d\n", (void*)this, n); for (i = 0; i < n; i++) { - nsIReflowCommand* rc = (nsIReflowCommand*) + nsHTMLReflowCommand* rc = (nsHTMLReflowCommand*) mReflowCommands.ElementAt(i); rc->List(stdout); } @@ -6200,16 +6203,15 @@ PresShell::SendInterruptNotificationTo(nsIFrame* aFrame, nsIPresShell::InterruptType aInterruptType) { // create a reflow command targeted at aFrame - nsIReflowCommand* reflowCmd; + nsHTMLReflowCommand* reflowCmd; nsresult rv; // Target the reflow comamnd at aFrame rv = NS_NewHTMLReflowCommand(&reflowCmd, aFrame, - nsIReflowCommand::Timeout); + eReflowType_Timeout); if (NS_SUCCEEDED(rv)) { // Add the reflow command AppendReflowCommandInternal(reflowCmd, mTimeoutReflowCommands); - NS_RELEASE(reflowCmd); } return rv; } @@ -6293,7 +6295,7 @@ PresShell::CloneStyleSet(nsIStyleSet* aSet, nsIStyleSet** aResult) nsresult -PresShell::ReflowCommandAdded(nsIReflowCommand* aRC) +PresShell::ReflowCommandAdded(nsHTMLReflowCommand* aRC) { if (gAsyncReflowDuringDocLoad) { @@ -6333,7 +6335,7 @@ PresShell::ReflowCommandAdded(nsIReflowCommand* aRC) } nsresult -PresShell::ReflowCommandRemoved(nsIReflowCommand* aRC) +PresShell::ReflowCommandRemoved(nsHTMLReflowCommand* aRC) { if (gAsyncReflowDuringDocLoad) { NS_PRECONDITION(mRCCreatedDuringLoad >= 0, "PresShell's reflow command queue is in a bad state."); @@ -7505,7 +7507,6 @@ static void RecurseIndiTotals(nsIPresContext* aPresContext, //------------------------------------------------------------------ PRIntn ReflowCountMgr::DoSingleIndi(PLHashEntry *he, PRIntn i, void *arg) { - char *str = (char *)he->key; IndiReflowCounter * counter = (IndiReflowCounter *)he->value; if (counter && !counter->mHasBeenOutput) { char * name = ToNewCString(counter->mName); diff --git a/layout/base/public/MANIFEST b/layout/base/public/MANIFEST index bd2d296ee0b2..9af757b9ddb2 100644 --- a/layout/base/public/MANIFEST +++ b/layout/base/public/MANIFEST @@ -29,7 +29,6 @@ nsIPresState.h nsIPrintContext.h nsIPrintPreviewContext.h nsIReflowCallback.h -nsIReflowCommand.h nsIScrollableFrame.h nsIScrollableViewProvider.h nsIStatefulFrame.h @@ -37,5 +36,6 @@ nsIStyleContext.h nsIStyleFrameConstruction.h nsIStyleSet.h nsITextFrame.h +nsReflowType.h nsStyleChangeList.h nsStyleConsts.h diff --git a/layout/base/public/Makefile.in b/layout/base/public/Makefile.in index 8532dddbb0f3..8db7631ecb85 100644 --- a/layout/base/public/Makefile.in +++ b/layout/base/public/Makefile.in @@ -58,13 +58,13 @@ nsIPresState.h \ nsIPrintContext.h \ nsIPrintPreviewContext.h \ nsIReflowCallback.h \ -nsIReflowCommand.h \ nsIScrollableFrame.h \ nsIScrollableViewProvider.h \ nsIStatefulFrame.h \ nsIStyleContext.h \ nsIStyleFrameConstruction.h \ nsIStyleSet.h \ +nsReflowType.h \ nsStyleChangeList.h \ nsStyleConsts.h \ $(NULL) diff --git a/layout/base/public/makefile.win b/layout/base/public/makefile.win index f6264df88cb4..9fad95f9c2c3 100644 --- a/layout/base/public/makefile.win +++ b/layout/base/public/makefile.win @@ -53,13 +53,13 @@ EXPORTS = \ nsIPrintContext.h \ nsIPrintPreviewContext.h \ nsIReflowCallback.h \ - nsIReflowCommand.h \ nsIScrollableFrame.h \ nsIScrollableViewProvider.h \ nsIStatefulFrame.h \ nsIStyleContext.h \ nsIStyleFrameConstruction.h \ nsIStyleSet.h \ + nsReflowType.h \ nsStyleChangeList.h \ nsStyleConsts.h \ !ifdef IBMBIDI diff --git a/layout/base/public/nsHTMLReflowState.h b/layout/base/public/nsHTMLReflowState.h index 9f722c52e4fc..e3b27df7c2d1 100644 --- a/layout/base/public/nsHTMLReflowState.h +++ b/layout/base/public/nsHTMLReflowState.h @@ -42,7 +42,7 @@ class nsIFrame; class nsIPresContext; -class nsIReflowCommand; +class nsHTMLReflowCommand; class nsIRenderingContext; class nsSpaceManager; class nsLineLayout; @@ -140,7 +140,7 @@ struct nsHTMLReflowState { nsReflowReason reason; // the reflow command. only set for a reflow reason of eReflowReason_Incremental - nsIReflowCommand* reflowCommand; + nsHTMLReflowCommand* reflowCommand; // the available space in which to reflow the frame. The space represents the // amount of room for the frame's border, padding, and content area (not the @@ -264,7 +264,7 @@ struct nsHTMLReflowState { // reflow. nsHTMLReflowState(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIReflowCommand& aReflowCommand, + nsHTMLReflowCommand& aReflowCommand, nsIRenderingContext* aRenderingContext, const nsSize& aAvailableSpace); diff --git a/layout/base/public/nsIFrame.h b/layout/base/public/nsIFrame.h index 2eb7b275e008..aa128ea4cfa2 100644 --- a/layout/base/public/nsIFrame.h +++ b/layout/base/public/nsIFrame.h @@ -68,7 +68,7 @@ */ struct nsHTMLReflowState; -class nsIReflowCommand; +class nsHTMLReflowCommand; struct nsHTMLReflowMetrics; class nsIAtom; @@ -1059,7 +1059,7 @@ public: /** * Called by a child frame on a parent frame to tell the parent frame that the child needs * to be reflowed. The parent should either propagate the request to its parent frame or - * handle the request by generating a nsIReflowCommand::ReflowDirtyChildren reflow command. + * handle the request by generating a eReflowType_ReflowDirtyChildren reflow command. */ NS_IMETHOD ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild) = 0; @@ -1079,9 +1079,9 @@ public: * Called during appending or cancelling a reflow command to give frames notice * of reflow commands that will be targeted below them. */ - NS_IMETHOD ReflowCommandNotify(nsIPresShell* aShell, - nsIReflowCommand* aRC, - PRBool aCommandAdded) = 0; + NS_IMETHOD ReflowCommandNotify(nsIPresShell* aShell, + nsHTMLReflowCommand* aRC, + PRBool aCommandAdded) = 0; /** * Called in style ReResolution to get the frame that contains the style context that is the diff --git a/layout/base/public/nsIPresShell.h b/layout/base/public/nsIPresShell.h index 886f25635f95..baf2f49d259a 100644 --- a/layout/base/public/nsIPresShell.h +++ b/layout/base/public/nsIPresShell.h @@ -39,9 +39,10 @@ #include "nsISupports.h" #include "nsCoord.h" -#include "nsIReflowCommand.h" #include "nsEvent.h" +#include "nsReflowType.h" +class nsIAtom; class nsIContent; class nsIContentIterator; class nsIDocument; @@ -64,6 +65,7 @@ class nsIArena; class nsIReflowCallback; class nsISupportsArray; class nsIDOMNode; +class nsHTMLReflowCommand; #define NS_IPRESSHELL_IID \ { 0x76e79c60, 0x944e, 0x11d1, \ @@ -287,8 +289,8 @@ public: /** * Reflow commands */ - NS_IMETHOD AppendReflowCommand(nsIReflowCommand* aReflowCommand) = 0; - NS_IMETHOD CancelReflowCommand(nsIFrame* aTargetFrame, nsIReflowCommand::ReflowType* aCmdType) = 0; + NS_IMETHOD AppendReflowCommand(nsHTMLReflowCommand* aReflowCommand) = 0; + NS_IMETHOD CancelReflowCommand(nsIFrame* aTargetFrame, nsReflowType* aCmdType) = 0; NS_IMETHOD CancelAllReflowCommands() = 0; diff --git a/layout/base/public/nsIReflowCommand.h b/layout/base/public/nsIReflowCommand.h deleted file mode 100644 index 28d1d6ddd4ba..000000000000 --- a/layout/base/public/nsIReflowCommand.h +++ /dev/null @@ -1,183 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef nsIReflowCommand_h___ -#define nsIReflowCommand_h___ - -#include "nsISupports.h" -#include - -class nsIAtom; -class nsIFrame; -class nsIPresContext; -class nsIRenderingContext; -struct nsHTMLReflowMetrics; -struct nsSize; - -// IID for the nsIReflowCommand interface {C3658E40-FF20-11d1-85BC-00A02468FAB6} -#define NS_IREFLOWCOMMAND_IID \ -{ 0xc3658e40, 0xff20, 0x11d1, \ - {0x85, 0xbc, 0x0, 0xa0, 0x24, 0x68, 0xfa, 0xb6}} - -// Reflow command flags -#define NS_RC_CREATED_DURING_DOCUMENT_LOAD 0x0001 - -/** - * A reflow command is an object that is generated in response to a content - * model change notification. The reflow command is given to a presentation - * shell where it is queued and then dispatched by invoking the reflow - * commands's Dispatch() member function. - * - * Reflow command processing follows a path from the root frame down to the - * target frame (the frame for which the reflow command is destined). Reflow - * commands are processed by invoking the frame's Reflow() member function. - * - * The typical flow of control for a given reflow command starts with a content - * change notification. The content notifications are sent to document observers. - * The presentation shell forwards the notifications to the style set. The style - * system responds to the notifications by creating new frame (or destroying - * existing frames) as appropriate, and then generating a reflow command. - * - * @see nsIDocumentObserver - * @see nsIStyleSet - * @see nsIFrameReflow#Reflow() - * @see nsIPresShell#AppendReflowCommand() - * @see nsIPresShell#ProcessReflowCommands() - */ -class nsIReflowCommand : public nsISupports { -public: - static const nsIID& GetIID() { static nsIID iid = NS_IREFLOWCOMMAND_IID; return iid; } - - enum ReflowType { - // This reflow command is used when a leaf node's content changes - // (e.g. some text in a text run, an image's source, etc.). The - // target of the reflow command is the frame that changed (see - // nsIFrame#ContentChanged() for how the target frame is - // determined). - ContentChanged, - - // This reflow command is used when the style for a frame has - // changed. This also implies that if the frame is a container - // that its childrens style has also changed. The target of the - // reflow command is the frame that changed style. - StyleChanged, - - // Reflow dirty stuff (really a per-frame extension) - ReflowDirty, - - // The pres shell ran out of time but will guaranteed the reflow command gets processed. - Timeout, - - // Trap door for extensions. - UserDefined - }; - - /** - * Dispatch the reflow command. - * - * Builds a path from the target frame back to the root frame, and then - * invokes the root frame's Reflow() member function. - * - * @see nsIFrame#Reflow() - */ - NS_IMETHOD Dispatch(nsIPresContext* aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsSize& aMaxSize, - nsIRenderingContext& aRendContext) = 0; - - /** - * Get the next frame in the command processing path. If requested removes the - * the frame from the path. You must remove the frame from the path before - * dispatching the reflow command to the next frame in the chain. - */ - NS_IMETHOD GetNext(nsIFrame*& aNextFrame, PRBool aRemove = PR_TRUE) = 0; - - /** - * Get the target of the reflow command. - */ - NS_IMETHOD GetTarget(nsIFrame*& aTargetFrame) const = 0; - - /** - * Change the target of the reflow command. - */ - NS_IMETHOD SetTarget(nsIFrame* aTargetFrame) = 0; - - /** - * Get the type of reflow command. - */ - NS_IMETHOD GetType(ReflowType& aReflowType) const = 0; - - /** - * Get the child frame associated with the reflow command. - */ - NS_IMETHOD GetChildFrame(nsIFrame*& aChildFrame) const = 0; - - /** - * Returns the name of the child list to which the child frame belongs. - * Only used for reflow command types FrameAppended, FrameInserted, and - * FrameRemoved - * - * Returns nsnull if the child frame is associated with the unnamed - * principal child list - */ - NS_IMETHOD GetChildListName(nsIAtom*& aListName) const = 0; - - /** - * Sets the name of the child list to which the child frame belongs. - * Only used for reflow command types FrameAppended, FrameInserted, and - * FrameRemoved - */ - NS_IMETHOD SetChildListName(nsIAtom* aListName) = 0; - - /** - * Get the previous sibling frame associated with the reflow command. - * This is used for FrameInserted reflow commands. - */ - NS_IMETHOD GetPrevSiblingFrame(nsIFrame*& aSiblingFrame) const = 0; - - /** - * Dump out the reflow-command to out - */ - NS_IMETHOD List(FILE* out) const = 0; - - /** - * Get/set reflow command flags - */ - NS_IMETHOD GetFlags(PRInt32* aFlags) = 0; - NS_IMETHOD SetFlags(PRInt32 aFlags) = 0; -}; - -#endif /* nsIReflowCommand_h___ */ diff --git a/layout/base/public/nsReflowType.h b/layout/base/public/nsReflowType.h new file mode 100644 index 000000000000..13ac01b95112 --- /dev/null +++ b/layout/base/public/nsReflowType.h @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef nsReflowType_h__ +#define nsReflowType_h__ + +enum nsReflowType { + /** + * This reflow command is used when a leaf node's content changes + * (e.g. some text in a text run, an image's source, etc.). The + * target of the reflow command is the frame that changed (see + * nsIFrame#ContentChanged() for how the target frame is + * determined). + */ + eReflowType_ContentChanged, + + /** + * This reflow command is used when the style for a frame has + * changed. This also implies that if the frame is a container + * that its childrens style has also changed. The target of the + * reflow command is the frame that changed style. + */ + eReflowType_StyleChanged, + + /** + * Reflow dirty stuff (really a per-frame extension) + */ + eReflowType_ReflowDirty, + + /** + * The pres shell ran out of time but will guaranteed the reflow + * command gets processed. + */ + eReflowType_Timeout, + + /** + * Trap door for extensions. + */ + eReflowType_UserDefined +}; + +#endif // nsReflowType_h__ + diff --git a/layout/doc/layout.xml b/layout/doc/layout.xml index b24048c78f0b..986c9812b049 100644 --- a/layout/doc/layout.xml +++ b/layout/doc/layout.xml @@ -221,7 +221,7 @@ following items are also included: has changed size) and 'eReflowReason_Incremental' (processing of an incremental reflow command). -Reflow commands (see nsIReflowCommand in mozilla/layout/base/public) are used +Reflow commands (see nsHTMLReflowCommand in mozilla/layout/html/base/src) are used to kick off an incremental reflow. They're generated either by the style system (in response to a style change) or by a frame itself (for example, if a frame has dirty child frames that need to be reflowed it will generate a reflow command). diff --git a/layout/forms/nsFieldSetFrame.cpp b/layout/forms/nsFieldSetFrame.cpp index fb62b36a760b..37fd5243c651 100644 --- a/layout/forms/nsFieldSetFrame.cpp +++ b/layout/forms/nsFieldSetFrame.cpp @@ -293,7 +293,7 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext, nsReflowReason reason = aReflowState.reason; if ( aReflowState.reason == eReflowReason_Incremental ) { - nsIReflowCommand::ReflowType reflowType; + nsReflowType reflowType; aReflowState.reflowCommand->GetType(reflowType); // See if it's targeted at us @@ -303,7 +303,7 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext, if (this == targetFrame) { switch (reflowType) { - case nsIReflowCommand::StyleChanged: + case eReflowType_StyleChanged: { nsHTMLReflowState newState(aReflowState); newState.reason = eReflowReason_StyleChange; @@ -312,7 +312,7 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext, break; // if its a dirty type then reflow us with a dirty reflow - case nsIReflowCommand::ReflowDirty: + case eReflowType_ReflowDirty: { nsHTMLReflowState newState(aReflowState); newState.reason = eReflowReason_Dirty; diff --git a/layout/forms/nsGfxButtonControlFrame.cpp b/layout/forms/nsGfxButtonControlFrame.cpp index c03f035478fe..6553e26936ce 100644 --- a/layout/forms/nsGfxButtonControlFrame.cpp +++ b/layout/forms/nsGfxButtonControlFrame.cpp @@ -319,9 +319,9 @@ nsGfxButtonControlFrame::DoNavQuirksReflow(nsIPresContext* aPresContext if (this == targetFrame) { Invalidate(aPresContext, nsRect(0,0,mRect.width,mRect.height), PR_FALSE); - nsIReflowCommand::ReflowType reflowType; + nsReflowType reflowType; aReflowState.reflowCommand->GetType(reflowType); - if (nsIReflowCommand::StyleChanged == reflowType) { + if (eReflowType_StyleChanged == reflowType) { reflowState.reason = eReflowReason_StyleChange; } else { diff --git a/layout/forms/nsHTMLButtonControlFrame.cpp b/layout/forms/nsHTMLButtonControlFrame.cpp index a65089125e72..987709f7624b 100644 --- a/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/layout/forms/nsHTMLButtonControlFrame.cpp @@ -598,9 +598,9 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext* aPresContext, if (this == targetFrame) { Invalidate(aPresContext, nsRect(0,0,mRect.width,mRect.height), PR_FALSE); - nsIReflowCommand::ReflowType reflowType; + nsReflowType reflowType; aReflowState.reflowCommand->GetType(reflowType); - if (nsIReflowCommand::StyleChanged == reflowType) { + if (eReflowType_StyleChanged == reflowType) { reflowState.reason = eReflowReason_StyleChange; } else { diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 5d0a814095c4..4c665974243f 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -58,7 +58,7 @@ #include "nsIScrollableView.h" #include "nsIDOMHTMLOptGroupElement.h" #include "nsWidgetsCID.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIPresShell.h" #include "nsHTMLParts.h" #include "nsIDOMEventReceiver.h" @@ -784,7 +784,7 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, nsIFrame* targetFrame; firstPassState.reflowCommand->GetTarget(targetFrame); if (this == targetFrame) { - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); firstPassState.reason = eReflowReason_StyleChange; firstPassState.reflowCommand = nsnull; @@ -798,7 +798,7 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, NS_ASSERTION(aDesiredSize.height < 100000, "Height is still NS_UNCONSTRAINEDSIZE"); return res; } - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); firstPassState.reason = eReflowReason_StyleChange; firstPassState.reflowCommand = nsnull; diff --git a/layout/generic/nsAbsoluteContainingBlock.cpp b/layout/generic/nsAbsoluteContainingBlock.cpp index a64bae38e11a..7d4cc697ee74 100644 --- a/layout/generic/nsAbsoluteContainingBlock.cpp +++ b/layout/generic/nsAbsoluteContainingBlock.cpp @@ -38,11 +38,10 @@ #include "nsAbsoluteContainingBlock.h" #include "nsContainerFrame.h" #include "nsHTMLIIDs.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIStyleContext.h" #include "nsIViewManager.h" #include "nsLayoutAtoms.h" -#include "nsIReflowCommand.h" #include "nsIPresShell.h" #include "nsHTMLParts.h" #include "nsIPresContext.h" @@ -88,12 +87,11 @@ nsAbsoluteContainingBlock::AppendFrames(nsIFrame* aDelegatingFrame, mAbsoluteFrames.AppendFrames(nsnull, aFrameList); // Generate a reflow command to reflow the dirty frames - nsIReflowCommand* reflowCmd; - rv = NS_NewHTMLReflowCommand(&reflowCmd, aDelegatingFrame, nsIReflowCommand::ReflowDirty); + nsHTMLReflowCommand* reflowCmd; + rv = NS_NewHTMLReflowCommand(&reflowCmd, aDelegatingFrame, eReflowType_ReflowDirty); if (NS_SUCCEEDED(rv)) { reflowCmd->SetChildListName(nsLayoutAtoms::absoluteList); aPresShell.AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); } return rv; @@ -116,12 +114,11 @@ nsAbsoluteContainingBlock::InsertFrames(nsIFrame* aDelegatingFrame, mAbsoluteFrames.InsertFrames(nsnull, aPrevFrame, aFrameList); // Generate a reflow command to reflow the dirty frames - nsIReflowCommand* reflowCmd; - rv = NS_NewHTMLReflowCommand(&reflowCmd, aDelegatingFrame, nsIReflowCommand::ReflowDirty); + nsHTMLReflowCommand* reflowCmd; + rv = NS_NewHTMLReflowCommand(&reflowCmd, aDelegatingFrame, eReflowType_ReflowDirty); if (NS_SUCCEEDED(rv)) { reflowCmd->SetChildListName(nsLayoutAtoms::absoluteList); aPresShell.AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); } return rv; @@ -306,14 +303,14 @@ nsAbsoluteContainingBlock::IncrementalReflow(nsIFrame* aDelegatin NS_IF_RELEASE(listName); if (isAbsoluteChild) { - nsIReflowCommand::ReflowType type; + nsReflowType type; // Get the type of reflow command aReflowState.reflowCommand->GetType(type); // The only type of reflow command we expect is that we have dirty // child frames to reflow - NS_ASSERTION(nsIReflowCommand::ReflowDirty, "unexpected reflow type"); + NS_ASSERTION(eReflowType_ReflowDirty, "unexpected reflow type"); // Walk the positioned frames and reflow the dirty frames for (nsIFrame* f = mAbsoluteFrames.FirstChild(); f; f->GetNextSibling(&f)) { diff --git a/layout/generic/nsAreaFrame.cpp b/layout/generic/nsAreaFrame.cpp index 4f8d5c5f4200..7c65a75dbd2e 100644 --- a/layout/generic/nsAreaFrame.cpp +++ b/layout/generic/nsAreaFrame.cpp @@ -36,7 +36,6 @@ * ***** END LICENSE BLOCK ***** */ #include "nsAreaFrame.h" #include "nsBlockBandData.h" -#include "nsIReflowCommand.h" #include "nsIStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 6e0826a5af2d..1c0786af63ec 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -54,7 +54,7 @@ #include "nsIFrameManager.h" #include "nsIPresContext.h" #include "nsIPresShell.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIStyleContext.h" #include "nsIView.h" #include "nsIFontMetrics.h" @@ -84,6 +84,7 @@ #include "nsIDOMHTMLHtmlElement.h" #ifdef DEBUG +#include "nsPrintfCString.h" #include "nsBlockDebugFlags.h" @@ -182,10 +183,11 @@ nsBlockFrame::InitDebugFlags() // Debugging support code #ifdef DEBUG -static const char* kReflowCommandType[] = { +const char* nsBlockFrame::kReflowCommandType[] = { "ContentChanged", "StyleChanged", "ReflowDirty", + "Timeout", "UserDefined", }; #endif @@ -600,10 +602,27 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus); #ifdef DEBUG if (gNoisyReflow) { + nsCAutoString reflow; + reflow.Append(nsHTMLReflowState::ReasonToString(aReflowState.reason)); + + if (aReflowState.reason == eReflowReason_Incremental) { + reflow += " ("; + + nsReflowType type; + aReflowState.reflowCommand->GetType(type); + reflow += kReflowCommandType[type]; + + nsIFrame* target; + aReflowState.reflowCommand->GetTarget(target); + reflow += nsPrintfCString("@%p", target); + + reflow += ")"; + } + IndentBy(stdout, gNoiseIndent); ListTag(stdout); printf(": begin %s reflow availSize=%d,%d computedSize=%d,%d\n", - nsHTMLReflowState::ReasonToString(aReflowState.reason), + reflow.get(), aReflowState.availableWidth, aReflowState.availableHeight, aReflowState.mComputedWidth, aReflowState.mComputedHeight); } @@ -759,24 +778,26 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, mState &= ~NS_FRAME_FIRST_REFLOW; break; - case eReflowReason_Dirty: + case eReflowReason_Dirty: + // Do nothing; the dirty lines will already have been marked. break; case eReflowReason_Incremental: // should call GetNext() ? aReflowState.reflowCommand->GetTarget(target); if (this == target) { - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); #ifdef NOISY_REFLOW_REASON ListTag(stdout); printf(": reflow=incremental type=%d\n", type); #endif switch (type) { - case nsIReflowCommand::StyleChanged: + case eReflowType_StyleChanged: rv = PrepareStyleChangedReflow(state); isStyleChange = PR_TRUE; break; - case nsIReflowCommand::ReflowDirty: + case eReflowType_ReflowDirty: + // Do nothing; the dirty lines will already have been marked. break; default: // Map any other incremental operations into full reflows @@ -2032,7 +2053,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) #ifdef DEBUG if (gNoisyReflow) { if (aState.mReflowState.reason == eReflowReason_Incremental) { - nsIReflowCommand::ReflowType type; + nsReflowType type; aState.mReflowState.reflowCommand->GetType(type); IndentBy(stdout, gNoiseIndent); ListTag(stdout); @@ -2837,15 +2858,13 @@ nsBlockFrame::AttributeChanged(nsIPresContext* aPresContext, nsCOMPtr shell; aPresContext->GetShell(getter_AddRefs(shell)); - nsIReflowCommand* reflowCmd; + nsHTMLReflowCommand* reflowCmd; rv = NS_NewHTMLReflowCommand(&reflowCmd, this, - nsIReflowCommand::ContentChanged, + eReflowType_ContentChanged, nsnull, aAttribute); - if (NS_SUCCEEDED(rv)) { + if (NS_SUCCEEDED(rv)) shell->AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); - } } else if (nsHTMLAtoms::value == aAttribute) { const nsStyleDisplay* styleDisplay; @@ -2875,15 +2894,13 @@ nsBlockFrame::AttributeChanged(nsIPresContext* aPresContext, nsCOMPtr shell; aPresContext->GetShell(getter_AddRefs(shell)); - nsIReflowCommand* reflowCmd; + nsHTMLReflowCommand* reflowCmd; rv = NS_NewHTMLReflowCommand(&reflowCmd, blockParent, - nsIReflowCommand::ContentChanged, + eReflowType_ContentChanged, nsnull, aAttribute); - if (NS_SUCCEEDED(rv)) { + if (NS_SUCCEEDED(rv)) shell->AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); - } } } } @@ -5822,13 +5839,12 @@ nsBlockFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild) // although we should. We can't use the NS_FRAME_HAS_DIRTY_CHILDREN // flag, because that's used to indicate whether in-flow children are // dirty... - nsIReflowCommand* reflowCmd; + nsHTMLReflowCommand* reflowCmd; nsresult rv = NS_NewHTMLReflowCommand(&reflowCmd, this, - nsIReflowCommand::ReflowDirty); + eReflowType_ReflowDirty); if (NS_SUCCEEDED(rv)) { reflowCmd->SetChildListName(nsLayoutAtoms::absoluteList); aPresShell->AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); } #ifdef DEBUG @@ -5870,7 +5886,7 @@ nsBlockFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild) mState |= NS_FRAME_HAS_DIRTY_CHILDREN; nsFrame::CreateAndPostReflowCommand(aPresShell, this, - nsIReflowCommand::ReflowDirty, nsnull, nsnull, nsnull); + eReflowType_ReflowDirty, nsnull, nsnull, nsnull); #ifdef DEBUG if (gNoisyReflow) { @@ -5885,7 +5901,7 @@ nsBlockFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild) mState |= NS_FRAME_IS_DIRTY; // Cancel the dirty children reflow command you posted earlier - nsIReflowCommand::ReflowType type = nsIReflowCommand::ReflowDirty; + nsReflowType type = eReflowType_ReflowDirty; aPresShell->CancelReflowCommand(this, &type); #ifdef DEBUG diff --git a/layout/generic/nsBlockFrame.h b/layout/generic/nsBlockFrame.h index 567c0af9887f..c28949a77320 100644 --- a/layout/generic/nsBlockFrame.h +++ b/layout/generic/nsBlockFrame.h @@ -519,6 +519,8 @@ public: static PRInt32 gNoiseIndent; + static const char* kReflowCommandType[]; + protected: static void InitDebugFlags(); #endif diff --git a/layout/generic/nsBlockReflowContext.cpp b/layout/generic/nsBlockReflowContext.cpp index b98d72f20faf..7808d5702562 100644 --- a/layout/generic/nsBlockReflowContext.cpp +++ b/layout/generic/nsBlockReflowContext.cpp @@ -44,7 +44,7 @@ #include "nsIPresContext.h" #include "nsIContent.h" #include "nsIStyleContext.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsHTMLContainerFrame.h" #include "nsBlockFrame.h" #include "nsIDOMHTMLTableCellElement.h" @@ -282,18 +282,18 @@ nsBlockReflowContext::ReflowBlock(nsIFrame* aFrame, // and it's target is the current block, then make sure we send // StyleChange reflow reasons down to all the children so that // they don't over-optimize their reflow. - nsIReflowCommand* rc = mOuterReflowState.reflowCommand; + nsHTMLReflowCommand* rc = mOuterReflowState.reflowCommand; if (rc) { - nsIReflowCommand::ReflowType type; + nsReflowType type; rc->GetType(type); - if (type == nsIReflowCommand::StyleChanged) { + if (type == eReflowType_StyleChanged) { nsIFrame* target; rc->GetTarget(target); if (target == mOuterReflowState.frame) { reason = eReflowReason_StyleChange; } } - else if (type == nsIReflowCommand::ReflowDirty && + else if (type == eReflowType_ReflowDirty && (state & NS_FRAME_IS_DIRTY)) { reason = eReflowReason_Dirty; } diff --git a/layout/generic/nsBlockReflowContext.h b/layout/generic/nsBlockReflowContext.h index 0cca2f50f885..8d8d7d7895f2 100644 --- a/layout/generic/nsBlockReflowContext.h +++ b/layout/generic/nsBlockReflowContext.h @@ -136,6 +136,10 @@ protected: nsIFrame* mFrame; nsRect mSpace; + + // For an incremental reflow that has not yet reached the target + // frame, this field contains the next frame along the reflow's + // path. nsIFrame* mNextRCFrame; // Spacing style for the frame we are reflowing; only valid after reflow diff --git a/layout/generic/nsBulletFrame.cpp b/layout/generic/nsBulletFrame.cpp index 1d9956b8e606..5d08983de9a1 100644 --- a/layout/generic/nsBulletFrame.cpp +++ b/layout/generic/nsBulletFrame.cpp @@ -46,7 +46,7 @@ #include "nsIPresContext.h" #include "nsIPresShell.h" #include "nsIDocument.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIRenderingContext.h" #include "nsILoadGroup.h" #include "nsIURL.h" @@ -1335,11 +1335,11 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext, DO_GLOBAL_REFLOW_COUNT("nsBulletFrame", aReflowState.reason); DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus); if (eReflowReason_Incremental == aReflowState.reason) { - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); /* if the style changed, see if we need to load a new url */ - if (nsIReflowCommand::StyleChanged == type) { + if (eReflowType_StyleChanged == type) { nsCOMPtr baseURI; GetBaseURI(getter_AddRefs(baseURI)); diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index d19e5a70330e..659a9cf810dc 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -48,7 +48,7 @@ #include "nsIScrollableView.h" #include "nsVoidArray.h" #include "nsISizeOfHandler.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsHTMLIIDs.h" #include "nsHTMLContainerFrame.h" #include "nsIFrameManager.h" @@ -353,7 +353,7 @@ nsContainerFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild) mState |= NS_FRAME_HAS_DIRTY_CHILDREN; nsFrame::CreateAndPostReflowCommand(aPresShell, aChild, - nsIReflowCommand::ReflowDirty, nsnull, nsnull, nsnull); + eReflowType_ReflowDirty, nsnull, nsnull, nsnull); return NS_OK; } diff --git a/layout/generic/nsFirstLetterFrame.cpp b/layout/generic/nsFirstLetterFrame.cpp index 50d020be4747..a2c987c68887 100644 --- a/layout/generic/nsFirstLetterFrame.cpp +++ b/layout/generic/nsFirstLetterFrame.cpp @@ -38,7 +38,6 @@ #include "nsHTMLContainerFrame.h" #include "nsIPresContext.h" #include "nsIStyleContext.h" -#include "nsIReflowCommand.h" #include "nsIContent.h" #include "nsLineLayout.h" #include "nsHTMLAtoms.h" diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 4de9b736783a..93e091a4b6ff 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -1850,13 +1850,11 @@ nsFrame::ContentChanged(nsIPresContext* aPresContext, nsCOMPtr shell; nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); if (NS_SUCCEEDED(rv) && shell) { - nsIReflowCommand* reflowCmd; + nsHTMLReflowCommand* reflowCmd; rv = NS_NewHTMLReflowCommand(&reflowCmd, this, - nsIReflowCommand::ContentChanged); - if (NS_SUCCEEDED(rv)) { + eReflowType_ContentChanged); + if (NS_SUCCEEDED(rv)) shell->AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); - } } return rv; } @@ -3859,9 +3857,9 @@ nsFrame::GetAccessible(nsIAccessible** aAccessible) #endif NS_IMETHODIMP -nsFrame::ReflowCommandNotify(nsIPresShell* aShell, - nsIReflowCommand* aRC, - PRBool aCommandAdded) +nsFrame::ReflowCommandNotify(nsIPresShell* aShell, + nsHTMLReflowCommand* aRC, + PRBool aCommandAdded) { return NS_OK; @@ -3972,12 +3970,12 @@ nsFrame::GetFirstLeaf(nsIPresContext* aPresContext, nsIFrame **aFrame) } } -nsresult nsFrame::CreateAndPostReflowCommand(nsIPresShell* aPresShell, - nsIFrame* aTargetFrame, - nsIReflowCommand::ReflowType aReflowType, - nsIFrame* aChildFrame, - nsIAtom* aAttribute, - nsIAtom* aListName) +nsresult nsFrame::CreateAndPostReflowCommand(nsIPresShell* aPresShell, + nsIFrame* aTargetFrame, + nsReflowType aReflowType, + nsIFrame* aChildFrame, + nsIAtom* aAttribute, + nsIAtom* aListName) { nsresult rv; @@ -3985,8 +3983,8 @@ nsresult nsFrame::CreateAndPostReflowCommand(nsIPresShell* aPresS rv = NS_ERROR_NULL_POINTER; } else { - nsCOMPtr reflowCmd; - rv = NS_NewHTMLReflowCommand(getter_AddRefs(reflowCmd), aTargetFrame, + nsHTMLReflowCommand* reflowCmd; + rv = NS_NewHTMLReflowCommand(&reflowCmd, aTargetFrame, aReflowType, aChildFrame, aAttribute); if (NS_SUCCEEDED(rv)) { diff --git a/layout/generic/nsFrame.h b/layout/generic/nsFrame.h index de0cab5899bd..f7e20cd007da 100644 --- a/layout/generic/nsFrame.h +++ b/layout/generic/nsFrame.h @@ -47,7 +47,7 @@ #endif #include "nsIPresShell.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIFrameSelection.h" #include "nsHTMLReflowState.h" #include "nsHTMLReflowMetrics.h" @@ -273,9 +273,9 @@ public: nsPeekOffsetStruct *aPos); NS_IMETHOD GetOffsets(PRInt32 &aStart, PRInt32 &aEnd) const; NS_IMETHOD ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild); - NS_IMETHOD ReflowCommandNotify(nsIPresShell* aPresShell, - nsIReflowCommand* aRC, - PRBool aCommandAdded); + NS_IMETHOD ReflowCommandNotify(nsIPresShell* aPresShell, + nsHTMLReflowCommand* aRC, + PRBool aCommandAdded); #ifdef ACCESSIBILITY NS_IMETHOD GetAccessible(nsIAccessible** aAccessible); @@ -368,12 +368,12 @@ public: nsIFrame *aFrame, nsIView **aView); - static nsresult CreateAndPostReflowCommand(nsIPresShell* aPresShell, - nsIFrame* aTargetFrame, - nsIReflowCommand::ReflowType aReflowType, - nsIFrame* aChildFrame, - nsIAtom* aAttribute, - nsIAtom* aListName); + static nsresult CreateAndPostReflowCommand(nsIPresShell* aPresShell, + nsIFrame* aTargetFrame, + nsReflowType aReflowType, + nsIFrame* aChildFrame, + nsIAtom* aAttribute, + nsIAtom* aListName); //Mouse Capturing code used by the frames to tell the view to capture all the following events NS_IMETHOD CaptureMouse(nsIPresContext* aPresContext, PRBool aGrabMouseEvents); diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index fa0e4da4c830..f717a2bc66a3 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -37,7 +37,7 @@ #include "nsCOMPtr.h" #include "nsHTMLParts.h" #include "nsIPresContext.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIDeviceContext.h" #include "nsPageFrame.h" #include "nsViewsCID.h" @@ -1371,7 +1371,7 @@ nsGfxScrollFrameInner::Layout(nsBoxLayoutState& aState) // force a reflow of the fixed children nsFrame::CreateAndPostReflowCommand(presShell, parentFrame, - nsIReflowCommand::UserDefined, nsnull, nsnull, nsLayoutAtoms::fixedList); + eReflowType_UserDefined, nsnull, nsnull, nsLayoutAtoms::fixedList); } } } diff --git a/layout/generic/nsHTMLContainerFrame.cpp b/layout/generic/nsHTMLContainerFrame.cpp index 6488e111bc05..2c4f3b5645c1 100644 --- a/layout/generic/nsHTMLContainerFrame.cpp +++ b/layout/generic/nsHTMLContainerFrame.cpp @@ -56,7 +56,6 @@ #include "nsIView.h" #include "nsIViewManager.h" #include "nsViewsCID.h" -#include "nsIReflowCommand.h" #include "nsHTMLIIDs.h" #include "nsIDOMEvent.h" #include "nsIScrollableView.h" diff --git a/layout/generic/nsHTMLFrame.cpp b/layout/generic/nsHTMLFrame.cpp index 1a0f11113898..d400025711ad 100644 --- a/layout/generic/nsHTMLFrame.cpp +++ b/layout/generic/nsHTMLFrame.cpp @@ -39,7 +39,7 @@ #include "nsHTMLContainerFrame.h" #include "nsCSSRendering.h" #include "nsIDocument.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIPresContext.h" #include "nsIStyleContext.h" #include "nsViewsCID.h" @@ -310,11 +310,10 @@ CanvasFrame::AppendFrames(nsIPresContext* aPresContext, mFrames.AppendFrame(nsnull, aFrameList); // Generate a reflow command to reflow the newly inserted frame - nsIReflowCommand* reflowCmd; - rv = NS_NewHTMLReflowCommand(&reflowCmd, this, nsIReflowCommand::ReflowDirty); + nsHTMLReflowCommand* reflowCmd; + rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ReflowDirty); if (NS_SUCCEEDED(rv)) { aPresShell.AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); } } @@ -366,11 +365,10 @@ CanvasFrame::RemoveFrame(nsIPresContext* aPresContext, mFrames.DestroyFrame(aPresContext, aOldFrame); // Generate a reflow command so we get reflowed - nsIReflowCommand* reflowCmd; - rv = NS_NewHTMLReflowCommand(&reflowCmd, this, nsIReflowCommand::ReflowDirty); + nsHTMLReflowCommand* reflowCmd; + rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ReflowDirty); if (NS_SUCCEEDED(rv)) { aPresShell.AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); } } else { @@ -417,7 +415,6 @@ CanvasFrame::Paint(nsIPresContext* aPresContext, #endif if (mDoPaintFocus) { - PRBool clipEmpty; nsRect focusRect; GetRect(focusRect); ///////////////////// @@ -506,15 +503,15 @@ CanvasFrame::Reflow(nsIPresContext* aPresContext, aReflowState.reflowCommand->GetTarget(targetFrame); if (this == targetFrame) { // Get the reflow type - nsIReflowCommand::ReflowType reflowType; + nsReflowType reflowType; aReflowState.reflowCommand->GetType(reflowType); switch (reflowType) { - case nsIReflowCommand::ReflowDirty: + case eReflowType_ReflowDirty: isDirtyChildReflow = PR_TRUE; break; - case nsIReflowCommand::StyleChanged: + case eReflowType_StyleChanged: // Remember it's a style change so we can set the reflow reason below isStyleChange = PR_TRUE; break; diff --git a/layout/generic/nsHTMLParts.h b/layout/generic/nsHTMLParts.h index b706ff1a052d..b16972a29e73 100644 --- a/layout/generic/nsHTMLParts.h +++ b/layout/generic/nsHTMLParts.h @@ -39,13 +39,15 @@ #include "nscore.h" #include "nsISupports.h" -#include "nsIReflowCommand.h" +#include "nsReflowType.h" +class nsHTMLReflowCommand; class nsIArena; class nsIAtom; class nsINodeInfo; class nsIContent; class nsIContentIterator; class nsIDocument; +class nsIFrame; class nsIHTMLContent; class nsIHTMLContentSink; class nsIHTMLFragmentContentSink; @@ -213,10 +215,10 @@ extern nsresult NS_NewHTMLFragmentContentSink(nsIHTMLFragmentContentSink** aInst /** Create a new HTML reflow command */ extern nsresult -NS_NewHTMLReflowCommand(nsIReflowCommand** aInstancePtrResult, - nsIFrame* aTargetFrame, - nsIReflowCommand::ReflowType aReflowType, - nsIFrame* aChildFrame = nsnull, - nsIAtom* aAttribute = nsnull); +NS_NewHTMLReflowCommand(nsHTMLReflowCommand** aInstancePtrResult, + nsIFrame* aTargetFrame, + nsReflowType aReflowType, + nsIFrame* aChildFrame = nsnull, + nsIAtom* aAttribute = nsnull); #endif /* nsHTMLParts_h___ */ diff --git a/layout/generic/nsHTMLReflowCommand.cpp b/layout/generic/nsHTMLReflowCommand.cpp index cf8a87052553..48137460e144 100644 --- a/layout/generic/nsHTMLReflowCommand.cpp +++ b/layout/generic/nsHTMLReflowCommand.cpp @@ -49,11 +49,11 @@ nsresult -NS_NewHTMLReflowCommand(nsIReflowCommand** aInstancePtrResult, - nsIFrame* aTargetFrame, - nsIReflowCommand::ReflowType aReflowType, - nsIFrame* aChildFrame, - nsIAtom* aAttribute) +NS_NewHTMLReflowCommand(nsHTMLReflowCommand** aInstancePtrResult, + nsIFrame* aTargetFrame, + nsReflowType aReflowType, + nsIFrame* aChildFrame, + nsIAtom* aAttribute) { NS_ASSERTION(aInstancePtrResult, "null result passed to NS_NewHTMLReflowCommand"); @@ -64,8 +64,6 @@ NS_NewHTMLReflowCommand(nsIReflowCommand** aInstancePtrResult, return NS_ERROR_OUT_OF_MEMORY; } - NS_ADDREF(*aInstancePtrResult); - return NS_OK; } @@ -107,20 +105,20 @@ mPathStats gmPathStats; // Construct a reflow command given a target frame, reflow command type, // and optional child frame -nsHTMLReflowCommand::nsHTMLReflowCommand(nsIFrame* aTargetFrame, - ReflowType aReflowType, - nsIFrame* aChildFrame, - nsIAtom* aAttribute) +nsHTMLReflowCommand::nsHTMLReflowCommand(nsIFrame* aTargetFrame, + nsReflowType aReflowType, + nsIFrame* aChildFrame, + nsIAtom* aAttribute) : mType(aReflowType), mTargetFrame(aTargetFrame), mChildFrame(aChildFrame), mPrevSiblingFrame(nsnull), mAttribute(aAttribute), mListName(nsnull), mFlags(0) { + MOZ_COUNT_CTOR(nsHTMLReflowCommand); NS_PRECONDITION(mTargetFrame != nsnull, "null target frame"); if (nsnull!=mAttribute) NS_ADDREF(mAttribute); - NS_INIT_REFCNT(); #ifdef DEBUG_jesup gReflows++; gReflowsInUse++; @@ -131,6 +129,7 @@ nsHTMLReflowCommand::nsHTMLReflowCommand(nsIFrame* aTargetFrame, nsHTMLReflowCommand::~nsHTMLReflowCommand() { + MOZ_COUNT_DTOR(nsHTMLReflowCommand); #ifdef DEBUG_jesup if (mPath.GetArraySize() == 0) gReflowsMaxZero++; @@ -145,8 +144,6 @@ nsHTMLReflowCommand::~nsHTMLReflowCommand() NS_IF_RELEASE(mListName); } -NS_IMPL_ISUPPORTS1(nsHTMLReflowCommand, nsIReflowCommand) - nsIFrame* nsHTMLReflowCommand::GetContainingBlock(nsIFrame* aFloater) const { nsIFrame* containingBlock; @@ -255,7 +252,7 @@ NS_IMETHODIMP nsHTMLReflowCommand::SetTarget(nsIFrame* aTargetFrame) return NS_OK; } -NS_IMETHODIMP nsHTMLReflowCommand::GetType(ReflowType& aReflowType) const +NS_IMETHODIMP nsHTMLReflowCommand::GetType(nsReflowType& aReflowType) const { aReflowType = mType; return NS_OK; @@ -374,3 +371,4 @@ nsHTMLReflowCommand::SetFlags(PRInt32 aFlags) mFlags = aFlags; return NS_OK; } + diff --git a/layout/generic/nsHTMLReflowCommand.h b/layout/generic/nsHTMLReflowCommand.h index e2d8ca3c5dec..48188e8f2b93 100644 --- a/layout/generic/nsHTMLReflowCommand.h +++ b/layout/generic/nsHTMLReflowCommand.h @@ -36,60 +36,141 @@ * ***** END LICENSE BLOCK ***** */ #ifndef nsHTMLReflowCommand_h___ #define nsHTMLReflowCommand_h___ - -#include "nsIReflowCommand.h" +#include "nsReflowType.h" #include "nsVoidArray.h" -class nsIAtom; +class nsIAtom; +class nsIFrame; +class nsIPresContext; +class nsIRenderingContext; +struct nsHTMLReflowMetrics; +struct nsSize; + +// Reflow command flags +#define NS_RC_CREATED_DURING_DOCUMENT_LOAD 0x0001 + /** - * An HTML reflow command + * A reflow command is an object that is generated in response to a content + * model change notification. The reflow command is given to a presentation + * shell where it is queued and then dispatched by invoking the reflow + * commands's Dispatch() member function. + * + * Reflow command processing follows a path from the root frame down to the + * target frame (the frame for which the reflow command is destined). Reflow + * commands are processed by invoking the frame's Reflow() member function. + * + * The typical flow of control for a given reflow command starts with a content + * change notification. The content notifications are sent to document observers. + * The presentation shell forwards the notifications to the style set. The style + * system responds to the notifications by creating new frame (or destroying + * existing frames) as appropriate, and then generating a reflow command. + * + * @see nsIDocumentObserver + * @see nsIStyleSet + * @see nsIFrameReflow#Reflow() + * @see nsIPresShell#AppendReflowCommand() + * @see nsIPresShell#ProcessReflowCommands() */ -class nsHTMLReflowCommand : public nsIReflowCommand { +class nsHTMLReflowCommand { public: /** * Construct an HTML reflow command of type aReflowType and with target * frame aTargetFrame. You can also specify an optional child frame, e.g. * to indicate the inserted child frame */ - nsHTMLReflowCommand(nsIFrame* aTargetFrame, - ReflowType aReflowType, - nsIFrame* aChildFrame = nsnull, - nsIAtom* aAttribute = nsnull); + nsHTMLReflowCommand(nsIFrame* aTargetFrame, + nsReflowType aReflowType, + nsIFrame* aChildFrame = nsnull, + nsIAtom* aAttribute = nsnull); - virtual ~nsHTMLReflowCommand(); + ~nsHTMLReflowCommand(); - // nsISupports - NS_DECL_ISUPPORTS + /** + * Dispatch the reflow command. + * + * Builds a path from the target frame back to the root frame, and then + * invokes the root frame's Reflow() member function. + * + * @see nsIFrame#Reflow() + */ + nsresult Dispatch(nsIPresContext* aPresContext, + nsHTMLReflowMetrics& aDesiredSize, + const nsSize& aMaxSize, + nsIRenderingContext& aRendContext); - // nsIReflowCommand - NS_IMETHOD Dispatch(nsIPresContext* aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsSize& aMaxSize, - nsIRenderingContext& aRendContext); - NS_IMETHOD GetNext(nsIFrame*& aNextFrame, PRBool aRemove); - NS_IMETHOD GetTarget(nsIFrame*& aTargetFrame) const; - NS_IMETHOD SetTarget(nsIFrame* aTargetFrame); - NS_IMETHOD GetType(ReflowType& aReflowType) const; + /** + * Get the next frame in the command processing path. If requested removes the + * the frame from the path. You must remove the frame from the path before + * dispatching the reflow command to the next frame in the chain. + */ + nsresult GetNext(nsIFrame*& aNextFrame, PRBool aRemove = PR_TRUE); - /** can return nsnull. If nsnull is not returned, the caller must NS_RELEASE aAttribute */ - NS_IMETHOD GetAttribute(nsIAtom *& aAttribute) const; + /** + * Get the target of the reflow command. + */ + nsresult GetTarget(nsIFrame*& aTargetFrame) const; - NS_IMETHOD GetChildFrame(nsIFrame*& aChildFrame) const; - NS_IMETHOD GetChildListName(nsIAtom*& aListName) const; - NS_IMETHOD SetChildListName(nsIAtom* aListName); - NS_IMETHOD GetPrevSiblingFrame(nsIFrame*& aSiblingFrame) const; - NS_IMETHOD List(FILE* out) const; + /** + * Change the target of the reflow command. + */ + nsresult SetTarget(nsIFrame* aTargetFrame); - NS_IMETHOD GetFlags(PRInt32* aFlags); - NS_IMETHOD SetFlags(PRInt32 aFlags); + /** + * Get the type of reflow command. + */ + nsresult GetType(nsReflowType& aReflowType) const; + + /** + * Can return nsnull. If nsnull is not returned, the caller must NS_RELEASE aAttribute + */ + nsresult GetAttribute(nsIAtom *& aAttribute) const; + + /** + * Get the child frame associated with the reflow command. + */ + nsresult GetChildFrame(nsIFrame*& aChildFrame) const; + + /** + * Returns the name of the child list to which the child frame belongs. + * Only used for reflow command types FrameAppended, FrameInserted, and + * FrameRemoved + * + * Returns nsnull if the child frame is associated with the unnamed + * principal child list + */ + nsresult GetChildListName(nsIAtom*& aListName) const; + + /** + * Sets the name of the child list to which the child frame belongs. + * Only used for reflow command types FrameAppended, FrameInserted, and + * FrameRemoved + */ + nsresult SetChildListName(nsIAtom* aListName); + + /** + * Get the previous sibling frame associated with the reflow command. + * This is used for FrameInserted reflow commands. + */ + nsresult GetPrevSiblingFrame(nsIFrame*& aSiblingFrame) const; + + /** + * Dump out the reflow-command to out + */ + nsresult List(FILE* out) const; + + /** + * Get/set reflow command flags + */ + nsresult GetFlags(PRInt32* aFlags); + nsresult SetFlags(PRInt32 aFlags); protected: void BuildPath(); nsIFrame* GetContainingBlock(nsIFrame* aFloater) const; private: - ReflowType mType; + nsReflowType mType; nsIFrame* mTargetFrame; nsIFrame* mChildFrame; nsIFrame* mPrevSiblingFrame; diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp index bd7a053f0cfd..8d6855f27a56 100644 --- a/layout/generic/nsHTMLReflowState.cpp +++ b/layout/generic/nsHTMLReflowState.cpp @@ -108,7 +108,7 @@ nsHTMLReflowState::nsHTMLReflowState(nsIPresContext* aPresContext, // reflow. nsHTMLReflowState::nsHTMLReflowState(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIReflowCommand& aReflowCommand, + nsHTMLReflowCommand& aReflowCommand, nsIRenderingContext* aRenderingContext, const nsSize& aAvailableSpace) : mReflowDepth(0) diff --git a/layout/generic/nsHTMLReflowState.h b/layout/generic/nsHTMLReflowState.h index 9f722c52e4fc..e3b27df7c2d1 100644 --- a/layout/generic/nsHTMLReflowState.h +++ b/layout/generic/nsHTMLReflowState.h @@ -42,7 +42,7 @@ class nsIFrame; class nsIPresContext; -class nsIReflowCommand; +class nsHTMLReflowCommand; class nsIRenderingContext; class nsSpaceManager; class nsLineLayout; @@ -140,7 +140,7 @@ struct nsHTMLReflowState { nsReflowReason reason; // the reflow command. only set for a reflow reason of eReflowReason_Incremental - nsIReflowCommand* reflowCommand; + nsHTMLReflowCommand* reflowCommand; // the available space in which to reflow the frame. The space represents the // amount of room for the frame's border, padding, and content area (not the @@ -264,7 +264,7 @@ struct nsHTMLReflowState { // reflow. nsHTMLReflowState(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIReflowCommand& aReflowCommand, + nsHTMLReflowCommand& aReflowCommand, nsIRenderingContext* aRenderingContext, const nsSize& aAvailableSpace); diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 2eb7b275e008..aa128ea4cfa2 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -68,7 +68,7 @@ */ struct nsHTMLReflowState; -class nsIReflowCommand; +class nsHTMLReflowCommand; struct nsHTMLReflowMetrics; class nsIAtom; @@ -1059,7 +1059,7 @@ public: /** * Called by a child frame on a parent frame to tell the parent frame that the child needs * to be reflowed. The parent should either propagate the request to its parent frame or - * handle the request by generating a nsIReflowCommand::ReflowDirtyChildren reflow command. + * handle the request by generating a eReflowType_ReflowDirtyChildren reflow command. */ NS_IMETHOD ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild) = 0; @@ -1079,9 +1079,9 @@ public: * Called during appending or cancelling a reflow command to give frames notice * of reflow commands that will be targeted below them. */ - NS_IMETHOD ReflowCommandNotify(nsIPresShell* aShell, - nsIReflowCommand* aRC, - PRBool aCommandAdded) = 0; + NS_IMETHOD ReflowCommandNotify(nsIPresShell* aShell, + nsHTMLReflowCommand* aRC, + PRBool aCommandAdded) = 0; /** * Called in style ReResolution to get the frame that contains the style context that is the diff --git a/layout/generic/nsLeafFrame.cpp b/layout/generic/nsLeafFrame.cpp index e697459b44e8..c9e4641dd1cf 100644 --- a/layout/generic/nsLeafFrame.cpp +++ b/layout/generic/nsLeafFrame.cpp @@ -142,10 +142,10 @@ nsLeafFrame::ContentChanged(nsIPresContext* aPresContext, { /* // Generate a reflow command with this frame as the target frame - nsIReflowCommand* cmd; + nsHTMLReflowCommand* cmd; nsresult rv; - rv = NS_NewHTMLReflowCommand(&cmd, this, nsIReflowCommand::ContentChanged); + rv = NS_NewHTMLReflowCommand(&cmd, this, eReflowType_ContentChanged); if (NS_SUCCEEDED(rv)) { nsCOMPtr shell; rv = aPresContext->GetShell(getter_AddRefs(shell)); diff --git a/layout/generic/nsLineBox.cpp b/layout/generic/nsLineBox.cpp index 84bc458028a6..4bbf57b972d0 100644 --- a/layout/generic/nsLineBox.cpp +++ b/layout/generic/nsLineBox.cpp @@ -495,7 +495,7 @@ nsLineBox::GetCombinedArea(nsRect* aResult) if (aResult) { *aResult = mData ? mData->mCombinedArea : mBounds; #ifdef VERY_NOISY_REFLOW - printf("nsLB::SetCombinedArea(1) %p (%d, %d, %d, %d)\n", + printf("nsLineBox::GetCombinedArea(1) %p (%d,%d,%d,%d)\n", this, aResult->x, aResult->y, aResult->width, aResult->height); #endif } diff --git a/layout/generic/nsLineLayout.cpp b/layout/generic/nsLineLayout.cpp index 814f9f37c01b..690a8fdfcedf 100644 --- a/layout/generic/nsLineLayout.cpp +++ b/layout/generic/nsLineLayout.cpp @@ -52,7 +52,7 @@ #include "nsIRenderingContext.h" #include "nsLayoutAtoms.h" #include "nsPlaceholderFrame.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIDocument.h" #include "nsIHTMLDocument.h" #include "nsIContent.h" @@ -942,11 +942,11 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, // it's target is the current span, then make sure we send // StyleChange reflow reasons down to the children so that they // don't over-optimize their reflow. - nsIReflowCommand* rc = rs->reflowCommand; + nsHTMLReflowCommand* rc = rs->reflowCommand; if (rc) { - nsIReflowCommand::ReflowType type; + nsReflowType type; rc->GetType(type); - if (type == nsIReflowCommand::StyleChanged) { + if (type == eReflowType_StyleChanged) { nsIFrame* parentFrame = psd->mFrame ? psd->mFrame->mFrame : mBlockReflowState->frame; @@ -956,7 +956,7 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, reason = eReflowReason_StyleChange; } } - else if (type == nsIReflowCommand::ReflowDirty && + else if (type == eReflowType_ReflowDirty && (state & NS_FRAME_IS_DIRTY)) { reason = eReflowReason_Dirty; } diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index be4b772b55dc..68b0afdb569e 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -1462,13 +1462,11 @@ nsObjectFrame::ContentChanged(nsIPresContext* aPresContext, nsCOMPtr shell; nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); if (NS_SUCCEEDED(rv) && shell) { - nsIReflowCommand* reflowCmd; + nsHTMLReflowCommand* reflowCmd; rv = NS_NewHTMLReflowCommand(&reflowCmd, this, - nsIReflowCommand::ContentChanged); - if (NS_SUCCEEDED(rv)) { + eReflowType_ContentChanged); + if (NS_SUCCEEDED(rv)) shell->AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); - } } return rv; } diff --git a/layout/generic/nsPageFrame.cpp b/layout/generic/nsPageFrame.cpp index a1a18eb19e8e..000e3391601c 100644 --- a/layout/generic/nsPageFrame.cpp +++ b/layout/generic/nsPageFrame.cpp @@ -39,7 +39,6 @@ #include "nsIContent.h" #include "nsIPresContext.h" #include "nsIStyleContext.h" -#include "nsIReflowCommand.h" #include "nsIRenderingContext.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" diff --git a/layout/generic/nsReflowType.h b/layout/generic/nsReflowType.h new file mode 100644 index 000000000000..13ac01b95112 --- /dev/null +++ b/layout/generic/nsReflowType.h @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef nsReflowType_h__ +#define nsReflowType_h__ + +enum nsReflowType { + /** + * This reflow command is used when a leaf node's content changes + * (e.g. some text in a text run, an image's source, etc.). The + * target of the reflow command is the frame that changed (see + * nsIFrame#ContentChanged() for how the target frame is + * determined). + */ + eReflowType_ContentChanged, + + /** + * This reflow command is used when the style for a frame has + * changed. This also implies that if the frame is a container + * that its childrens style has also changed. The target of the + * reflow command is the frame that changed style. + */ + eReflowType_StyleChanged, + + /** + * Reflow dirty stuff (really a per-frame extension) + */ + eReflowType_ReflowDirty, + + /** + * The pres shell ran out of time but will guaranteed the reflow + * command gets processed. + */ + eReflowType_Timeout, + + /** + * Trap door for extensions. + */ + eReflowType_UserDefined +}; + +#endif // nsReflowType_h__ + diff --git a/layout/generic/nsSimplePageSequence.cpp b/layout/generic/nsSimplePageSequence.cpp index ebd39b6dc5d5..9ff6dbc412d3 100644 --- a/layout/generic/nsSimplePageSequence.cpp +++ b/layout/generic/nsSimplePageSequence.cpp @@ -38,7 +38,6 @@ #include "nsReadableUtils.h" #include "nsSimplePageSequence.h" #include "nsIPresContext.h" -#include "nsIReflowCommand.h" #include "nsIRenderingContext.h" #include "nsIStyleContext.h" #include "nsHTMLAtoms.h" diff --git a/layout/generic/nsViewportFrame.cpp b/layout/generic/nsViewportFrame.cpp index 139477afe9de..26989d6a2dcf 100644 --- a/layout/generic/nsViewportFrame.cpp +++ b/layout/generic/nsViewportFrame.cpp @@ -43,7 +43,7 @@ #include "nsIScrollableFrame.h" #include "nsIDeviceContext.h" #include "nsIPresContext.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIPresShell.h" @@ -209,12 +209,11 @@ ViewportFrame::AppendFrames(nsIPresContext* aPresContext, mFixedFrames.AppendFrames(nsnull, aFrameList); // Generate a reflow command to reflow the dirty frames - nsIReflowCommand* reflowCmd; - rv = NS_NewHTMLReflowCommand(&reflowCmd, this, nsIReflowCommand::ReflowDirty); + nsHTMLReflowCommand* reflowCmd; + rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ReflowDirty); if (NS_SUCCEEDED(rv)) { reflowCmd->SetChildListName(nsLayoutAtoms::fixedList); aPresShell.AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); } } @@ -243,12 +242,11 @@ ViewportFrame::InsertFrames(nsIPresContext* aPresContext, mFixedFrames.InsertFrames(nsnull, aPrevFrame, aFrameList); // Generate a reflow command to reflow the dirty frames - nsIReflowCommand* reflowCmd; - rv = NS_NewHTMLReflowCommand(&reflowCmd, this, nsIReflowCommand::ReflowDirty); + nsHTMLReflowCommand* reflowCmd; + rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ReflowDirty); if (NS_SUCCEEDED(rv)) { reflowCmd->SetChildListName(nsLayoutAtoms::fixedList); aPresShell.AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); } } @@ -456,14 +454,14 @@ nsresult ViewportFrame::IncrementalReflow(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState) { - nsIReflowCommand::ReflowType type; + nsReflowType type; // Get the type of reflow command aReflowState.reflowCommand->GetType(type); // The only type of reflow command we expect is that we have dirty // child frames to reflow - NS_ASSERTION(nsIReflowCommand::ReflowDirty, "unexpected reflow type"); + NS_ASSERTION(eReflowType_ReflowDirty, "unexpected reflow type"); // Calculate how much room is available for the fixed items. That means // determining if the viewport is scrollable and whether the vertical and/or @@ -513,11 +511,11 @@ ViewportFrame::Reflow(nsIPresContext* aPresContext, nsIFrame* nextFrame = nsnull; PRBool isHandled = PR_FALSE; - nsIReflowCommand::ReflowType reflowType = nsIReflowCommand::ContentChanged; + nsReflowType reflowType = eReflowType_ContentChanged; if (aReflowState.reflowCommand) { aReflowState.reflowCommand->GetType(reflowType); } - if (reflowType == nsIReflowCommand::UserDefined) { + if (reflowType == eReflowType_UserDefined) { // Reflow the fixed frames to account for changed scrolled area size ReflowFixedFrames(aPresContext, aReflowState); isHandled = PR_TRUE; diff --git a/layout/html/base/src/nsAbsoluteContainingBlock.cpp b/layout/html/base/src/nsAbsoluteContainingBlock.cpp index a64bae38e11a..7d4cc697ee74 100644 --- a/layout/html/base/src/nsAbsoluteContainingBlock.cpp +++ b/layout/html/base/src/nsAbsoluteContainingBlock.cpp @@ -38,11 +38,10 @@ #include "nsAbsoluteContainingBlock.h" #include "nsContainerFrame.h" #include "nsHTMLIIDs.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIStyleContext.h" #include "nsIViewManager.h" #include "nsLayoutAtoms.h" -#include "nsIReflowCommand.h" #include "nsIPresShell.h" #include "nsHTMLParts.h" #include "nsIPresContext.h" @@ -88,12 +87,11 @@ nsAbsoluteContainingBlock::AppendFrames(nsIFrame* aDelegatingFrame, mAbsoluteFrames.AppendFrames(nsnull, aFrameList); // Generate a reflow command to reflow the dirty frames - nsIReflowCommand* reflowCmd; - rv = NS_NewHTMLReflowCommand(&reflowCmd, aDelegatingFrame, nsIReflowCommand::ReflowDirty); + nsHTMLReflowCommand* reflowCmd; + rv = NS_NewHTMLReflowCommand(&reflowCmd, aDelegatingFrame, eReflowType_ReflowDirty); if (NS_SUCCEEDED(rv)) { reflowCmd->SetChildListName(nsLayoutAtoms::absoluteList); aPresShell.AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); } return rv; @@ -116,12 +114,11 @@ nsAbsoluteContainingBlock::InsertFrames(nsIFrame* aDelegatingFrame, mAbsoluteFrames.InsertFrames(nsnull, aPrevFrame, aFrameList); // Generate a reflow command to reflow the dirty frames - nsIReflowCommand* reflowCmd; - rv = NS_NewHTMLReflowCommand(&reflowCmd, aDelegatingFrame, nsIReflowCommand::ReflowDirty); + nsHTMLReflowCommand* reflowCmd; + rv = NS_NewHTMLReflowCommand(&reflowCmd, aDelegatingFrame, eReflowType_ReflowDirty); if (NS_SUCCEEDED(rv)) { reflowCmd->SetChildListName(nsLayoutAtoms::absoluteList); aPresShell.AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); } return rv; @@ -306,14 +303,14 @@ nsAbsoluteContainingBlock::IncrementalReflow(nsIFrame* aDelegatin NS_IF_RELEASE(listName); if (isAbsoluteChild) { - nsIReflowCommand::ReflowType type; + nsReflowType type; // Get the type of reflow command aReflowState.reflowCommand->GetType(type); // The only type of reflow command we expect is that we have dirty // child frames to reflow - NS_ASSERTION(nsIReflowCommand::ReflowDirty, "unexpected reflow type"); + NS_ASSERTION(eReflowType_ReflowDirty, "unexpected reflow type"); // Walk the positioned frames and reflow the dirty frames for (nsIFrame* f = mAbsoluteFrames.FirstChild(); f; f->GetNextSibling(&f)) { diff --git a/layout/html/base/src/nsAreaFrame.cpp b/layout/html/base/src/nsAreaFrame.cpp index 4f8d5c5f4200..7c65a75dbd2e 100644 --- a/layout/html/base/src/nsAreaFrame.cpp +++ b/layout/html/base/src/nsAreaFrame.cpp @@ -36,7 +36,6 @@ * ***** END LICENSE BLOCK ***** */ #include "nsAreaFrame.h" #include "nsBlockBandData.h" -#include "nsIReflowCommand.h" #include "nsIStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" diff --git a/layout/html/base/src/nsBlockFrame.cpp b/layout/html/base/src/nsBlockFrame.cpp index 6e0826a5af2d..1c0786af63ec 100644 --- a/layout/html/base/src/nsBlockFrame.cpp +++ b/layout/html/base/src/nsBlockFrame.cpp @@ -54,7 +54,7 @@ #include "nsIFrameManager.h" #include "nsIPresContext.h" #include "nsIPresShell.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIStyleContext.h" #include "nsIView.h" #include "nsIFontMetrics.h" @@ -84,6 +84,7 @@ #include "nsIDOMHTMLHtmlElement.h" #ifdef DEBUG +#include "nsPrintfCString.h" #include "nsBlockDebugFlags.h" @@ -182,10 +183,11 @@ nsBlockFrame::InitDebugFlags() // Debugging support code #ifdef DEBUG -static const char* kReflowCommandType[] = { +const char* nsBlockFrame::kReflowCommandType[] = { "ContentChanged", "StyleChanged", "ReflowDirty", + "Timeout", "UserDefined", }; #endif @@ -600,10 +602,27 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus); #ifdef DEBUG if (gNoisyReflow) { + nsCAutoString reflow; + reflow.Append(nsHTMLReflowState::ReasonToString(aReflowState.reason)); + + if (aReflowState.reason == eReflowReason_Incremental) { + reflow += " ("; + + nsReflowType type; + aReflowState.reflowCommand->GetType(type); + reflow += kReflowCommandType[type]; + + nsIFrame* target; + aReflowState.reflowCommand->GetTarget(target); + reflow += nsPrintfCString("@%p", target); + + reflow += ")"; + } + IndentBy(stdout, gNoiseIndent); ListTag(stdout); printf(": begin %s reflow availSize=%d,%d computedSize=%d,%d\n", - nsHTMLReflowState::ReasonToString(aReflowState.reason), + reflow.get(), aReflowState.availableWidth, aReflowState.availableHeight, aReflowState.mComputedWidth, aReflowState.mComputedHeight); } @@ -759,24 +778,26 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, mState &= ~NS_FRAME_FIRST_REFLOW; break; - case eReflowReason_Dirty: + case eReflowReason_Dirty: + // Do nothing; the dirty lines will already have been marked. break; case eReflowReason_Incremental: // should call GetNext() ? aReflowState.reflowCommand->GetTarget(target); if (this == target) { - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); #ifdef NOISY_REFLOW_REASON ListTag(stdout); printf(": reflow=incremental type=%d\n", type); #endif switch (type) { - case nsIReflowCommand::StyleChanged: + case eReflowType_StyleChanged: rv = PrepareStyleChangedReflow(state); isStyleChange = PR_TRUE; break; - case nsIReflowCommand::ReflowDirty: + case eReflowType_ReflowDirty: + // Do nothing; the dirty lines will already have been marked. break; default: // Map any other incremental operations into full reflows @@ -2032,7 +2053,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) #ifdef DEBUG if (gNoisyReflow) { if (aState.mReflowState.reason == eReflowReason_Incremental) { - nsIReflowCommand::ReflowType type; + nsReflowType type; aState.mReflowState.reflowCommand->GetType(type); IndentBy(stdout, gNoiseIndent); ListTag(stdout); @@ -2837,15 +2858,13 @@ nsBlockFrame::AttributeChanged(nsIPresContext* aPresContext, nsCOMPtr shell; aPresContext->GetShell(getter_AddRefs(shell)); - nsIReflowCommand* reflowCmd; + nsHTMLReflowCommand* reflowCmd; rv = NS_NewHTMLReflowCommand(&reflowCmd, this, - nsIReflowCommand::ContentChanged, + eReflowType_ContentChanged, nsnull, aAttribute); - if (NS_SUCCEEDED(rv)) { + if (NS_SUCCEEDED(rv)) shell->AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); - } } else if (nsHTMLAtoms::value == aAttribute) { const nsStyleDisplay* styleDisplay; @@ -2875,15 +2894,13 @@ nsBlockFrame::AttributeChanged(nsIPresContext* aPresContext, nsCOMPtr shell; aPresContext->GetShell(getter_AddRefs(shell)); - nsIReflowCommand* reflowCmd; + nsHTMLReflowCommand* reflowCmd; rv = NS_NewHTMLReflowCommand(&reflowCmd, blockParent, - nsIReflowCommand::ContentChanged, + eReflowType_ContentChanged, nsnull, aAttribute); - if (NS_SUCCEEDED(rv)) { + if (NS_SUCCEEDED(rv)) shell->AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); - } } } } @@ -5822,13 +5839,12 @@ nsBlockFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild) // although we should. We can't use the NS_FRAME_HAS_DIRTY_CHILDREN // flag, because that's used to indicate whether in-flow children are // dirty... - nsIReflowCommand* reflowCmd; + nsHTMLReflowCommand* reflowCmd; nsresult rv = NS_NewHTMLReflowCommand(&reflowCmd, this, - nsIReflowCommand::ReflowDirty); + eReflowType_ReflowDirty); if (NS_SUCCEEDED(rv)) { reflowCmd->SetChildListName(nsLayoutAtoms::absoluteList); aPresShell->AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); } #ifdef DEBUG @@ -5870,7 +5886,7 @@ nsBlockFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild) mState |= NS_FRAME_HAS_DIRTY_CHILDREN; nsFrame::CreateAndPostReflowCommand(aPresShell, this, - nsIReflowCommand::ReflowDirty, nsnull, nsnull, nsnull); + eReflowType_ReflowDirty, nsnull, nsnull, nsnull); #ifdef DEBUG if (gNoisyReflow) { @@ -5885,7 +5901,7 @@ nsBlockFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild) mState |= NS_FRAME_IS_DIRTY; // Cancel the dirty children reflow command you posted earlier - nsIReflowCommand::ReflowType type = nsIReflowCommand::ReflowDirty; + nsReflowType type = eReflowType_ReflowDirty; aPresShell->CancelReflowCommand(this, &type); #ifdef DEBUG diff --git a/layout/html/base/src/nsBlockFrame.h b/layout/html/base/src/nsBlockFrame.h index 567c0af9887f..c28949a77320 100644 --- a/layout/html/base/src/nsBlockFrame.h +++ b/layout/html/base/src/nsBlockFrame.h @@ -519,6 +519,8 @@ public: static PRInt32 gNoiseIndent; + static const char* kReflowCommandType[]; + protected: static void InitDebugFlags(); #endif diff --git a/layout/html/base/src/nsBlockReflowContext.cpp b/layout/html/base/src/nsBlockReflowContext.cpp index b98d72f20faf..7808d5702562 100644 --- a/layout/html/base/src/nsBlockReflowContext.cpp +++ b/layout/html/base/src/nsBlockReflowContext.cpp @@ -44,7 +44,7 @@ #include "nsIPresContext.h" #include "nsIContent.h" #include "nsIStyleContext.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsHTMLContainerFrame.h" #include "nsBlockFrame.h" #include "nsIDOMHTMLTableCellElement.h" @@ -282,18 +282,18 @@ nsBlockReflowContext::ReflowBlock(nsIFrame* aFrame, // and it's target is the current block, then make sure we send // StyleChange reflow reasons down to all the children so that // they don't over-optimize their reflow. - nsIReflowCommand* rc = mOuterReflowState.reflowCommand; + nsHTMLReflowCommand* rc = mOuterReflowState.reflowCommand; if (rc) { - nsIReflowCommand::ReflowType type; + nsReflowType type; rc->GetType(type); - if (type == nsIReflowCommand::StyleChanged) { + if (type == eReflowType_StyleChanged) { nsIFrame* target; rc->GetTarget(target); if (target == mOuterReflowState.frame) { reason = eReflowReason_StyleChange; } } - else if (type == nsIReflowCommand::ReflowDirty && + else if (type == eReflowType_ReflowDirty && (state & NS_FRAME_IS_DIRTY)) { reason = eReflowReason_Dirty; } diff --git a/layout/html/base/src/nsBlockReflowContext.h b/layout/html/base/src/nsBlockReflowContext.h index 0cca2f50f885..8d8d7d7895f2 100644 --- a/layout/html/base/src/nsBlockReflowContext.h +++ b/layout/html/base/src/nsBlockReflowContext.h @@ -136,6 +136,10 @@ protected: nsIFrame* mFrame; nsRect mSpace; + + // For an incremental reflow that has not yet reached the target + // frame, this field contains the next frame along the reflow's + // path. nsIFrame* mNextRCFrame; // Spacing style for the frame we are reflowing; only valid after reflow diff --git a/layout/html/base/src/nsBulletFrame.cpp b/layout/html/base/src/nsBulletFrame.cpp index 1d9956b8e606..5d08983de9a1 100644 --- a/layout/html/base/src/nsBulletFrame.cpp +++ b/layout/html/base/src/nsBulletFrame.cpp @@ -46,7 +46,7 @@ #include "nsIPresContext.h" #include "nsIPresShell.h" #include "nsIDocument.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIRenderingContext.h" #include "nsILoadGroup.h" #include "nsIURL.h" @@ -1335,11 +1335,11 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext, DO_GLOBAL_REFLOW_COUNT("nsBulletFrame", aReflowState.reason); DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus); if (eReflowReason_Incremental == aReflowState.reason) { - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); /* if the style changed, see if we need to load a new url */ - if (nsIReflowCommand::StyleChanged == type) { + if (eReflowType_StyleChanged == type) { nsCOMPtr baseURI; GetBaseURI(getter_AddRefs(baseURI)); diff --git a/layout/html/base/src/nsContainerFrame.cpp b/layout/html/base/src/nsContainerFrame.cpp index d19e5a70330e..659a9cf810dc 100644 --- a/layout/html/base/src/nsContainerFrame.cpp +++ b/layout/html/base/src/nsContainerFrame.cpp @@ -48,7 +48,7 @@ #include "nsIScrollableView.h" #include "nsVoidArray.h" #include "nsISizeOfHandler.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsHTMLIIDs.h" #include "nsHTMLContainerFrame.h" #include "nsIFrameManager.h" @@ -353,7 +353,7 @@ nsContainerFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild) mState |= NS_FRAME_HAS_DIRTY_CHILDREN; nsFrame::CreateAndPostReflowCommand(aPresShell, aChild, - nsIReflowCommand::ReflowDirty, nsnull, nsnull, nsnull); + eReflowType_ReflowDirty, nsnull, nsnull, nsnull); return NS_OK; } diff --git a/layout/html/base/src/nsFirstLetterFrame.cpp b/layout/html/base/src/nsFirstLetterFrame.cpp index 50d020be4747..a2c987c68887 100644 --- a/layout/html/base/src/nsFirstLetterFrame.cpp +++ b/layout/html/base/src/nsFirstLetterFrame.cpp @@ -38,7 +38,6 @@ #include "nsHTMLContainerFrame.h" #include "nsIPresContext.h" #include "nsIStyleContext.h" -#include "nsIReflowCommand.h" #include "nsIContent.h" #include "nsLineLayout.h" #include "nsHTMLAtoms.h" diff --git a/layout/html/base/src/nsFrame.cpp b/layout/html/base/src/nsFrame.cpp index 4de9b736783a..93e091a4b6ff 100644 --- a/layout/html/base/src/nsFrame.cpp +++ b/layout/html/base/src/nsFrame.cpp @@ -1850,13 +1850,11 @@ nsFrame::ContentChanged(nsIPresContext* aPresContext, nsCOMPtr shell; nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); if (NS_SUCCEEDED(rv) && shell) { - nsIReflowCommand* reflowCmd; + nsHTMLReflowCommand* reflowCmd; rv = NS_NewHTMLReflowCommand(&reflowCmd, this, - nsIReflowCommand::ContentChanged); - if (NS_SUCCEEDED(rv)) { + eReflowType_ContentChanged); + if (NS_SUCCEEDED(rv)) shell->AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); - } } return rv; } @@ -3859,9 +3857,9 @@ nsFrame::GetAccessible(nsIAccessible** aAccessible) #endif NS_IMETHODIMP -nsFrame::ReflowCommandNotify(nsIPresShell* aShell, - nsIReflowCommand* aRC, - PRBool aCommandAdded) +nsFrame::ReflowCommandNotify(nsIPresShell* aShell, + nsHTMLReflowCommand* aRC, + PRBool aCommandAdded) { return NS_OK; @@ -3972,12 +3970,12 @@ nsFrame::GetFirstLeaf(nsIPresContext* aPresContext, nsIFrame **aFrame) } } -nsresult nsFrame::CreateAndPostReflowCommand(nsIPresShell* aPresShell, - nsIFrame* aTargetFrame, - nsIReflowCommand::ReflowType aReflowType, - nsIFrame* aChildFrame, - nsIAtom* aAttribute, - nsIAtom* aListName) +nsresult nsFrame::CreateAndPostReflowCommand(nsIPresShell* aPresShell, + nsIFrame* aTargetFrame, + nsReflowType aReflowType, + nsIFrame* aChildFrame, + nsIAtom* aAttribute, + nsIAtom* aListName) { nsresult rv; @@ -3985,8 +3983,8 @@ nsresult nsFrame::CreateAndPostReflowCommand(nsIPresShell* aPresS rv = NS_ERROR_NULL_POINTER; } else { - nsCOMPtr reflowCmd; - rv = NS_NewHTMLReflowCommand(getter_AddRefs(reflowCmd), aTargetFrame, + nsHTMLReflowCommand* reflowCmd; + rv = NS_NewHTMLReflowCommand(&reflowCmd, aTargetFrame, aReflowType, aChildFrame, aAttribute); if (NS_SUCCEEDED(rv)) { diff --git a/layout/html/base/src/nsFrame.h b/layout/html/base/src/nsFrame.h index de0cab5899bd..f7e20cd007da 100644 --- a/layout/html/base/src/nsFrame.h +++ b/layout/html/base/src/nsFrame.h @@ -47,7 +47,7 @@ #endif #include "nsIPresShell.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIFrameSelection.h" #include "nsHTMLReflowState.h" #include "nsHTMLReflowMetrics.h" @@ -273,9 +273,9 @@ public: nsPeekOffsetStruct *aPos); NS_IMETHOD GetOffsets(PRInt32 &aStart, PRInt32 &aEnd) const; NS_IMETHOD ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild); - NS_IMETHOD ReflowCommandNotify(nsIPresShell* aPresShell, - nsIReflowCommand* aRC, - PRBool aCommandAdded); + NS_IMETHOD ReflowCommandNotify(nsIPresShell* aPresShell, + nsHTMLReflowCommand* aRC, + PRBool aCommandAdded); #ifdef ACCESSIBILITY NS_IMETHOD GetAccessible(nsIAccessible** aAccessible); @@ -368,12 +368,12 @@ public: nsIFrame *aFrame, nsIView **aView); - static nsresult CreateAndPostReflowCommand(nsIPresShell* aPresShell, - nsIFrame* aTargetFrame, - nsIReflowCommand::ReflowType aReflowType, - nsIFrame* aChildFrame, - nsIAtom* aAttribute, - nsIAtom* aListName); + static nsresult CreateAndPostReflowCommand(nsIPresShell* aPresShell, + nsIFrame* aTargetFrame, + nsReflowType aReflowType, + nsIFrame* aChildFrame, + nsIAtom* aAttribute, + nsIAtom* aListName); //Mouse Capturing code used by the frames to tell the view to capture all the following events NS_IMETHOD CaptureMouse(nsIPresContext* aPresContext, PRBool aGrabMouseEvents); diff --git a/layout/html/base/src/nsGfxScrollFrame.cpp b/layout/html/base/src/nsGfxScrollFrame.cpp index fa0e4da4c830..f717a2bc66a3 100644 --- a/layout/html/base/src/nsGfxScrollFrame.cpp +++ b/layout/html/base/src/nsGfxScrollFrame.cpp @@ -37,7 +37,7 @@ #include "nsCOMPtr.h" #include "nsHTMLParts.h" #include "nsIPresContext.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIDeviceContext.h" #include "nsPageFrame.h" #include "nsViewsCID.h" @@ -1371,7 +1371,7 @@ nsGfxScrollFrameInner::Layout(nsBoxLayoutState& aState) // force a reflow of the fixed children nsFrame::CreateAndPostReflowCommand(presShell, parentFrame, - nsIReflowCommand::UserDefined, nsnull, nsnull, nsLayoutAtoms::fixedList); + eReflowType_UserDefined, nsnull, nsnull, nsLayoutAtoms::fixedList); } } } diff --git a/layout/html/base/src/nsHTMLContainerFrame.cpp b/layout/html/base/src/nsHTMLContainerFrame.cpp index 6488e111bc05..2c4f3b5645c1 100644 --- a/layout/html/base/src/nsHTMLContainerFrame.cpp +++ b/layout/html/base/src/nsHTMLContainerFrame.cpp @@ -56,7 +56,6 @@ #include "nsIView.h" #include "nsIViewManager.h" #include "nsViewsCID.h" -#include "nsIReflowCommand.h" #include "nsHTMLIIDs.h" #include "nsIDOMEvent.h" #include "nsIScrollableView.h" diff --git a/layout/html/base/src/nsHTMLFrame.cpp b/layout/html/base/src/nsHTMLFrame.cpp index 1a0f11113898..d400025711ad 100644 --- a/layout/html/base/src/nsHTMLFrame.cpp +++ b/layout/html/base/src/nsHTMLFrame.cpp @@ -39,7 +39,7 @@ #include "nsHTMLContainerFrame.h" #include "nsCSSRendering.h" #include "nsIDocument.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIPresContext.h" #include "nsIStyleContext.h" #include "nsViewsCID.h" @@ -310,11 +310,10 @@ CanvasFrame::AppendFrames(nsIPresContext* aPresContext, mFrames.AppendFrame(nsnull, aFrameList); // Generate a reflow command to reflow the newly inserted frame - nsIReflowCommand* reflowCmd; - rv = NS_NewHTMLReflowCommand(&reflowCmd, this, nsIReflowCommand::ReflowDirty); + nsHTMLReflowCommand* reflowCmd; + rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ReflowDirty); if (NS_SUCCEEDED(rv)) { aPresShell.AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); } } @@ -366,11 +365,10 @@ CanvasFrame::RemoveFrame(nsIPresContext* aPresContext, mFrames.DestroyFrame(aPresContext, aOldFrame); // Generate a reflow command so we get reflowed - nsIReflowCommand* reflowCmd; - rv = NS_NewHTMLReflowCommand(&reflowCmd, this, nsIReflowCommand::ReflowDirty); + nsHTMLReflowCommand* reflowCmd; + rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ReflowDirty); if (NS_SUCCEEDED(rv)) { aPresShell.AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); } } else { @@ -417,7 +415,6 @@ CanvasFrame::Paint(nsIPresContext* aPresContext, #endif if (mDoPaintFocus) { - PRBool clipEmpty; nsRect focusRect; GetRect(focusRect); ///////////////////// @@ -506,15 +503,15 @@ CanvasFrame::Reflow(nsIPresContext* aPresContext, aReflowState.reflowCommand->GetTarget(targetFrame); if (this == targetFrame) { // Get the reflow type - nsIReflowCommand::ReflowType reflowType; + nsReflowType reflowType; aReflowState.reflowCommand->GetType(reflowType); switch (reflowType) { - case nsIReflowCommand::ReflowDirty: + case eReflowType_ReflowDirty: isDirtyChildReflow = PR_TRUE; break; - case nsIReflowCommand::StyleChanged: + case eReflowType_StyleChanged: // Remember it's a style change so we can set the reflow reason below isStyleChange = PR_TRUE; break; diff --git a/layout/html/base/src/nsHTMLParts.h b/layout/html/base/src/nsHTMLParts.h index b706ff1a052d..b16972a29e73 100644 --- a/layout/html/base/src/nsHTMLParts.h +++ b/layout/html/base/src/nsHTMLParts.h @@ -39,13 +39,15 @@ #include "nscore.h" #include "nsISupports.h" -#include "nsIReflowCommand.h" +#include "nsReflowType.h" +class nsHTMLReflowCommand; class nsIArena; class nsIAtom; class nsINodeInfo; class nsIContent; class nsIContentIterator; class nsIDocument; +class nsIFrame; class nsIHTMLContent; class nsIHTMLContentSink; class nsIHTMLFragmentContentSink; @@ -213,10 +215,10 @@ extern nsresult NS_NewHTMLFragmentContentSink(nsIHTMLFragmentContentSink** aInst /** Create a new HTML reflow command */ extern nsresult -NS_NewHTMLReflowCommand(nsIReflowCommand** aInstancePtrResult, - nsIFrame* aTargetFrame, - nsIReflowCommand::ReflowType aReflowType, - nsIFrame* aChildFrame = nsnull, - nsIAtom* aAttribute = nsnull); +NS_NewHTMLReflowCommand(nsHTMLReflowCommand** aInstancePtrResult, + nsIFrame* aTargetFrame, + nsReflowType aReflowType, + nsIFrame* aChildFrame = nsnull, + nsIAtom* aAttribute = nsnull); #endif /* nsHTMLParts_h___ */ diff --git a/layout/html/base/src/nsHTMLReflowCommand.cpp b/layout/html/base/src/nsHTMLReflowCommand.cpp index cf8a87052553..48137460e144 100644 --- a/layout/html/base/src/nsHTMLReflowCommand.cpp +++ b/layout/html/base/src/nsHTMLReflowCommand.cpp @@ -49,11 +49,11 @@ nsresult -NS_NewHTMLReflowCommand(nsIReflowCommand** aInstancePtrResult, - nsIFrame* aTargetFrame, - nsIReflowCommand::ReflowType aReflowType, - nsIFrame* aChildFrame, - nsIAtom* aAttribute) +NS_NewHTMLReflowCommand(nsHTMLReflowCommand** aInstancePtrResult, + nsIFrame* aTargetFrame, + nsReflowType aReflowType, + nsIFrame* aChildFrame, + nsIAtom* aAttribute) { NS_ASSERTION(aInstancePtrResult, "null result passed to NS_NewHTMLReflowCommand"); @@ -64,8 +64,6 @@ NS_NewHTMLReflowCommand(nsIReflowCommand** aInstancePtrResult, return NS_ERROR_OUT_OF_MEMORY; } - NS_ADDREF(*aInstancePtrResult); - return NS_OK; } @@ -107,20 +105,20 @@ mPathStats gmPathStats; // Construct a reflow command given a target frame, reflow command type, // and optional child frame -nsHTMLReflowCommand::nsHTMLReflowCommand(nsIFrame* aTargetFrame, - ReflowType aReflowType, - nsIFrame* aChildFrame, - nsIAtom* aAttribute) +nsHTMLReflowCommand::nsHTMLReflowCommand(nsIFrame* aTargetFrame, + nsReflowType aReflowType, + nsIFrame* aChildFrame, + nsIAtom* aAttribute) : mType(aReflowType), mTargetFrame(aTargetFrame), mChildFrame(aChildFrame), mPrevSiblingFrame(nsnull), mAttribute(aAttribute), mListName(nsnull), mFlags(0) { + MOZ_COUNT_CTOR(nsHTMLReflowCommand); NS_PRECONDITION(mTargetFrame != nsnull, "null target frame"); if (nsnull!=mAttribute) NS_ADDREF(mAttribute); - NS_INIT_REFCNT(); #ifdef DEBUG_jesup gReflows++; gReflowsInUse++; @@ -131,6 +129,7 @@ nsHTMLReflowCommand::nsHTMLReflowCommand(nsIFrame* aTargetFrame, nsHTMLReflowCommand::~nsHTMLReflowCommand() { + MOZ_COUNT_DTOR(nsHTMLReflowCommand); #ifdef DEBUG_jesup if (mPath.GetArraySize() == 0) gReflowsMaxZero++; @@ -145,8 +144,6 @@ nsHTMLReflowCommand::~nsHTMLReflowCommand() NS_IF_RELEASE(mListName); } -NS_IMPL_ISUPPORTS1(nsHTMLReflowCommand, nsIReflowCommand) - nsIFrame* nsHTMLReflowCommand::GetContainingBlock(nsIFrame* aFloater) const { nsIFrame* containingBlock; @@ -255,7 +252,7 @@ NS_IMETHODIMP nsHTMLReflowCommand::SetTarget(nsIFrame* aTargetFrame) return NS_OK; } -NS_IMETHODIMP nsHTMLReflowCommand::GetType(ReflowType& aReflowType) const +NS_IMETHODIMP nsHTMLReflowCommand::GetType(nsReflowType& aReflowType) const { aReflowType = mType; return NS_OK; @@ -374,3 +371,4 @@ nsHTMLReflowCommand::SetFlags(PRInt32 aFlags) mFlags = aFlags; return NS_OK; } + diff --git a/layout/html/base/src/nsHTMLReflowCommand.h b/layout/html/base/src/nsHTMLReflowCommand.h index e2d8ca3c5dec..48188e8f2b93 100644 --- a/layout/html/base/src/nsHTMLReflowCommand.h +++ b/layout/html/base/src/nsHTMLReflowCommand.h @@ -36,60 +36,141 @@ * ***** END LICENSE BLOCK ***** */ #ifndef nsHTMLReflowCommand_h___ #define nsHTMLReflowCommand_h___ - -#include "nsIReflowCommand.h" +#include "nsReflowType.h" #include "nsVoidArray.h" -class nsIAtom; +class nsIAtom; +class nsIFrame; +class nsIPresContext; +class nsIRenderingContext; +struct nsHTMLReflowMetrics; +struct nsSize; + +// Reflow command flags +#define NS_RC_CREATED_DURING_DOCUMENT_LOAD 0x0001 + /** - * An HTML reflow command + * A reflow command is an object that is generated in response to a content + * model change notification. The reflow command is given to a presentation + * shell where it is queued and then dispatched by invoking the reflow + * commands's Dispatch() member function. + * + * Reflow command processing follows a path from the root frame down to the + * target frame (the frame for which the reflow command is destined). Reflow + * commands are processed by invoking the frame's Reflow() member function. + * + * The typical flow of control for a given reflow command starts with a content + * change notification. The content notifications are sent to document observers. + * The presentation shell forwards the notifications to the style set. The style + * system responds to the notifications by creating new frame (or destroying + * existing frames) as appropriate, and then generating a reflow command. + * + * @see nsIDocumentObserver + * @see nsIStyleSet + * @see nsIFrameReflow#Reflow() + * @see nsIPresShell#AppendReflowCommand() + * @see nsIPresShell#ProcessReflowCommands() */ -class nsHTMLReflowCommand : public nsIReflowCommand { +class nsHTMLReflowCommand { public: /** * Construct an HTML reflow command of type aReflowType and with target * frame aTargetFrame. You can also specify an optional child frame, e.g. * to indicate the inserted child frame */ - nsHTMLReflowCommand(nsIFrame* aTargetFrame, - ReflowType aReflowType, - nsIFrame* aChildFrame = nsnull, - nsIAtom* aAttribute = nsnull); + nsHTMLReflowCommand(nsIFrame* aTargetFrame, + nsReflowType aReflowType, + nsIFrame* aChildFrame = nsnull, + nsIAtom* aAttribute = nsnull); - virtual ~nsHTMLReflowCommand(); + ~nsHTMLReflowCommand(); - // nsISupports - NS_DECL_ISUPPORTS + /** + * Dispatch the reflow command. + * + * Builds a path from the target frame back to the root frame, and then + * invokes the root frame's Reflow() member function. + * + * @see nsIFrame#Reflow() + */ + nsresult Dispatch(nsIPresContext* aPresContext, + nsHTMLReflowMetrics& aDesiredSize, + const nsSize& aMaxSize, + nsIRenderingContext& aRendContext); - // nsIReflowCommand - NS_IMETHOD Dispatch(nsIPresContext* aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsSize& aMaxSize, - nsIRenderingContext& aRendContext); - NS_IMETHOD GetNext(nsIFrame*& aNextFrame, PRBool aRemove); - NS_IMETHOD GetTarget(nsIFrame*& aTargetFrame) const; - NS_IMETHOD SetTarget(nsIFrame* aTargetFrame); - NS_IMETHOD GetType(ReflowType& aReflowType) const; + /** + * Get the next frame in the command processing path. If requested removes the + * the frame from the path. You must remove the frame from the path before + * dispatching the reflow command to the next frame in the chain. + */ + nsresult GetNext(nsIFrame*& aNextFrame, PRBool aRemove = PR_TRUE); - /** can return nsnull. If nsnull is not returned, the caller must NS_RELEASE aAttribute */ - NS_IMETHOD GetAttribute(nsIAtom *& aAttribute) const; + /** + * Get the target of the reflow command. + */ + nsresult GetTarget(nsIFrame*& aTargetFrame) const; - NS_IMETHOD GetChildFrame(nsIFrame*& aChildFrame) const; - NS_IMETHOD GetChildListName(nsIAtom*& aListName) const; - NS_IMETHOD SetChildListName(nsIAtom* aListName); - NS_IMETHOD GetPrevSiblingFrame(nsIFrame*& aSiblingFrame) const; - NS_IMETHOD List(FILE* out) const; + /** + * Change the target of the reflow command. + */ + nsresult SetTarget(nsIFrame* aTargetFrame); - NS_IMETHOD GetFlags(PRInt32* aFlags); - NS_IMETHOD SetFlags(PRInt32 aFlags); + /** + * Get the type of reflow command. + */ + nsresult GetType(nsReflowType& aReflowType) const; + + /** + * Can return nsnull. If nsnull is not returned, the caller must NS_RELEASE aAttribute + */ + nsresult GetAttribute(nsIAtom *& aAttribute) const; + + /** + * Get the child frame associated with the reflow command. + */ + nsresult GetChildFrame(nsIFrame*& aChildFrame) const; + + /** + * Returns the name of the child list to which the child frame belongs. + * Only used for reflow command types FrameAppended, FrameInserted, and + * FrameRemoved + * + * Returns nsnull if the child frame is associated with the unnamed + * principal child list + */ + nsresult GetChildListName(nsIAtom*& aListName) const; + + /** + * Sets the name of the child list to which the child frame belongs. + * Only used for reflow command types FrameAppended, FrameInserted, and + * FrameRemoved + */ + nsresult SetChildListName(nsIAtom* aListName); + + /** + * Get the previous sibling frame associated with the reflow command. + * This is used for FrameInserted reflow commands. + */ + nsresult GetPrevSiblingFrame(nsIFrame*& aSiblingFrame) const; + + /** + * Dump out the reflow-command to out + */ + nsresult List(FILE* out) const; + + /** + * Get/set reflow command flags + */ + nsresult GetFlags(PRInt32* aFlags); + nsresult SetFlags(PRInt32 aFlags); protected: void BuildPath(); nsIFrame* GetContainingBlock(nsIFrame* aFloater) const; private: - ReflowType mType; + nsReflowType mType; nsIFrame* mTargetFrame; nsIFrame* mChildFrame; nsIFrame* mPrevSiblingFrame; diff --git a/layout/html/base/src/nsHTMLReflowState.cpp b/layout/html/base/src/nsHTMLReflowState.cpp index bd7a053f0cfd..8d6855f27a56 100644 --- a/layout/html/base/src/nsHTMLReflowState.cpp +++ b/layout/html/base/src/nsHTMLReflowState.cpp @@ -108,7 +108,7 @@ nsHTMLReflowState::nsHTMLReflowState(nsIPresContext* aPresContext, // reflow. nsHTMLReflowState::nsHTMLReflowState(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIReflowCommand& aReflowCommand, + nsHTMLReflowCommand& aReflowCommand, nsIRenderingContext* aRenderingContext, const nsSize& aAvailableSpace) : mReflowDepth(0) diff --git a/layout/html/base/src/nsLeafFrame.cpp b/layout/html/base/src/nsLeafFrame.cpp index e697459b44e8..c9e4641dd1cf 100644 --- a/layout/html/base/src/nsLeafFrame.cpp +++ b/layout/html/base/src/nsLeafFrame.cpp @@ -142,10 +142,10 @@ nsLeafFrame::ContentChanged(nsIPresContext* aPresContext, { /* // Generate a reflow command with this frame as the target frame - nsIReflowCommand* cmd; + nsHTMLReflowCommand* cmd; nsresult rv; - rv = NS_NewHTMLReflowCommand(&cmd, this, nsIReflowCommand::ContentChanged); + rv = NS_NewHTMLReflowCommand(&cmd, this, eReflowType_ContentChanged); if (NS_SUCCEEDED(rv)) { nsCOMPtr shell; rv = aPresContext->GetShell(getter_AddRefs(shell)); diff --git a/layout/html/base/src/nsLineBox.cpp b/layout/html/base/src/nsLineBox.cpp index 84bc458028a6..4bbf57b972d0 100644 --- a/layout/html/base/src/nsLineBox.cpp +++ b/layout/html/base/src/nsLineBox.cpp @@ -495,7 +495,7 @@ nsLineBox::GetCombinedArea(nsRect* aResult) if (aResult) { *aResult = mData ? mData->mCombinedArea : mBounds; #ifdef VERY_NOISY_REFLOW - printf("nsLB::SetCombinedArea(1) %p (%d, %d, %d, %d)\n", + printf("nsLineBox::GetCombinedArea(1) %p (%d,%d,%d,%d)\n", this, aResult->x, aResult->y, aResult->width, aResult->height); #endif } diff --git a/layout/html/base/src/nsLineLayout.cpp b/layout/html/base/src/nsLineLayout.cpp index 814f9f37c01b..690a8fdfcedf 100644 --- a/layout/html/base/src/nsLineLayout.cpp +++ b/layout/html/base/src/nsLineLayout.cpp @@ -52,7 +52,7 @@ #include "nsIRenderingContext.h" #include "nsLayoutAtoms.h" #include "nsPlaceholderFrame.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIDocument.h" #include "nsIHTMLDocument.h" #include "nsIContent.h" @@ -942,11 +942,11 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, // it's target is the current span, then make sure we send // StyleChange reflow reasons down to the children so that they // don't over-optimize their reflow. - nsIReflowCommand* rc = rs->reflowCommand; + nsHTMLReflowCommand* rc = rs->reflowCommand; if (rc) { - nsIReflowCommand::ReflowType type; + nsReflowType type; rc->GetType(type); - if (type == nsIReflowCommand::StyleChanged) { + if (type == eReflowType_StyleChanged) { nsIFrame* parentFrame = psd->mFrame ? psd->mFrame->mFrame : mBlockReflowState->frame; @@ -956,7 +956,7 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, reason = eReflowReason_StyleChange; } } - else if (type == nsIReflowCommand::ReflowDirty && + else if (type == eReflowType_ReflowDirty && (state & NS_FRAME_IS_DIRTY)) { reason = eReflowReason_Dirty; } diff --git a/layout/html/base/src/nsObjectFrame.cpp b/layout/html/base/src/nsObjectFrame.cpp index be4b772b55dc..68b0afdb569e 100644 --- a/layout/html/base/src/nsObjectFrame.cpp +++ b/layout/html/base/src/nsObjectFrame.cpp @@ -1462,13 +1462,11 @@ nsObjectFrame::ContentChanged(nsIPresContext* aPresContext, nsCOMPtr shell; nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); if (NS_SUCCEEDED(rv) && shell) { - nsIReflowCommand* reflowCmd; + nsHTMLReflowCommand* reflowCmd; rv = NS_NewHTMLReflowCommand(&reflowCmd, this, - nsIReflowCommand::ContentChanged); - if (NS_SUCCEEDED(rv)) { + eReflowType_ContentChanged); + if (NS_SUCCEEDED(rv)) shell->AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); - } } return rv; } diff --git a/layout/html/base/src/nsPageFrame.cpp b/layout/html/base/src/nsPageFrame.cpp index a1a18eb19e8e..000e3391601c 100644 --- a/layout/html/base/src/nsPageFrame.cpp +++ b/layout/html/base/src/nsPageFrame.cpp @@ -39,7 +39,6 @@ #include "nsIContent.h" #include "nsIPresContext.h" #include "nsIStyleContext.h" -#include "nsIReflowCommand.h" #include "nsIRenderingContext.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" diff --git a/layout/html/base/src/nsPresShell.cpp b/layout/html/base/src/nsPresShell.cpp index 3d162197baae..0615af3a31b8 100644 --- a/layout/html/base/src/nsPresShell.cpp +++ b/layout/html/base/src/nsPresShell.cpp @@ -49,7 +49,7 @@ #include "nsINameSpaceManager.h" // for Pref-related rule management (bugs 22963,20760,31816) #include "nsIServiceManager.h" #include "nsFrame.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIViewManager.h" #include "nsCRT.h" #include "prlog.h" @@ -876,15 +876,15 @@ public: nsIContent** aContent) const; NS_IMETHOD GetPlaceholderFrameFor(nsIFrame* aFrame, nsIFrame** aPlaceholderFrame) const; - NS_IMETHOD AppendReflowCommand(nsIReflowCommand* aReflowCommand); - NS_IMETHOD AppendReflowCommandInternal(nsIReflowCommand* aReflowCommand, - nsVoidArray& aQueue); + NS_IMETHOD AppendReflowCommand(nsHTMLReflowCommand* aReflowCommand); + NS_IMETHOD AppendReflowCommandInternal(nsHTMLReflowCommand* aReflowCommand, + nsVoidArray& aQueue); NS_IMETHOD CancelReflowCommand(nsIFrame* aTargetFrame, - nsIReflowCommand::ReflowType* aCmdType); - NS_IMETHOD CancelReflowCommandInternal(nsIFrame* aTargetFrame, - nsIReflowCommand::ReflowType* aCmdType, - nsVoidArray& aQueue, - PRBool aProcessDummyLayoutRequest = PR_TRUE); + nsReflowType* aCmdType); + NS_IMETHOD CancelReflowCommandInternal(nsIFrame* aTargetFrame, + nsReflowType* aCmdType, + nsVoidArray& aQueue, + PRBool aProcessDummyLayoutRequest = PR_TRUE); NS_IMETHOD CancelAllReflowCommands(); NS_IMETHOD IsSafeToFlush(PRBool& aIsSafeToFlush); NS_IMETHOD FlushPendingNotifications(PRBool aUpdateViews); @@ -1092,8 +1092,8 @@ protected: */ nsresult NotifyReflowObservers(const char *aData); - nsresult ReflowCommandAdded(nsIReflowCommand* aRC); - nsresult ReflowCommandRemoved(nsIReflowCommand* aRC); + nsresult ReflowCommandAdded(nsHTMLReflowCommand* aRC); + nsresult ReflowCommandRemoved(nsHTMLReflowCommand* aRC); // This method should be called after a reflow commands have been // removed from the queue, but after the state in the presshell is @@ -1118,8 +1118,8 @@ protected: nsresult GetReflowEventStatus(PRBool* aPending); nsresult SetReflowEventStatus(PRBool aPending); void PostReflowEvent(); - PRBool AlreadyInQueue(nsIReflowCommand* aReflowCommand, - nsVoidArray& aQueue); + PRBool AlreadyInQueue(nsHTMLReflowCommand* aReflowCommand, + nsVoidArray& aQueue); friend struct ReflowEvent; // utility to determine if we're in the middle of a drag @@ -3526,8 +3526,8 @@ PresShell::EndReflow(nsIDocument *aDocument, nsIPresShell* aShell) // frame it targets is targeted by a pre-existing reflow command in // the queue. PRBool -PresShell::AlreadyInQueue(nsIReflowCommand* aReflowCommand, - nsVoidArray& aQueue) +PresShell::AlreadyInQueue(nsHTMLReflowCommand* aReflowCommand, + nsVoidArray& aQueue) { PRInt32 i, n = aQueue.Count(); nsIFrame* targetFrame; @@ -3536,12 +3536,12 @@ PresShell::AlreadyInQueue(nsIReflowCommand* aReflowCommand, if (NS_SUCCEEDED(aReflowCommand->GetTarget(targetFrame))) { // Iterate over the reflow commands and compare the targeted frames. for (i = 0; i < n; i++) { - nsIReflowCommand* rc = (nsIReflowCommand*) aQueue.ElementAt(i); + nsHTMLReflowCommand* rc = (nsHTMLReflowCommand*) aQueue.ElementAt(i); if (rc) { nsIFrame* targetOfQueuedRC; if (NS_SUCCEEDED(rc->GetTarget(targetOfQueuedRC))) { - nsIReflowCommand::ReflowType RCType; - nsIReflowCommand::ReflowType queuedRCType; + nsReflowType RCType; + nsReflowType queuedRCType; aReflowCommand->GetType(RCType); rc->GetType(queuedRCType); if (targetFrame == targetOfQueuedRC && @@ -3564,9 +3564,9 @@ PresShell::AlreadyInQueue(nsIReflowCommand* aReflowCommand, } void -NotifyAncestorFramesOfReflowCommand(nsIPresShell* aPresShell, - nsIReflowCommand* aRC, - PRBool aCommandAdded) +NotifyAncestorFramesOfReflowCommand(nsIPresShell* aPresShell, + nsHTMLReflowCommand* aRC, + PRBool aCommandAdded) { if (aRC) { nsIFrame* target; @@ -3583,8 +3583,8 @@ NotifyAncestorFramesOfReflowCommand(nsIPresShell* aPresShell, } NS_IMETHODIMP -PresShell::AppendReflowCommandInternal(nsIReflowCommand* aReflowCommand, - nsVoidArray& aQueue) +PresShell::AppendReflowCommandInternal(nsHTMLReflowCommand* aReflowCommand, + nsVoidArray& aQueue) { // If we've not yet done the initial reflow, then don't bother // enqueuing a reflow command yet. @@ -3616,11 +3616,14 @@ PresShell::AppendReflowCommandInternal(nsIReflowCommand* aReflowCommand, // who call SendInterruptNotificationTo to make sure there are no duplicates if ((&aQueue == &mTimeoutReflowCommands) || ((&aQueue == &mReflowCommands) && !AlreadyInQueue(aReflowCommand, aQueue))) { - NS_ADDREF(aReflowCommand); rv = (aQueue.AppendElement(aReflowCommand) ? NS_OK : NS_ERROR_OUT_OF_MEMORY); ReflowCommandAdded(aReflowCommand); NotifyAncestorFramesOfReflowCommand(this, aReflowCommand, PR_TRUE); } + else { + // We're not going to process this reflow command. + delete aReflowCommand; + } // For async reflow during doc load, post a reflow event if we are not batching reflow commands. // For sync reflow during doc load, post a reflow event if we are not batching reflow commands @@ -3637,7 +3640,7 @@ PresShell::AppendReflowCommandInternal(nsIReflowCommand* aReflowCommand, } NS_IMETHODIMP -PresShell::AppendReflowCommand(nsIReflowCommand* aReflowCommand) +PresShell::AppendReflowCommand(nsHTMLReflowCommand* aReflowCommand) { return AppendReflowCommandInternal(aReflowCommand, mReflowCommands); } @@ -3665,14 +3668,14 @@ PresShell :: IsDragInProgress ( ) const NS_IMETHODIMP -PresShell::CancelReflowCommandInternal(nsIFrame* aTargetFrame, - nsIReflowCommand::ReflowType* aCmdType, - nsVoidArray& aQueue, - PRBool aProcessDummyLayoutRequest) +PresShell::CancelReflowCommandInternal(nsIFrame* aTargetFrame, + nsReflowType* aCmdType, + nsVoidArray& aQueue, + PRBool aProcessDummyLayoutRequest) { PRInt32 i, n = aQueue.Count(); for (i = 0; i < n; i++) { - nsIReflowCommand* rc = (nsIReflowCommand*) aQueue.ElementAt(i); + nsHTMLReflowCommand* rc = (nsHTMLReflowCommand*) aQueue.ElementAt(i); if (rc) { nsIFrame* target; if (NS_SUCCEEDED(rc->GetTarget(target))) { @@ -3680,7 +3683,7 @@ PresShell::CancelReflowCommandInternal(nsIFrame* aTargetFram if (aCmdType != NULL) { // If aCmdType is specified, only remove reflow commands // of that type - nsIReflowCommand::ReflowType type; + nsReflowType type; if (NS_SUCCEEDED(rc->GetType(type))) { if (type != *aCmdType) continue; @@ -3696,7 +3699,7 @@ PresShell::CancelReflowCommandInternal(nsIFrame* aTargetFram aQueue.RemoveElementAt(i); ReflowCommandRemoved(rc); NotifyAncestorFramesOfReflowCommand(this, rc, PR_FALSE); - NS_RELEASE(rc); + delete rc; n--; i--; continue; @@ -3713,8 +3716,8 @@ PresShell::CancelReflowCommandInternal(nsIFrame* aTargetFram } NS_IMETHODIMP -PresShell::CancelReflowCommand(nsIFrame* aTargetFrame, - nsIReflowCommand::ReflowType* aCmdType) +PresShell::CancelReflowCommand(nsIFrame* aTargetFrame, + nsReflowType* aCmdType) { return CancelReflowCommandInternal(aTargetFrame, aCmdType, mReflowCommands); } @@ -3724,21 +3727,21 @@ NS_IMETHODIMP PresShell::CancelAllReflowCommands() { PRInt32 n = mReflowCommands.Count(); - nsIReflowCommand* rc; + nsHTMLReflowCommand* rc; PRInt32 i; for (i = 0; i < n; i++) { - rc = NS_STATIC_CAST(nsIReflowCommand*, mReflowCommands.ElementAt(0)); + rc = NS_STATIC_CAST(nsHTMLReflowCommand*, mReflowCommands.ElementAt(0)); mReflowCommands.RemoveElementAt(0); ReflowCommandRemoved(rc); - NS_RELEASE(rc); + delete rc; } n = mTimeoutReflowCommands.Count(); for (i = 0; i < n; i++) { - rc = NS_STATIC_CAST(nsIReflowCommand*, mTimeoutReflowCommands.ElementAt(0)); + rc = NS_STATIC_CAST(nsHTMLReflowCommand*, mTimeoutReflowCommands.ElementAt(0)); mTimeoutReflowCommands.RemoveElementAt(0); ReflowCommandRemoved(rc); - NS_RELEASE(rc); + delete rc; } DoneRemovingReflowCommands(); @@ -6043,7 +6046,7 @@ PresShell::ProcessReflowCommand(nsVoidArray& aQueue, { // Use RemoveElementAt in case the reflowcommand dispatches a // new one during its execution. - nsIReflowCommand* rc = (nsIReflowCommand*)aQueue.ElementAt(0); + nsHTMLReflowCommand* rc = (nsHTMLReflowCommand*)aQueue.ElementAt(0); aQueue.RemoveElementAt(0); // Dispatch the reflow command @@ -6055,7 +6058,7 @@ PresShell::ProcessReflowCommand(nsVoidArray& aQueue, afterReflow = PR_Now(); ReflowCommandRemoved(rc); - NS_RELEASE(rc); + delete rc; VERIFY_STYLE_TREE; if (aAccumulateTime) { @@ -6095,7 +6098,7 @@ PresShell::ProcessReflowCommands(PRBool aInterruptible) PRInt32 i, n = mReflowCommands.Count(); printf("\nPresShell::ProcessReflowCommands: this=%p, count=%d\n", (void*)this, n); for (i = 0; i < n; i++) { - nsIReflowCommand* rc = (nsIReflowCommand*) + nsHTMLReflowCommand* rc = (nsHTMLReflowCommand*) mReflowCommands.ElementAt(i); rc->List(stdout); } @@ -6200,16 +6203,15 @@ PresShell::SendInterruptNotificationTo(nsIFrame* aFrame, nsIPresShell::InterruptType aInterruptType) { // create a reflow command targeted at aFrame - nsIReflowCommand* reflowCmd; + nsHTMLReflowCommand* reflowCmd; nsresult rv; // Target the reflow comamnd at aFrame rv = NS_NewHTMLReflowCommand(&reflowCmd, aFrame, - nsIReflowCommand::Timeout); + eReflowType_Timeout); if (NS_SUCCEEDED(rv)) { // Add the reflow command AppendReflowCommandInternal(reflowCmd, mTimeoutReflowCommands); - NS_RELEASE(reflowCmd); } return rv; } @@ -6293,7 +6295,7 @@ PresShell::CloneStyleSet(nsIStyleSet* aSet, nsIStyleSet** aResult) nsresult -PresShell::ReflowCommandAdded(nsIReflowCommand* aRC) +PresShell::ReflowCommandAdded(nsHTMLReflowCommand* aRC) { if (gAsyncReflowDuringDocLoad) { @@ -6333,7 +6335,7 @@ PresShell::ReflowCommandAdded(nsIReflowCommand* aRC) } nsresult -PresShell::ReflowCommandRemoved(nsIReflowCommand* aRC) +PresShell::ReflowCommandRemoved(nsHTMLReflowCommand* aRC) { if (gAsyncReflowDuringDocLoad) { NS_PRECONDITION(mRCCreatedDuringLoad >= 0, "PresShell's reflow command queue is in a bad state."); @@ -7505,7 +7507,6 @@ static void RecurseIndiTotals(nsIPresContext* aPresContext, //------------------------------------------------------------------ PRIntn ReflowCountMgr::DoSingleIndi(PLHashEntry *he, PRIntn i, void *arg) { - char *str = (char *)he->key; IndiReflowCounter * counter = (IndiReflowCounter *)he->value; if (counter && !counter->mHasBeenOutput) { char * name = ToNewCString(counter->mName); diff --git a/layout/html/base/src/nsScrollFrame.cpp b/layout/html/base/src/nsScrollFrame.cpp index 83b4b8645824..f13c8871141e 100644 --- a/layout/html/base/src/nsScrollFrame.cpp +++ b/layout/html/base/src/nsScrollFrame.cpp @@ -38,7 +38,7 @@ #include "nsCOMPtr.h" #include "nsHTMLParts.h" #include "nsIPresContext.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIDeviceContext.h" #include "nsPageFrame.h" #include "nsViewsCID.h" @@ -675,12 +675,12 @@ nsScrollFrame::Reflow(nsIPresContext* aPresContext, // See whether we're the target of the reflow command aReflowState.reflowCommand->GetTarget(targetFrame); if (this == targetFrame) { - nsIReflowCommand::ReflowType type; + nsReflowType type; // The only type of reflow command we expect to get is a style // change reflow command aReflowState.reflowCommand->GetType(type); - NS_ASSERTION(nsIReflowCommand::StyleChanged == type, "unexpected reflow type"); + NS_ASSERTION(eReflowType_StyleChanged == type, "unexpected reflow type"); // Make a copy of the reflow state (with a different reflow reason) and // then recurse @@ -907,7 +907,7 @@ nsScrollFrame::Reflow(nsIPresContext* aPresContext, // force a reflow of the fixed children nsFrame::CreateAndPostReflowCommand(presShell, parentFrame, - nsIReflowCommand::UserDefined, nsnull, nsnull, nsLayoutAtoms::fixedList); + eReflowType_UserDefined, nsnull, nsnull, nsLayoutAtoms::fixedList); } } } diff --git a/layout/html/base/src/nsSimplePageSequence.cpp b/layout/html/base/src/nsSimplePageSequence.cpp index ebd39b6dc5d5..9ff6dbc412d3 100644 --- a/layout/html/base/src/nsSimplePageSequence.cpp +++ b/layout/html/base/src/nsSimplePageSequence.cpp @@ -38,7 +38,6 @@ #include "nsReadableUtils.h" #include "nsSimplePageSequence.h" #include "nsIPresContext.h" -#include "nsIReflowCommand.h" #include "nsIRenderingContext.h" #include "nsIStyleContext.h" #include "nsHTMLAtoms.h" diff --git a/layout/html/base/src/nsViewportFrame.cpp b/layout/html/base/src/nsViewportFrame.cpp index 139477afe9de..26989d6a2dcf 100644 --- a/layout/html/base/src/nsViewportFrame.cpp +++ b/layout/html/base/src/nsViewportFrame.cpp @@ -43,7 +43,7 @@ #include "nsIScrollableFrame.h" #include "nsIDeviceContext.h" #include "nsIPresContext.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIPresShell.h" @@ -209,12 +209,11 @@ ViewportFrame::AppendFrames(nsIPresContext* aPresContext, mFixedFrames.AppendFrames(nsnull, aFrameList); // Generate a reflow command to reflow the dirty frames - nsIReflowCommand* reflowCmd; - rv = NS_NewHTMLReflowCommand(&reflowCmd, this, nsIReflowCommand::ReflowDirty); + nsHTMLReflowCommand* reflowCmd; + rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ReflowDirty); if (NS_SUCCEEDED(rv)) { reflowCmd->SetChildListName(nsLayoutAtoms::fixedList); aPresShell.AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); } } @@ -243,12 +242,11 @@ ViewportFrame::InsertFrames(nsIPresContext* aPresContext, mFixedFrames.InsertFrames(nsnull, aPrevFrame, aFrameList); // Generate a reflow command to reflow the dirty frames - nsIReflowCommand* reflowCmd; - rv = NS_NewHTMLReflowCommand(&reflowCmd, this, nsIReflowCommand::ReflowDirty); + nsHTMLReflowCommand* reflowCmd; + rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ReflowDirty); if (NS_SUCCEEDED(rv)) { reflowCmd->SetChildListName(nsLayoutAtoms::fixedList); aPresShell.AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); } } @@ -456,14 +454,14 @@ nsresult ViewportFrame::IncrementalReflow(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState) { - nsIReflowCommand::ReflowType type; + nsReflowType type; // Get the type of reflow command aReflowState.reflowCommand->GetType(type); // The only type of reflow command we expect is that we have dirty // child frames to reflow - NS_ASSERTION(nsIReflowCommand::ReflowDirty, "unexpected reflow type"); + NS_ASSERTION(eReflowType_ReflowDirty, "unexpected reflow type"); // Calculate how much room is available for the fixed items. That means // determining if the viewport is scrollable and whether the vertical and/or @@ -513,11 +511,11 @@ ViewportFrame::Reflow(nsIPresContext* aPresContext, nsIFrame* nextFrame = nsnull; PRBool isHandled = PR_FALSE; - nsIReflowCommand::ReflowType reflowType = nsIReflowCommand::ContentChanged; + nsReflowType reflowType = eReflowType_ContentChanged; if (aReflowState.reflowCommand) { aReflowState.reflowCommand->GetType(reflowType); } - if (reflowType == nsIReflowCommand::UserDefined) { + if (reflowType == eReflowType_UserDefined) { // Reflow the fixed frames to account for changed scrolled area size ReflowFixedFrames(aPresContext, aReflowState); isHandled = PR_TRUE; diff --git a/layout/html/forms/src/nsFieldSetFrame.cpp b/layout/html/forms/src/nsFieldSetFrame.cpp index fb62b36a760b..37fd5243c651 100644 --- a/layout/html/forms/src/nsFieldSetFrame.cpp +++ b/layout/html/forms/src/nsFieldSetFrame.cpp @@ -293,7 +293,7 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext, nsReflowReason reason = aReflowState.reason; if ( aReflowState.reason == eReflowReason_Incremental ) { - nsIReflowCommand::ReflowType reflowType; + nsReflowType reflowType; aReflowState.reflowCommand->GetType(reflowType); // See if it's targeted at us @@ -303,7 +303,7 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext, if (this == targetFrame) { switch (reflowType) { - case nsIReflowCommand::StyleChanged: + case eReflowType_StyleChanged: { nsHTMLReflowState newState(aReflowState); newState.reason = eReflowReason_StyleChange; @@ -312,7 +312,7 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext, break; // if its a dirty type then reflow us with a dirty reflow - case nsIReflowCommand::ReflowDirty: + case eReflowType_ReflowDirty: { nsHTMLReflowState newState(aReflowState); newState.reason = eReflowReason_Dirty; diff --git a/layout/html/forms/src/nsFormFrame.cpp b/layout/html/forms/src/nsFormFrame.cpp index 9528a13106a4..e5603281f82d 100644 --- a/layout/html/forms/src/nsFormFrame.cpp +++ b/layout/html/forms/src/nsFormFrame.cpp @@ -85,7 +85,7 @@ #include "nsIDOMNSHTMLFormElement.h" #include "nsDOMError.h" #include "nsHTMLParts.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsICategoryManager.h" #include "nsIFormSubmitObserver.h" @@ -665,12 +665,11 @@ nsFormFrame::StyleChangeReflow(nsIPresContext* aPresContext, nsCOMPtr shell; aPresContext->GetShell(getter_AddRefs(shell)); - nsIReflowCommand* reflowCmd; + nsHTMLReflowCommand* reflowCmd; nsresult rv = NS_NewHTMLReflowCommand(&reflowCmd, aFrame, - nsIReflowCommand::StyleChanged); + eReflowType_StyleChanged); if (NS_SUCCEEDED(rv)) { shell->AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); } } diff --git a/layout/html/forms/src/nsGfxButtonControlFrame.cpp b/layout/html/forms/src/nsGfxButtonControlFrame.cpp index c03f035478fe..6553e26936ce 100644 --- a/layout/html/forms/src/nsGfxButtonControlFrame.cpp +++ b/layout/html/forms/src/nsGfxButtonControlFrame.cpp @@ -319,9 +319,9 @@ nsGfxButtonControlFrame::DoNavQuirksReflow(nsIPresContext* aPresContext if (this == targetFrame) { Invalidate(aPresContext, nsRect(0,0,mRect.width,mRect.height), PR_FALSE); - nsIReflowCommand::ReflowType reflowType; + nsReflowType reflowType; aReflowState.reflowCommand->GetType(reflowType); - if (nsIReflowCommand::StyleChanged == reflowType) { + if (eReflowType_StyleChanged == reflowType) { reflowState.reason = eReflowReason_StyleChange; } else { diff --git a/layout/html/forms/src/nsHTMLButtonControlFrame.cpp b/layout/html/forms/src/nsHTMLButtonControlFrame.cpp index a65089125e72..987709f7624b 100644 --- a/layout/html/forms/src/nsHTMLButtonControlFrame.cpp +++ b/layout/html/forms/src/nsHTMLButtonControlFrame.cpp @@ -598,9 +598,9 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext* aPresContext, if (this == targetFrame) { Invalidate(aPresContext, nsRect(0,0,mRect.width,mRect.height), PR_FALSE); - nsIReflowCommand::ReflowType reflowType; + nsReflowType reflowType; aReflowState.reflowCommand->GetType(reflowType); - if (nsIReflowCommand::StyleChanged == reflowType) { + if (eReflowType_StyleChanged == reflowType) { reflowState.reason = eReflowReason_StyleChange; } else { diff --git a/layout/html/forms/src/nsListControlFrame.cpp b/layout/html/forms/src/nsListControlFrame.cpp index 5d0a814095c4..4c665974243f 100644 --- a/layout/html/forms/src/nsListControlFrame.cpp +++ b/layout/html/forms/src/nsListControlFrame.cpp @@ -58,7 +58,7 @@ #include "nsIScrollableView.h" #include "nsIDOMHTMLOptGroupElement.h" #include "nsWidgetsCID.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIPresShell.h" #include "nsHTMLParts.h" #include "nsIDOMEventReceiver.h" @@ -784,7 +784,7 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, nsIFrame* targetFrame; firstPassState.reflowCommand->GetTarget(targetFrame); if (this == targetFrame) { - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); firstPassState.reason = eReflowReason_StyleChange; firstPassState.reflowCommand = nsnull; @@ -798,7 +798,7 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, NS_ASSERTION(aDesiredSize.height < 100000, "Height is still NS_UNCONSTRAINEDSIZE"); return res; } - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); firstPassState.reason = eReflowReason_StyleChange; firstPassState.reflowCommand = nsnull; diff --git a/layout/html/style/src/nsCSSFrameConstructor.cpp b/layout/html/style/src/nsCSSFrameConstructor.cpp index c3eeb026050d..8db768db7feb 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -419,13 +419,19 @@ GetIBContainingBlockFor(nsIFrame* aFrame) nsIFrame* parentFrame; do { aFrame->GetParent(&parentFrame); - if (!parentFrame || !IsFrameSpecial(parentFrame)) + + if (! parentFrame) { + NS_ERROR("no unsplit block frame in IB hierarchy"); + return aFrame; + } + + if (!IsFrameSpecial(parentFrame)) break; aFrame = parentFrame; } while (1); - return aFrame; + return parentFrame; } //---------------------------------------------------------------------- @@ -8605,6 +8611,17 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, nsLayoutAtoms::fixedList, state.mFixedItems.childList); } + +#ifdef DEBUG + if (gReallyNoisyContentUpdates && docElementFrame) { + nsIFrameDebug* fdbg = nsnull; + CallQueryInterface(docElementFrame, &fdbg); + if (fdbg) { + printf("nsCSSFrameConstructor::ContentInserted: resulting frame model:\n"); + fdbg->List(aPresContext, stdout, 0); + } + } +#endif } nsCOMPtr bm; @@ -9904,9 +9921,9 @@ nsCSSFrameConstructor::StyleChangeReflow(nsIPresContext* aPresContext, nsCOMPtr shell; aPresContext->GetShell(getter_AddRefs(shell)); - nsCOMPtr reflowCmd; - rv = NS_NewHTMLReflowCommand(getter_AddRefs(reflowCmd), aFrame, - nsIReflowCommand::StyleChanged, + nsHTMLReflowCommand *reflowCmd; + rv = NS_NewHTMLReflowCommand(&reflowCmd, aFrame, + eReflowType_StyleChanged, nsnull, aAttribute); @@ -13461,6 +13478,12 @@ nsCSSFrameConstructor::WipeContainingBlock(nsIPresContext* aPresContext, aFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&) parentDisplay); if (NS_STYLE_DISPLAY_INLINE == parentDisplay->mDisplay) { if (!AreAllKidsInline(aFrameList)) { + // XXXwaterson temporary code until we figure out why bug 102931 + // is really happening. + NS_ASSERTION(aBlockContent != nsnull, "ack, inline without a containing block"); + if (! aBlockContent) + return PR_FALSE; + // Ok, reverse tracks: wipe out the frames we just created nsCOMPtr presShell; nsCOMPtr frameManager; diff --git a/layout/html/table/src/Makefile.in b/layout/html/table/src/Makefile.in index 6719553f238f..b7d00a7f7629 100644 --- a/layout/html/table/src/Makefile.in +++ b/layout/html/table/src/Makefile.in @@ -60,7 +60,7 @@ FORCE_STATIC_LIB = 1 include $(topsrcdir)/config/rules.mk -DEFINES += -D_IMPL_NS_HTML +DEFINES += -D_IMPL_NS_HTML -DDEBUG_TABLE_REFLOW_off INCLUDES += \ -I$(srcdir)/../../base/src \ diff --git a/layout/html/table/src/nsTableCellFrame.cpp b/layout/html/table/src/nsTableCellFrame.cpp index 71c4004fa0b0..6ce64654efe5 100644 --- a/layout/html/table/src/nsTableCellFrame.cpp +++ b/layout/html/table/src/nsTableCellFrame.cpp @@ -40,7 +40,7 @@ #include "nsTableCellFrame.h" #include "nsTableFrame.h" #include "nsTableRowGroupFrame.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" @@ -858,9 +858,9 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext, rv = aReflowState.reflowCommand->GetTarget(target); if ((PR_TRUE==NS_SUCCEEDED(rv)) && target) { if (this == target) { - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); - if (nsIReflowCommand::StyleChanged == type) { + if (eReflowType_StyleChanged == type) { isStyleChanged = PR_TRUE; } else { diff --git a/layout/html/table/src/nsTableColFrame.cpp b/layout/html/table/src/nsTableColFrame.cpp index c40919b7437d..17cd7804237d 100644 --- a/layout/html/table/src/nsTableColFrame.cpp +++ b/layout/html/table/src/nsTableColFrame.cpp @@ -37,7 +37,6 @@ #include "nsCOMPtr.h" #include "nsTableColFrame.h" #include "nsContainerFrame.h" -#include "nsIReflowCommand.h" #include "nsIStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" diff --git a/layout/html/table/src/nsTableColGroupFrame.cpp b/layout/html/table/src/nsTableColGroupFrame.cpp index 945dba1980da..d157c02819d0 100644 --- a/layout/html/table/src/nsTableColGroupFrame.cpp +++ b/layout/html/table/src/nsTableColGroupFrame.cpp @@ -39,7 +39,7 @@ #include "nsTableFrame.h" #include "nsIHTMLTableColElement.h" #include "nsIDOMHTMLTableColElement.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" @@ -551,7 +551,7 @@ NS_METHOD nsTableColGroupFrame::IR_TargetIsMe(nsIPresContext* aPresCont { nsresult rv = NS_OK; aStatus = NS_FRAME_COMPLETE; - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); nsIFrame *objectFrame; aReflowState.reflowCommand->GetChildFrame(objectFrame); @@ -560,11 +560,11 @@ NS_METHOD nsTableColGroupFrame::IR_TargetIsMe(nsIPresContext* aPresCont objectFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay)); switch (type) { - case nsIReflowCommand::StyleChanged : + case eReflowType_StyleChanged : rv = IR_StyleChanged(aPresContext, aDesiredSize, aReflowState, aStatus); break; - case nsIReflowCommand::ContentChanged : + case eReflowType_ContentChanged : NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged"); rv = NS_ERROR_ILLEGAL_VALUE; break; diff --git a/layout/html/table/src/nsTableFrame.cpp b/layout/html/table/src/nsTableFrame.cpp index 5ff228b0df22..1e4b9d4a0dfe 100644 --- a/layout/html/table/src/nsTableFrame.cpp +++ b/layout/html/table/src/nsTableFrame.cpp @@ -63,7 +63,7 @@ #include "nsIView.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsLayoutAtoms.h" #include "nsIDeviceContext.h" #include "nsIStyleSet.h" @@ -295,7 +295,7 @@ nsTableFrame::Destroy(nsIPresContext* aPresContext) NS_IMETHODIMP nsTableFrame::ReflowCommandNotify(nsIPresShell* aShell, - nsIReflowCommand* aRC, + nsHTMLReflowCommand* aRC, PRBool aCommandAdded) { @@ -305,14 +305,14 @@ nsTableFrame::ReflowCommandNotify(nsIPresShell* aShell, } #ifndef TABLE_REFLOW_COALESCING_OFF - nsIReflowCommand::ReflowType type; + nsReflowType type; aRC->GetType(type); - if ((type == nsIReflowCommand::ContentChanged) || - (type == nsIReflowCommand::StyleChanged) || - (type == nsIReflowCommand::ReflowDirty)) { + if ((type == eReflowType_ContentChanged) || + (type == eReflowType_StyleChanged) || + (type == eReflowType_ReflowDirty)) { mNumDescendantReflowsPending += (aCommandAdded) ? 1 : -1; } - else if (type == nsIReflowCommand::Timeout) { + else if (type == eReflowType_Timeout) { if (aCommandAdded) { mNumDescendantTimeoutReflowsPending++; if (RequestedTimeoutReflow()) { @@ -389,13 +389,12 @@ nsTableFrame::AppendDirtyReflowCommand(nsIPresShell* aPresShell, frameState |= NS_FRAME_IS_DIRTY; // mark the table frame as dirty aFrame->SetFrameState(frameState); - nsIReflowCommand* reflowCmd; + nsHTMLReflowCommand* reflowCmd; nsresult rv = NS_NewHTMLReflowCommand(&reflowCmd, aFrame, - nsIReflowCommand::ReflowDirty); + eReflowType_ReflowDirty); if (NS_SUCCEEDED(rv)) { // Add the reflow command rv = aPresShell->AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); } return rv; @@ -1607,9 +1606,9 @@ PRBool nsTableFrame::NeedsReflow(const nsHTMLReflowState& aReflowState) #ifndef TABLE_REFLOW_COALESCING_OFF nsIFrame* reflowTarget; aReflowState.reflowCommand->GetTarget(reflowTarget); - nsIReflowCommand::ReflowType reflowType; + nsReflowType reflowType; aReflowState.reflowCommand->GetType(reflowType); - if (reflowType == nsIReflowCommand::Timeout) { + if (reflowType == eReflowType_Timeout) { result = PR_FALSE; if (this == reflowTarget) { if (mNumDescendantTimeoutReflowsPending <= 0) { @@ -2032,9 +2031,9 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext, // determine if we need to reset DescendantReflowedNotTimeout and/or // RequestedTimeoutReflow after a timeout reflow. if (aReflowState.reflowCommand) { - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); - if (nsIReflowCommand::Timeout == type) { + if (eReflowType_Timeout == type) { nsIFrame* target = nsnull; aReflowState.reflowCommand->GetTarget(target); if (target == this) { // target is me @@ -2682,7 +2681,7 @@ nsTableFrame::IncrementalReflow(nsIPresContext* aPresContext, nsIFrame* target = nsnull; rv = aReflowState.reflowCommand->GetTarget(target); if (NS_SUCCEEDED(rv) && target) { - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); // this is the target if target is either this or the outer table frame containing this inner frame nsIFrame* outerTableFrame = nsnull; @@ -2713,18 +2712,18 @@ nsTableFrame::IR_TargetIsMe(nsIPresContext* aPresContext, nsresult rv = NS_OK; aStatus = NS_FRAME_COMPLETE; - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowState.reflowCommand->GetType(type); switch (type) { - case nsIReflowCommand::StyleChanged : + case eReflowType_StyleChanged : rv = IR_StyleChanged(aPresContext, aReflowState, aStatus); break; - case nsIReflowCommand::ContentChanged : + case eReflowType_ContentChanged : NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged"); rv = NS_ERROR_ILLEGAL_VALUE; break; - case nsIReflowCommand::ReflowDirty: { + case eReflowType_ReflowDirty: { // reflow the dirty children nsTableReflowState reflowState(aReflowState.reflowState, *this, eReflowReason_Initial, aReflowState.availSize.width, aReflowState.availSize.height); @@ -2735,7 +2734,7 @@ nsTableFrame::IR_TargetIsMe(nsIPresContext* aPresContext, SetNeedStrategyInit(PR_TRUE); } break; - case nsIReflowCommand::Timeout: { + case eReflowType_Timeout: { // for a timeout reflow, don't do anything here break; } @@ -2864,9 +2863,9 @@ nsTableFrame::IR_TargetIsChild(nsIPresContext* aPresContext, #ifndef TABLE_REFLOW_COALESCING_OFF // update the descendant reflow counts and determine if we need to request a timeout reflow PRBool needToRequestTimeoutReflow = PR_FALSE; - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowState.reflowCommand->GetType(type); - if (nsIReflowCommand::Timeout == type) { + if (eReflowType_Timeout == type) { mNumDescendantTimeoutReflowsPending--; NS_ASSERTION(mNumDescendantTimeoutReflowsPending >= 0, "invalid descendant reflow count"); } @@ -4877,9 +4876,9 @@ void nsTableFrame::DebugReflow(nsIFrame* aFrame, timer->mComputedWidth = aState.mComputedWidth; timer->mComputedHeight = aState.mComputedHeight; timer->mCount = gRflCount++; - nsIReflowCommand* reflowCommand = aState.reflowCommand; + nsHTMLReflowCommand* reflowCommand = aState.reflowCommand; if (reflowCommand) { - nsIReflowCommand::ReflowType reflowType; + nsReflowType reflowType; reflowCommand->GetType(reflowType); timer->mReflowType = reflowType; } diff --git a/layout/html/table/src/nsTableFrame.h b/layout/html/table/src/nsTableFrame.h index a81d25848b76..4862e4a92c28 100644 --- a/layout/html/table/src/nsTableFrame.h +++ b/layout/html/table/src/nsTableFrame.h @@ -562,9 +562,9 @@ public: // increment or decrement the count of pending reflow commands targeted at // descendants. Only rebalance the table when this count goes to 0 or the // reflow is the last one in a batch (limited by the pres shell). - NS_IMETHOD ReflowCommandNotify(nsIPresShell* aShell, - nsIReflowCommand* aRC, - PRBool aCommandAdded); + NS_IMETHOD ReflowCommandNotify(nsIPresShell* aShell, + nsHTMLReflowCommand* aRC, + PRBool aCommandAdded); PRBool IsRowInserted() const; void SetRowInserted(PRBool aValue); diff --git a/layout/html/table/src/nsTableOuterFrame.cpp b/layout/html/table/src/nsTableOuterFrame.cpp index 1810ebe0ae00..7d0bc101bdd2 100644 --- a/layout/html/table/src/nsTableOuterFrame.cpp +++ b/layout/html/table/src/nsTableOuterFrame.cpp @@ -37,7 +37,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsTableOuterFrame.h" #include "nsTableFrame.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" @@ -260,13 +260,11 @@ nsTableOuterFrame::AppendFrames(nsIPresContext* aPresContext, // Reflow the new caption frame. It's already marked dirty, so generate a reflow // command that tells us to reflow our dirty child frames - nsIReflowCommand* reflowCmd; + nsHTMLReflowCommand* reflowCmd; - rv = NS_NewHTMLReflowCommand(&reflowCmd, this, nsIReflowCommand::ReflowDirty); - if (NS_SUCCEEDED(rv)) { + rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ReflowDirty); + if (NS_SUCCEEDED(rv)) aPresShell.AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); - } } } else { @@ -319,13 +317,11 @@ nsTableOuterFrame::RemoveFrame(nsIPresContext* aPresContext, } // Generate a reflow command so we get reflowed - nsIReflowCommand* reflowCmd; + nsHTMLReflowCommand* reflowCmd; - rv = NS_NewHTMLReflowCommand(&reflowCmd, this, nsIReflowCommand::ReflowDirty); - if (NS_SUCCEEDED(rv)) { + rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ReflowDirty); + if (NS_SUCCEEDED(rv)) aPresShell.AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); - } return NS_OK; } @@ -1112,9 +1108,9 @@ nsTableOuterFrame::IR_TargetIsCaptionFrame(nsIPresContext* aPresContex nsSize containSize = GetContainingBlockSize(aOuterRS); // for now just reflow the table if a style changed. This should be improved - nsIReflowCommand::ReflowType reflowCommandType; + nsReflowType reflowCommandType; aOuterRS.reflowCommand->GetType(reflowCommandType); - PRBool needInnerReflow = (nsIReflowCommand::StyleChanged == reflowCommandType) + PRBool needInnerReflow = (eReflowType_StyleChanged == reflowCommandType) ? PR_TRUE : PR_FALSE; if (mMinCaptionWidth != captionMES.width) { @@ -1234,21 +1230,21 @@ nsresult nsTableOuterFrame::IR_TargetIsMe(nsIPresContext* aPresContext nsReflowStatus& aStatus) { nsresult rv = NS_OK; - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); nsIFrame* objectFrame; aReflowState.reflowCommand->GetChildFrame(objectFrame); switch (type) { - case nsIReflowCommand::ReflowDirty: + case eReflowType_ReflowDirty: rv = IR_ReflowDirty(aPresContext, aDesiredSize, aReflowState, aStatus); break; - case nsIReflowCommand::StyleChanged : - case nsIReflowCommand::Timeout : + case eReflowType_StyleChanged : + case eReflowType_Timeout : rv = IR_InnerTableReflow(aPresContext, aDesiredSize, aReflowState, aStatus); break; - case nsIReflowCommand::ContentChanged : + case eReflowType_ContentChanged : NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged"); rv = NS_ERROR_ILLEGAL_VALUE; break; @@ -1288,9 +1284,9 @@ nsTableOuterFrame::IR_InnerTableReflow(nsIPresContext* aPresContext, nsIFrame* target = nsnull; aOuterRS.reflowCommand->GetTarget(target); if (this == target) { - nsIReflowCommand::ReflowType type; + nsReflowType type; aOuterRS.reflowCommand->GetType(type); - if (nsIReflowCommand::StyleChanged == type) { + if (eReflowType_StyleChanged == type) { ReflowReason = eReflowReason_StyleChange; } } diff --git a/layout/html/table/src/nsTableRowFrame.cpp b/layout/html/table/src/nsTableRowFrame.cpp index 29acf0f9994b..8fd988c0139d 100644 --- a/layout/html/table/src/nsTableRowFrame.cpp +++ b/layout/html/table/src/nsTableRowFrame.cpp @@ -47,7 +47,7 @@ #include "nsTableFrame.h" #include "nsTableCellFrame.h" #include "nsIView.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsCSSRendering.h" #include "nsHTMLIIDs.h" #include "nsLayoutAtoms.h" @@ -924,9 +924,9 @@ nsTableRowFrame::ReflowChildren(nsIPresContext* aPresContext, if (eReflowReason_Incremental == aReflowState.reason) { aReflowState.reflowCommand->GetTarget(target); if (this == target) { - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); - if (nsIReflowCommand::StyleChanged == type) { + if (eReflowType_StyleChanged == type) { notifyStyleChange = PR_TRUE; } } @@ -1166,17 +1166,17 @@ nsTableRowFrame::IR_TargetIsMe(nsIPresContext* aPresContext, { nsresult rv = NS_FRAME_COMPLETE; - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); switch (type) { - case nsIReflowCommand::ReflowDirty: + case eReflowType_ReflowDirty: // Reflow the dirty child frames. Typically this is newly added frames. rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, aTableFrame, aStatus, PR_TRUE); break; - case nsIReflowCommand::StyleChanged : + case eReflowType_StyleChanged : rv = IR_StyleChanged(aPresContext, aDesiredSize, aReflowState, aTableFrame, aStatus); break; - case nsIReflowCommand::ContentChanged : + case eReflowType_ContentChanged : NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged"); rv = NS_ERROR_ILLEGAL_VALUE; break; diff --git a/layout/html/table/src/nsTableRowGroupFrame.cpp b/layout/html/table/src/nsTableRowGroupFrame.cpp index b4813971eff1..0fffa286c3e2 100644 --- a/layout/html/table/src/nsTableRowGroupFrame.cpp +++ b/layout/html/table/src/nsTableRowGroupFrame.cpp @@ -45,7 +45,7 @@ #include "nsStyleConsts.h" #include "nsIContent.h" #include "nsIView.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsHTMLIIDs.h" #include "nsIDeviceContext.h" #include "nsHTMLAtoms.h" @@ -430,9 +430,9 @@ nsTableRowGroupFrame::ReflowChildren(nsIPresContext* aPresContext, if (eReflowReason_Incremental == aReflowState.reason) { aReflowState.reflowState.reflowCommand->GetTarget(target); if (this == target) { - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowState.reflowCommand->GetType(type); - if (nsIReflowCommand::StyleChanged == type) { + if (eReflowType_StyleChanged == type) { reason = eReflowReason_StyleChange; } } @@ -1356,11 +1356,11 @@ nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext* aPresContext, nsReflowStatus& aStatus) { nsresult rv = NS_FRAME_COMPLETE; - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowState.reflowCommand->GetType(type); switch (type) { - case nsIReflowCommand::ReflowDirty: { + case eReflowType_ReflowDirty: { nsRowGroupReflowState state(aReflowState); state.reason = eReflowReason_Resize; // Reflow the dirty child frames. Typically this is newly added frames. @@ -1370,10 +1370,10 @@ nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext* aPresContext, CalculateRowHeights(aPresContext, aDesiredSize, aReflowState.reflowState, firstRowReflowed); break; } - case nsIReflowCommand::StyleChanged : + case eReflowType_StyleChanged : rv = IR_StyleChanged(aPresContext, aDesiredSize, aReflowState, aStatus); break; - case nsIReflowCommand::ContentChanged : + case eReflowType_ContentChanged : NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged"); rv = NS_ERROR_ILLEGAL_VALUE; break; diff --git a/layout/mathml/base/src/nsMathMLContainerFrame.cpp b/layout/mathml/base/src/nsMathMLContainerFrame.cpp index 9bae4375f9c6..dfb8b30863cb 100644 --- a/layout/mathml/base/src/nsMathMLContainerFrame.cpp +++ b/layout/mathml/base/src/nsMathMLContainerFrame.cpp @@ -1070,10 +1070,10 @@ nsMathMLContainerFrame::AttributeChanged(nsIPresContext* aPresContext, aNameSpaceID, aAttribute, aModType, aHint); if (NS_FAILED(rv)) return rv; nsCOMPtr shell; - nsCOMPtr reflowCmd; + nsCOMPtr reflowCmd; aPresContext->GetShell(getter_AddRefs(shell)); rv = NS_NewHTMLReflowCommand(getter_AddRefs(reflowCmd), this, - nsIReflowCommand::ContentChanged, + eReflowType_ContentChanged, nsnull, aAttribute); if (NS_SUCCEEDED(rv) && shell) shell->AppendReflowCommand(reflowCmd); return rv; diff --git a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp index d3cebb58eaa7..ba363dd65ddf 100644 --- a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp +++ b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp @@ -563,8 +563,8 @@ nsSVGOuterSVGFrame::AppendFrames(nsIPresContext* aPresContext, vm->EndUpdateViewBatch(NS_VMREFRESH_IMMEDIATE); // Generate a reflow command to reflow the dirty frames - //nsIReflowCommand* reflowCmd; - //rv = NS_NewHTMLReflowCommand(&reflowCmd, aDelegatingFrame, nsIReflowCommand::ReflowDirty); + //nsHTMLReflowCommand* reflowCmd; + //rv = NS_NewHTMLReflowCommand(&reflowCmd, aDelegatingFrame, eReflowType_ReflowDirty); //if (NS_SUCCEEDED(rv)) { // reflowCmd->SetChildListName(nsLayoutAtoms::absoluteList); // aPresShell.AppendReflowCommand(reflowCmd); @@ -624,8 +624,8 @@ nsSVGOuterSVGFrame::InsertFrames(nsIPresContext* aPresContext, vm->EndUpdateViewBatch(NS_VMREFRESH_IMMEDIATE); // Generate a reflow command to reflow the dirty frames - //nsIReflowCommand* reflowCmd; - //rv = NS_NewHTMLReflowCommand(&reflowCmd, aDelegatingFrame, nsIReflowCommand::ReflowDirty); + //nsHTMLReflowCommand* reflowCmd; + //rv = NS_NewHTMLReflowCommand(&reflowCmd, aDelegatingFrame, eReflowType_ReflowDirty); //if (NS_SUCCEEDED(rv)) { // reflowCmd->SetChildListName(nsLayoutAtoms::absoluteList); // aPresShell.AppendReflowCommand(reflowCmd); @@ -683,8 +683,8 @@ nsSVGOuterSVGFrame::RemoveFrame(nsIPresContext* aPresContext, vm->EndUpdateViewBatch(NS_VMREFRESH_IMMEDIATE); // Generate a reflow command to reflow the dirty frames - //nsIReflowCommand* reflowCmd; - //rv = NS_NewHTMLReflowCommand(&reflowCmd, aDelegatingFrame, nsIReflowCommand::ReflowDirty); + //nsHTMLReflowCommand* reflowCmd; + //rv = NS_NewHTMLReflowCommand(&reflowCmd, aDelegatingFrame, eReflowType_ReflowDirty); //if (NS_SUCCEEDED(rv)) { // reflowCmd->SetChildListName(nsLayoutAtoms::absoluteList); // aPresShell.AppendReflowCommand(reflowCmd); @@ -1048,8 +1048,8 @@ void nsSVGOuterSVGFrame::InitiateReflow() mNeedsReflow = PR_FALSE; // Generate a reflow command to reflow ourselves - nsCOMPtr reflowCmd; - NS_NewHTMLReflowCommand(getter_AddRefs(reflowCmd), this, nsIReflowCommand::ReflowDirty); + nsCOMPtr reflowCmd; + NS_NewHTMLReflowCommand(getter_AddRefs(reflowCmd), this, eReflowType_ReflowDirty); if (!reflowCmd) { NS_ERROR("error creating reflow command object"); return; diff --git a/layout/tables/nsTableCellFrame.cpp b/layout/tables/nsTableCellFrame.cpp index 71c4004fa0b0..6ce64654efe5 100644 --- a/layout/tables/nsTableCellFrame.cpp +++ b/layout/tables/nsTableCellFrame.cpp @@ -40,7 +40,7 @@ #include "nsTableCellFrame.h" #include "nsTableFrame.h" #include "nsTableRowGroupFrame.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" @@ -858,9 +858,9 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext, rv = aReflowState.reflowCommand->GetTarget(target); if ((PR_TRUE==NS_SUCCEEDED(rv)) && target) { if (this == target) { - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); - if (nsIReflowCommand::StyleChanged == type) { + if (eReflowType_StyleChanged == type) { isStyleChanged = PR_TRUE; } else { diff --git a/layout/tables/nsTableColFrame.cpp b/layout/tables/nsTableColFrame.cpp index c40919b7437d..17cd7804237d 100644 --- a/layout/tables/nsTableColFrame.cpp +++ b/layout/tables/nsTableColFrame.cpp @@ -37,7 +37,6 @@ #include "nsCOMPtr.h" #include "nsTableColFrame.h" #include "nsContainerFrame.h" -#include "nsIReflowCommand.h" #include "nsIStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" diff --git a/layout/tables/nsTableColGroupFrame.cpp b/layout/tables/nsTableColGroupFrame.cpp index 945dba1980da..d157c02819d0 100644 --- a/layout/tables/nsTableColGroupFrame.cpp +++ b/layout/tables/nsTableColGroupFrame.cpp @@ -39,7 +39,7 @@ #include "nsTableFrame.h" #include "nsIHTMLTableColElement.h" #include "nsIDOMHTMLTableColElement.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" @@ -551,7 +551,7 @@ NS_METHOD nsTableColGroupFrame::IR_TargetIsMe(nsIPresContext* aPresCont { nsresult rv = NS_OK; aStatus = NS_FRAME_COMPLETE; - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); nsIFrame *objectFrame; aReflowState.reflowCommand->GetChildFrame(objectFrame); @@ -560,11 +560,11 @@ NS_METHOD nsTableColGroupFrame::IR_TargetIsMe(nsIPresContext* aPresCont objectFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay)); switch (type) { - case nsIReflowCommand::StyleChanged : + case eReflowType_StyleChanged : rv = IR_StyleChanged(aPresContext, aDesiredSize, aReflowState, aStatus); break; - case nsIReflowCommand::ContentChanged : + case eReflowType_ContentChanged : NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged"); rv = NS_ERROR_ILLEGAL_VALUE; break; diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 5ff228b0df22..1e4b9d4a0dfe 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -63,7 +63,7 @@ #include "nsIView.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsLayoutAtoms.h" #include "nsIDeviceContext.h" #include "nsIStyleSet.h" @@ -295,7 +295,7 @@ nsTableFrame::Destroy(nsIPresContext* aPresContext) NS_IMETHODIMP nsTableFrame::ReflowCommandNotify(nsIPresShell* aShell, - nsIReflowCommand* aRC, + nsHTMLReflowCommand* aRC, PRBool aCommandAdded) { @@ -305,14 +305,14 @@ nsTableFrame::ReflowCommandNotify(nsIPresShell* aShell, } #ifndef TABLE_REFLOW_COALESCING_OFF - nsIReflowCommand::ReflowType type; + nsReflowType type; aRC->GetType(type); - if ((type == nsIReflowCommand::ContentChanged) || - (type == nsIReflowCommand::StyleChanged) || - (type == nsIReflowCommand::ReflowDirty)) { + if ((type == eReflowType_ContentChanged) || + (type == eReflowType_StyleChanged) || + (type == eReflowType_ReflowDirty)) { mNumDescendantReflowsPending += (aCommandAdded) ? 1 : -1; } - else if (type == nsIReflowCommand::Timeout) { + else if (type == eReflowType_Timeout) { if (aCommandAdded) { mNumDescendantTimeoutReflowsPending++; if (RequestedTimeoutReflow()) { @@ -389,13 +389,12 @@ nsTableFrame::AppendDirtyReflowCommand(nsIPresShell* aPresShell, frameState |= NS_FRAME_IS_DIRTY; // mark the table frame as dirty aFrame->SetFrameState(frameState); - nsIReflowCommand* reflowCmd; + nsHTMLReflowCommand* reflowCmd; nsresult rv = NS_NewHTMLReflowCommand(&reflowCmd, aFrame, - nsIReflowCommand::ReflowDirty); + eReflowType_ReflowDirty); if (NS_SUCCEEDED(rv)) { // Add the reflow command rv = aPresShell->AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); } return rv; @@ -1607,9 +1606,9 @@ PRBool nsTableFrame::NeedsReflow(const nsHTMLReflowState& aReflowState) #ifndef TABLE_REFLOW_COALESCING_OFF nsIFrame* reflowTarget; aReflowState.reflowCommand->GetTarget(reflowTarget); - nsIReflowCommand::ReflowType reflowType; + nsReflowType reflowType; aReflowState.reflowCommand->GetType(reflowType); - if (reflowType == nsIReflowCommand::Timeout) { + if (reflowType == eReflowType_Timeout) { result = PR_FALSE; if (this == reflowTarget) { if (mNumDescendantTimeoutReflowsPending <= 0) { @@ -2032,9 +2031,9 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext, // determine if we need to reset DescendantReflowedNotTimeout and/or // RequestedTimeoutReflow after a timeout reflow. if (aReflowState.reflowCommand) { - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); - if (nsIReflowCommand::Timeout == type) { + if (eReflowType_Timeout == type) { nsIFrame* target = nsnull; aReflowState.reflowCommand->GetTarget(target); if (target == this) { // target is me @@ -2682,7 +2681,7 @@ nsTableFrame::IncrementalReflow(nsIPresContext* aPresContext, nsIFrame* target = nsnull; rv = aReflowState.reflowCommand->GetTarget(target); if (NS_SUCCEEDED(rv) && target) { - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); // this is the target if target is either this or the outer table frame containing this inner frame nsIFrame* outerTableFrame = nsnull; @@ -2713,18 +2712,18 @@ nsTableFrame::IR_TargetIsMe(nsIPresContext* aPresContext, nsresult rv = NS_OK; aStatus = NS_FRAME_COMPLETE; - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowState.reflowCommand->GetType(type); switch (type) { - case nsIReflowCommand::StyleChanged : + case eReflowType_StyleChanged : rv = IR_StyleChanged(aPresContext, aReflowState, aStatus); break; - case nsIReflowCommand::ContentChanged : + case eReflowType_ContentChanged : NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged"); rv = NS_ERROR_ILLEGAL_VALUE; break; - case nsIReflowCommand::ReflowDirty: { + case eReflowType_ReflowDirty: { // reflow the dirty children nsTableReflowState reflowState(aReflowState.reflowState, *this, eReflowReason_Initial, aReflowState.availSize.width, aReflowState.availSize.height); @@ -2735,7 +2734,7 @@ nsTableFrame::IR_TargetIsMe(nsIPresContext* aPresContext, SetNeedStrategyInit(PR_TRUE); } break; - case nsIReflowCommand::Timeout: { + case eReflowType_Timeout: { // for a timeout reflow, don't do anything here break; } @@ -2864,9 +2863,9 @@ nsTableFrame::IR_TargetIsChild(nsIPresContext* aPresContext, #ifndef TABLE_REFLOW_COALESCING_OFF // update the descendant reflow counts and determine if we need to request a timeout reflow PRBool needToRequestTimeoutReflow = PR_FALSE; - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowState.reflowCommand->GetType(type); - if (nsIReflowCommand::Timeout == type) { + if (eReflowType_Timeout == type) { mNumDescendantTimeoutReflowsPending--; NS_ASSERTION(mNumDescendantTimeoutReflowsPending >= 0, "invalid descendant reflow count"); } @@ -4877,9 +4876,9 @@ void nsTableFrame::DebugReflow(nsIFrame* aFrame, timer->mComputedWidth = aState.mComputedWidth; timer->mComputedHeight = aState.mComputedHeight; timer->mCount = gRflCount++; - nsIReflowCommand* reflowCommand = aState.reflowCommand; + nsHTMLReflowCommand* reflowCommand = aState.reflowCommand; if (reflowCommand) { - nsIReflowCommand::ReflowType reflowType; + nsReflowType reflowType; reflowCommand->GetType(reflowType); timer->mReflowType = reflowType; } diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index a81d25848b76..4862e4a92c28 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -562,9 +562,9 @@ public: // increment or decrement the count of pending reflow commands targeted at // descendants. Only rebalance the table when this count goes to 0 or the // reflow is the last one in a batch (limited by the pres shell). - NS_IMETHOD ReflowCommandNotify(nsIPresShell* aShell, - nsIReflowCommand* aRC, - PRBool aCommandAdded); + NS_IMETHOD ReflowCommandNotify(nsIPresShell* aShell, + nsHTMLReflowCommand* aRC, + PRBool aCommandAdded); PRBool IsRowInserted() const; void SetRowInserted(PRBool aValue); diff --git a/layout/tables/nsTableOuterFrame.cpp b/layout/tables/nsTableOuterFrame.cpp index 1810ebe0ae00..7d0bc101bdd2 100644 --- a/layout/tables/nsTableOuterFrame.cpp +++ b/layout/tables/nsTableOuterFrame.cpp @@ -37,7 +37,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsTableOuterFrame.h" #include "nsTableFrame.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" @@ -260,13 +260,11 @@ nsTableOuterFrame::AppendFrames(nsIPresContext* aPresContext, // Reflow the new caption frame. It's already marked dirty, so generate a reflow // command that tells us to reflow our dirty child frames - nsIReflowCommand* reflowCmd; + nsHTMLReflowCommand* reflowCmd; - rv = NS_NewHTMLReflowCommand(&reflowCmd, this, nsIReflowCommand::ReflowDirty); - if (NS_SUCCEEDED(rv)) { + rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ReflowDirty); + if (NS_SUCCEEDED(rv)) aPresShell.AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); - } } } else { @@ -319,13 +317,11 @@ nsTableOuterFrame::RemoveFrame(nsIPresContext* aPresContext, } // Generate a reflow command so we get reflowed - nsIReflowCommand* reflowCmd; + nsHTMLReflowCommand* reflowCmd; - rv = NS_NewHTMLReflowCommand(&reflowCmd, this, nsIReflowCommand::ReflowDirty); - if (NS_SUCCEEDED(rv)) { + rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ReflowDirty); + if (NS_SUCCEEDED(rv)) aPresShell.AppendReflowCommand(reflowCmd); - NS_RELEASE(reflowCmd); - } return NS_OK; } @@ -1112,9 +1108,9 @@ nsTableOuterFrame::IR_TargetIsCaptionFrame(nsIPresContext* aPresContex nsSize containSize = GetContainingBlockSize(aOuterRS); // for now just reflow the table if a style changed. This should be improved - nsIReflowCommand::ReflowType reflowCommandType; + nsReflowType reflowCommandType; aOuterRS.reflowCommand->GetType(reflowCommandType); - PRBool needInnerReflow = (nsIReflowCommand::StyleChanged == reflowCommandType) + PRBool needInnerReflow = (eReflowType_StyleChanged == reflowCommandType) ? PR_TRUE : PR_FALSE; if (mMinCaptionWidth != captionMES.width) { @@ -1234,21 +1230,21 @@ nsresult nsTableOuterFrame::IR_TargetIsMe(nsIPresContext* aPresContext nsReflowStatus& aStatus) { nsresult rv = NS_OK; - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); nsIFrame* objectFrame; aReflowState.reflowCommand->GetChildFrame(objectFrame); switch (type) { - case nsIReflowCommand::ReflowDirty: + case eReflowType_ReflowDirty: rv = IR_ReflowDirty(aPresContext, aDesiredSize, aReflowState, aStatus); break; - case nsIReflowCommand::StyleChanged : - case nsIReflowCommand::Timeout : + case eReflowType_StyleChanged : + case eReflowType_Timeout : rv = IR_InnerTableReflow(aPresContext, aDesiredSize, aReflowState, aStatus); break; - case nsIReflowCommand::ContentChanged : + case eReflowType_ContentChanged : NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged"); rv = NS_ERROR_ILLEGAL_VALUE; break; @@ -1288,9 +1284,9 @@ nsTableOuterFrame::IR_InnerTableReflow(nsIPresContext* aPresContext, nsIFrame* target = nsnull; aOuterRS.reflowCommand->GetTarget(target); if (this == target) { - nsIReflowCommand::ReflowType type; + nsReflowType type; aOuterRS.reflowCommand->GetType(type); - if (nsIReflowCommand::StyleChanged == type) { + if (eReflowType_StyleChanged == type) { ReflowReason = eReflowReason_StyleChange; } } diff --git a/layout/tables/nsTableRowFrame.cpp b/layout/tables/nsTableRowFrame.cpp index 29acf0f9994b..8fd988c0139d 100644 --- a/layout/tables/nsTableRowFrame.cpp +++ b/layout/tables/nsTableRowFrame.cpp @@ -47,7 +47,7 @@ #include "nsTableFrame.h" #include "nsTableCellFrame.h" #include "nsIView.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsCSSRendering.h" #include "nsHTMLIIDs.h" #include "nsLayoutAtoms.h" @@ -924,9 +924,9 @@ nsTableRowFrame::ReflowChildren(nsIPresContext* aPresContext, if (eReflowReason_Incremental == aReflowState.reason) { aReflowState.reflowCommand->GetTarget(target); if (this == target) { - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); - if (nsIReflowCommand::StyleChanged == type) { + if (eReflowType_StyleChanged == type) { notifyStyleChange = PR_TRUE; } } @@ -1166,17 +1166,17 @@ nsTableRowFrame::IR_TargetIsMe(nsIPresContext* aPresContext, { nsresult rv = NS_FRAME_COMPLETE; - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); switch (type) { - case nsIReflowCommand::ReflowDirty: + case eReflowType_ReflowDirty: // Reflow the dirty child frames. Typically this is newly added frames. rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, aTableFrame, aStatus, PR_TRUE); break; - case nsIReflowCommand::StyleChanged : + case eReflowType_StyleChanged : rv = IR_StyleChanged(aPresContext, aDesiredSize, aReflowState, aTableFrame, aStatus); break; - case nsIReflowCommand::ContentChanged : + case eReflowType_ContentChanged : NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged"); rv = NS_ERROR_ILLEGAL_VALUE; break; diff --git a/layout/tables/nsTableRowGroupFrame.cpp b/layout/tables/nsTableRowGroupFrame.cpp index b4813971eff1..0fffa286c3e2 100644 --- a/layout/tables/nsTableRowGroupFrame.cpp +++ b/layout/tables/nsTableRowGroupFrame.cpp @@ -45,7 +45,7 @@ #include "nsStyleConsts.h" #include "nsIContent.h" #include "nsIView.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsHTMLIIDs.h" #include "nsIDeviceContext.h" #include "nsHTMLAtoms.h" @@ -430,9 +430,9 @@ nsTableRowGroupFrame::ReflowChildren(nsIPresContext* aPresContext, if (eReflowReason_Incremental == aReflowState.reason) { aReflowState.reflowState.reflowCommand->GetTarget(target); if (this == target) { - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowState.reflowCommand->GetType(type); - if (nsIReflowCommand::StyleChanged == type) { + if (eReflowType_StyleChanged == type) { reason = eReflowReason_StyleChange; } } @@ -1356,11 +1356,11 @@ nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext* aPresContext, nsReflowStatus& aStatus) { nsresult rv = NS_FRAME_COMPLETE; - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowState.reflowCommand->GetType(type); switch (type) { - case nsIReflowCommand::ReflowDirty: { + case eReflowType_ReflowDirty: { nsRowGroupReflowState state(aReflowState); state.reason = eReflowReason_Resize; // Reflow the dirty child frames. Typically this is newly added frames. @@ -1370,10 +1370,10 @@ nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext* aPresContext, CalculateRowHeights(aPresContext, aDesiredSize, aReflowState.reflowState, firstRowReflowed); break; } - case nsIReflowCommand::StyleChanged : + case eReflowType_StyleChanged : rv = IR_StyleChanged(aPresContext, aDesiredSize, aReflowState, aStatus); break; - case nsIReflowCommand::ContentChanged : + case eReflowType_ContentChanged : NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged"); rv = NS_ERROR_ILLEGAL_VALUE; break; diff --git a/layout/xul/base/src/nsBox.cpp b/layout/xul/base/src/nsBox.cpp index 613cb662c885..0f50078138ce 100644 --- a/layout/xul/base/src/nsBox.cpp +++ b/layout/xul/base/src/nsBox.cpp @@ -328,7 +328,7 @@ nsBox::MarkStyleChange(nsBoxLayoutState& aState) nsIFrame* frame = nsnull; GetFrame(&frame); nsFrame::CreateAndPostReflowCommand(shell, frame, - nsIReflowCommand::StyleChange, nsnull, nsnull, nsnull); + nsHTMLReflowCommand::StyleChange, nsnull, nsnull, nsnull); return NS_OK; */ nsIFrame* frame = nsnull; @@ -423,7 +423,7 @@ nsBox::RelayoutStyleChange(nsBoxLayoutState& aState, nsIBox* aChild) nsIFrame* frame = nsnull; aChild->GetFrame(&frame); nsFrame::CreateAndPostReflowCommand(shell, frame, - nsIReflowCommand::StyleChanged, nsnull, nsnull, nsnull); + eReflowType_StyleChanged, nsnull, nsnull, nsnull); return NS_OK; } } else { diff --git a/layout/xul/base/src/nsBoxFrame.cpp b/layout/xul/base/src/nsBoxFrame.cpp index 128dfb01f407..3e72d5f3aabb 100644 --- a/layout/xul/base/src/nsBoxFrame.cpp +++ b/layout/xul/base/src/nsBoxFrame.cpp @@ -73,7 +73,6 @@ #include "nsINameSpaceManager.h" #include "nsHTMLAtoms.h" #include "nsXULAtoms.h" -#include "nsIReflowCommand.h" #include "nsIContent.h" #include "nsSpaceManager.h" #include "nsHTMLParts.h" diff --git a/layout/xul/base/src/nsBoxLayoutState.cpp b/layout/xul/base/src/nsBoxLayoutState.cpp index 42fa8c66ef3a..3f63860b586c 100644 --- a/layout/xul/base/src/nsBoxLayoutState.cpp +++ b/layout/xul/base/src/nsBoxLayoutState.cpp @@ -43,7 +43,7 @@ // #include "nsBoxLayoutState.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsBoxFrame.h" #include "nsIStyleContext.h" #include "nsHTMLAtoms.h" @@ -186,13 +186,13 @@ nsBoxLayoutState::HandleReflow(nsIBox* aRootBox) void -nsBoxLayoutState::UnWind(nsIReflowCommand* aCommand, nsIBox* aBox) +nsBoxLayoutState::UnWind(nsHTMLReflowCommand* aCommand, nsIBox* aBox) { // if incremental unwindow the chain nsIFrame* incrementalChild = nsnull; nsIFrame* target = nsnull; aCommand->GetTarget(target); - nsIReflowCommand::ReflowType type; + nsReflowType type; mReflowState->reflowCommand->GetType(type); while(1) @@ -227,7 +227,7 @@ nsBoxLayoutState::UnWind(nsIReflowCommand* aCommand, nsIBox* aBox) // mark it dirty generating a new reflow command targeted // at us and coelesce out this one. - if (type == nsIReflowCommand::StyleChanged) { + if (type == eReflowType_StyleChanged) { ibox->MarkStyleChange(*this); // could be a visiblity change. Like collapse so we need to dirty @@ -290,7 +290,7 @@ nsBoxLayoutState::UnWind(nsIReflowCommand* aCommand, nsIBox* aBox) /* void -nsBoxLayoutState::UnWind(nsIReflowCommand* aCommand, nsIBox* aBox) +nsBoxLayoutState::UnWind(nsHTMLReflowCommand* aCommand, nsIBox* aBox) { nsFrameState state; @@ -333,7 +333,7 @@ nsBoxLayoutState::UnWind(nsIReflowCommand* aCommand, nsIBox* aBox) */ nsIBox* -nsBoxLayoutState::GetTargetBox(nsIReflowCommand* mCommand, PRBool& aIsAdaptor) +nsBoxLayoutState::GetTargetBox(nsHTMLReflowCommand* mCommand, PRBool& aIsAdaptor) { nsIFrame* target = nsnull; mReflowState->reflowCommand->GetTarget(target); diff --git a/layout/xul/base/src/nsBoxLayoutState.h b/layout/xul/base/src/nsBoxLayoutState.h index d722b03e1ddb..00911b922805 100644 --- a/layout/xul/base/src/nsBoxLayoutState.h +++ b/layout/xul/base/src/nsBoxLayoutState.h @@ -56,7 +56,7 @@ class nsCalculatedBoxInfo; struct nsHTMLReflowMetrics; class nsString; class nsIBox; -class nsIReflowCommand; +class nsHTMLReflowCommand; class nsBoxLayoutState { @@ -104,8 +104,8 @@ public: private: //void DirtyAllChildren(nsBoxLayoutState& aState, nsIBox* aBox); - void UnWind(nsIReflowCommand* aCommand, nsIBox* aRootBox); - nsIBox* GetTargetBox(nsIReflowCommand* mCommand, PRBool& aIsAdaptor); + void UnWind(nsHTMLReflowCommand* aCommand, nsIBox* aRootBox); + nsIBox* GetTargetBox(nsHTMLReflowCommand* mCommand, PRBool& aIsAdaptor); nsIBox* GetBoxForFrame(nsIFrame* aFrame, PRBool& aIsAdaptor); nsCOMPtr mPresContext; diff --git a/layout/xul/base/src/nsBoxToBlockAdaptor.cpp b/layout/xul/base/src/nsBoxToBlockAdaptor.cpp index bd367e9c34c0..251f14c6ce44 100644 --- a/layout/xul/base/src/nsBoxToBlockAdaptor.cpp +++ b/layout/xul/base/src/nsBoxToBlockAdaptor.cpp @@ -52,7 +52,7 @@ #include "nsINameSpaceManager.h" #include "nsHTMLAtoms.h" #include "nsXULAtoms.h" -#include "nsIReflowCommand.h" +#include "nsHTMLReflowCommand.h" #include "nsIContent.h" #include "nsSpaceManager.h" #include "nsHTMLParts.h" @@ -111,13 +111,13 @@ nsAdaptorPrintReason(nsHTMLReflowState& aReflowState) break; case eReflowReason_Incremental: { - nsIReflowCommand::ReflowType type; + nsReflowType type; aReflowState.reflowCommand->GetType(type); switch (type) { - case nsIReflowCommand::StyleChanged: + case eReflowType_StyleChanged: reflowReasonString = "incremental (StyleChanged)"; break; - case nsIReflowCommand::ReflowDirty: + case eReflowType_ReflowDirty: reflowReasonString = "incremental (ReflowDirty)"; break; default: @@ -793,10 +793,10 @@ nsBoxToBlockAdaptor::Reflow(nsBoxLayoutState& aState, reflowState.reason = eReflowReason_StyleChange; } else if (reason == eReflowReason_Incremental) { - nsIReflowCommand::ReflowType type; + nsReflowType type; reflowState.reflowCommand->GetType(type); - if (type != nsIReflowCommand::StyleChanged) { + if (type != eReflowType_StyleChanged) { #ifdef DEBUG_REFLOW nsAdaptorAddIndents(); printf("Size=(%d,%d)\n",reflowState.mComputedWidth, reflowState.mComputedHeight); @@ -1062,10 +1062,10 @@ nsBoxToBlockAdaptor::CanSetMaxElementSize(nsBoxLayoutState& aState, nsReflowReas if (reflowState->reason == eReflowReason_Incremental) { if (reflowState->reflowCommand) { // MaxElement doesn't work on style change reflows.. :-( - nsIReflowCommand::ReflowType type; + nsReflowType type; reflowState->reflowCommand->GetType(type); - if (type == nsIReflowCommand::StyleChanged) + if (type == eReflowType_StyleChanged) return PR_FALSE; } diff --git a/layout/xul/base/src/nsContainerBox.cpp b/layout/xul/base/src/nsContainerBox.cpp index 009d046c75a8..e9997d34e033 100644 --- a/layout/xul/base/src/nsContainerBox.cpp +++ b/layout/xul/base/src/nsContainerBox.cpp @@ -66,7 +66,6 @@ #include "nsINameSpaceManager.h" #include "nsHTMLAtoms.h" #include "nsXULAtoms.h" -#include "nsIReflowCommand.h" #include "nsIContent.h" #include "nsHTMLParts.h" #include "nsIViewManager.h" diff --git a/layout/xul/base/src/nsDeckFrame.cpp b/layout/xul/base/src/nsDeckFrame.cpp index 77248aedb34c..7c5077d8e8d5 100644 --- a/layout/xul/base/src/nsDeckFrame.cpp +++ b/layout/xul/base/src/nsDeckFrame.cpp @@ -52,7 +52,6 @@ #include "nsINameSpaceManager.h" #include "nsXULAtoms.h" #include "nsHTMLAtoms.h" -#include "nsIReflowCommand.h" #include "nsHTMLParts.h" #include "nsIPresShell.h" #include "nsStyleChangeList.h" diff --git a/layout/xul/base/src/nsDocElementBoxFrame.cpp b/layout/xul/base/src/nsDocElementBoxFrame.cpp index e89ad8429391..30a76bbfa2d8 100644 --- a/layout/xul/base/src/nsDocElementBoxFrame.cpp +++ b/layout/xul/base/src/nsDocElementBoxFrame.cpp @@ -38,7 +38,6 @@ #include "nsContainerFrame.h" #include "nsCSSRendering.h" #include "nsIDocument.h" -#include "nsIReflowCommand.h" #include "nsIPresContext.h" #include "nsIStyleContext.h" #include "nsViewsCID.h" diff --git a/layout/xul/base/src/nsGrippyFrame.cpp b/layout/xul/base/src/nsGrippyFrame.cpp index a77bf526bb22..c6e3de6f61eb 100644 --- a/layout/xul/base/src/nsGrippyFrame.cpp +++ b/layout/xul/base/src/nsGrippyFrame.cpp @@ -53,7 +53,6 @@ #include "nsINameSpaceManager.h" #include "nsHTMLAtoms.h" #include "nsXULAtoms.h" -#include "nsIReflowCommand.h" //#include "nsSliderFrame.h" #include "nsIDOMElement.h" #include "nsIDOMDocument.h" diff --git a/layout/xul/base/src/nsMenuFrame.cpp b/layout/xul/base/src/nsMenuFrame.cpp index 67b703162c3b..013b23cb5546 100644 --- a/layout/xul/base/src/nsMenuFrame.cpp +++ b/layout/xul/base/src/nsMenuFrame.cpp @@ -50,7 +50,6 @@ #include "nsIPresContext.h" #include "nsIPresShell.h" #include "nsIStyleContext.h" -#include "nsIReflowCommand.h" #include "nsCSSRendering.h" #include "nsINameSpaceManager.h" #include "nsLayoutAtoms.h" diff --git a/layout/xul/base/src/nsPopupSetFrame.cpp b/layout/xul/base/src/nsPopupSetFrame.cpp index 155247f39a03..d48e049a5a72 100644 --- a/layout/xul/base/src/nsPopupSetFrame.cpp +++ b/layout/xul/base/src/nsPopupSetFrame.cpp @@ -49,7 +49,6 @@ #include "nsIAtom.h" #include "nsIPresContext.h" #include "nsIStyleContext.h" -#include "nsIReflowCommand.h" #include "nsCSSRendering.h" #include "nsINameSpaceManager.h" #include "nsLayoutAtoms.h" diff --git a/layout/xul/base/src/nsRootBoxFrame.cpp b/layout/xul/base/src/nsRootBoxFrame.cpp index b698cfa37cb0..68340ee0a98d 100644 --- a/layout/xul/base/src/nsRootBoxFrame.cpp +++ b/layout/xul/base/src/nsRootBoxFrame.cpp @@ -38,7 +38,6 @@ #include "nsContainerFrame.h" #include "nsCSSRendering.h" #include "nsIDocument.h" -#include "nsIReflowCommand.h" #include "nsIPresContext.h" #include "nsIStyleContext.h" #include "nsViewsCID.h" diff --git a/layout/xul/base/src/nsScrollBoxFrame.cpp b/layout/xul/base/src/nsScrollBoxFrame.cpp index 855f03316555..3e95796722bf 100644 --- a/layout/xul/base/src/nsScrollBoxFrame.cpp +++ b/layout/xul/base/src/nsScrollBoxFrame.cpp @@ -41,7 +41,6 @@ #include "nsCOMPtr.h" #include "nsHTMLParts.h" #include "nsIPresContext.h" -#include "nsIReflowCommand.h" #include "nsIDeviceContext.h" #include "nsPageFrame.h" #include "nsViewsCID.h" diff --git a/layout/xul/base/src/nsScrollbarButtonFrame.cpp b/layout/xul/base/src/nsScrollbarButtonFrame.cpp index e80a123b5404..ce0a08a0e8a3 100644 --- a/layout/xul/base/src/nsScrollbarButtonFrame.cpp +++ b/layout/xul/base/src/nsScrollbarButtonFrame.cpp @@ -52,7 +52,6 @@ #include "nsINameSpaceManager.h" #include "nsHTMLAtoms.h" #include "nsXULAtoms.h" -#include "nsIReflowCommand.h" #include "nsSliderFrame.h" #include "nsIScrollbarFrame.h" #include "nsIScrollbarMediator.h" diff --git a/layout/xul/base/src/nsSliderFrame.cpp b/layout/xul/base/src/nsSliderFrame.cpp index 209ee2d4f934..f57b34055c78 100644 --- a/layout/xul/base/src/nsSliderFrame.cpp +++ b/layout/xul/base/src/nsSliderFrame.cpp @@ -53,7 +53,6 @@ #include "nsINameSpaceManager.h" #include "nsXULAtoms.h" #include "nsHTMLAtoms.h" -#include "nsIReflowCommand.h" #include "nsHTMLParts.h" #include "nsIPresShell.h" #include "nsStyleChangeList.h" diff --git a/layout/xul/base/src/nsSplitterFrame.cpp b/layout/xul/base/src/nsSplitterFrame.cpp index 2a3095200809..1ca41a9d757a 100644 --- a/layout/xul/base/src/nsSplitterFrame.cpp +++ b/layout/xul/base/src/nsSplitterFrame.cpp @@ -652,9 +652,9 @@ nsSplitterFrameInner::MouseDrag(nsIPresContext* aPresContext, nsGUIEvent* aEvent nsCOMPtr shell; aPresContext->GetShell(getter_AddRefs(shell)); - nsCOMPtr reflowCmd; + nsCOMPtr reflowCmd; nsresult rv = NS_NewHTMLReflowCommand(getter_AddRefs(reflowCmd), mOuter->mParent, - nsIReflowCommand::StyleChanged); + eReflowType_StyleChanged); if (NS_SUCCEEDED(rv)) shell->AppendReflowCommand(reflowCmd); diff --git a/layout/xul/base/src/nsStackFrame.cpp b/layout/xul/base/src/nsStackFrame.cpp index 0af01210766b..eeee7b21b268 100644 --- a/layout/xul/base/src/nsStackFrame.cpp +++ b/layout/xul/base/src/nsStackFrame.cpp @@ -52,7 +52,6 @@ #include "nsINameSpaceManager.h" #include "nsXULAtoms.h" #include "nsHTMLAtoms.h" -#include "nsIReflowCommand.h" #include "nsHTMLParts.h" #include "nsIPresShell.h" #include "nsStyleChangeList.h"