bug 232731 : misc cleanup in printing code
git-svn-id: svn://10.0.0.236/trunk@152139 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -350,9 +350,6 @@ public:
|
||||
// nsIDocumentViewerPrint Printing Methods
|
||||
NS_DECL_NSIDOCUMENTVIEWERPRINT
|
||||
|
||||
// Helpers (also used by nsPrintEngine)
|
||||
PRBool IsWebShellAFrameSet(nsIWebShell * aParent);
|
||||
|
||||
protected:
|
||||
virtual ~DocumentViewerImpl();
|
||||
|
||||
@@ -1688,92 +1685,7 @@ DocumentViewerImpl::CreateStyleSet(nsIDocument* aDocument,
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Note this is also defined in nsPrintEngine
|
||||
// They can't share it because nsPrintEngine may not be available
|
||||
// when printing isn't turned on
|
||||
static nsIPresShell *
|
||||
GetPresShellFor(nsIDocShell* aDocShell)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_GetInterface(aDocShell));
|
||||
if (!domDoc) return nsnull;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
|
||||
if (!doc) return nsnull;
|
||||
|
||||
return doc->GetShellAt(0);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// This gets ref counted copies of the PresShell and Root Content
|
||||
// for a given nsIWebShell
|
||||
void
|
||||
DocumentViewerImpl::GetPresShellAndRootContent(nsIWebShell * aWebShell,
|
||||
nsIPresShell** aPresShell,
|
||||
nsIContent** aContent)
|
||||
{
|
||||
NS_ASSERTION(aWebShell, "Pointer is null!");
|
||||
NS_ASSERTION(aPresShell, "Pointer is null!");
|
||||
NS_ASSERTION(aContent, "Pointer is null!");
|
||||
|
||||
*aContent = nsnull;
|
||||
*aPresShell = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aWebShell));
|
||||
|
||||
nsIPresShell *presShell = GetPresShellFor(docShell);
|
||||
if (!presShell)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
presShell->GetDocument(getter_AddRefs(doc));
|
||||
if (!doc)
|
||||
return;
|
||||
|
||||
NS_IF_ADDREF(*aContent = doc->GetRootContent());
|
||||
NS_ADDREF(*aPresShell = presShell);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
nsresult
|
||||
DocumentViewerImpl::FindFrameSetWithIID(nsIContent * aParentContent,
|
||||
const nsIID& aIID)
|
||||
{
|
||||
PRUint32 numChildren = aParentContent->GetChildCount();
|
||||
|
||||
// do a breadth search across all siblings
|
||||
PRUint32 inx;
|
||||
for (inx = 0; inx < numChildren; ++inx) {
|
||||
nsIContent *child = aParentContent->GetChildAt(inx);
|
||||
|
||||
if (child) {
|
||||
nsCOMPtr<nsISupports> temp;
|
||||
if (NS_SUCCEEDED(child->QueryInterface(aIID, (void**)getter_AddRefs(temp)))) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
PRBool
|
||||
DocumentViewerImpl::IsWebShellAFrameSet(nsIWebShell * aWebShell)
|
||||
{
|
||||
NS_ASSERTION(aWebShell, "Pointer is null!");
|
||||
|
||||
PRBool doesContainFrameSet = PR_FALSE;
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
nsCOMPtr<nsIContent> rootContent;
|
||||
GetPresShellAndRootContent(aWebShell, getter_AddRefs(presShell), getter_AddRefs(rootContent));
|
||||
if (rootContent) {
|
||||
if (NS_SUCCEEDED(FindFrameSetWithIID(rootContent, NS_GET_IID(nsIDOMHTMLFrameSetElement)))) {
|
||||
doesContainFrameSet = PR_TRUE;
|
||||
}
|
||||
}
|
||||
return doesContainFrameSet;
|
||||
}
|
||||
|
||||
nsresult
|
||||
DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
|
||||
|
||||
@@ -85,9 +85,6 @@ public:
|
||||
|
||||
virtual void OnDonePrinting() = 0;
|
||||
|
||||
virtual nsresult FindFrameSetWithIID(nsIContent * aParentContent, const nsIID& aIID) = 0;
|
||||
|
||||
virtual void GetPresShellAndRootContent(nsIWebShell * aWebShell, nsIPresShell** aPresShell, nsIContent** aContent) = 0;
|
||||
};
|
||||
|
||||
/* Use this macro when declaring classes that implement this interface. */
|
||||
@@ -102,8 +99,6 @@ public:
|
||||
virtual void IncrementDestroyRefCount(); \
|
||||
virtual void ReturnToGalleyPresentation(); \
|
||||
virtual void InstallNewPresentation(); \
|
||||
virtual void OnDonePrinting(); \
|
||||
virtual nsresult FindFrameSetWithIID(nsIContent * aParentContent, const nsIID& aIID); \
|
||||
virtual void GetPresShellAndRootContent(nsIWebShell * aWebShell, nsIPresShell** aPresShell, nsIContent** aContent);
|
||||
virtual void OnDonePrinting();
|
||||
|
||||
#endif /* nsIDocumentViewerPrint_h___ */
|
||||
|
||||
@@ -1372,7 +1372,7 @@ nsPrintEngine::EnumerateDocumentNames(PRUint32* aCount,
|
||||
NS_ASSERTION(po, "nsPrintObject can't be null!");
|
||||
PRUnichar * docTitleStr;
|
||||
PRUnichar * docURLStr;
|
||||
GetWebShellTitleAndURL(po->mWebShell, po->mDocument, &docTitleStr, &docURLStr);
|
||||
GetDocumentTitleAndURL(po->mDocument, &docTitleStr, &docURLStr);
|
||||
|
||||
// Use the URL if the doc is empty
|
||||
if (!docTitleStr || !*docTitleStr) {
|
||||
@@ -1770,9 +1770,7 @@ nsPrintEngine::IsParentAFrameSet(nsIWebShell * aParent)
|
||||
if (doc) {
|
||||
nsIContent *rootContent = doc->GetRootContent();
|
||||
if (rootContent) {
|
||||
if (NS_SUCCEEDED(mDocViewerPrint->FindFrameSetWithIID(rootContent, NS_GET_IID(nsIDOMHTMLFrameSetElement)))) {
|
||||
isFrameSet = PR_TRUE;
|
||||
}
|
||||
isFrameSet = HasFramesetChild(rootContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1793,7 +1791,7 @@ nsPrintEngine::BuildDocTree(nsIDocShellTreeNode * aParentNode,
|
||||
NS_ASSERTION(aPO, "Pointer is null!");
|
||||
|
||||
// Get the Doc and Title String
|
||||
GetWebShellTitleAndURL(aPO->mWebShell, aPO->mDocument, &aPO->mDocTitle, &aPO->mDocURL);
|
||||
GetDocumentTitleAndURL(aPO->mDocument, &aPO->mDocTitle, &aPO->mDocURL);
|
||||
|
||||
PRInt32 childWebshellCount;
|
||||
aParentNode->GetChildCount(&childWebshellCount);
|
||||
@@ -1833,12 +1831,10 @@ nsPrintEngine::BuildDocTree(nsIDocShellTreeNode * aParentNode,
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
void
|
||||
nsPrintEngine::GetWebShellTitleAndURL(nsIWebShell* aWebShell,
|
||||
nsIDocument* aDoc,
|
||||
nsPrintEngine::GetDocumentTitleAndURL(nsIDocument* aDoc,
|
||||
PRUnichar** aTitle,
|
||||
PRUnichar** aURLStr)
|
||||
{
|
||||
NS_ASSERTION(aWebShell, "Pointer is null!");
|
||||
NS_ASSERTION(aDoc, "Pointer is null!");
|
||||
NS_ASSERTION(aTitle, "Pointer is null!");
|
||||
NS_ASSERTION(aURLStr, "Pointer is null!");
|
||||
@@ -1875,7 +1871,7 @@ nsPrintEngine::MapContentToWebShells(nsPrintObject* aRootPO,
|
||||
// Recursively walk the content from the root item
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
nsCOMPtr<nsIContent> rootContent;
|
||||
mDocViewerPrint->GetPresShellAndRootContent(aPO->mWebShell, getter_AddRefs(presShell), getter_AddRefs(rootContent));
|
||||
GetPresShellAndRootContent(aPO->mDocShell, getter_AddRefs(presShell), getter_AddRefs(rootContent));
|
||||
if (presShell && rootContent) {
|
||||
MapContentForPO(aRootPO, presShell, rootContent);
|
||||
}
|
||||
@@ -3886,23 +3882,6 @@ nsPrintEngine::GetPageRangeForSelection(nsIPresShell * aPresShell,
|
||||
//-- Section: Misc Support Methods
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Note this is also defined in DocumentViewerImpl
|
||||
// static
|
||||
nsIPresShell *
|
||||
GetPresShellFor(nsIDocShell* aDocShell)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_GetInterface(aDocShell));
|
||||
if (!domDoc)
|
||||
return nsnull;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
|
||||
if (!doc)
|
||||
return nsnull;
|
||||
|
||||
return doc->GetShellAt(0);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
void nsPrintEngine::SetIsPrinting(PRBool aIsPrinting)
|
||||
{
|
||||
@@ -3933,6 +3912,59 @@ nsPrintEngine::CleanupDocTitleArray(PRUnichar**& aArray, PRInt32& aCount)
|
||||
aArray = NULL;
|
||||
aCount = 0;
|
||||
}
|
||||
//---------------------------------------------------------------------
|
||||
// This gets ref counted copies of the PresShell and Root Content
|
||||
// for a given docshell
|
||||
// static
|
||||
void
|
||||
nsPrintEngine::GetPresShellAndRootContent(nsIDocShell * aDocShell,
|
||||
nsIPresShell** aPresShell,
|
||||
nsIContent** aContent)
|
||||
{
|
||||
NS_ASSERTION(aDocShell, "Pointer is null!");
|
||||
NS_ASSERTION(aPresShell, "Pointer is null!");
|
||||
NS_ASSERTION(aContent, "Pointer is null!");
|
||||
|
||||
*aContent = nsnull;
|
||||
*aPresShell = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_GetInterface(aDocShell));
|
||||
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
|
||||
if (!doc)
|
||||
return;
|
||||
|
||||
nsIPresShell *presShell = doc->GetShellAt(0);
|
||||
if (!presShell)
|
||||
return;
|
||||
|
||||
NS_IF_ADDREF(*aContent = doc->GetRootContent());
|
||||
NS_ADDREF(*aPresShell = presShell);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// static
|
||||
PRBool nsPrintEngine::HasFramesetChild(nsIContent* aContent)
|
||||
{
|
||||
if (!aContent) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRUint32 numChildren = aContent->GetChildCount();
|
||||
|
||||
// do a breadth search across all siblings
|
||||
for (PRUint32 i = 0; i < numChildren; ++i) {
|
||||
nsIContent *child = aContent->GetChildAt(i);
|
||||
if (child->Tag() == nsHTMLAtoms::frameset &&
|
||||
child->IsContentOfType(nsIContent::eHTML)) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Get the Focused Frame for a documentviewer
|
||||
|
||||
@@ -214,9 +214,6 @@ public:
|
||||
nsPrintObject* aPO,
|
||||
PRUint32 aDelay);
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Static Methods
|
||||
//---------------------------------------------------------------------
|
||||
PRBool IsWindowsInOurSubTree(nsIDOMWindow * aDOMWindow);
|
||||
PRBool IsParentAFrameSet(nsIWebShell * aParent);
|
||||
PRBool IsThereAnIFrameSelected(nsIWebShell* aWebShell,
|
||||
@@ -229,9 +226,12 @@ public:
|
||||
// get the currently infocus frame for the document viewer
|
||||
already_AddRefed<nsIDOMWindow> FindFocusedDOMWindow();
|
||||
|
||||
void GetWebShellTitleAndURL(nsIWebShell* aWebShell, nsIDocument* aDoc,
|
||||
PRUnichar** aTitle, PRUnichar** aURLStr);
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Static Methods
|
||||
//---------------------------------------------------------------------
|
||||
static void GetDocumentTitleAndURL(nsIDocument* aDoc,
|
||||
PRUnichar** aTitle,
|
||||
PRUnichar** aURLStr);
|
||||
static void GetDisplayTitleAndURL(nsPrintObject* aPO,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
const PRUnichar* aBrandName,
|
||||
@@ -240,6 +240,11 @@ public:
|
||||
eDocTitleDefault aDefType = eDocTitleDefNone);
|
||||
static void ShowPrintErrorDialog(nsresult printerror,
|
||||
PRBool aIsPrinting = PR_TRUE);
|
||||
static void GetPresShellAndRootContent(nsIDocShell * aDocShell,
|
||||
nsIPresShell** aPresShell,
|
||||
nsIContent** aContent);
|
||||
|
||||
static PRBool HasFramesetChild(nsIContent* aContent);
|
||||
|
||||
PRBool CheckBeforeDestroy();
|
||||
nsresult Cancelled();
|
||||
|
||||
@@ -350,9 +350,6 @@ public:
|
||||
// nsIDocumentViewerPrint Printing Methods
|
||||
NS_DECL_NSIDOCUMENTVIEWERPRINT
|
||||
|
||||
// Helpers (also used by nsPrintEngine)
|
||||
PRBool IsWebShellAFrameSet(nsIWebShell * aParent);
|
||||
|
||||
protected:
|
||||
virtual ~DocumentViewerImpl();
|
||||
|
||||
@@ -1688,92 +1685,7 @@ DocumentViewerImpl::CreateStyleSet(nsIDocument* aDocument,
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Note this is also defined in nsPrintEngine
|
||||
// They can't share it because nsPrintEngine may not be available
|
||||
// when printing isn't turned on
|
||||
static nsIPresShell *
|
||||
GetPresShellFor(nsIDocShell* aDocShell)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_GetInterface(aDocShell));
|
||||
if (!domDoc) return nsnull;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
|
||||
if (!doc) return nsnull;
|
||||
|
||||
return doc->GetShellAt(0);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// This gets ref counted copies of the PresShell and Root Content
|
||||
// for a given nsIWebShell
|
||||
void
|
||||
DocumentViewerImpl::GetPresShellAndRootContent(nsIWebShell * aWebShell,
|
||||
nsIPresShell** aPresShell,
|
||||
nsIContent** aContent)
|
||||
{
|
||||
NS_ASSERTION(aWebShell, "Pointer is null!");
|
||||
NS_ASSERTION(aPresShell, "Pointer is null!");
|
||||
NS_ASSERTION(aContent, "Pointer is null!");
|
||||
|
||||
*aContent = nsnull;
|
||||
*aPresShell = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aWebShell));
|
||||
|
||||
nsIPresShell *presShell = GetPresShellFor(docShell);
|
||||
if (!presShell)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
presShell->GetDocument(getter_AddRefs(doc));
|
||||
if (!doc)
|
||||
return;
|
||||
|
||||
NS_IF_ADDREF(*aContent = doc->GetRootContent());
|
||||
NS_ADDREF(*aPresShell = presShell);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
nsresult
|
||||
DocumentViewerImpl::FindFrameSetWithIID(nsIContent * aParentContent,
|
||||
const nsIID& aIID)
|
||||
{
|
||||
PRUint32 numChildren = aParentContent->GetChildCount();
|
||||
|
||||
// do a breadth search across all siblings
|
||||
PRUint32 inx;
|
||||
for (inx = 0; inx < numChildren; ++inx) {
|
||||
nsIContent *child = aParentContent->GetChildAt(inx);
|
||||
|
||||
if (child) {
|
||||
nsCOMPtr<nsISupports> temp;
|
||||
if (NS_SUCCEEDED(child->QueryInterface(aIID, (void**)getter_AddRefs(temp)))) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
PRBool
|
||||
DocumentViewerImpl::IsWebShellAFrameSet(nsIWebShell * aWebShell)
|
||||
{
|
||||
NS_ASSERTION(aWebShell, "Pointer is null!");
|
||||
|
||||
PRBool doesContainFrameSet = PR_FALSE;
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
nsCOMPtr<nsIContent> rootContent;
|
||||
GetPresShellAndRootContent(aWebShell, getter_AddRefs(presShell), getter_AddRefs(rootContent));
|
||||
if (rootContent) {
|
||||
if (NS_SUCCEEDED(FindFrameSetWithIID(rootContent, NS_GET_IID(nsIDOMHTMLFrameSetElement)))) {
|
||||
doesContainFrameSet = PR_TRUE;
|
||||
}
|
||||
}
|
||||
return doesContainFrameSet;
|
||||
}
|
||||
|
||||
nsresult
|
||||
DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
|
||||
|
||||
@@ -85,9 +85,6 @@ public:
|
||||
|
||||
virtual void OnDonePrinting() = 0;
|
||||
|
||||
virtual nsresult FindFrameSetWithIID(nsIContent * aParentContent, const nsIID& aIID) = 0;
|
||||
|
||||
virtual void GetPresShellAndRootContent(nsIWebShell * aWebShell, nsIPresShell** aPresShell, nsIContent** aContent) = 0;
|
||||
};
|
||||
|
||||
/* Use this macro when declaring classes that implement this interface. */
|
||||
@@ -102,8 +99,6 @@ public:
|
||||
virtual void IncrementDestroyRefCount(); \
|
||||
virtual void ReturnToGalleyPresentation(); \
|
||||
virtual void InstallNewPresentation(); \
|
||||
virtual void OnDonePrinting(); \
|
||||
virtual nsresult FindFrameSetWithIID(nsIContent * aParentContent, const nsIID& aIID); \
|
||||
virtual void GetPresShellAndRootContent(nsIWebShell * aWebShell, nsIPresShell** aPresShell, nsIContent** aContent);
|
||||
virtual void OnDonePrinting();
|
||||
|
||||
#endif /* nsIDocumentViewerPrint_h___ */
|
||||
|
||||
@@ -1372,7 +1372,7 @@ nsPrintEngine::EnumerateDocumentNames(PRUint32* aCount,
|
||||
NS_ASSERTION(po, "nsPrintObject can't be null!");
|
||||
PRUnichar * docTitleStr;
|
||||
PRUnichar * docURLStr;
|
||||
GetWebShellTitleAndURL(po->mWebShell, po->mDocument, &docTitleStr, &docURLStr);
|
||||
GetDocumentTitleAndURL(po->mDocument, &docTitleStr, &docURLStr);
|
||||
|
||||
// Use the URL if the doc is empty
|
||||
if (!docTitleStr || !*docTitleStr) {
|
||||
@@ -1770,9 +1770,7 @@ nsPrintEngine::IsParentAFrameSet(nsIWebShell * aParent)
|
||||
if (doc) {
|
||||
nsIContent *rootContent = doc->GetRootContent();
|
||||
if (rootContent) {
|
||||
if (NS_SUCCEEDED(mDocViewerPrint->FindFrameSetWithIID(rootContent, NS_GET_IID(nsIDOMHTMLFrameSetElement)))) {
|
||||
isFrameSet = PR_TRUE;
|
||||
}
|
||||
isFrameSet = HasFramesetChild(rootContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1793,7 +1791,7 @@ nsPrintEngine::BuildDocTree(nsIDocShellTreeNode * aParentNode,
|
||||
NS_ASSERTION(aPO, "Pointer is null!");
|
||||
|
||||
// Get the Doc and Title String
|
||||
GetWebShellTitleAndURL(aPO->mWebShell, aPO->mDocument, &aPO->mDocTitle, &aPO->mDocURL);
|
||||
GetDocumentTitleAndURL(aPO->mDocument, &aPO->mDocTitle, &aPO->mDocURL);
|
||||
|
||||
PRInt32 childWebshellCount;
|
||||
aParentNode->GetChildCount(&childWebshellCount);
|
||||
@@ -1833,12 +1831,10 @@ nsPrintEngine::BuildDocTree(nsIDocShellTreeNode * aParentNode,
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
void
|
||||
nsPrintEngine::GetWebShellTitleAndURL(nsIWebShell* aWebShell,
|
||||
nsIDocument* aDoc,
|
||||
nsPrintEngine::GetDocumentTitleAndURL(nsIDocument* aDoc,
|
||||
PRUnichar** aTitle,
|
||||
PRUnichar** aURLStr)
|
||||
{
|
||||
NS_ASSERTION(aWebShell, "Pointer is null!");
|
||||
NS_ASSERTION(aDoc, "Pointer is null!");
|
||||
NS_ASSERTION(aTitle, "Pointer is null!");
|
||||
NS_ASSERTION(aURLStr, "Pointer is null!");
|
||||
@@ -1875,7 +1871,7 @@ nsPrintEngine::MapContentToWebShells(nsPrintObject* aRootPO,
|
||||
// Recursively walk the content from the root item
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
nsCOMPtr<nsIContent> rootContent;
|
||||
mDocViewerPrint->GetPresShellAndRootContent(aPO->mWebShell, getter_AddRefs(presShell), getter_AddRefs(rootContent));
|
||||
GetPresShellAndRootContent(aPO->mDocShell, getter_AddRefs(presShell), getter_AddRefs(rootContent));
|
||||
if (presShell && rootContent) {
|
||||
MapContentForPO(aRootPO, presShell, rootContent);
|
||||
}
|
||||
@@ -3886,23 +3882,6 @@ nsPrintEngine::GetPageRangeForSelection(nsIPresShell * aPresShell,
|
||||
//-- Section: Misc Support Methods
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Note this is also defined in DocumentViewerImpl
|
||||
// static
|
||||
nsIPresShell *
|
||||
GetPresShellFor(nsIDocShell* aDocShell)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_GetInterface(aDocShell));
|
||||
if (!domDoc)
|
||||
return nsnull;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
|
||||
if (!doc)
|
||||
return nsnull;
|
||||
|
||||
return doc->GetShellAt(0);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
void nsPrintEngine::SetIsPrinting(PRBool aIsPrinting)
|
||||
{
|
||||
@@ -3933,6 +3912,59 @@ nsPrintEngine::CleanupDocTitleArray(PRUnichar**& aArray, PRInt32& aCount)
|
||||
aArray = NULL;
|
||||
aCount = 0;
|
||||
}
|
||||
//---------------------------------------------------------------------
|
||||
// This gets ref counted copies of the PresShell and Root Content
|
||||
// for a given docshell
|
||||
// static
|
||||
void
|
||||
nsPrintEngine::GetPresShellAndRootContent(nsIDocShell * aDocShell,
|
||||
nsIPresShell** aPresShell,
|
||||
nsIContent** aContent)
|
||||
{
|
||||
NS_ASSERTION(aDocShell, "Pointer is null!");
|
||||
NS_ASSERTION(aPresShell, "Pointer is null!");
|
||||
NS_ASSERTION(aContent, "Pointer is null!");
|
||||
|
||||
*aContent = nsnull;
|
||||
*aPresShell = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_GetInterface(aDocShell));
|
||||
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
|
||||
if (!doc)
|
||||
return;
|
||||
|
||||
nsIPresShell *presShell = doc->GetShellAt(0);
|
||||
if (!presShell)
|
||||
return;
|
||||
|
||||
NS_IF_ADDREF(*aContent = doc->GetRootContent());
|
||||
NS_ADDREF(*aPresShell = presShell);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// static
|
||||
PRBool nsPrintEngine::HasFramesetChild(nsIContent* aContent)
|
||||
{
|
||||
if (!aContent) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRUint32 numChildren = aContent->GetChildCount();
|
||||
|
||||
// do a breadth search across all siblings
|
||||
for (PRUint32 i = 0; i < numChildren; ++i) {
|
||||
nsIContent *child = aContent->GetChildAt(i);
|
||||
if (child->Tag() == nsHTMLAtoms::frameset &&
|
||||
child->IsContentOfType(nsIContent::eHTML)) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Get the Focused Frame for a documentviewer
|
||||
|
||||
@@ -214,9 +214,6 @@ public:
|
||||
nsPrintObject* aPO,
|
||||
PRUint32 aDelay);
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Static Methods
|
||||
//---------------------------------------------------------------------
|
||||
PRBool IsWindowsInOurSubTree(nsIDOMWindow * aDOMWindow);
|
||||
PRBool IsParentAFrameSet(nsIWebShell * aParent);
|
||||
PRBool IsThereAnIFrameSelected(nsIWebShell* aWebShell,
|
||||
@@ -229,9 +226,12 @@ public:
|
||||
// get the currently infocus frame for the document viewer
|
||||
already_AddRefed<nsIDOMWindow> FindFocusedDOMWindow();
|
||||
|
||||
void GetWebShellTitleAndURL(nsIWebShell* aWebShell, nsIDocument* aDoc,
|
||||
PRUnichar** aTitle, PRUnichar** aURLStr);
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Static Methods
|
||||
//---------------------------------------------------------------------
|
||||
static void GetDocumentTitleAndURL(nsIDocument* aDoc,
|
||||
PRUnichar** aTitle,
|
||||
PRUnichar** aURLStr);
|
||||
static void GetDisplayTitleAndURL(nsPrintObject* aPO,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
const PRUnichar* aBrandName,
|
||||
@@ -240,6 +240,11 @@ public:
|
||||
eDocTitleDefault aDefType = eDocTitleDefNone);
|
||||
static void ShowPrintErrorDialog(nsresult printerror,
|
||||
PRBool aIsPrinting = PR_TRUE);
|
||||
static void GetPresShellAndRootContent(nsIDocShell * aDocShell,
|
||||
nsIPresShell** aPresShell,
|
||||
nsIContent** aContent);
|
||||
|
||||
static PRBool HasFramesetChild(nsIContent* aContent);
|
||||
|
||||
PRBool CheckBeforeDestroy();
|
||||
nsresult Cancelled();
|
||||
|
||||
Reference in New Issue
Block a user