зеркало из https://github.com/mozilla/gecko-dev.git
Bug 612529 part 3 - Make <annotation-xml> an HTML integration point depending on the encoding attribute. rs=jonas, a=blocking2.0-betaN.
This commit is contained in:
Родитель
84881910ae
Коммит
e6fbe390cb
|
@ -63,6 +63,10 @@ final class StackNode<T> {
|
||||||
return (flags & ElementName.FOSTER_PARENTING) != 0;
|
return (flags & ElementName.FOSTER_PARENTING) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isHtmlIntegrationPoint() {
|
||||||
|
return (flags & ElementName.HTML_INTEGRATION_POINT) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for copying. This doesn't take another
|
* Constructor for copying. This doesn't take another
|
||||||
* <code>StackNode</code> because in C++ the caller is reponsible for
|
* <code>StackNode</code> because in C++ the caller is reponsible for
|
||||||
|
@ -168,7 +172,7 @@ final class StackNode<T> {
|
||||||
*/
|
*/
|
||||||
StackNode(ElementName elementName, T node, @Local String popName,
|
StackNode(ElementName elementName, T node, @Local String popName,
|
||||||
boolean markAsIntegrationPoint) {
|
boolean markAsIntegrationPoint) {
|
||||||
this.flags = prepareMathFlags(elementName.getFlags());
|
this.flags = prepareMathFlags(elementName.getFlags(), markAsIntegrationPoint);
|
||||||
this.name = elementName.name;
|
this.name = elementName.name;
|
||||||
this.popName = popName;
|
this.popName = popName;
|
||||||
this.ns = "http://www.w3.org/1998/Math/MathML";
|
this.ns = "http://www.w3.org/1998/Math/MathML";
|
||||||
|
@ -185,11 +189,14 @@ final class StackNode<T> {
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int prepareMathFlags(int flags) {
|
private static int prepareMathFlags(int flags, boolean markAsIntegrationPoint) {
|
||||||
flags &= ~(ElementName.FOSTER_PARENTING | ElementName.SCOPING | ElementName.SPECIAL);
|
flags &= ~(ElementName.FOSTER_PARENTING | ElementName.SCOPING | ElementName.SPECIAL);
|
||||||
if ((flags & ElementName.SCOPING_AS_MATHML) != 0) {
|
if ((flags & ElementName.SCOPING_AS_MATHML) != 0) {
|
||||||
flags |= (ElementName.SCOPING | ElementName.SPECIAL);
|
flags |= (ElementName.SCOPING | ElementName.SPECIAL);
|
||||||
}
|
}
|
||||||
|
if (markAsIntegrationPoint) {
|
||||||
|
flags |= ElementName.HTML_INTEGRATION_POINT;
|
||||||
|
}
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1440,10 +1440,9 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||||
if (inForeign) {
|
if (inForeign) {
|
||||||
StackNode<T> currentNode = stack[currentPtr];
|
StackNode<T> currentNode = stack[currentPtr];
|
||||||
@NsUri String currNs = currentNode.ns;
|
@NsUri String currNs = currentNode.ns;
|
||||||
int currGroup = currentNode.getGroup();
|
|
||||||
if (("http://www.w3.org/1999/xhtml" == currNs)
|
if (("http://www.w3.org/1999/xhtml" == currNs)
|
||||||
|| ("http://www.w3.org/1998/Math/MathML" == currNs && ((MGLYPH_OR_MALIGNMARK != group && MI_MO_MN_MS_MTEXT == currGroup) || (SVG == group && ANNOTATION_XML == currGroup)))
|
|| currentNode.isHtmlIntegrationPoint()
|
||||||
|| ("http://www.w3.org/2000/svg" == currNs && (TITLE == currGroup || (FOREIGNOBJECT_OR_DESC == currGroup)))) {
|
|| (currNs == "http://www.w3.org/1998/Math/MathML" && ((currentNode.getGroup() == MI_MO_MN_MS_MTEXT && group != MGLYPH_OR_MALIGNMARK) || (currentNode.getGroup() == ANNOTATION_XML && group == SVG)))) {
|
||||||
needsPostProcessing = true;
|
needsPostProcessing = true;
|
||||||
// fall through to non-foreign behavior
|
// fall through to non-foreign behavior
|
||||||
} else {
|
} else {
|
||||||
|
@ -4913,10 +4912,27 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||||
} else {
|
} else {
|
||||||
appendElement(elt, current.node);
|
appendElement(elt, current.node);
|
||||||
}
|
}
|
||||||
StackNode<T> node = new StackNode<T>(elementName, elt, popName, false);
|
boolean markAsHtmlIntegrationPoint = false;
|
||||||
|
if (ElementName.ANNOTATION_XML == elementName
|
||||||
|
&& annotationXmlEncodingPermitsHtml(attributes)) {
|
||||||
|
markAsHtmlIntegrationPoint = true;
|
||||||
|
}
|
||||||
|
StackNode<T> node = new StackNode<T>(elementName, elt, popName,
|
||||||
|
markAsHtmlIntegrationPoint);
|
||||||
push(node);
|
push(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean annotationXmlEncodingPermitsHtml(HtmlAttributes attributes) {
|
||||||
|
String encoding = attributes.getValue(AttributeName.ENCODING);
|
||||||
|
if (encoding == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString(
|
||||||
|
"application/xhtml+xml", encoding)
|
||||||
|
|| Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString(
|
||||||
|
"text/html", encoding);
|
||||||
|
}
|
||||||
|
|
||||||
private void appendToCurrentNodeAndPushElementMayFosterSVG(
|
private void appendToCurrentNodeAndPushElementMayFosterSVG(
|
||||||
ElementName elementName, HtmlAttributes attributes)
|
ElementName elementName, HtmlAttributes attributes)
|
||||||
throws SAXException {
|
throws SAXException {
|
||||||
|
|
|
@ -83,6 +83,12 @@ nsHtml5StackNode::isFosterParenting()
|
||||||
return (flags & NS_HTML5ELEMENT_NAME_FOSTER_PARENTING);
|
return (flags & NS_HTML5ELEMENT_NAME_FOSTER_PARENTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PRBool
|
||||||
|
nsHtml5StackNode::isHtmlIntegrationPoint()
|
||||||
|
{
|
||||||
|
return (flags & NS_HTML5ELEMENT_NAME_HTML_INTEGRATION_POINT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
nsHtml5StackNode::nsHtml5StackNode(PRInt32 flags, PRInt32 ns, nsIAtom* name, nsIContent** node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes)
|
nsHtml5StackNode::nsHtml5StackNode(PRInt32 flags, PRInt32 ns, nsIAtom* name, nsIContent** node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes)
|
||||||
: flags(flags),
|
: flags(flags),
|
||||||
|
@ -152,7 +158,7 @@ nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIAtom* pop
|
||||||
|
|
||||||
|
|
||||||
nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName, PRBool markAsIntegrationPoint)
|
nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName, PRBool markAsIntegrationPoint)
|
||||||
: flags(prepareMathFlags(elementName->getFlags())),
|
: flags(prepareMathFlags(elementName->getFlags(), markAsIntegrationPoint)),
|
||||||
name(elementName->name),
|
name(elementName->name),
|
||||||
popName(popName),
|
popName(popName),
|
||||||
ns(kNameSpaceID_MathML),
|
ns(kNameSpaceID_MathML),
|
||||||
|
@ -174,12 +180,15 @@ nsHtml5StackNode::prepareSvgFlags(PRInt32 flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
PRInt32
|
PRInt32
|
||||||
nsHtml5StackNode::prepareMathFlags(PRInt32 flags)
|
nsHtml5StackNode::prepareMathFlags(PRInt32 flags, PRBool markAsIntegrationPoint)
|
||||||
{
|
{
|
||||||
flags &= ~(NS_HTML5ELEMENT_NAME_FOSTER_PARENTING | NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL);
|
flags &= ~(NS_HTML5ELEMENT_NAME_FOSTER_PARENTING | NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL);
|
||||||
if ((flags & NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML)) {
|
if ((flags & NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML)) {
|
||||||
flags |= (NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL);
|
flags |= (NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL);
|
||||||
}
|
}
|
||||||
|
if (markAsIntegrationPoint) {
|
||||||
|
flags |= NS_HTML5ELEMENT_NAME_HTML_INTEGRATION_POINT;
|
||||||
|
}
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ class nsHtml5StackNode
|
||||||
PRBool isScoping();
|
PRBool isScoping();
|
||||||
PRBool isSpecial();
|
PRBool isSpecial();
|
||||||
PRBool isFosterParenting();
|
PRBool isFosterParenting();
|
||||||
|
PRBool isHtmlIntegrationPoint();
|
||||||
nsHtml5StackNode(PRInt32 flags, PRInt32 ns, nsIAtom* name, nsIContent** node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes);
|
nsHtml5StackNode(PRInt32 flags, PRInt32 ns, nsIAtom* name, nsIContent** node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes);
|
||||||
nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node);
|
nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node);
|
||||||
nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsHtml5HtmlAttributes* attributes);
|
nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsHtml5HtmlAttributes* attributes);
|
||||||
|
@ -90,7 +91,7 @@ class nsHtml5StackNode
|
||||||
nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName, PRBool markAsIntegrationPoint);
|
nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName, PRBool markAsIntegrationPoint);
|
||||||
private:
|
private:
|
||||||
static PRInt32 prepareSvgFlags(PRInt32 flags);
|
static PRInt32 prepareSvgFlags(PRInt32 flags);
|
||||||
static PRInt32 prepareMathFlags(PRInt32 flags);
|
static PRInt32 prepareMathFlags(PRInt32 flags, PRBool markAsIntegrationPoint);
|
||||||
public:
|
public:
|
||||||
~nsHtml5StackNode();
|
~nsHtml5StackNode();
|
||||||
void dropAttributes();
|
void dropAttributes();
|
||||||
|
|
|
@ -566,8 +566,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
|
||||||
if (inForeign) {
|
if (inForeign) {
|
||||||
nsHtml5StackNode* currentNode = stack[currentPtr];
|
nsHtml5StackNode* currentNode = stack[currentPtr];
|
||||||
PRInt32 currNs = currentNode->ns;
|
PRInt32 currNs = currentNode->ns;
|
||||||
PRInt32 currGroup = currentNode->getGroup();
|
if ((kNameSpaceID_XHTML == currNs) || currentNode->isHtmlIntegrationPoint() || (currNs == kNameSpaceID_MathML && ((currentNode->getGroup() == NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT && group != NS_HTML5TREE_BUILDER_MGLYPH_OR_MALIGNMARK) || (currentNode->getGroup() == NS_HTML5TREE_BUILDER_ANNOTATION_XML && group == NS_HTML5TREE_BUILDER_SVG)))) {
|
||||||
if ((kNameSpaceID_XHTML == currNs) || (kNameSpaceID_MathML == currNs && ((NS_HTML5TREE_BUILDER_MGLYPH_OR_MALIGNMARK != group && NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT == currGroup) || (NS_HTML5TREE_BUILDER_SVG == group && NS_HTML5TREE_BUILDER_ANNOTATION_XML == currGroup))) || (kNameSpaceID_SVG == currNs && (NS_HTML5TREE_BUILDER_TITLE == currGroup || (NS_HTML5TREE_BUILDER_FOREIGNOBJECT_OR_DESC == currGroup)))) {
|
|
||||||
needsPostProcessing = PR_TRUE;
|
needsPostProcessing = PR_TRUE;
|
||||||
} else {
|
} else {
|
||||||
switch(group) {
|
switch(group) {
|
||||||
|
@ -3607,10 +3606,24 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFosterMathML(nsHtml5Elem
|
||||||
} else {
|
} else {
|
||||||
appendElement(elt, current->node);
|
appendElement(elt, current->node);
|
||||||
}
|
}
|
||||||
nsHtml5StackNode* node = new nsHtml5StackNode(elementName, elt, popName, PR_FALSE);
|
PRBool markAsHtmlIntegrationPoint = PR_FALSE;
|
||||||
|
if (nsHtml5ElementName::ELT_ANNOTATION_XML == elementName && annotationXmlEncodingPermitsHtml(attributes)) {
|
||||||
|
markAsHtmlIntegrationPoint = PR_TRUE;
|
||||||
|
}
|
||||||
|
nsHtml5StackNode* node = new nsHtml5StackNode(elementName, elt, popName, markAsHtmlIntegrationPoint);
|
||||||
push(node);
|
push(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PRBool
|
||||||
|
nsHtml5TreeBuilder::annotationXmlEncodingPermitsHtml(nsHtml5HtmlAttributes* attributes)
|
||||||
|
{
|
||||||
|
nsString* encoding = attributes->getValue(nsHtml5AttributeName::ATTR_ENCODING);
|
||||||
|
if (!encoding) {
|
||||||
|
return PR_FALSE;
|
||||||
|
}
|
||||||
|
return nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString("application/xhtml+xml", encoding) || nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString("text/html", encoding);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFosterSVG(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
|
nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFosterSVG(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
|
||||||
{
|
{
|
||||||
|
|
|
@ -179,6 +179,7 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
|
||||||
void appendToCurrentNodeAndPushElement(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
|
void appendToCurrentNodeAndPushElement(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
|
||||||
void appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
|
void appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
|
||||||
void appendToCurrentNodeAndPushElementMayFosterMathML(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
|
void appendToCurrentNodeAndPushElementMayFosterMathML(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
|
||||||
|
PRBool annotationXmlEncodingPermitsHtml(nsHtml5HtmlAttributes* attributes);
|
||||||
void appendToCurrentNodeAndPushElementMayFosterSVG(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
|
void appendToCurrentNodeAndPushElementMayFosterSVG(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
|
||||||
void appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes, nsIContent** form);
|
void appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes, nsIContent** form);
|
||||||
void appendVoidElementToCurrentMayFoster(nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContent** form);
|
void appendVoidElementToCurrentMayFoster(nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContent** form);
|
||||||
|
|
|
@ -13,9 +13,5 @@ var html5Exceptions = {
|
||||||
"<svg>\u0000</svg><frameset>" : true, // Bug 612527
|
"<svg>\u0000</svg><frameset>" : true, // Bug 612527
|
||||||
"<svg>\u0000 </svg><frameset>" : true, // Bug 612527
|
"<svg>\u0000 </svg><frameset>" : true, // Bug 612527
|
||||||
"<option><span><option>" : true, // Bug 612528
|
"<option><span><option>" : true, // Bug 612528
|
||||||
"<math><annotation-xml encoding=\"application/xhtml+xml\"><div>" : true, // Bug 612529
|
|
||||||
"<math><annotation-xml encoding=\"aPPlication/xhtmL+xMl\"><div>" : true, // Bug 612529
|
|
||||||
"<math><annotation-xml encoding=\"text/html\"><div>" : true, // Bug 612529
|
|
||||||
"<math><annotation-xml encoding=\"Text/htmL\"><div>" : true, // Bug 612529
|
|
||||||
"<!doctype html><div><body><frameset>" : true, // Bug 614241
|
"<!doctype html><div><body><frameset>" : true, // Bug 614241
|
||||||
}
|
}
|
||||||
|
|
|
@ -375,7 +375,6 @@
|
||||||
<math><annotation-xml><div>
|
<math><annotation-xml><div>
|
||||||
#errors
|
#errors
|
||||||
#document
|
#document
|
||||||
#document
|
|
||||||
| <html>
|
| <html>
|
||||||
| <head>
|
| <head>
|
||||||
| <body>
|
| <body>
|
||||||
|
@ -387,7 +386,6 @@
|
||||||
<math><annotation-xml encoding="application/svg+xml"><div>
|
<math><annotation-xml encoding="application/svg+xml"><div>
|
||||||
#errors
|
#errors
|
||||||
#document
|
#document
|
||||||
#document
|
|
||||||
| <html>
|
| <html>
|
||||||
| <head>
|
| <head>
|
||||||
| <body>
|
| <body>
|
||||||
|
@ -400,7 +398,6 @@
|
||||||
<math><annotation-xml encoding="application/xhtml+xml"><div>
|
<math><annotation-xml encoding="application/xhtml+xml"><div>
|
||||||
#errors
|
#errors
|
||||||
#document
|
#document
|
||||||
#document
|
|
||||||
| <html>
|
| <html>
|
||||||
| <head>
|
| <head>
|
||||||
| <body>
|
| <body>
|
||||||
|
@ -413,7 +410,6 @@
|
||||||
<math><annotation-xml encoding="aPPlication/xhtmL+xMl"><div>
|
<math><annotation-xml encoding="aPPlication/xhtmL+xMl"><div>
|
||||||
#errors
|
#errors
|
||||||
#document
|
#document
|
||||||
#document
|
|
||||||
| <html>
|
| <html>
|
||||||
| <head>
|
| <head>
|
||||||
| <body>
|
| <body>
|
||||||
|
@ -426,7 +422,6 @@
|
||||||
<math><annotation-xml encoding="text/html"><div>
|
<math><annotation-xml encoding="text/html"><div>
|
||||||
#errors
|
#errors
|
||||||
#document
|
#document
|
||||||
#document
|
|
||||||
| <html>
|
| <html>
|
||||||
| <head>
|
| <head>
|
||||||
| <body>
|
| <body>
|
||||||
|
@ -439,7 +434,6 @@
|
||||||
<math><annotation-xml encoding="Text/htmL"><div>
|
<math><annotation-xml encoding="Text/htmL"><div>
|
||||||
#errors
|
#errors
|
||||||
#document
|
#document
|
||||||
#document
|
|
||||||
| <html>
|
| <html>
|
||||||
| <head>
|
| <head>
|
||||||
| <body>
|
| <body>
|
||||||
|
@ -452,7 +446,6 @@
|
||||||
<math><annotation-xml encoding=" text/html "><div>
|
<math><annotation-xml encoding=" text/html "><div>
|
||||||
#errors
|
#errors
|
||||||
#document
|
#document
|
||||||
#document
|
|
||||||
| <html>
|
| <html>
|
||||||
| <head>
|
| <head>
|
||||||
| <body>
|
| <body>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче