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;