Comments added to content model. Comments and text content now have a special tagname

git-svn-id: svn://10.0.0.236/trunk@18362 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
vidur%netscape.com
1999-01-22 22:48:00 +00:00
parent bb9e8f162b
commit ea2adbea24
29 changed files with 231 additions and 35 deletions

View File

@@ -22,6 +22,7 @@
#include "nsIDOMEventReceiver.h"
#include "nsIContent.h"
#include "nsFrame.h"
#include "nsLayoutAtoms.h"
static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
@@ -100,6 +101,14 @@ nsCommentNode::QueryInterface(REFNSIID aIID, void** aInstancePtr)
return NS_NOINTERFACE;
}
NS_IMETHODIMP
nsCommentNode::GetTag(nsIAtom*& aResult) const
{
aResult = nsLayoutAtoms::commentTagName;
NS_ADDREF(aResult);
return NS_OK;
}
NS_IMETHODIMP
nsCommentNode::GetNodeName(nsString& aNodeName)
{
@@ -141,7 +150,7 @@ nsCommentNode::List(FILE* out, PRInt32 aIndent) const
PRInt32 index;
for (index = aIndent; --index >= 0; ) fputs(" ", out);
fprintf(out, " refcount=%d<", mRefCnt);
fprintf(out, "Comment refcount=%d<", mRefCnt);
nsAutoString tmp;
mInner.ToCString(tmp, 0, mInner.mText.GetLength());

View File

@@ -25,6 +25,7 @@
#include "nsIDOMScriptObjectFactory.h"
#include "nsGenericElement.h"
#include "nsLayoutAtoms.h"
#include "nsHTMLAtoms.h" // XXX until atoms get factored into nsLayoutAtoms
nsIAtom* nsContentList::gWildCardAtom = nsnull;
@@ -320,7 +321,8 @@ nsContentList::Match(nsIContent *aContent, PRBool *aMatch)
// If we have to match all, only do those that have
// a tagName i.e. only the elements.
if (mMatchAll && (nsnull != name)) {
if (mMatchAll && (nsLayoutAtoms::textTagName != name) &&
(nsLayoutAtoms::commentTagName != name)) {
*aMatch = PR_TRUE;
}
// XXX We don't yet match on namespace. Maybe we should??

View File

@@ -125,10 +125,6 @@ struct nsGenericDOMDataNode {
aID = kNameSpaceID_None;
return NS_OK;
}
nsresult GetTag(nsIAtom*& aResult) const {
aResult = nsnull;
return NS_OK;
}
nsresult ParseAttributeString(const nsString& aStr,
nsIAtom*& aName,
PRInt32& aNameSpaceID) {
@@ -393,9 +389,7 @@ struct nsGenericDOMDataNode {
NS_IMETHOD GetNameSpaceID(PRInt32& aID) const { \
return _g.GetNameSpaceID(aID); \
} \
NS_IMETHOD GetTag(nsIAtom*& aResult) const { \
return _g.GetTag(aResult); \
} \
NS_IMETHOD GetTag(nsIAtom*& aResult) const; \
NS_IMETHOD ParseAttributeString(const nsString& aStr, \
nsIAtom*& aName, \
PRInt32& aNameSpaceID) { \

View File

@@ -25,6 +25,7 @@
#include "nsFrame.h"
#include "nsIDocument.h"
#include "nsCRT.h"
#include "nsLayoutAtoms.h"
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
static NS_DEFINE_IID(kITextContentIID, NS_ITEXT_CONTENT_IID);
@@ -124,6 +125,14 @@ nsTextNode::QueryInterface(REFNSIID aIID, void** aInstancePtr)
return NS_NOINTERFACE;
}
NS_IMETHODIMP
nsTextNode::GetTag(nsIAtom*& aResult) const
{
aResult = nsLayoutAtoms::textTagName;
NS_ADDREF(aResult);
return NS_OK;
}
NS_IMETHODIMP
nsTextNode::GetNodeName(nsString& aNodeName)
{

View File

@@ -71,6 +71,7 @@ nsIAtom* nsHTMLAtoms::colgroup;
nsIAtom* nsHTMLAtoms::cols;
nsIAtom* nsHTMLAtoms::colspan;
nsIAtom* nsHTMLAtoms::columnPseudo;
nsIAtom* nsHTMLAtoms::commentPseudo;
nsIAtom* nsHTMLAtoms::compact;
nsIAtom* nsHTMLAtoms::content;
nsIAtom* nsHTMLAtoms::coords;
@@ -314,6 +315,7 @@ void nsHTMLAtoms::AddrefAtoms()
cols = NS_NewAtom("COLS");
colspan = NS_NewAtom("COLSPAN");
columnPseudo = NS_NewAtom(":BODY-COLUMN");
commentPseudo = NS_NewAtom(":MOZ-COMMENT");
compact = NS_NewAtom("COMPACT");
content = NS_NewAtom("CONTENT");
coords = NS_NewAtom("COORDS");
@@ -473,7 +475,7 @@ void nsHTMLAtoms::AddrefAtoms()
thead = NS_NewAtom("THEAD");
text = NS_NewAtom("TEXT");
textarea = NS_NewAtom("TEXTAREA");
textPseudo = NS_NewAtom(":TEXT");
textPseudo = NS_NewAtom(":MOZ-TEXT");
th = NS_NewAtom("TH");
title = NS_NewAtom("TITLE");
top = NS_NewAtom("TOP");
@@ -553,6 +555,7 @@ void nsHTMLAtoms::ReleaseAtoms()
NS_RELEASE(cols);
NS_RELEASE(colspan);
NS_RELEASE(columnPseudo);
NS_RELEASE(commentPseudo);
NS_RELEASE(compact);
NS_RELEASE(content);
NS_RELEASE(coords);

View File

@@ -93,6 +93,7 @@ public:
static nsIAtom* cols;
static nsIAtom* colspan;
static nsIAtom* columnPseudo;
static nsIAtom* commentPseudo;
static nsIAtom* compact;
static nsIAtom* content;
static nsIAtom* coords;

View File

@@ -37,6 +37,7 @@
#include "nsITextContent.h"
#include "nsIDOMText.h"
#include "nsIDOMComment.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsIDOMHTMLTextAreaElement.h"
@@ -72,6 +73,7 @@ static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
static NS_DEFINE_IID(kIHTMLContentIID, NS_IHTMLCONTENT_IID);
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
static NS_DEFINE_IID(kIDOMHTMLFormElementIID, NS_IDOMHTMLFORMELEMENT_IID);
static NS_DEFINE_IID(kIDOMHTMLMapElementIID, NS_IDOMHTMLMAPELEMENT_IID);
static NS_DEFINE_IID(kIDOMHTMLTextAreaElementIID, NS_IDOMHTMLTEXTAREAELEMENT_IID);
@@ -262,6 +264,7 @@ public:
nsresult CloseContainer(const nsIParserNode& aNode);
nsresult AddLeaf(const nsIParserNode& aNode);
nsresult AddLeaf(nsIHTMLContent* aContent);
nsresult AddComment(const nsIParserNode& aNode);
nsresult End();
nsresult GrowStack();
@@ -1108,6 +1111,43 @@ SinkContext::AddLeaf(nsIHTMLContent* aContent)
return NS_OK;
}
nsresult
SinkContext::AddComment(const nsIParserNode& aNode)
{
nsIContent *comment;
nsIDOMComment *domComment;
nsresult result = NS_OK;
FlushText();
result = NS_NewCommentNode(&comment);
if (NS_OK == result) {
result = comment->QueryInterface(kIDOMCommentIID,
(void **)&domComment);
if (NS_OK == result) {
domComment->AppendData(aNode.GetText());
NS_RELEASE(domComment);
comment->SetDocument(mSink->mDocument, PR_FALSE);
nsIHTMLContent* parent;
if ((nsnull == mSink->mBody) && (nsnull != mSink->mHead)) {
parent = mSink->mHead;
}
else {
parent = mStack[mStackPos - 1].mContent;
}
parent->AppendChildTo(comment, PR_FALSE);
// Mark sink dirty if it can safely reflow something
MaybeMarkSinkDirty();
}
NS_RELEASE(comment);
}
return result;
}
nsresult
SinkContext::End()
{
@@ -1877,8 +1917,7 @@ HTMLContentSink::AddLeaf(const nsIParserNode& aNode)
* @return error code
*/
nsresult HTMLContentSink::AddComment(const nsIParserNode& aNode) {
nsresult result= NS_OK;
return result;
return mCurrentContext->AddComment(aNode);
}
/**

View File

@@ -1825,7 +1825,7 @@ HTMLStyleSheetImpl::ConstructFrameByTag(nsIPresContext* aPresContext,
// Initialize OUT parameter
aNewFrame = nsnull;
if (nsnull == aTag) {
if (nsLayoutAtoms::textTagName == aTag) {
rv = NS_NewTextFrame(aNewFrame);
}
else {
@@ -2778,7 +2778,7 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
nsIStyleContext* parentStyleContext;
aParentFrame->GetStyleContext(parentStyleContext);
if (nsnull == tag) {
if (nsLayoutAtoms::textTagName == tag) {
// Use a special pseudo element style context for text
nsIContent* parentContent = nsnull;
if (nsnull != aParentFrame) {
@@ -2789,6 +2789,18 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
parentStyleContext);
rv = (nsnull == styleContext) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
NS_IF_RELEASE(parentContent);
} else if (nsLayoutAtoms::commentTagName == tag) {
// Use a special pseudo element style context for comments
nsIContent* parentContent = nsnull;
if (nsnull != aParentFrame) {
aParentFrame->GetContent(parentContent);
}
styleContext = aPresContext->ResolvePseudoStyleContextFor(parentContent,
nsHTMLAtoms::commentPseudo,
parentStyleContext);
rv = (nsnull == styleContext) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
NS_IF_RELEASE(parentContent);
} else {
styleContext = aPresContext->ResolveStyleContextFor(aContent, parentStyleContext);
rv = (nsnull == styleContext) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;

View File

@@ -93,6 +93,7 @@ public:
static nsIAtom* cols;
static nsIAtom* colspan;
static nsIAtom* columnPseudo;
static nsIAtom* commentPseudo;
static nsIAtom* compact;
static nsIAtom* content;
static nsIAtom* coords;

View File

@@ -55,6 +55,10 @@ public:
static nsIAtom* bulletList;
static nsIAtom* colGroupList;
static nsIAtom* floaterList;
// Alphabetical list of pseudo tag names for non-element content
static nsIAtom* textTagName;
static nsIAtom* commentTagName;
};
#endif /* nsLayoutAtoms_h___ */

View File

@@ -71,6 +71,7 @@ nsIAtom* nsHTMLAtoms::colgroup;
nsIAtom* nsHTMLAtoms::cols;
nsIAtom* nsHTMLAtoms::colspan;
nsIAtom* nsHTMLAtoms::columnPseudo;
nsIAtom* nsHTMLAtoms::commentPseudo;
nsIAtom* nsHTMLAtoms::compact;
nsIAtom* nsHTMLAtoms::content;
nsIAtom* nsHTMLAtoms::coords;
@@ -314,6 +315,7 @@ void nsHTMLAtoms::AddrefAtoms()
cols = NS_NewAtom("COLS");
colspan = NS_NewAtom("COLSPAN");
columnPseudo = NS_NewAtom(":BODY-COLUMN");
commentPseudo = NS_NewAtom(":MOZ-COMMENT");
compact = NS_NewAtom("COMPACT");
content = NS_NewAtom("CONTENT");
coords = NS_NewAtom("COORDS");
@@ -473,7 +475,7 @@ void nsHTMLAtoms::AddrefAtoms()
thead = NS_NewAtom("THEAD");
text = NS_NewAtom("TEXT");
textarea = NS_NewAtom("TEXTAREA");
textPseudo = NS_NewAtom(":TEXT");
textPseudo = NS_NewAtom(":MOZ-TEXT");
th = NS_NewAtom("TH");
title = NS_NewAtom("TITLE");
top = NS_NewAtom("TOP");
@@ -553,6 +555,7 @@ void nsHTMLAtoms::ReleaseAtoms()
NS_RELEASE(cols);
NS_RELEASE(colspan);
NS_RELEASE(columnPseudo);
NS_RELEASE(commentPseudo);
NS_RELEASE(compact);
NS_RELEASE(content);
NS_RELEASE(coords);

View File

@@ -42,6 +42,8 @@ nsIAtom* nsLayoutAtoms::bulletList;
nsIAtom* nsLayoutAtoms::colGroupList;
nsIAtom* nsLayoutAtoms::floaterList;
nsIAtom* nsLayoutAtoms::textTagName;
nsIAtom* nsLayoutAtoms::commentTagName;
static nsrefcnt gRefCnt;
@@ -67,6 +69,9 @@ void nsLayoutAtoms::AddrefAtoms()
bulletList = NS_NewAtom("Bullet-list");
colGroupList = NS_NewAtom("ColGroup-list");
floaterList = NS_NewAtom("Floater-list");
textTagName = NS_NewAtom("__moz_text");
commentTagName = NS_NewAtom("__moz_comment");
}
++gRefCnt;
}
@@ -94,6 +99,9 @@ void nsLayoutAtoms::ReleaseAtoms()
NS_RELEASE(bulletList);
NS_RELEASE(colGroupList);
NS_RELEASE(floaterList);
NS_RELEASE(textTagName);
NS_RELEASE(commentTagName);
}
}

View File

@@ -42,6 +42,8 @@ nsIAtom* nsLayoutAtoms::bulletList;
nsIAtom* nsLayoutAtoms::colGroupList;
nsIAtom* nsLayoutAtoms::floaterList;
nsIAtom* nsLayoutAtoms::textTagName;
nsIAtom* nsLayoutAtoms::commentTagName;
static nsrefcnt gRefCnt;
@@ -67,6 +69,9 @@ void nsLayoutAtoms::AddrefAtoms()
bulletList = NS_NewAtom("Bullet-list");
colGroupList = NS_NewAtom("ColGroup-list");
floaterList = NS_NewAtom("Floater-list");
textTagName = NS_NewAtom("__moz_text");
commentTagName = NS_NewAtom("__moz_comment");
}
++gRefCnt;
}
@@ -94,6 +99,9 @@ void nsLayoutAtoms::ReleaseAtoms()
NS_RELEASE(bulletList);
NS_RELEASE(colGroupList);
NS_RELEASE(floaterList);
NS_RELEASE(textTagName);
NS_RELEASE(commentTagName);
}
}

