Bug 414046 - Remove nsPresShell::GetLayoutObjectFor(), r/sr=roc

This commit is contained in:
Arpad Borsos 2008-09-04 22:32:39 +02:00
parent 5f408e1832
commit 06188d3762
7 changed files with 22 additions and 107 deletions

View File

@ -4270,32 +4270,6 @@ nsHTMLEditor::SelectAll()
#pragma mark -
#endif
NS_IMETHODIMP nsHTMLEditor::GetLayoutObject(nsIDOMNode *aNode, nsISupports **aLayoutObject)
{
nsresult result = NS_ERROR_FAILURE; // we return an error unless we get the index
if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
if (!ps) return NS_ERROR_NOT_INITIALIZED;
if ((nsnull!=aNode))
{ // get the content interface
nsCOMPtr<nsIContent> nodeAsContent( do_QueryInterface(aNode) );
if (nodeAsContent)
{ // get the frame from the content interface
//Note: frames are not ref counted, so don't use an nsCOMPtr
*aLayoutObject = nsnull;
result = ps->GetLayoutObjectFor(nodeAsContent, aLayoutObject);
}
}
else {
result = NS_ERROR_NULL_POINTER;
}
return result;
}
// this will NOT find aAttribute unless aAttribute has a non-null value
// so singleton attributes like <Table border> will not be matched!
void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode *aNode,

View File

@ -458,14 +458,6 @@ protected:
mCSSAware = ((aFlags & (eEditorNoCSSMask | eEditorMailMask)) == 0);
}
/** returns the layout object (nsIFrame in the real world) for aNode
* @param aNode the content to get a frame for
* @param aLayoutObject the "primary frame" for aNode, if one exists. May be null
* @return NS_OK whether a frame is found or not
* an error if some serious error occurs
*/
NS_IMETHOD GetLayoutObject(nsIDOMNode *aInNode, nsISupports **aOutLayoutObject);
// Return TRUE if aElement is a table-related elemet and caret was set
PRBool SetCaretInTableCell(nsIDOMElement* aElement);
PRBool IsElementInBody(nsIDOMElement* aElement);

View File

@ -45,6 +45,8 @@
#include "nsIDOMNode.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMRange.h"
#include "nsIFrame.h"
#include "nsIPresShell.h"
#include "nsISelection.h"
#include "nsISelectionPrivate.h"
#include "nsLayoutCID.h"
@ -2718,9 +2720,14 @@ nsHTMLEditor::GetCellIndexes(nsIDOMElement *aCell,
return NS_ERROR_FAILURE;
}
nsISupports *layoutObject=nsnull; // frames are not ref counted, so don't use an nsCOMPtr
res = nsHTMLEditor::GetLayoutObject(aCell, &layoutObject);
if (NS_FAILED(res)) return res;
if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
if (!ps) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIContent> nodeAsContent( do_QueryInterface(aCell) );
if (!nodeAsContent) return NS_ERROR_FAILURE;
// frames are not ref counted, so don't use an nsCOMPtr
nsIFrame *layoutObject = ps->GetPrimaryFrameFor(nodeAsContent);
if (!layoutObject) return NS_ERROR_FAILURE;
nsITableCellLayout *cellLayoutObject=nsnull; // again, frames are not ref-counted
@ -2734,14 +2741,17 @@ NS_IMETHODIMP
nsHTMLEditor::GetTableLayoutObject(nsIDOMElement* aTable, nsITableLayout **tableLayoutObject)
{
*tableLayoutObject=nsnull;
if (!aTable)
return NS_ERROR_NOT_INITIALIZED;
if (!aTable) return NS_ERROR_NOT_INITIALIZED;
if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
if (!ps) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIContent> nodeAsContent( do_QueryInterface(aTable) );
if (!nodeAsContent) return NS_ERROR_FAILURE;
// frames are not ref counted, so don't use an nsCOMPtr
nsISupports *layoutObject=nsnull;
nsresult res = GetLayoutObject(aTable, &layoutObject);
if (NS_FAILED(res)) return res;
nsIFrame *layoutObject = ps->GetPrimaryFrameFor(nodeAsContent);
if (!layoutObject) return NS_ERROR_FAILURE;
return layoutObject->QueryInterface(NS_GET_IID(nsITableLayout),
(void**)(tableLayoutObject));
}

View File

