Remove the mPresShell member of nsBoxObject, and some other cleanup. Bug

329181, r=neil, sr=jst
This commit is contained in:
bzbarsky%mit.edu 2006-03-07 03:20:39 +00:00
Родитель abf9d4ba14
Коммит 9b57d8e873
14 изменённых файлов: 175 добавлений и 362 удалений

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

@ -3322,10 +3322,6 @@ nsDocument::GetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject** aResult)
}
}
nsIPresShell *shell = GetShellAt(0);
if (!shell)
return NS_ERROR_FAILURE;
PRInt32 namespaceID;
nsCOMPtr<nsIAtom> tag;
nsCOMPtr<nsIXBLService> xblService =
@ -3360,11 +3356,7 @@ nsDocument::GetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject** aResult)
return NS_ERROR_FAILURE;
nsCOMPtr<nsPIBoxObject> privateBox(do_QueryInterface(boxObject));
rv = privateBox->Init(content, shell);
if (NS_FAILED(rv)) {
return rv;
}
privateBox->Init(content);
SetBoxObjectFor(aElement, boxObject);
@ -3392,7 +3384,7 @@ nsDocument::SetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject* aBoxObject)
mBoxObjectTable->Remove(&key, getter_AddRefs(supp));
nsCOMPtr<nsPIBoxObject> boxObject(do_QueryInterface(supp));
if (boxObject) {
boxObject->SetDocument(nsnull);
boxObject->Clear();
}
}

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