View File

@@ -55,6 +55,10 @@ public:
static nsIAtom* bulletList;
static nsIAtom* colGroupList;
static nsIAtom* floaterList;
// Alphabetical list of pseudo tag names for non-element content
static nsIAtom* textTagName;
static nsIAtom* commentTagName;
};
#endif /* nsLayoutAtoms_h___ */

View File

@@ -55,6 +55,10 @@ public:
static nsIAtom* bulletList;
static nsIAtom* colGroupList;
static nsIAtom* floaterList;
// Alphabetical list of pseudo tag names for non-element content
static nsIAtom* textTagName;
static nsIAtom* commentTagName;
};
#endif /* nsLayoutAtoms_h___ */

View File

@@ -22,6 +22,7 @@
#include "nsIDOMEventReceiver.h"
#include "nsIContent.h"
#include "nsFrame.h"
#include "nsLayoutAtoms.h"
static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
@@ -100,6 +101,14 @@ nsCommentNode::QueryInterface(REFNSIID aIID, void** aInstancePtr)
return NS_NOINTERFACE;
}
NS_IMETHODIMP
nsCommentNode::GetTag(nsIAtom*& aResult) const
{
aResult = nsLayoutAtoms::commentTagName;
NS_ADDREF(aResult);
return NS_OK;
}
NS_IMETHODIMP
nsCommentNode::GetNodeName(nsString& aNodeName)
{
@@ -141,7 +150,7 @@ nsCommentNode::List(FILE* out, PRInt32 aIndent) const
PRInt32 index;
for (index = aIndent; --index >= 0; ) fputs(" ", out);
fprintf(out, " refcount=%d<", mRefCnt);
fprintf(out, "Comment refcount=%d<", mRefCnt);
nsAutoString tmp;
mInner.ToCString(tmp, 0, mInner.mText.GetLength());

View File

@@ -25,6 +25,7 @@
#include "nsIDOMScriptObjectFactory.h"
#include "nsGenericElement.h"
#include "nsLayoutAtoms.h"
#include "nsHTMLAtoms.h" // XXX until atoms get factored into nsLayoutAtoms
nsIAtom* nsContentList::gWildCardAtom = nsnull;
@@ -320,7 +321,8 @@ nsContentList::Match(nsIContent *aContent, PRBool *aMatch)
// If we have to match all, only do those that have
// a tagName i.e. only the elements.
if (mMatchAll && (nsnull != name)) {
if (mMatchAll && (nsLayoutAtoms::textTagName != name) &&
(nsLayoutAtoms::commentTagName != name)) {
*aMatch = PR_TRUE;
}
// XXX We don't yet match on namespace. Maybe we should??

View File

@@ -125,10 +125,6 @@ struct nsGenericDOMDataNode {
aID = kNameSpaceID_None;
return NS_OK;
}
nsresult GetTag(nsIAtom*& aResult) const {
aResult = nsnull;
return NS_OK;
}
nsresult ParseAttributeString(const nsString& aStr,
nsIAtom*& aName,
PRInt32& aNameSpaceID) {
@@ -393,9 +389,7 @@ struct nsGenericDOMDataNode {
NS_IMETHOD GetNameSpaceID(PRInt32& aID) const { \
return _g.GetNameSpaceID(aID); \
} \
NS_IMETHOD GetTag(nsIAtom*& aResult) const { \
return _g.GetTag(aResult); \
} \
NS_IMETHOD GetTag(nsIAtom*& aResult) const; \
NS_IMETHOD ParseAttributeString(const nsString& aStr, \
nsIAtom*& aName, \
PRInt32& aNameSpaceID) { \

View File

@@ -42,6 +42,8 @@ nsIAtom* nsLayoutAtoms::bulletList;
nsIAtom* nsLayoutAtoms::colGroupList;
nsIAtom* nsLayoutAtoms::floaterList;
nsIAtom* nsLayoutAtoms::textTagName;
nsIAtom* nsLayoutAtoms::commentTagName;
static nsrefcnt gRefCnt;
@@ -67,6 +69,9 @@ void nsLayoutAtoms::AddrefAtoms()
bulletList = NS_NewAtom("Bullet-list");
colGroupList = NS_NewAtom("ColGroup-list");
floaterList = NS_NewAtom("Floater-list");
textTagName = NS_NewAtom("__moz_text");
commentTagName = NS_NewAtom("__moz_comment");
}
++gRefCnt;
}
@@ -94,6 +99,9 @@ void nsLayoutAtoms::ReleaseAtoms()
NS_RELEASE(bulletList);
NS_RELEASE(colGroupList);
NS_RELEASE(floaterList);
NS_RELEASE(textTagName);
NS_RELEASE(commentTagName);
}
}

View File

@@ -25,6 +25,7 @@
#include "nsFrame.h"
#include "nsIDocument.h"
#include "nsCRT.h"
#include "nsLayoutAtoms.h"
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
static NS_DEFINE_IID(kITextContentIID, NS_ITEXT_CONTENT_IID);
@@ -124,6 +125,14 @@ nsTextNode::QueryInterface(REFNSIID aIID, void** aInstancePtr)
return NS_NOINTERFACE;
}
NS_IMETHODIMP
nsTextNode::GetTag(nsIAtom*& aResult) const
{
aResult = nsLayoutAtoms::textTagName;
NS_ADDREF(aResult);
return NS_OK;
}
NS_IMETHODIMP
nsTextNode::GetNodeName(nsString& aNodeName)
{

View File

@@ -43,6 +43,7 @@
#include "nsIEventStateManager.h"
#include "nsIFocusTracker.h"
#include "nsHTMLParts.h"
#include "nsLayoutAtoms.h"
// Some Misc #defines
#define SELECTION_DEBUG 0
@@ -1609,7 +1610,7 @@ nsFrame::MakeFrameName(const char* aType, nsString& aResult) const
if (nsnull != mContent) {
nsIAtom* tag;
mContent->GetTag(tag);
if (tag != nsnull) {
if ((tag != nsnull) && (tag != nsLayoutAtoms::textTagName)) {
aResult.Append("(");
nsAutoString buf;
tag->ToString(buf);

View File

@@ -43,6 +43,7 @@
#include "nsIEventStateManager.h"
#include "nsIFocusTracker.h"
#include "nsHTMLParts.h"
#include "nsLayoutAtoms.h"
// Some Misc #defines
#define SELECTION_DEBUG 0
@@ -1609,7 +1610,7 @@ nsFrame::MakeFrameName(const char* aType, nsString& aResult) const
if (nsnull != mContent) {
nsIAtom* tag;
mContent->GetTag(tag);
if (tag != nsnull) {
if ((tag != nsnull) && (tag != nsLayoutAtoms::textTagName)) {
aResult.Append("(");
nsAutoString buf;
tag->ToString(buf);

View File

@@ -71,6 +71,7 @@ nsIAtom* nsHTMLAtoms::colgroup;
nsIAtom* nsHTMLAtoms::cols;
nsIAtom* nsHTMLAtoms::colspan;
nsIAtom* nsHTMLAtoms::columnPseudo;
nsIAtom* nsHTMLAtoms::commentPseudo;
nsIAtom* nsHTMLAtoms::compact;
nsIAtom* nsHTMLAtoms::content;
nsIAtom* nsHTMLAtoms::coords;
@@ -314,6 +315,7 @@ void nsHTMLAtoms::AddrefAtoms()
cols = NS_NewAtom("COLS");
colspan = NS_NewAtom("COLSPAN");
columnPseudo = NS_NewAtom(":BODY-COLUMN");
commentPseudo = NS_NewAtom(":MOZ-COMMENT");
compact = NS_NewAtom("COMPACT");
content = NS_NewAtom("CONTENT");
coords = NS_NewAtom("COORDS");
@@ -473,7 +475,7 @@ void nsHTMLAtoms::AddrefAtoms()
thead = NS_NewAtom("THEAD");
text = NS_NewAtom("TEXT");
textarea = NS_NewAtom("TEXTAREA");
textPseudo = NS_NewAtom(":TEXT");
textPseudo = NS_NewAtom(":MOZ-TEXT");
th = NS_NewAtom("TH");
title = NS_NewAtom("TITLE");
top = NS_NewAtom("TOP");
@@ -553,6 +555,7 @@ void nsHTMLAtoms::ReleaseAtoms()
NS_RELEASE(cols);
NS_RELEASE(colspan);
NS_RELEASE(columnPseudo);
NS_RELEASE(commentPseudo);
NS_RELEASE(compact);
NS_RELEASE(content);
NS_RELEASE(coords);

View File

@@ -93,6 +93,7 @@ public:
static nsIAtom* cols;
static nsIAtom* colspan;
static nsIAtom* columnPseudo;
static nsIAtom* commentPseudo;
static nsIAtom* compact;
static nsIAtom* content;
static nsIAtom* coords;

View File

@@ -37,6 +37,7 @@
#include "nsITextContent.h"
#include "nsIDOMText.h"
#include "nsIDOMComment.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsIDOMHTMLTextAreaElement.h"
@@ -72,6 +73,7 @@ static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
static NS_DEFINE_IID(kIHTMLContentIID, NS_IHTMLCONTENT_IID);
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
static NS_DEFINE_IID(kIDOMHTMLFormElementIID, NS_IDOMHTMLFORMELEMENT_IID);
static NS_DEFINE_IID(kIDOMHTMLMapElementIID, NS_IDOMHTMLMAPELEMENT_IID);
static NS_DEFINE_IID(kIDOMHTMLTextAreaElementIID, NS_IDOMHTMLTEXTAREAELEMENT_IID);
@@ -262,6 +264,7 @@ public:
nsresult CloseContainer(const nsIParserNode& aNode);
nsresult AddLeaf(const nsIParserNode& aNode);
nsresult AddLeaf(nsIHTMLContent* aContent);
nsresult AddComment(const nsIParserNode& aNode);
nsresult End();
nsresult GrowStack();
@@ -1108,6 +1111,43 @@ SinkContext::AddLeaf(nsIHTMLContent* aContent)
return NS_OK;
}
nsresult
SinkContext::AddComment(const nsIParserNode& aNode)
{
nsIContent *comment;
nsIDOMComment *domComment;
nsresult result = NS_OK;
FlushText();
result = NS_NewCommentNode(&comment);
if (NS_OK == result) {
result = comment->QueryInterface(kIDOMCommentIID,
(void **)&domComment);
if (NS_OK == result) {
domComment->AppendData(aNode.GetText());
NS_RELEASE(domComment);
comment->SetDocument(mSink->mDocument, PR_FALSE);
nsIHTMLContent* parent;
if ((nsnull == mSink->mBody) && (nsnull != mSink->mHead)) {
parent = mSink->mHead;
}
else {
parent = mStack[mStackPos - 1].mContent;
}
parent->AppendChildTo(comment, PR_FALSE);
// Mark sink dirty if it can safely reflow something
MaybeMarkSinkDirty();
}
NS_RELEASE(comment);
}
return result;
}
nsresult
SinkContext::End()
{
@@ -1877,8 +1917,7 @@ HTMLContentSink::AddLeaf(const nsIParserNode& aNode)
* @return error code
*/
nsresult HTMLContentSink::AddComment(const nsIParserNode& aNode) {
nsresult result= NS_OK;
return result;
return mCurrentContext->AddComment(aNode);
}
/**

View File

@@ -581,4 +581,6 @@ NOFRAMES {
display: block;
}
:MOZ-COMMENT {
display: none;
}

View File

@@ -1825,7 +1825,7 @@ HTMLStyleSheetImpl::ConstructFrameByTag(nsIPresContext* aPresContext,
// Initialize OUT parameter
aNewFrame = nsnull;
if (nsnull == aTag) {
if (nsLayoutAtoms::textTagName == aTag) {
rv = NS_NewTextFrame(aNewFrame);
}
else {
@@ -2778,7 +2778,7 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
nsIStyleContext* parentStyleContext;
aParentFrame->GetStyleContext(parentStyleContext);
if (nsnull == tag) {
if (nsLayoutAtoms::textTagName == tag) {
// Use a special pseudo element style context for text
nsIContent* parentContent = nsnull;
if (nsnull != aParentFrame) {
@@ -2789,6 +2789,18 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
parentStyleContext);
rv = (nsnull == styleContext) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
NS_IF_RELEASE(parentContent);
} else if (nsLayoutAtoms::commentTagName == tag) {
// Use a special pseudo element style context for comments
nsIContent* parentContent = nsnull;
if (nsnull != aParentFrame) {
aParentFrame->GetContent(parentContent);
}
styleContext = aPresContext->ResolvePseudoStyleContextFor(parentContent,
nsHTMLAtoms::commentPseudo,
parentStyleContext);
rv = (nsnull == styleContext) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
NS_IF_RELEASE(parentContent);
} else {
styleContext = aPresContext->ResolveStyleContextFor(aContent, parentStyleContext);
rv = (nsnull == styleContext) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;

View File

@@ -1825,7 +1825,7 @@ HTMLStyleSheetImpl::ConstructFrameByTag(nsIPresContext* aPresContext,
// Initialize OUT parameter
aNewFrame = nsnull;
if (nsnull == aTag) {
if (nsLayoutAtoms::textTagName == aTag) {
rv = NS_NewTextFrame(aNewFrame);
}
else {
@@ -2778,7 +2778,7 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
nsIStyleContext* parentStyleContext;
aParentFrame->GetStyleContext(parentStyleContext);
if (nsnull == tag) {
if (nsLayoutAtoms::textTagName == tag) {
// Use a special pseudo element style context for text
nsIContent* parentContent = nsnull;
if (nsnull != aParentFrame) {
@@ -2789,6 +2789,18 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
parentStyleContext);
rv = (nsnull == styleContext) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
NS_IF_RELEASE(parentContent);
} else if (nsLayoutAtoms::commentTagName == tag) {
// Use a special pseudo element style context for comments
nsIContent* parentContent = nsnull;
if (nsnull != aParentFrame) {
aParentFrame->GetContent(parentContent);
}
styleContext = aPresContext->ResolvePseudoStyleContextFor(parentContent,
nsHTMLAtoms::commentPseudo,
parentStyleContext);
rv = (nsnull == styleContext) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
NS_IF_RELEASE(parentContent);
} else {
styleContext = aPresContext->ResolveStyleContextFor(aContent, parentStyleContext);
rv = (nsnull == styleContext) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;

View File

@@ -581,4 +581,6 @@ NOFRAMES {
display: block;
}
:MOZ-COMMENT {
display: none;
}