зеркало из https://github.com/mozilla/pjs.git
For IMAGE SRC/FRAME SRC, set a charset from the document and pass it to NS_NewURI,
bug 127282, r=attinasi, sr=darin, a=asa.
This commit is contained in:
Родитель
d9b7047793
Коммит
2bfc3f7831
|
@ -1148,11 +1148,12 @@ nsHTMLFrameInnerFrame::DoLoadURL(nsIPresContext* aPresContext)
|
|||
// Make an absolute URL
|
||||
nsCOMPtr<nsIURI> baseURL;
|
||||
nsCOMPtr<nsIHTMLContent> htmlContent = do_QueryInterface(parentContent, &rv);
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
if (NS_SUCCEEDED(rv) && htmlContent) {
|
||||
htmlContent->GetBaseURL(*getter_AddRefs(baseURL));
|
||||
(void) htmlContent->GetDocument(*getter_AddRefs(doc));
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
rv = parentContent->GetDocument(*getter_AddRefs(doc));
|
||||
if (NS_SUCCEEDED(rv) && doc) {
|
||||
doc->GetBaseURL(*getter_AddRefs(baseURL));
|
||||
|
@ -1160,12 +1161,17 @@ nsHTMLFrameInnerFrame::DoLoadURL(nsIPresContext* aPresContext)
|
|||
}
|
||||
if (!baseURL) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsAutoString docCharset;
|
||||
if (doc)
|
||||
(void) doc->GetDocumentCharacterSet(docCharset);
|
||||
|
||||
nsAutoString absURL;
|
||||
rv = NS_MakeAbsoluteURI(absURL, url, baseURL);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewURI(getter_AddRefs(uri), absURL);
|
||||
NS_NewURI(getter_AddRefs(uri), absURL,
|
||||
docCharset.IsEmpty() ? nsnull : NS_ConvertUCS2toUTF8(docCharset).get());
|
||||
|
||||
// Check for security
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan =
|
||||
|
|
|
@ -1927,6 +1927,19 @@ nsImageFrame::RealLoadImage(const nsAReadableString& aSpec, nsIPresContext *aPre
|
|||
|
||||
#define INTERNAL_GOPHER_LENGTH 16 /* "internal-gopher-" length */
|
||||
|
||||
void
|
||||
nsImageFrame::GetDocumentCharacterSet(nsAWritableString& aCharset) const
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIHTMLContent> htmlContent(do_QueryInterface(mContent, &rv));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
rv = htmlContent->GetDocument(*getter_AddRefs(doc));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
(void) doc->GetDocumentCharacterSet(aCharset);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsImageFrame::GetURI(const nsAReadableString& aSpec, nsIURI **aURI)
|
||||
{
|
||||
|
@ -1954,7 +1967,11 @@ nsImageFrame::GetRealURI(const nsAReadableString& aSpec, nsIURI **aURI)
|
|||
{
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
GetBaseURI(getter_AddRefs(baseURI));
|
||||
NS_NewURI(aURI, aSpec, nsnull, baseURI);
|
||||
nsAutoString charset;
|
||||
GetDocumentCharacterSet(charset);
|
||||
NS_NewURI(aURI, aSpec,
|
||||
charset.IsEmpty() ? nsnull : NS_ConvertUCS2toUTF8(charset).get(),
|
||||
baseURI);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -225,6 +225,7 @@ private:
|
|||
nsresult RealLoadImage(const nsAReadableString& aSpec, nsIPresContext *aPresContext, imgIRequest *aRequest);
|
||||
inline int GetImageLoad(imgIRequest *aRequest);
|
||||
nscoord GetContinuationOffset(nscoord* aWidth = 0) const;
|
||||
void GetDocumentCharacterSet(nsAWritableString& aCharset) const;
|
||||
|
||||
nsImageMap* mImageMap;
|
||||
|
||||
|
|
|
@ -1927,6 +1927,19 @@ nsImageFrame::RealLoadImage(const nsAReadableString& aSpec, nsIPresContext *aPre
|
|||
|
||||
#define INTERNAL_GOPHER_LENGTH 16 /* "internal-gopher-" length */
|
||||
|
||||
void
|
||||
nsImageFrame::GetDocumentCharacterSet(nsAWritableString& aCharset) const
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIHTMLContent> htmlContent(do_QueryInterface(mContent, &rv));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
rv = htmlContent->GetDocument(*getter_AddRefs(doc));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
(void) doc->GetDocumentCharacterSet(aCharset);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsImageFrame::GetURI(const nsAReadableString& aSpec, nsIURI **aURI)
|
||||
{
|
||||
|
@ -1954,7 +1967,11 @@ nsImageFrame::GetRealURI(const nsAReadableString& aSpec, nsIURI **aURI)
|
|||
{
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
GetBaseURI(getter_AddRefs(baseURI));
|
||||
NS_NewURI(aURI, aSpec, nsnull, baseURI);
|
||||
nsAutoString charset;
|
||||
GetDocumentCharacterSet(charset);
|
||||
NS_NewURI(aURI, aSpec,
|
||||
charset.IsEmpty() ? nsnull : NS_ConvertUCS2toUTF8(charset).get(),
|
||||
baseURI);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -225,6 +225,7 @@ private:
|
|||
nsresult RealLoadImage(const nsAReadableString& aSpec, nsIPresContext *aPresContext, imgIRequest *aRequest);
|
||||
inline int GetImageLoad(imgIRequest *aRequest);
|
||||
nscoord GetContinuationOffset(nscoord* aWidth = 0) const;
|
||||
void GetDocumentCharacterSet(nsAWritableString& aCharset) const;
|
||||
|
||||
nsImageMap* mImageMap;
|
||||
|
||||
|
|
|
@ -1148,11 +1148,12 @@ nsHTMLFrameInnerFrame::DoLoadURL(nsIPresContext* aPresContext)
|
|||
// Make an absolute URL
|
||||
nsCOMPtr<nsIURI> baseURL;
|
||||
nsCOMPtr<nsIHTMLContent> htmlContent = do_QueryInterface(parentContent, &rv);
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
if (NS_SUCCEEDED(rv) && htmlContent) {
|
||||
htmlContent->GetBaseURL(*getter_AddRefs(baseURL));
|
||||
(void) htmlContent->GetDocument(*getter_AddRefs(doc));
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
rv = parentContent->GetDocument(*getter_AddRefs(doc));
|
||||
if (NS_SUCCEEDED(rv) && doc) {
|
||||
doc->GetBaseURL(*getter_AddRefs(baseURL));
|
||||
|
@ -1160,12 +1161,17 @@ nsHTMLFrameInnerFrame::DoLoadURL(nsIPresContext* aPresContext)
|
|||
}
|
||||
if (!baseURL) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsAutoString docCharset;
|
||||
if (doc)
|
||||
(void) doc->GetDocumentCharacterSet(docCharset);
|
||||
|
||||
nsAutoString absURL;
|
||||
rv = NS_MakeAbsoluteURI(absURL, url, baseURL);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewURI(getter_AddRefs(uri), absURL);
|
||||
NS_NewURI(getter_AddRefs(uri), absURL,
|
||||
docCharset.IsEmpty() ? nsnull : NS_ConvertUCS2toUTF8(docCharset).get());
|
||||
|
||||
// Check for security
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan =
|
||||
|
|
Загрузка…
Ссылка в новой задаче