From 05e293d03eddd3a2cb08a3cc7ff419e47e50a5c4 Mon Sep 17 00:00:00 2001 From: "troy%netscape.com" Date: Thu, 3 Feb 2000 00:51:37 +0000 Subject: [PATCH] r=vidur@netscape.com Performance. Added NS_FRAME_HAS_VIEW frame state flag so we can quickly tell whether the frame has an associated view git-svn-id: svn://10.0.0.236/trunk@59586 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/public/nsIFrame.h | 3 +++ mozilla/layout/generic/nsFrame.cpp | 29 +++++++++++++++--------- mozilla/layout/generic/nsIFrame.h | 3 +++ mozilla/layout/html/base/src/nsFrame.cpp | 29 +++++++++++++++--------- 4 files changed, 42 insertions(+), 22 deletions(-) diff --git a/mozilla/layout/base/public/nsIFrame.h b/mozilla/layout/base/public/nsIFrame.h index ab9c378d3d5..b845c520043 100644 --- a/mozilla/layout/base/public/nsIFrame.h +++ b/mozilla/layout/base/public/nsIFrame.h @@ -168,6 +168,9 @@ typedef PRUint32 nsFrameState; // If this bit is set, the frame has dirty children. #define NS_FRAME_HAS_DIRTY_CHILDREN 0x00001000 +// If this bit is set, the frame has an associated view +#define NS_FRAME_HAS_VIEW 0x00002000 + // The low 16 bits of the frame state word are reserved by this API. #define NS_FRAME_RESERVED 0x0000FFFF diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 3207a2864b6..a068cd83229 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -1406,18 +1406,22 @@ NS_IMETHODIMP nsFrame::GetView(nsIPresContext* aPresContext, nsIView** aView) co // Initialize OUT parameter *aView = nsnull; - // Check for a property on the frame - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - - if (presShell) { - nsCOMPtr frameManager; - presShell->GetFrameManager(getter_AddRefs(frameManager)); + // Check the frame state bit and see if the frame has a view + if (mState & NS_FRAME_HAS_VIEW) { + // Check for a property on the frame + nsCOMPtr presShell; + aPresContext->GetShell(getter_AddRefs(presShell)); - if (frameManager) { - void* value; - frameManager->GetFrameProperty((nsIFrame*)this, nsLayoutAtoms::viewProperty, 0, &value); - *aView = (nsIView*)value; + if (presShell) { + nsCOMPtr frameManager; + presShell->GetFrameManager(getter_AddRefs(frameManager)); + + if (frameManager) { + void* value; + frameManager->GetFrameProperty((nsIFrame*)this, nsLayoutAtoms::viewProperty, 0, &value); + *aView = (nsIView*)value; + NS_ASSERTION(value != 0, "frame state bit was set but frame has no view"); + } } } @@ -1442,6 +1446,9 @@ NS_IMETHODIMP nsFrame::SetView(nsIPresContext* aPresContext, nsIView* aView) aView, nsnull); } } + + // Set the frame state bit that says the frame has a view + mState |= NS_FRAME_HAS_VIEW; } return NS_OK; diff --git a/mozilla/layout/generic/nsIFrame.h b/mozilla/layout/generic/nsIFrame.h index ab9c378d3d5..b845c520043 100644 --- a/mozilla/layout/generic/nsIFrame.h +++ b/mozilla/layout/generic/nsIFrame.h @@ -168,6 +168,9 @@ typedef PRUint32 nsFrameState; // If this bit is set, the frame has dirty children. #define NS_FRAME_HAS_DIRTY_CHILDREN 0x00001000 +// If this bit is set, the frame has an associated view +#define NS_FRAME_HAS_VIEW 0x00002000 + // The low 16 bits of the frame state word are reserved by this API. #define NS_FRAME_RESERVED 0x0000FFFF diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index 3207a2864b6..a068cd83229 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -1406,18 +1406,22 @@ NS_IMETHODIMP nsFrame::GetView(nsIPresContext* aPresContext, nsIView** aView) co // Initialize OUT parameter *aView = nsnull; - // Check for a property on the frame - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - - if (presShell) { - nsCOMPtr frameManager; - presShell->GetFrameManager(getter_AddRefs(frameManager)); + // Check the frame state bit and see if the frame has a view + if (mState & NS_FRAME_HAS_VIEW) { + // Check for a property on the frame + nsCOMPtr presShell; + aPresContext->GetShell(getter_AddRefs(presShell)); - if (frameManager) { - void* value; - frameManager->GetFrameProperty((nsIFrame*)this, nsLayoutAtoms::viewProperty, 0, &value); - *aView = (nsIView*)value; + if (presShell) { + nsCOMPtr frameManager; + presShell->GetFrameManager(getter_AddRefs(frameManager)); + + if (frameManager) { + void* value; + frameManager->GetFrameProperty((nsIFrame*)this, nsLayoutAtoms::viewProperty, 0, &value); + *aView = (nsIView*)value; + NS_ASSERTION(value != 0, "frame state bit was set but frame has no view"); + } } } @@ -1442,6 +1446,9 @@ NS_IMETHODIMP nsFrame::SetView(nsIPresContext* aPresContext, nsIView* aView) aView, nsnull); } } + + // Set the frame state bit that says the frame has a view + mState |= NS_FRAME_HAS_VIEW; } return NS_OK;