зеркало из 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;
|
||||
}
|
||||
|
||||
public boolean isHtmlIntegrationPoint() {
|
||||
return (flags & ElementName.HTML_INTEGRATION_POINT) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for copying. This doesn't take another
|
||||
* <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,
|
||||
boolean markAsIntegrationPoint) {
|
||||
this.flags = prepareMathFlags(elementName.getFlags());
|
||||
this.flags = prepareMathFlags(elementName.getFlags(), markAsIntegrationPoint);
|
||||
this.name = elementName.name;
|
||||
this.popName = popName;
|
||||
this.ns = "http://www.w3.org/1998/Math/MathML";
|
||||
|
@ -185,11 +189,14 @@ final class StackNode<T> {
|
|||
return flags;
|
||||
}
|
||||
|
||||
private static int prepareMathFlags(int flags) {
|
||||
private static int prepareMathFlags(int flags, boolean markAsIntegrationPoint) {
|
||||
flags &= ~(ElementName.FOSTER_PARENTING | ElementName.SCOPING | ElementName.SPECIAL);
|
||||
if ((flags & ElementName.SCOPING_AS_MATHML) != 0) {
|
||||
flags |= (ElementName.SCOPING | ElementName.SPECIAL);
|
||||
}
|
||||
if (markAsIntegrationPoint) {
|
||||
flags |= ElementName.HTML_INTEGRATION_POINT;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
|
|
@ -1440,10 +1440,9 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
if (inForeign) {
|
||||
StackNode<T> currentNode = stack[currentPtr];
|
||||
@NsUri String currNs = currentNode.ns;
|
||||
int currGroup = currentNode.getGroup();
|
||||
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)))
|
||||
|| ("http://www.w3.org/2000/svg" == currNs && (TITLE == currGroup || (FOREIGNOBJECT_OR_DESC == currGroup)))) {
|
||||
|| currentNode.isHtmlIntegrationPoint()
|
||||
|| (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;
|
||||
// fall through to non-foreign behavior
|
||||
} else {
|
||||
|
@ -4913,10 +4912,27 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
} else {
|
||||
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);
|
||||
}
|
||||
|
||||
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(
|
||||
ElementName elementName, HtmlAttributes attributes)
|
||||
throws SAXException {
|
||||
|
|
|
@ -83,6 +83,12 @@ nsHtml5StackNode::isFosterParenting()
|
|||
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)
|
||||
: flags(flags),
|
||||
|
@ -152,7 +158,7 @@ nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIAtom* pop
|
|||
|
||||
|
||||
nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName, PRBool markAsIntegrationPoint)
|
||||
: flags(prepareMathFlags(elementName->getFlags())),
|
||||
: flags(prepareMathFlags(elementName->getFlags(), markAsIntegrationPoint)),
|
||||
name(elementName->name),
|
||||
popName(popName),
|
||||
ns(kNameSpaceID_MathML),
|
||||
|
@ -174,12 +180,15 @@ nsHtml5StackNode::prepareSvgFlags(PRInt32 flags)
|
|||
}
|
||||
|
||||
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);
|
||||
if ((flags & NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML)) {
|
||||
flags |= (NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL);
|
||||
}
|
||||
if (markAsIntegrationPoint) {
|
||||
flags |= NS_HTML5ELEMENT_NAME_HTML_INTEGRATION_POINT;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,6 +82,7 @@ class nsHtml5StackNode
|
|||
PRBool isScoping();
|
||||
PRBool isSpecial();
|
||||
PRBool isFosterParenting();
|
||||
PRBool isHtmlIntegrationPoint();
|
||||
nsHtml5StackNode(PRInt32 flags, PRInt32 ns, nsIAtom* name, nsIContent** node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes);
|
||||
nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node);
|
||||
nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsHtml5HtmlAttributes* attributes);
|
||||
|
@ -90,7 +91,7 @@ class nsHtml5StackNode
|
|||
nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName, PRBool markAsIntegrationPoint);
|
||||
private:
|
||||
static PRInt32 prepareSvgFlags(PRInt32 flags);
|
||||
static PRInt32 prepareMathFlags(PRInt32 flags);
|
||||
static PRInt32 prepareMathFlags(PRInt32 flags, PRBool markAsIntegrationPoint);
|
||||
public:
|
||||
~nsHtml5StackNode();
|
||||
void dropAttributes();
|
||||
|
|
|
@ -566,8 +566,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
|
|||
if (inForeign) {
|
||||
nsHtml5StackNode* currentNode = stack[currentPtr];
|
||||
PRInt32 currNs = currentNode->ns;
|
||||
PRInt32 currGroup = currentNode->getGroup();
|
||||
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)))) {
|
||||
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)))) {
|
||||
needsPostProcessing = PR_TRUE;
|
||||
} else {
|
||||
switch(group) {
|
||||
|
@ -3607,10 +3606,24 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFosterMathML(nsHtml5Elem
|
|||
} else {
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFosterSVG(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
|
||||
{
|
||||
|
|
|
@ -179,6 +179,7 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
|
|||
void appendToCurrentNodeAndPushElement(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
|
||||
void appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
|
||||
void appendToCurrentNodeAndPushElementMayFosterMathML(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
|
||||
PRBool annotationXmlEncodingPermitsHtml(nsHtml5HtmlAttributes* attributes);
|
||||
void appendToCurrentNodeAndPushElementMayFosterSVG(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
|
||||
void appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName* elementName, 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
|
||||
"<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
|
||||
}
|
||||
|
|
|
@ -375,7 +375,6 @@
|
|||
<math><annotation-xml><div>
|
||||
#errors
|
||||
#document
|
||||
#document
|
||||
| <html>
|
||||
| <head>
|
||||
| <body>
|
||||
|
@ -387,7 +386,6 @@
|
|||
<math><annotation-xml encoding="application/svg+xml"><div>
|
||||
#errors
|
||||
#document
|
||||
#document
|
||||
| <html>
|
||||
| <head>
|
||||
| <body>
|
||||
|
@ -400,7 +398,6 @@
|
|||
<math><annotation-xml encoding="application/xhtml+xml"><div>
|
||||
#errors
|
||||
#document
|
||||
#document
|
||||
| <html>
|
||||
| <head>
|
||||
| <body>
|
||||
|
@ -413,7 +410,6 @@
|
|||
<math><annotation-xml encoding="aPPlication/xhtmL+xMl"><div>
|
||||
#errors
|
||||
#document
|
||||
#document
|
||||
| <html>
|
||||
| <head>
|
||||
| <body>
|
||||
|
@ -426,7 +422,6 @@
|
|||
<math><annotation-xml encoding="text/html"><div>
|
||||
#errors
|
||||
#document
|
||||
#document
|
||||
| <html>
|
||||
| <head>
|
||||
| <body>
|
||||
|
@ -439,7 +434,6 @@
|
|||
<math><annotation-xml encoding="Text/htmL"><div>
|
||||
#errors
|
||||
#document
|
||||
#document
|
||||
| <html>
|
||||
| <head>
|
||||
| <body>
|
||||
|
@ -452,7 +446,6 @@
|
|||
<math><annotation-xml encoding=" text/html "><div>
|
||||
#errors
|
||||
#document
|
||||
#document
|
||||
| <html>
|
||||
| <head>
|
||||
| <body>
|
||||
|
|
Загрузка…
Ссылка в новой задаче