зеркало из https://github.com/mozilla/gecko-dev.git
Fix for text/html and text/plain OBJECTs don't work bug 678 r=av sr=attinasi
This commit is contained in:
Родитель
59177f86ce
Коммит
196d33ffdc
|
@ -89,8 +89,11 @@
|
||||||
// XXX For temporary paint code
|
// XXX For temporary paint code
|
||||||
#include "nsIStyleContext.h"
|
#include "nsIStyleContext.h"
|
||||||
|
|
||||||
//~~~ For image mime types
|
//~~~ For mime types
|
||||||
#include "nsMimeTypes.h"
|
#include "nsMimeTypes.h"
|
||||||
|
#include "nsIMIMEService.h"
|
||||||
|
#include "nsCExternalHandlerService.h"
|
||||||
|
#include "nsICategoryManager.h"
|
||||||
|
|
||||||
#include "nsObjectFrame.h"
|
#include "nsObjectFrame.h"
|
||||||
#include "nsIObjectFrame.h"
|
#include "nsIObjectFrame.h"
|
||||||
|
@ -417,6 +420,58 @@ void nsObjectFrame::IsSupportedImage(nsIContent* aContent, PRBool* aImage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nsObjectFrame::IsSupportedDocument(nsIContent* aContent, PRBool* aDoc)
|
||||||
|
{
|
||||||
|
*aDoc = PR_FALSE;
|
||||||
|
nsresult rv;
|
||||||
|
|
||||||
|
if(aContent == nsnull)
|
||||||
|
return;
|
||||||
|
|
||||||
|
nsCOMPtr<nsICategoryManager> catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||||
|
if (NS_FAILED(rv)) return;
|
||||||
|
|
||||||
|
nsAutoString type;
|
||||||
|
rv = aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, type);
|
||||||
|
if((rv == NS_CONTENT_ATTR_HAS_VALUE) && (type.Length() > 0))
|
||||||
|
{
|
||||||
|
nsXPIDLCString value;
|
||||||
|
char * buf = ToNewCString(type);
|
||||||
|
rv = catman->GetCategoryEntry("Gecko-Content-Viewers",buf, getter_Copies(value));
|
||||||
|
nsMemory::Free(buf);
|
||||||
|
|
||||||
|
if (NS_SUCCEEDED(rv) && value && *value && (value.Length() > 0))
|
||||||
|
*aDoc = PR_TRUE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we don't have a TYPE= try getting the mime-type via the DATA= url
|
||||||
|
nsAutoString data;
|
||||||
|
rv = aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::data, data);
|
||||||
|
if((rv == NS_CONTENT_ATTR_HAS_VALUE) && (data.Length() > 0))
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIURI> uri;
|
||||||
|
nsCOMPtr<nsIURI> baseURL;
|
||||||
|
|
||||||
|
if (NS_FAILED(GetBaseURL(*getter_AddRefs(baseURL)))) return; // XXX NS_NewURI fails without base
|
||||||
|
rv = NS_NewURI(getter_AddRefs(uri), data, baseURL);
|
||||||
|
if (NS_FAILED(rv)) return;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIMIMEService> mimeService = do_GetService(NS_MIMESERVICE_CONTRACTID, &rv);
|
||||||
|
if (NS_FAILED(rv)) return;
|
||||||
|
|
||||||
|
char * contentType;
|
||||||
|
rv = mimeService->GetTypeFromURI(uri, &contentType);
|
||||||
|
if (NS_FAILED(rv)) return;
|
||||||
|
|
||||||
|
nsXPIDLCString value;
|
||||||
|
rv = catman->GetCategoryEntry("Gecko-Content-Viewers",contentType, getter_Copies(value));
|
||||||
|
|
||||||
|
if (NS_SUCCEEDED(rv) && value && *value && (value.Length() > 0))
|
||||||
|
*aDoc = PR_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsObjectFrame::SetInitialChildList(nsIPresContext* aPresContext,
|
NS_IMETHODIMP nsObjectFrame::SetInitialChildList(nsIPresContext* aPresContext,
|
||||||
nsIAtom* aListName,
|
nsIAtom* aListName,
|
||||||
nsIFrame* aChildList)
|
nsIFrame* aChildList)
|
||||||
|
@ -465,6 +520,40 @@ nsObjectFrame::Init(nsIPresContext* aPresContext,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
aNewFrame->Destroy(aPresContext);
|
aNewFrame->Destroy(aPresContext);
|
||||||
|
|
||||||
|
return rv; // bail at this point
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// for now, we should try to do the same for "document" types and create
|
||||||
|
// and IFrame-like sub-frame
|
||||||
|
PRBool bDoc = PR_FALSE;
|
||||||
|
IsSupportedDocument(aContent, &bDoc);
|
||||||
|
|
||||||
|
if(bDoc)
|
||||||
|
{
|
||||||
|
// fix up DATA= to SRC=
|
||||||
|
nsAutoString url;
|
||||||
|
if (NS_CONTENT_ATTR_HAS_VALUE !=
|
||||||
|
aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::data, url))
|
||||||
|
return rv; // if DATA= is empty, what shall we do? bail for now...
|
||||||
|
aContent->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::src, url, PR_FALSE);
|
||||||
|
|
||||||
|
nsCOMPtr<nsIPresShell> shell;
|
||||||
|
aPresContext->GetShell(getter_AddRefs(shell));
|
||||||
|
nsIFrame * aNewFrame = nsnull;
|
||||||
|
rv = NS_NewHTMLFrameOuterFrame(shell, &aNewFrame);
|
||||||
|
if(NS_FAILED(rv))
|
||||||
|
return rv;
|
||||||
|
|
||||||
|
rv = aNewFrame->Init(aPresContext, aContent, this, aContext, aPrevInFlow);
|
||||||
|
if(NS_SUCCEEDED(rv))
|
||||||
|
{
|
||||||
|
nsHTMLContainerFrame::CreateViewForFrame(aPresContext, aNewFrame, aContext, nsnull, PR_FALSE);
|
||||||
|
mFrames.AppendFrame(this, aNewFrame);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
aNewFrame->Destroy(aPresContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -728,7 +817,7 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext,
|
||||||
// handle an image elsewhere
|
// handle an image elsewhere
|
||||||
nsIFrame * child = mFrames.FirstChild();
|
nsIFrame * child = mFrames.FirstChild();
|
||||||
if(child != nsnull)
|
if(child != nsnull)
|
||||||
return HandleImage(aPresContext, aMetrics, aReflowState, aStatus, child);
|
return HandleChild(aPresContext, aMetrics, aReflowState, aStatus, child);
|
||||||
// if we are printing, bail for now
|
// if we are printing, bail for now
|
||||||
nsCOMPtr<nsIPrintContext> thePrinterContext = do_QueryInterface(aPresContext);
|
nsCOMPtr<nsIPrintContext> thePrinterContext = do_QueryInterface(aPresContext);
|
||||||
if (thePrinterContext) return rv;
|
if (thePrinterContext) return rv;
|
||||||
|
@ -1152,7 +1241,7 @@ nsObjectFrame::ReinstantiatePlugin(nsIPresContext* aPresContext, nsHTMLReflowMet
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsObjectFrame::HandleImage(nsIPresContext* aPresContext,
|
nsObjectFrame::HandleChild(nsIPresContext* aPresContext,
|
||||||
nsHTMLReflowMetrics& aMetrics,
|
nsHTMLReflowMetrics& aMetrics,
|
||||||
const nsHTMLReflowState& aReflowState,
|
const nsHTMLReflowState& aReflowState,
|
||||||
nsReflowStatus& aStatus,
|
nsReflowStatus& aStatus,
|
||||||
|
|
|
@ -83,6 +83,7 @@ public:
|
||||||
nsresult GetFullURL(nsIURI*& aFullURL);
|
nsresult GetFullURL(nsIURI*& aFullURL);
|
||||||
|
|
||||||
void IsSupportedImage(nsIContent* aContent, PRBool* aImage);
|
void IsSupportedImage(nsIContent* aContent, PRBool* aImage);
|
||||||
|
void IsSupportedDocument(nsIContent* aContent, PRBool* aDoc);
|
||||||
|
|
||||||
nsIPresContext *mPresContext; // weak ref
|
nsIPresContext *mPresContext; // weak ref
|
||||||
protected:
|
protected:
|
||||||
|
@ -117,11 +118,11 @@ protected:
|
||||||
nsHTMLReflowMetrics& aMetrics,
|
nsHTMLReflowMetrics& aMetrics,
|
||||||
const nsHTMLReflowState& aReflowState);
|
const nsHTMLReflowState& aReflowState);
|
||||||
|
|
||||||
nsresult HandleImage(nsIPresContext* aPresContext,
|
nsresult HandleChild(nsIPresContext* aPresContext,
|
||||||
nsHTMLReflowMetrics& aMetrics,
|
nsHTMLReflowMetrics& aMetrics,
|
||||||
const nsHTMLReflowState& aReflowState,
|
const nsHTMLReflowState& aReflowState,
|
||||||
nsReflowStatus& aStatus,
|
nsReflowStatus& aStatus,
|
||||||
nsIFrame* child);
|
nsIFrame* child);
|
||||||
|
|
||||||
nsresult GetBaseURL(nsIURI* &aURL);
|
nsresult GetBaseURL(nsIURI* &aURL);
|
||||||
|
|
||||||
|
|
|
@ -89,8 +89,11 @@
|
||||||
// XXX For temporary paint code
|
// XXX For temporary paint code
|
||||||
#include "nsIStyleContext.h"
|
#include "nsIStyleContext.h"
|
||||||
|
|
||||||
//~~~ For image mime types
|
//~~~ For mime types
|
||||||
#include "nsMimeTypes.h"
|
#include "nsMimeTypes.h"
|
||||||
|
#include "nsIMIMEService.h"
|
||||||
|
#include "nsCExternalHandlerService.h"
|
||||||
|
#include "nsICategoryManager.h"
|
||||||
|
|
||||||
#include "nsObjectFrame.h"
|
#include "nsObjectFrame.h"
|
||||||
#include "nsIObjectFrame.h"
|
#include "nsIObjectFrame.h"
|
||||||
|
@ -417,6 +420,58 @@ void nsObjectFrame::IsSupportedImage(nsIContent* aContent, PRBool* aImage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nsObjectFrame::IsSupportedDocument(nsIContent* aContent, PRBool* aDoc)
|
||||||
|
{
|
||||||
|
*aDoc = PR_FALSE;
|
||||||
|
nsresult rv;
|
||||||
|
|
||||||
|
if(aContent == nsnull)
|
||||||
|
return;
|
||||||
|
|
||||||
|
nsCOMPtr<nsICategoryManager> catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||||
|
if (NS_FAILED(rv)) return;
|
||||||
|
|
||||||
|
nsAutoString type;
|
||||||
|
rv = aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, type);
|
||||||
|
if((rv == NS_CONTENT_ATTR_HAS_VALUE) && (type.Length() > 0))
|
||||||
|
{
|
||||||
|
nsXPIDLCString value;
|
||||||
|
char * buf = ToNewCString(type);
|
||||||
|
rv = catman->GetCategoryEntry("Gecko-Content-Viewers",buf, getter_Copies(value));
|
||||||
|
nsMemory::Free(buf);
|
||||||
|
|
||||||
|
if (NS_SUCCEEDED(rv) && value && *value && (value.Length() > 0))
|
||||||
|
*aDoc = PR_TRUE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we don't have a TYPE= try getting the mime-type via the DATA= url
|
||||||
|
nsAutoString data;
|
||||||
|
rv = aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::data, data);
|
||||||
|
if((rv == NS_CONTENT_ATTR_HAS_VALUE) && (data.Length() > 0))
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIURI> uri;
|
||||||
|
nsCOMPtr<nsIURI> baseURL;
|
||||||
|
|
||||||
|
if (NS_FAILED(GetBaseURL(*getter_AddRefs(baseURL)))) return; // XXX NS_NewURI fails without base
|
||||||
|
rv = NS_NewURI(getter_AddRefs(uri), data, baseURL);
|
||||||
|
if (NS_FAILED(rv)) return;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIMIMEService> mimeService = do_GetService(NS_MIMESERVICE_CONTRACTID, &rv);
|
||||||
|
if (NS_FAILED(rv)) return;
|
||||||
|
|
||||||
|
char * contentType;
|
||||||
|
rv = mimeService->GetTypeFromURI(uri, &contentType);
|
||||||
|
if (NS_FAILED(rv)) return;
|
||||||
|
|
||||||
|
nsXPIDLCString value;
|
||||||
|
rv = catman->GetCategoryEntry("Gecko-Content-Viewers",contentType, getter_Copies(value));
|
||||||
|
|
||||||
|
if (NS_SUCCEEDED(rv) && value && *value && (value.Length() > 0))
|
||||||
|
*aDoc = PR_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsObjectFrame::SetInitialChildList(nsIPresContext* aPresContext,
|
NS_IMETHODIMP nsObjectFrame::SetInitialChildList(nsIPresContext* aPresContext,
|
||||||
nsIAtom* aListName,
|
nsIAtom* aListName,
|
||||||
nsIFrame* aChildList)
|
nsIFrame* aChildList)
|
||||||
|
@ -465,6 +520,40 @@ nsObjectFrame::Init(nsIPresContext* aPresContext,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
aNewFrame->Destroy(aPresContext);
|
aNewFrame->Destroy(aPresContext);
|
||||||
|
|
||||||
|
return rv; // bail at this point
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// for now, we should try to do the same for "document" types and create
|
||||||
|
// and IFrame-like sub-frame
|
||||||
|
PRBool bDoc = PR_FALSE;
|
||||||
|
IsSupportedDocument(aContent, &bDoc);
|
||||||
|
|
||||||
|
if(bDoc)
|
||||||
|
{
|
||||||
|
// fix up DATA= to SRC=
|
||||||
|
nsAutoString url;
|
||||||
|
if (NS_CONTENT_ATTR_HAS_VALUE !=
|
||||||
|
aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::data, url))
|
||||||
|
return rv; // if DATA= is empty, what shall we do? bail for now...
|
||||||
|
aContent->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::src, url, PR_FALSE);
|
||||||
|
|
||||||
|
nsCOMPtr<nsIPresShell> shell;
|
||||||
|
aPresContext->GetShell(getter_AddRefs(shell));
|
||||||
|
nsIFrame * aNewFrame = nsnull;
|
||||||
|
rv = NS_NewHTMLFrameOuterFrame(shell, &aNewFrame);
|
||||||
|
if(NS_FAILED(rv))
|
||||||
|
return rv;
|
||||||
|
|
||||||
|
rv = aNewFrame->Init(aPresContext, aContent, this, aContext, aPrevInFlow);
|
||||||
|
if(NS_SUCCEEDED(rv))
|
||||||
|
{
|
||||||
|
nsHTMLContainerFrame::CreateViewForFrame(aPresContext, aNewFrame, aContext, nsnull, PR_FALSE);
|
||||||
|
mFrames.AppendFrame(this, aNewFrame);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
aNewFrame->Destroy(aPresContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -728,7 +817,7 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext,
|
||||||
// handle an image elsewhere
|
// handle an image elsewhere
|
||||||
nsIFrame * child = mFrames.FirstChild();
|
nsIFrame * child = mFrames.FirstChild();
|
||||||
if(child != nsnull)
|
if(child != nsnull)
|
||||||
return HandleImage(aPresContext, aMetrics, aReflowState, aStatus, child);
|
return HandleChild(aPresContext, aMetrics, aReflowState, aStatus, child);
|
||||||
// if we are printing, bail for now
|
// if we are printing, bail for now
|
||||||
nsCOMPtr<nsIPrintContext> thePrinterContext = do_QueryInterface(aPresContext);
|
nsCOMPtr<nsIPrintContext> thePrinterContext = do_QueryInterface(aPresContext);
|
||||||
if (thePrinterContext) return rv;
|
if (thePrinterContext) return rv;
|
||||||
|
@ -1152,7 +1241,7 @@ nsObjectFrame::ReinstantiatePlugin(nsIPresContext* aPresContext, nsHTMLReflowMet
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsObjectFrame::HandleImage(nsIPresContext* aPresContext,
|
nsObjectFrame::HandleChild(nsIPresContext* aPresContext,
|
||||||
nsHTMLReflowMetrics& aMetrics,
|
nsHTMLReflowMetrics& aMetrics,
|
||||||
const nsHTMLReflowState& aReflowState,
|
const nsHTMLReflowState& aReflowState,
|
||||||
nsReflowStatus& aStatus,
|
nsReflowStatus& aStatus,
|
||||||
|
|
|
@ -83,6 +83,7 @@ public:
|
||||||
nsresult GetFullURL(nsIURI*& aFullURL);
|
nsresult GetFullURL(nsIURI*& aFullURL);
|
||||||
|
|
||||||
void IsSupportedImage(nsIContent* aContent, PRBool* aImage);
|
void IsSupportedImage(nsIContent* aContent, PRBool* aImage);
|
||||||
|
void IsSupportedDocument(nsIContent* aContent, PRBool* aDoc);
|
||||||
|
|
||||||
nsIPresContext *mPresContext; // weak ref
|
nsIPresContext *mPresContext; // weak ref
|
||||||
protected:
|
protected:
|
||||||
|
@ -117,11 +118,11 @@ protected:
|
||||||
nsHTMLReflowMetrics& aMetrics,
|
nsHTMLReflowMetrics& aMetrics,
|
||||||
const nsHTMLReflowState& aReflowState);
|
const nsHTMLReflowState& aReflowState);
|
||||||
|
|
||||||
nsresult HandleImage(nsIPresContext* aPresContext,
|
nsresult HandleChild(nsIPresContext* aPresContext,
|
||||||
nsHTMLReflowMetrics& aMetrics,
|
nsHTMLReflowMetrics& aMetrics,
|
||||||
const nsHTMLReflowState& aReflowState,
|
const nsHTMLReflowState& aReflowState,
|
||||||
nsReflowStatus& aStatus,
|
nsReflowStatus& aStatus,
|
||||||
nsIFrame* child);
|
nsIFrame* child);
|
||||||
|
|
||||||
nsresult GetBaseURL(nsIURI* &aURL);
|
nsresult GetBaseURL(nsIURI* &aURL);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче