Added a new method GetCanvasFrame which walks down from the root frame looking for the frame that represents the canvas. b=40217 r=kmcclusk a=karnaze

This commit is contained in:
attinasi%netscape.com 2000-05-31 22:33:12 +00:00
Родитель 10cd56f365
Коммит 009460e9a7
3 изменённых файлов: 78 добавлений и 0 удалений

Просмотреть файл

@ -177,6 +177,9 @@ public:
NS_IMETHOD GetRootFrame(nsIFrame** aRootFrame) const;
NS_IMETHOD SetRootFrame(nsIFrame* aRootFrame);
// Get the canvas frame: searches from the Root frame down, may be null
NS_IMETHOD GetCanvasFrame(nsIPresContext* aPresContext, nsIFrame** aCanvasFrame) const;
// Primary frame functions
NS_IMETHOD GetPrimaryFrameFor(nsIContent* aContent, nsIFrame** aPrimaryFrame);
NS_IMETHOD SetPrimaryFrameFor(nsIContent* aContent,
@ -408,6 +411,40 @@ FrameManager::SetRootFrame(nsIFrame* aRootFrame)
return NS_OK;
}
NS_IMETHODIMP
FrameManager::GetCanvasFrame(nsIPresContext* aPresContext, nsIFrame** aCanvasFrame) const
{
NS_PRECONDITION(aCanvasFrame, "aCanvasFrame argument cannot be null");
NS_PRECONDITION(aPresContext, "aPresContext argument cannot be null");
*aCanvasFrame = nsnull;
if (mRootFrame) {
// walk the children of the root frame looking for a frame with type==canvas
// start at the root
nsIFrame* childFrame = mRootFrame;
while (childFrame) {
// get each sibling of the child and check them, startig at the child
nsIFrame *siblingFrame = childFrame;
while (siblingFrame) {
nsCOMPtr<nsIAtom> frameType;
siblingFrame->GetFrameType(getter_AddRefs(frameType));
if (frameType.get() == nsLayoutAtoms::canvasFrame) {
// this is it: set the out-arg and stop looking
*aCanvasFrame = siblingFrame;
break;
} else {
siblingFrame->GetNextSibling(&siblingFrame);
}
}
// move on to the child's child
childFrame->FirstChild(aPresContext, nsnull, &childFrame);
}
NS_ASSERTION(*aCanvasFrame != nsnull, "CanvasFrame could not be found and should be");
}
return NS_OK;
}
//----------------------------------------------------------------------
// Primary frame functions

Просмотреть файл

@ -78,6 +78,10 @@ public:
NS_IMETHOD GetRootFrame(nsIFrame** aRootFrame) const = 0;
NS_IMETHOD SetRootFrame(nsIFrame* aRootFrame) = 0;
// Get the canvas frame. The canvas frame may or may not exist, so the
// argument aCanvasFrame may be nsnull.
NS_IMETHOD GetCanvasFrame(nsIPresContext* aPresContext, nsIFrame** aCanvasFrame) const = 0;
// Primary frame functions
NS_IMETHOD GetPrimaryFrameFor(nsIContent* aContent, nsIFrame** aPrimaryFrame) = 0;
NS_IMETHOD SetPrimaryFrameFor(nsIContent* aContent,

Просмотреть файл

@ -177,6 +177,9 @@ public:
NS_IMETHOD GetRootFrame(nsIFrame** aRootFrame) const;
NS_IMETHOD SetRootFrame(nsIFrame* aRootFrame);
// Get the canvas frame: searches from the Root frame down, may be null
NS_IMETHOD GetCanvasFrame(nsIPresContext* aPresContext, nsIFrame** aCanvasFrame) const;
// Primary frame functions
NS_IMETHOD GetPrimaryFrameFor(nsIContent* aContent, nsIFrame** aPrimaryFrame);
NS_IMETHOD SetPrimaryFrameFor(nsIContent* aContent,
@ -408,6 +411,40 @@ FrameManager::SetRootFrame(nsIFrame* aRootFrame)
return NS_OK;
}
NS_IMETHODIMP
FrameManager::GetCanvasFrame(nsIPresContext* aPresContext, nsIFrame** aCanvasFrame) const
{
NS_PRECONDITION(aCanvasFrame, "aCanvasFrame argument cannot be null");
NS_PRECONDITION(aPresContext, "aPresContext argument cannot be null");
*aCanvasFrame = nsnull;
if (mRootFrame) {
// walk the children of the root frame looking for a frame with type==canvas
// start at the root
nsIFrame* childFrame = mRootFrame;
while (childFrame) {
// get each sibling of the child and check them, startig at the child
nsIFrame *siblingFrame = childFrame;
while (siblingFrame) {
nsCOMPtr<nsIAtom> frameType;
siblingFrame->GetFrameType(getter_AddRefs(frameType));
if (frameType.get() == nsLayoutAtoms::canvasFrame) {
// this is it: set the out-arg and stop looking
*aCanvasFrame = siblingFrame;
break;
} else {
siblingFrame->GetNextSibling(&siblingFrame);
}
}
// move on to the child's child
childFrame->FirstChild(aPresContext, nsnull, &childFrame);
}
NS_ASSERTION(*aCanvasFrame != nsnull, "CanvasFrame could not be found and should be");
}
return NS_OK;
}
//----------------------------------------------------------------------
// Primary frame functions