Bug 643410 - Reconstruct active formatting elements on text in an HTML integration point; handle U+0000 per spec in a MathML text integration point. r=jonas.

This commit is contained in:
Henri Sivonen 2011-04-08 09:07:28 +03:00
Родитель ae0a413aa5
Коммит bca107676a
12 изменённых файлов: 325 добавлений и 13 удалений

Просмотреть файл

@ -950,7 +950,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
case IN_BODY:
case IN_CELL:
case IN_CAPTION:
if (!isInForeign()) {
if (!isInForeignButNotHtmlIntegrationPoint()) {
reconstructTheActiveFormattingElements();
}
// fall through
@ -1009,7 +1009,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
* Reconstruct the active formatting
* elements, if any.
*/
if (!isInForeign()) {
if (!isInForeignButNotHtmlIntegrationPoint()) {
flushCharacters();
reconstructTheActiveFormattingElements();
}
@ -1205,7 +1205,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
* Reconstruct the active formatting
* elements, if any.
*/
if (!isInForeign()) {
if (!isInForeignButNotHtmlIntegrationPoint()) {
flushCharacters();
reconstructTheActiveFormattingElements();
}
@ -1330,10 +1330,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
if (stackNode.isHtmlIntegrationPoint()) {
return;
}
if (stackNode.ns == "http://www.w3.org/1998/Math/MathML"
&& stackNode.getGroup() == MI_MO_MN_MS_MTEXT) {
return;
}
accumulateCharacters(REPLACEMENT_CHARACTER, 0, 1);
}
}
@ -5325,6 +5321,12 @@ public abstract class TreeBuilder<T> implements TokenHandler,
&& stack[currentPtr].ns != "http://www.w3.org/1999/xhtml";
}
private boolean isInForeignButNotHtmlIntegrationPoint() {
return currentPtr >= 0
&& stack[currentPtr].ns != "http://www.w3.org/1999/xhtml"
&& !stack[currentPtr].isHtmlIntegrationPoint();
}
/**
* The argument MUST be an interned string or <code>null</code>.
*

Просмотреть файл

@ -190,7 +190,7 @@ nsHtml5TreeBuilder::characters(const PRUnichar* buf, PRInt32 start, PRInt32 leng
case NS_HTML5TREE_BUILDER_IN_BODY:
case NS_HTML5TREE_BUILDER_IN_CELL:
case NS_HTML5TREE_BUILDER_IN_CAPTION: {
if (!isInForeign()) {
if (!isInForeignButNotHtmlIntegrationPoint()) {
reconstructTheActiveFormattingElements();
}
}
@ -236,7 +236,7 @@ nsHtml5TreeBuilder::characters(const PRUnichar* buf, PRInt32 start, PRInt32 leng
accumulateCharacters(buf, start, i - start);
start = i;
}
if (!isInForeign()) {
if (!isInForeignButNotHtmlIntegrationPoint()) {
flushCharacters();
reconstructTheActiveFormattingElements();
}
@ -338,7 +338,7 @@ nsHtml5TreeBuilder::characters(const PRUnichar* buf, PRInt32 start, PRInt32 leng
accumulateCharacters(buf, start, i - start);
start = i;
}
if (!isInForeign()) {
if (!isInForeignButNotHtmlIntegrationPoint()) {
flushCharacters();
reconstructTheActiveFormattingElements();
}
@ -435,9 +435,6 @@ nsHtml5TreeBuilder::zeroOriginatingReplacementCharacter()
if (stackNode->isHtmlIntegrationPoint()) {
return;
}
if (stackNode->ns == kNameSpaceID_MathML && stackNode->getGroup() == NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT) {
return;
}
accumulateCharacters(REPLACEMENT_CHARACTER, 0, 1);
}
}
@ -3714,6 +3711,12 @@ nsHtml5TreeBuilder::isInForeign()
return currentPtr >= 0 && stack[currentPtr]->ns != kNameSpaceID_XHTML;
}
PRBool
nsHtml5TreeBuilder::isInForeignButNotHtmlIntegrationPoint()
{
return currentPtr >= 0 && stack[currentPtr]->ns != kNameSpaceID_XHTML && !stack[currentPtr]->isHtmlIntegrationPoint();
}
void
nsHtml5TreeBuilder::setFragmentContext(nsIAtom* context, PRInt32 ns, nsIContent** node, PRBool quirks)
{

Просмотреть файл

@ -217,6 +217,7 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
private:
PRBool isInForeign();
PRBool isInForeignButNotHtmlIntegrationPoint();
public:
void setFragmentContext(nsIAtom* context, PRInt32 ns, nsIContent** node, PRBool quirks);
protected:

Просмотреть файл

@ -8,3 +8,45 @@
| <html>
| <head>
| <frameset>
#data
<!DOCTYPE html><table><caption><svg>foo</table>bar
#errors
47: End tag “table” did not match the name of the current open element (“svg”).
47: “table” closed but “caption” was still open.
47: End tag “table” seen, but there were open elements.
36: Unclosed element “svg”.
#document
| <!DOCTYPE html>
| <html>
| <head>
| <body>
| <table>
| <caption>
| <svg svg>
| "foo"
| "bar"
#data
<table><tr><td><svg><desc><td></desc><circle>
#errors
7: Start tag seen without seeing a doctype first. Expected “<!DOCTYPE html>”.
30: A table cell was implicitly closed, but there were open elements.
26: Unclosed element “desc”.
20: Unclosed element “svg”.
37: Stray end tag “desc”.
45: End of file seen and there were open elements.
45: Unclosed element “circle”.
7: Unclosed element “table”.
#document
| <html>
| <head>
| <body>
| <table>
| <tbody>
| <tr>
| <td>
| <svg svg>
| <svg desc>
| <td>
| <circle>

Двоичный файл не отображается.

Просмотреть файл

@ -46,6 +46,7 @@ include $(topsrcdir)/config/rules.mk
_TEST_FILES = adoption01.dat \
webkit01.dat \
ark.dat \
$(NULL)
libs:: $(_TEST_FILES)

Просмотреть файл

@ -0,0 +1,26 @@
#data
<p><font size=4><font size=4><font size=4><script>document.getElementsByTagName("font")[2].setAttribute("size", "5");</script><font size=4><p>X
#errors
#document
| <html>
| <head>
| <body>
| <p>
| <font>
| size="4"
| <font>
| size="4"
| <font>
| size="5"
| <script>
| "document.getElementsByTagName("font")[2].setAttribute("size", "5");"
| <font>
| size="4"
| <p>
| <font>
| size="4"
| <font>
| size="4"
| <font>
| size="4"
| "X"

Просмотреть файл

@ -97,6 +97,17 @@
| <embed>
| "A"
#data
<!DOCTYPE html><body><frame>A
#errors
26: Stray start tag “frame”.
#document
| <!DOCTYPE html>
| <html>
| <head>
| <body>
| "A"
#data
<!DOCTYPE html><body><hr>A
#errors

Просмотреть файл

@ -193,3 +193,119 @@
| <i>
| <nobr>
| "2"
#data
<p><code x</code></p>
#errors
#document
| <html>
| <head>
| <body>
| <p>
| <code>
| code=""
| x<=""
| <code>
| code=""
| x<=""
| "
"
#data
<!DOCTYPE html><svg><foreignObject><p><i></p>a
#errors
45: End tag “p” seen, but there were open elements.
41: Unclosed element “i”.
46: End of file seen and there were open elements.
35: Unclosed element “foreignObject”.
20: Unclosed element “svg”.
#document
| <!DOCTYPE html>
| <html>
| <head>
| <body>
| <svg svg>
| <svg foreignObject>
| <p>
| <i>
| <i>
| "a"
#data
<!DOCTYPE html><table><tr><td><svg><foreignObject><p><i></p>a
#errors
56: End tag “p” seen, but there were open elements.
52: Unclosed element “i”.
57: End of file seen and there were open elements.
46: Unclosed element “foreignObject”.
31: Unclosed element “svg”.
22: Unclosed element “table”.
#document
| <!DOCTYPE html>
| <html>
| <head>
| <body>
| <table>
| <tbody>
| <tr>
| <td>
| <svg svg>
| <svg foreignObject>
| <p>
| <i>
| <i>
| "a"
#data
<!DOCTYPE html><math><mtext><p><i></p>a
#errors
38: End tag “p” seen, but there were open elements.
34: Unclosed element “i”.
39: End of file in a foreign namespace context.
#document
| <!DOCTYPE html>
| <html>
| <head>
| <body>
| <math math>
| <math mtext>
| <p>
| <i>
| "a"
#data
<!DOCTYPE html><table><tr><td><math><mtext><p><i></p>a
#errors
53: End tag “p” seen, but there were open elements.
49: Unclosed element “i”.
54: End of file in a foreign namespace context.
#document
| <!DOCTYPE html>
| <html>
| <head>
| <body>
| <table>
| <tbody>
| <tr>
| <td>
| <math math>
| <math mtext>
| <p>
| <i>
| "a"
#data
<!DOCTYPE html><body><div><!/div>a
#errors
29: Bogus comment.
34: End of file seen and there were open elements.
26: Unclosed element “div”.
#document
| <!DOCTYPE html>
| <html>
| <head>
| <body>
| <div>
| <!-- /div -->
| "a"

Просмотреть файл

@ -535,3 +535,60 @@ console.log("FOO<span>BAR</span>BAZ");
| "B"
| <div>
| "C"
#data
<svg><em><desc></em>
#errors
#document
| <html>
| <head>
| <body>
| <svg svg>
| <em>
| <desc>
#data
<svg><tfoot></mi><td>
#errors
#document
| <html>
| <head>
| <body>
| <svg svg>
| <svg tfoot>
| <svg td>
#data
<math><mrow><mrow><mn>1</mn></mrow><mi>a</mi></mrow></math>
#errors
#document
| <html>
| <head>
| <body>
| <math math>
| <math mrow>
| <math mrow>
| <math mn>
| "1"
| <math mi>
| "a"
#data
<!doctype html><input type="hidden"><frameset>
#errors
#document
| <!DOCTYPE html>
| <html>
| <head>
| <frameset>
#data
<!doctype html><input type="button"><frameset>
#errors
#document
| <!DOCTYPE html>
| <html>
| <head>
| <body>
| <input>
| type="button"

Просмотреть файл

@ -40,3 +40,55 @@
| <html>
| <head>
| <body>
#data
<table><td></tbody>A
#errors
#document
| <html>
| <head>
| <body>
| "A"
| <table>
| <tbody>
| <tr>
| <td>
#data
<table><td></thead>A
#errors
#document
| <html>
| <head>
| <body>
| <table>
| <tbody>
| <tr>
| <td>
| "A"
#data
<table><td></tfoot>A
#errors
#document
| <html>
| <head>
| <body>
| <table>
| <tbody>
| <tr>
| <td>
| "A"
#data
<table><thead><td></tbody>A
#errors
#document
| <html>
| <head>
| <body>
| <table>
| <thead>
| <tr>
| <td>
| "A"

Просмотреть файл

@ -30,6 +30,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=366936
"plain-text-unsafe.dat",
"scripted/adoption01.dat",
"scripted/webkit01.dat",
"scripted/ark.dat",
"scriptdata01.dat",
"tables01.dat",
"tests10.dat",