From d0993e942b3b1ee82fcce38792f7302b3129dd76 Mon Sep 17 00:00:00 2001 From: "tor%cs.brown.edu" Date: Wed, 10 Nov 2004 19:02:52 +0000 Subject: [PATCH] Bug 240408 - allow SVG builds to handle SVG content in natively. r=dbaron, sr=jst git-svn-id: svn://10.0.0.236/trunk@165214 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsObjectFrame.cpp | 26 +++++++++++++------ mozilla/layout/generic/nsObjectFrame.h | 4 +-- .../layout/html/base/src/nsObjectFrame.cpp | 26 +++++++++++++------ mozilla/layout/html/base/src/nsObjectFrame.h | 4 +-- 4 files changed, 40 insertions(+), 20 deletions(-) diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index 3548deefb18..01032fcf9f8 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -469,7 +469,8 @@ nsObjectFrame::GetSkipSides() const // #define DO_DIRTY_INTERSECT 1 // enable dirty rect intersection during paint -PRBool nsObjectFrame::IsSupportedImage(nsIContent* aContent) +/* static */ PRBool +nsObjectFrame::IsSupportedImage(nsIContent* aContent) { if (!aContent) return PR_FALSE; @@ -517,7 +518,8 @@ PRBool nsObjectFrame::IsSupportedImage(nsIContent* aContent) return NS_SUCCEEDED(rv) && supported; } -PRBool nsObjectFrame::IsSupportedDocument(nsIContent* aContent) +/* static */ PRBool +nsObjectFrame::IsSupportedDocument(nsIContent* aContent) { nsresult rv; @@ -534,7 +536,13 @@ PRBool nsObjectFrame::IsSupportedDocument(nsIContent* aContent) { // if we don't have a TYPE= try getting the mime-type via the DATA= url nsAutoString data; - rv = aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, data); + // If this is an OBJECT tag, we should look for a DATA attribute. + // If not, it's an EMBED tag, and so we should look for a SRC attribute. + if (aContent->Tag() == nsHTMLAtoms::object) + rv = aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, data); + else + rv = aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, data); + if (rv != NS_CONTENT_ATTR_HAS_VALUE || data.IsEmpty()) { return PR_FALSE; } @@ -553,6 +561,13 @@ PRBool nsObjectFrame::IsSupportedDocument(nsIContent* aContent) } else { CopyUTF16toUTF8(type, typeStr); } + + // only allow browser to handle content of for svg (bug 240408) + if (aContent->Tag() == nsHTMLAtoms::embed) +#ifdef MOZ_SVG + if (!typeStr.LowerCaseEqualsLiteral("image/svg+xml")) +#endif + return PR_FALSE; nsXPIDLCString value; rv = catman->GetCategoryEntry("Gecko-Content-Viewers", typeStr.get(), getter_Copies(value)); @@ -630,11 +645,6 @@ nsObjectFrame::Init(nsPresContext* aPresContext, return rv; // bail at this point } - - // only do the following for the object tag - if (aContent->Tag() != nsHTMLAtoms::object) - return rv; - // for now, we should try to do the same for "document" types and create // and IFrame-like sub-frame PRBool bDoc = IsSupportedDocument(aContent); diff --git a/mozilla/layout/generic/nsObjectFrame.h b/mozilla/layout/generic/nsObjectFrame.h index a1a06e31480..9605ee672b3 100644 --- a/mozilla/layout/generic/nsObjectFrame.h +++ b/mozilla/layout/generic/nsObjectFrame.h @@ -118,8 +118,8 @@ public: PRBool aViewOnly); nsIURI* GetFullURL() { return mFullURL; } - PRBool IsSupportedImage(nsIContent* aContent); - PRBool IsSupportedDocument(nsIContent* aContent); + static PRBool IsSupportedImage(nsIContent* aContent); + static PRBool IsSupportedDocument(nsIContent* aContent); // for a given aRoot, this walks the frame tree looking for the next outFrame static nsIObjectFrame* GetNextObjectFrame(nsPresContext* aPresContext, diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index 3548deefb18..01032fcf9f8 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -469,7 +469,8 @@ nsObjectFrame::GetSkipSides() const // #define DO_DIRTY_INTERSECT 1 // enable dirty rect intersection during paint -PRBool nsObjectFrame::IsSupportedImage(nsIContent* aContent) +/* static */ PRBool +nsObjectFrame::IsSupportedImage(nsIContent* aContent) { if (!aContent) return PR_FALSE; @@ -517,7 +518,8 @@ PRBool nsObjectFrame::IsSupportedImage(nsIContent* aContent) return NS_SUCCEEDED(rv) && supported; } -PRBool nsObjectFrame::IsSupportedDocument(nsIContent* aContent) +/* static */ PRBool +nsObjectFrame::IsSupportedDocument(nsIContent* aContent) { nsresult rv; @@ -534,7 +536,13 @@ PRBool nsObjectFrame::IsSupportedDocument(nsIContent* aContent) { // if we don't have a TYPE= try getting the mime-type via the DATA= url nsAutoString data; - rv = aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, data); + // If this is an OBJECT tag, we should look for a DATA attribute. + // If not, it's an EMBED tag, and so we should look for a SRC attribute. + if (aContent->Tag() == nsHTMLAtoms::object) + rv = aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, data); + else + rv = aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, data); + if (rv != NS_CONTENT_ATTR_HAS_VALUE || data.IsEmpty()) { return PR_FALSE; } @@ -553,6 +561,13 @@ PRBool nsObjectFrame::IsSupportedDocument(nsIContent* aContent) } else { CopyUTF16toUTF8(type, typeStr); } + + // only allow browser to handle content of for svg (bug 240408) + if (aContent->Tag() == nsHTMLAtoms::embed) +#ifdef MOZ_SVG + if (!typeStr.LowerCaseEqualsLiteral("image/svg+xml")) +#endif + return PR_FALSE; nsXPIDLCString value; rv = catman->GetCategoryEntry("Gecko-Content-Viewers", typeStr.get(), getter_Copies(value)); @@ -630,11 +645,6 @@ nsObjectFrame::Init(nsPresContext* aPresContext, return rv; // bail at this point } - - // only do the following for the object tag - if (aContent->Tag() != nsHTMLAtoms::object) - return rv; - // for now, we should try to do the same for "document" types and create // and IFrame-like sub-frame PRBool bDoc = IsSupportedDocument(aContent); diff --git a/mozilla/layout/html/base/src/nsObjectFrame.h b/mozilla/layout/html/base/src/nsObjectFrame.h index a1a06e31480..9605ee672b3 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.h +++ b/mozilla/layout/html/base/src/nsObjectFrame.h @@ -118,8 +118,8 @@ public: PRBool aViewOnly); nsIURI* GetFullURL() { return mFullURL; } - PRBool IsSupportedImage(nsIContent* aContent); - PRBool IsSupportedDocument(nsIContent* aContent); + static PRBool IsSupportedImage(nsIContent* aContent); + static PRBool IsSupportedDocument(nsIContent* aContent); // for a given aRoot, this walks the frame tree looking for the next outFrame static nsIObjectFrame* GetNextObjectFrame(nsPresContext* aPresContext,