mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Backed out changeset 5e9663384022 (bug 1575620) for causing bustages in builds/worker/workspace/build/src/obj-firefox/dist/include/nsIContent.h CLOSED TREE
This commit is contained in:
parent
ff18afeafd
commit
b99fd194b2
@ -542,8 +542,9 @@ class nsIContent : public nsINode {
|
||||
* For container elements, this is called *before* any of the children are
|
||||
* created or added into the tree.
|
||||
*
|
||||
* NOTE: this is only called for elements listed in
|
||||
* RequiresDoneCreatingElement. This is an efficiency measure.
|
||||
* NOTE: this is currently only called for input and button, in the HTML
|
||||
* content sink. If you want to call it on your element, modify the content
|
||||
* sink of your choice to do so. This is an efficiency measure.
|
||||
*
|
||||
* If you also need to determine whether the parser is the one creating your
|
||||
* element (through createElement() or cloneNode() generally) then add a
|
||||
@ -564,8 +565,10 @@ class nsIContent : public nsINode {
|
||||
* This method is called when the parser finishes creating the element's
|
||||
* children, if any are present.
|
||||
*
|
||||
* NOTE: this is only called for elements listed in
|
||||
* RequiresDoneAddingChildren. This is an efficiency measure.
|
||||
* NOTE: this is currently only called for textarea, select, and object
|
||||
* elements in the HTML content sink. If you want to call it on your element,
|
||||
* modify the content sink of your choice to do so. This is an efficiency
|
||||
* measure.
|
||||
*
|
||||
* If you also need to determine whether the parser is the one creating your
|
||||
* element (through createElement() or cloneNode() generally) then add a
|
||||
@ -592,47 +595,6 @@ class nsIContent : public nsINode {
|
||||
*/
|
||||
virtual bool IsDoneAddingChildren() { return true; }
|
||||
|
||||
/**
|
||||
* Returns true if an element needs its DoneCreatingElement method to be
|
||||
* called after it has been created.
|
||||
* @see nsIContent::DoneCreatingElement
|
||||
*
|
||||
* @param aNamespaceID the node's namespace ID
|
||||
* @param aName the node's tag name
|
||||
*/
|
||||
static inline bool RequiresDoneCreatingElement(int32_t aNamespace,
|
||||
nsAtom* aName) {
|
||||
if (aNamespace == kNameSpaceID_XHTML &&
|
||||
(aName == nsGkAtoms::input || aName == nsGkAtoms::button ||
|
||||
aName == nsGkAtoms::menuitem || aName == nsGkAtoms::audio ||
|
||||
aName == nsGkAtoms::video)) {
|
||||
MOZ_ASSERT(!RequiresDoneAddingChildren(
|
||||
aNamespace, aName,
|
||||
"Both DoneCreatingElement and DoneAddingChildren on a same element "
|
||||
"isn't supported."));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if an element needs its DoneAddingChildren method to be
|
||||
* called after all of its children have been added.
|
||||
* @see nsIContent::DoneAddingChildren
|
||||
*
|
||||
* @param aNamespace the node's namespace ID
|
||||
* @param aName the node's tag name
|
||||
*/
|
||||
static inline bool RequiresDoneAddingChildren(int32_t aNamespace,
|
||||
nsAtom* aName) {
|
||||
return (aNamespace == kNameSpaceID_XHTML &&
|
||||
(aName == nsGkAtoms::select || aName == nsGkAtoms::textarea ||
|
||||
aName == nsGkAtoms::head || aName == nsGkAtoms::title ||
|
||||
aName == nsGkAtoms::object || aName == nsGkAtoms::output)) ||
|
||||
(aNamespace == kNameSpaceID_SVG && aName == nsGkAtoms::title) ||
|
||||
(aNamespace == kNameSpaceID_XUL && aName == nsGkAtoms::linkset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID of this content node (the atom corresponding to the
|
||||
* value of the id attribute). This may be null if there is no ID.
|
||||
|
@ -410,9 +410,7 @@ nsresult PrototypeDocumentContentSink::InsertXMLStylesheetPI(
|
||||
}
|
||||
|
||||
void PrototypeDocumentContentSink::CloseElement(Element* aElement) {
|
||||
if (nsIContent::RequiresDoneAddingChildren(
|
||||
aElement->NodeInfo()->NamespaceID(),
|
||||
aElement->NodeInfo()->NameAtom())) {
|
||||
if (aElement->IsXULElement(nsGkAtoms::linkset)) {
|
||||
aElement->DoneAddingChildren(false);
|
||||
}
|
||||
}
|
||||
@ -514,12 +512,6 @@ nsresult PrototypeDocumentContentSink::ResumeWalkInternal() {
|
||||
rv = nodeToPushTo->AppendChildTo(child, false);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (nsIContent::RequiresDoneCreatingElement(
|
||||
protoele->mNodeInfo->NamespaceID(),
|
||||
protoele->mNodeInfo->NameAtom())) {
|
||||
child->DoneCreatingElement();
|
||||
}
|
||||
|
||||
// If it has children, push the element onto the context
|
||||
// stack and begin to process them.
|
||||
if (protoele->mChildren.Length() > 0) {
|
||||
|
@ -2,6 +2,5 @@
|
||||
support-files =
|
||||
whitespace.xhtml
|
||||
no_whitespace.xhtml
|
||||
form.xhtml
|
||||
|
||||
[test_prototype_document.xhtml]
|
||||
|
@ -1,8 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<body>
|
||||
<input type="text" id="input" value=""/>
|
||||
</body>
|
||||
</html>
|
@ -61,15 +61,6 @@ add_task(async function test_prototype_document() {
|
||||
// TODO: Test whitespace within XUL elements, since it is handled differently
|
||||
// with and without the prototype sink (bug 1544567).
|
||||
});
|
||||
|
||||
add_task(async function test_prototype_document_form() {
|
||||
let browser = document.getElementById("browser");
|
||||
await load(browser, "form.xhtml");
|
||||
ok(browser.contentDocument.loadedFromPrototype, `form.xhtml should load from prototype.`);
|
||||
browser.contentDocument.getElementById("input").value = "test";
|
||||
await load(browser, "form.xhtml");
|
||||
is(browser.contentDocument.getElementById("input").value, "test", "input value should persist after reload");
|
||||
});
|
||||
]]></script>
|
||||
</body>
|
||||
</window>
|
||||
|
@ -522,8 +522,14 @@ nsresult nsXMLContentSink::CloseElement(nsIContent* aContent) {
|
||||
|
||||
// Some HTML nodes need DoneAddingChildren() called to initialize
|
||||
// properly (eg form state restoration).
|
||||
if (nsIContent::RequiresDoneAddingChildren(nodeInfo->NamespaceID(),
|
||||
nodeInfo->NameAtom())) {
|
||||
if ((nodeInfo->NamespaceID() == kNameSpaceID_XHTML &&
|
||||
(nodeInfo->NameAtom() == nsGkAtoms::select ||
|
||||
nodeInfo->NameAtom() == nsGkAtoms::textarea ||
|
||||
nodeInfo->NameAtom() == nsGkAtoms::video ||
|
||||
nodeInfo->NameAtom() == nsGkAtoms::audio ||
|
||||
nodeInfo->NameAtom() == nsGkAtoms::head ||
|
||||
nodeInfo->NameAtom() == nsGkAtoms::object)) ||
|
||||
nodeInfo->NameAtom() == nsGkAtoms::title) {
|
||||
aContent->DoneAddingChildren(HaveNotifiedForCurrentContent());
|
||||
}
|
||||
|
||||
@ -951,14 +957,16 @@ nsresult nsXMLContentSink::HandleStartElement(
|
||||
|
||||
// Some HTML nodes need DoneCreatingElement() called to initialize
|
||||
// properly (eg form state restoration).
|
||||
if (nsIContent::RequiresDoneCreatingElement(nodeInfo->NamespaceID(),
|
||||
nodeInfo->NameAtom())) {
|
||||
content->DoneCreatingElement();
|
||||
}
|
||||
|
||||
if (nodeInfo->NamespaceID() == kNameSpaceID_XHTML &&
|
||||
nodeInfo->NameAtom() == nsGkAtoms::head && !mCurrentHead) {
|
||||
mCurrentHead = content;
|
||||
if (nodeInfo->NamespaceID() == kNameSpaceID_XHTML) {
|
||||
if (nodeInfo->NameAtom() == nsGkAtoms::input ||
|
||||
nodeInfo->NameAtom() == nsGkAtoms::button ||
|
||||
nodeInfo->NameAtom() == nsGkAtoms::menuitem ||
|
||||
nodeInfo->NameAtom() == nsGkAtoms::audio ||
|
||||
nodeInfo->NameAtom() == nsGkAtoms::video) {
|
||||
content->DoneCreatingElement();
|
||||
} else if (nodeInfo->NameAtom() == nsGkAtoms::head && !mCurrentHead) {
|
||||
mCurrentHead = content;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsMonolithicContainer(nodeInfo)) {
|
||||
|
@ -262,10 +262,10 @@ nsresult txMozillaXMLOutput::endElement() {
|
||||
}
|
||||
|
||||
// Handle elements that are different when parser-created
|
||||
if (nsIContent::RequiresDoneCreatingElement(
|
||||
element->NodeInfo()->NamespaceID(),
|
||||
element->NodeInfo()->NameAtom())) {
|
||||
element->DoneCreatingElement();
|
||||
if (element->IsAnyOfHTMLElements(nsGkAtoms::title, nsGkAtoms::object,
|
||||
nsGkAtoms::select, nsGkAtoms::textarea) ||
|
||||
element->IsSVGElement(nsGkAtoms::title)) {
|
||||
element->DoneAddingChildren(true);
|
||||
} else if (element->IsSVGElement(nsGkAtoms::script) ||
|
||||
element->IsHTMLElement(nsGkAtoms::script)) {
|
||||
nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(element);
|
||||
@ -282,10 +282,10 @@ nsresult txMozillaXMLOutput::endElement() {
|
||||
"Script elements need to implement nsIScriptElement and SVG "
|
||||
"wasn't disabled.");
|
||||
}
|
||||
} else if (nsIContent::RequiresDoneAddingChildren(
|
||||
element->NodeInfo()->NamespaceID(),
|
||||
element->NodeInfo()->NameAtom())) {
|
||||
element->DoneAddingChildren(true);
|
||||
} else if (element->IsAnyOfHTMLElements(
|
||||
nsGkAtoms::input, nsGkAtoms::button, nsGkAtoms::menuitem,
|
||||
nsGkAtoms::audio, nsGkAtoms::video)) {
|
||||
element->DoneCreatingElement();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -905,7 +905,18 @@ void nsHtml5TreeBuilder::elementPushed(int32_t aNamespace, nsAtom* aName,
|
||||
treeOp->Init(mozilla::AsVariant(opStartLayout()));
|
||||
return;
|
||||
}
|
||||
if (nsIContent::RequiresDoneCreatingElement(kNameSpaceID_XHTML, aName)) {
|
||||
if (aName == nsGkAtoms::input || aName == nsGkAtoms::button) {
|
||||
if (mBuilder) {
|
||||
nsHtml5TreeOperation::DoneCreatingElement(
|
||||
static_cast<nsIContent*>(aElement));
|
||||
} else {
|
||||
opDoneCreatingElement operation(aElement);
|
||||
mOpQueue.AppendElement()->Init(mozilla::AsVariant(operation));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (aName == nsGkAtoms::audio || aName == nsGkAtoms::video ||
|
||||
aName == nsGkAtoms::menuitem) {
|
||||
if (mBuilder) {
|
||||
nsHtml5TreeOperation::DoneCreatingElement(
|
||||
static_cast<nsIContent*>(aElement));
|
||||
@ -973,9 +984,7 @@ void nsHtml5TreeBuilder::elementPopped(int32_t aNamespace, nsAtom* aName,
|
||||
treeOp->Init(mozilla::AsVariant(operation));
|
||||
return;
|
||||
}
|
||||
// Some nodes need DoneAddingChildren() called to initialize
|
||||
// properly (e.g. form state restoration).
|
||||
if (nsIContent::RequiresDoneAddingChildren(aNamespace, aName)) {
|
||||
if (aName == nsGkAtoms::title) {
|
||||
if (mBuilder) {
|
||||
nsHtml5TreeOperation::DoneAddingChildren(
|
||||
static_cast<nsIContent*>(aElement));
|
||||
@ -1024,6 +1033,26 @@ void nsHtml5TreeBuilder::elementPopped(int32_t aNamespace, nsAtom* aName,
|
||||
return;
|
||||
}
|
||||
// we now have only HTML
|
||||
// Some HTML nodes need DoneAddingChildren() called to initialize
|
||||
// properly (e.g. form state restoration).
|
||||
// XXX expose ElementName group here and do switch
|
||||
if (aName == nsGkAtoms::object || aName == nsGkAtoms::select ||
|
||||
aName == nsGkAtoms::textarea || aName == nsGkAtoms::output ||
|
||||
aName == nsGkAtoms::head) {
|
||||
if (mBuilder) {
|
||||
nsHtml5TreeOperation::DoneAddingChildren(
|
||||
static_cast<nsIContent*>(aElement));
|
||||
return;
|
||||
}
|
||||
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement(mozilla::fallible);
|
||||
if (MOZ_UNLIKELY(!treeOp)) {
|
||||
MarkAsBrokenAndRequestSuspensionWithoutBuilder(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
opDoneAddingChildren operation(aElement);
|
||||
treeOp->Init(mozilla::AsVariant(operation));
|
||||
return;
|
||||
}
|
||||
if (aName == nsGkAtoms::meta && !fragment && !mBuilder) {
|
||||
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement(mozilla::fallible);
|
||||
if (MOZ_UNLIKELY(!treeOp)) {
|
||||
|
Loading…
Reference in New Issue
Block a user