mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 908347 - make a bunch of html content sink stuff explicitly only deal with html:body r=mrbkap
This commit is contained in:
parent
705a930a75
commit
3a62231955
@ -163,9 +163,6 @@ public:
|
|||||||
NS_IMETHOD CloseContainer(ElementType aTag);
|
NS_IMETHOD CloseContainer(ElementType aTag);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
already_AddRefed<nsGenericHTMLElement>
|
|
||||||
CreateContentObject(nsHTMLTag aNodeType);
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void SinkTraceNode(uint32_t aBit,
|
void SinkTraceNode(uint32_t aBit,
|
||||||
const char* aMsg,
|
const char* aMsg,
|
||||||
@ -205,7 +202,7 @@ protected:
|
|||||||
|
|
||||||
// Routines for tags that require special handling
|
// Routines for tags that require special handling
|
||||||
nsresult CloseHTML();
|
nsresult CloseHTML();
|
||||||
nsresult OpenBody(nsHTMLTag aNodeType);
|
nsresult OpenBody();
|
||||||
nsresult CloseBody();
|
nsresult CloseBody();
|
||||||
|
|
||||||
void CloseHeadContext();
|
void CloseHeadContext();
|
||||||
@ -233,7 +230,7 @@ public:
|
|||||||
|
|
||||||
nsresult Begin(nsHTMLTag aNodeType, nsGenericHTMLElement* aRoot,
|
nsresult Begin(nsHTMLTag aNodeType, nsGenericHTMLElement* aRoot,
|
||||||
uint32_t aNumFlushed, int32_t aInsertionPoint);
|
uint32_t aNumFlushed, int32_t aInsertionPoint);
|
||||||
nsresult OpenContainer(nsHTMLTag aNodeType);
|
nsresult OpenBody();
|
||||||
nsresult CloseContainer(const nsHTMLTag aTag);
|
nsresult CloseContainer(const nsHTMLTag aTag);
|
||||||
nsresult AddLeaf(nsIContent* aContent);
|
nsresult AddLeaf(nsIContent* aContent);
|
||||||
nsresult End();
|
nsresult End();
|
||||||
@ -309,39 +306,6 @@ HTMLContentSink::SinkTraceNode(uint32_t aBit,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
|
||||||
* Factory subroutine to create all of the html content objects.
|
|
||||||
*/
|
|
||||||
already_AddRefed<nsGenericHTMLElement>
|
|
||||||
HTMLContentSink::CreateContentObject(nsHTMLTag aNodeType)
|
|
||||||
{
|
|
||||||
// Find/create atom for the tag name
|
|
||||||
|
|
||||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
|
||||||
|
|
||||||
MOZ_ASSERT(aNodeType != eHTMLTag_userdefined);
|
|
||||||
if (mNodeInfoCache[aNodeType]) {
|
|
||||||
nodeInfo = mNodeInfoCache[aNodeType];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
nsIParserService *parserService = nsContentUtils::GetParserService();
|
|
||||||
if (!parserService)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
nsIAtom *name = parserService->HTMLIdToAtomTag(aNodeType);
|
|
||||||
NS_ASSERTION(name, "What? Reverse mapping of id to string broken!!!");
|
|
||||||
|
|
||||||
nodeInfo = mNodeInfoManager->GetNodeInfo(name, nullptr, kNameSpaceID_XHTML,
|
|
||||||
nsIDOMNode::ELEMENT_NODE);
|
|
||||||
NS_IF_ADDREF(mNodeInfoCache[aNodeType] = nodeInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_ENSURE_TRUE(nodeInfo, nullptr);
|
|
||||||
|
|
||||||
// Make the content object
|
|
||||||
return CreateHTMLElement(aNodeType, nodeInfo.forget(), FROM_PARSER_NETWORK);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
NS_NewHTMLElement(nsIContent** aResult, already_AddRefed<nsINodeInfo> aNodeInfo,
|
NS_NewHTMLElement(nsIContent** aResult, already_AddRefed<nsINodeInfo> aNodeInfo,
|
||||||
FromParser aFromParser)
|
FromParser aFromParser)
|
||||||
@ -494,13 +458,13 @@ SinkContext::DidAddContent(nsIContent* aContent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
SinkContext::OpenContainer(nsHTMLTag aNodeType)
|
SinkContext::OpenBody()
|
||||||
{
|
{
|
||||||
FlushTextAndRelease();
|
FlushTextAndRelease();
|
||||||
|
|
||||||
SINK_TRACE_NODE(SINK_TRACE_CALLS,
|
SINK_TRACE_NODE(SINK_TRACE_CALLS,
|
||||||
"SinkContext::OpenContainer",
|
"SinkContext::OpenContainer",
|
||||||
aNodeType,
|
eHTMLTag_body,
|
||||||
mStackPos,
|
mStackPos,
|
||||||
mSink);
|
mSink);
|
||||||
|
|
||||||
@ -518,48 +482,25 @@ SinkContext::OpenContainer(nsHTMLTag aNodeType)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new container content object
|
nsCOMPtr<nsINodeInfo> nodeInfo =
|
||||||
nsGenericHTMLElement* content =
|
mSink->mNodeInfoManager->GetNodeInfo(nsGkAtoms::body, nullptr,
|
||||||
mSink->CreateContentObject(aNodeType).get();
|
kNameSpaceID_XHTML,
|
||||||
if (!content) {
|
nsIDOMNode::ELEMENT_NODE);
|
||||||
|
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_UNEXPECTED);
|
||||||
|
|
||||||
|
// Make the content object
|
||||||
|
nsRefPtr<nsGenericHTMLElement> body =
|
||||||
|
NS_NewHTMLBodyElement(nodeInfo.forget(), FROM_PARSER_NETWORK);
|
||||||
|
if (!body) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
mStack[mStackPos].mType = aNodeType;
|
mStack[mStackPos].mType = eHTMLTag_body;
|
||||||
mStack[mStackPos].mContent = content;
|
body.forget(&mStack[mStackPos].mContent);
|
||||||
mStack[mStackPos].mNumFlushed = 0;
|
mStack[mStackPos].mNumFlushed = 0;
|
||||||
mStack[mStackPos].mInsertionPoint = -1;
|
mStack[mStackPos].mInsertionPoint = -1;
|
||||||
++mStackPos;
|
++mStackPos;
|
||||||
mStack[mStackPos - 2].Add(content);
|
mStack[mStackPos - 2].Add(mStack[mStackPos - 1].mContent);
|
||||||
if (mSink->IsMonolithicContainer(aNodeType)) {
|
|
||||||
mSink->mInMonolithicContainer++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Special handling for certain tags
|
|
||||||
switch (aNodeType) {
|
|
||||||
case eHTMLTag_form:
|
|
||||||
MOZ_CRASH("Must not use HTMLContentSink for forms.");
|
|
||||||
|
|
||||||
case eHTMLTag_frameset:
|
|
||||||
MOZ_CRASH("Must not use HTMLContentSink for frames.");
|
|
||||||
|
|
||||||
case eHTMLTag_noembed:
|
|
||||||
case eHTMLTag_noframes:
|
|
||||||
MOZ_CRASH("Must not use HTMLContentSink for noembed/noframes.");
|
|
||||||
|
|
||||||
case eHTMLTag_script:
|
|
||||||
case eHTMLTag_style:
|
|
||||||
MOZ_CRASH("Must not use HTMLContentSink for styles and scripts.");
|
|
||||||
|
|
||||||
case eHTMLTag_button:
|
|
||||||
case eHTMLTag_audio:
|
|
||||||
case eHTMLTag_video:
|
|
||||||
content->DoneCreatingElement();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@ -1318,7 +1259,7 @@ HTMLContentSink::CloseHTML()
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
HTMLContentSink::OpenBody(nsHTMLTag aNodeType)
|
HTMLContentSink::OpenBody()
|
||||||
{
|
{
|
||||||
SINK_TRACE_NODE(SINK_TRACE_CALLS,
|
SINK_TRACE_NODE(SINK_TRACE_CALLS,
|
||||||
"HTMLContentSink::OpenBody",
|
"HTMLContentSink::OpenBody",
|
||||||
@ -1333,7 +1274,7 @@ HTMLContentSink::OpenBody(nsHTMLTag aNodeType)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult rv = mCurrentContext->OpenContainer(aNodeType);
|
nsresult rv = mCurrentContext->OpenBody();
|
||||||
|
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
return rv;
|
return rv;
|
||||||
@ -1406,7 +1347,7 @@ HTMLContentSink::OpenContainer(ElementType aElementType)
|
|||||||
|
|
||||||
switch (aElementType) {
|
switch (aElementType) {
|
||||||
case eBody:
|
case eBody:
|
||||||
rv = OpenBody(eHTMLTag_body);
|
rv = OpenBody();
|
||||||
break;
|
break;
|
||||||
case eHTML:
|
case eHTML:
|
||||||
if (mRoot) {
|
if (mRoot) {
|
||||||
|
Loading…
Reference in New Issue
Block a user