Save background images on tables/rows/cells. Bug 115532, r=adamlock, sr=jst

This commit is contained in:
bzbarsky%mit.edu 2002-06-21 22:33:50 +00:00
Родитель 750ed97f3f
Коммит 1dad29c8ea
1 изменённых файлов: 65 добавлений и 8 удалений

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

@ -58,6 +58,9 @@
#include "nsIPrompt.h" #include "nsIPrompt.h"
#include "nsIDOMHTMLBodyElement.h" #include "nsIDOMHTMLBodyElement.h"
#include "nsIDOMHTMLTableElement.h"
#include "nsIDOMHTMLTableRowElement.h"
#include "nsIDOMHTMLTableCellElement.h"
#include "nsIDOMHTMLAnchorElement.h" #include "nsIDOMHTMLAnchorElement.h"
#include "nsIDOMHTMLAreaElement.h" #include "nsIDOMHTMLAreaElement.h"
#include "nsIDOMHTMLImageElement.h" #include "nsIDOMHTMLImageElement.h"
@ -116,9 +119,9 @@ struct OutputData
OutputData(nsIURI *aFile, nsIURI *aOriginalLocation, PRBool aCalcFileExt) : OutputData(nsIURI *aFile, nsIURI *aOriginalLocation, PRBool aCalcFileExt) :
mFile(aFile), mFile(aFile),
mOriginalLocation(aOriginalLocation), mOriginalLocation(aOriginalLocation),
mCalcFileExt(aCalcFileExt),
mSelfProgress(0), mSelfProgress(0),
mSelfProgressMax(10000) mSelfProgressMax(10000),
mCalcFileExt(aCalcFileExt)
{ {
} }
~OutputData() ~OutputData()
@ -150,9 +153,9 @@ struct UploadData
// modern systems should able to cope with. // modern systems should able to cope with.
#ifdef XP_MAC #ifdef XP_MAC
const PRInt32 kDefaultMaxFilenameLength = 31; const PRUint32 kDefaultMaxFilenameLength = 31;
#else #else
const PRInt32 kDefaultMaxFilenameLength = 64; const PRUint32 kDefaultMaxFilenameLength = 64;
#endif #endif
// Default flags for persistence // Default flags for persistence
@ -165,6 +168,7 @@ const char *kWebBrowserPersistStringBundle =
"chrome://global/locale/nsWebBrowserPersist.properties"; "chrome://global/locale/nsWebBrowserPersist.properties";
nsWebBrowserPersist::nsWebBrowserPersist() : nsWebBrowserPersist::nsWebBrowserPersist() :
mCurrentThingsToPersist(0),
mFirstAndOnlyUse(PR_TRUE), mFirstAndOnlyUse(PR_TRUE),
mCancel(PR_FALSE), mCancel(PR_FALSE),
mJustStartedLoading(PR_TRUE), mJustStartedLoading(PR_TRUE),
@ -173,9 +177,8 @@ nsWebBrowserPersist::nsWebBrowserPersist() :
mReplaceExisting(PR_TRUE), mReplaceExisting(PR_TRUE),
mPersistFlags(kDefaultPersistFlags), mPersistFlags(kDefaultPersistFlags),
mPersistResult(NS_OK), mPersistResult(NS_OK),
mEncodingFlags(0),
mWrapColumn(72), mWrapColumn(72),
mCurrentThingsToPersist(0) mEncodingFlags(0)
{ {
NS_INIT_REFCNT(); NS_INIT_REFCNT();
} }
@ -1815,7 +1818,7 @@ nsWebBrowserPersist::CalculateAndAppendFileExt(nsIURI *aURI, nsIChannel *aChanne
if (!fileExt.IsEmpty()) if (!fileExt.IsEmpty())
{ {
PRInt32 newLength = newFileName.Length() + fileExt.Length() + 1; PRUint32 newLength = newFileName.Length() + fileExt.Length() + 1;
if (newLength > kDefaultMaxFilenameLength) if (newLength > kDefaultMaxFilenameLength)
{ {
newFileName.Truncate(newFileName.Length() - (newLength - kDefaultMaxFilenameLength)); newFileName.Truncate(newFileName.Length() - (newLength - kDefaultMaxFilenameLength));
@ -2166,6 +2169,27 @@ nsWebBrowserPersist::OnWalkDOMNode(nsIDOMNode *aNode, PRBool *aAbort)
return NS_OK; return NS_OK;
} }
nsCOMPtr<nsIDOMHTMLTableElement> nodeAsTable = do_QueryInterface(aNode);
if (nodeAsTable)
{
StoreURIAttribute(aNode, "background");
return NS_OK;
}
nsCOMPtr<nsIDOMHTMLTableRowElement> nodeAsTableRow = do_QueryInterface(aNode);
if (nodeAsTableRow)
{
StoreURIAttribute(aNode, "background");
return NS_OK;
}
nsCOMPtr<nsIDOMHTMLTableCellElement> nodeAsTableCell = do_QueryInterface(aNode);
if (nodeAsTableCell)
{
StoreURIAttribute(aNode, "background");
return NS_OK;
}
nsCOMPtr<nsIDOMHTMLScriptElement> nodeAsScript = do_QueryInterface(aNode); nsCOMPtr<nsIDOMHTMLScriptElement> nodeAsScript = do_QueryInterface(aNode);
if (nodeAsScript) if (nodeAsScript)
{ {
@ -2305,6 +2329,39 @@ nsWebBrowserPersist::CloneNodeWithFixedUpURIAttributes(
return rv; return rv;
} }
nsCOMPtr<nsIDOMHTMLTableElement> nodeAsTable = do_QueryInterface(aNodeIn);
if (nodeAsTable)
{
rv = GetNodeToFixup(aNodeIn, aNodeOut);
if (NS_SUCCEEDED(rv) && *aNodeOut)
{
FixupNodeAttribute(*aNodeOut, "background");
}
return rv;
}
nsCOMPtr<nsIDOMHTMLTableRowElement> nodeAsTableRow = do_QueryInterface(aNodeIn);
if (nodeAsTableRow)
{
rv = GetNodeToFixup(aNodeIn, aNodeOut);
if (NS_SUCCEEDED(rv) && *aNodeOut)
{
FixupNodeAttribute(*aNodeOut, "background");
}
return rv;
}
nsCOMPtr<nsIDOMHTMLTableCellElement> nodeAsTableCell = do_QueryInterface(aNodeIn);
if (nodeAsTableCell)
{
rv = GetNodeToFixup(aNodeIn, aNodeOut);
if (NS_SUCCEEDED(rv) && *aNodeOut)
{
FixupNodeAttribute(*aNodeOut, "background");
}
return rv;
}
nsCOMPtr<nsIDOMHTMLImageElement> nodeAsImage = do_QueryInterface(aNodeIn); nsCOMPtr<nsIDOMHTMLImageElement> nodeAsImage = do_QueryInterface(aNodeIn);
if (nodeAsImage) if (nodeAsImage)
{ {