@ -63,9 +63,10 @@ class nsIURI;
class nsIContent;
class nsIRDFDataSource;
// {954F0811-81DC-11d2-B52A-000000000000}
// {7f9c0158-1da3-4279-9ee5-fa7931b94db1}
#define NS_IXULDOCUMENT_IID \
{ 0x954f0811, 0x81dc, 0x11d2, { 0xb5, 0x2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
{ 0x7f9c0158, 0x1da3, 0x4279, \
{ 0x9e, 0xe5, 0xfa, 0x79, 0x31, 0xb9, 0x4d, 0xb1 } }
/**
* XUL extensions to nsIDocument
@ -151,11 +152,6 @@ public:
* request than the one whose document is being notified here.
*/
NS_IMETHOD OnPrototypeLoadDone() = 0;
/**
* Notify the XUL document that it's being hidden
*/
NS_IMETHOD OnHide() = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIXULDocument, NS_IXULDOCUMENT_IID)

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

@ -685,30 +685,6 @@ nsXULDocument::OnPrototypeLoadDone()
return ResumeWalk();
}
PR_STATIC_CALLBACK(PRBool)
ClearPresentationStuff(nsHashKey *aKey, void *aData, void* aClosure)
{
nsISupports *supp = NS_STATIC_CAST(nsISupports *, aData);
nsCOMPtr<nsPIBoxObject> boxObject(do_QueryInterface(supp));
if (boxObject) {
boxObject->InvalidatePresentationStuff();
}
return PR_TRUE;
}
NS_IMETHODIMP
nsXULDocument::OnHide()
{
if (mBoxObjectTable) {
mBoxObjectTable->Enumerate(ClearPresentationStuff, nsnull);
}
return NS_OK;
}
PR_STATIC_CALLBACK(void)
ClearBroadcasterMapEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry)
{

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

@ -140,7 +140,6 @@ public:
NS_IMETHOD GetTemplateBuilderFor(nsIContent* aContent,
nsIXULTemplateBuilder** aResult);
NS_IMETHOD OnPrototypeLoadDone();
NS_IMETHOD OnHide();
// nsIDOMNode interface overrides
NS_IMETHOD CloneNode(PRBool deep, nsIDOMNode **_retval);

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

@ -1996,14 +1996,6 @@ DocumentViewerImpl::Hide(void)
selPrivate->RemoveSelectionListener(mSelectionListener);
}
#ifdef MOZ_XUL
nsCOMPtr<nsIXULDocument> xul_doc(do_QueryInterface(mDocument));
if (xul_doc) {
xul_doc->OnHide();
}
#endif
nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mContainer));
if (docShell) {
PRBool saveLayoutState = PR_FALSE;

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

@ -38,9 +38,10 @@
#ifndef nsPIBoxObject_h___
#define nsPIBoxObject_h___
// {9580E69B-8FD6-414e-80CD-3A1821017646}
// {91f2b229-b139-460e-a508-db9d52e9ed87}
#define NS_PIBOXOBJECT_IID \
{ 0x9580e69b, 0x8fd6, 0x414e, { 0x80, 0xcd, 0x3a, 0x18, 0x21, 0x1, 0x76, 0x46 } }
{ 0x91f2b229, 0xb139, 0x460e, \
{ 0xa5, 0x08, 0xdb, 0x9d, 0x52, 0xe9, 0xed, 0x87 } }
class nsIPresShell;
class nsIContent;
@ -49,13 +50,15 @@ class nsIDocument;
class nsPIBoxObject : public nsIBoxObject
{
public:
NS_DEFINE_STATIC_CID_ACCESSOR(NS_PIBOXOBJECT_IID)
NS_DECLARE_STATIC_IID_ACCESSOR(NS_PIBOXOBJECT_IID)
NS_IMETHOD Init(nsIContent* aContent, nsIPresShell* aShell) = 0;
NS_IMETHOD SetDocument(nsIDocument* aDocument) = 0;
virtual void Init(nsIContent* aContent) = 0;
NS_IMETHOD InvalidatePresentationStuff() = 0;
// Drop the weak ref to the content node as needed
virtual void Clear() = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsPIBoxObject, NS_PIBOXOBJECT_IID)
#endif

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

@ -81,7 +81,7 @@ NS_IMPL_RELEASE(nsBoxObject)
// Constructors/Destructors
nsBoxObject::nsBoxObject(void)
:mContent(nsnull), mPresShell(nsnull)
:mContent(nsnull)
{
}
@ -92,10 +92,11 @@ nsBoxObject::~nsBoxObject(void)
NS_IMETHODIMP
nsBoxObject::GetElement(nsIDOMElement** aResult)
{
if (mContent)
mContent->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aResult);
else
*aResult = nsnull;
if (mContent) {
return CallQueryInterface(mContent, aResult);
}
*aResult = nsnull;
return NS_OK;
}
@ -131,58 +132,54 @@ nsBoxObject::SetPaintManager(nsIBoxPaintManager* aPaintManager)
// nsPIBoxObject //////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsBoxObject::Init(nsIContent* aContent, nsIPresShell* aShell)
void
nsBoxObject::Init(nsIContent* aContent)
{
mContent = aContent;
mPresShell = do_GetWeakReference(aShell);
return NS_OK;
}
NS_IMETHODIMP
nsBoxObject::SetDocument(nsIDocument* aDocument)
void
nsBoxObject::Clear()
{
mPresState = nsnull;
if (aDocument) {
mPresShell = do_GetWeakReference(aDocument->GetShellAt(0));
}
else {
mPresShell = nsnull;
}
return NS_OK;
}
NS_IMETHODIMP
nsBoxObject::InvalidatePresentationStuff()
{
mPresShell = nsnull;
return NS_OK;
mContent = nsnull;
}
nsIFrame*
nsBoxObject::GetFrame()
nsBoxObject::GetFrame(PRBool aFlushLayout)
{
nsCOMPtr<nsIPresShell> shell = GetPresShell();
nsIPresShell* shell = GetPresShell(aFlushLayout);
if (!shell)
return nsnull;
// XXXbz should flush on document, no? Except people call this from
// frame code, maybe?
shell->FlushPendingNotifications(Flush_Frames);
if (!aFlushLayout) {
// If we didn't flush layout when getting the presshell, we should at least
// flush to make sure our frame model is up to date.
// XXXbz should flush on document, no? Except people call this from
// frame code, maybe?
shell->FlushPendingNotifications(Flush_Frames);
}
return shell->GetPrimaryFrameFor(mContent);
}
already_AddRefed<nsIPresShell>
nsBoxObject::GetPresShell()
nsIPresShell*
nsBoxObject::GetPresShell(PRBool aFlushLayout)
{
if (!mPresShell) {
if (!mContent) {
return nsnull;
}
nsIPresShell* shell = nsnull;
CallQueryReferent(mPresShell.get(), &shell);
return shell;
nsIDocument* doc = mContent->GetCurrentDoc();
if (!doc) {
return nsnull;
}
if (aFlushLayout) {
doc->FlushPendingNotifications(Flush_Layout);
}
return doc->GetShellAt(0);
}
nsresult
@ -194,80 +191,66 @@ nsBoxObject::GetOffsetRect(nsRect& aRect)
if (!mContent)
return NS_ERROR_NOT_INITIALIZED;
nsresult res = NS_OK;
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
// Get the Frame for our content
nsIFrame* frame = GetFrame(PR_TRUE);
if (frame) {
// Get its origin
nsPoint origin = frame->GetPosition();
if (doc) {
// Flush all pending notifications so that our frames are uptodate. Must
// do this before we get the presshell, since this can destroy presshells.
doc->FlushPendingNotifications(Flush_Layout);
// Get Presentation shell 0
nsIPresShell *presShell = doc->GetShellAt(0);
if(presShell) {
// Get the Frame for our content
nsIFrame* frame = presShell->GetPrimaryFrameFor(mContent);
if(frame) {
// Get its origin
nsPoint origin = frame->GetPosition();
// Get the union of all rectangles in this and continuation frames
nsRect rcFrame;
nsIFrame* next = frame;
do {
rcFrame.UnionRect(rcFrame, next->GetRect());
next = next->GetNextInFlow();
} while (nsnull != next);
// Get the union of all rectangles in this and continuation frames
nsRect rcFrame;
nsIFrame* next = frame;
do {
rcFrame.UnionRect(rcFrame, next->GetRect());
next = next->GetNextContinuation();
} while (nsnull != next);
// Find the frame parent whose content's tagName either matches
// the tagName passed in or is the document element.
nsIContent *docElement = doc->GetRootContent();
nsIFrame* parent = frame->GetParent();
while (parent) {
// If we've hit the document element, break here
if (parent->GetContent() == docElement) {
break;
}
// Add the parent's origin to our own to get to the
// right coordinate system
origin += parent->GetPosition();
parent = parent->GetParent();
}
// For the origin, add in the border for the frame
const nsStyleBorder* border = frame->GetStyleBorder();
origin.x += border->GetBorderWidth(NS_SIDE_LEFT);
origin.y += border->GetBorderWidth(NS_SIDE_TOP);
// And subtract out the border for the parent
if (parent) {
const nsStyleBorder* parentBorder = parent->GetStyleBorder();
origin.x -= parentBorder->GetBorderWidth(NS_SIDE_LEFT);
origin.y -= parentBorder->GetBorderWidth(NS_SIDE_TOP);
}
// Get the Presentation Context from the Shell
nsPresContext *context = presShell->GetPresContext();
if (context) {
// Get the scale from that Presentation Context
float scale;
scale = context->TwipsToPixels();
// Convert to pixels using that scale
aRect.x = NSTwipsToIntPixels(origin.x, scale);
aRect.y = NSTwipsToIntPixels(origin.y, scale);
aRect.width = NSTwipsToIntPixels(rcFrame.width, scale);
aRect.height = NSTwipsToIntPixels(rcFrame.height, scale);
}
// Find the frame parent whose content is the document element.
nsIContent *docElement = mContent->GetCurrentDoc()->GetRootContent();
nsIFrame* parent = frame->GetParent();
while (parent) {
// If we've hit the document element, break here
if (parent->GetContent() == docElement) {
break;
}
// Add the parent's origin to our own to get to the
// right coordinate system
origin += parent->GetPosition();
parent = parent->GetParent();
}
// For the origin, add in the border for the frame
const nsStyleBorder* border = frame->GetStyleBorder();
origin.x += border->GetBorderWidth(NS_SIDE_LEFT);
origin.y += border->GetBorderWidth(NS_SIDE_TOP);
// And subtract out the border for the parent
if (parent) {
const nsStyleBorder* parentBorder = parent->GetStyleBorder();
origin.x -= parentBorder->GetBorderWidth(NS_SIDE_LEFT);
origin.y -= parentBorder->GetBorderWidth(NS_SIDE_TOP);
}
// Get the Presentation Context from the Shell
nsIPresShell* shell = GetPresShell(PR_FALSE);
NS_ASSERTION(shell, "Must have shell if we have a frame!");
nsPresContext *context = shell->GetPresContext();
if (context) {
// Get the scale from that Presentation Context
float scale;
scale = context->TwipsToPixels();
// Convert to pixels using that scale
aRect.x = NSTwipsToIntPixels(origin.x, scale);
aRect.y = NSTwipsToIntPixels(origin.y, scale);
aRect.width = NSTwipsToIntPixels(rcFrame.width, scale);
aRect.height = NSTwipsToIntPixels(rcFrame.height, scale);
}
}
return res;
return NS_OK;
}
nsresult
@ -278,27 +261,11 @@ nsBoxObject::GetScreenPosition(nsIntPoint& aPoint)
if (!mContent)
return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
if (doc) {
// Get Presentation shell 0
nsIPresShell *presShell = doc->GetShellAt(0);
if (presShell) {
// Flush all pending notifications so that our frames are uptodate
doc->FlushPendingNotifications(Flush_Layout);
nsPresContext *presContext = presShell->GetPresContext();
if (presContext) {
nsIFrame* frame = presShell->GetPrimaryFrameFor(mContent);
if (frame) {
nsIntRect rect = frame->GetScreenRect();
aPoint.x = rect.x;
aPoint.y = rect.y;
}
}
}
nsIFrame* frame = GetFrame(PR_TRUE);
if (frame) {
nsIntRect rect = frame->GetScreenRect();
aPoint.x = rect.x;
aPoint.y = rect.y;
}
return NS_OK;
@ -482,7 +449,7 @@ nsBoxObject::RemoveProperty(const PRUnichar* aPropertyName)
NS_IMETHODIMP
nsBoxObject::GetParentBox(nsIDOMElement * *aParentBox)
{
nsIFrame* frame = GetFrame();
nsIFrame* frame = GetFrame(PR_FALSE);
if (!frame) return NS_OK;
nsIFrame* parent = frame->GetParent();
if (!parent) return NS_OK;
@ -497,7 +464,7 @@ NS_IMETHODIMP
nsBoxObject::GetFirstChild(nsIDOMElement * *aFirstVisibleChild)
{
*aFirstVisibleChild = nsnull;
nsIFrame* frame = GetFrame();
nsIFrame* frame = GetFrame(PR_FALSE);
if (!frame) return NS_OK;
nsIFrame* firstFrame = frame->GetFirstChild(nsnull);
if (!firstFrame) return NS_OK;
@ -511,7 +478,7 @@ NS_IMETHODIMP
nsBoxObject::GetLastChild(nsIDOMElement * *aLastVisibleChild)
{
*aLastVisibleChild = nsnull;
nsIFrame* frame = GetFrame();
nsIFrame* frame = GetFrame(PR_FALSE);
if (!frame) return NS_OK;
return GetPreviousSibling(frame, nsnull, aLastVisibleChild);
}
@ -520,7 +487,7 @@ NS_IMETHODIMP
nsBoxObject::GetNextSibling(nsIDOMElement **aNextOrdinalSibling)
{
*aNextOrdinalSibling = nsnull;
nsIFrame* frame = GetFrame();
nsIFrame* frame = GetFrame(PR_FALSE);
if (!frame) return NS_OK;
nsIFrame* nextFrame = frame->GetNextSibling();
if (!nextFrame) return NS_OK;
@ -534,7 +501,7 @@ NS_IMETHODIMP
nsBoxObject::GetPreviousSibling(nsIDOMElement **aPreviousOrdinalSibling)
{
*aPreviousOrdinalSibling = nsnull;
nsIFrame* frame = GetFrame();
nsIFrame* frame = GetFrame(PR_FALSE);
if (!frame) return NS_OK;
nsIFrame* parentFrame = frame->GetParent();
if (!parentFrame) return NS_OK;
@ -566,7 +533,7 @@ nsBoxObject::GetDocShell(nsIDocShell** aResult)
{
*aResult = nsnull;
nsIFrame *frame = GetFrame();
nsIFrame *frame = GetFrame(PR_FALSE);
if (frame) {
nsIFrameFrame *frame_frame = nsnull;
@ -580,6 +547,10 @@ nsBoxObject::GetDocShell(nsIDocShell** aResult)
}
}
if (!mContent) {
return NS_OK;
}
// No nsIFrameFrame available for mContent, try if there's a mapping
// between mContent's document to mContent's subdocument.

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

@ -41,8 +41,6 @@
#include "nsPresState.h"
#include "nsPoint.h"
#include "nsAutoPtr.h"
#include "nsIWeakReference.h"
#include "nsIWeakReferenceUtils.h"
class nsIBoxLayoutManager;
class nsIBoxPaintManager;
@ -60,12 +58,11 @@ public:
virtual ~nsBoxObject();
// nsPIBoxObject
NS_IMETHOD Init(nsIContent* aContent, nsIPresShell* aPresShell);
NS_IMETHOD SetDocument(nsIDocument* aDocument);
NS_IMETHOD InvalidatePresentationStuff();
virtual void Init(nsIContent* aContent);
virtual void Clear();
virtual nsIFrame* GetFrame();
already_AddRefed<nsIPresShell> GetPresShell();
nsIFrame* GetFrame(PRBool aFlushLayout);
nsIPresShell* GetPresShell(PRBool aFlushLayout);
nsresult GetOffsetRect(nsRect& aRect);
nsresult GetScreenPosition(nsIntPoint& aPoint);
@ -84,5 +81,4 @@ protected:
nsAutoPtr<nsPresState> mPresState; // [OWNER]
nsIContent* mContent; // [WEAK]
nsWeakPtr mPresShell;
};

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

@ -1,101 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 Communicator client 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):
* Original Author: David W. Hyatt (hyatt@netscape.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 MPL, 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 MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsIEditorBoxObject.h"
#include "nsBoxObject.h"
#include "nsIDocument.h"
#include "nsIFrame.h"
#include "nsIComponentManager.h"
#include "nsIDocShell.h"
class nsEditorBoxObject : public nsIEditorBoxObject, public nsBoxObject
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIEDITORBOXOBJECT
nsEditorBoxObject();
virtual ~nsEditorBoxObject();
//NS_PIBOXOBJECT interfaces
NS_IMETHOD Init(nsIContent* aContent, nsIPresShell* aPresShell);
NS_IMETHOD SetDocument(nsIDocument* aDocument);
};
/* Implementation file */
NS_IMPL_ISUPPORTS_INHERITED1(nsEditorBoxObject, nsBoxObject, nsIEditorBoxObject)
NS_IMETHODIMP
nsEditorBoxObject::SetDocument(nsIDocument* aDocument)
{
return nsBoxObject::SetDocument(aDocument);
}
nsEditorBoxObject::nsEditorBoxObject()
{
}
nsEditorBoxObject::~nsEditorBoxObject()
{
/* destructor code */
}
NS_IMETHODIMP nsEditorBoxObject::Init(nsIContent* aContent, nsIPresShell* aPresShell)
{
return nsBoxObject::Init(aContent, aPresShell);
}
NS_IMETHODIMP nsEditorBoxObject::GetDocShell(nsIDocShell** aResult)
{
return nsBoxObject::GetDocShell(aResult);
}
// Creation Routine ///////////////////////////////////////////////////////////////////////
nsresult
NS_NewEditorBoxObject(nsIBoxObject** aResult)
{
*aResult = new nsEditorBoxObject;
if (!*aResult)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aResult);
return NS_OK;
}

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

@ -61,7 +61,8 @@ public:
nsListBoxObject();
virtual ~nsListBoxObject();
NS_IMETHOD InvalidatePresentationStuff();
// nsPIBoxObject
virtual void Clear();
protected:
nsIListBoxObject* mListBoxBody;
@ -204,11 +205,11 @@ nsListBoxObject::GetListBoxBody()
return mListBoxBody;
}
nsIFrame* frame = GetFrame();
nsIFrame* frame = GetFrame(PR_FALSE);
if (!frame)
return nsnull;
nsCOMPtr<nsIPresShell> shell = GetPresShell();
nsIPresShell* shell = GetPresShell(PR_FALSE);
if (!shell) {
return nsnull;
}
@ -236,12 +237,12 @@ nsListBoxObject::GetListBoxBody()
return mListBoxBody;
}
NS_IMETHODIMP
nsListBoxObject::InvalidatePresentationStuff()
void
nsListBoxObject::Clear()
{
ClearCachedListBoxBody();
return nsBoxObject::InvalidatePresentationStuff();
nsBoxObject::Clear();
}
// Creation Routine ///////////////////////////////////////////////////////////////////////

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

@ -88,7 +88,7 @@ nsMenuBoxObject::~nsMenuBoxObject()
/* void openMenu (in boolean openFlag); */
NS_IMETHODIMP nsMenuBoxObject::OpenMenu(PRBool aOpenFlag)
{
nsIFrame* frame = GetFrame();
nsIFrame* frame = GetFrame(PR_FALSE);
if (!frame)
return NS_OK;
@ -103,7 +103,7 @@ NS_IMETHODIMP nsMenuBoxObject::OpenMenu(PRBool aOpenFlag)
NS_IMETHODIMP nsMenuBoxObject::GetActiveChild(nsIDOMElement** aResult)
{
*aResult = nsnull;
nsIFrame* frame = GetFrame();
nsIFrame* frame = GetFrame(PR_FALSE);
if (!frame)
return NS_OK;
@ -116,7 +116,7 @@ NS_IMETHODIMP nsMenuBoxObject::GetActiveChild(nsIDOMElement** aResult)
NS_IMETHODIMP nsMenuBoxObject::SetActiveChild(nsIDOMElement* aResult)
{
nsIFrame* frame = GetFrame();
nsIFrame* frame = GetFrame(PR_FALSE);
if (!frame)
return NS_OK;
@ -148,7 +148,7 @@ NS_IMETHODIMP nsMenuBoxObject::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent, PRBool*
if (nsMenuBarListener::IsAccessKeyPressed(aKeyEvent))
return NS_OK;
nsIFrame* frame = GetFrame();
nsIFrame* frame = GetFrame(PR_FALSE);
if (!frame)
return NS_OK;

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

@ -69,7 +69,7 @@ protected:
nsIPopupSetFrame* GetPopupSetFrame();
nsMenuPopupFrame* GetMenuPopupFrame()
{ return NS_STATIC_CAST(nsMenuPopupFrame*, GetFrame()); }
{ return NS_STATIC_CAST(nsMenuPopupFrame*, GetFrame(PR_FALSE)); }
};
NS_IMPL_ISUPPORTS_INHERITED1(nsPopupBoxObject, nsBoxObject, nsIPopupBoxObject)
@ -77,7 +77,7 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsPopupBoxObject, nsBoxObject, nsIPopupBoxObject)
nsIPopupSetFrame*
nsPopupBoxObject::GetPopupSetFrame()
{
nsCOMPtr<nsIPresShell> shell = GetPresShell();
nsIPresShell* shell = GetPresShell(PR_FALSE);
if (!shell) {
return nsnull;
}
@ -108,7 +108,7 @@ NS_IMETHODIMP
nsPopupBoxObject::HidePopup()
{
nsIPopupSetFrame *popupSet = GetPopupSetFrame();
nsIFrame *ourFrame = GetFrame();
nsIFrame *ourFrame = GetFrame(PR_FALSE);
if (ourFrame && popupSet) {
popupSet->HidePopup(ourFrame);
popupSet->DestroyPopup(ourFrame, PR_TRUE);

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

@ -90,7 +90,7 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollTo(PRInt32 x, PRInt32 y)
if (!scrollableView)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIPresShell> shell = GetPresShell();
nsCOMPtr<nsIPresShell> shell = GetPresShell(PR_FALSE);
if (!shell) {
return NS_ERROR_UNEXPECTED;
}
@ -130,7 +130,7 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollByLine(PRInt32 dlines)
// the <scrollbox>'s box frame is the scrollframe's "scrolled frame", and
// the <scrollbox>'s child box is a child of that.
static nsIFrame* GetScrolledBox(nsBoxObject* aScrollBox) {
nsIFrame* frame = aScrollBox->GetFrame();
nsIFrame* frame = aScrollBox->GetFrame(PR_FALSE);
if (!frame)
return nsnull;
nsIScrollableFrame* scrollFrame;
@ -244,7 +244,7 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollToElement(nsIDOMElement *child)
if (!scrollableView)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIPresShell> shell = GetPresShell();
nsCOMPtr<nsIPresShell> shell = GetPresShell(PR_FALSE);
if (!shell) {
return NS_ERROR_UNEXPECTED;
}
@ -317,7 +317,7 @@ NS_IMETHODIMP nsScrollBoxObject::GetPosition(PRInt32 *x, PRInt32 *y)
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIPresShell> shell = GetPresShell();
nsIPresShell* shell = GetPresShell(PR_FALSE);
if (!shell) {
return NS_ERROR_UNEXPECTED;
}
@ -339,7 +339,7 @@ NS_IMETHODIMP nsScrollBoxObject::GetScrolledSize(PRInt32 *width, PRInt32 *height
nsRect scrollRect = scrolledBox->GetRect();
nsCOMPtr<nsIPresShell> shell = GetPresShell();
nsIPresShell* shell = GetPresShell(PR_FALSE);
if (!shell) {
return NS_ERROR_UNEXPECTED;
}
@ -356,11 +356,32 @@ NS_IMETHODIMP nsScrollBoxObject::GetScrolledSize(PRInt32 *width, PRInt32 *height
NS_IMETHODIMP nsScrollBoxObject::EnsureElementIsVisible(nsIDOMElement *child)
{
NS_ENSURE_ARG_POINTER(child);
// Start with getting info about the child, since that will flush
// layout and possibly destroy scrollable views, presshells, etc.
nsCOMPtr<nsIDOMDocument> doc;
// XXXbz sXBL/XBL2 issue -- which document?
child->GetOwnerDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMNSDocument> nsDoc(do_QueryInterface(doc));
if(!nsDoc)
return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIBoxObject> childBoxObject;
nsDoc->GetBoxObjectFor(child, getter_AddRefs(childBoxObject));
if(!childBoxObject)
return NS_ERROR_UNEXPECTED;
PRInt32 x, y, width, height;
childBoxObject->GetX(&x);
childBoxObject->GetY(&y);
childBoxObject->GetWidth(&width);
childBoxObject->GetHeight(&height);
nsIScrollableView* scrollableView = GetScrollableView();
if (!scrollableView)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIPresShell> shell = GetPresShell();
nsIPresShell* shell = GetPresShell(PR_FALSE);
if (!shell) {
return NS_ERROR_UNEXPECTED;
}
@ -374,22 +395,6 @@ NS_IMETHODIMP nsScrollBoxObject::EnsureElementIsVisible(nsIDOMElement *child)
return NS_ERROR_FAILURE;
nsRect rect, crect;
nsCOMPtr<nsIDOMDocument> doc;
child->GetOwnerDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMNSDocument> nsDoc(do_QueryInterface(doc));
if(!nsDoc)
return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIBoxObject> childBoxObject;
nsDoc->GetBoxObjectFor(child, getter_AddRefs(childBoxObject));
if(!childBoxObject)
return NS_ERROR_UNEXPECTED;
PRInt32 x,y,width,height;
childBoxObject->GetX(&x);
childBoxObject->GetY(&y);
childBoxObject->GetWidth(&width);
childBoxObject->GetHeight(&height);
// get the twips rectangle from the boxobject (which has pixels)
rect.x = NSToIntRound(x * pixelsToTwips);
rect.y = NSToIntRound(y * pixelsToTwips);
@ -448,7 +453,7 @@ nsIScrollableView*
nsScrollBoxObject::GetScrollableView()
{
// get the frame.
nsIFrame* frame = GetFrame();
nsIFrame* frame = GetFrame(PR_FALSE);
if (!frame)
return nsnull;

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

@ -62,9 +62,7 @@ public:
nsITreeBoxObject* GetTreeBody();
//NS_PIBOXOBJECT interfaces
NS_IMETHOD Init(nsIContent* aContent, nsIPresShell* aPresShell);
NS_IMETHOD SetDocument(nsIDocument* aDocument);
NS_IMETHOD InvalidatePresentationStuff();
virtual void Clear();
// nsPITreeBoxObject
virtual void ClearCachedTreeBody();
@ -78,16 +76,15 @@ NS_IMPL_ISUPPORTS_INHERITED2(nsTreeBoxObject, nsBoxObject, nsITreeBoxObject,
nsPITreeBoxObject)
NS_IMETHODIMP
nsTreeBoxObject::SetDocument(nsIDocument* aDocument)
void
nsTreeBoxObject::Clear()
{
// this should only be called with a null document, which indicates
// that we're being torn down.
NS_ASSERTION(aDocument == nsnull, "SetDocument called with non-null document");
ClearCachedTreeBody();
// Drop the view's ref to us.
NS_NAMED_LITERAL_STRING(viewString, "view");
nsCOMPtr<nsISupports> suppView;
GetPropertyAsSupports(NS_LITERAL_STRING("view").get(), getter_AddRefs(suppView));
GetPropertyAsSupports(viewString.get(), getter_AddRefs(suppView));
nsCOMPtr<nsITreeView> treeView(do_QueryInterface(suppView));
if (treeView) {
nsCOMPtr<nsITreeSelection> sel;
@ -97,19 +94,12 @@ nsTreeBoxObject::SetDocument(nsIDocument* aDocument)
treeView->SetTree(nsnull); // Break the circular ref between the view and us.
}
return nsBoxObject::SetDocument(aDocument);
SetPropertyAsSupports(viewString.get(), nsnull);
nsBoxObject::Clear();
}
NS_IMETHODIMP
nsTreeBoxObject::InvalidatePresentationStuff()
{
ClearCachedTreeBody();
SetPropertyAsSupports(NS_LITERAL_STRING("view").get(), nsnull);
return nsBoxObject::InvalidatePresentationStuff();
}
nsTreeBoxObject::nsTreeBoxObject()
: mTreeBody(nsnull)
{
@ -121,13 +111,6 @@ nsTreeBoxObject::~nsTreeBoxObject()
}
NS_IMETHODIMP nsTreeBoxObject::Init(nsIContent* aContent, nsIPresShell* aPresShell)
{
nsresult rv = nsBoxObject::Init(aContent, aPresShell);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
static void FindBodyElement(nsIContent* aParent, nsIContent** aResult)
{
*aResult = nsnull;
@ -157,7 +140,7 @@ nsTreeBoxObject::GetTreeBody()
return mTreeBody;
}
nsIFrame* frame = GetFrame();
nsIFrame* frame = GetFrame(PR_FALSE);
if (!frame)
return nsnull;
@ -165,7 +148,7 @@ nsTreeBoxObject::GetTreeBody()
nsCOMPtr<nsIContent> content;
FindBodyElement(frame->GetContent(), getter_AddRefs(content));
nsCOMPtr<nsIPresShell> shell = GetPresShell();
nsIPresShell* shell = GetPresShell(PR_FALSE);
if (!shell) {
return nsnull;
}