@ -1810,31 +1810,6 @@ nsPlaintextEditor::SelectEntireDocument(nsISelection *aSelection)
#pragma mark -
#endif
NS_IMETHODIMP nsPlaintextEditor::GetLayoutObject(nsIDOMNode *aNode, nsISupports **aLayoutObject)
{
nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
if (!ps) return NS_ERROR_NOT_INITIALIZED;
nsresult result = NS_ERROR_NULL_POINTER;
if (aNode)
{ // get the content interface
nsCOMPtr<nsIContent> nodeAsContent( do_QueryInterface(aNode) );
if (nodeAsContent)
{ // get the frame from the content interface
//Note: frames are not ref counted, so don't use an nsCOMPtr
*aLayoutObject = nsnull;
result = ps->GetLayoutObjectFor(nodeAsContent, aLayoutObject);
}
}
return result;
}
#ifdef XP_MAC
#pragma mark -
#endif
nsresult
nsPlaintextEditor::SetAttributeOrEquivalent(nsIDOMElement * aElement,
const nsAString & aAttribute,

View File

@ -173,13 +173,6 @@ protected:
// Create the event listeners for the editor to install.
virtual nsresult CreateEventListeners();
/** returns the layout object (nsIFrame in the real world) for aNode
* @param aNode the content to get a frame for
* @param aLayoutObject the "primary frame" for aNode, if one exists. May be null
* @return NS_OK whether a frame is found or not
* an error if some serious error occurs
*/
NS_IMETHOD GetLayoutObject(nsIDOMNode *aInNode, nsISupports **aOutLayoutObject);
// Helpers for output routines
NS_IMETHOD GetAndInitDocEncoder(const nsAString& aFormatType,
PRUint32 aFlags,

View File

@ -103,10 +103,10 @@ typedef short SelectionType;
typedef PRUint32 nsFrameState;
// 23e048f6-49bb-4ac4-b900-c63865363ad3
// 134e504f-4fd1-4590-9f5d-899afee63d0f
#define NS_IPRESSHELL_IID \
{ 0x23e048f6, 0x49bb, 0x4ac4, \
{ 0xb9, 0x00, 0xc6, 0x38, 0x65, 0x36, 0x3a, 0xd3 } }
{ 0x134e504f, 0x4fd1, 0x4590, \
{ 0x9f, 0x5d, 0x89, 0x9a, 0xfe, 0xe6, 0x3d, 0x0f } }
// Constants for ScrollContentIntoView() function
#define NS_PRESSHELL_SCROLL_TOP 0
@ -346,15 +346,6 @@ public:
*/
virtual NS_HIDDEN_(nsIFrame*) GetRealPrimaryFrameFor(nsIContent* aContent) const = 0;
/**
* Returns a layout object associated with the primary frame for the content object.
*
* @param aContent the content object for which we seek a layout object
* @param aResult the resulting layout object as an nsISupports, if found.
*/
NS_IMETHOD GetLayoutObjectFor(nsIContent* aContent,
nsISupports** aResult) const = 0;
/**
* Gets the placeholder frame associated with the specified frame. This is
* a helper frame that forwards the request to the frame manager.

View File

@ -814,8 +814,6 @@ public:
virtual NS_HIDDEN_(nsIFrame*) GetPrimaryFrameFor(nsIContent* aContent) const;
virtual NS_HIDDEN_(nsIFrame*) GetRealPrimaryFrameFor(nsIContent* aContent) const;
NS_IMETHOD GetLayoutObjectFor(nsIContent* aContent,
nsISupports** aResult) const;
NS_IMETHOD GetPlaceholderFrameFor(nsIFrame* aFrame,
nsIFrame** aPlaceholderFrame) const;
NS_IMETHOD FrameNeedsReflow(nsIFrame *aFrame, IntrinsicDirty aIntrinsicDirty,
@ -4903,24 +4901,6 @@ PresShell::GetRealPrimaryFrameFor(nsIContent* aContent) const
return nsPlaceholderFrame::GetRealFrameFor(primaryFrame);
}
NS_IMETHODIMP
PresShell::GetLayoutObjectFor(nsIContent* aContent,
nsISupports** aResult) const
{
nsresult result = NS_ERROR_NULL_POINTER;
if ((nsnull!=aResult) && (nsnull!=aContent))
{
*aResult = nsnull;
nsIFrame *primaryFrame = GetPrimaryFrameFor(aContent);
if (primaryFrame)
{
result = primaryFrame->QueryInterface(NS_GET_IID(nsISupports),
(void**)aResult);
}
}
return result;
}
NS_IMETHODIMP
PresShell::GetPlaceholderFrameFor(nsIFrame* aFrame,
nsIFrame** aResult) const