Only propagate the body background to the canvas in HTML documents; don't do it

for XHTML.   Bug 214969, r+sr=dbaron
This commit is contained in:
bzbarsky@mit.edu
2003-10-15 02:48:25 +00:00
parent f0b6893e06
commit 0f6cfe86d1
2 changed files with 58 additions and 38 deletions

View File

@@ -65,6 +65,7 @@
#include "nsIDOMHTMLBodyElement.h" #include "nsIDOMHTMLBodyElement.h"
#include "nsIDOMHTMLDocument.h" #include "nsIDOMHTMLDocument.h"
#include "nsLayoutUtils.h" #include "nsLayoutUtils.h"
#include "nsINameSpaceManager.h"
#define BORDER_FULL 0 //entire side #define BORDER_FULL 0 //entire side
#define BORDER_INSIDE 1 //inside half #define BORDER_INSIDE 1 //inside half
@@ -2695,6 +2696,9 @@ FindCanvasBackground(nsIPresContext* aPresContext,
node->GetOwnerDocument(getter_AddRefs(doc)); node->GetOwnerDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryInterface(doc); nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryInterface(doc);
if (htmlDoc) { if (htmlDoc) {
PRInt32 namespaceID;
content->GetNameSpaceID(&namespaceID);
if (namespaceID == kNameSpaceID_None) { // HTML, not XHTML
nsCOMPtr<nsIDOMHTMLElement> body; nsCOMPtr<nsIDOMHTMLElement> body;
htmlDoc->GetBody(getter_AddRefs(body)); htmlDoc->GetBody(getter_AddRefs(body));
nsCOMPtr<nsIContent> bodyContent = do_QueryInterface(body); nsCOMPtr<nsIContent> bodyContent = do_QueryInterface(body);
@@ -2718,6 +2722,7 @@ FindCanvasBackground(nsIPresContext* aPresContext,
} }
} }
} }
}
*aBackground = result; *aBackground = result;
} else { } else {
@@ -2751,6 +2756,11 @@ FindElementBackground(nsIPresContext* aPresContext,
if (!content || !content->IsContentOfType(nsIContent::eHTML)) if (!content || !content->IsContentOfType(nsIContent::eHTML))
return PR_TRUE; // not frame for an HTML element return PR_TRUE; // not frame for an HTML element
PRInt32 namespaceID;
content->GetNameSpaceID(&namespaceID);
if (namespaceID != kNameSpaceID_None) // This is XHTML, not HTML
return PR_TRUE;
if (!parentFrame) if (!parentFrame)
return PR_TRUE; // no parent to look at return PR_TRUE; // no parent to look at

View File

@@ -65,6 +65,7 @@
#include "nsIDOMHTMLBodyElement.h" #include "nsIDOMHTMLBodyElement.h"
#include "nsIDOMHTMLDocument.h" #include "nsIDOMHTMLDocument.h"
#include "nsLayoutUtils.h" #include "nsLayoutUtils.h"
#include "nsINameSpaceManager.h"
#define BORDER_FULL 0 //entire side #define BORDER_FULL 0 //entire side
#define BORDER_INSIDE 1 //inside half #define BORDER_INSIDE 1 //inside half
@@ -2695,6 +2696,9 @@ FindCanvasBackground(nsIPresContext* aPresContext,
node->GetOwnerDocument(getter_AddRefs(doc)); node->GetOwnerDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryInterface(doc); nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryInterface(doc);
if (htmlDoc) { if (htmlDoc) {
PRInt32 namespaceID;
content->GetNameSpaceID(&namespaceID);
if (namespaceID == kNameSpaceID_None) { // HTML, not XHTML
nsCOMPtr<nsIDOMHTMLElement> body; nsCOMPtr<nsIDOMHTMLElement> body;
htmlDoc->GetBody(getter_AddRefs(body)); htmlDoc->GetBody(getter_AddRefs(body));
nsCOMPtr<nsIContent> bodyContent = do_QueryInterface(body); nsCOMPtr<nsIContent> bodyContent = do_QueryInterface(body);
@@ -2718,6 +2722,7 @@ FindCanvasBackground(nsIPresContext* aPresContext,
} }
} }
} }
}
*aBackground = result; *aBackground = result;
} else { } else {
@@ -2751,6 +2756,11 @@ FindElementBackground(nsIPresContext* aPresContext,
if (!content || !content->IsContentOfType(nsIContent::eHTML)) if (!content || !content->IsContentOfType(nsIContent::eHTML))
return PR_TRUE; // not frame for an HTML element return PR_TRUE; // not frame for an HTML element
PRInt32 namespaceID;
content->GetNameSpaceID(&namespaceID);
if (namespaceID != kNameSpaceID_None) // This is XHTML, not HTML
return PR_TRUE;
if (!parentFrame) if (!parentFrame)
return PR_TRUE; // no parent to look at return PR_TRUE; // no parent to look at